@ton-wallet/create 14.0.4 → 14.0.6
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/package.json +1 -2
- package/dist/client/TonClient.d.ts +0 -228
- package/dist/client/TonClient.js +0 -441
- package/dist/client/TonClient.spec.d.ts +0 -1
- package/dist/client/TonClient.spec.js +0 -45
- package/dist/client/TonClient4.d.ts +0 -1130
- package/dist/client/TonClient4.js +0 -687
- package/dist/client/TonClient4.spec.d.ts +0 -1
- package/dist/client/TonClient4.spec.js +0 -42
- package/dist/client/api/HttpApi.d.ts +0 -764
- package/dist/client/api/HttpApi.js +0 -306
- package/dist/client/api/TonCache.d.ts +0 -16
- package/dist/client/api/TonCache.js +0 -33
- package/dist/config/ConfigParser.d.ts +0 -622
- package/dist/config/ConfigParser.js +0 -711
- package/dist/config/ConfigParser.spec.d.ts +0 -8
- package/dist/config/ConfigParser.spec.js +0 -97
- package/dist/elector/ElectorContract.d.ts +0 -51
- package/dist/elector/ElectorContract.js +0 -192
- package/dist/elector/ElectorContract.spec.d.ts +0 -8
- package/dist/elector/ElectorContract.spec.js +0 -104
- package/dist/index.d.ts +0 -33
- package/dist/index.js +0 -129
- package/dist/jetton/JettonMaster.d.ts +0 -21
- package/dist/jetton/JettonMaster.js +0 -39
- package/dist/jetton/JettonMaster.spec.d.ts +0 -8
- package/dist/jetton/JettonMaster.spec.js +0 -27
- package/dist/jetton/JettonWallet.d.ts +0 -14
- package/dist/jetton/JettonWallet.js +0 -27
- package/dist/multisig/MultisigOrder.d.ts +0 -17
- package/dist/multisig/MultisigOrder.js +0 -73
- package/dist/multisig/MultisigOrder.spec.d.ts +0 -1
- package/dist/multisig/MultisigOrder.spec.js +0 -139
- package/dist/multisig/MultisigOrderBuilder.d.ts +0 -13
- package/dist/multisig/MultisigOrderBuilder.js +0 -37
- package/dist/multisig/MultisigWallet.d.ts +0 -27
- package/dist/multisig/MultisigWallet.js +0 -134
- package/dist/multisig/MultisigWallet.spec.d.ts +0 -1
- package/dist/multisig/MultisigWallet.spec.js +0 -248
- package/dist/utils/createTestClient.d.ts +0 -9
- package/dist/utils/createTestClient.js +0 -18
- package/dist/utils/createTestClient4.d.ts +0 -9
- package/dist/utils/createTestClient4.js +0 -15
- package/dist/utils/fees.d.ts +0 -25
- package/dist/utils/fees.js +0 -105
- package/dist/utils/fees.spec.d.ts +0 -1
- package/dist/utils/fees.spec.js +0 -83
- package/dist/utils/maybe.d.ts +0 -8
- package/dist/utils/maybe.js +0 -9
- package/dist/utils/randomTestKey.d.ts +0 -8
- package/dist/utils/randomTestKey.js +0 -24
- package/dist/utils/time.d.ts +0 -15
- package/dist/utils/time.js +0 -63
- package/dist/utils/toUrlSafe.d.ts +0 -8
- package/dist/utils/toUrlSafe.js +0 -23
- package/dist/wallets/WalletContractV1R1.d.ts +0 -58
- package/dist/wallets/WalletContractV1R1.js +0 -100
- package/dist/wallets/WalletContractV1R1.spec.d.ts +0 -8
- package/dist/wallets/WalletContractV1R1.spec.js +0 -44
- package/dist/wallets/WalletContractV1R2.d.ts +0 -58
- package/dist/wallets/WalletContractV1R2.js +0 -101
- package/dist/wallets/WalletContractV1R2.spec.d.ts +0 -8
- package/dist/wallets/WalletContractV1R2.spec.js +0 -44
- package/dist/wallets/WalletContractV1R3.d.ts +0 -58
- package/dist/wallets/WalletContractV1R3.js +0 -101
- package/dist/wallets/WalletContractV1R3.spec.d.ts +0 -8
- package/dist/wallets/WalletContractV1R3.spec.js +0 -44
- package/dist/wallets/WalletContractV2R1.d.ts +0 -60
- package/dist/wallets/WalletContractV2R1.js +0 -102
- package/dist/wallets/WalletContractV2R1.spec.d.ts +0 -8
- package/dist/wallets/WalletContractV2R1.spec.js +0 -44
- package/dist/wallets/WalletContractV2R2.d.ts +0 -60
- package/dist/wallets/WalletContractV2R2.js +0 -102
- package/dist/wallets/WalletContractV2R2.spec.d.ts +0 -8
- package/dist/wallets/WalletContractV2R2.spec.js +0 -44
- package/dist/wallets/WalletContractV3R1.d.ts +0 -57
- package/dist/wallets/WalletContractV3R1.js +0 -104
- package/dist/wallets/WalletContractV3R1.spec.d.ts +0 -8
- package/dist/wallets/WalletContractV3R1.spec.js +0 -44
- package/dist/wallets/WalletContractV3R2.d.ts +0 -57
- package/dist/wallets/WalletContractV3R2.js +0 -104
- package/dist/wallets/WalletContractV3R2.spec.d.ts +0 -8
- package/dist/wallets/WalletContractV3R2.spec.js +0 -44
- package/dist/wallets/WalletContractV3Types.d.ts +0 -12
- package/dist/wallets/WalletContractV3Types.js +0 -2
- package/dist/wallets/WalletContractV4.d.ts +0 -65
- package/dist/wallets/WalletContractV4.js +0 -105
- package/dist/wallets/WalletContractV4.spec.d.ts +0 -8
- package/dist/wallets/WalletContractV4.spec.js +0 -48
- package/dist/wallets/WalletContractV5Beta.d.ts +0 -3
- package/dist/wallets/WalletContractV5Beta.js +0 -19
- package/dist/wallets/WalletContractV5R1.d.ts +0 -3
- package/dist/wallets/WalletContractV5R1.js +0 -19
- package/dist/wallets/signing/createWalletTransfer.d.ts +0 -48
- package/dist/wallets/signing/createWalletTransfer.js +0 -190
- package/dist/wallets/signing/singer.d.ts +0 -9
- package/dist/wallets/signing/singer.js +0 -21
- package/dist/wallets/v5beta/WalletContractV5Beta.d.ts +0 -130
- package/dist/wallets/v5beta/WalletContractV5Beta.js +0 -211
- package/dist/wallets/v5beta/WalletContractV5Beta.spec.d.ts +0 -8
- package/dist/wallets/v5beta/WalletContractV5Beta.spec.js +0 -298
- package/dist/wallets/v5beta/WalletV5BetaActions.d.ts +0 -6
- package/dist/wallets/v5beta/WalletV5BetaActions.js +0 -92
- package/dist/wallets/v5beta/WalletV5BetaActions.spec.d.ts +0 -1
- package/dist/wallets/v5beta/WalletV5BetaActions.spec.js +0 -166
- package/dist/wallets/v5beta/WalletV5BetaWalletId.d.ts +0 -13
- package/dist/wallets/v5beta/WalletV5BetaWalletId.js +0 -31
- package/dist/wallets/v5beta/WalletV5BetaWalletId.spec.d.ts +0 -1
- package/dist/wallets/v5beta/WalletV5BetaWalletId.spec.js +0 -68
- package/dist/wallets/v5beta/WalletV5OutActions.d.ts +0 -17
- package/dist/wallets/v5beta/WalletV5OutActions.js +0 -11
- package/dist/wallets/v5r1/WalletContractV5R1.d.ts +0 -125
- package/dist/wallets/v5r1/WalletContractV5R1.js +0 -207
- package/dist/wallets/v5r1/WalletContractV5R1.spec.d.ts +0 -8
- package/dist/wallets/v5r1/WalletContractV5R1.spec.js +0 -321
- package/dist/wallets/v5r1/WalletV5R1Actions.d.ts +0 -12
- package/dist/wallets/v5r1/WalletV5R1Actions.js +0 -128
- package/dist/wallets/v5r1/WalletV5R1Actions.spec.d.ts +0 -1
- package/dist/wallets/v5r1/WalletV5R1Actions.spec.js +0 -262
- package/dist/wallets/v5r1/WalletV5R1WalletId.d.ts +0 -47
- package/dist/wallets/v5r1/WalletV5R1WalletId.js +0 -69
- package/dist/wallets/v5r1/WalletV5R1WalletId.spec.d.ts +0 -1
- package/dist/wallets/v5r1/WalletV5R1WalletId.spec.js +0 -72
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.HttpApi = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Copyright (c) Whales Corp.
|
|
9
|
-
* All Rights Reserved.
|
|
10
|
-
*
|
|
11
|
-
* This source code is licensed under the MIT license found in the
|
|
12
|
-
* LICENSE file in the root directory of this source tree.
|
|
13
|
-
*/
|
|
14
|
-
const TonCache_1 = require("./TonCache");
|
|
15
|
-
const dataloader_1 = __importDefault(require("dataloader"));
|
|
16
|
-
const axios_1 = __importDefault(require("axios"));
|
|
17
|
-
const zod_1 = require("zod");
|
|
18
|
-
const version = require('../../../package.json').version;
|
|
19
|
-
const blockIdExt = zod_1.z.object({
|
|
20
|
-
'@type': zod_1.z.literal('ton.blockIdExt'),
|
|
21
|
-
workchain: zod_1.z.number(),
|
|
22
|
-
shard: zod_1.z.string(),
|
|
23
|
-
seqno: zod_1.z.number(),
|
|
24
|
-
root_hash: zod_1.z.string(),
|
|
25
|
-
file_hash: zod_1.z.string()
|
|
26
|
-
});
|
|
27
|
-
const addressInformation = zod_1.z.object({
|
|
28
|
-
balance: zod_1.z.union([zod_1.z.number(), zod_1.z.string()]),
|
|
29
|
-
state: zod_1.z.union([zod_1.z.literal('active'), zod_1.z.literal('uninitialized'), zod_1.z.literal('frozen')]),
|
|
30
|
-
data: zod_1.z.string(),
|
|
31
|
-
code: zod_1.z.string(),
|
|
32
|
-
last_transaction_id: zod_1.z.object({
|
|
33
|
-
'@type': zod_1.z.literal('internal.transactionId'),
|
|
34
|
-
lt: zod_1.z.string(),
|
|
35
|
-
hash: zod_1.z.string()
|
|
36
|
-
}),
|
|
37
|
-
block_id: blockIdExt,
|
|
38
|
-
sync_utime: zod_1.z.number()
|
|
39
|
-
});
|
|
40
|
-
const bocResponse = zod_1.z.object({
|
|
41
|
-
'@type': zod_1.z.literal('ok')
|
|
42
|
-
});
|
|
43
|
-
const feeResponse = zod_1.z.object({
|
|
44
|
-
'@type': zod_1.z.literal('query.fees'),
|
|
45
|
-
source_fees: zod_1.z.object({
|
|
46
|
-
'@type': zod_1.z.literal('fees'),
|
|
47
|
-
in_fwd_fee: zod_1.z.number(),
|
|
48
|
-
storage_fee: zod_1.z.number(),
|
|
49
|
-
gas_fee: zod_1.z.number(),
|
|
50
|
-
fwd_fee: zod_1.z.number()
|
|
51
|
-
})
|
|
52
|
-
});
|
|
53
|
-
const callGetMethod = zod_1.z.object({
|
|
54
|
-
gas_used: zod_1.z.number(),
|
|
55
|
-
exit_code: zod_1.z.number(),
|
|
56
|
-
stack: zod_1.z.array(zod_1.z.unknown())
|
|
57
|
-
});
|
|
58
|
-
const messageData = zod_1.z.union([
|
|
59
|
-
zod_1.z.object({
|
|
60
|
-
'@type': zod_1.z.literal('msg.dataRaw'),
|
|
61
|
-
'body': zod_1.z.string()
|
|
62
|
-
}),
|
|
63
|
-
zod_1.z.object({
|
|
64
|
-
'@type': zod_1.z.literal('msg.dataText'),
|
|
65
|
-
'text': zod_1.z.string()
|
|
66
|
-
}),
|
|
67
|
-
zod_1.z.object({
|
|
68
|
-
'@type': zod_1.z.literal('msg.dataDecryptedText'),
|
|
69
|
-
'text': zod_1.z.string()
|
|
70
|
-
}),
|
|
71
|
-
zod_1.z.object({
|
|
72
|
-
'@type': zod_1.z.literal('msg.dataEncryptedText'),
|
|
73
|
-
'text': zod_1.z.string()
|
|
74
|
-
})
|
|
75
|
-
]);
|
|
76
|
-
const message = zod_1.z.object({
|
|
77
|
-
source: zod_1.z.string(),
|
|
78
|
-
destination: zod_1.z.string(),
|
|
79
|
-
value: zod_1.z.string(),
|
|
80
|
-
fwd_fee: zod_1.z.string(),
|
|
81
|
-
ihr_fee: zod_1.z.string(),
|
|
82
|
-
created_lt: zod_1.z.string(),
|
|
83
|
-
body_hash: zod_1.z.string(),
|
|
84
|
-
msg_data: messageData,
|
|
85
|
-
message: zod_1.z.string().optional()
|
|
86
|
-
});
|
|
87
|
-
const transaction = zod_1.z.object({
|
|
88
|
-
data: zod_1.z.string(),
|
|
89
|
-
utime: zod_1.z.number(),
|
|
90
|
-
transaction_id: zod_1.z.object({
|
|
91
|
-
lt: zod_1.z.string(),
|
|
92
|
-
hash: zod_1.z.string()
|
|
93
|
-
}),
|
|
94
|
-
fee: zod_1.z.string(),
|
|
95
|
-
storage_fee: zod_1.z.string(),
|
|
96
|
-
other_fee: zod_1.z.string(),
|
|
97
|
-
in_msg: zod_1.z.union([zod_1.z.undefined(), message]),
|
|
98
|
-
out_msgs: zod_1.z.array(message)
|
|
99
|
-
});
|
|
100
|
-
const getTransactions = zod_1.z.array(transaction);
|
|
101
|
-
const getMasterchain = zod_1.z.object({
|
|
102
|
-
state_root_hash: zod_1.z.string(),
|
|
103
|
-
last: blockIdExt,
|
|
104
|
-
init: blockIdExt
|
|
105
|
-
});
|
|
106
|
-
const getShards = zod_1.z.object({
|
|
107
|
-
shards: zod_1.z.array(blockIdExt)
|
|
108
|
-
});
|
|
109
|
-
const blockShortTxt = zod_1.z.object({
|
|
110
|
-
'@type': zod_1.z.literal('blocks.shortTxId'),
|
|
111
|
-
mode: zod_1.z.number(),
|
|
112
|
-
account: zod_1.z.string(),
|
|
113
|
-
lt: zod_1.z.string(),
|
|
114
|
-
hash: zod_1.z.string()
|
|
115
|
-
});
|
|
116
|
-
const getBlockTransactions = zod_1.z.object({
|
|
117
|
-
id: blockIdExt,
|
|
118
|
-
req_count: zod_1.z.number(),
|
|
119
|
-
incomplete: zod_1.z.boolean(),
|
|
120
|
-
transactions: zod_1.z.array(blockShortTxt)
|
|
121
|
-
});
|
|
122
|
-
class TypedCache {
|
|
123
|
-
constructor(namespace, cache, codec, keyEncoder) {
|
|
124
|
-
this.namespace = namespace;
|
|
125
|
-
this.cache = cache;
|
|
126
|
-
this.codec = codec;
|
|
127
|
-
this.keyEncoder = keyEncoder;
|
|
128
|
-
}
|
|
129
|
-
async get(key) {
|
|
130
|
-
let ex = await this.cache.get(this.namespace, this.keyEncoder(key));
|
|
131
|
-
if (ex) {
|
|
132
|
-
let decoded = this.codec.safeParse(JSON.parse(ex));
|
|
133
|
-
if (decoded.success) {
|
|
134
|
-
return decoded.data;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
async set(key, value) {
|
|
140
|
-
if (value !== null) {
|
|
141
|
-
await this.cache.set(this.namespace, this.keyEncoder(key), JSON.stringify(value));
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
await this.cache.set(this.namespace, this.keyEncoder(key), null);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
class HttpApi {
|
|
149
|
-
constructor(endpoint, parameters) {
|
|
150
|
-
this.endpoint = endpoint;
|
|
151
|
-
this.cache = new TonCache_1.InMemoryCache();
|
|
152
|
-
this.parameters = {
|
|
153
|
-
timeout: parameters?.timeout || 30000,
|
|
154
|
-
apiKey: parameters?.apiKey,
|
|
155
|
-
adapter: parameters?.adapter
|
|
156
|
-
};
|
|
157
|
-
// Shard
|
|
158
|
-
this.shardCache = new TypedCache('ton-shard', this.cache, zod_1.z.array(blockIdExt), (src) => src + '');
|
|
159
|
-
this.shardLoader = new dataloader_1.default(async (src) => {
|
|
160
|
-
return await Promise.all(src.map(async (v) => {
|
|
161
|
-
const cached = await this.shardCache.get(v);
|
|
162
|
-
if (cached) {
|
|
163
|
-
return cached;
|
|
164
|
-
}
|
|
165
|
-
let loaded = (await this.doCall('shards', { seqno: v }, getShards)).shards;
|
|
166
|
-
await this.shardCache.set(v, loaded);
|
|
167
|
-
return loaded;
|
|
168
|
-
}));
|
|
169
|
-
});
|
|
170
|
-
// Shard Transactions
|
|
171
|
-
this.shardTransactionsCache = new TypedCache('ton-shard-tx', this.cache, getBlockTransactions, (src) => src.workchain + ':' + src.shard + ':' + src.seqno);
|
|
172
|
-
this.shardTransactionsLoader = new dataloader_1.default(async (src) => {
|
|
173
|
-
return await Promise.all(src.map(async (v) => {
|
|
174
|
-
const cached = await this.shardTransactionsCache.get(v);
|
|
175
|
-
if (cached) {
|
|
176
|
-
return cached;
|
|
177
|
-
}
|
|
178
|
-
let loaded = await this.doCall('getBlockTransactions', { workchain: v.workchain, seqno: v.seqno, shard: v.shard }, getBlockTransactions);
|
|
179
|
-
await this.shardTransactionsCache.set(v, loaded);
|
|
180
|
-
return loaded;
|
|
181
|
-
}));
|
|
182
|
-
}, { cacheKeyFn: (src) => src.workchain + ':' + src.shard + ':' + src.seqno });
|
|
183
|
-
}
|
|
184
|
-
getAddressInformation(address) {
|
|
185
|
-
return this.doCall('getAddressInformation', { address: address.toString() }, addressInformation);
|
|
186
|
-
}
|
|
187
|
-
async getTransactions(address, opts) {
|
|
188
|
-
const inclusive = opts.inclusive;
|
|
189
|
-
delete opts.inclusive;
|
|
190
|
-
// Convert hash
|
|
191
|
-
let hash = undefined;
|
|
192
|
-
if (opts.hash) {
|
|
193
|
-
hash = Buffer.from(opts.hash, 'base64').toString('hex');
|
|
194
|
-
}
|
|
195
|
-
// Adjust limit
|
|
196
|
-
let limit = opts.limit;
|
|
197
|
-
if (opts.hash && opts.lt && inclusive !== true) {
|
|
198
|
-
limit++;
|
|
199
|
-
}
|
|
200
|
-
// Do request
|
|
201
|
-
let res = await this.doCall('getTransactions', { address: address.toString(), ...opts, limit, hash }, getTransactions);
|
|
202
|
-
if (res.length > limit) {
|
|
203
|
-
res = res.slice(0, limit);
|
|
204
|
-
}
|
|
205
|
-
// Adjust result
|
|
206
|
-
if (opts.hash && opts.lt && inclusive !== true) {
|
|
207
|
-
res.shift();
|
|
208
|
-
return res;
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
return res;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
async getMasterchainInfo() {
|
|
215
|
-
return await this.doCall('getMasterchainInfo', {}, getMasterchain);
|
|
216
|
-
}
|
|
217
|
-
async getShards(seqno) {
|
|
218
|
-
return await this.shardLoader.load(seqno);
|
|
219
|
-
}
|
|
220
|
-
async getBlockTransactions(workchain, seqno, shard) {
|
|
221
|
-
return await this.shardTransactionsLoader.load({ workchain, seqno, shard });
|
|
222
|
-
}
|
|
223
|
-
async getTransaction(address, lt, hash) {
|
|
224
|
-
let convHash = Buffer.from(hash, 'base64').toString('hex');
|
|
225
|
-
let res = await this.doCall('getTransactions', { address: address.toString(), lt, hash: convHash, limit: 1 }, getTransactions);
|
|
226
|
-
let ex = res.find((v) => v.transaction_id.lt === lt && v.transaction_id.hash === hash);
|
|
227
|
-
if (ex) {
|
|
228
|
-
return ex;
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
return null;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
async callGetMethod(address, method, stack) {
|
|
235
|
-
return await this.doCall('runGetMethod', { address: address.toString(), method, stack: serializeStack(stack) }, callGetMethod);
|
|
236
|
-
}
|
|
237
|
-
async sendBoc(body) {
|
|
238
|
-
await this.doCall('sendBoc', { boc: body.toString('base64') }, bocResponse);
|
|
239
|
-
}
|
|
240
|
-
async estimateFee(address, args) {
|
|
241
|
-
return await this.doCall('estimateFee', {
|
|
242
|
-
address: address.toString(),
|
|
243
|
-
body: args.body.toBoc().toString('base64'),
|
|
244
|
-
'init_data': args.initData ? args.initData.toBoc().toString('base64') : '',
|
|
245
|
-
'init_code': args.initCode ? args.initCode.toBoc().toString('base64') : '',
|
|
246
|
-
ignore_chksig: args.ignoreSignature
|
|
247
|
-
}, feeResponse);
|
|
248
|
-
}
|
|
249
|
-
async tryLocateResultTx(source, destination, created_lt) {
|
|
250
|
-
return await this.doCall('tryLocateResultTx', { source: source.toString(), destination: destination.toString(), created_lt }, transaction);
|
|
251
|
-
}
|
|
252
|
-
async tryLocateSourceTx(source, destination, created_lt) {
|
|
253
|
-
return await this.doCall('tryLocateSourceTx', { source: source.toString(), destination: destination.toString(), created_lt }, transaction);
|
|
254
|
-
}
|
|
255
|
-
async doCall(method, body, codec) {
|
|
256
|
-
let headers = {
|
|
257
|
-
'Content-Type': 'application/json',
|
|
258
|
-
'X-Ton-Client-Version': version,
|
|
259
|
-
};
|
|
260
|
-
if (this.parameters.apiKey) {
|
|
261
|
-
headers['X-API-Key'] = this.parameters.apiKey;
|
|
262
|
-
}
|
|
263
|
-
let res = await axios_1.default.post(this.endpoint, JSON.stringify({
|
|
264
|
-
id: '1',
|
|
265
|
-
jsonrpc: '2.0',
|
|
266
|
-
method: method,
|
|
267
|
-
params: body
|
|
268
|
-
}), {
|
|
269
|
-
headers,
|
|
270
|
-
timeout: this.parameters.timeout,
|
|
271
|
-
adapter: this.parameters.adapter
|
|
272
|
-
});
|
|
273
|
-
if (res.status !== 200 || !res.data.ok) {
|
|
274
|
-
throw Error('Received error: ' + JSON.stringify(res.data));
|
|
275
|
-
}
|
|
276
|
-
let decoded = codec.safeParse(res.data.result);
|
|
277
|
-
if (decoded.success) {
|
|
278
|
-
return decoded.data;
|
|
279
|
-
}
|
|
280
|
-
else {
|
|
281
|
-
throw Error('Malformed response: ' + decoded.error.format()._errors.join(', '));
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
exports.HttpApi = HttpApi;
|
|
286
|
-
function serializeStack(src) {
|
|
287
|
-
let stack = [];
|
|
288
|
-
for (let s of src) {
|
|
289
|
-
if (s.type === 'int') {
|
|
290
|
-
stack.push(['num', s.value.toString()]);
|
|
291
|
-
}
|
|
292
|
-
else if (s.type === 'cell') {
|
|
293
|
-
stack.push(['tvm.Cell', s.cell.toBoc().toString('base64')]);
|
|
294
|
-
}
|
|
295
|
-
else if (s.type === 'slice') {
|
|
296
|
-
stack.push(['tvm.Slice', s.cell.toBoc().toString('base64')]);
|
|
297
|
-
}
|
|
298
|
-
else if (s.type === 'builder') {
|
|
299
|
-
stack.push(['tvm.Builder', s.cell.toBoc().toString('base64')]);
|
|
300
|
-
}
|
|
301
|
-
else {
|
|
302
|
-
throw Error('Unsupported stack item type: ' + s.type);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
return stack;
|
|
306
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Whales Corp.
|
|
3
|
-
* All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
export interface TonCache {
|
|
9
|
-
set(namespace: string, key: string, value: string | null): Promise<void>;
|
|
10
|
-
get(namespace: string, key: string): Promise<string | null>;
|
|
11
|
-
}
|
|
12
|
-
export declare class InMemoryCache implements TonCache {
|
|
13
|
-
private cache;
|
|
14
|
-
set: (namespace: string, key: string, value: string | null) => Promise<void>;
|
|
15
|
-
get: (namespace: string, key: string) => Promise<string | null>;
|
|
16
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.InMemoryCache = void 0;
|
|
11
|
-
class InMemoryCache {
|
|
12
|
-
constructor() {
|
|
13
|
-
this.cache = new Map();
|
|
14
|
-
this.set = async (namespace, key, value) => {
|
|
15
|
-
if (value !== null) {
|
|
16
|
-
this.cache.set(namespace + '$$' + key, value);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
this.cache.delete(namespace + '$$' + key);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
this.get = async (namespace, key) => {
|
|
23
|
-
let res = this.cache.get(namespace + '$$' + key);
|
|
24
|
-
if (res !== undefined) {
|
|
25
|
-
return res;
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.InMemoryCache = InMemoryCache;
|