-
Notifications
You must be signed in to change notification settings - Fork 380
Expand file tree
/
Copy pathcheckTypes.manual.ts
More file actions
45 lines (32 loc) · 1.59 KB
/
checkTypes.manual.ts
File metadata and controls
45 lines (32 loc) · 1.59 KB
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
40
41
42
43
44
45
// Copyright 2017-2025 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
// Simple non-runnable checks to test type definitions in the editor itself
import '@polkadot/api-augment';
import type { TestKeyringMapSubstrate } from '@polkadot/keyring/testingPairs';
import { ApiPromise } from '@polkadot/api';
import { BlueprintPromise, ContractPromise } from '@polkadot/api-contract';
import { createTestPairs } from '@polkadot/keyring/testingPairs';
import abiIncrementer from './test/contracts/ink/v0/incrementer.json' assert { type: 'json' };
async function checkBlueprint (api: ApiPromise, pairs: TestKeyringMapSubstrate): Promise<void> {
const blueprint = new BlueprintPromise(api, abiIncrementer as Record<string, unknown>, '0x1234');
await blueprint.tx['new']({ gasLimit: 456, salt: '0x1234', value: 123 }, 42).signAndSend(pairs.bob);
await blueprint.tx['new']({ gasLimit: 456, value: 123 }, 42).signAndSend(pairs.bob);
}
async function checkContract (api: ApiPromise, pairs: TestKeyringMapSubstrate): Promise<void> {
const contract = new ContractPromise(api, abiIncrementer as Record<string, unknown>, '0x1234');
// queries
await contract.query['get'](pairs.alice.address, {});
// execute
await contract.tx['inc']({ gasLimit: 1234 }, 123).signAndSend(pairs.eve);
}
async function main (): Promise<void> {
const api = await ApiPromise.create({
hasher: (data: Uint8Array): Uint8Array => data
});
const pairs = createTestPairs();
await Promise.all([
checkBlueprint(api, pairs),
checkContract(api, pairs)
]);
}
main().catch(console.error);