@ton/ton 13.5.1
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/CHANGELOG.md +133 -0
- package/LICENSE +9 -0
- package/README.md +78 -0
- package/dist/client/TonClient.d.ts +231 -0
- package/dist/client/TonClient.js +392 -0
- package/dist/client/TonClient.spec.d.ts +1 -0
- package/dist/client/TonClient.spec.js +37 -0
- package/dist/client/TonClient4.d.ts +289 -0
- package/dist/client/TonClient4.js +514 -0
- package/dist/client/TonClient4.spec.d.ts +1 -0
- package/dist/client/TonClient4.spec.js +36 -0
- package/dist/client/api/HttpApi.d.ts +632 -0
- package/dist/client/api/HttpApi.js +297 -0
- package/dist/client/api/TonCache.d.ts +16 -0
- package/dist/client/api/TonCache.js +33 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +68 -0
- package/dist/jetton/JettonMaster.d.ts +21 -0
- package/dist/jetton/JettonMaster.js +39 -0
- package/dist/jetton/JettonMaster.spec.d.ts +8 -0
- package/dist/jetton/JettonMaster.spec.js +27 -0
- package/dist/jetton/JettonWallet.d.ts +14 -0
- package/dist/jetton/JettonWallet.js +27 -0
- package/dist/multisig/MultisigOrder.d.ts +17 -0
- package/dist/multisig/MultisigOrder.js +73 -0
- package/dist/multisig/MultisigOrder.spec.d.ts +1 -0
- package/dist/multisig/MultisigOrder.spec.js +139 -0
- package/dist/multisig/MultisigOrderBuilder.d.ts +13 -0
- package/dist/multisig/MultisigOrderBuilder.js +37 -0
- package/dist/multisig/MultisigWallet.d.ts +26 -0
- package/dist/multisig/MultisigWallet.js +120 -0
- package/dist/multisig/MultisigWallet.spec.d.ts +1 -0
- package/dist/multisig/MultisigWallet.spec.js +230 -0
- package/dist/utils/createTestClient.d.ts +9 -0
- package/dist/utils/createTestClient.js +18 -0
- package/dist/utils/createTestClient4.d.ts +9 -0
- package/dist/utils/createTestClient4.js +15 -0
- package/dist/utils/maybe.d.ts +8 -0
- package/dist/utils/maybe.js +9 -0
- package/dist/utils/randomTestKey.d.ts +8 -0
- package/dist/utils/randomTestKey.js +24 -0
- package/dist/utils/time.d.ts +15 -0
- package/dist/utils/time.js +63 -0
- package/dist/utils/toUrlSafe.d.ts +8 -0
- package/dist/utils/toUrlSafe.js +23 -0
- package/dist/wallets/WalletContractV1R1.d.ts +58 -0
- package/dist/wallets/WalletContractV1R1.js +100 -0
- package/dist/wallets/WalletContractV1R1.spec.d.ts +8 -0
- package/dist/wallets/WalletContractV1R1.spec.js +44 -0
- package/dist/wallets/WalletContractV1R2.d.ts +58 -0
- package/dist/wallets/WalletContractV1R2.js +101 -0
- package/dist/wallets/WalletContractV1R2.spec.d.ts +8 -0
- package/dist/wallets/WalletContractV1R2.spec.js +44 -0
- package/dist/wallets/WalletContractV1R3.d.ts +58 -0
- package/dist/wallets/WalletContractV1R3.js +101 -0
- package/dist/wallets/WalletContractV1R3.spec.d.ts +8 -0
- package/dist/wallets/WalletContractV1R3.spec.js +44 -0
- package/dist/wallets/WalletContractV2R1.d.ts +60 -0
- package/dist/wallets/WalletContractV2R1.js +102 -0
- package/dist/wallets/WalletContractV2R1.spec.d.ts +8 -0
- package/dist/wallets/WalletContractV2R1.spec.js +44 -0
- package/dist/wallets/WalletContractV2R2.d.ts +60 -0
- package/dist/wallets/WalletContractV2R2.js +102 -0
- package/dist/wallets/WalletContractV2R2.spec.d.ts +8 -0
- package/dist/wallets/WalletContractV2R2.spec.js +44 -0
- package/dist/wallets/WalletContractV3R1.d.ts +62 -0
- package/dist/wallets/WalletContractV3R1.js +111 -0
- package/dist/wallets/WalletContractV3R1.spec.d.ts +8 -0
- package/dist/wallets/WalletContractV3R1.spec.js +44 -0
- package/dist/wallets/WalletContractV3R2.d.ts +62 -0
- package/dist/wallets/WalletContractV3R2.js +111 -0
- package/dist/wallets/WalletContractV3R2.spec.d.ts +8 -0
- package/dist/wallets/WalletContractV3R2.spec.js +44 -0
- package/dist/wallets/WalletContractV4.d.ts +62 -0
- package/dist/wallets/WalletContractV4.js +112 -0
- package/dist/wallets/WalletContractV4.spec.d.ts +8 -0
- package/dist/wallets/WalletContractV4.spec.js +48 -0
- package/dist/wallets/signing/createWalletTransfer.d.ts +39 -0
- package/dist/wallets/signing/createWalletTransfer.js +122 -0
- package/package.json +68 -0
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Whales Corp.
|
|
4
|
+
* All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
10
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
11
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
12
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
13
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
14
|
+
};
|
|
15
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
16
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
17
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
18
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
19
|
+
};
|
|
20
|
+
var _TonClient_api;
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.TonClient = void 0;
|
|
23
|
+
const HttpApi_1 = require("./api/HttpApi");
|
|
24
|
+
const core_1 = require("@ton/core");
|
|
25
|
+
class TonClient {
|
|
26
|
+
constructor(parameters) {
|
|
27
|
+
_TonClient_api.set(this, void 0);
|
|
28
|
+
this.parameters = {
|
|
29
|
+
endpoint: parameters.endpoint
|
|
30
|
+
};
|
|
31
|
+
__classPrivateFieldSet(this, _TonClient_api, new HttpApi_1.HttpApi(this.parameters.endpoint, {
|
|
32
|
+
timeout: parameters.timeout,
|
|
33
|
+
apiKey: parameters.apiKey,
|
|
34
|
+
adapter: parameters.httpAdapter
|
|
35
|
+
}), "f");
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get Address Balance
|
|
39
|
+
* @param address address for balance check
|
|
40
|
+
* @returns balance
|
|
41
|
+
*/
|
|
42
|
+
async getBalance(address) {
|
|
43
|
+
return (await this.getContractState(address)).balance;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Invoke get method
|
|
47
|
+
* @param address contract address
|
|
48
|
+
* @param name name of method
|
|
49
|
+
* @param params optional parameters
|
|
50
|
+
* @returns stack and gas_used field
|
|
51
|
+
*/
|
|
52
|
+
async runMethod(address, name, stack = []) {
|
|
53
|
+
let res = await __classPrivateFieldGet(this, _TonClient_api, "f").callGetMethod(address, name, stack);
|
|
54
|
+
if (res.exit_code !== 0) {
|
|
55
|
+
throw Error('Unable to execute get method. Got exit_code: ' + res.exit_code);
|
|
56
|
+
}
|
|
57
|
+
return { gas_used: res.gas_used, stack: parseStack(res.stack) };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Invoke get method
|
|
61
|
+
* @param address contract address
|
|
62
|
+
* @param name name of method
|
|
63
|
+
* @param params optional parameters
|
|
64
|
+
* @returns stack and gas_used field
|
|
65
|
+
* @deprecated use runMethod instead
|
|
66
|
+
*/
|
|
67
|
+
async callGetMethod(address, name, stack = []) {
|
|
68
|
+
return this.runMethod(address, name, stack);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Invoke get method that returns error code instead of throwing error
|
|
72
|
+
* @param address contract address
|
|
73
|
+
* @param name name of method
|
|
74
|
+
* @param params optional parameters
|
|
75
|
+
* @returns stack and gas_used field
|
|
76
|
+
*/
|
|
77
|
+
async runMethodWithError(address, name, params = []) {
|
|
78
|
+
let res = await __classPrivateFieldGet(this, _TonClient_api, "f").callGetMethod(address, name, params);
|
|
79
|
+
return { gas_used: res.gas_used, stack: parseStack(res.stack), exit_code: res.exit_code };
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Invoke get method that returns error code instead of throwing error
|
|
83
|
+
* @param address contract address
|
|
84
|
+
* @param name name of method
|
|
85
|
+
* @param params optional parameters
|
|
86
|
+
* @returns stack and gas_used field
|
|
87
|
+
* @deprecated use runMethodWithError instead
|
|
88
|
+
*/
|
|
89
|
+
async callGetMethodWithError(address, name, stack = []) {
|
|
90
|
+
return this.runMethodWithError(address, name, stack);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get transactions
|
|
94
|
+
* @param address address
|
|
95
|
+
*/
|
|
96
|
+
async getTransactions(address, opts) {
|
|
97
|
+
// Fetch transactions
|
|
98
|
+
let tx = await __classPrivateFieldGet(this, _TonClient_api, "f").getTransactions(address, opts);
|
|
99
|
+
let res = [];
|
|
100
|
+
for (let r of tx) {
|
|
101
|
+
res.push((0, core_1.loadTransaction)(core_1.Cell.fromBoc(Buffer.from(r.data, 'base64'))[0].beginParse()));
|
|
102
|
+
}
|
|
103
|
+
return res;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Get transaction by it's id
|
|
107
|
+
* @param address address
|
|
108
|
+
* @param lt logical time
|
|
109
|
+
* @param hash transaction hash
|
|
110
|
+
* @returns transaction or null if not exist
|
|
111
|
+
*/
|
|
112
|
+
async getTransaction(address, lt, hash) {
|
|
113
|
+
let res = await __classPrivateFieldGet(this, _TonClient_api, "f").getTransaction(address, lt, hash);
|
|
114
|
+
if (res) {
|
|
115
|
+
return (0, core_1.loadTransaction)(core_1.Cell.fromBoc(Buffer.from(res.data, 'base64'))[0].beginParse());
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Fetch latest masterchain info
|
|
123
|
+
* @returns masterchain info
|
|
124
|
+
*/
|
|
125
|
+
async getMasterchainInfo() {
|
|
126
|
+
let r = await __classPrivateFieldGet(this, _TonClient_api, "f").getMasterchainInfo();
|
|
127
|
+
return {
|
|
128
|
+
workchain: r.init.workchain,
|
|
129
|
+
shard: r.last.shard,
|
|
130
|
+
initSeqno: r.init.seqno,
|
|
131
|
+
latestSeqno: r.last.seqno
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Fetch latest workchain shards
|
|
136
|
+
* @param seqno masterchain seqno
|
|
137
|
+
*/
|
|
138
|
+
async getWorkchainShards(seqno) {
|
|
139
|
+
let r = await __classPrivateFieldGet(this, _TonClient_api, "f").getShards(seqno);
|
|
140
|
+
return r.map((m) => ({
|
|
141
|
+
workchain: m.workchain,
|
|
142
|
+
shard: m.shard,
|
|
143
|
+
seqno: m.seqno
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Fetch transactions inf shards
|
|
148
|
+
* @param workchain
|
|
149
|
+
* @param seqno
|
|
150
|
+
* @param shard
|
|
151
|
+
*/
|
|
152
|
+
async getShardTransactions(workchain, seqno, shard) {
|
|
153
|
+
let tx = await __classPrivateFieldGet(this, _TonClient_api, "f").getBlockTransactions(workchain, seqno, shard);
|
|
154
|
+
if (tx.incomplete) {
|
|
155
|
+
throw Error('Unsupported');
|
|
156
|
+
}
|
|
157
|
+
return tx.transactions.map((v) => ({
|
|
158
|
+
account: core_1.Address.parseRaw(v.account),
|
|
159
|
+
lt: v.lt,
|
|
160
|
+
hash: v.hash
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Send message to a network
|
|
165
|
+
* @param src source message
|
|
166
|
+
*/
|
|
167
|
+
async sendMessage(src) {
|
|
168
|
+
const boc = (0, core_1.beginCell)()
|
|
169
|
+
.store((0, core_1.storeMessage)(src))
|
|
170
|
+
.endCell()
|
|
171
|
+
.toBoc();
|
|
172
|
+
await __classPrivateFieldGet(this, _TonClient_api, "f").sendBoc(boc);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Send file to a network
|
|
176
|
+
* @param src source file
|
|
177
|
+
*/
|
|
178
|
+
async sendFile(src) {
|
|
179
|
+
await __classPrivateFieldGet(this, _TonClient_api, "f").sendBoc(src);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Estimate fees for external message
|
|
183
|
+
* @param address target address
|
|
184
|
+
* @returns
|
|
185
|
+
*/
|
|
186
|
+
async estimateExternalMessageFee(address, args) {
|
|
187
|
+
return await __classPrivateFieldGet(this, _TonClient_api, "f").estimateFee(address, { body: args.body, initCode: args.initCode, initData: args.initData, ignoreSignature: args.ignoreSignature });
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Send external message to contract
|
|
191
|
+
* @param contract contract to send message
|
|
192
|
+
* @param src message body
|
|
193
|
+
*/
|
|
194
|
+
async sendExternalMessage(contract, src) {
|
|
195
|
+
if (await this.isContractDeployed(contract.address) || !contract.init) {
|
|
196
|
+
const message = (0, core_1.external)({
|
|
197
|
+
to: contract.address,
|
|
198
|
+
body: src
|
|
199
|
+
});
|
|
200
|
+
await this.sendMessage(message);
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
const message = (0, core_1.external)({
|
|
204
|
+
to: contract.address,
|
|
205
|
+
init: { code: contract.init.code, data: contract.init.data },
|
|
206
|
+
body: src
|
|
207
|
+
});
|
|
208
|
+
await this.sendMessage(message);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Check if contract is deployed
|
|
213
|
+
* @param address addres to check
|
|
214
|
+
* @returns true if contract is in active state
|
|
215
|
+
*/
|
|
216
|
+
async isContractDeployed(address) {
|
|
217
|
+
return (await this.getContractState(address)).state === 'active';
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Resolves contract state
|
|
221
|
+
* @param address contract address
|
|
222
|
+
*/
|
|
223
|
+
async getContractState(address) {
|
|
224
|
+
let info = await __classPrivateFieldGet(this, _TonClient_api, "f").getAddressInformation(address);
|
|
225
|
+
let balance = BigInt(info.balance);
|
|
226
|
+
let state = info.state;
|
|
227
|
+
return {
|
|
228
|
+
balance,
|
|
229
|
+
state,
|
|
230
|
+
code: info.code !== '' ? Buffer.from(info.code, 'base64') : null,
|
|
231
|
+
data: info.data !== '' ? Buffer.from(info.data, 'base64') : null,
|
|
232
|
+
lastTransaction: info.last_transaction_id.lt !== '0' ? {
|
|
233
|
+
lt: info.last_transaction_id.lt,
|
|
234
|
+
hash: info.last_transaction_id.hash,
|
|
235
|
+
} : null,
|
|
236
|
+
blockId: {
|
|
237
|
+
workchain: info.block_id.workchain,
|
|
238
|
+
shard: info.block_id.shard,
|
|
239
|
+
seqno: info.block_id.seqno
|
|
240
|
+
},
|
|
241
|
+
timestampt: info.sync_utime
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Open contract
|
|
246
|
+
* @param src source contract
|
|
247
|
+
* @returns contract
|
|
248
|
+
*/
|
|
249
|
+
open(src) {
|
|
250
|
+
return (0, core_1.openContract)(src, (args) => createProvider(this, args.address, args.init));
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Create a provider
|
|
254
|
+
* @param address address
|
|
255
|
+
* @param init optional init
|
|
256
|
+
* @returns provider
|
|
257
|
+
*/
|
|
258
|
+
provider(address, init) {
|
|
259
|
+
return createProvider(this, address, init);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
exports.TonClient = TonClient;
|
|
263
|
+
_TonClient_api = new WeakMap();
|
|
264
|
+
function parseStack(src) {
|
|
265
|
+
let stack = [];
|
|
266
|
+
for (let s of src) {
|
|
267
|
+
if (s[0] === 'num') {
|
|
268
|
+
let val = s[1];
|
|
269
|
+
if (val.startsWith('-')) {
|
|
270
|
+
stack.push({ type: 'int', value: -BigInt(val.slice(1)) });
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
stack.push({ type: 'int', value: BigInt(val) });
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
else if (s[0] === 'null') {
|
|
277
|
+
stack.push({ type: 'null' });
|
|
278
|
+
}
|
|
279
|
+
else if (s[0] === 'cell') {
|
|
280
|
+
stack.push({ type: 'cell', cell: core_1.Cell.fromBoc(Buffer.from(s[1].bytes, 'base64'))[0] });
|
|
281
|
+
}
|
|
282
|
+
else if (s[0] === 'slice') {
|
|
283
|
+
stack.push({ type: 'slice', cell: core_1.Cell.fromBoc(Buffer.from(s[1].bytes, 'base64'))[0] });
|
|
284
|
+
}
|
|
285
|
+
else if (s[0] === 'builder') {
|
|
286
|
+
stack.push({ type: 'builder', cell: core_1.Cell.fromBoc(Buffer.from(s[1].bytes, 'base64'))[0] });
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
throw Error('Unsupported stack item type: ' + s[0]);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return new core_1.TupleReader(stack);
|
|
293
|
+
}
|
|
294
|
+
function createProvider(client, address, init) {
|
|
295
|
+
return {
|
|
296
|
+
async getState() {
|
|
297
|
+
let state = await client.getContractState(address);
|
|
298
|
+
let balance = state.balance;
|
|
299
|
+
let last = state.lastTransaction ? { lt: BigInt(state.lastTransaction.lt), hash: Buffer.from(state.lastTransaction.hash, 'base64') } : null;
|
|
300
|
+
let storage;
|
|
301
|
+
if (state.state === 'active') {
|
|
302
|
+
storage = {
|
|
303
|
+
type: 'active',
|
|
304
|
+
code: state.code ? state.code : null,
|
|
305
|
+
data: state.data ? state.data : null,
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
else if (state.state === 'uninitialized') {
|
|
309
|
+
storage = {
|
|
310
|
+
type: 'uninit',
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
else if (state.state === 'frozen') {
|
|
314
|
+
storage = {
|
|
315
|
+
type: 'frozen',
|
|
316
|
+
stateHash: Buffer.alloc(0),
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
throw Error('Unsupported state');
|
|
321
|
+
}
|
|
322
|
+
return {
|
|
323
|
+
balance,
|
|
324
|
+
last,
|
|
325
|
+
state: storage,
|
|
326
|
+
};
|
|
327
|
+
},
|
|
328
|
+
async get(name, args) {
|
|
329
|
+
let method = await client.callGetMethod(address, name, args);
|
|
330
|
+
return { stack: method.stack };
|
|
331
|
+
},
|
|
332
|
+
async external(message) {
|
|
333
|
+
//
|
|
334
|
+
// Resolve init
|
|
335
|
+
//
|
|
336
|
+
let neededInit = null;
|
|
337
|
+
if (init && !await client.isContractDeployed(address)) {
|
|
338
|
+
neededInit = init;
|
|
339
|
+
}
|
|
340
|
+
//
|
|
341
|
+
// Send package
|
|
342
|
+
//
|
|
343
|
+
const ext = (0, core_1.external)({
|
|
344
|
+
to: address,
|
|
345
|
+
init: neededInit ? { code: neededInit.code, data: neededInit.data } : null,
|
|
346
|
+
body: message
|
|
347
|
+
});
|
|
348
|
+
let boc = (0, core_1.beginCell)()
|
|
349
|
+
.store((0, core_1.storeMessage)(ext))
|
|
350
|
+
.endCell()
|
|
351
|
+
.toBoc();
|
|
352
|
+
await client.sendFile(boc);
|
|
353
|
+
},
|
|
354
|
+
async internal(via, message) {
|
|
355
|
+
// Resolve init
|
|
356
|
+
let neededInit = null;
|
|
357
|
+
if (init && (!await client.isContractDeployed(address))) {
|
|
358
|
+
neededInit = init;
|
|
359
|
+
}
|
|
360
|
+
// Resolve bounce
|
|
361
|
+
let bounce = true;
|
|
362
|
+
if (message.bounce !== null && message.bounce !== undefined) {
|
|
363
|
+
bounce = message.bounce;
|
|
364
|
+
}
|
|
365
|
+
// Resolve value
|
|
366
|
+
let value;
|
|
367
|
+
if (typeof message.value === 'string') {
|
|
368
|
+
value = (0, core_1.toNano)(message.value);
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
value = message.value;
|
|
372
|
+
}
|
|
373
|
+
// Resolve body
|
|
374
|
+
let body = null;
|
|
375
|
+
if (typeof message.body === 'string') {
|
|
376
|
+
body = (0, core_1.comment)(message.body);
|
|
377
|
+
}
|
|
378
|
+
else if (message.body) {
|
|
379
|
+
body = message.body;
|
|
380
|
+
}
|
|
381
|
+
// Send internal message
|
|
382
|
+
await via.send({
|
|
383
|
+
to: address,
|
|
384
|
+
value,
|
|
385
|
+
bounce,
|
|
386
|
+
sendMode: message.sendMode,
|
|
387
|
+
init: neededInit,
|
|
388
|
+
body
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@ton/core");
|
|
4
|
+
const TonClient_1 = require("./TonClient");
|
|
5
|
+
let describeConditional = process.env.TEST_CLIENTS ? describe : describe.skip;
|
|
6
|
+
describeConditional('TonClient', () => {
|
|
7
|
+
let client = new TonClient_1.TonClient({
|
|
8
|
+
endpoint: 'https://mainnet.tonhubapi.com/jsonRPC',
|
|
9
|
+
});
|
|
10
|
+
const testAddress = core_1.Address.parse('EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N');
|
|
11
|
+
it('should get contract state', async () => {
|
|
12
|
+
let state = await client.getContractState(testAddress);
|
|
13
|
+
console.log(state);
|
|
14
|
+
});
|
|
15
|
+
it('should get balance', async () => {
|
|
16
|
+
let balance = await client.getBalance(testAddress);
|
|
17
|
+
console.log(balance);
|
|
18
|
+
});
|
|
19
|
+
it('should get transactions', async () => {
|
|
20
|
+
let transactions = await client.getTransactions(testAddress, { limit: 3 });
|
|
21
|
+
console.log(transactions);
|
|
22
|
+
});
|
|
23
|
+
it('should get single transaction', async () => {
|
|
24
|
+
let info = await client.getTransaction(testAddress, '37508996000003', 'xiwW9EROcDMWFibmm2YNW/2kTaDW5qwRJxveEf4xUQA=');
|
|
25
|
+
console.log(info);
|
|
26
|
+
});
|
|
27
|
+
it('should run method', async () => {
|
|
28
|
+
let seqno = await client.runMethod(testAddress, 'seqno');
|
|
29
|
+
console.log(seqno);
|
|
30
|
+
});
|
|
31
|
+
it('should get mc info', async () => {
|
|
32
|
+
let info = await client.getMasterchainInfo();
|
|
33
|
+
let shardInfo = await client.getShardTransactions(info.workchain, info.latestSeqno, info.shard);
|
|
34
|
+
let wcShards = await client.getWorkchainShards(info.latestSeqno);
|
|
35
|
+
console.log(info, shardInfo, wcShards);
|
|
36
|
+
});
|
|
37
|
+
});
|