forked from etherspot/etherspot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path09-projects.ts
84 lines (68 loc) · 1.77 KB
/
09-projects.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import { Wallet } from 'ethers';
import { Sdk } from '../../src';
import { logger, topUpAccount, randomAddress, randomPrivateKey } from './common';
async function main(): Promise<void> {
const projectKey = `project${Date.now().toString(16)}`;
{
const wallet = Wallet.createRandom();
logger.log('project owner wallet', wallet.address);
const sdk = new Sdk(wallet);
logger.log(
'project',
await sdk.updateProject({
key: projectKey,
endpoint: 'http://localhost:4010/',
privateKey: randomPrivateKey(),
}),
);
}
{
const wallet = Wallet.createRandom();
logger.log('sender wallet', wallet.address);
const sdk = new Sdk(wallet, {
projectKey,
projectMetadata: 'test',
});
logger.log('project call', await sdk.callCurrentProject());
logger.log(
'project call with custom metadata',
await sdk.callCurrentProject({
customProjectMetadata: 'test2',
}),
);
logger.log(
'project call with payload',
await sdk.callCurrentProject({
payload: {
a: 1,
b: 2,
},
}),
);
const { state } = sdk;
logger.log(
'contract account',
await sdk.computeContractAccount({
sync: false,
}),
);
await topUpAccount(state.accountAddress, '0.5');
logger.log(
'batch #1',
await sdk.batchAddAccountOwner({
owner: randomAddress(),
}),
);
logger.log(
'batch #2',
await sdk.batchAddAccountOwner({
owner: randomAddress(),
}),
);
logger.log('estimated batch', await sdk.estimateGatewayBatch());
logger.log('submitted batch', await sdk.submitGatewayBatch());
}
}
main()
.catch(logger.error)
.finally(() => process.exit());