@tonappchain/sdk 0.7.2-alpha-18 → 0.7.2-alpha-21
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/dist/artifacts/dev/ton/internal/wrappers/CrossChainLayer.js +6 -2
- package/dist/artifacts/testnet/ton/internal/build/CrossChainLayer.compiled.json +1 -1
- package/dist/artifacts/testnet/ton/internal/build/Executor.compiled.json +1 -1
- package/dist/artifacts/testnet/ton/internal/build/JettonMinter.compiled.json +1 -1
- package/dist/artifacts/testnet/ton/internal/build/JettonProxy.compiled.json +1 -1
- package/dist/artifacts/testnet/ton/internal/build/JettonWallet.compiled.json +1 -1
- package/dist/artifacts/testnet/ton/internal/build/NFTItem.compiled.json +1 -1
- package/dist/artifacts/testnet/ton/internal/build/NFTProxy.compiled.json +1 -1
- package/dist/artifacts/testnet/ton/internal/build/Settings.compiled.json +1 -1
- package/dist/artifacts/testnet/ton/internal/wrappers/CrossChainLayer.d.ts +65 -6
- package/dist/artifacts/testnet/ton/internal/wrappers/CrossChainLayer.js +169 -18
- package/dist/artifacts/testnet/ton/internal/wrappers/JettonMinter.d.ts +4 -2
- package/dist/artifacts/testnet/ton/internal/wrappers/JettonMinter.js +5 -3
- package/dist/artifacts/testnet/ton/internal/wrappers/JettonProxy.d.ts +9 -0
- package/dist/artifacts/testnet/ton/internal/wrappers/JettonProxy.js +10 -1
- package/dist/artifacts/testnet/ton/internal/wrappers/JettonWallet.d.ts +7 -0
- package/dist/artifacts/testnet/ton/internal/wrappers/JettonWallet.js +9 -2
- package/dist/artifacts/testnet/ton/internal/wrappers/NFTCollection.d.ts +9 -0
- package/dist/artifacts/testnet/ton/internal/wrappers/NFTCollection.js +9 -0
- package/dist/artifacts/testnet/ton/internal/wrappers/NFTItem.d.ts +7 -0
- package/dist/artifacts/testnet/ton/internal/wrappers/NFTItem.js +7 -0
- package/dist/artifacts/testnet/ton/internal/wrappers/NFTProxy.d.ts +7 -0
- package/dist/artifacts/testnet/ton/internal/wrappers/NFTProxy.js +8 -1
- package/dist/artifacts/testnet/ton/internal/wrappers/Settings.d.ts +1 -0
- package/dist/artifacts/testnet/ton/internal/wrappers/Settings.js +1 -0
- package/dist/artifacts/testnet/ton/internal/wrappers/utils/CrossChainLayerPayload.d.ts +10 -0
- package/dist/artifacts/testnet/ton/internal/wrappers/utils/CrossChainLayerPayload.js +24 -0
- package/dist/artifacts/testnet/ton/internal/wrappers/utils/MerkleRoots.d.ts +2 -1
- package/dist/artifacts/testnet/ton/internal/wrappers/utils/MerkleRoots.js +9 -1
- package/dist/src/adapters/RetryableContractOpener.js +15 -11
- package/dist/src/adapters/TonClient4Opener.d.ts +1 -0
- package/dist/src/adapters/TonClient4Opener.js +9 -1
- package/dist/src/adapters/TonClientOpener.d.ts +2 -0
- package/dist/src/adapters/TonClientOpener.js +11 -1
- package/dist/src/errors/errors.js +29 -12
- package/dist/src/errors/instances.js +32 -11
- package/dist/src/interfaces/IOperationTracker.d.ts +22 -22
- package/dist/src/sdk/Consts.d.ts +1 -0
- package/dist/src/sdk/Consts.js +2 -1
- package/dist/src/sdk/OperationTracker.d.ts +11 -11
- package/dist/src/sdk/OperationTracker.js +33 -33
- package/dist/src/sdk/StartTracking.d.ts +3 -3
- package/dist/src/sdk/StartTracking.js +3 -2
- package/dist/src/sdk/Utils.js +3 -3
- package/dist/src/structs/Struct.d.ts +3 -3
- package/dist/src/structs/Struct.js +4 -3
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Address, Cell, Contract, ContractProvider, Sender } from '@ton/ton';
|
|
2
2
|
import { Maybe } from '@ton/core/dist/utils/maybe';
|
|
3
|
+
import { StorageStats } from './utils/GasUtils';
|
|
3
4
|
export declare const JettonMinterOpCodes: {
|
|
4
5
|
mint: number;
|
|
5
6
|
changeAdmin: number;
|
|
@@ -19,7 +20,7 @@ export declare const JettonMinterErrors: {
|
|
|
19
20
|
};
|
|
20
21
|
export type JettonMinterConfig = {
|
|
21
22
|
totalSupply: bigint;
|
|
22
|
-
adminAddress
|
|
23
|
+
adminAddress?: Address;
|
|
23
24
|
newAdminAddress?: Address;
|
|
24
25
|
content: Cell;
|
|
25
26
|
jettonWalletCode: Cell;
|
|
@@ -28,7 +29,7 @@ export type JettonMinterConfig = {
|
|
|
28
29
|
export type JettonMinterData = {
|
|
29
30
|
totalSupply: bigint;
|
|
30
31
|
mintable: boolean;
|
|
31
|
-
adminAddress
|
|
32
|
+
adminAddress?: Address;
|
|
32
33
|
content: Cell;
|
|
33
34
|
walletCode: Cell;
|
|
34
35
|
};
|
|
@@ -39,6 +40,7 @@ export declare class JettonMinter implements Contract {
|
|
|
39
40
|
code: Cell;
|
|
40
41
|
data: Cell;
|
|
41
42
|
} | undefined;
|
|
43
|
+
static storageStats: StorageStats;
|
|
42
44
|
constructor(address: Address, init?: {
|
|
43
45
|
code: Cell;
|
|
44
46
|
data: Cell;
|
|
@@ -6,6 +6,7 @@ exports.jettonMinterConfigToCell = jettonMinterConfigToCell;
|
|
|
6
6
|
const ton_1 = require("@ton/ton");
|
|
7
7
|
const CrossChainLayer_1 = require("./CrossChainLayer");
|
|
8
8
|
const Constants_1 = require("./Constants");
|
|
9
|
+
const GasUtils_1 = require("./utils/GasUtils");
|
|
9
10
|
exports.JettonMinterOpCodes = {
|
|
10
11
|
mint: 0xd7b9c06e,
|
|
11
12
|
changeAdmin: 0x581879bc,
|
|
@@ -58,7 +59,7 @@ class JettonMinter {
|
|
|
58
59
|
value,
|
|
59
60
|
sendMode: ton_1.SendMode.PAY_GAS_SEPARATELY,
|
|
60
61
|
body: (0, ton_1.beginCell)()
|
|
61
|
-
.storeUint(CrossChainLayer_1.CrossChainLayerOpCodes.
|
|
62
|
+
.storeUint(CrossChainLayer_1.CrossChainLayerOpCodes.anyone_tvmMsgToEvmErrorNotification, 32)
|
|
62
63
|
.storeUint(params.queryId || 0, 64)
|
|
63
64
|
.storeUint(params.operation || CrossChainLayer_1.MsgType.jettonBurn, 32)
|
|
64
65
|
.storeAddress(params.jettonOwnerAddress)
|
|
@@ -166,7 +167,7 @@ class JettonMinter {
|
|
|
166
167
|
const res = await provider.get('get_jetton_data', []);
|
|
167
168
|
const totalSupply = res.stack.readBigNumber();
|
|
168
169
|
const mintable = res.stack.readBoolean();
|
|
169
|
-
const adminAddress = res.stack.
|
|
170
|
+
const adminAddress = res.stack.readAddressOpt() ?? undefined;
|
|
170
171
|
const content = res.stack.readCell();
|
|
171
172
|
const walletCode = res.stack.readCell();
|
|
172
173
|
return {
|
|
@@ -184,7 +185,7 @@ class JettonMinter {
|
|
|
184
185
|
async getFullData(provider) {
|
|
185
186
|
const res = await provider.get('get_full_data', []);
|
|
186
187
|
const totalSupply = res.stack.readBigNumber();
|
|
187
|
-
const adminAddress = res.stack.
|
|
188
|
+
const adminAddress = res.stack.readAddressOpt() ?? undefined;
|
|
188
189
|
const newAdminAddress = res.stack.readAddressOpt() ?? undefined;
|
|
189
190
|
const content = res.stack.readCell();
|
|
190
191
|
const jettonWalletCode = res.stack.readCell();
|
|
@@ -207,3 +208,4 @@ class JettonMinter {
|
|
|
207
208
|
}
|
|
208
209
|
}
|
|
209
210
|
exports.JettonMinter = JettonMinter;
|
|
211
|
+
JettonMinter.storageStats = new GasUtils_1.StorageStats(10208n, 28n);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Address, Cell, Contract, ContractProvider, Sender } from '@ton/core';
|
|
2
|
+
import { StorageStats } from './utils/GasUtils';
|
|
2
3
|
export type JettonProxyConfig = {
|
|
3
4
|
crossChainLayerAddress: string;
|
|
4
5
|
adminAddress: string;
|
|
@@ -31,6 +32,14 @@ export declare class JettonProxy implements Contract {
|
|
|
31
32
|
code: Cell;
|
|
32
33
|
data: Cell;
|
|
33
34
|
} | undefined;
|
|
35
|
+
static estimatedJettonWalletCells: bigint;
|
|
36
|
+
static estimatedJettonWalletBits: bigint;
|
|
37
|
+
static storageStats: StorageStats;
|
|
38
|
+
static msgToTvmGasConsumption: bigint;
|
|
39
|
+
static errorNotificationGasConsumption: bigint;
|
|
40
|
+
static transferNotificationGasConsumption: bigint;
|
|
41
|
+
static estimatedReceiveTransferGasConsumption: bigint;
|
|
42
|
+
static estimatedSendTransferGasConsumption: bigint;
|
|
34
43
|
constructor(address: Address, init?: {
|
|
35
44
|
code: Cell;
|
|
36
45
|
data: Cell;
|
|
@@ -5,6 +5,7 @@ exports.jettonProxyConfigToCell = jettonProxyConfigToCell;
|
|
|
5
5
|
const core_1 = require("@ton/core");
|
|
6
6
|
const CrossChainLayer_1 = require("./CrossChainLayer");
|
|
7
7
|
const Constants_1 = require("./Constants");
|
|
8
|
+
const GasUtils_1 = require("./utils/GasUtils");
|
|
8
9
|
exports.JettonProxyOpCodes = {
|
|
9
10
|
jettonWallet_transfer: 0xf8a7ea5,
|
|
10
11
|
jettonWallet_transferNotification: 0x7362d09c,
|
|
@@ -13,7 +14,7 @@ exports.JettonProxyOpCodes = {
|
|
|
13
14
|
anyone_tvmMsgToEVM: 0x6c582059,
|
|
14
15
|
admin_changeAdminAddress: 0x581879bc,
|
|
15
16
|
admin_cancelChangingAdminAddress: 0x60094a1b,
|
|
16
|
-
admin_updateCode:
|
|
17
|
+
admin_updateCode: 0x6e7145f9,
|
|
17
18
|
newAdmin_confirmChangingAdminAddress: 0x6a4fbe34,
|
|
18
19
|
};
|
|
19
20
|
exports.JettonProxyErrors = {
|
|
@@ -156,3 +157,11 @@ class JettonProxy {
|
|
|
156
157
|
}
|
|
157
158
|
}
|
|
158
159
|
exports.JettonProxy = JettonProxy;
|
|
160
|
+
JettonProxy.estimatedJettonWalletCells = 25n;
|
|
161
|
+
JettonProxy.estimatedJettonWalletBits = 11000n;
|
|
162
|
+
JettonProxy.storageStats = new GasUtils_1.StorageStats(7760n, 16n);
|
|
163
|
+
JettonProxy.msgToTvmGasConsumption = 5536n;
|
|
164
|
+
JettonProxy.errorNotificationGasConsumption = 5556n;
|
|
165
|
+
JettonProxy.transferNotificationGasConsumption = 8515n;
|
|
166
|
+
JettonProxy.estimatedReceiveTransferGasConsumption = 12000n;
|
|
167
|
+
JettonProxy.estimatedSendTransferGasConsumption = 11000n;
|
|
@@ -42,8 +42,15 @@ export declare class JettonWallet implements Contract {
|
|
|
42
42
|
code: Cell;
|
|
43
43
|
data: Cell;
|
|
44
44
|
} | undefined;
|
|
45
|
+
static mintAfterErrorGasConsumption: bigint;
|
|
46
|
+
static burnNotificationGasConsumption: bigint;
|
|
47
|
+
static nftBurnGasConsumption: bigint;
|
|
48
|
+
static receiveTransferGasConsumption: bigint;
|
|
49
|
+
static sendTransferGasConsumption: bigint;
|
|
50
|
+
static burnGasConsumption: bigint;
|
|
45
51
|
static storageStats: StorageStats;
|
|
46
52
|
static stateInitStats: StorageStats;
|
|
53
|
+
static storageDuration: bigint;
|
|
47
54
|
constructor(address: Address, init?: {
|
|
48
55
|
code: Cell;
|
|
49
56
|
data: Cell;
|
|
@@ -189,5 +189,12 @@ class JettonWallet {
|
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
exports.JettonWallet = JettonWallet;
|
|
192
|
-
JettonWallet.
|
|
193
|
-
JettonWallet.
|
|
192
|
+
JettonWallet.mintAfterErrorGasConsumption = 9654n;
|
|
193
|
+
JettonWallet.burnNotificationGasConsumption = 10357n;
|
|
194
|
+
JettonWallet.nftBurnGasConsumption = 11552n;
|
|
195
|
+
JettonWallet.receiveTransferGasConsumption = 11427n;
|
|
196
|
+
JettonWallet.sendTransferGasConsumption = 10669n;
|
|
197
|
+
JettonWallet.burnGasConsumption = 8653n;
|
|
198
|
+
JettonWallet.storageStats = new GasUtils_1.StorageStats(949n, 3n);
|
|
199
|
+
JettonWallet.stateInitStats = new GasUtils_1.StorageStats(847n, 3n);
|
|
200
|
+
JettonWallet.storageDuration = 5n * 365n * 24n * 3600n;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Address, Cell, Contract, ContractProvider, Sender } from '@ton/core';
|
|
2
|
+
import { StorageStats } from './utils/GasUtils';
|
|
2
3
|
export declare const NFTCollectionOpCodes: {
|
|
3
4
|
admin_deployNFTItem: number;
|
|
4
5
|
admin_batchDeployNFTItems: number;
|
|
@@ -33,6 +34,14 @@ export declare class NFTCollection implements Contract {
|
|
|
33
34
|
code: Cell;
|
|
34
35
|
data: Cell;
|
|
35
36
|
} | undefined;
|
|
37
|
+
static stateInitStats: StorageStats;
|
|
38
|
+
static handleErrorNotificationGasConsumption: bigint;
|
|
39
|
+
static transferGasConsumption: bigint;
|
|
40
|
+
static burnGasConsumption: bigint;
|
|
41
|
+
static storageStats: StorageStats;
|
|
42
|
+
static initGasConsumption: bigint;
|
|
43
|
+
static nftHandleErrorNotificationGasConsumption: bigint;
|
|
44
|
+
static nftTransferGasConsumption: bigint;
|
|
36
45
|
constructor(address: Address, init?: {
|
|
37
46
|
code: Cell;
|
|
38
47
|
data: Cell;
|
|
@@ -4,6 +4,7 @@ exports.NFTCollection = exports.NFTCollectionErrors = exports.NFTCollectionOpCod
|
|
|
4
4
|
exports.nftCollectionConfigToCell = nftCollectionConfigToCell;
|
|
5
5
|
const core_1 = require("@ton/core");
|
|
6
6
|
const Constants_1 = require("./Constants");
|
|
7
|
+
const GasUtils_1 = require("./utils/GasUtils");
|
|
7
8
|
exports.NFTCollectionOpCodes = {
|
|
8
9
|
admin_deployNFTItem: 0xfdba5d5f,
|
|
9
10
|
admin_batchDeployNFTItems: 0x909d579b,
|
|
@@ -149,3 +150,11 @@ class NFTCollection {
|
|
|
149
150
|
}
|
|
150
151
|
}
|
|
151
152
|
exports.NFTCollection = NFTCollection;
|
|
153
|
+
NFTCollection.stateInitStats = new GasUtils_1.StorageStats(1328n, 5n);
|
|
154
|
+
NFTCollection.handleErrorNotificationGasConsumption = 4638n;
|
|
155
|
+
NFTCollection.transferGasConsumption = 11722n;
|
|
156
|
+
NFTCollection.burnGasConsumption = 11552n;
|
|
157
|
+
NFTCollection.storageStats = new GasUtils_1.StorageStats(7240n, 24n);
|
|
158
|
+
NFTCollection.initGasConsumption = 7546n;
|
|
159
|
+
NFTCollection.nftHandleErrorNotificationGasConsumption = 4638n;
|
|
160
|
+
NFTCollection.nftTransferGasConsumption = 11722n;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Address, Cell, Contract, ContractProvider, Sender } from '@ton/core';
|
|
2
|
+
import { StorageStats } from './utils/GasUtils';
|
|
2
3
|
export declare const NFTItemOpCodes: {
|
|
3
4
|
owner_transfer: number;
|
|
4
5
|
owner_burn: number;
|
|
@@ -41,6 +42,12 @@ export declare class NFTItem implements Contract {
|
|
|
41
42
|
code: Cell;
|
|
42
43
|
data: Cell;
|
|
43
44
|
} | undefined;
|
|
45
|
+
static stateInitStats: StorageStats;
|
|
46
|
+
static storageStats: StorageStats;
|
|
47
|
+
static handleErrorNotificationGasConsumption: bigint;
|
|
48
|
+
static transferGasConsumption: bigint;
|
|
49
|
+
static burnGasConsumption: bigint;
|
|
50
|
+
static initGasConsumption: bigint;
|
|
44
51
|
constructor(address: Address, init?: {
|
|
45
52
|
code: Cell;
|
|
46
53
|
data: Cell;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NFTItem = exports.NFTItemErrors = exports.NFTItemOpCodes = void 0;
|
|
4
4
|
exports.nftItemConfigToCell = nftItemConfigToCell;
|
|
5
5
|
const core_1 = require("@ton/core");
|
|
6
|
+
const GasUtils_1 = require("./utils/GasUtils");
|
|
6
7
|
exports.NFTItemOpCodes = {
|
|
7
8
|
owner_transfer: 0x5fcc3d14,
|
|
8
9
|
owner_burn: 0x3b390ce,
|
|
@@ -146,3 +147,9 @@ class NFTItem {
|
|
|
146
147
|
}
|
|
147
148
|
}
|
|
148
149
|
exports.NFTItem = NFTItem;
|
|
150
|
+
NFTItem.stateInitStats = new GasUtils_1.StorageStats(1328n, 5n);
|
|
151
|
+
NFTItem.storageStats = new GasUtils_1.StorageStats(1422n, 5n);
|
|
152
|
+
NFTItem.handleErrorNotificationGasConsumption = 4638n;
|
|
153
|
+
NFTItem.transferGasConsumption = 11722n;
|
|
154
|
+
NFTItem.burnGasConsumption = 11552n;
|
|
155
|
+
NFTItem.initGasConsumption = 7546n;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Address, Cell, Contract, ContractProvider, Sender } from '@ton/core';
|
|
2
|
+
import { StorageStats } from './utils/GasUtils';
|
|
2
3
|
export declare const NFTItemTransferOperation = 2332633442;
|
|
3
4
|
export declare const NFTProxyOpCodes: {
|
|
4
5
|
admin_changeAdmin: number;
|
|
@@ -32,6 +33,12 @@ export declare class NFTProxy implements Contract {
|
|
|
32
33
|
code: Cell;
|
|
33
34
|
data: Cell;
|
|
34
35
|
} | undefined;
|
|
36
|
+
static estimatedNftItemCells: bigint;
|
|
37
|
+
static estimatedNftItemBits: bigint;
|
|
38
|
+
static storageStats: StorageStats;
|
|
39
|
+
static ownershipAssignedGasConsumption: bigint;
|
|
40
|
+
static errorNotificationGasConsumption: bigint;
|
|
41
|
+
static msgToTvmGasConsumption: bigint;
|
|
35
42
|
constructor(address: Address, init?: {
|
|
36
43
|
code: Cell;
|
|
37
44
|
data: Cell;
|
|
@@ -4,10 +4,11 @@ exports.NFTProxy = exports.NFTProxyErrors = exports.NFTProxyOpCodes = exports.NF
|
|
|
4
4
|
exports.nftProxyConfigToCell = nftProxyConfigToCell;
|
|
5
5
|
const core_1 = require("@ton/core");
|
|
6
6
|
const Constants_1 = require("./Constants");
|
|
7
|
+
const GasUtils_1 = require("./utils/GasUtils");
|
|
7
8
|
exports.NFTItemTransferOperation = 0x8b092962;
|
|
8
9
|
exports.NFTProxyOpCodes = {
|
|
9
10
|
admin_changeAdmin: 0x581879bc,
|
|
10
|
-
admin_updateCode:
|
|
11
|
+
admin_updateCode: 0x6e7145f9,
|
|
11
12
|
ccl_evmMsgToTVMProxy: 0x7817b330,
|
|
12
13
|
ccl_errorNotification: 0xae7df95b,
|
|
13
14
|
ccl_tvmMsgToEVM: 0x6c582059,
|
|
@@ -155,3 +156,9 @@ class NFTProxy {
|
|
|
155
156
|
}
|
|
156
157
|
}
|
|
157
158
|
exports.NFTProxy = NFTProxy;
|
|
159
|
+
NFTProxy.estimatedNftItemCells = 25n;
|
|
160
|
+
NFTProxy.estimatedNftItemBits = 9877n;
|
|
161
|
+
NFTProxy.storageStats = new GasUtils_1.StorageStats(7512n, 15n);
|
|
162
|
+
NFTProxy.ownershipAssignedGasConsumption = 7688n;
|
|
163
|
+
NFTProxy.errorNotificationGasConsumption = 4737n;
|
|
164
|
+
NFTProxy.msgToTvmGasConsumption = 5348n;
|
|
@@ -148,5 +148,6 @@ class Settings {
|
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
exports.Settings = Settings;
|
|
151
|
+
Settings.storageStats = new GasUtils_1.StorageStats(38743n, 118n);
|
|
151
152
|
Settings.minStorageDuration = 10 * 365 * 24 * 3600; // 10 years
|
|
152
153
|
Settings.minStorageStats = new GasUtils_1.StorageStats(29557n, 104n);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Address, Cell } from '@ton/core';
|
|
2
|
+
export type CrossChainLayerPayload = {
|
|
3
|
+
operationId: bigint;
|
|
4
|
+
destinationAddress: Address;
|
|
5
|
+
destinationMsgValue: bigint;
|
|
6
|
+
payload: Cell;
|
|
7
|
+
maybeStateInit?: Cell;
|
|
8
|
+
};
|
|
9
|
+
export declare function CrossChainLayerPayloadToCell(payload: CrossChainLayerPayload): Cell;
|
|
10
|
+
export declare function CrossChainLayerPayloadFromCell(cell: Cell): CrossChainLayerPayload;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CrossChainLayerPayloadToCell = CrossChainLayerPayloadToCell;
|
|
4
|
+
exports.CrossChainLayerPayloadFromCell = CrossChainLayerPayloadFromCell;
|
|
5
|
+
const core_1 = require("@ton/core");
|
|
6
|
+
function CrossChainLayerPayloadToCell(payload) {
|
|
7
|
+
return (0, core_1.beginCell)()
|
|
8
|
+
.storeUint(payload.operationId, 256)
|
|
9
|
+
.storeAddress(payload.destinationAddress)
|
|
10
|
+
.storeCoins(payload.destinationMsgValue)
|
|
11
|
+
.storeRef(payload.payload)
|
|
12
|
+
.storeMaybeRef(payload.maybeStateInit)
|
|
13
|
+
.endCell();
|
|
14
|
+
}
|
|
15
|
+
function CrossChainLayerPayloadFromCell(cell) {
|
|
16
|
+
const slice = cell.beginParse();
|
|
17
|
+
return {
|
|
18
|
+
operationId: slice.loadUintBig(256),
|
|
19
|
+
destinationAddress: slice.loadAddress(),
|
|
20
|
+
destinationMsgValue: slice.loadCoins(),
|
|
21
|
+
payload: slice.loadRef(),
|
|
22
|
+
maybeStateInit: slice.loadMaybeRef() ?? undefined,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -4,4 +4,5 @@ export type MerkleRoot = {
|
|
|
4
4
|
validTimestamp: number;
|
|
5
5
|
};
|
|
6
6
|
export declare function cellToArray(addrDict: Cell | null): Array<MerkleRoot>;
|
|
7
|
-
export declare function
|
|
7
|
+
export declare function arrayToDict(arr: Array<MerkleRoot>): Dictionary<bigint, number>;
|
|
8
|
+
export declare function arrayToCell(arr: Array<MerkleRoot>): Cell;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cellToArray = cellToArray;
|
|
4
|
+
exports.arrayToDict = arrayToDict;
|
|
4
5
|
exports.arrayToCell = arrayToCell;
|
|
5
6
|
const core_1 = require("@ton/core");
|
|
6
7
|
const Constants_1 = require("../Constants");
|
|
@@ -18,10 +19,17 @@ function cellToArray(addrDict) {
|
|
|
18
19
|
}
|
|
19
20
|
return resArr;
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
+
function arrayToDict(arr) {
|
|
22
23
|
let dict = core_1.Dictionary.empty(core_1.Dictionary.Keys.BigUint(Constants_1.Params.bitsize.hash), core_1.Dictionary.Values.Uint(Constants_1.Params.bitsize.time));
|
|
23
24
|
for (let i = 0; i < arr.length; i++) {
|
|
24
25
|
dict.set(arr[i].root, arr[i].validTimestamp);
|
|
25
26
|
}
|
|
26
27
|
return dict;
|
|
27
28
|
}
|
|
29
|
+
function arrayToCell(arr) {
|
|
30
|
+
let dict = core_1.Dictionary.empty(core_1.Dictionary.Keys.BigUint(Constants_1.Params.bitsize.hash), core_1.Dictionary.Values.Uint(Constants_1.Params.bitsize.time));
|
|
31
|
+
for (let i = 0; i < arr.length; i++) {
|
|
32
|
+
dict.set(arr[i].root, arr[i].validTimestamp);
|
|
33
|
+
}
|
|
34
|
+
return (0, core_1.beginCell)().storeDictDirect(dict).endCell();
|
|
35
|
+
}
|
|
@@ -153,23 +153,27 @@ class RetryableContractOpener {
|
|
|
153
153
|
return { success: true, data: result.data };
|
|
154
154
|
}
|
|
155
155
|
lastError = result.lastError;
|
|
156
|
+
const isTransactionError = lastError instanceof errors_1.TransactionError;
|
|
157
|
+
const isContractExecutionError = !!lastError && this.isContractExecutionError(lastError);
|
|
158
|
+
const shouldStopOnNonTransportError = !!lastError && !!shouldFallbackOnError && !shouldFallbackOnError(lastError);
|
|
156
159
|
if (lastError) {
|
|
157
|
-
|
|
160
|
+
const stopReason = isTransactionError
|
|
161
|
+
? 'TransactionError'
|
|
162
|
+
: isContractExecutionError
|
|
163
|
+
? 'contract execution error'
|
|
164
|
+
: shouldStopOnNonTransportError
|
|
165
|
+
? 'non-transport error'
|
|
166
|
+
: undefined;
|
|
167
|
+
this.logger?.debug(`[RetryableContractOpener] ${operationName}: ${openerLabel} failed${stopReason ? ` (stopping fallback because of ${stopReason})` : ''}: ${lastError.message}`);
|
|
158
168
|
}
|
|
159
|
-
if (
|
|
160
|
-
this.logger?.debug(`[RetryableContractOpener] ${operationName}: stopping fallback because of TransactionError`);
|
|
169
|
+
if (isTransactionError) {
|
|
161
170
|
return { success: false, lastError };
|
|
162
171
|
}
|
|
163
|
-
if (
|
|
164
|
-
this.logger?.debug(`[RetryableContractOpener] ${operationName}: stopping fallback because of contract execution error`);
|
|
172
|
+
if (isContractExecutionError) {
|
|
165
173
|
return { success: false, lastError };
|
|
166
174
|
}
|
|
167
|
-
if (
|
|
168
|
-
|
|
169
|
-
if (!shouldFallback) {
|
|
170
|
-
this.logger?.debug(`[RetryableContractOpener] ${operationName}: stopping fallback due to non-transport error`);
|
|
171
|
-
return { success: false, lastError };
|
|
172
|
-
}
|
|
175
|
+
if (shouldStopOnNonTransportError) {
|
|
176
|
+
return { success: false, lastError };
|
|
173
177
|
}
|
|
174
178
|
}
|
|
175
179
|
return { success: false, lastError };
|
|
@@ -21,3 +21,4 @@ export declare class TonClient4Opener extends BaseContractOpener {
|
|
|
21
21
|
export declare function tonHubApi4Opener(network: Network, timeout?: number, logger?: ILogger): TonClient4Opener;
|
|
22
22
|
export declare function tonClient4Opener(client: TonClient4, logger?: ILogger): TonClient4Opener;
|
|
23
23
|
export declare function orbsOpener4(network: Network, timeout?: number, logger?: ILogger): Promise<TonClient4Opener>;
|
|
24
|
+
export declare function getOrbsOpener4WithRetry(network: Network, timeout?: number, logger?: ILogger, maxRetries?: number, delay?: number): Promise<TonClient4Opener>;
|
|
@@ -4,6 +4,8 @@ exports.TonClient4Opener = void 0;
|
|
|
4
4
|
exports.tonHubApi4Opener = tonHubApi4Opener;
|
|
5
5
|
exports.tonClient4Opener = tonClient4Opener;
|
|
6
6
|
exports.orbsOpener4 = orbsOpener4;
|
|
7
|
+
exports.getOrbsOpener4WithRetry = getOrbsOpener4WithRetry;
|
|
8
|
+
const ton_access_1 = require("@orbs-network/ton-access");
|
|
7
9
|
const ton_1 = require("@ton/ton");
|
|
8
10
|
const Consts_1 = require("../sdk/Consts");
|
|
9
11
|
const Struct_1 = require("../structs/Struct");
|
|
@@ -81,7 +83,13 @@ function tonClient4Opener(client, logger) {
|
|
|
81
83
|
return new TonClient4Opener(client, logger);
|
|
82
84
|
}
|
|
83
85
|
async function orbsOpener4(network, timeout = Consts_1.DEFAULT_HTTP_CLIENT_TIMEOUT_MS, logger) {
|
|
84
|
-
const
|
|
86
|
+
const tonNetwork = network === Struct_1.Network.MAINNET ? 'mainnet' : 'testnet';
|
|
87
|
+
const endpoint = await (0, ton_access_1.getHttpV4Endpoint)({ network: tonNetwork });
|
|
88
|
+
const client = new ton_1.TonClient4({ endpoint, timeout });
|
|
89
|
+
return new TonClient4Opener(client, logger);
|
|
90
|
+
}
|
|
91
|
+
async function getOrbsOpener4WithRetry(network, timeout = Consts_1.DEFAULT_HTTP_CLIENT_TIMEOUT_MS, logger, maxRetries = Consts_1.DEFAULT_RETRY_MAX_COUNT, delay = Consts_1.DEFAULT_RETRY_DELAY_MS) {
|
|
92
|
+
const endpoint = await (0, OpenerUtils_1.getHttpV4EndpointWithRetry)(network, maxRetries, delay);
|
|
85
93
|
const client = new ton_1.TonClient4({ endpoint, timeout });
|
|
86
94
|
return new TonClient4Opener(client, logger);
|
|
87
95
|
}
|
|
@@ -2,6 +2,7 @@ import { Address, Contract, OpenedContract, TonClient, Transaction } from '@ton/
|
|
|
2
2
|
import { ILogger } from '../interfaces';
|
|
3
3
|
import { AddressInformation, ContractState, GetTransactionsOptions, Network } from '../structs/Struct';
|
|
4
4
|
import { BaseContractOpener } from './BaseContractOpener';
|
|
5
|
+
import { TonClient4Opener } from './TonClient4Opener';
|
|
5
6
|
export declare class TonClientOpener extends BaseContractOpener {
|
|
6
7
|
private readonly client;
|
|
7
8
|
private readonly httpClient;
|
|
@@ -15,3 +16,4 @@ export declare class TonClientOpener extends BaseContractOpener {
|
|
|
15
16
|
}
|
|
16
17
|
export declare function tonClientOpener(client: TonClient, logger?: ILogger): TonClientOpener;
|
|
17
18
|
export declare function orbsOpener(network: Network, logger?: ILogger): Promise<TonClientOpener>;
|
|
19
|
+
export declare function getOrbsOpenerWithRetry(network: Network, timeout?: number, logger?: ILogger, maxRetries?: number, delay?: number): Promise<TonClient4Opener>;
|
|
@@ -3,12 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TonClientOpener = void 0;
|
|
4
4
|
exports.tonClientOpener = tonClientOpener;
|
|
5
5
|
exports.orbsOpener = orbsOpener;
|
|
6
|
+
exports.getOrbsOpenerWithRetry = getOrbsOpenerWithRetry;
|
|
7
|
+
const ton_access_1 = require("@orbs-network/ton-access");
|
|
6
8
|
const ton_1 = require("@ton/ton");
|
|
7
9
|
const AxiosHttpClient_1 = require("../sdk/AxiosHttpClient");
|
|
8
10
|
const Consts_1 = require("../sdk/Consts");
|
|
9
11
|
const Utils_1 = require("../sdk/Utils");
|
|
12
|
+
const Struct_1 = require("../structs/Struct");
|
|
10
13
|
const BaseContractOpener_1 = require("./BaseContractOpener");
|
|
11
14
|
const OpenerUtils_1 = require("./OpenerUtils");
|
|
15
|
+
const TonClient4Opener_1 = require("./TonClient4Opener");
|
|
12
16
|
class TonClientOpener extends BaseContractOpener_1.BaseContractOpener {
|
|
13
17
|
constructor(client, logger) {
|
|
14
18
|
super(logger);
|
|
@@ -66,7 +70,13 @@ function tonClientOpener(client, logger) {
|
|
|
66
70
|
return new TonClientOpener(client, logger);
|
|
67
71
|
}
|
|
68
72
|
async function orbsOpener(network, logger) {
|
|
69
|
-
const
|
|
73
|
+
const tonNetwork = network === Struct_1.Network.MAINNET ? 'mainnet' : 'testnet';
|
|
74
|
+
const endpoint = await (0, ton_access_1.getHttpEndpoint)({ network: tonNetwork });
|
|
70
75
|
const client = new ton_1.TonClient({ endpoint, timeout: Consts_1.DEFAULT_HTTP_CLIENT_TIMEOUT_MS });
|
|
71
76
|
return new TonClientOpener(client, logger);
|
|
72
77
|
}
|
|
78
|
+
async function getOrbsOpenerWithRetry(network, timeout = Consts_1.DEFAULT_HTTP_CLIENT_TIMEOUT_MS, logger, maxRetries = Consts_1.DEFAULT_RETRY_MAX_COUNT, delay = Consts_1.DEFAULT_RETRY_DELAY_MS) {
|
|
79
|
+
const endpoint = await (0, OpenerUtils_1.getHttpEndpointWithRetry)(network, maxRetries, delay);
|
|
80
|
+
const client = new ton_1.TonClient4({ endpoint, timeout });
|
|
81
|
+
return new TonClient4Opener_1.TonClient4Opener(client, logger);
|
|
82
|
+
}
|
|
@@ -8,6 +8,32 @@ class ErrorWithStatusCode extends Error {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
exports.ErrorWithStatusCode = ErrorWithStatusCode;
|
|
11
|
+
function asString(value) {
|
|
12
|
+
return typeof value === 'string' && value.length > 0 ? value : undefined;
|
|
13
|
+
}
|
|
14
|
+
function asNumber(value) {
|
|
15
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
if (typeof value === 'string' && value.trim().length > 0) {
|
|
19
|
+
const parsed = Number(value);
|
|
20
|
+
if (Number.isFinite(parsed)) {
|
|
21
|
+
return parsed;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
function extractResponseMessage(responseData) {
|
|
27
|
+
if (typeof responseData === 'string' && responseData.length > 0) {
|
|
28
|
+
return responseData;
|
|
29
|
+
}
|
|
30
|
+
const data = responseData;
|
|
31
|
+
const nestedError = data?.error && typeof data.error === 'object' ? data.error : undefined;
|
|
32
|
+
return (asString(data?.message) ??
|
|
33
|
+
asString(data?.error) ??
|
|
34
|
+
asString(nestedError?.message) ??
|
|
35
|
+
asString(nestedError?.error));
|
|
36
|
+
}
|
|
11
37
|
class ContractError extends ErrorWithStatusCode {
|
|
12
38
|
constructor(message, errorCode) {
|
|
13
39
|
super(message, errorCode);
|
|
@@ -22,21 +48,12 @@ class FetchError extends ErrorWithStatusCode {
|
|
|
22
48
|
this.inner = inner;
|
|
23
49
|
if (inner && typeof inner === 'object') {
|
|
24
50
|
const err = inner;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
else if (typeof err.response?.status === 'number') {
|
|
29
|
-
this.httpStatus = err.response.status;
|
|
30
|
-
}
|
|
31
|
-
if (typeof err.errorCode === 'number') {
|
|
32
|
-
this.innerErrorCode = err.errorCode;
|
|
33
|
-
}
|
|
51
|
+
this.httpStatus = asNumber(err.status) ?? asNumber(err.response?.status);
|
|
52
|
+
this.innerErrorCode = asNumber(err.errorCode);
|
|
34
53
|
if (typeof err.name === 'string') {
|
|
35
54
|
this.innerErrorName = err.name;
|
|
36
55
|
}
|
|
37
|
-
|
|
38
|
-
this.innerMessage = err.message;
|
|
39
|
-
}
|
|
56
|
+
this.innerMessage = extractResponseMessage(err.response?.data) ?? asString(err.message);
|
|
40
57
|
if (options?.includeInnerStack && typeof err.stack === 'string') {
|
|
41
58
|
this.innerStack = err.stack;
|
|
42
59
|
}
|
|
@@ -30,26 +30,47 @@ exports.invalidAssetType = new errors_1.FormatError('Invalid asset type', 114);
|
|
|
30
30
|
const prepareMessageGroupError = (isBocSizeValid, isDepthValid) => new errors_1.PrepareMessageGroupError(`Failed to prepare message group: BOC size valid: ${isBocSizeValid}, depth valid: ${isDepthValid}`, 115);
|
|
31
31
|
exports.prepareMessageGroupError = prepareMessageGroupError;
|
|
32
32
|
exports.noValidGroupFoundError = new errors_1.NoValidGroupFoundError('Failed to prepare valid message group', 116);
|
|
33
|
+
function extractEndpoint(message) {
|
|
34
|
+
const match = message.match(/https?:\/\/\S+/i);
|
|
35
|
+
if (!match) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
return match[0].replace(/[),.;]+$/, '');
|
|
39
|
+
}
|
|
40
|
+
function extractResponseMessage(data) {
|
|
41
|
+
if (typeof data === 'string' && data.length > 0) {
|
|
42
|
+
return data;
|
|
43
|
+
}
|
|
44
|
+
if (!data || typeof data !== 'object') {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
const payload = data;
|
|
48
|
+
if (typeof payload.message === 'string' && payload.message.length > 0) {
|
|
49
|
+
return payload.message;
|
|
50
|
+
}
|
|
51
|
+
if (typeof payload.error === 'string' && payload.error.length > 0) {
|
|
52
|
+
return payload.error;
|
|
53
|
+
}
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
33
56
|
function buildInnerErrorSummary(inner) {
|
|
34
57
|
if (inner && typeof inner === 'object') {
|
|
35
58
|
const err = inner;
|
|
36
59
|
const parts = [];
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
? err.response.status
|
|
41
|
-
: undefined;
|
|
60
|
+
const responseMessage = extractResponseMessage(err.response?.data);
|
|
61
|
+
const httpStatus = [err.httpStatus, err.status, err.response?.status].find((value) => typeof value === 'number');
|
|
62
|
+
const httpMessage = typeof err.innerMessage === 'string' && err.innerMessage.length > 0 ? err.innerMessage : responseMessage;
|
|
42
63
|
if (typeof httpStatus === 'number') {
|
|
43
64
|
parts.push(`httpStatus=${httpStatus}`);
|
|
44
65
|
}
|
|
45
|
-
if (typeof
|
|
46
|
-
parts.push(`
|
|
47
|
-
}
|
|
48
|
-
if (typeof err.name === 'string' && err.name.length > 0) {
|
|
49
|
-
parts.push(`name=${err.name}`);
|
|
66
|
+
if (typeof httpMessage === 'string' && httpMessage.length > 0) {
|
|
67
|
+
parts.push(`httpMessage=${httpMessage}`);
|
|
50
68
|
}
|
|
51
69
|
if (typeof err.message === 'string' && err.message.length > 0) {
|
|
52
|
-
|
|
70
|
+
const endpoint = extractEndpoint(err.message);
|
|
71
|
+
if (endpoint) {
|
|
72
|
+
parts.push(`endpoint=${endpoint}`);
|
|
73
|
+
}
|
|
53
74
|
}
|
|
54
75
|
if (parts.length > 0) {
|
|
55
76
|
return parts.join(', ');
|