forked from etherspot/etherspot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03-contract-account.ts
63 lines (50 loc) · 1.39 KB
/
03-contract-account.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
import { Wallet } from 'ethers';
import { Sdk } from '../../src';
import { logger, topUpAccount, getBalance, randomAddress } from './common';
async function main(): Promise<void> {
const wallet = Wallet.createRandom();
logger.log('wallet', wallet.address);
const sdk = new Sdk(wallet);
const { state } = sdk;
logger.log('key account', state.account);
logger.log(
'contract account',
await sdk.computeContractAccount({
sync: false,
}),
);
await sdk.syncAccount();
logger.log('synced contract account', state.account);
logger.log('synced contract account member', state.accountMember);
logger.log(
'get account',
await sdk.getAccount({
address: state.accountAddress,
}),
);
logger.log(
'get account members',
await sdk.getAccountMembers({
account: state.accountAddress,
}),
);
await topUpAccount(state.accountAddress, '0.5');
logger.log('contract account balance', await getBalance(state.accountAddress));
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());