@sign-global/tokentable 0.4.3-beta.0 → 0.4.3-beta.2
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/cjs/airdrop/AirdropClient.d.ts +1 -1
- package/dist/cjs/airdrop/AirdropClient.js +4 -3
- package/dist/cjs/airdrop/AirdropClient.js.map +1 -1
- package/dist/cjs/airdrop/SignatureAirdropClient.d.ts +10 -1
- package/dist/cjs/airdrop/SignatureAirdropClient.js +48 -11
- package/dist/cjs/airdrop/SignatureAirdropClient.js.map +1 -1
- package/dist/cjs/airdrop/common/index.d.ts +1 -1
- package/dist/cjs/airdrop/constants/chain-config.d.ts +1 -1
- package/dist/cjs/airdrop/constants/chain-config.js +1 -1
- package/dist/cjs/airdrop/constants/chain-config.js.map +1 -1
- package/dist/cjs/airdrop/constants/index.d.ts +1 -0
- package/dist/cjs/airdrop/constants/index.js +1 -0
- package/dist/cjs/airdrop/constants/index.js.map +1 -1
- package/dist/cjs/airdrop/contracts/evm/contracts/AirdropSignatureClient.js +0 -1
- package/dist/cjs/airdrop/contracts/evm/contracts/AirdropSignatureClient.js.map +1 -1
- package/dist/cjs/airdrop/contracts/index.d.ts +1 -0
- package/dist/cjs/airdrop/contracts/index.js +3 -1
- package/dist/cjs/airdrop/contracts/index.js.map +1 -1
- package/dist/cjs/airdrop/contracts/solana/AirdropService.d.ts +16 -0
- package/dist/cjs/airdrop/contracts/solana/AirdropService.js +38 -0
- package/dist/cjs/airdrop/contracts/solana/AirdropService.js.map +1 -0
- package/dist/cjs/airdrop/contracts/solana/AirdropSignatureClient.d.ts +3 -2
- package/dist/cjs/airdrop/contracts/solana/AirdropSignatureClient.js +12 -11
- package/dist/cjs/airdrop/contracts/solana/AirdropSignatureClient.js.map +1 -1
- package/dist/cjs/airdrop/contracts/solana/FeeCollectorClient.d.ts +3 -2
- package/dist/cjs/airdrop/contracts/solana/FeeCollectorClient.js +7 -3
- package/dist/cjs/airdrop/contracts/solana/FeeCollectorClient.js.map +1 -1
- package/dist/cjs/airdrop/contracts/solana/MerkleDistributorClient.d.ts +49 -0
- package/dist/cjs/airdrop/contracts/solana/MerkleDistributorClient.js +242 -0
- package/dist/cjs/airdrop/contracts/solana/MerkleDistributorClient.js.map +1 -0
- package/dist/cjs/airdrop/contracts/solana/SignatureAirdropService.d.ts +1 -0
- package/dist/cjs/airdrop/contracts/solana/SignatureAirdropService.js.map +1 -1
- package/dist/cjs/airdrop/contracts/solana/SolanaContractClient.d.ts +1 -0
- package/dist/cjs/airdrop/contracts/solana/SolanaContractClient.js +3 -0
- package/dist/cjs/airdrop/contracts/solana/SolanaContractClient.js.map +1 -1
- package/dist/cjs/airdrop/contracts/solana/eddsa_token_with_fees_distributor_solana.d.ts +1668 -0
- package/dist/cjs/airdrop/contracts/solana/eddsa_token_with_fees_distributor_solana.js +3 -0
- package/dist/cjs/airdrop/contracts/solana/eddsa_token_with_fees_distributor_solana.js.map +1 -0
- package/dist/cjs/airdrop/contracts/solana/{fungible_token_distributor_solana.json → eddsa_token_with_fees_distributor_solana.json} +127 -38
- package/dist/cjs/airdrop/contracts/solana/fee_collector.d.ts +198 -1
- package/dist/cjs/airdrop/contracts/solana/fee_collector.json +200 -3
- package/dist/cjs/airdrop/contracts/solana/merkle_token_distributor_solana.d.ts +1695 -0
- package/dist/cjs/airdrop/contracts/solana/merkle_token_distributor_solana.js +3 -0
- package/dist/cjs/airdrop/contracts/solana/merkle_token_distributor_solana.js.map +1 -0
- package/dist/cjs/airdrop/contracts/solana/merkle_token_distributor_solana.json +1689 -0
- package/dist/cjs/airdrop/services/index.d.ts +3 -2
- package/dist/cjs/airdrop/services/index.js +8 -1
- package/dist/cjs/airdrop/services/index.js.map +1 -1
- package/dist/cjs/airdrop/strategies/AirdropStrategyFactory.d.ts +1 -0
- package/dist/cjs/airdrop/strategies/AirdropStrategyFactory.js +2 -1
- package/dist/cjs/airdrop/strategies/AirdropStrategyFactory.js.map +1 -1
- package/dist/cjs/airdrop/strategies/IAirdropStrategy.d.ts +1 -0
- package/dist/cjs/airdrop/strategies/SolanaAirdropStrategy.d.ts +25 -0
- package/dist/cjs/airdrop/strategies/SolanaAirdropStrategy.js +62 -0
- package/dist/cjs/airdrop/strategies/SolanaAirdropStrategy.js.map +1 -0
- package/dist/cjs/airdrop/types/index.d.ts +8 -1
- package/dist/cjs/airdrop/types/index.js +1 -0
- package/dist/cjs/airdrop/types/index.js.map +1 -1
- package/dist/esm/airdrop/AirdropClient.d.ts +1 -1
- package/dist/esm/airdrop/AirdropClient.js +4 -3
- package/dist/esm/airdrop/AirdropClient.js.map +1 -1
- package/dist/esm/airdrop/SignatureAirdropClient.d.ts +10 -1
- package/dist/esm/airdrop/SignatureAirdropClient.js +49 -12
- package/dist/esm/airdrop/SignatureAirdropClient.js.map +1 -1
- package/dist/esm/airdrop/common/index.d.ts +1 -1
- package/dist/esm/airdrop/constants/chain-config.d.ts +1 -1
- package/dist/esm/airdrop/constants/chain-config.js +1 -1
- package/dist/esm/airdrop/constants/chain-config.js.map +1 -1
- package/dist/esm/airdrop/constants/index.d.ts +1 -0
- package/dist/esm/airdrop/constants/index.js +1 -0
- package/dist/esm/airdrop/constants/index.js.map +1 -1
- package/dist/esm/airdrop/contracts/evm/contracts/AirdropSignatureClient.js +0 -1
- package/dist/esm/airdrop/contracts/evm/contracts/AirdropSignatureClient.js.map +1 -1
- package/dist/esm/airdrop/contracts/index.d.ts +1 -0
- package/dist/esm/airdrop/contracts/index.js +1 -0
- package/dist/esm/airdrop/contracts/index.js.map +1 -1
- package/dist/esm/airdrop/contracts/solana/AirdropService.d.ts +16 -0
- package/dist/esm/airdrop/contracts/solana/AirdropService.js +34 -0
- package/dist/esm/airdrop/contracts/solana/AirdropService.js.map +1 -0
- package/dist/esm/airdrop/contracts/solana/AirdropSignatureClient.d.ts +3 -2
- package/dist/esm/airdrop/contracts/solana/AirdropSignatureClient.js +11 -10
- package/dist/esm/airdrop/contracts/solana/AirdropSignatureClient.js.map +1 -1
- package/dist/esm/airdrop/contracts/solana/FeeCollectorClient.d.ts +3 -2
- package/dist/esm/airdrop/contracts/solana/FeeCollectorClient.js +7 -3
- package/dist/esm/airdrop/contracts/solana/FeeCollectorClient.js.map +1 -1
- package/dist/esm/airdrop/contracts/solana/MerkleDistributorClient.d.ts +49 -0
- package/dist/esm/airdrop/contracts/solana/MerkleDistributorClient.js +212 -0
- package/dist/esm/airdrop/contracts/solana/MerkleDistributorClient.js.map +1 -0
- package/dist/esm/airdrop/contracts/solana/SignatureAirdropService.d.ts +1 -0
- package/dist/esm/airdrop/contracts/solana/SignatureAirdropService.js.map +1 -1
- package/dist/esm/airdrop/contracts/solana/SolanaContractClient.d.ts +1 -0
- package/dist/esm/airdrop/contracts/solana/SolanaContractClient.js +3 -0
- package/dist/esm/airdrop/contracts/solana/SolanaContractClient.js.map +1 -1
- package/dist/esm/airdrop/contracts/solana/eddsa_token_with_fees_distributor_solana.d.ts +1668 -0
- package/dist/esm/airdrop/contracts/solana/eddsa_token_with_fees_distributor_solana.js +2 -0
- package/dist/esm/airdrop/contracts/solana/eddsa_token_with_fees_distributor_solana.js.map +1 -0
- package/dist/esm/airdrop/contracts/solana/{fungible_token_distributor_solana.json → eddsa_token_with_fees_distributor_solana.json} +127 -38
- package/dist/esm/airdrop/contracts/solana/fee_collector.d.ts +198 -1
- package/dist/esm/airdrop/contracts/solana/fee_collector.json +200 -3
- package/dist/esm/airdrop/contracts/solana/merkle_token_distributor_solana.d.ts +1695 -0
- package/dist/esm/airdrop/contracts/solana/merkle_token_distributor_solana.js +2 -0
- package/dist/esm/airdrop/contracts/solana/merkle_token_distributor_solana.js.map +1 -0
- package/dist/esm/airdrop/contracts/solana/merkle_token_distributor_solana.json +1689 -0
- package/dist/esm/airdrop/services/index.d.ts +3 -2
- package/dist/esm/airdrop/services/index.js +6 -0
- package/dist/esm/airdrop/services/index.js.map +1 -1
- package/dist/esm/airdrop/strategies/AirdropStrategyFactory.d.ts +1 -0
- package/dist/esm/airdrop/strategies/AirdropStrategyFactory.js +2 -1
- package/dist/esm/airdrop/strategies/AirdropStrategyFactory.js.map +1 -1
- package/dist/esm/airdrop/strategies/IAirdropStrategy.d.ts +1 -0
- package/dist/esm/airdrop/strategies/SolanaAirdropStrategy.d.ts +25 -0
- package/dist/esm/airdrop/strategies/SolanaAirdropStrategy.js +58 -0
- package/dist/esm/airdrop/strategies/SolanaAirdropStrategy.js.map +1 -0
- package/dist/esm/airdrop/types/index.d.ts +8 -1
- package/dist/esm/airdrop/types/index.js +1 -0
- package/dist/esm/airdrop/types/index.js.map +1 -1
- package/package.json +2 -9
- package/src/airdrop/AirdropClient.ts +0 -307
- package/src/airdrop/SignatureAirdropClient.ts +0 -337
- package/src/airdrop/common/index.ts +0 -54
- package/src/airdrop/common/projectDataForTon.ts +0 -79
- package/src/airdrop/constants/chain-config.ts +0 -107
- package/src/airdrop/constants/index.ts +0 -8
- package/src/airdrop/constants/network.ts +0 -78
- package/src/airdrop/contracts/evm/AirdropService.ts +0 -181
- package/src/airdrop/contracts/evm/SignatureAirdropService.ts +0 -114
- package/src/airdrop/contracts/evm/contracts/AirdropSignatureClient.ts +0 -63
- package/src/airdrop/contracts/evm/contracts/AirdropSignatureFeeClient.ts +0 -61
- package/src/airdrop/contracts/evm/contracts/AirdropV2Client.ts +0 -37
- package/src/airdrop/contracts/evm/contracts/AirdropV3Client.ts +0 -49
- package/src/airdrop/contracts/evm/contracts/AirdropV3FeeClient.ts +0 -16
- package/src/airdrop/contracts/evm/contracts/AirdropV4Client.ts +0 -36
- package/src/airdrop/contracts/evm/contracts/ContractBaseClient.ts +0 -85
- package/src/airdrop/contracts/evm/contracts/DeployClient.ts +0 -35
- package/src/airdrop/contracts/evm/contracts/FeeCollectorClient.ts +0 -21
- package/src/airdrop/contracts/evm/contracts/KycClient.ts +0 -21
- package/src/airdrop/contracts/evm/contracts/abis/Airdrop.json +0 -674
- package/src/airdrop/contracts/evm/contracts/abis/AirdropV2.json +0 -676
- package/src/airdrop/contracts/evm/contracts/abis/AirdropV3.json +0 -740
- package/src/airdrop/contracts/evm/contracts/abis/AirdropV3_Fee.json +0 -678
- package/src/airdrop/contracts/evm/contracts/abis/CustomFeeNativeAirdropV4.json +0 -701
- package/src/airdrop/contracts/evm/contracts/abis/Deployer.json +0 -271
- package/src/airdrop/contracts/evm/contracts/abis/ERC721.json +0 -737
- package/src/airdrop/contracts/evm/contracts/abis/FeeCollector.json +0 -322
- package/src/airdrop/contracts/evm/contracts/abis/FungibleTokenECDSADistributor.json +0 -564
- package/src/airdrop/contracts/evm/contracts/abis/FungibleTokenWithFeesECDSADistributor.json +0 -260
- package/src/airdrop/contracts/evm/contracts/abis/KycHook.json +0 -312
- package/src/airdrop/contracts/index.ts +0 -4
- package/src/airdrop/contracts/solana/AirdropSignatureClient.ts +0 -242
- package/src/airdrop/contracts/solana/FeeCollectorClient.ts +0 -43
- package/src/airdrop/contracts/solana/SignatureAirdropService.ts +0 -51
- package/src/airdrop/contracts/solana/SolanaContractClient.ts +0 -126
- package/src/airdrop/contracts/solana/fee_collector.json +0 -1063
- package/src/airdrop/contracts/solana/fee_collector.ts +0 -1069
- package/src/airdrop/contracts/solana/fungible_token_distributor_solana.json +0 -1573
- package/src/airdrop/contracts/solana/fungible_token_distributor_solana.ts +0 -1579
- package/src/airdrop/contracts/ton/AirdropClientV1.ts +0 -122
- package/src/airdrop/contracts/ton/AirdropClientV2.ts +0 -118
- package/src/airdrop/contracts/ton/AirdropClientV21.ts +0 -131
- package/src/airdrop/contracts/ton/AirdropClientV3.ts +0 -127
- package/src/airdrop/contracts/ton/AirdropService.ts +0 -150
- package/src/airdrop/contracts/ton/TonContractBaseClient.ts +0 -236
- package/src/airdrop/contracts/ton/v1/build/Leaf.compiled.json +0 -1
- package/src/airdrop/contracts/ton/v1/build/MerkleTokenDistributor.compiled.json +0 -1
- package/src/airdrop/contracts/ton/v1/utils/constants.ts +0 -42
- package/src/airdrop/contracts/ton/v1/utils/date.utils.ts +0 -11
- package/src/airdrop/contracts/ton/v1/utils/index.ts +0 -3
- package/src/airdrop/contracts/ton/v1/utils/ton.utils.ts +0 -84
- package/src/airdrop/contracts/ton/v1/wrappers/JettonMinter.ts +0 -81
- package/src/airdrop/contracts/ton/v1/wrappers/JettonWallet.ts +0 -73
- package/src/airdrop/contracts/ton/v1/wrappers/Leaf.ts +0 -88
- package/src/airdrop/contracts/ton/v1/wrappers/MerkleTokenDistributor.ts +0 -317
- package/src/airdrop/contracts/ton/v1/wrappers/index.ts +0 -2
- package/src/airdrop/contracts/ton/v2/build/Leaf.compiled.json +0 -1
- package/src/airdrop/contracts/ton/v2/build/MerkleTokenDistributor.compiled.json +0 -1
- package/src/airdrop/contracts/ton/v2/utils/constants.ts +0 -43
- package/src/airdrop/contracts/ton/v2/utils/date.utils.ts +0 -11
- package/src/airdrop/contracts/ton/v2/utils/index.ts +0 -3
- package/src/airdrop/contracts/ton/v2/utils/ton.utils.ts +0 -102
- package/src/airdrop/contracts/ton/v2/wrappers/Leaf.ts +0 -69
- package/src/airdrop/contracts/ton/v2/wrappers/MerkleTokenDistributor.ts +0 -340
- package/src/airdrop/contracts/ton/v2/wrappers/index.ts +0 -2
- package/src/airdrop/contracts/ton/v21/build/Leaf.compiled.json +0 -1
- package/src/airdrop/contracts/ton/v21/build/MerkleTokenDistributor.compiled.json +0 -1
- package/src/airdrop/contracts/ton/v21/utils/constants.ts +0 -48
- package/src/airdrop/contracts/ton/v21/utils/date.utils.ts +0 -11
- package/src/airdrop/contracts/ton/v21/utils/index.ts +0 -3
- package/src/airdrop/contracts/ton/v21/utils/ton.utils.ts +0 -84
- package/src/airdrop/contracts/ton/v21/wrappers/Leaf.ts +0 -69
- package/src/airdrop/contracts/ton/v21/wrappers/MerkleTokenDistributor.ts +0 -346
- package/src/airdrop/contracts/ton/v21/wrappers/index.ts +0 -2
- package/src/airdrop/contracts/ton/v3/build/Leaf.compiled.json +0 -1
- package/src/airdrop/contracts/ton/v3/build/MerkleTokenDistributor.compiled.json +0 -1
- package/src/airdrop/contracts/ton/v3/utils/constants.ts +0 -43
- package/src/airdrop/contracts/ton/v3/utils/date.utils.ts +0 -11
- package/src/airdrop/contracts/ton/v3/utils/index.ts +0 -3
- package/src/airdrop/contracts/ton/v3/utils/ton.utils.ts +0 -84
- package/src/airdrop/contracts/ton/v3/wrappers/Leaf.ts +0 -68
- package/src/airdrop/contracts/ton/v3/wrappers/MerkleTokenDistributor.ts +0 -316
- package/src/airdrop/contracts/ton/v3/wrappers/index.ts +0 -2
- package/src/airdrop/index.ts +0 -10
- package/src/airdrop/services/index.ts +0 -159
- package/src/airdrop/services/wallet-service/ton/WalletService.ts +0 -226
- package/src/airdrop/services/wallet-service/ton/index.ts +0 -1
- package/src/airdrop/strategies/AirdropStrategyFactory.ts +0 -31
- package/src/airdrop/strategies/EvmAirdropStrategy.ts +0 -81
- package/src/airdrop/strategies/IAirdropStrategy.ts +0 -26
- package/src/airdrop/strategies/StrategyCache.ts +0 -34
- package/src/airdrop/strategies/TonAirdropStrategy.ts +0 -77
- package/src/airdrop/tests/index.test.ts +0 -387
- package/src/airdrop/types/index.ts +0 -199
- package/src/index.ts +0 -3
- package/src/utils/api-client.ts +0 -69
- package/src/utils/index.ts +0 -3
- package/src/utils/utils.ts +0 -45
- package/src/utils/web3.ts +0 -172
- package/src/wallets/WalletBase.ts +0 -92
- package/src/wallets/WalletFactory.tsx +0 -35
- package/src/wallets/index.ts +0 -3
- package/src/wallets/providers/evm/EvmWallet.ts +0 -101
- package/src/wallets/providers/evm/index.tsx +0 -56
- package/src/wallets/providers/index.ts +0 -4
- package/src/wallets/providers/solana/index.tsx +0 -133
- package/src/wallets/providers/ton/TonWallet.ts +0 -153
- package/src/wallets/providers/ton/index.tsx +0 -41
- package/src/wallets/types.ts +0 -45
- package/src/wallets/utils/index.ts +0 -61
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Address,
|
|
3
|
-
beginCell,
|
|
4
|
-
Builder,
|
|
5
|
-
Cell,
|
|
6
|
-
Contract,
|
|
7
|
-
contractAddress,
|
|
8
|
-
ContractProvider,
|
|
9
|
-
Dictionary,
|
|
10
|
-
Sender,
|
|
11
|
-
SendMode,
|
|
12
|
-
Slice,
|
|
13
|
-
toNano,
|
|
14
|
-
TupleItem
|
|
15
|
-
} from '@ton/core';
|
|
16
|
-
import { CodeType, dateToUnixTimestamp, intToString, OpCode, stringToInt, unixTimestampToDate } from '../utils';
|
|
17
|
-
|
|
18
|
-
export type MerkleTokenDistributorConfig = {
|
|
19
|
-
version: string;
|
|
20
|
-
adminAddress: Address;
|
|
21
|
-
root: bigint;
|
|
22
|
-
deployer: Address;
|
|
23
|
-
token?: Address;
|
|
24
|
-
startTime: Date;
|
|
25
|
-
endTime: Date;
|
|
26
|
-
leafCode: Cell;
|
|
27
|
-
claimFee: bigint;
|
|
28
|
-
claimFeeAddress: Address;
|
|
29
|
-
paused?: boolean;
|
|
30
|
-
feelessThreshold?: bigint;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export function tokenDistributorConfigToCell(config: MerkleTokenDistributorConfig): Cell {
|
|
34
|
-
const {
|
|
35
|
-
version,
|
|
36
|
-
adminAddress,
|
|
37
|
-
deployer,
|
|
38
|
-
endTime,
|
|
39
|
-
leafCode,
|
|
40
|
-
root,
|
|
41
|
-
startTime,
|
|
42
|
-
token,
|
|
43
|
-
claimFee,
|
|
44
|
-
claimFeeAddress,
|
|
45
|
-
paused = false,
|
|
46
|
-
feelessThreshold = 0
|
|
47
|
-
} = config;
|
|
48
|
-
const c2 = beginCell()
|
|
49
|
-
.storeCoins(claimFee)
|
|
50
|
-
.storeAddress(claimFeeAddress)
|
|
51
|
-
.storeUint(paused ? 1 : 0, 1)
|
|
52
|
-
.storeCoins(feelessThreshold)
|
|
53
|
-
.endCell();
|
|
54
|
-
|
|
55
|
-
const c1 = beginCell()
|
|
56
|
-
.storeAddress(deployer)
|
|
57
|
-
.storeAddress(token)
|
|
58
|
-
.storeUint(dateToUnixTimestamp(startTime), 32)
|
|
59
|
-
.storeUint(dateToUnixTimestamp(endTime), 32)
|
|
60
|
-
.storeRef(leafCode)
|
|
61
|
-
.endCell();
|
|
62
|
-
|
|
63
|
-
return beginCell()
|
|
64
|
-
.storeUint(stringToInt(version), 64)
|
|
65
|
-
.storeAddress(adminAddress)
|
|
66
|
-
.storeUint(root, 256)
|
|
67
|
-
.storeRef(c1)
|
|
68
|
-
.storeRef(c2)
|
|
69
|
-
.endCell();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export type TokenDistributorEntry = {
|
|
73
|
-
address: Address;
|
|
74
|
-
claimableAmount: bigint;
|
|
75
|
-
claimableTimestamp: number;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export const tokenDistributorEntryValue = {
|
|
79
|
-
serialize: (src: TokenDistributorEntry, buidler: Builder) => {
|
|
80
|
-
buidler.storeAddress(src.address).storeCoins(src.claimableAmount).storeUint(src.claimableTimestamp, 32);
|
|
81
|
-
},
|
|
82
|
-
parse: (src: Slice) => {
|
|
83
|
-
return {
|
|
84
|
-
address: src.loadAddress(),
|
|
85
|
-
claimableAmount: src.loadCoins(),
|
|
86
|
-
claimableTimestamp: src.loadUint(32)
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export function generateEntriesDictionary(entries: TokenDistributorEntry[]): Dictionary<bigint, TokenDistributorEntry> {
|
|
92
|
-
const dict: Dictionary<bigint, TokenDistributorEntry> = Dictionary.empty(
|
|
93
|
-
Dictionary.Keys.BigUint(64),
|
|
94
|
-
tokenDistributorEntryValue
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
for (let i = 0; i < entries.length; i++) {
|
|
98
|
-
dict.set(BigInt(i), entries[i]);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return dict;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export class MerkleTokenDistributor implements Contract {
|
|
105
|
-
constructor(readonly address: Address, readonly init?: { code: Cell; data: Cell }) {}
|
|
106
|
-
|
|
107
|
-
static createFromAddress(address: Address) {
|
|
108
|
-
return new MerkleTokenDistributor(address);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
static createFromConfig(config: MerkleTokenDistributorConfig, code: Cell, workchain = 0) {
|
|
112
|
-
const data = tokenDistributorConfigToCell(config);
|
|
113
|
-
const init = { code, data };
|
|
114
|
-
return new MerkleTokenDistributor(contractAddress(workchain, init), init);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
async sendDeploy(provider: ContractProvider, via: Sender, value: bigint) {
|
|
118
|
-
await provider.internal(via, {
|
|
119
|
-
value,
|
|
120
|
-
sendMode: SendMode.PAY_GAS_SEPARATELY,
|
|
121
|
-
body: beginCell().endCell()
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
async getVersion(provider: ContractProvider): Promise<string> {
|
|
126
|
-
const result = await provider.get('get_version', []);
|
|
127
|
-
|
|
128
|
-
return intToString(Number(result.stack.readBigNumber()));
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
async getLeafAddress(provider: ContractProvider, index: bigint): Promise<Address> {
|
|
132
|
-
const arg: TupleItem = {
|
|
133
|
-
value: index,
|
|
134
|
-
type: 'int'
|
|
135
|
-
};
|
|
136
|
-
const result = await provider.get('get_leaf_address', [arg]);
|
|
137
|
-
|
|
138
|
-
return result.stack.readAddress();
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
async getRoot(provider: ContractProvider): Promise<bigint> {
|
|
142
|
-
const result = await provider.get('get_root', []);
|
|
143
|
-
|
|
144
|
-
return result.stack.readBigNumber();
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
async getTime(provider: ContractProvider): Promise<[Date, Date] | [null, null]> {
|
|
148
|
-
const result = await provider.get('get_time', []);
|
|
149
|
-
const stack = result.stack;
|
|
150
|
-
|
|
151
|
-
try {
|
|
152
|
-
return [unixTimestampToDate(stack.readNumber()), unixTimestampToDate(stack.readNumber())];
|
|
153
|
-
} catch (e) {
|
|
154
|
-
return [null, null];
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
async getToken(provider: ContractProvider): Promise<Address | null> {
|
|
159
|
-
const result = await provider.get('get_token', []);
|
|
160
|
-
|
|
161
|
-
try {
|
|
162
|
-
return result.stack.readAddress();
|
|
163
|
-
} catch (e) {
|
|
164
|
-
return null;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
async getAdminAddress(provider: ContractProvider): Promise<Address> {
|
|
169
|
-
const result = await provider.get('get_admin_address', []);
|
|
170
|
-
|
|
171
|
-
return result.stack.readAddress();
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
async getClaimFee(provider: ContractProvider): Promise<bigint> {
|
|
175
|
-
const result = await provider.get('get_claim_fee', []);
|
|
176
|
-
|
|
177
|
-
return result.stack.readBigNumber();
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
async getClaimFeeAddress(provider: ContractProvider): Promise<Address> {
|
|
181
|
-
const result = await provider.get('get_claim_fee_address', []);
|
|
182
|
-
|
|
183
|
-
return result.stack.readAddress();
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
async getPaused(provider: ContractProvider): Promise<boolean> {
|
|
187
|
-
const result = await provider.get('get_paused', []);
|
|
188
|
-
|
|
189
|
-
return result.stack.readNumber() === 1;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
async getFeelessThreshold(provider: ContractProvider): Promise<bigint> {
|
|
193
|
-
const result = await provider.get('get_feeless_threshold', []);
|
|
194
|
-
|
|
195
|
-
return result.stack.readBigNumber();
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
async sendChangeAdmin(provider: ContractProvider, via: Sender, newAdmin: Address) {
|
|
199
|
-
const messageBody = beginCell().storeUint(OpCode.ChangeAdmin, 32).storeUint(0, 64).storeAddress(newAdmin).endCell();
|
|
200
|
-
const result = await provider.internal(via, {
|
|
201
|
-
value: '0.01',
|
|
202
|
-
body: messageBody
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
return result;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
async sendChangeCode(provider: ContractProvider, via: Sender, codeType: CodeType, newCode: Cell) {
|
|
209
|
-
const messageBody = beginCell()
|
|
210
|
-
.storeUint(OpCode.ChangeCode, 32)
|
|
211
|
-
.storeUint(0, 64)
|
|
212
|
-
.storeUint(codeType, 32)
|
|
213
|
-
.storeRef(newCode)
|
|
214
|
-
.endCell();
|
|
215
|
-
const result = await provider.internal(via, {
|
|
216
|
-
value: '0.01',
|
|
217
|
-
body: messageBody
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
return result;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
async sendChangeVersion(provider: ContractProvider, via: Sender, version: string) {
|
|
224
|
-
const messageBody = beginCell()
|
|
225
|
-
.storeUint(OpCode.ChangeVersion, 32)
|
|
226
|
-
.storeUint(0, 64)
|
|
227
|
-
.storeUint(stringToInt(version), 64)
|
|
228
|
-
.endCell();
|
|
229
|
-
const result = await provider.internal(via, {
|
|
230
|
-
value: '0.01',
|
|
231
|
-
body: messageBody
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
return result;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
async sendWithdraw(provider: ContractProvider, via: Sender, amount: string) {
|
|
238
|
-
const messageBody = beginCell()
|
|
239
|
-
.storeUint(OpCode.Withdraw, 32)
|
|
240
|
-
.storeUint(0, 64)
|
|
241
|
-
.storeCoins(toNano(amount))
|
|
242
|
-
.endCell();
|
|
243
|
-
const result = await provider.internal(via, {
|
|
244
|
-
value: '0.01',
|
|
245
|
-
body: messageBody
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
return result;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
async sendWithdrawTokens(provider: ContractProvider, via: Sender, amount: string) {
|
|
252
|
-
const messageBody = beginCell()
|
|
253
|
-
.storeUint(OpCode.WithdrawTokens, 32)
|
|
254
|
-
.storeUint(0, 64)
|
|
255
|
-
.storeCoins(toNano(amount))
|
|
256
|
-
.endCell();
|
|
257
|
-
const result = await provider.internal(via, {
|
|
258
|
-
value: '0.1',
|
|
259
|
-
body: messageBody
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
return result;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
async sendSetBaseParams(
|
|
266
|
-
provider: ContractProvider,
|
|
267
|
-
via: Sender,
|
|
268
|
-
startTime: Date,
|
|
269
|
-
endTime: Date,
|
|
270
|
-
root: bigint,
|
|
271
|
-
token: Address
|
|
272
|
-
) {
|
|
273
|
-
const messageBody = beginCell()
|
|
274
|
-
.storeUint(OpCode.SetBaseParams, 32)
|
|
275
|
-
.storeUint(0, 64)
|
|
276
|
-
.storeAddress(token)
|
|
277
|
-
.storeUint(dateToUnixTimestamp(startTime), 32)
|
|
278
|
-
.storeUint(dateToUnixTimestamp(endTime), 32)
|
|
279
|
-
.storeUint(root, 256)
|
|
280
|
-
.endCell();
|
|
281
|
-
const result = await provider.internal(via, {
|
|
282
|
-
value: '0.01',
|
|
283
|
-
body: messageBody
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
return result;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
async sendSetPaused(provider: ContractProvider, via: Sender, paused: boolean) {
|
|
290
|
-
const messageBody = beginCell()
|
|
291
|
-
.storeUint(OpCode.SetPaused, 32)
|
|
292
|
-
.storeUint(0, 64)
|
|
293
|
-
.storeUint(paused ? 1 : 0, 1)
|
|
294
|
-
.endCell();
|
|
295
|
-
const result = await provider.internal(via, {
|
|
296
|
-
value: '0.01',
|
|
297
|
-
body: messageBody
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
return result;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
async sendSetFeelessThreshold(provider: ContractProvider, via: Sender, feelessThreshold: bigint) {
|
|
304
|
-
const messageBody = beginCell()
|
|
305
|
-
.storeUint(OpCode.SetFeelessThreshold, 32)
|
|
306
|
-
.storeUint(0, 64)
|
|
307
|
-
.storeCoins(feelessThreshold)
|
|
308
|
-
.endCell();
|
|
309
|
-
const result = await provider.internal(via, {
|
|
310
|
-
value: '0.01',
|
|
311
|
-
body: messageBody
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
return result;
|
|
315
|
-
}
|
|
316
|
-
}
|
package/src/airdrop/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { AirdropClient } from './AirdropClient';
|
|
2
|
-
export { SignatureAirdropClient } from './SignatureAirdropClient';
|
|
3
|
-
export {
|
|
4
|
-
EvmSignatureAirdropService,
|
|
5
|
-
SolanaSignatureAirdropService,
|
|
6
|
-
EvmAirdropService,
|
|
7
|
-
TonAirdropService
|
|
8
|
-
} from './contracts';
|
|
9
|
-
|
|
10
|
-
export { CONST } from './constants';
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { apiClient } from '../../utils/api-client';
|
|
2
|
-
import { safeParseJSON } from '../../utils/utils';
|
|
3
|
-
import {
|
|
4
|
-
AirdropSigIdentityTypeEnum,
|
|
5
|
-
IAirdropData,
|
|
6
|
-
IAirdropSignatureData,
|
|
7
|
-
IClaimSignature,
|
|
8
|
-
IContractConfig,
|
|
9
|
-
IProject
|
|
10
|
-
} from '../types';
|
|
11
|
-
|
|
12
|
-
export { TonWalletService } from './wallet-service/ton';
|
|
13
|
-
|
|
14
|
-
const createApiClient = (baseURL?: string) => {
|
|
15
|
-
return baseURL ? apiClient.extend({ baseURL }) : apiClient;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const getAirdropProject = async (projectId: string, baseURL?: string): Promise<IProject> => {
|
|
19
|
-
const client = createApiClient(baseURL);
|
|
20
|
-
const res = await client.get<any>(`/airdrop-open/projects/${projectId}`);
|
|
21
|
-
if (!res) return res; // res is null
|
|
22
|
-
const projectConfig = res?.themeConf;
|
|
23
|
-
const blockCountries = safeParseJSON(projectConfig?.blockCountries);
|
|
24
|
-
return {
|
|
25
|
-
...res,
|
|
26
|
-
blockCountries
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const getAirdropProjectId = async (
|
|
31
|
-
data: {
|
|
32
|
-
recipient: string;
|
|
33
|
-
slug: string;
|
|
34
|
-
},
|
|
35
|
-
baseURL?: string
|
|
36
|
-
): Promise<{ recipient: string; projectIds: string[] }> => {
|
|
37
|
-
const client = createApiClient(baseURL);
|
|
38
|
-
return client.post(`/airdrop-open/query-pid`, data);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const getAirdropPro = async (
|
|
42
|
-
slug: string,
|
|
43
|
-
baseURL?: string
|
|
44
|
-
): Promise<{
|
|
45
|
-
slug: string;
|
|
46
|
-
childProjectMapping: Record<string, string>;
|
|
47
|
-
}> => {
|
|
48
|
-
const client = createApiClient(baseURL);
|
|
49
|
-
return client.get(`/airdrop-open/airdrop-pro/${slug}`);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const getAirdropQuery = async (
|
|
53
|
-
data: {
|
|
54
|
-
recipient: string;
|
|
55
|
-
projectId: string;
|
|
56
|
-
recipientType: string;
|
|
57
|
-
},
|
|
58
|
-
baseURL?: string
|
|
59
|
-
): Promise<IAirdropData> => {
|
|
60
|
-
const client = createApiClient(baseURL);
|
|
61
|
-
return client.post(`/airdrop-open/query`, data);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export const getAirdropContractConfig = async (
|
|
65
|
-
data: { chainId: string; chainType: string; contractAddress: string },
|
|
66
|
-
baseURL?: string
|
|
67
|
-
): Promise<IContractConfig> => {
|
|
68
|
-
const client = createApiClient(baseURL);
|
|
69
|
-
return client.post(`/airdrop-open/contract/config`, data);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export const getJettonInfo = async (
|
|
73
|
-
data: { address: string; isTestnet: 'true' | 'false' },
|
|
74
|
-
baseURL?: string
|
|
75
|
-
): Promise<any> => {
|
|
76
|
-
const client = createApiClient(baseURL);
|
|
77
|
-
return client.get(`/airdrop-open/jetton/${data.address}?isTestnet=${data.isTestnet}`);
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
interface SidResponse {
|
|
81
|
-
sid: string;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
interface TwitterConnectParams {
|
|
85
|
-
code: string;
|
|
86
|
-
projectId: string;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
interface WalletBindParams {
|
|
90
|
-
projectId: string;
|
|
91
|
-
key: string;
|
|
92
|
-
signature: string;
|
|
93
|
-
message: string;
|
|
94
|
-
timestamp: number;
|
|
95
|
-
recipientType: string;
|
|
96
|
-
address: string;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const getSidHeader = (projectId: string) => ({
|
|
100
|
-
sid: window.localStorage.getItem(`sid_${projectId}`) || ''
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
export const connectTwitter = async (data: TwitterConnectParams, baseURL?: string): Promise<SidResponse> => {
|
|
104
|
-
const client = createApiClient(baseURL);
|
|
105
|
-
return client.post('/airdrop-open/connect-twitter', data, {
|
|
106
|
-
headers: getSidHeader(data.projectId)
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
export const checkEligibility = async (
|
|
111
|
-
data: { projectId: string },
|
|
112
|
-
baseURL?: string
|
|
113
|
-
): Promise<IAirdropSignatureData> => {
|
|
114
|
-
const headers = getSidHeader(data.projectId);
|
|
115
|
-
if (!headers.sid)
|
|
116
|
-
return {
|
|
117
|
-
claims: [],
|
|
118
|
-
identities: []
|
|
119
|
-
};
|
|
120
|
-
const client = createApiClient(baseURL);
|
|
121
|
-
|
|
122
|
-
return client.post('/airdrop-open/check-eligibility', data, {
|
|
123
|
-
headers: headers
|
|
124
|
-
});
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
export const bindWallet = async (data: WalletBindParams, baseURL?: string): Promise<SidResponse> => {
|
|
128
|
-
const client = createApiClient(baseURL);
|
|
129
|
-
return client.post('/airdrop-open/connect-wallet', data, {
|
|
130
|
-
headers: getSidHeader(data.projectId)
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
interface DisconnectParams {
|
|
135
|
-
projectId: string;
|
|
136
|
-
recipientType: AirdropSigIdentityTypeEnum;
|
|
137
|
-
recipient?: string;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export const disconnectRecipient = async (data: DisconnectParams, baseURL?: string): Promise<void> => {
|
|
141
|
-
const client = createApiClient(baseURL);
|
|
142
|
-
return client.post('/airdrop-open/disconnect', data, {
|
|
143
|
-
headers: getSidHeader(data.projectId)
|
|
144
|
-
});
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
export const checkGetSignatures = async (
|
|
148
|
-
data: {
|
|
149
|
-
projectId: string;
|
|
150
|
-
claimIds: string[];
|
|
151
|
-
recipient: string;
|
|
152
|
-
},
|
|
153
|
-
baseURL?: string
|
|
154
|
-
): Promise<{ signatures: IClaimSignature[] }> => {
|
|
155
|
-
const client = createApiClient(baseURL);
|
|
156
|
-
return client.post('/airdrop-open/check-get-signatures', data, {
|
|
157
|
-
headers: getSidHeader(data.projectId)
|
|
158
|
-
});
|
|
159
|
-
};
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import TonWeb from 'tonweb';
|
|
2
|
-
import { Address } from '@ton/core';
|
|
3
|
-
import { JettonMaster, TonClient } from '@ton/ton';
|
|
4
|
-
import { delay, flipAddressType } from '../../../../utils';
|
|
5
|
-
|
|
6
|
-
import { Api, HttpClient, Event } from 'tonapi-sdk-js';
|
|
7
|
-
import { ChainConfig } from '../../../constants';
|
|
8
|
-
import { getJettonInfo } from '../../index';
|
|
9
|
-
import { CHAIN } from '@tonconnect/ui-react';
|
|
10
|
-
// import { getHttpEndpoint } from '@orbs-network/ton-access';
|
|
11
|
-
// import { CHAIN } from '@tonconnect/ui-react';
|
|
12
|
-
|
|
13
|
-
interface WaitForTransactionOptions {
|
|
14
|
-
address: string;
|
|
15
|
-
hash: string;
|
|
16
|
-
refetchInterval?: number;
|
|
17
|
-
refetchLimit?: number;
|
|
18
|
-
chainId: string;
|
|
19
|
-
contractAddress?: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export abstract class TonWalletService {
|
|
23
|
-
// static walletClient = tonStore.walletClient;
|
|
24
|
-
|
|
25
|
-
static disconnect() {
|
|
26
|
-
//
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
static async getTonClient(chainId: string) {
|
|
30
|
-
const endpoint = ChainConfig[chainId as keyof typeof ChainConfig].rpcUrl;
|
|
31
|
-
// const endpoint = await getHttpEndpoint({ network: chainId === CHAIN.TESTNET ? 'testnet' : 'mainnet' });
|
|
32
|
-
return new TonClient({
|
|
33
|
-
endpoint: endpoint
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
static getTonApiClient(chainId: string) {
|
|
38
|
-
const { tonApiPrefix } = ChainConfig[chainId as keyof typeof ChainConfig] as any;
|
|
39
|
-
|
|
40
|
-
const httpClient = new HttpClient({
|
|
41
|
-
baseUrl: tonApiPrefix
|
|
42
|
-
// baseApiParams: {
|
|
43
|
-
// headers: {
|
|
44
|
-
// Authorization: `Bearer ${tonApiKey}`,
|
|
45
|
-
// 'Content-type': 'application/json'
|
|
46
|
-
// }
|
|
47
|
-
// }
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const client = new Api(httpClient);
|
|
51
|
-
return client;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
static waitForTransactionByClient = async (options: WaitForTransactionOptions): Promise<Event | null> => {
|
|
55
|
-
const { hash, refetchInterval = 3000, refetchLimit, chainId } = options;
|
|
56
|
-
|
|
57
|
-
return new Promise((resolve) => {
|
|
58
|
-
let refetches = 0;
|
|
59
|
-
const interval = setInterval(async () => {
|
|
60
|
-
refetches += 1;
|
|
61
|
-
|
|
62
|
-
console.log(hash, 'waiting transaction...');
|
|
63
|
-
const tonApi = this.getTonApiClient(chainId);
|
|
64
|
-
const events = await tonApi.events.getEvent(hash);
|
|
65
|
-
console.log(events, 'traceData');
|
|
66
|
-
if (!events.in_progress) {
|
|
67
|
-
await delay(3000);
|
|
68
|
-
clearInterval(interval);
|
|
69
|
-
resolve(events);
|
|
70
|
-
}
|
|
71
|
-
if (refetchLimit && refetches >= refetchLimit) {
|
|
72
|
-
clearInterval(interval);
|
|
73
|
-
resolve(null);
|
|
74
|
-
}
|
|
75
|
-
}, refetchInterval);
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
static waitForTransactionLegacy = async (options: WaitForTransactionOptions): Promise<Event | null> => {
|
|
80
|
-
const { refetchInterval = 3000, refetchLimit, chainId, address, contractAddress } = options;
|
|
81
|
-
|
|
82
|
-
const tonApi = this.getTonApiClient(chainId);
|
|
83
|
-
const tonClient = await this.getTonClient(chainId);
|
|
84
|
-
const walletAddress = Address.parse(address);
|
|
85
|
-
|
|
86
|
-
return new Promise((resolve) => {
|
|
87
|
-
let refetches = 0;
|
|
88
|
-
const interval = setInterval(async () => {
|
|
89
|
-
refetches += 1;
|
|
90
|
-
|
|
91
|
-
console.log('waiting transaction...');
|
|
92
|
-
|
|
93
|
-
let hash;
|
|
94
|
-
|
|
95
|
-
if (contractAddress) {
|
|
96
|
-
const res = await tonApi.accounts.getAccountEvents(address, {
|
|
97
|
-
limit: 5
|
|
98
|
-
});
|
|
99
|
-
const targetTransaction = res.events.find((it) => {
|
|
100
|
-
return (
|
|
101
|
-
it.actions.length &&
|
|
102
|
-
it.actions.find((action) => {
|
|
103
|
-
return action.simple_preview.accounts.find((ac) => {
|
|
104
|
-
return Address.parse(ac.address).toRawString() === Address.parse(contractAddress).toRawString();
|
|
105
|
-
});
|
|
106
|
-
})
|
|
107
|
-
);
|
|
108
|
-
});
|
|
109
|
-
console.log(targetTransaction, 'res');
|
|
110
|
-
if (targetTransaction) {
|
|
111
|
-
hash = targetTransaction.event_id;
|
|
112
|
-
}
|
|
113
|
-
} else {
|
|
114
|
-
const state = await tonClient.getContractState(walletAddress);
|
|
115
|
-
console.log(state, 'state');
|
|
116
|
-
hash = state.lastTransaction?.hash;
|
|
117
|
-
}
|
|
118
|
-
if (hash) {
|
|
119
|
-
const events = await tonApi.events.getEvent(hash);
|
|
120
|
-
console.log(events, 'events');
|
|
121
|
-
if (!events.in_progress) {
|
|
122
|
-
clearInterval(interval);
|
|
123
|
-
resolve(events);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
if (refetchLimit && refetches >= refetchLimit) {
|
|
127
|
-
clearInterval(interval);
|
|
128
|
-
resolve(null);
|
|
129
|
-
}
|
|
130
|
-
}, refetchInterval);
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
static async waitForTransaction({
|
|
135
|
-
hash,
|
|
136
|
-
chainId,
|
|
137
|
-
address,
|
|
138
|
-
contractAddress
|
|
139
|
-
}: {
|
|
140
|
-
hash: string;
|
|
141
|
-
chainId: string;
|
|
142
|
-
address: string;
|
|
143
|
-
contractAddress?: string;
|
|
144
|
-
}) {
|
|
145
|
-
return this.waitForTransactionByClient({ hash, address, chainId, contractAddress });
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
static async fetchBalance(args: { chainId: string; address: string; token?: string }) {
|
|
149
|
-
try {
|
|
150
|
-
const config = ChainConfig[args.chainId as keyof typeof ChainConfig] as any;
|
|
151
|
-
const options = { method: 'GET' };
|
|
152
|
-
const rawAddress = flipAddressType(args.address);
|
|
153
|
-
|
|
154
|
-
const url = args.token
|
|
155
|
-
? `${config.tonApiPrefix}/v2/accounts/${rawAddress}/jettons?currencies=usd`
|
|
156
|
-
: `${config.tonApiPrefix}/v2/blockchain/accounts/${rawAddress}`;
|
|
157
|
-
|
|
158
|
-
const response = await fetch(url, options);
|
|
159
|
-
const responseJSON: any = await response.json();
|
|
160
|
-
const current = args.token
|
|
161
|
-
? responseJSON.balances.find((it: any) => it.jetton.address === flipAddressType(args.token!))
|
|
162
|
-
: { balance: responseJSON.balance / 1000000000 };
|
|
163
|
-
|
|
164
|
-
return {
|
|
165
|
-
value: current?.balance || 0
|
|
166
|
-
};
|
|
167
|
-
} catch {
|
|
168
|
-
return {
|
|
169
|
-
value: 0
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
static async fetchToken(args: { chainId: string; address: string }) {
|
|
175
|
-
return getJettonInfo({
|
|
176
|
-
address: args.address,
|
|
177
|
-
isTestnet: args.chainId === CHAIN.TESTNET ? 'true' : 'false'
|
|
178
|
-
});
|
|
179
|
-
// const client = this.getTonApiClient(args.chainId as string);
|
|
180
|
-
// const data: any = await client.jettons.getJettonInfo(args.address);
|
|
181
|
-
// const { metadata, total_supply } = data;
|
|
182
|
-
// return {
|
|
183
|
-
// ...metadata,
|
|
184
|
-
// totalSupply: {
|
|
185
|
-
// value: total_supply,
|
|
186
|
-
// formatted: fromNano(total_supply)
|
|
187
|
-
// }
|
|
188
|
-
// };
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
static async signMessage() {}
|
|
192
|
-
|
|
193
|
-
static async addChain() {}
|
|
194
|
-
|
|
195
|
-
static async fetchEnsAddress() {
|
|
196
|
-
return '';
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
static validateAddress(address: string) {
|
|
200
|
-
try {
|
|
201
|
-
Address.parse(address);
|
|
202
|
-
return true;
|
|
203
|
-
} catch (e) {
|
|
204
|
-
return false;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
static isSameAddress(address1: string, address2: string) {
|
|
209
|
-
return Address.parse(address1).toRawString() === Address.parse(address2).toRawString();
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
static getJettonAddress = async ({
|
|
213
|
-
chainId,
|
|
214
|
-
address,
|
|
215
|
-
token
|
|
216
|
-
}: {
|
|
217
|
-
chainId: string;
|
|
218
|
-
address: string;
|
|
219
|
-
token: string;
|
|
220
|
-
}) => {
|
|
221
|
-
const client = await this.getTonClient(chainId);
|
|
222
|
-
const jettonWallet = client.open(JettonMaster.create(Address.parse(token)));
|
|
223
|
-
|
|
224
|
-
return jettonWallet.getWalletAddress(Address.parse(address));
|
|
225
|
-
};
|
|
226
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { TonWalletService } from './WalletService';
|