@tonappchain/sdk 0.7.2-alpha-5 → 0.7.2-alpha-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.
|
@@ -183,7 +183,7 @@ async function liteClientOpener(options) {
|
|
|
183
183
|
getConfig: async () => {
|
|
184
184
|
const block = await client.getMasterchainInfo();
|
|
185
185
|
const { config } = await client.getConfig(block.last);
|
|
186
|
-
return config;
|
|
186
|
+
return (0, ton_1.beginCell)().storeDictDirect(config).endCell().toBoc().toString('base64');
|
|
187
187
|
},
|
|
188
188
|
};
|
|
189
189
|
}
|
|
@@ -208,7 +208,7 @@ function sandboxOpener(blockchain) {
|
|
|
208
208
|
throw new Error('Not implemented.');
|
|
209
209
|
},
|
|
210
210
|
getConfig: async () => {
|
|
211
|
-
return blockchain.config.
|
|
211
|
+
return blockchain.config.toBoc().toString('base64');
|
|
212
212
|
},
|
|
213
213
|
};
|
|
214
214
|
}
|
|
@@ -239,9 +239,7 @@ async function orbsOpener(network) {
|
|
|
239
239
|
url.searchParams.append('seqno', info.latestSeqno.toString());
|
|
240
240
|
const result = await fetch(url);
|
|
241
241
|
const body = await result.json();
|
|
242
|
-
return
|
|
243
|
-
.beginParse()
|
|
244
|
-
.loadDictDirect(ton_1.Dictionary.Keys.Int(32), ton_1.Dictionary.Values.Cell());
|
|
242
|
+
return body.result.config.bytes;
|
|
245
243
|
},
|
|
246
244
|
};
|
|
247
245
|
}
|
|
@@ -286,9 +284,7 @@ async function orbsOpener4(network, timeout = 10000) {
|
|
|
286
284
|
getConfig: async () => {
|
|
287
285
|
const block = await client4.getLastBlock();
|
|
288
286
|
const { config } = await client4.getConfig(block.last.seqno);
|
|
289
|
-
return
|
|
290
|
-
.beginParse()
|
|
291
|
-
.loadDictDirect(ton_1.Dictionary.Keys.Int(32), ton_1.Dictionary.Values.Cell());
|
|
287
|
+
return config.cell;
|
|
292
288
|
},
|
|
293
289
|
};
|
|
294
290
|
}
|
|
@@ -317,9 +313,7 @@ function tonClientOpener(client) {
|
|
|
317
313
|
url.searchParams.append('seqno', info.latestSeqno.toString());
|
|
318
314
|
const result = await fetch(url);
|
|
319
315
|
const body = await result.json();
|
|
320
|
-
return
|
|
321
|
-
.beginParse()
|
|
322
|
-
.loadDictDirect(ton_1.Dictionary.Keys.Int(32), ton_1.Dictionary.Values.Cell());
|
|
316
|
+
return body.result.config.bytes;
|
|
323
317
|
},
|
|
324
318
|
};
|
|
325
319
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SandboxContract } from '@ton/sandbox';
|
|
2
|
-
import { Address,
|
|
2
|
+
import { Address, Contract, OpenedContract, Transaction } from '@ton/ton';
|
|
3
3
|
import { ContractOpener } from '../interfaces';
|
|
4
4
|
import { AddressInformation, GetTransactionsOptions } from '../structs/InternalStruct';
|
|
5
5
|
import { ContractState, Network } from '../structs/Struct';
|
|
@@ -19,7 +19,7 @@ export declare class RetryableContractOpener implements ContractOpener {
|
|
|
19
19
|
open<T extends Contract>(src: T): OpenedContract<T> | SandboxContract<T>;
|
|
20
20
|
getContractState(address: Address): Promise<ContractState>;
|
|
21
21
|
getAddressInformation(address: Address): Promise<AddressInformation>;
|
|
22
|
-
getConfig(): Promise<
|
|
22
|
+
getConfig(): Promise<string>;
|
|
23
23
|
closeConnections(): void;
|
|
24
24
|
private executeWithFallback;
|
|
25
25
|
private tryWithRetries;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SandboxContract } from '@ton/sandbox';
|
|
2
|
-
import type { Address,
|
|
2
|
+
import type { Address, Contract, OpenedContract, Transaction } from '@ton/ton';
|
|
3
3
|
import { AddressInformation, GetTransactionsOptions } from '../structs/InternalStruct';
|
|
4
4
|
import { ContractState } from '../structs/Struct';
|
|
5
5
|
export interface ContractOpener {
|
|
@@ -22,5 +22,5 @@ export interface ContractOpener {
|
|
|
22
22
|
getTransactionByHash(address: Address, hash: string, opts?: GetTransactionsOptions): Promise<Transaction | null>;
|
|
23
23
|
getAdjacentTransactions(address: Address, hash: string, opts?: GetTransactionsOptions): Promise<Transaction[]>;
|
|
24
24
|
getAddressInformation(address: Address): Promise<AddressInformation>;
|
|
25
|
-
getConfig(): Promise<
|
|
25
|
+
getConfig(): Promise<string>;
|
|
26
26
|
}
|
|
@@ -196,54 +196,17 @@ class Configuration {
|
|
|
196
196
|
static async retrieveTONFeesParams(contractOpener) {
|
|
197
197
|
try {
|
|
198
198
|
const config = await contractOpener.getConfig();
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
199
|
+
const fullConfig = (0, ton_1.parseFullConfig)((0, ton_1.loadConfigParamsAsSlice)(config));
|
|
200
|
+
return {
|
|
201
|
+
gasPrice: Number(fullConfig.gasPrices.workchain.other.gasPrice),
|
|
202
|
+
lumpPrice: Number(fullConfig.msgPrices.workchain.lumpPrice),
|
|
203
|
+
msgBitPrice: Number(fullConfig.msgPrices.workchain.bitPrice),
|
|
204
|
+
msgCellPrice: Number(fullConfig.msgPrices.workchain.cellPrice),
|
|
205
|
+
ihrPriceFactor: Number(fullConfig.msgPrices.workchain.ihrPriceFactor),
|
|
206
|
+
firstFrac: Number(fullConfig.msgPrices.workchain.firstFrac),
|
|
207
|
+
accountBitPrice: Number(fullConfig.storagePrices[0].bit_price_ps),
|
|
208
|
+
accountCellPrice: Number(fullConfig.storagePrices[0].cell_price_ps),
|
|
208
209
|
};
|
|
209
|
-
// ───────────────────────────────────────────────
|
|
210
|
-
// Param 21 – Gas prices
|
|
211
|
-
// ───────────────────────────────────────────────
|
|
212
|
-
const param21 = config.get(21);
|
|
213
|
-
if (!param21)
|
|
214
|
-
throw new Error('Param 21 (gas prices) not found in config');
|
|
215
|
-
let slice = param21.beginParse();
|
|
216
|
-
slice.skip(8 + 64 + 64 + 8); // = 144 bits
|
|
217
|
-
const gasPriceRaw = slice.loadUint(64);
|
|
218
|
-
prices.gasPrice = gasPriceRaw / 65536;
|
|
219
|
-
// ───────────────────────────────────────────────
|
|
220
|
-
// Param 25 – Message forwarding prices
|
|
221
|
-
// ───────────────────────────────────────────────
|
|
222
|
-
const param25 = config.get(25);
|
|
223
|
-
if (!param25)
|
|
224
|
-
throw new Error('Param 25 (msg prices) not found in config');
|
|
225
|
-
slice = param25.beginParse();
|
|
226
|
-
slice.skip(8); // usually just flags / version
|
|
227
|
-
prices.lumpPrice = slice.loadUint(64);
|
|
228
|
-
prices.msgBitPrice = slice.loadUint(64);
|
|
229
|
-
prices.msgCellPrice = slice.loadUint(64);
|
|
230
|
-
prices.ihrPriceFactor = slice.loadUint(32);
|
|
231
|
-
prices.firstFrac = slice.loadUint(16);
|
|
232
|
-
// ───────────────────────────────────────────────
|
|
233
|
-
// Param 18 – Storage prices
|
|
234
|
-
// ───────────────────────────────────────────────
|
|
235
|
-
const param18 = config.get(18);
|
|
236
|
-
if (!param18)
|
|
237
|
-
throw new Error('Param 18 (storage prices) not found in config');
|
|
238
|
-
const dict = param18.beginParse().loadDictDirect(ton_1.Dictionary.Keys.Uint(32), ton_1.Dictionary.Values.Cell());
|
|
239
|
-
const entry = await dict.get(0);
|
|
240
|
-
if (!entry)
|
|
241
|
-
throw new Error('Storage price entry for key 0 not found');
|
|
242
|
-
slice = entry.beginParse();
|
|
243
|
-
slice.skip(8 + 32);
|
|
244
|
-
prices.accountBitPrice = slice.loadUint(64);
|
|
245
|
-
prices.accountCellPrice = slice.loadUint(64);
|
|
246
|
-
return prices;
|
|
247
210
|
}
|
|
248
211
|
catch {
|
|
249
212
|
// return standard values from https://tonviewer.com/config#25 in case of failure
|
|
@@ -81,7 +81,7 @@ class Simulator {
|
|
|
81
81
|
// Storage Fee (nanotons)
|
|
82
82
|
const storageFee = Math.ceil(((accountBits * accountBitPrice + accountCells * accountCellPrice) * timeDelta) / Fees_1.FIXED_POINT_SHIFT);
|
|
83
83
|
// Computation Fee (nanotons)
|
|
84
|
-
const computeFee = gasUsed * gasPrice;
|
|
84
|
+
const computeFee = (gasUsed * gasPrice) / Fees_1.FIXED_POINT_SHIFT;
|
|
85
85
|
// Forwarding Fee (nanotons)
|
|
86
86
|
const msgFwdFees = lumpPrice + Math.ceil((msgBitPrice * msgBits + msgCellPrice * msgCells) / Fees_1.FIXED_POINT_SHIFT);
|
|
87
87
|
const ihrFwdFees = Math.ceil((msgFwdFees * ihrPriceFactor) / Fees_1.FIXED_POINT_SHIFT);
|