forked from near/multisig-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
base.js
38 lines (31 loc) · 983 Bytes
/
base.js
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
class MultisigBase {
constructor(masterAccount, receiverId) {
this.masterAccount = masterAccount;
this.receiverId = receiverId;
this.actions = [];
}
transfer = (amount) => {
this.actions.push({ type: "Transfer", amount });
return this;
}
functionCall = (methodName, args, deposit, gas) => {
this.actions.push({
"type": "FunctionCall",
"method_name": methodName,
"args": btoa(JSON.stringify(args)),
"deposit": deposit ? deposit : '0',
"gas": gas ? gas : '100000000000000'
});
return this;
}
finish = async () => {
console.log(`Creating request to ${this.receiverId}: ${this.actions}`);
return contract.functionCall(accountId, 'add_request', {
request: {
receiver_id: this.receiverId,
actions: this.actions
}
});
}
}
export { MultisigBase };