Skip to content

Commit

Permalink
chore: switch to link action in proposal state monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
tsmbl committed Apr 29, 2024
1 parent 33c4b46 commit 938fbc7
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions src/proposal-state-monitoring.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ import {
} from '@solana/spl-governance';
import { CachingEventType, fmtTokenAmount, RealmMints } from './realms-cache';
import { OnEvent } from '@nestjs/event-emitter';
import { DappMessageActionType, DialectSdk } from '@dialectlabs/sdk';
import {
DappMessageActionType,
DappMessageLinkAction,

Check warning on line 24 in src/proposal-state-monitoring.service.ts

View workflow job for this annotation

GitHub Actions / Integration

'DappMessageLinkAction' is defined but never used
DappMessageLinksAction,
DialectSdk,
} from '@dialectlabs/sdk';
import { Solana } from '@dialectlabs/blockchain-sdk-solana';
import { amountToShortString } from './formatting-utilts';

Expand Down Expand Up @@ -141,22 +146,35 @@ export class ProposalStateChangeMonitoringService {
): DialectSdkNotification {
const realmName: string = realm.name;
const proposalLink = `https://realms.today/dao/${realmId}/proposal/${pubkey.toBase58()}`;
const actions: DappMessageLinksAction = {
type: DappMessageActionType.LINK,
links: [
{
label: 'View Proposal',
url: proposalLink,
},
],
};
if (account.state === ProposalState.ExecutingWithErrors) {
return {
title: `Proposal for ${realmName} is executing with errors`,
message: `Proposal ${account.name} for ${realmName} is executing with errors: ${proposalLink}`,
message: `Proposal ${account.name} for ${realmName} is executing with errors`,
actions,
};
}
if (account.state === ProposalState.Cancelled) {
return {
title: `Proposal for ${realmName} is canceled`,
message: `Proposal ${account.name} for ${realmName} is canceled: ${proposalLink}`,
message: `Proposal ${account.name} for ${realmName} is canceled`,
actions,
};
}

if (account.state === ProposalState.Completed) {
return {
title: `Proposal for ${realmName} is completed`,
message: `Proposal ${account.name} for ${realmName} is completed: ${proposalLink}`,
message: `Proposal ${account.name} for ${realmName} is completed`,
actions,
};
}

Expand All @@ -172,16 +190,8 @@ export class ProposalStateChangeMonitoringService {
account.name
} for ${realmName} is succeeded with ${relativeYesCount.toFixed(
1,
)}% of πŸ‘ votes (${yesVotesFormatted} πŸ‘ / ${noVotesFormatted} πŸ‘Ž): ${proposalLink}`,
actions: {
type: DappMessageActionType.LINK,
links: [
{
label: 'View Proposal',
url: proposalLink,
},
],
},
)}% of πŸ‘ votes (${yesVotesFormatted} πŸ‘ / ${noVotesFormatted} πŸ‘Ž)`,
actions,
};
}
if (account.state === ProposalState.Defeated) {
Expand All @@ -191,16 +201,8 @@ export class ProposalStateChangeMonitoringService {
account.name
} for ${realmName} is defeated with ${relativeNoCount.toFixed(
1,
)}% of πŸ‘Ž votes (${yesVotesFormatted} πŸ‘ / ${noVotesFormatted} πŸ‘Ž): ${proposalLink}`,
actions: {
type: DappMessageActionType.LINK,
links: [
{
label: 'View Proposal',
url: proposalLink,
},
],
},
)}% of πŸ‘Ž votes (${yesVotesFormatted} πŸ‘ / ${noVotesFormatted} πŸ‘Ž)`,
actions,
};
}
return {
Expand All @@ -209,7 +211,8 @@ export class ProposalStateChangeMonitoringService {
}`,
message: `Proposal ${account.name} for ${realmName} is ${
ProposalState[account.state]?.toString() ?? 'changed'
}: ${proposalLink}`,
}`,
actions,
};
}
}
Expand Down

0 comments on commit 938fbc7

Please sign in to comment.