Skip to content

Commit

Permalink
feat(msig): add cancel action
Browse files Browse the repository at this point in the history
  • Loading branch information
deansallinen committed Dec 5, 2024
1 parent 23064fa commit 1d3ec71
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const load: LayoutLoad = async ({ fetch, params, parent }) => {
({ level }: { level?: PermissionLevel }) => (level ? PermissionLevel.from(level) : undefined)
);

// TODO: Use ABICache here to prevent duplicate calls
const actions = await Promise.all(
transaction.actions.map(async (a) => {
const { abi } = await network.client.v1.chain.get_abi(String(a.account));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
total_approvals.some((a) => wharf.session && a.equals(wharf.session.permissionLevel))
);
let userIsProposer = $derived(wharf.session?.actor.equals(Name.from(proposal.proposer)));
let transacting = $derived(manager.transacting);
let userHasApproved = $derived(manager.approved);
Expand All @@ -55,6 +57,7 @@
const handleApprove = () => manager.approve();
const handleUnapprove = () => manager.unapprove();
const handleExecute = () => manager.execute();
const handleCancel = () => manager.cancel();
</script>

<MultiCard>
Expand Down Expand Up @@ -143,6 +146,9 @@
{/if}
{/if}

{#if userIsProposer}
<Button variant="secondary" onclick={handleCancel}>Cancel MSIG</Button>
{/if}

<Button variant="primary" onclick={handleExecute}>Execute</Button>
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,17 @@ export class ApprovalManager {

this.transact(action);
}

async cancel() {
if (!this.network || !this.wharf || !this.wharf.session) {
throw new Error("Can't sign, data not ready");
}
const action = this.network.contracts.msig.action('cancel', {
proposer: Name.from(this.proposal.proposer),
proposal_name: Name.from(this.proposal.name),
canceler: this.wharf.session.actor
});

this.transact(action);
}
}

0 comments on commit 1d3ec71

Please sign in to comment.