@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.
Files changed (133) hide show
  1. package/README.md +47 -11
  2. package/dist/client/TonClient.d.ts +6 -6
  3. package/dist/client/TonClient.js +105 -80
  4. package/dist/client/TonClient4.d.ts +1 -1
  5. package/dist/client/TonClient4.js +227 -138
  6. package/dist/client/api/HttpApi.d.ts +122 -122
  7. package/dist/client/api/HttpApi.js +103 -72
  8. package/dist/client/api/TonCache.js +3 -3
  9. package/dist/config/ConfigParser.d.ts +221 -409
  10. package/dist/config/ConfigParser.js +407 -89
  11. package/dist/elector/ElectorContract.js +46 -20
  12. package/dist/index.d.ts +22 -22
  13. package/dist/index.js +2 -1
  14. package/dist/jetton/JettonMaster.js +5 -3
  15. package/dist/jetton/JettonWallet.js +2 -2
  16. package/dist/multisig/MultisigOrder.d.ts +2 -2
  17. package/dist/multisig/MultisigOrder.js +1 -1
  18. package/dist/multisig/MultisigOrderBuilder.d.ts +2 -2
  19. package/dist/multisig/MultisigOrderBuilder.js +1 -1
  20. package/dist/multisig/MultisigWallet.d.ts +3 -3
  21. package/dist/multisig/MultisigWallet.js +8 -8
  22. package/dist/utils/createTestClient.d.ts +1 -1
  23. package/dist/utils/createTestClient.js +6 -2
  24. package/dist/utils/createTestClient4.d.ts +1 -1
  25. package/dist/utils/createTestClient4.js +5 -1
  26. package/dist/utils/fees.d.ts +2 -2
  27. package/dist/utils/fees.js +21 -6
  28. package/dist/utils/{randomTestKey.d.ts → testUtils.d.ts} +2 -0
  29. package/dist/utils/testUtils.js +21 -0
  30. package/dist/utils/testWallets.d.ts +10 -10
  31. package/dist/utils/time.js +5 -3
  32. package/dist/utils/toUrlSafe.js +6 -6
  33. package/dist/wallets/WalletContractV1R1.d.ts +1 -57
  34. package/dist/wallets/WalletContractV1R1.js +15 -99
  35. package/dist/wallets/WalletContractV1R2.d.ts +1 -57
  36. package/dist/wallets/WalletContractV1R2.js +15 -100
  37. package/dist/wallets/WalletContractV1R3.d.ts +1 -57
  38. package/dist/wallets/WalletContractV1R3.js +15 -99
  39. package/dist/wallets/WalletContractV2R1.d.ts +1 -59
  40. package/dist/wallets/WalletContractV2R1.js +15 -101
  41. package/dist/wallets/WalletContractV2R2.d.ts +1 -59
  42. package/dist/wallets/WalletContractV2R2.js +15 -101
  43. package/dist/wallets/WalletContractV3R1.d.ts +1 -56
  44. package/dist/wallets/WalletContractV3R1.js +15 -103
  45. package/dist/wallets/WalletContractV3R2.d.ts +1 -56
  46. package/dist/wallets/WalletContractV3R2.js +15 -103
  47. package/dist/wallets/WalletContractV4.d.ts +2 -2
  48. package/dist/wallets/WalletContractV5Beta.d.ts +3 -3
  49. package/dist/wallets/WalletContractV5R1.d.ts +3 -3
  50. package/dist/wallets/signing/createWalletTransfer.d.ts +11 -3
  51. package/dist/wallets/signing/createWalletTransfer.js +18 -15
  52. package/dist/wallets/signing/singer.d.ts +2 -1
  53. package/dist/wallets/signing/singer.js +11 -5
  54. package/dist/wallets/v1/r1.d.ts +59 -0
  55. package/dist/wallets/v1/r1.js +103 -0
  56. package/dist/wallets/v1/r2.d.ts +59 -0
  57. package/dist/wallets/v1/r2.js +104 -0
  58. package/dist/wallets/v1/r3.d.ts +59 -0
  59. package/dist/wallets/v1/r3.js +103 -0
  60. package/dist/wallets/v2/r1.d.ts +61 -0
  61. package/dist/wallets/v2/r1.js +107 -0
  62. package/dist/wallets/v2/r2.d.ts +61 -0
  63. package/dist/wallets/v2/r2.js +107 -0
  64. package/dist/wallets/v3/r1.d.ts +58 -0
  65. package/dist/wallets/v3/r1.js +109 -0
  66. package/dist/wallets/v3/r2.d.ts +58 -0
  67. package/dist/wallets/v3/r2.js +109 -0
  68. package/dist/wallets/v4/WalletContractV4.d.ts +4 -2
  69. package/dist/wallets/v4/WalletContractV4.js +36 -32
  70. package/dist/wallets/v4/WalletContractV4Actions.d.ts +4 -4
  71. package/dist/wallets/v4/WalletContractV4Actions.js +10 -10
  72. package/dist/wallets/v5beta/WalletContractV5Beta.d.ts +7 -5
  73. package/dist/wallets/v5beta/WalletContractV5Beta.js +44 -28
  74. package/dist/wallets/v5beta/WalletV5BetaActions.d.ts +1 -1
  75. package/dist/wallets/v5beta/WalletV5BetaActions.js +25 -18
  76. package/dist/wallets/v5beta/WalletV5BetaWalletId.d.ts +2 -2
  77. package/dist/wallets/v5beta/WalletV5BetaWalletId.js +6 -4
  78. package/dist/wallets/v5beta/WalletV5OutActions.d.ts +4 -4
  79. package/dist/wallets/v5beta/WalletV5OutActions.js +3 -1
  80. package/dist/wallets/v5r1/WalletContractV5R1.d.ts +10 -6
  81. package/dist/wallets/v5r1/WalletContractV5R1.js +55 -36
  82. package/dist/wallets/v5r1/WalletV5R1Actions.d.ts +3 -3
  83. package/dist/wallets/v5r1/WalletV5R1Actions.js +32 -25
  84. package/dist/wallets/v5r1/WalletV5R1WalletId.d.ts +2 -2
  85. package/dist/wallets/v5r1/WalletV5R1WalletId.js +16 -10
  86. package/package.json +62 -65
  87. package/dist/client/TonClient.spec.d.ts +0 -1
  88. package/dist/client/TonClient.spec.js +0 -59
  89. package/dist/client/TonClient4.spec.d.ts +0 -1
  90. package/dist/client/TonClient4.spec.js +0 -67
  91. package/dist/config/ConfigParser.spec.d.ts +0 -8
  92. package/dist/config/ConfigParser.spec.js +0 -137
  93. package/dist/elector/ElectorContract.spec.d.ts +0 -8
  94. package/dist/elector/ElectorContract.spec.js +0 -104
  95. package/dist/jetton/JettonMaster.spec.d.ts +0 -8
  96. package/dist/jetton/JettonMaster.spec.js +0 -27
  97. package/dist/multisig/MultisigOrder.spec.d.ts +0 -1
  98. package/dist/multisig/MultisigOrder.spec.js +0 -139
  99. package/dist/multisig/MultisigWallet.spec.d.ts +0 -1
  100. package/dist/multisig/MultisigWallet.spec.js +0 -248
  101. package/dist/utils/fees.spec.d.ts +0 -1
  102. package/dist/utils/fees.spec.js +0 -83
  103. package/dist/utils/randomTestKey.js +0 -23
  104. package/dist/wallets/WalletContractV1R1.spec.d.ts +0 -8
  105. package/dist/wallets/WalletContractV1R1.spec.js +0 -67
  106. package/dist/wallets/WalletContractV1R2.spec.d.ts +0 -8
  107. package/dist/wallets/WalletContractV1R2.spec.js +0 -67
  108. package/dist/wallets/WalletContractV1R3.spec.d.ts +0 -8
  109. package/dist/wallets/WalletContractV1R3.spec.js +0 -44
  110. package/dist/wallets/WalletContractV2R1.spec.d.ts +0 -8
  111. package/dist/wallets/WalletContractV2R1.spec.js +0 -67
  112. package/dist/wallets/WalletContractV2R2.spec.d.ts +0 -8
  113. package/dist/wallets/WalletContractV2R2.spec.js +0 -67
  114. package/dist/wallets/WalletContractV3R1.spec.d.ts +0 -8
  115. package/dist/wallets/WalletContractV3R1.spec.js +0 -67
  116. package/dist/wallets/WalletContractV3R2.spec.d.ts +0 -8
  117. package/dist/wallets/WalletContractV3R2.spec.js +0 -67
  118. package/dist/wallets/v4/WalletContractV4.spec.d.ts +0 -8
  119. package/dist/wallets/v4/WalletContractV4.spec.js +0 -157
  120. package/dist/wallets/v4/WalletContractV4Actions.spec.d.ts +0 -1
  121. package/dist/wallets/v4/WalletContractV4Actions.spec.js +0 -74
  122. package/dist/wallets/v5beta/WalletContractV5Beta.spec.d.ts +0 -8
  123. package/dist/wallets/v5beta/WalletContractV5Beta.spec.js +0 -317
  124. package/dist/wallets/v5beta/WalletV5BetaActions.spec.d.ts +0 -1
  125. package/dist/wallets/v5beta/WalletV5BetaActions.spec.js +0 -166
  126. package/dist/wallets/v5beta/WalletV5BetaWalletId.spec.d.ts +0 -1
  127. package/dist/wallets/v5beta/WalletV5BetaWalletId.spec.js +0 -68
  128. package/dist/wallets/v5r1/WalletContractV5R1.spec.d.ts +0 -8
  129. package/dist/wallets/v5r1/WalletContractV5R1.spec.js +0 -340
  130. package/dist/wallets/v5r1/WalletV5R1Actions.spec.d.ts +0 -1
  131. package/dist/wallets/v5r1/WalletV5R1Actions.spec.js +0 -262
  132. package/dist/wallets/v5r1/WalletV5R1WalletId.spec.d.ts +0 -1
  133. 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('../../../package.json').version;
