@ton/ton 16.0.0 → 16.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -11
- package/dist/client/TonClient.d.ts +6 -6
- package/dist/client/TonClient.js +105 -80
- package/dist/client/TonClient4.d.ts +1 -1
- package/dist/client/TonClient4.js +227 -138
- package/dist/client/api/HttpApi.d.ts +122 -122
- package/dist/client/api/HttpApi.js +103 -72
- package/dist/client/api/TonCache.js +3 -3
- package/dist/config/ConfigParser.d.ts +221 -409
- package/dist/config/ConfigParser.js +407 -89
- package/dist/elector/ElectorContract.js +46 -20
- package/dist/index.d.ts +22 -22
- package/dist/index.js +2 -1
- package/dist/jetton/JettonMaster.js +5 -3
- package/dist/jetton/JettonWallet.js +2 -2
- package/dist/multisig/MultisigOrder.d.ts +2 -2
- package/dist/multisig/MultisigOrder.js +1 -1
- package/dist/multisig/MultisigOrderBuilder.d.ts +2 -2
- package/dist/multisig/MultisigOrderBuilder.js +1 -1
- package/dist/multisig/MultisigWallet.d.ts +3 -3
- package/dist/multisig/MultisigWallet.js +8 -8
- package/dist/utils/createTestClient.d.ts +1 -1
- package/dist/utils/createTestClient.js +6 -2
- package/dist/utils/createTestClient4.d.ts +1 -1
- package/dist/utils/createTestClient4.js +5 -1
- package/dist/utils/fees.d.ts +2 -2
- package/dist/utils/fees.js +21 -6
- package/dist/utils/{randomTestKey.d.ts → testUtils.d.ts} +2 -0
- package/dist/utils/testUtils.js +21 -0
- package/dist/utils/testWallets.d.ts +10 -10
- package/dist/utils/time.js +5 -3
- package/dist/utils/toUrlSafe.js +6 -6
- package/dist/wallets/WalletContractV1R1.d.ts +1 -57
- package/dist/wallets/WalletContractV1R1.js +15 -99
- package/dist/wallets/WalletContractV1R2.d.ts +1 -57
- package/dist/wallets/WalletContractV1R2.js +15 -100
- package/dist/wallets/WalletContractV1R3.d.ts +1 -57
- package/dist/wallets/WalletContractV1R3.js +15 -99
- package/dist/wallets/WalletContractV2R1.d.ts +1 -59
- package/dist/wallets/WalletContractV2R1.js +15 -101
- package/dist/wallets/WalletContractV2R2.d.ts +1 -59
- package/dist/wallets/WalletContractV2R2.js +15 -101
- package/dist/wallets/WalletContractV3R1.d.ts +1 -56
- package/dist/wallets/WalletContractV3R1.js +15 -103
- package/dist/wallets/WalletContractV3R2.d.ts +1 -56
- package/dist/wallets/WalletContractV3R2.js +15 -103
- package/dist/wallets/WalletContractV4.d.ts +2 -2
- package/dist/wallets/WalletContractV5Beta.d.ts +3 -3
- package/dist/wallets/WalletContractV5R1.d.ts +3 -3
- package/dist/wallets/signing/createWalletTransfer.d.ts +11 -3
- package/dist/wallets/signing/createWalletTransfer.js +18 -15
- package/dist/wallets/signing/singer.d.ts +2 -1
- package/dist/wallets/signing/singer.js +11 -5
- package/dist/wallets/v1/r1.d.ts +59 -0
- package/dist/wallets/v1/r1.js +103 -0
- package/dist/wallets/v1/r2.d.ts +59 -0
- package/dist/wallets/v1/r2.js +104 -0
- package/dist/wallets/v1/r3.d.ts +59 -0
- package/dist/wallets/v1/r3.js +103 -0
- package/dist/wallets/v2/r1.d.ts +61 -0
- package/dist/wallets/v2/r1.js +107 -0
- package/dist/wallets/v2/r2.d.ts +61 -0
- package/dist/wallets/v2/r2.js +107 -0
- package/dist/wallets/v3/r1.d.ts +58 -0
- package/dist/wallets/v3/r1.js +109 -0
- package/dist/wallets/v3/r2.d.ts +58 -0
- package/dist/wallets/v3/r2.js +109 -0
- package/dist/wallets/v4/WalletContractV4.d.ts +4 -2
- package/dist/wallets/v4/WalletContractV4.js +36 -32
- package/dist/wallets/v4/WalletContractV4Actions.d.ts +4 -4
- package/dist/wallets/v4/WalletContractV4Actions.js +10 -10
- package/dist/wallets/v5beta/WalletContractV5Beta.d.ts +7 -5
- package/dist/wallets/v5beta/WalletContractV5Beta.js +44 -28
- package/dist/wallets/v5beta/WalletV5BetaActions.d.ts +1 -1
- package/dist/wallets/v5beta/WalletV5BetaActions.js +25 -18
- package/dist/wallets/v5beta/WalletV5BetaWalletId.d.ts +2 -2
- package/dist/wallets/v5beta/WalletV5BetaWalletId.js +6 -4
- package/dist/wallets/v5beta/WalletV5OutActions.d.ts +4 -4
- package/dist/wallets/v5beta/WalletV5OutActions.js +3 -1
- package/dist/wallets/v5r1/WalletContractV5R1.d.ts +10 -6
- package/dist/wallets/v5r1/WalletContractV5R1.js +55 -36
- package/dist/wallets/v5r1/WalletV5R1Actions.d.ts +3 -3
- package/dist/wallets/v5r1/WalletV5R1Actions.js +32 -25
- package/dist/wallets/v5r1/WalletV5R1WalletId.d.ts +2 -2
- package/dist/wallets/v5r1/WalletV5R1WalletId.js +16 -10
- package/package.json +62 -65
- package/dist/client/TonClient.spec.d.ts +0 -1
- package/dist/client/TonClient.spec.js +0 -59
- package/dist/client/TonClient4.spec.d.ts +0 -1
- package/dist/client/TonClient4.spec.js +0 -67
- package/dist/config/ConfigParser.spec.d.ts +0 -8
- package/dist/config/ConfigParser.spec.js +0 -137
- package/dist/elector/ElectorContract.spec.d.ts +0 -8
- package/dist/elector/ElectorContract.spec.js +0 -104
- package/dist/jetton/JettonMaster.spec.d.ts +0 -8
- package/dist/jetton/JettonMaster.spec.js +0 -27
- package/dist/multisig/MultisigOrder.spec.d.ts +0 -1
- package/dist/multisig/MultisigOrder.spec.js +0 -139
- package/dist/multisig/MultisigWallet.spec.d.ts +0 -1
- package/dist/multisig/MultisigWallet.spec.js +0 -248
- package/dist/utils/fees.spec.d.ts +0 -1
- package/dist/utils/fees.spec.js +0 -83
- package/dist/utils/randomTestKey.js +0 -23
- package/dist/wallets/WalletContractV1R1.spec.d.ts +0 -8
- package/dist/wallets/WalletContractV1R1.spec.js +0 -67
- package/dist/wallets/WalletContractV1R2.spec.d.ts +0 -8
- package/dist/wallets/WalletContractV1R2.spec.js +0 -67
- package/dist/wallets/WalletContractV1R3.spec.d.ts +0 -8
- package/dist/wallets/WalletContractV1R3.spec.js +0 -44
- package/dist/wallets/WalletContractV2R1.spec.d.ts +0 -8
- package/dist/wallets/WalletContractV2R1.spec.js +0 -67
- package/dist/wallets/WalletContractV2R2.spec.d.ts +0 -8
- package/dist/wallets/WalletContractV2R2.spec.js +0 -67
- package/dist/wallets/WalletContractV3R1.spec.d.ts +0 -8
- package/dist/wallets/WalletContractV3R1.spec.js +0 -67
- package/dist/wallets/WalletContractV3R2.spec.d.ts +0 -8
- package/dist/wallets/WalletContractV3R2.spec.js +0 -67
- package/dist/wallets/v4/WalletContractV4.spec.d.ts +0 -8
- package/dist/wallets/v4/WalletContractV4.spec.js +0 -157
- package/dist/wallets/v4/WalletContractV4Actions.spec.d.ts +0 -1
- package/dist/wallets/v4/WalletContractV4Actions.spec.js +0 -74
- package/dist/wallets/v5beta/WalletContractV5Beta.spec.d.ts +0 -8
- package/dist/wallets/v5beta/WalletContractV5Beta.spec.js +0 -317
- package/dist/wallets/v5beta/WalletV5BetaActions.spec.d.ts +0 -1
- package/dist/wallets/v5beta/WalletV5BetaActions.spec.js +0 -166
- package/dist/wallets/v5beta/WalletV5BetaWalletId.spec.d.ts +0 -1
- package/dist/wallets/v5beta/WalletV5BetaWalletId.spec.js +0 -68
- package/dist/wallets/v5r1/WalletContractV5R1.spec.d.ts +0 -8
- package/dist/wallets/v5r1/WalletContractV5R1.spec.js +0 -340
- package/dist/wallets/v5r1/WalletV5R1Actions.spec.d.ts +0 -1
- package/dist/wallets/v5r1/WalletV5R1Actions.spec.js +0 -262
- package/dist/wallets/v5r1/WalletV5R1WalletId.spec.d.ts +0 -1
- package/dist/wallets/v5r1/WalletV5R1WalletId.spec.js +0 -103
|
@@ -15,68 +15,72 @@ const TonCache_1 = require("./TonCache");
|
|
|
15
15
|
const dataloader_1 = __importDefault(require("dataloader"));
|
|
16
16
|
const axios_1 = __importDefault(require("axios"));
|
|
17
17
|
const zod_1 = require("zod");
|
|
18
|
-
const version = require(
|
|
18
|
+
const version = require("../../../package.json").version;
|
|
19
19
|
const blockIdExt = zod_1.z.object({
|
|
20
|
-
|
|
20
|
+
"@type": zod_1.z.literal("ton.blockIdExt"),
|
|
21
21
|
workchain: zod_1.z.number(),
|
|
22
22
|
shard: zod_1.z.string(),
|
|
23
23
|
seqno: zod_1.z.number(),
|
|
24
24
|
root_hash: zod_1.z.string(),
|
|
25
|
-
file_hash: zod_1.z.string()
|
|
25
|
+
file_hash: zod_1.z.string(),
|
|
26
26
|
});
|
|
27
27
|
const addressInformation = zod_1.z.object({
|
|
28
28
|
balance: zod_1.z.union([zod_1.z.number(), zod_1.z.string()]),
|
|
29
29
|
extra_currencies: zod_1.z.optional(zod_1.z.array(zod_1.z.object({
|
|
30
|
-
|
|
30
|
+
"@type": zod_1.z.literal("extraCurrency"),
|
|
31
31
|
id: zod_1.z.number(),
|
|
32
|
-
amount: zod_1.z.string()
|
|
32
|
+
amount: zod_1.z.string(),
|
|
33
33
|
}))),
|
|
34
|
-
state: zod_1.z.union([
|
|
34
|
+
state: zod_1.z.union([
|
|
35
|
+
zod_1.z.literal("active"),
|
|
36
|
+
zod_1.z.literal("uninitialized"),
|
|
37
|
+
zod_1.z.literal("frozen"),
|
|
38
|
+
]),
|
|
35
39
|
data: zod_1.z.string(),
|
|
36
40
|
code: zod_1.z.string(),
|
|
37
41
|
last_transaction_id: zod_1.z.object({
|
|
38
|
-
|
|
42
|
+
"@type": zod_1.z.literal("internal.transactionId"),
|
|
39
43
|
lt: zod_1.z.string(),
|
|
40
|
-
hash: zod_1.z.string()
|
|
44
|
+
hash: zod_1.z.string(),
|
|
41
45
|
}),
|
|
42
46
|
block_id: blockIdExt,
|
|
43
|
-
sync_utime: zod_1.z.number()
|
|
47
|
+
sync_utime: zod_1.z.number(),
|
|
44
48
|
});
|
|
45
49
|
const bocResponse = zod_1.z.object({
|
|
46
|
-
|
|
50
|
+
"@type": zod_1.z.literal("ok"),
|
|
47
51
|
});
|
|
48
52
|
const feeResponse = zod_1.z.object({
|
|
49
|
-
|
|
53
|
+
"@type": zod_1.z.literal("query.fees"),
|
|
50
54
|
source_fees: zod_1.z.object({
|
|
51
|
-
|
|
55
|
+
"@type": zod_1.z.literal("fees"),
|
|
52
56
|
in_fwd_fee: zod_1.z.number(),
|
|
53
57
|
storage_fee: zod_1.z.number(),
|
|
54
58
|
gas_fee: zod_1.z.number(),
|
|
55
|
-
fwd_fee: zod_1.z.number()
|
|
56
|
-
})
|
|
59
|
+
fwd_fee: zod_1.z.number(),
|
|
60
|
+
}),
|
|
57
61
|
});
|
|
58
62
|
const callGetMethod = zod_1.z.object({
|
|
59
63
|
gas_used: zod_1.z.number(),
|
|
60
64
|
exit_code: zod_1.z.number(),
|
|
61
|
-
stack: zod_1.z.array(zod_1.z.unknown())
|
|
65
|
+
stack: zod_1.z.array(zod_1.z.unknown()),
|
|
62
66
|
});
|
|
63
67
|
const messageData = zod_1.z.union([
|
|
64
68
|
zod_1.z.object({
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
"@type": zod_1.z.literal("msg.dataRaw"),
|
|
70
|
+
body: zod_1.z.string(),
|
|
67
71
|
}),
|
|
68
72
|
zod_1.z.object({
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
"@type": zod_1.z.literal("msg.dataText"),
|
|
74
|
+
text: zod_1.z.string(),
|
|
71
75
|
}),
|
|
72
76
|
zod_1.z.object({
|
|
73
|
-
|
|
74
|
-
|
|
77
|
+
"@type": zod_1.z.literal("msg.dataDecryptedText"),
|
|
78
|
+
text: zod_1.z.string(),
|
|
75
79
|
}),
|
|
76
80
|
zod_1.z.object({
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
})
|
|
81
|
+
"@type": zod_1.z.literal("msg.dataEncryptedText"),
|
|
82
|
+
text: zod_1.z.string(),
|
|
83
|
+
}),
|
|
80
84
|
]);
|
|
81
85
|
const message = zod_1.z.object({
|
|
82
86
|
source: zod_1.z.string(),
|
|
@@ -87,42 +91,42 @@ const message = zod_1.z.object({
|
|
|
87
91
|
created_lt: zod_1.z.string(),
|
|
88
92
|
body_hash: zod_1.z.string(),
|
|
89
93
|
msg_data: messageData,
|
|
90
|
-
message: zod_1.z.string().optional()
|
|
94
|
+
message: zod_1.z.string().optional(),
|
|
91
95
|
});
|
|
92
96
|
const transaction = zod_1.z.object({
|
|
93
97
|
data: zod_1.z.string(),
|
|
94
98
|
utime: zod_1.z.number(),
|
|
95
99
|
transaction_id: zod_1.z.object({
|
|
96
100
|
lt: zod_1.z.string(),
|
|
97
|
-
hash: zod_1.z.string()
|
|
101
|
+
hash: zod_1.z.string(),
|
|
98
102
|
}),
|
|
99
103
|
fee: zod_1.z.string(),
|
|
100
104
|
storage_fee: zod_1.z.string(),
|
|
101
105
|
other_fee: zod_1.z.string(),
|
|
102
106
|
in_msg: zod_1.z.union([zod_1.z.undefined(), message]),
|
|
103
|
-
out_msgs: zod_1.z.array(message)
|
|
107
|
+
out_msgs: zod_1.z.array(message),
|
|
104
108
|
});
|
|
105
109
|
const getTransactions = zod_1.z.array(transaction);
|
|
106
110
|
const getMasterchain = zod_1.z.object({
|
|
107
111
|
state_root_hash: zod_1.z.string(),
|
|
108
112
|
last: blockIdExt,
|
|
109
|
-
init: blockIdExt
|
|
113
|
+
init: blockIdExt,
|
|
110
114
|
});
|
|
111
115
|
const getShards = zod_1.z.object({
|
|
112
|
-
shards: zod_1.z.array(blockIdExt)
|
|
116
|
+
shards: zod_1.z.array(blockIdExt),
|
|
113
117
|
});
|
|
114
118
|
const blockShortTxt = zod_1.z.object({
|
|
115
|
-
|
|
119
|
+
"@type": zod_1.z.literal("blocks.shortTxId"),
|
|
116
120
|
mode: zod_1.z.number(),
|
|
117
121
|
account: zod_1.z.string(),
|
|
118
122
|
lt: zod_1.z.string(),
|
|
119
|
-
hash: zod_1.z.string()
|
|
123
|
+
hash: zod_1.z.string(),
|
|
120
124
|
});
|
|
121
125
|
const getBlockTransactions = zod_1.z.object({
|
|
122
126
|
id: blockIdExt,
|
|
123
127
|
req_count: zod_1.z.number(),
|
|
124
128
|
incomplete: zod_1.z.boolean(),
|
|
125
|
-
transactions: zod_1.z.array(blockShortTxt)
|
|
129
|
+
transactions: zod_1.z.array(blockShortTxt),
|
|
126
130
|
});
|
|
127
131
|
class TypedCache {
|
|
128
132
|
constructor(namespace, cache, codec, keyEncoder) {
|
|
@@ -157,37 +161,43 @@ class HttpApi {
|
|
|
157
161
|
this.parameters = {
|
|
158
162
|
timeout: parameters?.timeout || 30000, // 30 seconds by default
|
|
159
163
|
apiKey: parameters?.apiKey,
|
|
160
|
-
adapter: parameters?.adapter
|
|
164
|
+
adapter: parameters?.adapter,
|
|
161
165
|
};
|
|
162
166
|
// Shard
|
|
163
|
-
this.shardCache = new TypedCache(
|
|
167
|
+
this.shardCache = new TypedCache("ton-shard", this.cache, zod_1.z.array(blockIdExt), (src) => src + "");
|
|
164
168
|
this.shardLoader = new dataloader_1.default(async (src) => {
|
|
165
169
|
return await Promise.all(src.map(async (v) => {
|
|
166
170
|
const cached = await this.shardCache.get(v);
|
|
167
171
|
if (cached) {
|
|
168
172
|
return cached;
|
|
169
173
|
}
|
|
170
|
-
let loaded = (await this.doCall(
|
|
174
|
+
let loaded = (await this.doCall("shards", { seqno: v }, getShards)).shards;
|
|
171
175
|
await this.shardCache.set(v, loaded);
|
|
172
176
|
return loaded;
|
|
173
177
|
}));
|
|
174
178
|
});
|
|
175
179
|
// Shard Transactions
|
|
176
|
-
this.shardTransactionsCache = new TypedCache(
|
|
180
|
+
this.shardTransactionsCache = new TypedCache("ton-shard-tx", this.cache, getBlockTransactions, (src) => src.workchain + ":" + src.shard + ":" + src.seqno);
|
|
177
181
|
this.shardTransactionsLoader = new dataloader_1.default(async (src) => {
|
|
178
182
|
return await Promise.all(src.map(async (v) => {
|
|
179
183
|
const cached = await this.shardTransactionsCache.get(v);
|
|
180
184
|
if (cached) {
|
|
181
185
|
return cached;
|
|
182
186
|
}
|
|
183
|
-
let loaded = await this.doCall(
|
|
187
|
+
let loaded = await this.doCall("getBlockTransactions", {
|
|
188
|
+
workchain: v.workchain,
|
|
189
|
+
seqno: v.seqno,
|
|
190
|
+
shard: v.shard,
|
|
191
|
+
}, getBlockTransactions);
|
|
184
192
|
await this.shardTransactionsCache.set(v, loaded);
|
|
185
193
|
return loaded;
|
|
186
194
|
}));
|
|
187
|
-
}, {
|
|
195
|
+
}, {
|
|
196
|
+
cacheKeyFn: (src) => src.workchain + ":" + src.shard + ":" + src.seqno,
|
|
197
|
+
});
|
|
188
198
|
}
|
|
189
199
|
getAddressInformation(address) {
|
|
190
|
-
return this.doCall(
|
|
200
|
+
return this.doCall("getAddressInformation", { address: address.toString() }, addressInformation);
|
|
191
201
|
}
|
|
192
202
|
async getTransactions(address, opts) {
|
|
193
203
|
const inclusive = opts.inclusive;
|
|
@@ -195,7 +205,7 @@ class HttpApi {
|
|
|
195
205
|
// Convert hash
|
|
196
206
|
let hash = undefined;
|
|
197
207
|
if (opts.hash) {
|
|
198
|
-
hash = Buffer.from(opts.hash,
|
|
208
|
+
hash = Buffer.from(opts.hash, "base64").toString("hex");
|
|
199
209
|
}
|
|
200
210
|
// Adjust limit
|
|
201
211
|
let limit = opts.limit;
|
|
@@ -203,7 +213,7 @@ class HttpApi {
|
|
|
203
213
|
limit++;
|
|
204
214
|
}
|
|
205
215
|
// Do request
|
|
206
|
-
let res = await this.doCall(
|
|
216
|
+
let res = await this.doCall("getTransactions", { address: address.toString(), ...opts, limit, hash }, getTransactions);
|
|
207
217
|
if (res.length > limit) {
|
|
208
218
|
res = res.slice(0, limit);
|
|
209
219
|
}
|
|
@@ -217,17 +227,21 @@ class HttpApi {
|
|
|
217
227
|
}
|
|
218
228
|
}
|
|
219
229
|
async getMasterchainInfo() {
|
|
220
|
-
return await this.doCall(
|
|
230
|
+
return await this.doCall("getMasterchainInfo", {}, getMasterchain);
|
|
221
231
|
}
|
|
222
232
|
async getShards(seqno) {
|
|
223
233
|
return await this.shardLoader.load(seqno);
|
|
224
234
|
}
|
|
225
235
|
async getBlockTransactions(workchain, seqno, shard) {
|
|
226
|
-
return await this.shardTransactionsLoader.load({
|
|
236
|
+
return await this.shardTransactionsLoader.load({
|
|
237
|
+
workchain,
|
|
238
|
+
seqno,
|
|
239
|
+
shard,
|
|
240
|
+
});
|
|
227
241
|
}
|
|
228
242
|
async getTransaction(address, lt, hash) {
|
|
229
|
-
let convHash = Buffer.from(hash,
|
|
230
|
-
let res = await this.doCall(
|
|
243
|
+
let convHash = Buffer.from(hash, "base64").toString("hex");
|
|
244
|
+
let res = await this.doCall("getTransactions", { address: address.toString(), lt, hash: convHash, limit: 1 }, getTransactions);
|
|
231
245
|
let ex = res.find((v) => v.transaction_id.lt === lt && v.transaction_id.hash === hash);
|
|
232
246
|
if (ex) {
|
|
233
247
|
return ex;
|
|
@@ -237,53 +251,70 @@ class HttpApi {
|
|
|
237
251
|
}
|
|
238
252
|
}
|
|
239
253
|
async callGetMethod(address, method, stack) {
|
|
240
|
-
return await this.doCall(
|
|
254
|
+
return await this.doCall("runGetMethod", {
|
|
255
|
+
address: address.toString(),
|
|
256
|
+
method,
|
|
257
|
+
stack: serializeStack(stack),
|
|
258
|
+
}, callGetMethod);
|
|
241
259
|
}
|
|
242
260
|
async sendBoc(body) {
|
|
243
|
-
await this.doCall(
|
|
261
|
+
await this.doCall("sendBoc", { boc: body.toString("base64") }, bocResponse);
|
|
244
262
|
}
|
|
245
263
|
async estimateFee(address, args) {
|
|
246
|
-
return await this.doCall(
|
|
264
|
+
return await this.doCall("estimateFee", {
|
|
247
265
|
address: address.toString(),
|
|
248
|
-
body: args.body.toBoc().toString(
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
266
|
+
body: args.body.toBoc().toString("base64"),
|
|
267
|
+
init_data: args.initData
|
|
268
|
+
? args.initData.toBoc().toString("base64")
|
|
269
|
+
: "",
|
|
270
|
+
init_code: args.initCode
|
|
271
|
+
? args.initCode.toBoc().toString("base64")
|
|
272
|
+
: "",
|
|
273
|
+
ignore_chksig: args.ignoreSignature,
|
|
252
274
|
}, feeResponse);
|
|
253
275
|
}
|
|
254
276
|
async tryLocateResultTx(source, destination, created_lt) {
|
|
255
|
-
return await this.doCall(
|
|
277
|
+
return await this.doCall("tryLocateResultTx", {
|
|
278
|
+
source: source.toString(),
|
|
279
|
+
destination: destination.toString(),
|
|
280
|
+
created_lt,
|
|
281
|
+
}, transaction);
|
|
256
282
|
}
|
|
257
283
|
async tryLocateSourceTx(source, destination, created_lt) {
|
|
258
|
-
return await this.doCall(
|
|
284
|
+
return await this.doCall("tryLocateSourceTx", {
|
|
285
|
+
source: source.toString(),
|
|
286
|
+
destination: destination.toString(),
|
|
287
|
+
created_lt,
|
|
288
|
+
}, transaction);
|
|
259
289
|
}
|
|
260
290
|
async doCall(method, body, codec) {
|
|
261
291
|
let headers = {
|
|
262
|
-
|
|
263
|
-
|
|
292
|
+
"Content-Type": "application/json",
|
|
293
|
+
"X-Ton-Client-Version": version,
|
|
264
294
|
};
|
|
265
295
|
if (this.parameters.apiKey) {
|
|
266
|
-
headers[
|
|
296
|
+
headers["X-API-Key"] = this.parameters.apiKey;
|
|
267
297
|
}
|
|
268
298
|
let res = await axios_1.default.post(this.endpoint, JSON.stringify({
|
|
269
|
-
id:
|
|
270
|
-
jsonrpc:
|
|
299
|
+
id: "1",
|
|
300
|
+
jsonrpc: "2.0",
|
|
271
301
|
method: method,
|
|
272
|
-
params: body
|
|
302
|
+
params: body,
|
|
273
303
|
}), {
|
|
274
304
|
headers,
|
|
275
305
|
timeout: this.parameters.timeout,
|
|
276
|
-
adapter: this.parameters.adapter
|
|
306
|
+
adapter: this.parameters.adapter,
|
|
277
307
|
});
|
|
278
308
|
if (res.status !== 200 || !res.data.ok) {
|
|
279
|
-
throw Error(
|
|
309
|
+
throw Error("Received error: " + JSON.stringify(res.data));
|
|
280
310
|
}
|
|
281
311
|
let decoded = codec.safeParse(res.data.result);
|
|
282
312
|
if (decoded.success) {
|
|
283
313
|
return decoded.data;
|
|
284
314
|
}
|
|
285
315
|
else {
|
|
286
|
-
throw Error(
|
|
316
|
+
throw Error("Malformed response: " +
|
|
317
|
+
decoded.error.format()._errors.join(", "));
|
|
287
318
|
}
|
|
288
319
|
}
|
|
289
320
|
}
|
|
@@ -291,20 +322,20 @@ exports.HttpApi = HttpApi;
|
|
|
291
322
|
function serializeStack(src) {
|
|
292
323
|
let stack = [];
|
|
293
324
|
for (let s of src) {
|
|
294
|
-
if (s.type ===
|
|
295
|
-
stack.push([
|
|
325
|
+
if (s.type === "int") {
|
|
326
|
+
stack.push(["num", s.value.toString()]);
|
|
296
327
|
}
|
|
297
|
-
else if (s.type ===
|
|
298
|
-
stack.push([
|
|
328
|
+
else if (s.type === "cell") {
|
|
329
|
+
stack.push(["tvm.Cell", s.cell.toBoc().toString("base64")]);
|
|
299
330
|
}
|
|
300
|
-
else if (s.type ===
|
|
301
|
-
stack.push([
|
|
331
|
+
else if (s.type === "slice") {
|
|
332
|
+
stack.push(["tvm.Slice", s.cell.toBoc().toString("base64")]);
|
|
302
333
|
}
|
|
303
|
-
else if (s.type ===
|
|
304
|
-
stack.push([
|
|
334
|
+
else if (s.type === "builder") {
|
|
335
|
+
stack.push(["tvm.Builder", s.cell.toBoc().toString("base64")]);
|
|
305
336
|
}
|
|
306
337
|
else {
|
|
307
|
-
throw Error(
|
|
338
|
+
throw Error("Unsupported stack item type: " + s.type);
|
|
308
339
|
}
|
|
309
340
|
}
|
|
310
341
|
return stack;
|
|
@@ -13,14 +13,14 @@ class InMemoryCache {
|
|
|
13
13
|
this.cache = new Map();
|
|
14
14
|
this.set = async (namespace, key, value) => {
|
|
15
15
|
if (value !== null) {
|
|
16
|
-
this.cache.set(namespace +
|
|
16
|
+
this.cache.set(namespace + "$$" + key, value);
|
|
17
17
|
}
|
|
18
18
|
else {
|
|
19
|
-
this.cache.delete(namespace +
|
|
19
|
+
this.cache.delete(namespace + "$$" + key);
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
this.get = async (namespace, key) => {
|
|
23
|
-
let res = this.cache.get(namespace +
|
|
23
|
+
let res = this.cache.get(namespace + "$$" + key);
|
|
24
24
|
if (res !== undefined) {
|
|
25
25
|
return res;
|
|
26
26
|
}
|