forked from broxus/ton-testing-suite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
req.js
91 lines (79 loc) · 3.07 KB
/
req.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
const giverConfig = require('./config/contracts/giverConfig');
const networkConfig = require('./config/general/networkConfig');
const seedPhraseConfig = require('./config/general/seedPhraseConfig');
const { abiContract } = require("@tonclient/core");
const freeton = require('./src');
const { address, abi } = require('./config/contracts/giverConfig');
const fs = require('fs');
const ton = new freeton.TonWrapper({
giverConfig: giverConfig,
network: networkConfig.network,
seed: seedPhraseConfig
});
aa = process.argv[2];
accountType = process.argv[3];
isInternal = process.argv[4] == '1' ? true : false;
incomingMessage = process.argv[5] == '1' ? 'dst' : 'src';
dirWithAbi = process.argv[6] ? process.argv[6] : './build/';
function loadAbi(type) {
if (type == 'w')
return JSON.parse(fs.readFileSync('build/TONTokenWallet.abi.json'));
if (type == 'p')
return JSON.parse(fs.readFileSync('build/SwapPairContract.abi.json'));
if (type == 'rpc')
return JSON.parse(fs.readFileSync('build/RootSwapPairContract.abi.json'));
if (type == 'tr')
return JSON.parse(fs.readFileSync('build/RootTokenContract.abi.json'));
if (type == 'wd')
return JSON.parse(fs.readFileSync('build/TONTokenWallet.abi.json'));
if (type == 'td')
return JSON.parse(fs.readFileSync('build/TIP3TokenDeployer.abi.json'));
}
async function main() {
await ton.setup(1);
await ton.ton.net.query_collection({
collection: 'accounts',
filter: {
id: { eq: aa }
},
result: 'balance acc_type'
}).then(console.log).catch(console.log);
abiA = loadAbi(accountType);
filter = {}
filter[incomingMessage] = { eq: aa };
try {
await ton.ton.net.query_collection({
collection: 'messages',
filter: filter,
order: [{
path: 'created_lt',
direction: 'ASC'
}],
result: "id created_lt msg_type status src dst value boc body" // "account_addr aborted total_fees" //
}).then(async s => s.result.forEach(async(el) => {
await ton.ton.abi.decode_message_body({
body: el.body,
is_internal: isInternal,
abi: abiContract(abiA)
}).then(k => {
console.log('################################################');
console.log(`source: ${el.src}`);
console.log(`destination: ${el.dst}`);
console.log(`value: ${el.value}`);
console.log(`status: ${el.status}`);
console.log(k);
}).catch(k => {
console.log('################################################');
console.log(`source: ${el.src}`);
console.log(`destination: ${el.dst}`);
console.log(`value: ${el.value}`);
console.log(`status: ${el.status}`);
console.log(`Cannot decode`);
});
})).catch(console.log);
} catch (err) {
console.log(err);
}
//process.exit(0);
}
main();