-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_freeze.js
73 lines (60 loc) · 1.86 KB
/
test_freeze.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
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
let eosjs = require('eosjs');
const ecc = require('eosjs-ecc');
const httpEndpoint = 'https://api-kylin.eosasia.one';
const keyProvider = '';
let eos = eosjs({
keyProvider: keyProvider,
httpEndpoint: httpEndpoint,
chainId: "5fff1dae8dc8e2fc4d5b23b2c7665c97f9e9d8edf2b6485a86ba311c25639191", // kylin
sign: true
});
let contract_mgr = '';
let contract_logic = '';
let account_to = '';
let sign_action = 'freeze';
let sign_key_index = 0; // sign with admin key
(async() => {
let binArg1 = await eos.abiJsonToBin(contract_logic, sign_action, [account_to]);
let bin1 = binArg1["binargs"];
console.log("bin1:", bin1);
let res = await eos.getTableRows({
code:contract_mgr,
scope:account_to,
table:'keydata',
json: true
});
let row = res.rows[sign_key_index];
let key = row['key'];
let nonce = key['nonce'];
console.log(nonce);
let msg = account_to + ":" + sign_action + ":" + bin1 + ":" + nonce;
var digest = ecc.sha256(msg);
// let pub = key['pubkey'];
var privkey = '';
var sigstr = ecc.signHash(digest, privkey).toString();
console.log(sigstr);
let binArg2 = await eos.abiJsonToBin(contract_logic, 'sendinternal', [sign_action, sigstr, bin1]);
let bin2 = binArg2["binargs"];
console.log("bin2:", bin2);
eos.transaction({
actions: [
{
account: contract_mgr,
name: "sendaction",
authorization: [
{
actor: "",
permission: "active"
}
],
data: {
act: "sendinternal",
bin_data: bin2
}
}
]
})
.then(result => {
console.log("==========send action ok, result:", result);
});
})();