18
+ const version = require("../../../package.json").version;
19
19
  const blockIdExt = zod_1.z.object({
20
- '@type': zod_1.z.literal('ton.blockIdExt'),
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
- '@type': zod_1.z.literal("extraCurrency"),
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([zod_1.z.literal('active'), zod_1.z.literal('uninitialized'), zod_1.z.literal('frozen')]),
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
- '@type': zod_1.z.literal('internal.transactionId'),
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
- '@type': zod_1.z.literal('ok')
50
+ "@type": zod_1.z.literal("ok"),
47
51
  });
48
52
  const feeResponse = zod_1.z.object({
49
- '@type': zod_1.z.literal('query.fees'),
53
+ "@type": zod_1.z.literal("query.fees"),
50
54
  source_fees: zod_1.z.object({
51
- '@type': zod_1.z.literal('fees'),
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
- '@type': zod_1.z.literal('msg.dataRaw'),
66
- 'body': zod_1.z.string()
69
+ "@type": zod_1.z.literal("msg.dataRaw"),
70
+ body: zod_1.z.string(),
67
71
  }),
68
72
  zod_1.z.object({
69
- '@type': zod_1.z.literal('msg.dataText'),
70
- 'text': zod_1.z.string()
73
+ "@type": zod_1.z.literal("msg.dataText"),
74
+ text: zod_1.z.string(),
71
75
  }),
72
76
  zod_1.z.object({
73
- '@type': zod_1.z.literal('msg.dataDecryptedText'),
74
- 'text': zod_1.z.string()
77
+ "@type": zod_1.z.literal("msg.dataDecryptedText"),
78
+ text: zod_1.z.string(),
75
79
  }),
76
80
  zod_1.z.object({
77
- '@type': zod_1.z.literal('msg.dataEncryptedText'),
78
- 'text': zod_1.z.string()
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
- '@type': zod_1.z.literal('blocks.shortTxId'),
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('ton-shard', this.cache, zod_1.z.array(blockIdExt), (src) => src + '');
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('shards', { seqno: v }, getShards)).shards;
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('ton-shard-tx', this.cache, getBlockTransactions, (src) => src.workchain + ':' + src.shard + ':' + src.seqno);
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('getBlockTransactions', { workchain: v.workchain, seqno: v.seqno, shard: v.shard }, getBlockTransactions);
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
- }, { cacheKeyFn: (src) => src.workchain + ':' + src.shard + ':' + src.seqno });
195
+ }, {
196
+ cacheKeyFn: (src) => src.workchain + ":" + src.shard + ":" + src.seqno,
197
+ });
188
198
  }
