@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.
Files changed (227) hide show
  1. package/dist/cjs/airdrop/AirdropClient.d.ts +1 -1
  2. package/dist/cjs/airdrop/AirdropClient.js +4 -3
  3. package/dist/cjs/airdrop/AirdropClient.js.map +1 -1
  4. package/dist/cjs/airdrop/SignatureAirdropClient.d.ts +10 -1
  5. package/dist/cjs/airdrop/SignatureAirdropClient.js +48 -11
  6. package/dist/cjs/airdrop/SignatureAirdropClient.js.map +1 -1
  7. package/dist/cjs/airdrop/common/index.d.ts +1 -1
  8. package/dist/cjs/airdrop/constants/chain-config.d.ts +1 -1
  9. package/dist/cjs/airdrop/constants/chain-config.js +1 -1
  10. package/dist/cjs/airdrop/constants/chain-config.js.map +1 -1
  11. package/dist/cjs/airdrop/constants/index.d.ts +1 -0
  12. package/dist/cjs/airdrop/constants/index.js +1 -0
  13. package/dist/cjs/airdrop/constants/index.js.map +1 -1
  14. package/dist/cjs/airdrop/contracts/evm/contracts/AirdropSignatureClient.js +0 -1
  15. package/dist/cjs/airdrop/contracts/evm/contracts/AirdropSignatureClient.js.map +1 -1
  16. package/dist/cjs/airdrop/contracts/index.d.ts +1 -0
  17. package/dist/cjs/airdrop/contracts/index.js +3 -1
  18. package/dist/cjs/airdrop/contracts/index.js.map +1 -1
  19. package/dist/cjs/airdrop/contracts/solana/AirdropService.d.ts +16 -0
  20. package/dist/cjs/airdrop/contracts/solana/AirdropService.js +38 -0
  21. package/dist/cjs/airdrop/contracts/solana/AirdropService.js.map +1 -0
  22. package/dist/cjs/airdrop/contracts/solana/AirdropSignatureClient.d.ts +3 -2
  23. package/dist/cjs/airdrop/contracts/solana/AirdropSignatureClient.js +12 -11
  24. package/dist/cjs/airdrop/contracts/solana/AirdropSignatureClient.js.map +1 -1
  25. package/dist/cjs/airdrop/contracts/solana/FeeCollectorClient.d.ts +3 -2
  26. package/dist/cjs/airdrop/contracts/solana/FeeCollectorClient.js +7 -3
  27. package/dist/cjs/airdrop/contracts/solana/FeeCollectorClient.js.map +1 -1
  28. package/dist/cjs/airdrop/contracts/solana/MerkleDistributorClient.d.ts +49 -0
  29. package/dist/cjs/airdrop/contracts/solana/MerkleDistributorClient.js +242 -0
  30. package/dist/cjs/airdrop/contracts/solana/MerkleDistributorClient.js.map +1 -0
  31. package/dist/cjs/airdrop/contracts/solana/SignatureAirdropService.d.ts +1 -0
  32. package/dist/cjs/airdrop/contracts/solana/SignatureAirdropService.js.map +1 -1
  33. package/dist/cjs/airdrop/contracts/solana/SolanaContractClient.d.ts +1 -0
  34. package/dist/cjs/airdrop/contracts/solana/SolanaContractClient.js +3 -0
  35. package/dist/cjs/airdrop/contracts/solana/SolanaContractClient.js.map +1 -1
  36. package/dist/cjs/airdrop/contracts/solana/eddsa_token_with_fees_distributor_solana.d.ts +1668 -0
  37. package/dist/cjs/airdrop/contracts/solana/eddsa_token_with_fees_distributor_solana.js +3 -0
  38. package/dist/cjs/airdrop/contracts/solana/eddsa_token_with_fees_distributor_solana.js.map +1 -0
  39. package/dist/cjs/airdrop/contracts/solana/{fungible_token_distributor_solana.json → eddsa_token_with_fees_distributor_solana.json} +127 -38
  40. package/dist/cjs/airdrop/contracts/solana/fee_collector.d.ts +198 -1
  41. package/dist/cjs/airdrop/contracts/solana/fee_collector.json +200 -3
  42. package/dist/cjs/airdrop/contracts/solana/merkle_token_distributor_solana.d.ts +1695 -0
  43. package/dist/cjs/airdrop/contracts/solana/merkle_token_distributor_solana.js +3 -0
  44. package/dist/cjs/airdrop/contracts/solana/merkle_token_distributor_solana.js.map +1 -0
  45. package/dist/cjs/airdrop/contracts/solana/merkle_token_distributor_solana.json +1689 -0
  46. package/dist/cjs/airdrop/services/index.d.ts +3 -2
  47. package/dist/cjs/airdrop/services/index.js +8 -1
  48. package/dist/cjs/airdrop/services/index.js.map +1 -1
  49. package/dist/cjs/airdrop/strategies/AirdropStrategyFactory.d.ts +1 -0
  50. package/dist/cjs/airdrop/strategies/AirdropStrategyFactory.js +2 -1
  51. package/dist/cjs/airdrop/strategies/AirdropStrategyFactory.js.map +1 -1
  52. package/dist/cjs/airdrop/strategies/IAirdropStrategy.d.ts +1 -0
  53. package/dist/cjs/airdrop/strategies/SolanaAirdropStrategy.d.ts +25 -0
  54. package/dist/cjs/airdrop/strategies/SolanaAirdropStrategy.js +62 -0
  55. package/dist/cjs/airdrop/strategies/SolanaAirdropStrategy.js.map +1 -0
  56. package/dist/cjs/airdrop/types/index.d.ts +8 -1
  57. package/dist/cjs/airdrop/types/index.js +1 -0
  58. package/dist/cjs/airdrop/types/index.js.map +1 -1
  59. package/dist/esm/airdrop/AirdropClient.d.ts +1 -1
  60. package/dist/esm/airdrop/AirdropClient.js +4 -3
  61. package/dist/esm/airdrop/AirdropClient.js.map +1 -1
  62. package/dist/esm/airdrop/SignatureAirdropClient.d.ts +10 -1
  63. package/dist/esm/airdrop/SignatureAirdropClient.js +49 -12
  64. package/dist/esm/airdrop/SignatureAirdropClient.js.map +1 -1
  65. package/dist/esm/airdrop/common/index.d.ts +1 -1
  66. package/dist/esm/airdrop/constants/chain-config.d.ts +1 -1
  67. package/dist/esm/airdrop/constants/chain-config.js +1 -1
  68. package/dist/esm/airdrop/constants/chain-config.js.map +1 -1
  69. package/dist/esm/airdrop/constants/index.d.ts +1 -0
  70. package/dist/esm/airdrop/constants/index.js +1 -0
  71. package/dist/esm/airdrop/constants/index.js.map +1 -1
  72. package/dist/esm/airdrop/contracts/evm/contracts/AirdropSignatureClient.js +0 -1
  73. package/dist/esm/airdrop/contracts/evm/contracts/AirdropSignatureClient.js.map +1 -1
  74. package/dist/esm/airdrop/contracts/index.d.ts +1 -0
  75. package/dist/esm/airdrop/contracts/index.js +1 -0
  76. package/dist/esm/airdrop/contracts/index.js.map +1 -1
  77. package/dist/esm/airdrop/contracts/solana/AirdropService.d.ts +16 -0
  78. package/dist/esm/airdrop/contracts/solana/AirdropService.js +34 -0
  79. package/dist/esm/airdrop/contracts/solana/AirdropService.js.map +1 -0
  80. package/dist/esm/airdrop/contracts/solana/AirdropSignatureClient.d.ts +3 -2
  81. package/dist/esm/airdrop/contracts/solana/AirdropSignatureClient.js +11 -10
  82. package/dist/esm/airdrop/contracts/solana/AirdropSignatureClient.js.map +1 -1
  83. package/dist/esm/airdrop/contracts/solana/FeeCollectorClient.d.ts +3 -2
  84. package/dist/esm/airdrop/contracts/solana/FeeCollectorClient.js +7 -3
  85. package/dist/esm/airdrop/contracts/solana/FeeCollectorClient.js.map +1 -1
  86. package/dist/esm/airdrop/contracts/solana/MerkleDistributorClient.d.ts +49 -0
  87. package/dist/esm/airdrop/contracts/solana/MerkleDistributorClient.js +212 -0
  88. package/dist/esm/airdrop/contracts/solana/MerkleDistributorClient.js.map +1 -0
  89. package/dist/esm/airdrop/contracts/solana/SignatureAirdropService.d.ts +1 -0
  90. package/dist/esm/airdrop/contracts/solana/SignatureAirdropService.js.map +1 -1
  91. package/dist/esm/airdrop/contracts/solana/SolanaContractClient.d.ts +1 -0
  92. package/dist/esm/airdrop/contracts/solana/SolanaContractClient.js +3 -0
  93. package/dist/esm/airdrop/contracts/solana/SolanaContractClient.js.map +1 -1
  94. package/dist/esm/airdrop/contracts/solana/eddsa_token_with_fees_distributor_solana.d.ts +1668 -0
  95. package/dist/esm/airdrop/contracts/solana/eddsa_token_with_fees_distributor_solana.js +2 -0
  96. package/dist/esm/airdrop/contracts/solana/eddsa_token_with_fees_distributor_solana.js.map +1 -0
  97. package/dist/esm/airdrop/contracts/solana/{fungible_token_distributor_solana.json → eddsa_token_with_fees_distributor_solana.json} +127 -38
  98. package/dist/esm/airdrop/contracts/solana/fee_collector.d.ts +198 -1
  99. package/dist/esm/airdrop/contracts/solana/fee_collector.json +200 -3
  100. package/dist/esm/airdrop/contracts/solana/merkle_token_distributor_solana.d.ts +1695 -0
  101. package/dist/esm/airdrop/contracts/solana/merkle_token_distributor_solana.js +2 -0
  102. package/dist/esm/airdrop/contracts/solana/merkle_token_distributor_solana.js.map +1 -0
  103. package/dist/esm/airdrop/contracts/solana/merkle_token_distributor_solana.json +1689 -0
  104. package/dist/esm/airdrop/services/index.d.ts +3 -2
  105. package/dist/esm/airdrop/services/index.js +6 -0
  106. package/dist/esm/airdrop/services/index.js.map +1 -1
  107. package/dist/esm/airdrop/strategies/AirdropStrategyFactory.d.ts +1 -0
  108. package/dist/esm/airdrop/strategies/AirdropStrategyFactory.js +2 -1
  109. package/dist/esm/airdrop/strategies/AirdropStrategyFactory.js.map +1 -1
  110. package/dist/esm/airdrop/strategies/IAirdropStrategy.d.ts +1 -0
  111. package/dist/esm/airdrop/strategies/SolanaAirdropStrategy.d.ts +25 -0
  112. package/dist/esm/airdrop/strategies/SolanaAirdropStrategy.js +58 -0
  113. package/dist/esm/airdrop/strategies/SolanaAirdropStrategy.js.map +1 -0
  114. package/dist/esm/airdrop/types/index.d.ts +8 -1
  115. package/dist/esm/airdrop/types/index.js +1 -0
  116. package/dist/esm/airdrop/types/index.js.map +1 -1
  117. package/package.json +2 -9
  118. package/src/airdrop/AirdropClient.ts +0 -307
  119. package/src/airdrop/SignatureAirdropClient.ts +0 -337
  120. package/src/airdrop/common/index.ts +0 -54
  121. package/src/airdrop/common/projectDataForTon.ts +0 -79
  122. package/src/airdrop/constants/chain-config.ts +0 -107
  123. package/src/airdrop/constants/index.ts +0 -8
  124. package/src/airdrop/constants/network.ts +0 -78
  125. package/src/airdrop/contracts/evm/AirdropService.ts +0 -181
  126. package/src/airdrop/contracts/evm/SignatureAirdropService.ts +0 -114
  127. package/src/airdrop/contracts/evm/contracts/AirdropSignatureClient.ts +0 -63
  128. package/src/airdrop/contracts/evm/contracts/AirdropSignatureFeeClient.ts +0 -61
  129. package/src/airdrop/contracts/evm/contracts/AirdropV2Client.ts +0 -37
  130. package/src/airdrop/contracts/evm/contracts/AirdropV3Client.ts +0 -49
  131. package/src/airdrop/contracts/evm/contracts/AirdropV3FeeClient.ts +0 -16
  132. package/src/airdrop/contracts/evm/contracts/AirdropV4Client.ts +0 -36
  133. package/src/airdrop/contracts/evm/contracts/ContractBaseClient.ts +0 -85
  134. package/src/airdrop/contracts/evm/contracts/DeployClient.ts +0 -35
  135. package/src/airdrop/contracts/evm/contracts/FeeCollectorClient.ts +0 -21
  136. package/src/airdrop/contracts/evm/contracts/KycClient.ts +0 -21
  137. package/src/airdrop/contracts/evm/contracts/abis/Airdrop.json +0 -674
  138. package/src/airdrop/contracts/evm/contracts/abis/AirdropV2.json +0 -676
  139. package/src/airdrop/contracts/evm/contracts/abis/AirdropV3.json +0 -740
  140. package/src/airdrop/contracts/evm/contracts/abis/AirdropV3_Fee.json +0 -678
  141. package/src/airdrop/contracts/evm/contracts/abis/CustomFeeNativeAirdropV4.json +0 -701
  142. package/src/airdrop/contracts/evm/contracts/abis/Deployer.json +0 -271
  143. package/src/airdrop/contracts/evm/contracts/abis/ERC721.json +0 -737
  144. package/src/airdrop/contracts/evm/contracts/abis/FeeCollector.json +0 -322
  145. package/src/airdrop/contracts/evm/contracts/abis/FungibleTokenECDSADistributor.json +0 -564
  146. package/src/airdrop/contracts/evm/contracts/abis/FungibleTokenWithFeesECDSADistributor.json +0 -260
  147. package/src/airdrop/contracts/evm/contracts/abis/KycHook.json +0 -312
  148. package/src/airdrop/contracts/index.ts +0 -4
  149. package/src/airdrop/contracts/solana/AirdropSignatureClient.ts +0 -242
  150. package/src/airdrop/contracts/solana/FeeCollectorClient.ts +0 -43
  151. package/src/airdrop/contracts/solana/SignatureAirdropService.ts +0 -51
  152. package/src/airdrop/contracts/solana/SolanaContractClient.ts +0 -126
  153. package/src/airdrop/contracts/solana/fee_collector.json +0 -1063
  154. package/src/airdrop/contracts/solana/fee_collector.ts +0 -1069
  155. package/src/airdrop/contracts/solana/fungible_token_distributor_solana.json +0 -1573
  156. package/src/airdrop/contracts/solana/fungible_token_distributor_solana.ts +0 -1579
  157. package/src/airdrop/contracts/ton/AirdropClientV1.ts +0 -122
  158. package/src/airdrop/contracts/ton/AirdropClientV2.ts +0 -118
  159. package/src/airdrop/contracts/ton/AirdropClientV21.ts +0 -131
  160. package/src/airdrop/contracts/ton/AirdropClientV3.ts +0 -127
  161. package/src/airdrop/contracts/ton/AirdropService.ts +0 -150
  162. package/src/airdrop/contracts/ton/TonContractBaseClient.ts +0 -236
  163. package/src/airdrop/contracts/ton/v1/build/Leaf.compiled.json +0 -1
  164. package/src/airdrop/contracts/ton/v1/build/MerkleTokenDistributor.compiled.json +0 -1
  165. package/src/airdrop/contracts/ton/v1/utils/constants.ts +0 -42
  166. package/src/airdrop/contracts/ton/v1/utils/date.utils.ts +0 -11
  167. package/src/airdrop/contracts/ton/v1/utils/index.ts +0 -3
  168. package/src/airdrop/contracts/ton/v1/utils/ton.utils.ts +0 -84
  169. package/src/airdrop/contracts/ton/v1/wrappers/JettonMinter.ts +0 -81
  170. package/src/airdrop/contracts/ton/v1/wrappers/JettonWallet.ts +0 -73
  171. package/src/airdrop/contracts/ton/v1/wrappers/Leaf.ts +0 -88
  172. package/src/airdrop/contracts/ton/v1/wrappers/MerkleTokenDistributor.ts +0 -317
  173. package/src/airdrop/contracts/ton/v1/wrappers/index.ts +0 -2
  174. package/src/airdrop/contracts/ton/v2/build/Leaf.compiled.json +0 -1
  175. package/src/airdrop/contracts/ton/v2/build/MerkleTokenDistributor.compiled.json +0 -1
  176. package/src/airdrop/contracts/ton/v2/utils/constants.ts +0 -43
  177. package/src/airdrop/contracts/ton/v2/utils/date.utils.ts +0 -11
  178. package/src/airdrop/contracts/ton/v2/utils/index.ts +0 -3
  179. package/src/airdrop/contracts/ton/v2/utils/ton.utils.ts +0 -102
  180. package/src/airdrop/contracts/ton/v2/wrappers/Leaf.ts +0 -69
  181. package/src/airdrop/contracts/ton/v2/wrappers/MerkleTokenDistributor.ts +0 -340
  182. package/src/airdrop/contracts/ton/v2/wrappers/index.ts +0 -2
  183. package/src/airdrop/contracts/ton/v21/build/Leaf.compiled.json +0 -1
  184. package/src/airdrop/contracts/ton/v21/build/MerkleTokenDistributor.compiled.json +0 -1
  185. package/src/airdrop/contracts/ton/v21/utils/constants.ts +0 -48
  186. package/src/airdrop/contracts/ton/v21/utils/date.utils.ts +0 -11
  187. package/src/airdrop/contracts/ton/v21/utils/index.ts +0 -3
  188. package/src/airdrop/contracts/ton/v21/utils/ton.utils.ts +0 -84
  189. package/src/airdrop/contracts/ton/v21/wrappers/Leaf.ts +0 -69
  190. package/src/airdrop/contracts/ton/v21/wrappers/MerkleTokenDistributor.ts +0 -346
  191. package/src/airdrop/contracts/ton/v21/wrappers/index.ts +0 -2
  192. package/src/airdrop/contracts/ton/v3/build/Leaf.compiled.json +0 -1
  193. package/src/airdrop/contracts/ton/v3/build/MerkleTokenDistributor.compiled.json +0 -1
  194. package/src/airdrop/contracts/ton/v3/utils/constants.ts +0 -43
  195. package/src/airdrop/contracts/ton/v3/utils/date.utils.ts +0 -11
  196. package/src/airdrop/contracts/ton/v3/utils/index.ts +0 -3
  197. package/src/airdrop/contracts/ton/v3/utils/ton.utils.ts +0 -84
  198. package/src/airdrop/contracts/ton/v3/wrappers/Leaf.ts +0 -68
  199. package/src/airdrop/contracts/ton/v3/wrappers/MerkleTokenDistributor.ts +0 -316
  200. package/src/airdrop/contracts/ton/v3/wrappers/index.ts +0 -2
  201. package/src/airdrop/index.ts +0 -10
  202. package/src/airdrop/services/index.ts +0 -159
  203. package/src/airdrop/services/wallet-service/ton/WalletService.ts +0 -226
  204. package/src/airdrop/services/wallet-service/ton/index.ts +0 -1
  205. package/src/airdrop/strategies/AirdropStrategyFactory.ts +0 -31
  206. package/src/airdrop/strategies/EvmAirdropStrategy.ts +0 -81
  207. package/src/airdrop/strategies/IAirdropStrategy.ts +0 -26
  208. package/src/airdrop/strategies/StrategyCache.ts +0 -34
  209. package/src/airdrop/strategies/TonAirdropStrategy.ts +0 -77
  210. package/src/airdrop/tests/index.test.ts +0 -387
  211. package/src/airdrop/types/index.ts +0 -199
  212. package/src/index.ts +0 -3
  213. package/src/utils/api-client.ts +0 -69
  214. package/src/utils/index.ts +0 -3
  215. package/src/utils/utils.ts +0 -45
  216. package/src/utils/web3.ts +0 -172
  217. package/src/wallets/WalletBase.ts +0 -92
  218. package/src/wallets/WalletFactory.tsx +0 -35
  219. package/src/wallets/index.ts +0 -3
  220. package/src/wallets/providers/evm/EvmWallet.ts +0 -101
  221. package/src/wallets/providers/evm/index.tsx +0 -56
  222. package/src/wallets/providers/index.ts +0 -4
  223. package/src/wallets/providers/solana/index.tsx +0 -133
  224. package/src/wallets/providers/ton/TonWallet.ts +0 -153
  225. package/src/wallets/providers/ton/index.tsx +0 -41
  226. package/src/wallets/types.ts +0 -45
  227. 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
- }
@@ -1,2 +0,0 @@
1
- export * from './Leaf';
2
- export * from './MerkleTokenDistributor';
@@ -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';