forked from broxus/ton-testing-suite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphql_checks.js
62 lines (53 loc) · 16 KB
/
graphql_checks.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
const giverConfig = require('./config/contracts/giverConfig');
const networkConfig = require('./config/general/networkConfig');
const seedPhraseConfig = require('./config/general/seedPhraseConfig');
const { TonClient, signerNone, abiContract } = require("@tonclient/core");
const freeton = require('./src');
const ton = new freeton.TonWrapper({
giverConfig: giverConfig,
network: networkConfig.network,
seed: seedPhraseConfig
});
a1 = process.argv[2];
a2 = process.argv[3];
async function main() {
await ton.setup(1);
await ton.ton.net.query_collection({
collection: 'accounts',
filter: {
id: { eq: a1 }
},
result: 'balance acc_type'
}).then(console.log).catch(console.log);
try {
await ton.ton.net.query_collection({
collection: 'messages',
filter: {
src: { eq: a1 },
//account_addr: { eq: a1 },
// dst: { eq: a2 }
},
result: "msg_type status src dst value boc body" // "account_addr aborted total_fees" //
}).then(async s => s.result.forEach(async(el) => {
//console.log(el.src))
//console.log(
await ton.ton.abi.decode_message_body({
body: el.body,
is_internal: true,
// // // // token
// // // abi: abiContract({ "ABI version": 2, "header": ["time", "expire"], "functions": [{ "name": "constructor", "inputs": [], "outputs": [] }, { "name": "getDetails", "inputs": [], "outputs": [{ "components": [{ "name": "name", "type": "bytes" }, { "name": "symbol", "type": "bytes" }, { "name": "decimals", "type": "uint8" }, { "name": "wallet_code", "type": "cell" }, { "name": "root_public_key", "type": "uint256" }, { "name": "root_owner_address", "type": "address" }, { "name": "total_supply", "type": "uint128" }, { "name": "start_gas_balance", "type": "uint128" }], "name": "value0", "type": "tuple" }] }, { "name": "getWalletAddress", "inputs": [{ "name": "wallet_public_key_", "type": "uint256" }, { "name": "owner_address_", "type": "address" }], "outputs": [{ "name": "value0", "type": "address" }] }, { "name": "deployWallet", "inputs": [{ "name": "tokens", "type": "uint128" }, { "name": "grams", "type": "uint128" }, { "name": "wallet_public_key_", "type": "uint256" }, { "name": "owner_address_", "type": "address" }, { "name": "gas_back_address", "type": "address" }], "outputs": [] }, { "name": "deployEmptyWallet", "inputs": [{ "name": "grams", "type": "uint128" }, { "name": "wallet_public_key_", "type": "uint256" }, { "name": "owner_address_", "type": "address" }, { "name": "gas_back_address", "type": "address" }], "outputs": [] }, { "name": "mint", "inputs": [{ "name": "tokens", "type": "uint128" }, { "name": "to", "type": "address" }], "outputs": [] }, { "name": "proxyBurn", "inputs": [{ "name": "tokens", "type": "uint128" }, { "name": "sender_address", "type": "address" }, { "name": "callback_address", "type": "address" }, { "name": "callback_payload", "type": "cell" }], "outputs": [] }, { "name": "tokensBurned", "inputs": [{ "name": "tokens", "type": "uint128" }, { "name": "sender_public_key", "type": "uint256" }, { "name": "sender_address", "type": "address" }, { "name": "callback_address", "type": "address" }, { "name": "callback_payload", "type": "cell" }], "outputs": [] }, { "name": "withdrawExtraGas", "inputs": [], "outputs": [] }, { "name": "name", "inputs": [], "outputs": [{ "name": "name", "type": "bytes" }] }, { "name": "symbol", "inputs": [], "outputs": [{ "name": "symbol", "type": "bytes" }] }, { "name": "decimals", "inputs": [], "outputs": [{ "name": "decimals", "type": "uint8" }] }, { "name": "wallet_code", "inputs": [], "outputs": [{ "name": "wallet_code", "type": "cell" }] }, { "name": "total_supply", "inputs": [], "outputs": [{ "name": "total_supply", "type": "uint128" }] }, { "name": "start_gas_balance", "inputs": [], "outputs": [{ "name": "start_gas_balance", "type": "uint128" }] }], "data": [{ "key": 1, "name": "_randomNonce", "type": "uint256" }, { "key": 2, "name": "name", "type": "bytes" }, { "key": 3, "name": "symbol", "type": "bytes" }, { "key": 4, "name": "decimals", "type": "uint8" }, { "key": 5, "name": "wallet_code", "type": "cell" }, { "key": 6, "name": "root_public_key", "type": "uint256" }, { "key": 7, "name": "root_owner_address", "type": "address" }], "events": [] })
// pair
abi: abiContract({ "ABI version": 2, "header": ["pubkey", "time", "expire"], "functions": [{ "name": "constructor", "inputs": [{ "name": "rootContract", "type": "address" }, { "name": "spd", "type": "uint256" }], "outputs": [] }, { "name": "_reinitialize", "inputs": [], "outputs": [] }, { "name": "withdrawTONs", "inputs": [{ "name": "tonDestination", "type": "address" }, { "name": "amount", "type": "uint128" }], "outputs": [] }, { "name": "getCreationTimestamp", "inputs": [], "outputs": [{ "name": "value0", "type": "uint256" }] }, { "name": "getLPComission", "inputs": [], "outputs": [{ "name": "value0", "type": "uint128" }] }, { "name": "getPairInfo", "inputs": [], "outputs": [{ "components": [{ "name": "rootContract", "type": "address" }, { "name": "tokenRoot1", "type": "address" }, { "name": "tokenRoot2", "type": "address" }, { "name": "tokenWallet1", "type": "address" }, { "name": "tokenWallet2", "type": "address" }, { "name": "deployerPubkey", "type": "uint256" }, { "name": "deployTimestamp", "type": "uint256" }, { "name": "swapPairAddress", "type": "address" }, { "name": "uniqueId", "type": "uint256" }, { "name": "swapPairCodeVersion", "type": "uint32" }], "name": "info", "type": "tuple" }] }, { "name": "getUserBalance", "inputs": [{ "name": "pubkey", "type": "uint256" }], "outputs": [{ "components": [{ "name": "tokenRoot1", "type": "address" }, { "name": "tokenRoot2", "type": "address" }, { "name": "tokenBalance1", "type": "uint128" }, { "name": "tokenBalance2", "type": "uint128" }], "name": "ubi", "type": "tuple" }] }, { "name": "getUserTONBalance", "inputs": [{ "name": "pubkey", "type": "uint256" }], "outputs": [{ "name": "balance", "type": "uint256" }] }, { "name": "getUserLiquidityPoolBalance", "inputs": [{ "name": "pubkey", "type": "uint256" }], "outputs": [{ "components": [{ "name": "tokenRoot1", "type": "address" }, { "name": "tokenRoot2", "type": "address" }, { "name": "userLiquidityTokenBalance", "type": "uint256" }, { "name": "liquidityTokensMinted", "type": "uint256" }, { "name": "lpToken1", "type": "uint128" }, { "name": "lpToken2", "type": "uint128" }], "name": "upi", "type": "tuple" }] }, { "name": "getExchangeRate", "inputs": [{ "name": "swappableTokenRoot", "type": "address" }, { "name": "swappableTokenAmount", "type": "uint128" }], "outputs": [{ "components": [{ "name": "swappableTokenAmount", "type": "uint128" }, { "name": "targetTokenAmount", "type": "uint128" }, { "name": "fee", "type": "uint128" }], "name": "value0", "type": "tuple" }] }, { "name": "getCurrentExchangeRate", "inputs": [], "outputs": [{ "name": "value0", "type": "uint128" }, { "name": "value1", "type": "uint128" }] }, { "name": "getProvidingLiquidityInfo", "inputs": [{ "name": "maxFirstTokenAmount", "type": "uint128" }, { "name": "maxSecondTokenAmount", "type": "uint128" }], "outputs": [{ "name": "providedFirstTokenAmount", "type": "uint128" }, { "name": "providedSecondTokenAmount", "type": "uint128" }] }, { "name": "getWithdrawingLiquidityInfo", "inputs": [{ "name": "liquidityTokensAmount", "type": "uint256" }], "outputs": [{ "name": "withdrawedFirstTokenAmount", "type": "uint128" }, { "name": "withdrawedSecondTokenAmount", "type": "uint128" }] }, { "name": "getAnotherTokenProvidingAmount", "inputs": [{ "name": "providingTokenRoot", "type": "address" }, { "name": "providingTokenAmount", "type": "uint128" }], "outputs": [{ "name": "anotherTokenAmount", "type": "uint128" }] }, { "name": "provideLiquidity", "inputs": [{ "name": "maxFirstTokenAmount", "type": "uint128" }, { "name": "maxSecondTokenAmount", "type": "uint128" }], "outputs": [{ "name": "providedFirstTokenAmount", "type": "uint128" }, { "name": "providedSecondTokenAmount", "type": "uint128" }] }, { "name": "withdrawLiquidity", "inputs": [{ "name": "liquidityTokensAmount", "type": "uint256" }], "outputs": [{ "name": "withdrawedFirstTokenAmount", "type": "uint128" }, { "name": "withdrawedSecondTokenAmount", "type": "uint128" }] }, { "name": "swap", "inputs": [{ "name": "swappableTokenRoot", "type": "address" }, { "name": "swappableTokenAmount", "type": "uint128" }], "outputs": [{ "components": [{ "name": "swappableTokenAmount", "type": "uint128" }, { "name": "targetTokenAmount", "type": "uint128" }, { "name": "fee", "type": "uint128" }], "name": "value0", "type": "tuple" }] }, { "name": "withdrawTokens", "inputs": [{ "name": "withdrawalTokenRoot", "type": "address" }, { "name": "receiveTokenWallet", "type": "address" }, { "name": "amount", "type": "uint128" }], "outputs": [] }, { "name": "transfer", "inputs": [{ "name": "receiver", "type": "uint256" }, { "name": "amount", "type": "uint256" }], "outputs": [] }, { "name": "getBalance", "inputs": [{ "name": "pubkey", "type": "uint256" }], "outputs": [{ "name": "value0", "type": "uint256" }] }, { "name": "_rebalance", "inputs": [{ "name": "balance", "type": "uint128" }], "outputs": [] }, { "name": "_rebalanceGetters", "inputs": [{ "name": "balance", "type": "uint128" }], "outputs": [] }, { "name": "_rebalanceERC20", "inputs": [{ "name": "balance", "type": "uint128" }], "outputs": [] }, { "name": "getWalletAddressCallback", "inputs": [{ "name": "walletAddress", "type": "address" }], "outputs": [] }, { "name": "tokensReceivedCallback", "inputs": [{ "name": "token_wallet", "type": "address" }, { "name": "token_root", "type": "address" }, { "name": "amount", "type": "uint128" }, { "name": "sender_public_key", "type": "uint256" }, { "name": "sender_address", "type": "address" }, { "name": "sender_wallet", "type": "address" }, { "name": "original_gas_to", "type": "address" }, { "name": "updated_balance", "type": "uint128" }, { "name": "payload", "type": "cell" }], "outputs": [] }, { "name": "updateSwapPairCode", "inputs": [{ "name": "newCode", "type": "cell" }, { "name": "newCodeVersion", "type": "uint32" }], "outputs": [] }, { "name": "checkIfSwapPairUpgradeRequired", "inputs": [{ "name": "newCodeVersion", "type": "uint32" }], "outputs": [{ "name": "value0", "type": "bool" }] }, { "name": "kLast", "inputs": [], "outputs": [{ "name": "kLast", "type": "uint256" }] }], "data": [{ "key": 1, "name": "token1", "type": "address" }, { "key": 2, "name": "token2", "type": "address" }, { "key": 3, "name": "swapPairID", "type": "uint256" }], "events": [] })
// // // wallet
// // abi: abiContract({ "ABI version": 2, "header": ["time", "expire"], "functions": [{ "name": "constructor", "inputs": [], "outputs": [] }, { "name": "getDetails", "inputs": [], "outputs": [{ "components": [{ "name": "root_address", "type": "address" }, { "name": "code", "type": "cell" }, { "name": "wallet_public_key", "type": "uint256" }, { "name": "owner_address", "type": "address" }, { "name": "balance", "type": "uint128" }], "name": "value0", "type": "tuple" }] }, { "name": "accept", "inputs": [{ "name": "tokens", "type": "uint128" }], "outputs": [] }, { "name": "allowance", "inputs": [], "outputs": [{ "components": [{ "name": "remaining_tokens", "type": "uint128" }, { "name": "spender", "type": "address" }], "name": "value0", "type": "tuple" }] }, { "name": "approve", "inputs": [{ "name": "spender", "type": "address" }, { "name": "remaining_tokens", "type": "uint128" }, { "name": "tokens", "type": "uint128" }], "outputs": [] }, { "name": "disapprove", "inputs": [], "outputs": [] }, { "name": "transferToRecipient", "inputs": [{ "name": "recipient_public_key", "type": "uint256" }, { "name": "recipient_address", "type": "address" }, { "name": "tokens", "type": "uint128" }, { "name": "deploy_grams", "type": "uint128" }, { "name": "transfer_grams", "type": "uint128" }], "outputs": [] }, { "name": "transferToRecipientWithNotify", "inputs": [{ "name": "recipient_public_key", "type": "uint256" }, { "name": "recipient_address", "type": "address" }, { "name": "tokens", "type": "uint128" }, { "name": "deploy_grams", "type": "uint128" }, { "name": "transfer_grams", "type": "uint128" }, { "name": "payload", "type": "cell" }], "outputs": [] }, { "name": "transfer", "inputs": [{ "name": "to", "type": "address" }, { "name": "tokens", "type": "uint128" }, { "name": "grams", "type": "uint128" }], "outputs": [] }, { "name": "transferWithNotify", "inputs": [{ "name": "to", "type": "address" }, { "name": "tokens", "type": "uint128" }, { "name": "grams", "type": "uint128" }, { "name": "payload", "type": "cell" }], "outputs": [] }, { "name": "transferFrom", "inputs": [{ "name": "from", "type": "address" }, { "name": "to", "type": "address" }, { "name": "tokens", "type": "uint128" }, { "name": "grams", "type": "uint128" }], "outputs": [] }, { "name": "transferFromWithNotify", "inputs": [{ "name": "from", "type": "address" }, { "name": "to", "type": "address" }, { "name": "tokens", "type": "uint128" }, { "name": "grams", "type": "uint128" }, { "name": "payload", "type": "cell" }], "outputs": [] }, { "name": "internalTransfer", "inputs": [{ "name": "tokens", "type": "uint128" }, { "name": "sender_public_key", "type": "uint256" }, { "name": "sender_address", "type": "address" }, { "name": "send_gas_to", "type": "address" }, { "name": "notify_receiver", "type": "bool" }, { "name": "payload", "type": "cell" }], "outputs": [] }, { "name": "internalTransferFrom", "inputs": [{ "name": "to", "type": "address" }, { "name": "tokens", "type": "uint128" }, { "name": "send_gas_to", "type": "address" }, { "name": "notify_receiver", "type": "bool" }, { "name": "payload", "type": "cell" }], "outputs": [] }, { "name": "burnByOwner", "inputs": [{ "name": "tokens", "type": "uint128" }, { "name": "grams", "type": "uint128" }, { "name": "callback_address", "type": "address" }, { "name": "callback_payload", "type": "cell" }], "outputs": [] }, { "name": "burnByRoot", "inputs": [{ "name": "tokens", "type": "uint128" }, { "name": "callback_address", "type": "address" }, { "name": "callback_payload", "type": "cell" }], "outputs": [] }, { "name": "setReceiveCallback", "inputs": [{ "name": "receive_callback_", "type": "address" }], "outputs": [] }, { "name": "destroy", "inputs": [{ "name": "gas_dest", "type": "address" }], "outputs": [] }, { "name": "balance", "inputs": [], "outputs": [{ "name": "balance", "type": "uint128" }] }, { "name": "receive_callback", "inputs": [], "outputs": [{ "name": "receive_callback", "type": "address" }] }, { "name": "target_gas_balance", "inputs": [], "outputs": [{ "name": "target_gas_balance", "type": "uint128" }] }], "data": [{ "key": 1, "name": "root_address", "type": "address" }, { "key": 2, "name": "code", "type": "cell" }, { "key": 3, "name": "wallet_public_key", "type": "uint256" }, { "key": 4, "name": "owner_address", "type": "address" }], "events": [] })б
// TON Handler
// abi: abiContract({ "ABI version": 2, "header": ["pubkey", "time", "expire"], "functions": [{ "name": "constructor", "inputs": [], "outputs": [] }, { "name": "t", "inputs": [], "outputs": [{ "name": "value0", "type": "uint256" }] }, { "name": "sendTONTo", "inputs": [{ "name": "dest", "type": "address" }, { "name": "amount", "type": "uint128" }], "outputs": [] }, { "name": "getPk", "inputs": [], "outputs": [{ "name": "value0", "type": "uint256" }] }, { "name": "getPkCell", "inputs": [], "outputs": [{ "name": "value0", "type": "cell" }] }, { "name": "tf", "inputs": [{ "name": "tc", "type": "cell" }], "outputs": [{ "name": "value0", "type": "bytes" }] }, { "name": "stoiTest", "inputs": [{ "name": "a", "type": "bytes" }], "outputs": [{ "name": "value0", "type": "uint256" }, { "name": "value1", "type": "bool" }] }], "data": [{ "key": 1, "name": "_randomNonce", "type": "uint256" }], "events": [] })
}).then(console.log).catch(console.log)
//el.aborted, el.total_fees, el.dst, el.status);
})).catch(console.log);
} catch (err) {
console.log(err);
}
//process.exit(0);
}
main();