@tonappchain/sdk 0.7.0-rc7.1 → 0.7.0-rc9
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/assets/AssetFactory.d.ts +4 -16
- package/dist/assets/AssetFactory.js +5 -4
- package/dist/assets/FT.d.ts +2 -1
- package/dist/assets/FT.js +36 -14
- package/dist/assets/NFT.d.ts +1 -1
- package/dist/assets/NFT.js +13 -5
- package/dist/sdk/LiteSequencerClient.d.ts +1 -0
- package/dist/sdk/LiteSequencerClient.js +18 -0
- package/dist/sdk/OperationTracker.d.ts +2 -0
- package/dist/sdk/OperationTracker.js +20 -0
- package/dist/sdk/TacSdk.d.ts +11 -3
- package/dist/sdk/TacSdk.js +53 -0
- package/dist/sdk/TransactionManager.js +6 -1
- package/dist/structs/Services.d.ts +27 -1
- package/dist/structs/Struct.d.ts +15 -0
- package/package.json +2 -2
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
import { IConfiguration } from '../structs/Services';
|
|
2
|
-
import { Asset,
|
|
2
|
+
import { Asset, AssetFromFTArg, AssetFromNFTCollectionArg, AssetFromNFTItemArg, EVMAddress, NFTAddressType, TVMAddress } from '../structs/Struct';
|
|
3
3
|
export declare class AssetFactory {
|
|
4
|
-
static from(configuration: IConfiguration, token:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} | {
|
|
8
|
-
address: TVMAddress | EVMAddress;
|
|
9
|
-
tokenType: AssetType.NFT;
|
|
10
|
-
addressType: NFTAddressType.COLLECTION;
|
|
11
|
-
index: bigint;
|
|
12
|
-
} | {
|
|
13
|
-
address: TVMAddress;
|
|
14
|
-
tokenType: AssetType.NFT;
|
|
15
|
-
addressType: NFTAddressType.ITEM;
|
|
16
|
-
}): Promise<Asset>;
|
|
17
|
-
private static createFTAsset;
|
|
18
|
-
private static createNFTAsset;
|
|
4
|
+
static from(configuration: IConfiguration, token: AssetFromFTArg | AssetFromNFTCollectionArg | AssetFromNFTItemArg): Promise<Asset>;
|
|
5
|
+
static createFTAsset(configuration: IConfiguration, address: TVMAddress | EVMAddress): Promise<Asset>;
|
|
6
|
+
static createNFTAsset(configuration: IConfiguration, address: TVMAddress | EVMAddress, addressType: NFTAddressType, index?: bigint): Promise<Asset>;
|
|
19
7
|
}
|
|
@@ -8,9 +8,10 @@ const FT_1 = require("./FT");
|
|
|
8
8
|
const NFT_1 = require("./NFT");
|
|
9
9
|
const TON_1 = require("./TON");
|
|
10
10
|
class AssetFactory {
|
|
11
|
-
/// PUBLIC
|
|
12
11
|
static async from(configuration, token) {
|
|
13
12
|
if (token.address === '' || token.address === configuration.nativeTONAddress) {
|
|
13
|
+
if (token.tokenType !== Struct_1.AssetType.FT)
|
|
14
|
+
throw (0, errors_1.unknownTokenTypeError)(token.address, 'detected TON, but token type is not FT');
|
|
14
15
|
return TON_1.TON.create(configuration);
|
|
15
16
|
}
|
|
16
17
|
const cachedAsset = AssetCache_1.AssetCache.get(token);
|
|
@@ -23,12 +24,12 @@ class AssetFactory {
|
|
|
23
24
|
AssetCache_1.AssetCache.set(token, asset);
|
|
24
25
|
return asset;
|
|
25
26
|
}
|
|
26
|
-
/// PRIVATE
|
|
27
|
-
/// CREATE FT ASSET
|
|
28
27
|
static async createFTAsset(configuration, address) {
|
|
28
|
+
if (address === configuration.nativeTONAddress || address === '') {
|
|
29
|
+
return TON_1.TON.create(configuration);
|
|
30
|
+
}
|
|
29
31
|
return FT_1.FT.fromAddress(configuration, address);
|
|
30
32
|
}
|
|
31
|
-
/// CREATE NFT ASSET
|
|
32
33
|
static async createNFTAsset(configuration, address, addressType, index) {
|
|
33
34
|
if (addressType === Struct_1.NFTAddressType.ITEM) {
|
|
34
35
|
return NFT_1.NFT.fromItem(configuration, address);
|
package/dist/assets/FT.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { AssetType, ContractOpener, EVMAddress, FeeParams, TVMAddress, UserWalle
|
|
|
6
6
|
import { Asset, Origin } from '../structs/Struct';
|
|
7
7
|
import { JettonWallet } from '../wrappers/JettonWallet';
|
|
8
8
|
export declare class FT implements Asset {
|
|
9
|
-
private
|
|
9
|
+
private _tvmAddress;
|
|
10
10
|
readonly type: AssetType;
|
|
11
11
|
readonly origin: Origin;
|
|
12
12
|
private _configuration;
|
|
@@ -18,6 +18,7 @@ export declare class FT implements Asset {
|
|
|
18
18
|
static getJettonData(contractOpener: ContractOpener, address: TVMAddress): Promise<import("../wrappers/JettonMaster").JettonMasterData>;
|
|
19
19
|
static getOrigin(configuration: IConfiguration, address: TVMAddress): Promise<Origin>;
|
|
20
20
|
static getTVMAddress(configuration: IConfiguration, address: EVMAddress): Promise<string>;
|
|
21
|
+
static getEVMAddress(configuration: IConfiguration, address: TVMAddress): Promise<string>;
|
|
21
22
|
private constructor();
|
|
22
23
|
static fromAddress(configuration: IConfiguration, address: TVMAddress | EVMAddress): Promise<FT>;
|
|
23
24
|
get rawAmount(): bigint;
|
package/dist/assets/FT.js
CHANGED
|
@@ -14,7 +14,7 @@ const JettonMaster_1 = require("../wrappers/JettonMaster");
|
|
|
14
14
|
const JettonWallet_1 = require("../wrappers/JettonWallet");
|
|
15
15
|
class FT {
|
|
16
16
|
get address() {
|
|
17
|
-
return this.
|
|
17
|
+
return this._tvmAddress.toString({ bounceable: true });
|
|
18
18
|
}
|
|
19
19
|
static async getJettonData(contractOpener, address) {
|
|
20
20
|
Validator_1.Validator.validateTVMAddress(address);
|
|
@@ -48,12 +48,14 @@ class FT {
|
|
|
48
48
|
}
|
|
49
49
|
static async getTVMAddress(configuration, address) {
|
|
50
50
|
Validator_1.Validator.validateEVMAddress(address);
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
// If token is TON native
|
|
52
|
+
const fromTVM = await configuration.TACParams.tokenUtils['exists(address)'](address);
|
|
53
|
+
if (fromTVM) {
|
|
53
54
|
const erc20Token = configuration.artifacts.tac.wrappers.CrossChainLayerERC20FactoryTAC.connect(address, configuration.TACParams.provider);
|
|
54
55
|
const info = await erc20Token.getInfo();
|
|
55
56
|
return info.tvmAddress;
|
|
56
57
|
}
|
|
58
|
+
// If token is TAC native
|
|
57
59
|
const jettonMaster = JettonMaster_1.JettonMaster.createFromConfig({
|
|
58
60
|
evmTokenAddress: address,
|
|
59
61
|
crossChainLayerAddress: ton_1.Address.parse(configuration.TONParams.crossChainLayerAddress),
|
|
@@ -62,11 +64,22 @@ class FT {
|
|
|
62
64
|
});
|
|
63
65
|
return jettonMaster.address.toString();
|
|
64
66
|
}
|
|
67
|
+
static async getEVMAddress(configuration, address) {
|
|
68
|
+
const tokenAddressString = ton_1.Address.parse(address).toString({ bounceable: true });
|
|
69
|
+
const origin = await FT.getOrigin(configuration, address);
|
|
70
|
+
if (origin === Struct_2.Origin.TON) {
|
|
71
|
+
return configuration.TACParams.tokenUtils.computeAddress(tokenAddressString);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
const givenMinter = configuration.TONParams.contractOpener.open(new JettonMaster_1.JettonMaster(ton_1.Address.parse(tokenAddressString)));
|
|
75
|
+
return givenMinter.getEVMAddress();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
65
78
|
constructor(address, origin, configuration) {
|
|
66
79
|
this.type = Struct_1.AssetType.FT;
|
|
67
|
-
this.
|
|
80
|
+
this._tvmAddress = ton_1.Address.parse(address);
|
|
68
81
|
this._configuration = configuration;
|
|
69
|
-
this._jettonMinter = this._configuration.TONParams.contractOpener.open(new JettonMaster_1.JettonMaster(this.
|
|
82
|
+
this._jettonMinter = this._configuration.TONParams.contractOpener.open(new JettonMaster_1.JettonMaster(this._tvmAddress));
|
|
70
83
|
this.origin = origin;
|
|
71
84
|
this._transferAmount = 0n;
|
|
72
85
|
}
|
|
@@ -78,13 +91,17 @@ class FT {
|
|
|
78
91
|
}
|
|
79
92
|
throw e;
|
|
80
93
|
});
|
|
81
|
-
|
|
94
|
+
const token = new FT(tvmAddress, origin, configuration);
|
|
95
|
+
if ((0, ethers_1.isAddress)(address)) {
|
|
96
|
+
token._evmAddress = address;
|
|
97
|
+
}
|
|
98
|
+
return token;
|
|
82
99
|
}
|
|
83
100
|
get rawAmount() {
|
|
84
101
|
return this._transferAmount;
|
|
85
102
|
}
|
|
86
103
|
get clone() {
|
|
87
|
-
const ft = new FT(this.
|
|
104
|
+
const ft = new FT(this._tvmAddress.toString(), this.origin, this._configuration);
|
|
88
105
|
ft._transferAmount = this._transferAmount;
|
|
89
106
|
ft._evmAddress = this._evmAddress;
|
|
90
107
|
ft._decimals = this._decimals;
|
|
@@ -128,16 +145,21 @@ class FT {
|
|
|
128
145
|
if (this._evmAddress) {
|
|
129
146
|
return this._evmAddress;
|
|
130
147
|
}
|
|
131
|
-
|
|
132
|
-
|
|
148
|
+
const tokenAddressString = this._tvmAddress.toString({ bounceable: true });
|
|
149
|
+
if (this.origin === Struct_2.Origin.TON) {
|
|
150
|
+
this._evmAddress = await this._configuration.TACParams.tokenUtils.computeAddress(tokenAddressString);
|
|
151
|
+
}
|
|
152
|
+
else if (this.origin === Struct_2.Origin.TAC) {
|
|
153
|
+
const givenMinter = this._configuration.TONParams.contractOpener.open(new JettonMaster_1.JettonMaster(ton_1.Address.parse(tokenAddressString)));
|
|
154
|
+
this._evmAddress = await givenMinter.getEVMAddress();
|
|
133
155
|
}
|
|
134
156
|
else {
|
|
135
|
-
|
|
157
|
+
throw (0, errors_1.unknownTokenTypeError)(tokenAddressString, 'Token origin is neither TON nor TAC');
|
|
136
158
|
}
|
|
137
159
|
return this._evmAddress;
|
|
138
160
|
}
|
|
139
161
|
async getTVMAddress() {
|
|
140
|
-
return this.
|
|
162
|
+
return this._tvmAddress.toString({ bounceable: true });
|
|
141
163
|
}
|
|
142
164
|
async generatePayload(params) {
|
|
143
165
|
const { excessReceiver, evmData, crossChainTonAmount = 0n, forwardFeeTonAmount = 0n, feeParams } = params;
|
|
@@ -154,7 +176,7 @@ class FT {
|
|
|
154
176
|
return payload;
|
|
155
177
|
}
|
|
156
178
|
get opType() {
|
|
157
|
-
return this.origin ===
|
|
179
|
+
return this.origin === Struct_2.Origin.TAC ? InternalStruct_1.AssetOpType.JETTON_BURN : InternalStruct_1.AssetOpType.JETTON_TRANSFER;
|
|
158
180
|
}
|
|
159
181
|
async getWallet(userAddress) {
|
|
160
182
|
const walletAddress = await this.getUserWalletAddress(userAddress);
|
|
@@ -168,7 +190,7 @@ class FT {
|
|
|
168
190
|
return BigInt(await wallet.getJettonBalance());
|
|
169
191
|
}
|
|
170
192
|
async getUserBalanceExtended(userAddress) {
|
|
171
|
-
const masterState = await this._configuration.TONParams.contractOpener.getContractState(this.
|
|
193
|
+
const masterState = await this._configuration.TONParams.contractOpener.getContractState(this._tvmAddress);
|
|
172
194
|
if (masterState.state !== 'active') {
|
|
173
195
|
return { exists: false };
|
|
174
196
|
}
|
|
@@ -185,7 +207,7 @@ class FT {
|
|
|
185
207
|
async checkBalance(userAddress) {
|
|
186
208
|
const balance = await this.getUserBalance(userAddress);
|
|
187
209
|
if (balance < this._transferAmount) {
|
|
188
|
-
throw (0, errors_1.insufficientBalanceError)(this.
|
|
210
|
+
throw (0, errors_1.insufficientBalanceError)(this._tvmAddress.toString());
|
|
189
211
|
}
|
|
190
212
|
}
|
|
191
213
|
async checkCanBeTransferedBy(userAddress) {
|
package/dist/assets/NFT.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export declare class NFT implements Asset {
|
|
|
30
30
|
static getCollectionData(contractOpener: ContractOpener, collectionAddress: TVMAddress): Promise<{
|
|
31
31
|
nextIndex: number;
|
|
32
32
|
content: Cell;
|
|
33
|
-
|
|
33
|
+
adminAddress: Address;
|
|
34
34
|
}>;
|
|
35
35
|
static getOrigin(configuration: IConfiguration, itemOrCollection: TVMAddress): Promise<Origin>;
|
|
36
36
|
static getItemAddress(contractOpener: ContractOpener, collectionAddress: TVMAddress, index: bigint): Promise<string>;
|
package/dist/assets/NFT.js
CHANGED
|
@@ -98,8 +98,10 @@ class NFT {
|
|
|
98
98
|
}
|
|
99
99
|
else {
|
|
100
100
|
const nftCollection = configuration.TONParams.contractOpener.open(wrappers_1.NFTCollection.createFromConfig({
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
adminAddress: (0, ton_1.address)(configuration.TONParams.crossChainLayerAddress),
|
|
102
|
+
newAdminAddress: null,
|
|
103
|
+
collectionContent: (0, ton_1.beginCell)().endCell(),
|
|
104
|
+
commonContent: (0, ton_1.beginCell)().endCell(),
|
|
103
105
|
nftItemCode: configuration.TONParams.nftItemCode,
|
|
104
106
|
originalAddress: collectionAddress,
|
|
105
107
|
}, configuration.TONParams.nftCollectionCode));
|
|
@@ -142,11 +144,17 @@ class NFT {
|
|
|
142
144
|
if (this._addresses.evmAddress) {
|
|
143
145
|
return this._addresses.evmAddress;
|
|
144
146
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
+
const tvmNFTAddress = ton_1.Address.parse(this._addresses.collection).toString({ bounceable: true });
|
|
148
|
+
const { code: givenNFTCollection } = await this._configuration.TONParams.contractOpener.getContractState(ton_1.Address.parse(tvmNFTAddress));
|
|
149
|
+
if (givenNFTCollection &&
|
|
150
|
+
this._configuration.TONParams.nftCollectionCode.equals(ton_1.Cell.fromBoc(givenNFTCollection)[0])) {
|
|
151
|
+
const nftCollection = this._configuration.TONParams.contractOpener.open(wrappers_1.NFTCollection.createFromAddress((0, ton_1.address)(tvmNFTAddress)));
|
|
152
|
+
const evmAddress = await nftCollection.getOriginalAddress();
|
|
153
|
+
this._addresses.evmAddress = evmAddress.toString();
|
|
147
154
|
}
|
|
148
155
|
else {
|
|
149
|
-
this._addresses.evmAddress =
|
|
156
|
+
this._addresses.evmAddress =
|
|
157
|
+
await this._configuration.TACParams.tokenUtils.computeAddressERC721(tvmNFTAddress);
|
|
150
158
|
}
|
|
151
159
|
return this._addresses.evmAddress;
|
|
152
160
|
}
|
|
@@ -3,6 +3,7 @@ export declare class LiteSequencerClient {
|
|
|
3
3
|
private readonly endpoint;
|
|
4
4
|
private readonly maxChunkSize;
|
|
5
5
|
constructor(endpoint: string, maxChunkSize?: number);
|
|
6
|
+
getOperationIdByTransactionHash(transactionHash: string): Promise<string>;
|
|
6
7
|
getOperationType(operationId: string): Promise<OperationType>;
|
|
7
8
|
getOperationId(transactionLinker: TransactionLinker): Promise<string>;
|
|
8
9
|
getOperationIdsByShardsKeys(shardsKeys: string[], caller: string, chunkSize?: number): Promise<OperationIdsByShardsKey>;
|
|
@@ -12,6 +12,24 @@ class LiteSequencerClient {
|
|
|
12
12
|
this.endpoint = endpoint;
|
|
13
13
|
this.maxChunkSize = maxChunkSize;
|
|
14
14
|
}
|
|
15
|
+
async getOperationIdByTransactionHash(transactionHash) {
|
|
16
|
+
const isEthHash = /^0x[a-fA-F0-9]{64}$/.test(transactionHash);
|
|
17
|
+
const path = isEthHash ? 'tac/operation-id' : 'ton/operation-id';
|
|
18
|
+
try {
|
|
19
|
+
const response = await axios_1.default.get(new URL(path, this.endpoint).toString(), {
|
|
20
|
+
params: { transactionHash },
|
|
21
|
+
});
|
|
22
|
+
return response.data.response || '';
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
26
|
+
if (error.response?.status === 404) {
|
|
27
|
+
return '';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
throw (0, errors_1.operationFetchError)(`endpoint ${this.endpoint} failed to complete request`, error);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
15
33
|
async getOperationType(operationId) {
|
|
16
34
|
try {
|
|
17
35
|
const response = await axios_1.default.get(new URL('operation-type', this.endpoint).toString(), {
|
|
@@ -6,6 +6,7 @@ export interface ILiteSequencerClientFactory {
|
|
|
6
6
|
export interface ILiteSequencerClient {
|
|
7
7
|
getOperationType(operationId: string): Promise<OperationType>;
|
|
8
8
|
getOperationId(transactionLinker: TransactionLinker): Promise<string>;
|
|
9
|
+
getOperationIdByTransactionHash(transactionHash: string): Promise<string>;
|
|
9
10
|
getOperationIdsByShardsKeys(shardsKeys: string[], caller: string, chunkSize?: number): Promise<OperationIdsByShardsKey>;
|
|
10
11
|
getStageProfilings(operationIds: string[], chunkSize?: number): Promise<ExecutionStagesByOperationId>;
|
|
11
12
|
getOperationStatuses(operationIds: string[], chunkSize?: number): Promise<StatusInfosByOperationId>;
|
|
@@ -17,6 +18,7 @@ export declare class OperationTracker implements IOperationTracker {
|
|
|
17
18
|
private readonly clients;
|
|
18
19
|
private readonly logger;
|
|
19
20
|
constructor(network: Network, customLiteSequencerEndpoints?: string[], logger?: ILogger, clientFactory?: ILiteSequencerClientFactory);
|
|
21
|
+
getOperationIdByTransactionHash(transactionHash: string, waitOptions?: WaitOptions<string>): Promise<string>;
|
|
20
22
|
getOperationType(operationId: string, waitOptions?: WaitOptions<OperationType>): Promise<OperationType>;
|
|
21
23
|
getOperationId(transactionLinker: TransactionLinker, waitOptions?: WaitOptions<string>): Promise<string>;
|
|
22
24
|
getOperationIdsByShardsKeys(shardsKeys: string[], caller: string, waitOptions?: WaitOptions<OperationIdsByShardsKey>, chunkSize?: number): Promise<OperationIdsByShardsKey>;
|
|
@@ -22,6 +22,26 @@ class OperationTracker {
|
|
|
22
22
|
this.clients = clientFactory.createClients(endpoints);
|
|
23
23
|
this.logger = logger;
|
|
24
24
|
}
|
|
25
|
+
async getOperationIdByTransactionHash(transactionHash, waitOptions) {
|
|
26
|
+
this.logger.debug(`Getting operation ID for transactionHash: ${(0, Utils_1.formatObjectForLogging)(transactionHash)}`);
|
|
27
|
+
const requestFn = async () => {
|
|
28
|
+
let lastError;
|
|
29
|
+
for (const client of this.clients) {
|
|
30
|
+
try {
|
|
31
|
+
const id = await client.getOperationIdByTransactionHash(transactionHash);
|
|
32
|
+
this.logger.debug(`Operation ID ${id == '' ? 'does not exist' : 'retrieved successfully'}`);
|
|
33
|
+
return id;
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
this.logger.warn(`Failed to get OperationId by transactionHash using one of the endpoints`);
|
|
37
|
+
lastError = error;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
this.logger.error('All endpoints failed to get operation id by transactionHash');
|
|
41
|
+
throw (0, errors_1.allEndpointsFailedError)(lastError);
|
|
42
|
+
};
|
|
43
|
+
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn) : await requestFn();
|
|
44
|
+
}
|
|
25
45
|
async getOperationType(operationId, waitOptions) {
|
|
26
46
|
this.logger.debug(`Getting operation type for ${(0, Utils_1.formatObjectForLogging)(operationId)}`);
|
|
27
47
|
const requestFn = async () => {
|
package/dist/sdk/TacSdk.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Wallet } from 'ethers';
|
|
2
2
|
import type { SenderAbstraction } from '../sender';
|
|
3
|
-
import { IConfiguration, ILogger } from '../structs/Services';
|
|
4
|
-
import { Asset, CrossChainTransactionOptions, CrosschainTx, EvmProxyMsg, ExecutionFeeEstimationResult, OperationIdsByShardsKey, SDKParams, SuggestedTONExecutorFee, TACSimulationRequest, TACSimulationResult, TransactionLinkerWithOperationId, WaitOptions } from '../structs/Struct';
|
|
5
|
-
export declare class TacSdk {
|
|
3
|
+
import { IConfiguration, ILogger, ITacSDK } from '../structs/Services';
|
|
4
|
+
import { Asset, CrossChainTransactionOptions, CrosschainTx, EvmProxyMsg, ExecutionFeeEstimationResult, NFTAddressType, NFTItemData, OperationIdsByShardsKey, SDKParams, SuggestedTONExecutorFee, TACSimulationRequest, TACSimulationResult, TransactionLinkerWithOperationId, UserWalletBalanceExtended, WaitOptions } from '../structs/Struct';
|
|
5
|
+
export declare class TacSdk implements ITacSDK {
|
|
6
6
|
readonly config: IConfiguration;
|
|
7
7
|
private readonly simulator;
|
|
8
8
|
private readonly transactionManager;
|
|
@@ -21,4 +21,12 @@ export declare class TacSdk {
|
|
|
21
21
|
isContractDeployedOnTVM(address: string): Promise<boolean>;
|
|
22
22
|
simulateTACMessage(req: TACSimulationRequest): Promise<TACSimulationResult>;
|
|
23
23
|
simulateTransactions(sender: SenderAbstraction, txs: CrosschainTx[]): Promise<TACSimulationResult[]>;
|
|
24
|
+
getUserJettonWalletAddress(userAddress: string, tokenAddress: string): Promise<string>;
|
|
25
|
+
getUserJettonBalance(userAddress: string, tokenAddress: string): Promise<bigint>;
|
|
26
|
+
getUserJettonBalanceExtended(userAddress: string, tokenAddress: string): Promise<UserWalletBalanceExtended>;
|
|
27
|
+
getNFTItemData(itemAddress: string): Promise<NFTItemData>;
|
|
28
|
+
getEVMTokenAddress(tvmTokenAddress: string): Promise<string>;
|
|
29
|
+
getTVMTokenAddress(evmTokenAddress: string): Promise<string>;
|
|
30
|
+
getTVMNFTAddress(evmNFTAddress: string, tokenId?: number | bigint): Promise<string>;
|
|
31
|
+
getEVMNFTAddress(tvmNFTAddress: string, addressType: NFTAddressType): Promise<string>;
|
|
24
32
|
}
|
package/dist/sdk/TacSdk.js
CHANGED
|
@@ -34,6 +34,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.TacSdk = void 0;
|
|
37
|
+
const assets_1 = require("../assets");
|
|
38
|
+
const FT_1 = require("../assets/FT");
|
|
39
|
+
const NFT_1 = require("../assets/NFT");
|
|
40
|
+
const TON_1 = require("../assets/TON");
|
|
37
41
|
const Struct_1 = require("../structs/Struct");
|
|
38
42
|
const Configuration_1 = require("./Configuration");
|
|
39
43
|
const Consts_1 = require("./Consts");
|
|
@@ -97,5 +101,54 @@ class TacSdk {
|
|
|
97
101
|
async simulateTransactions(sender, txs) {
|
|
98
102
|
return this.simulator.simulateTransactions(sender, txs);
|
|
99
103
|
}
|
|
104
|
+
// Jetton methods
|
|
105
|
+
async getUserJettonWalletAddress(userAddress, tokenAddress) {
|
|
106
|
+
const ft = await assets_1.AssetFactory.from(this.config, {
|
|
107
|
+
address: tokenAddress,
|
|
108
|
+
tokenType: Struct_1.AssetType.FT,
|
|
109
|
+
});
|
|
110
|
+
return ft.getUserWalletAddress(userAddress);
|
|
111
|
+
}
|
|
112
|
+
async getUserJettonBalance(userAddress, tokenAddress) {
|
|
113
|
+
const ft = await assets_1.AssetFactory.from(this.config, {
|
|
114
|
+
address: tokenAddress,
|
|
115
|
+
tokenType: Struct_1.AssetType.FT,
|
|
116
|
+
});
|
|
117
|
+
return ft.getUserBalance(userAddress);
|
|
118
|
+
}
|
|
119
|
+
async getUserJettonBalanceExtended(userAddress, tokenAddress) {
|
|
120
|
+
const ft = await assets_1.AssetFactory.from(this.config, {
|
|
121
|
+
address: tokenAddress,
|
|
122
|
+
tokenType: Struct_1.AssetType.FT,
|
|
123
|
+
});
|
|
124
|
+
return ft.getUserBalanceExtended(userAddress);
|
|
125
|
+
}
|
|
126
|
+
// NFT methods
|
|
127
|
+
async getNFTItemData(itemAddress) {
|
|
128
|
+
return NFT_1.NFT.getItemData(this.config.TONParams.contractOpener, itemAddress);
|
|
129
|
+
}
|
|
130
|
+
// Address conversion methods
|
|
131
|
+
async getEVMTokenAddress(tvmTokenAddress) {
|
|
132
|
+
if (tvmTokenAddress === this.nativeTONAddress || tvmTokenAddress === '') {
|
|
133
|
+
return TON_1.TON.create(this.config).getEVMAddress();
|
|
134
|
+
}
|
|
135
|
+
return FT_1.FT.getEVMAddress(this.config, tvmTokenAddress);
|
|
136
|
+
}
|
|
137
|
+
async getTVMTokenAddress(evmTokenAddress) {
|
|
138
|
+
return FT_1.FT.getTVMAddress(this.config, evmTokenAddress);
|
|
139
|
+
}
|
|
140
|
+
async getTVMNFTAddress(evmNFTAddress, tokenId) {
|
|
141
|
+
return NFT_1.NFT.getTVMAddress(this.config, evmNFTAddress, tokenId === undefined ? undefined : BigInt(tokenId));
|
|
142
|
+
}
|
|
143
|
+
async getEVMNFTAddress(tvmNFTAddress, addressType) {
|
|
144
|
+
if (addressType === Struct_1.NFTAddressType.ITEM) {
|
|
145
|
+
const nft = await NFT_1.NFT.fromItem(this.config, tvmNFTAddress);
|
|
146
|
+
return nft.getEVMAddress();
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
const nftCollection = await NFT_1.NFT.fromCollection(this.config, { collection: tvmNFTAddress, index: 0n });
|
|
150
|
+
return nftCollection.getEVMAddress();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
100
153
|
}
|
|
101
154
|
exports.TacSdk = TacSdk;
|
|
@@ -137,10 +137,15 @@ class TransactionManager {
|
|
|
137
137
|
return waitOptions
|
|
138
138
|
? {
|
|
139
139
|
sendTransactionResult,
|
|
140
|
-
operationId: await this.operationTracker
|
|
140
|
+
operationId: await this.operationTracker
|
|
141
|
+
.getOperationId(transactionLinker, {
|
|
141
142
|
...waitOptions,
|
|
142
143
|
successCheck: (operationId) => !!operationId,
|
|
143
144
|
logger: this.logger,
|
|
145
|
+
})
|
|
146
|
+
.catch((error) => {
|
|
147
|
+
this.logger.error(`Error while waiting for operation ID: ${error}`);
|
|
148
|
+
return undefined;
|
|
144
149
|
}),
|
|
145
150
|
...transactionLinker,
|
|
146
151
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { mainnet, testnet } from '@tonappchain/artifacts';
|
|
2
|
+
import { Wallet } from 'ethers';
|
|
2
3
|
import type { SenderAbstraction } from '../sender';
|
|
3
4
|
import { InternalTACParams, InternalTONParams } from './InternalStruct';
|
|
4
|
-
import { Asset, CrosschainTx, EvmProxyMsg, ExecutionFeeEstimationResult, ExecutionStages, ExecutionStagesByOperationId, Network, OperationIdsByShardsKey, OperationType, SimplifiedStatuses, StatusInfo, StatusInfosByOperationId, SuggestedTONExecutorFee, TACSimulationRequest, TACSimulationResult, TransactionLinker, WaitOptions } from './Struct';
|
|
5
|
+
import { Asset, CrossChainTransactionOptions, CrosschainTx, EvmProxyMsg, ExecutionFeeEstimationResult, ExecutionStages, ExecutionStagesByOperationId, Network, NFTAddressType, NFTItemData, OperationIdsByShardsKey, OperationType, SimplifiedStatuses, StatusInfo, StatusInfosByOperationId, SuggestedTONExecutorFee, TACSimulationRequest, TACSimulationResult, TransactionLinker, TransactionLinkerWithOperationId, UserWalletBalanceExtended, WaitOptions } from './Struct';
|
|
5
6
|
export interface IConfiguration {
|
|
6
7
|
readonly network: Network;
|
|
7
8
|
readonly artifacts: typeof testnet | typeof mainnet;
|
|
@@ -31,6 +32,7 @@ export interface ISimulator {
|
|
|
31
32
|
export interface IOperationTracker {
|
|
32
33
|
getOperationType(operationId: string, waitOptions?: WaitOptions<OperationType>): Promise<OperationType>;
|
|
33
34
|
getOperationId(transactionLinker: TransactionLinker, waitOptions?: WaitOptions<string>): Promise<string>;
|
|
35
|
+
getOperationIdByTransactionHash(transactionHash: string, waitOptions?: WaitOptions<string>): Promise<string>;
|
|
34
36
|
getOperationIdsByShardsKeys(shardsKeys: string[], caller: string, waitOptions?: WaitOptions<OperationIdsByShardsKey>, chunkSize?: number): Promise<OperationIdsByShardsKey>;
|
|
35
37
|
getStageProfiling(operationId: string, waitOptions?: WaitOptions<ExecutionStages>): Promise<ExecutionStages>;
|
|
36
38
|
getStageProfilings(operationIds: string[], waitOptions?: WaitOptions<ExecutionStagesByOperationId>, chunkSize?: number): Promise<ExecutionStagesByOperationId>;
|
|
@@ -38,3 +40,27 @@ export interface IOperationTracker {
|
|
|
38
40
|
getOperationStatus(operationId: string, waitOptions?: WaitOptions<StatusInfo>): Promise<StatusInfo>;
|
|
39
41
|
getSimplifiedOperationStatus(transactionLinker: TransactionLinker): Promise<SimplifiedStatuses>;
|
|
40
42
|
}
|
|
43
|
+
export interface ITacSDK {
|
|
44
|
+
readonly config: IConfiguration;
|
|
45
|
+
get nativeTONAddress(): string;
|
|
46
|
+
nativeTACAddress(): Promise<string>;
|
|
47
|
+
get getTrustedTACExecutors(): string[];
|
|
48
|
+
get getTrustedTONExecutors(): string[];
|
|
49
|
+
closeConnections(): unknown;
|
|
50
|
+
simulateTACMessage(req: TACSimulationRequest): Promise<TACSimulationResult>;
|
|
51
|
+
simulateTransactions(sender: SenderAbstraction, txs: CrosschainTx[]): Promise<TACSimulationResult[]>;
|
|
52
|
+
getTransactionSimulationInfo(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: Asset[]): Promise<ExecutionFeeEstimationResult>;
|
|
53
|
+
getTVMExecutorFeeInfo(assets: Asset[], feeSymbol: string): Promise<SuggestedTONExecutorFee>;
|
|
54
|
+
sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: Asset[], options?: CrossChainTransactionOptions, waitOptions?: WaitOptions<string>): Promise<TransactionLinkerWithOperationId>;
|
|
55
|
+
sendCrossChainTransactions(sender: SenderAbstraction, txs: CrosschainTx[], waitOptions?: WaitOptions<OperationIdsByShardsKey>): Promise<TransactionLinkerWithOperationId[]>;
|
|
56
|
+
bridgeTokensToTON(signer: Wallet, value: bigint, tonTarget: string, assets?: Asset[], tvmExecutorFee?: bigint): Promise<string>;
|
|
57
|
+
getUserJettonWalletAddress(userAddress: string, tokenAddress: string): Promise<string>;
|
|
58
|
+
getUserJettonBalance(userAddress: string, tokenAddress: string): Promise<bigint>;
|
|
59
|
+
getUserJettonBalanceExtended(userAddress: string, tokenAddress: string): Promise<UserWalletBalanceExtended>;
|
|
60
|
+
getNFTItemData(itemAddress: string): Promise<NFTItemData>;
|
|
61
|
+
getEVMTokenAddress(tvmTokenAddress: string): Promise<string>;
|
|
62
|
+
getTVMTokenAddress(evmTokenAddress: string): Promise<string>;
|
|
63
|
+
getTVMNFTAddress(evmNFTAddress: string, tokenId?: number | bigint): Promise<string>;
|
|
64
|
+
getEVMNFTAddress(tvmNFTAddress: string, addressType: NFTAddressType): Promise<string>;
|
|
65
|
+
isContractDeployedOnTVM(address: string): Promise<boolean>;
|
|
66
|
+
}
|
package/dist/structs/Struct.d.ts
CHANGED
|
@@ -356,3 +356,18 @@ export declare enum Origin {
|
|
|
356
356
|
}
|
|
357
357
|
export type TVMAddress = string;
|
|
358
358
|
export type EVMAddress = string;
|
|
359
|
+
export type AssetFromFTArg = {
|
|
360
|
+
address: TVMAddress | EVMAddress;
|
|
361
|
+
tokenType: AssetType.FT;
|
|
362
|
+
};
|
|
363
|
+
export type AssetFromNFTCollectionArg = {
|
|
364
|
+
address: TVMAddress | EVMAddress;
|
|
365
|
+
tokenType: AssetType.NFT;
|
|
366
|
+
addressType: NFTAddressType.COLLECTION;
|
|
367
|
+
index: bigint;
|
|
368
|
+
};
|
|
369
|
+
export type AssetFromNFTItemArg = {
|
|
370
|
+
address: TVMAddress;
|
|
371
|
+
tokenType: AssetType.NFT;
|
|
372
|
+
addressType: NFTAddressType.ITEM;
|
|
373
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tonappchain/sdk",
|
|
3
|
-
"version": "0.7.0-
|
|
3
|
+
"version": "0.7.0-rc9",
|
|
4
4
|
"repository": "https://github.com/TacBuild/tac-sdk.git",
|
|
5
5
|
"author": "TAC. <developers@tac>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@aws-crypto/sha256-js": "^5.2.0",
|
|
21
21
|
"@orbs-network/ton-access": "^2.3.3",
|
|
22
22
|
"@ton/ton": "15.1.0",
|
|
23
|
-
"@tonappchain/artifacts": "0.0.19-
|
|
23
|
+
"@tonappchain/artifacts": "0.0.19-smart-accounts-4",
|
|
24
24
|
"@tonappchain/ton-lite-client": "3.0.6",
|
|
25
25
|
"@tonconnect/ui": "^2.0.11",
|
|
26
26
|
"bn.js": "^5.2.1",
|