189
199
  getAddressInformation(address) {
190
- return this.doCall('getAddressInformation', { address: address.toString() }, addressInformation);
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, 'base64').toString('hex');
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('getTransactions', { address: address.toString(), ...opts, limit, hash }, getTransactions);
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('getMasterchainInfo', {}, getMasterchain);
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({ workchain, seqno, shard });
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, 'base64').toString('hex');
230
- let res = await this.doCall('getTransactions', { address: address.toString(), lt, hash: convHash, limit: 1 }, getTransactions);
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('runGetMethod', { address: address.toString(), method, stack: serializeStack(stack) }, callGetMethod);
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('sendBoc', { boc: body.toString('base64') }, bocResponse);
261
+ await this.doCall("sendBoc", { boc: body.toString("base64") }, bocResponse);
244
262
  }
245
263
  async estimateFee(address, args) {
246
- return await this.doCall('estimateFee', {
264
+ return await this.doCall("estimateFee", {
247
265
  address: address.toString(),
248
- body: args.body.toBoc().toString('base64'),
249
- 'init_data': args.initData ? args.initData.toBoc().toString('base64') : '',
250
- 'init_code': args.initCode ? args.initCode.toBoc().toString('base64') : '',
251
- ignore_chksig: args.ignoreSignature
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('tryLocateResultTx', { source: source.toString(), destination: destination.toString(), created_lt }, transaction);
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('tryLocateSourceTx', { source: source.toString(), destination: destination.toString(), created_lt }, transaction);
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
- 'Content-Type': 'application/json',
263
- 'X-Ton-Client-Version': version,
292
+ "Content-Type": "application/json",
293
+ "X-Ton-Client-Version": version,
264
294
  };
265
295
  if (this.parameters.apiKey) {
266
- headers['X-API-Key'] = this.parameters.apiKey;
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: '1',
270
- jsonrpc: '2.0',
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('Received error: ' + JSON.stringify(res.data));
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('Malformed response: ' + decoded.error.format()._errors.join(', '));
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 === 'int') {
295
- stack.push(['num', s.value.toString()]);
325
+ if (s.type === "int") {
326
+ stack.push(["num", s.value.toString()]);
296
327
  }
297
- else if (s.type === 'cell') {
298
- stack.push(['tvm.Cell', s.cell.toBoc().toString('base64')]);
328
+ else if (s.type === "cell") {
329
+ stack.push(["tvm.Cell", s.cell.toBoc().toString("base64")]);
299
330
  }
300
- else if (s.type === 'slice') {
301
- stack.push(['tvm.Slice', s.cell.toBoc().toString('base64')]);
331
+ else if (s.type === "slice") {
332
+ stack.push(["tvm.Slice", s.cell.toBoc().toString("base64")]);
302
333
  }
303
- else if (s.type === 'builder') {
304
- stack.push(['tvm.Builder', s.cell.toBoc().toString('base64')]);
334
+ else if (s.type === "builder") {
335
+ stack.push(["tvm.Builder", s.cell.toBoc().toString("base64")]);
305
336
  }
306
337
  else {
307
- throw Error('Unsupported stack item type: ' + s.type);
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 + '$$' + key, value);
16
+ this.cache.set(namespace + "$$" + key, value);
17
17
  }
18
18
  else {
19
- this.cache.delete(namespace + '$$' + key);
19
+ this.cache.delete(namespace + "$$" + key);
20
20
  }
21
21
  };
22
22
  this.get = async (namespace, key) => {
23
- let res = this.cache.get(namespace + '$$' + key);
23
+ let res = this.cache.get(namespace + "$$" + key);
24
24
  if (res !== undefined) {
25
25
  return res;
26
26
  }