Skip to content

Instantly share code, notes, and snippets.

@SuperstrongBE
Last active April 7, 2024 08:14
Show Gist options
  • Save SuperstrongBE/ce0eb91fc4cfea3a4f463c6bb2087a07 to your computer and use it in GitHub Desktop.
Save SuperstrongBE/ce0eb91fc4cfea3a4f463c6bb2087a07 to your computer and use it in GitHub Desktop.
Abi2ts exemple
// Generating smart contract TS types definition from local abi file with abi2ts
// npx abi2ts betsxpr -f ./target/betxpr.contract.abi > ./tests/interfaces/betxpr.ts
describe("End prediction", () => {
it("Should pick resolvers 4 resolvers (resolverSeeds length + 1) ", async () => {
// {contractName}_actionParams<'{action_name}'> turn a typed action parameters object to an array
const predictionEndParams = betsxpr_actionParams<'gov.endpoll'>({
predictionKey: 0,
resolverSeeds:[0,1,2]
})
// The produced array {contractName}_actionParams<'{action_name}'> is used to feed VERt contract action
await betXPR.actions['gov.endpoll'](predictionEndParams).send(`${betXPR.name.toString()}@active`);
// abi2ts generate your tables structure, so all fields are easily accessible.
const prediction: betsxpr_Tables['PredictionTable'] = betXPR.tables.predictions().getTableRow(BigInt(0));
expect(prediction.resolvers.length).equal(4);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment