-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathquery.ts
39 lines (31 loc) · 1.11 KB
/
query.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { ContractPromise } from "@polkadot/api-contract/promise";
import { ContractCall } from "../../lib/contractCall.js";
export class Query extends ContractCall<typeof Query> {
static description = "Call a query message on smart contract";
static args = { ...ContractCall.callArgs };
static flags = { ...ContractCall.callFlags };
public async run(): Promise<void> {
const { flags, args } = await this.parse(Query);
const contract = new ContractPromise(
this.api.apiInst,
this.metadata,
this.deploymentInfo.address
);
const storageDepositLimit = null;
const gasLimit: any = this.api.apiInst.registry.createType("WeightV2", {
refTime: BigInt(10000000000),
proofSize: BigInt(10000000000),
});
const queryResult = await contract.query[args.messageName](
this.account.pair.address,
{
gasLimit,
storageDepositLimit,
},
...flags.params
);
await this.api.apiInst.disconnect();
console.log(`Query result: ${queryResult.output?.toString()}`);
if (flags.verbose) console.log(queryResult.result.toHuman());
}
}