Skip to content

Commit

Permalink
add execute method
Browse files Browse the repository at this point in the history
  • Loading branch information
Artemka374 committed Aug 14, 2023
1 parent d3ab126 commit 50ad406
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/e2e/governance/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import {Transaction, VoteType} from '../../../typechain-generated/types-argument
import ContractGovernance from '../../../typechain-generated/contracts/my_governor'
import {KeyringPair} from '@polkadot/keyring/types'
import {expect} from 'chai'
import {blake2b} from "@polkadot/wasm-crypto";
import {blake2AsU8a} from "@polkadot/util-crypto";

export class GovernorHelper {
private proposal: Transaction | undefined;
Expand Down Expand Up @@ -55,4 +57,14 @@ export class GovernorHelper {
const proposalDeadline = (await this.governor?.query.proposalDeadline(this.proposalId as unknown as number[]))?.value.unwrapRecursively().ok
await this.governor?.tx.setBlockTimestamp(proposalDeadline as number)
}

async execute(proposer: KeyringPair) {
if (this.proposalId === undefined) {
throw new Error('Proposal Id not set')
}

const descriptionHash = blake2AsU8a(this.description!) as unknown as number[]

await this.governor?.withSigner(proposer).tx.execute([this.proposal!], descriptionHash)
}
}

0 comments on commit 50ad406

Please sign in to comment.