@tonappchain/sdk 0.7.0-rc8 → 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.
@@ -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
@@ -64,6 +64,17 @@ class FT {
64
64
  });
65
65
  return jettonMaster.address.toString();
66
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
+ }
67
78
  constructor(address, origin, configuration) {
68
79
  this.type = Struct_1.AssetType.FT;
69
80
  this._tvmAddress = ton_1.Address.parse(address);
@@ -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
- ownerAddress: Address;
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>;
@@ -98,8 +98,10 @@ class NFT {
98
98
  }
99
99
  else {
100
100
  const nftCollection = configuration.TONParams.contractOpener.open(wrappers_1.NFTCollection.createFromConfig({
101
- ownerAddress: ton_1.Address.parse(configuration.TONParams.crossChainLayerAddress),
102
- content: (0, ton_1.beginCell)().endCell(),
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));
@@ -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
  }
@@ -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;
@@ -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;
@@ -39,3 +40,27 @@ export interface IOperationTracker {
39
40
  getOperationStatus(operationId: string, waitOptions?: WaitOptions<StatusInfo>): Promise<StatusInfo>;
40
41
  getSimplifiedOperationStatus(transactionLinker: TransactionLinker): Promise<SimplifiedStatuses>;
41
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tonappchain/sdk",
3
- "version": "0.7.0-rc8",
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-mainnet-rc2",
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",