Skip to content

Commit 938fbc7

Browse files
committed
chore: switch to link action in proposal state monitoring
1 parent 33c4b46 commit 938fbc7

File tree

1 file changed

+28
-25
lines changed

1 file changed

+28
-25
lines changed

β€Žsrc/proposal-state-monitoring.service.ts

+28-25
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ import {
1919
} from '@solana/spl-governance';
2020
import { CachingEventType, fmtTokenAmount, RealmMints } from './realms-cache';
2121
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';
2328
import { Solana } from '@dialectlabs/blockchain-sdk-solana';
2429
import { amountToShortString } from './formatting-utilts';
2530

@@ -141,22 +146,35 @@ export class ProposalStateChangeMonitoringService {
141146
): DialectSdkNotification {
142147
const realmName: string = realm.name;
143148
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+
};
144158
if (account.state === ProposalState.ExecutingWithErrors) {
145159
return {
146160
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,
148163
};
149164
}
150165
if (account.state === ProposalState.Cancelled) {
151166
return {
152167
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,
154170
};
155171
}
172+
156173
if (account.state === ProposalState.Completed) {
157174
return {
158175
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,
160178
};
161179
}
162180

@@ -172,16 +190,8 @@ export class ProposalStateChangeMonitoringService {
172190
account.name
173191
} for ${realmName} is succeeded with ${relativeYesCount.toFixed(
174192
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,
185195
};
186196
}
187197
if (account.state === ProposalState.Defeated) {
@@ -191,16 +201,8 @@ export class ProposalStateChangeMonitoringService {
191201
account.name
192202
} for ${realmName} is defeated with ${relativeNoCount.toFixed(
193203
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,
204206
};
205207
}
206208
return {
@@ -209,7 +211,8 @@ export class ProposalStateChangeMonitoringService {
209211
}`,
210212
message: `Proposal ${account.name} for ${realmName} is ${
211213
ProposalState[account.state]?.toString() ?? 'changed'
212-
}: ${proposalLink}`,
214+
}`,
215+
actions,
213216
};
214217
}
215218
}

0 commit comments

Comments
Β (0)