@@ -19,7 +19,12 @@ import {
19
19
} from '@solana/spl-governance' ;
20
20
import { CachingEventType , fmtTokenAmount , RealmMints } from './realms-cache' ;
21
21
import { OnEvent } from '@nestjs/event-emitter' ;
22
- import { DappMessageActionType , DialectSdk } from '@dialectlabs/sdk' ;
22
+ import {
23
+ DappMessageActionType ,
24
+ DappMessageLinkAction ,
25
+ DappMessageLinksAction ,
26
+ DialectSdk ,
27
+ } from '@dialectlabs/sdk' ;
23
28
import { Solana } from '@dialectlabs/blockchain-sdk-solana' ;
24
29
import { amountToShortString } from './formatting-utilts' ;
25
30
@@ -141,22 +146,35 @@ export class ProposalStateChangeMonitoringService {
141
146
) : DialectSdkNotification {
142
147
const realmName : string = realm . name ;
143
148
const proposalLink = `https://realms.today/dao/${ realmId } /proposal/${ pubkey . toBase58 ( ) } ` ;
149
+ const actions : DappMessageLinksAction = {
150
+ type : DappMessageActionType . LINK ,
151
+ links : [
152
+ {
153
+ label : 'View Proposal' ,
154
+ url : proposalLink ,
155
+ } ,
156
+ ] ,
157
+ } ;
144
158
if ( account . state === ProposalState . ExecutingWithErrors ) {
145
159
return {
146
160
title : `Proposal for ${ realmName } is executing with errors` ,
147
- message : `Proposal ${ account . name } for ${ realmName } is executing with errors: ${ proposalLink } ` ,
161
+ message : `Proposal ${ account . name } for ${ realmName } is executing with errors` ,
162
+ actions,
148
163
} ;
149
164
}
150
165
if ( account . state === ProposalState . Cancelled ) {
151
166
return {
152
167
title : `Proposal for ${ realmName } is canceled` ,
153
- message : `Proposal ${ account . name } for ${ realmName } is canceled: ${ proposalLink } ` ,
168
+ message : `Proposal ${ account . name } for ${ realmName } is canceled` ,
169
+ actions,
154
170
} ;
155
171
}
172
+
156
173
if ( account . state === ProposalState . Completed ) {
157
174
return {
158
175
title : `Proposal for ${ realmName } is completed` ,
159
- message : `Proposal ${ account . name } for ${ realmName } is completed: ${ proposalLink } ` ,
176
+ message : `Proposal ${ account . name } for ${ realmName } is completed` ,
177
+ actions,
160
178
} ;
161
179
}
162
180
@@ -172,16 +190,8 @@ export class ProposalStateChangeMonitoringService {
172
190
account . name
173
191
} for ${ realmName } is succeeded with ${ relativeYesCount . toFixed (
174
192
1 ,
175
- ) } % of π votes (${ yesVotesFormatted } π / ${ noVotesFormatted } π): ${ proposalLink } `,
176
- actions : {
177
- type : DappMessageActionType . LINK ,
178
- links : [
179
- {
180
- label : 'View Proposal' ,
181
- url : proposalLink ,
182
- } ,
183
- ] ,
184
- } ,
193
+ ) } % of π votes (${ yesVotesFormatted } π / ${ noVotesFormatted } π)`,
194
+ actions,
185
195
} ;
186
196
}
187
197
if ( account . state === ProposalState . Defeated ) {
@@ -191,16 +201,8 @@ export class ProposalStateChangeMonitoringService {
191
201
account . name
192
202
} for ${ realmName } is defeated with ${ relativeNoCount . toFixed (
193
203
1 ,
194
- ) } % of π votes (${ yesVotesFormatted } π / ${ noVotesFormatted } π): ${ proposalLink } `,
195
- actions : {
196
- type : DappMessageActionType . LINK ,
197
- links : [
198
- {
199
- label : 'View Proposal' ,
200
- url : proposalLink ,
201
- } ,
202
- ] ,
203
- } ,
204
+ ) } % of π votes (${ yesVotesFormatted } π / ${ noVotesFormatted } π)`,
205
+ actions,
204
206
} ;
205
207
}
206
208
return {
@@ -209,7 +211,8 @@ export class ProposalStateChangeMonitoringService {
209
211
} `,
210
212
message : `Proposal ${ account . name } for ${ realmName } is ${
211
213
ProposalState [ account . state ] ?. toString ( ) ?? 'changed'
212
- } : ${ proposalLink } `,
214
+ } `,
215
+ actions,
213
216
} ;
214
217
}
215
218
}
0 commit comments