@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,346 +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
- startTime: Date;
24
- endTime: Date;
25
- leafCode: Cell;
26
- claimFee?: bigint;
27
- claimFeeAddress?: Address;
28
- paused?: boolean;
29
- feelessThreshold?: bigint;
30
- };
31
-
32
- export function tokenDistributorConfigToCell(config: MerkleTokenDistributorConfig): Cell {
33
- const {
34
- version,
35
- adminAddress,
36
- deployer,
37
- endTime,
38
- leafCode,
39
- root,
40
- startTime,
41
- claimFee,
42
- claimFeeAddress,
43
- paused = false,
44
- feelessThreshold = 0
45
- } = config;
46
- let c2 = beginCell()
47
- .storeCoins(claimFee ?? 0)
48
- .storeUint(claimFeeAddress ? 1 : 0, 1);
49
-
50
- if (claimFeeAddress) {
51
- c2 = c2.storeAddress(claimFeeAddress);
52
- }
53
-
54
- c2 = c2
55
- .storeUint(paused ? 1 : 0, 1)
56
- .storeCoins(feelessThreshold)
57
- .storeCoins(0);
58
-
59
- const c1 = beginCell()
60
- .storeAddress(deployer)
61
- .storeUint(dateToUnixTimestamp(startTime), 32)
62
- .storeUint(dateToUnixTimestamp(endTime), 32)
63
- .storeRef(leafCode)
64
- .endCell();
65
-
66
- return beginCell()
67
- .storeUint(stringToInt(version), 64)
68
- .storeAddress(adminAddress)
69
- .storeUint(root, 256)
70
- .storeRef(c1)
71
- .storeRef(c2.endCell())
72
- .endCell();
73
- }
74
-
75
- export type TokenDistributorEntry = {
76
- address: Address;
77
- claimableAmount: bigint;
78
- claimableTimestamp: number;
79
- };
80
-
81
- export const tokenDistributorEntryValue = {
82
- serialize: (src: TokenDistributorEntry, buidler: Builder) => {
83
- buidler.storeAddress(src.address).storeCoins(src.claimableAmount).storeUint(src.claimableTimestamp, 32);
84
- },
85
- parse: (src: Slice) => {
86
- return {
87
- address: src.loadAddress(),
88
- claimableAmount: src.loadCoins(),
89
- claimableTimestamp: src.loadUint(32)
90
- };
91
- }
92
- };
93
-
94
- export function generateEntriesDictionary(entries: TokenDistributorEntry[]): Dictionary<bigint, TokenDistributorEntry> {
95
- const dict: Dictionary<bigint, TokenDistributorEntry> = Dictionary.empty(
96
- Dictionary.Keys.BigUint(64),
97
- tokenDistributorEntryValue
98
- );
99
-
100
- for (let i = 0; i < entries.length; i++) {
101
- dict.set(BigInt(i), entries[i]);
102
- }
103
-
104
- return dict;
105
- }
106
-
107
- export class MerkleTokenDistributor implements Contract {
108
- constructor(readonly address: Address, readonly init?: { code: Cell; data: Cell }) {}
109
-
110
- static createFromAddress(address: Address) {
111
- return new MerkleTokenDistributor(address);
112
- }
113
-
114
- static createFromConfig(config: MerkleTokenDistributorConfig, code: Cell, workchain = 0) {
115
- const data = tokenDistributorConfigToCell(config);
116
- const init = { code, data };
117
- return new MerkleTokenDistributor(contractAddress(workchain, init), init);
118
- }
119
-
120
- async sendDeploy(provider: ContractProvider, via: Sender, value: bigint) {
121
- await provider.internal(via, {
122
- value,
123
- sendMode: SendMode.PAY_GAS_SEPARATELY,
124
- body: beginCell().endCell()
125
- });
126
- }
127
-
128
- async getVersion(provider: ContractProvider): Promise<string> {
129
- const result = await provider.get('get_version', []);
130
-
131
- return intToString(Number(result.stack.readBigNumber()));
132
- }
133
-
134
- async getLeafAddress(provider: ContractProvider, index: bigint): Promise<Address> {
135
- const arg: TupleItem = {
136
- value: index,
137
- type: 'int'
138
- };
139
- const result = await provider.get('get_leaf_address', [arg]);
140
-
141
- return result.stack.readAddress();
142
- }
143
-
144
- async getRoot(provider: ContractProvider): Promise<bigint> {
145
- const result = await provider.get('get_root', []);
146
-
147
- return result.stack.readBigNumber();
148
- }
149
-
150
- async getTime(provider: ContractProvider): Promise<[Date, Date] | [null, null]> {
151
- const result = await provider.get('get_time', []);
152
- const stack = result.stack;
153
-
154
- try {
155
- return [unixTimestampToDate(stack.readNumber()), unixTimestampToDate(stack.readNumber())];
156
- } catch (e) {
157
- return [null, null];
158
- }
159
- }
160
-
161
- async getAdminAddress(provider: ContractProvider): Promise<Address> {
162
- const result = await provider.get('get_admin_address', []);
163
-
164
- return result.stack.readAddress();
165
- }
166
-
167
- async getClaimFee(provider: ContractProvider): Promise<bigint> {
168
- const result = await provider.get('get_claim_fee', []);
169
-
170
- return result.stack.readBigNumber();
171
- }
172
-
173
- async getClaimFeeAddress(provider: ContractProvider): Promise<Address | null> {
174
- const result = await provider.get('get_claim_fee_address', []);
175
-
176
- try {
177
- return result.stack.readAddress();
178
- } catch (e) {
179
- return null;
180
- }
181
- }
182
-
183
- async getPaused(provider: ContractProvider): Promise<boolean> {
184
- const result = await provider.get('get_paused', []);
185
-
186
- return result.stack.readNumber() === 1;
187
- }
188
-
189
- async getFeelessThreshold(provider: ContractProvider): Promise<bigint> {
190
- const result = await provider.get('get_feeless_threshold', []);
191
-
192
- return result.stack.readBigNumber();
193
- }
194
-
195
- async getAccumulatedFees(provider: ContractProvider): Promise<bigint> {
196
- const result = await provider.get('get_accumulated_fees', []);
197
-
198
- return result.stack.readBigNumber();
199
- }
200
-
201
- async getBalance(provider: ContractProvider): Promise<bigint> {
202
- const result = await provider.get('get_ton_balance', []);
203
-
204
- return result.stack.readBigNumber();
205
- }
206
-
207
- async sendChangeAdmin(provider: ContractProvider, via: Sender, newAdmin: Address) {
208
- const messageBody = beginCell().storeUint(OpCode.ChangeAdmin, 32).storeUint(0, 64).storeAddress(newAdmin).endCell();
209
- const result = await provider.internal(via, {
210
- value: '0.01',
211
- body: messageBody
212
- });
213
-
214
- return result;
215
- }
216
-
217
- async sendChangeCode(provider: ContractProvider, via: Sender, codeType: CodeType, newCode: Cell) {
218
- const messageBody = beginCell()
219
- .storeUint(OpCode.ChangeCode, 32)
220
- .storeUint(0, 64)
221
- .storeUint(codeType, 32)
222
- .storeRef(newCode)
223
- .endCell();
224
- const result = await provider.internal(via, {
225
- value: '0.01',
226
- body: messageBody
227
- });
228
-
229
- return result;
230
- }
231
-
232
- async sendChangeVersion(provider: ContractProvider, via: Sender, version: string) {
233
- const messageBody = beginCell()
234
- .storeUint(OpCode.ChangeVersion, 32)
235
- .storeUint(0, 64)
236
- .storeUint(stringToInt(version), 64)
237
- .endCell();
238
- const result = await provider.internal(via, {
239
- value: '0.01',
240
- body: messageBody
241
- });
242
-
243
- return result;
244
- }
245
-
246
- async sendWithdraw(provider: ContractProvider, via: Sender, amount: string) {
247
- const messageBody = beginCell()
248
- .storeUint(OpCode.Withdraw, 32)
249
- .storeUint(0, 64)
250
- .storeCoins(toNano(amount))
251
- .endCell();
252
- const result = await provider.internal(via, {
253
- value: '0.01',
254
- body: messageBody
255
- });
256
-
257
- return result;
258
- }
259
-
260
- async sendWithdrawFees(provider: ContractProvider, via: Sender) {
261
- const messageBody = beginCell().storeUint(OpCode.WithdrawFees, 32).storeUint(0, 64).endCell();
262
- const result = await provider.internal(via, {
263
- value: '0.1',
264
- body: messageBody
265
- });
266
-
267
- return result;
268
- }
269
-
270
- async sendSetBaseParams(provider: ContractProvider, via: Sender, startTime: Date, endTime: Date, root: bigint) {
271
- const messageBody = beginCell()
272
- .storeUint(OpCode.SetBaseParams, 32)
273
- .storeUint(0, 64)
274
- .storeUint(dateToUnixTimestamp(startTime), 32)
275
- .storeUint(dateToUnixTimestamp(endTime), 32)
276
- .storeUint(root, 256)
277
- .endCell();
278
- const result = await provider.internal(via, {
279
- value: '0.01',
280
- body: messageBody
281
- });
282
- return result;
283
- }
284
-
285
- async sendSetClaimFee(provider: ContractProvider, via: Sender, claimFee: bigint) {
286
- const messageBody = beginCell().storeUint(OpCode.SetClaimFee, 32).storeUint(0, 64).storeCoins(claimFee).endCell();
287
- const result = await provider.internal(via, {
288
- value: '0.01',
289
- body: messageBody
290
- });
291
-
292
- return result;
293
- }
294
-
295
- async sendSetClaimFeeAddress(provider: ContractProvider, via: Sender, claimFeeAddress: Address) {
296
- const messageBody = beginCell()
297
- .storeUint(OpCode.SetClaimFeeAddress, 32)
298
- .storeUint(0, 64)
299
- .storeAddress(claimFeeAddress)
300
- .endCell();
301
- const result = await provider.internal(via, {
302
- value: '0.01',
303
- body: messageBody
304
- });
305
-
306
- return result;
307
- }
308
-
309
- async sendSetPaused(provider: ContractProvider, via: Sender, paused: boolean) {
310
- const messageBody = beginCell()
311
- .storeUint(OpCode.SetPaused, 32)
312
- .storeUint(0, 64)
313
- .storeUint(paused ? 1 : 0, 1)
314
- .endCell();
315
- const result = await provider.internal(via, {
316
- value: '0.01',
317
- body: messageBody
318
- });
319
-
320
- return result;
321
- }
322
-
323
- async sendSetFeelessThreshold(provider: ContractProvider, via: Sender, feelessThreshold: bigint) {
324
- const messageBody = beginCell()
325
- .storeUint(OpCode.SetFeelessThreshold, 32)
326
- .storeUint(0, 64)
327
- .storeCoins(feelessThreshold)
328
- .endCell();
329
- const result = await provider.internal(via, {
330
- value: '0.01',
331
- body: messageBody
332
- });
333
-
334
- return result;
335
- }
336
-
337
- async sendClearClaimFeeAddress(provider: ContractProvider, via: Sender) {
338
- const messageBody = beginCell().storeUint(OpCode.ClearClaimFeeAddress, 32).storeUint(0, 64).endCell();
339
- const result = await provider.internal(via, {
340
- value: '0.01',
341
- body: messageBody
342
- });
343
-
344
- return result;
345
- }
346
- }
@@ -1,2 +0,0 @@
1
- export * from './Leaf';
2
- export * from './MerkleTokenDistributor';
@@ -1 +0,0 @@
1
- {"hex":"b5ee9c7241022a01000887000114ff00f4a413f4bcf2c80b01020162050202015804030025bbc01f057f844f842c8cb00f843cf16cb3fc98000dbaf13f057f84280202c918060201480c0702012009080019d8164658000e78b659fe4f6aa40201200b0a0025f76a268698000fc317d2000fc31e99f987c32400276be401c1cb232c072c004b2c1f2fff2743e900c20103a3c00d04f62082300de0b6b3a7640000ba9b30823025b946ebc0b36173e08200c354218235c702bd3a30fc0000be228238070c1cc73b00c80000bbb0f2f420c1008e1282300de0b6b3a76400005202a3f04712a984e020821b782dace9d9aa18bee30f01a7648238056bc75e2d6310000021822056bc75e2d631aa18bee300211716150e02f4822056bc75e2d631aa17be8e2701822056bc75e2d631aa17a101824adf0ab5a80a22c61ab5a7008238056bc75e2d63100000a984de21822056bc75e2d631aa16be8e2601822056bc75e2d631aa16a10182403f1fce3da636ea5cf8508238056bc75e2d63100000a984de21823815af1d78b58c400000bee30021140f02f482380ad78ebc5ac6200000be8e260182380ad78ebc5ac6200000a1018238280e60114edb805d038238056bc75e2d63100000a984de218238056bc75e2d63100000be8e26018238056bc75e2d63100000a10182380ebc5fb417461211108238056bc75e2d63100000a984de218232b5e3af16b1880000bee30021131001ec82315af1d78b58c40000be8e250182315af1d78b58c40000a101823806f5f17757889379378238056bc75e2d63100000a984de218238056bc75e2d6310000021a0511382380ad78ebc5ac6200000a98466a0511382381043561a8829300000a98466a05113823815af1d78b58c400000a98466a051131101ea82381b1ae4d6e2ef500000a98466a0511382382086ac351052600000a98466a05113823825f273933db5700000a98466a05113822056bc75e2d631aa16a98466a05113823830ca024f987b900000a98466a0511382383635c9adc5dea00000a98466a0511382383ba1910bf341b00000a98466a0031200428238410d586a20a4c00000a98412a08238056bc75e2d63100000a984018064a984004a018232b5e3af16b1880000a101823808f00f760a4b2db55d8238056bc75e2d63100000a984004c01823815af1d78b58c400000a101823927fa27722cc06cc5e28238056bc75e2d63100000a984003830822056bc75e2d631aa18a18261855144814a7ff805980ff0084000005020821b782dace9d9aa17be8e18821b782dace9d9aa17a182501425982cf597cd205cef73809171e20042821b782dace9d9aa18a18288195e54c5dd42177f53a27172fa9ec630262827aa2302012024190103aee01a01f62082300de0b6b3a7640000b98e1182300de0b6b3a76400005202a984f03ba3e0702182b05803bcc5cb9634ba4cfb2213f784019318ed4dcb6017880faa35be8e23308288195e54c5dd42177f53a27172fa9ec630262827aa23a904821b782dace9d9aa18de2182708bcc0026baae9e45e470190267a230cfaa18be1b02ea8e1c0182501425982cf597cd205cef7380a90401821b782dace9d9aa17a0dea76401a764208261855144814a7ff805980ff0084000be8e2a8238056bc75e2d631000008261855144814a7ff805980ff0084000a98401822056bc75e2d631aa18a001de20824adf0ab5a80a22c61ab5a700bee30020231c02f882403f1fce3da636ea5cf850be8e268238056bc75e2d6310000082403f1fce3da636ea5cf850a98401822056bc75e2d631aa16a001de20823927fa27722cc06cc5e2be8e268238056bc75e2d63100000823927fa27722cc06cc5e2a98401823815af1d78b58c400000a001de208238280e60114edb805d03bee30020221d02f482380ebc5fb41746121110be8e268238056bc75e2d6310000082380ebc5fb41746121110a984018238056bc75e2d63100000a001de20823808f00f760a4b2db55dbe8e258238056bc75e2d63100000823808f00f760a4b2db55da984018232b5e3af16b1880000a001de20823806f5f1775788937937bee30020211e01ec823806248f33704b286603be8e258238056bc75e2d63100000823806248f33704b286603a984018230ad78ebc5ac620000a001de20823805c548670b9510e7acbe8e258238056bc75e2d63100000823805c548670b9510e7aca98401823056bc75e2d6310000a001de208238056bc75e2d63100000a11f01fe8238056bc75e2d631000005122a012a98453008238056bc75e2d63100000a9845c8238056bc75e2d63100000a9842073a90413a051218238056bc75e2d63100000a9842075a90413a051218238056bc75e2d63100000a9842077a90413a051218238056bc75e2d63100000a9842079a90413a0598238056bc75e2d6310000020001ca984800ba904a0aa00a08064a904004a8238056bc75e2d63100000823806f5f1775788937937a9840182315af1d78b58c40000a001004c8238056bc75e2d631000008238280e60114edb805d03a9840182380ad78ebc5ac6200000a001004e8238056bc75e2d63100000824adf0ab5a80a22c61ab5a700a98401822056bc75e2d631aa17a00102012026250063a46410e0804c45896c678b00d180ef381038c70a023d5486531812d40950025503815210e0002298731819d5016780e4e84001d7d0c8871c02497c0f83434c0c05c6c2497c0f83e900c0074c7f4cfc8a08426871dda6ea38d8d16fc15fe10f1c17ca8f4cff4c03e1104eebcabdc3e10fe113c163000244c383e900c1c20043232c15633c5887e80b2dab260103ec03800a084140f4725eeb8c097c12103fcbc22702fcf057038210042c1d80bef2b0f842c001f268d4d33f30f864885210f90001f900baf26420d739f2aad30701c003f2ab21d765aa00a6025220f9415f03f84401d4308040f40e6fa131f2ad71f843f844f058f842f8448210d0d5f405c8cb1f15cb3f12cc13cb3f12cb0001cf16c9718010c8cb05f843cf1670fa02cb6accc9292800088306fb0000006e3bece9"}
@@ -1 +0,0 @@
1
- {"hex":"b5ee9c7241024801000c65000114ff00f4a413f4bcf2c80b01020162150202012008030201200504000db8379f055f84d80201480706000db1ecfc157e12e0000db3aafc157e112002015812090201580d0a0201200c0b0010abe0f055f847f8480010a8e0f055f059f05a020120110e02016e100f000bb92f055f84a8000bba9f055f8468000ca82ff055f8430201201413000db1a7fc157e1320000db0643c157e10a00202c9301602014824170201201f180201201a190081d41057d7840387d8141084d0e3bb4e4658f8a659f89659f9163804a99382c65804bb880e5802c678b7164b8c008646582a801e78b387d010965b56664c1837d8040201201e1b0201201d1c00cd2082bebc201c3ec0be1354842f23885c7232e3dc3232c7c073c5f25c60043232c17e12f3c5be12be80b2dab3325c7ec0379c08208403e29fa97232c7c572cfd63e8088b3c59633c584b2c0087e80b2c0325c60063232c17e11b3c59c3e80b2dab33260c1bec02000173e4020c27232c2b2fff274200029570c8cb00f828cf16cb3fc9f84976c8cb04ccccc9802012023200201202221005d4c85004fa0258cf16cb0001fa02c9c85006cf165004cf1612cb1fcb1fccc904c8cb3f5003cf16cbff12ccccc9ed54800895ed44d0d33f01f862fa4001f863d3ff01f864d401d0fa4001f865fa4001f866d31f01f867d31f01f868d430f869d430d0fa0001f86afa4001f86bd30001f86cfa0030f86d800276be401c1cb232c072c004b2c1f2fff2743e900c20103a3c02504f62082300de0b6b3a7640000ba9b30823025b946ebc0b36173e08200c354218235c702bd3a30fc0000be228238070c1cc73b00c80000bbb0f2f420c1008e1282300de0b6b3a76400005202a3f04712a984e020821b782dace9d9aa18bee30f01a7648238056bc75e2d6310000021822056bc75e2d631aa18bee300212f2e2d2602f4822056bc75e2d631aa17be8e2701822056bc75e2d631aa17a101824adf0ab5a80a22c61ab5a7008238056bc75e2d63100000a984de21822056bc75e2d631aa16be8e2601822056bc75e2d631aa16a10182403f1fce3da636ea5cf8508238056bc75e2d63100000a984de21823815af1d78b58c400000bee300212c2702f482380ad78ebc5ac6200000be8e260182380ad78ebc5ac6200000a1018238280e60114edb805d038238056bc75e2d63100000a984de218238056bc75e2d63100000be8e26018238056bc75e2d63100000a10182380ebc5fb417461211108238056bc75e2d63100000a984de218232b5e3af16b1880000bee300212b2801ec82315af1d78b58c40000be8e250182315af1d78b58c40000a101823806f5f17757889379378238056bc75e2d63100000a984de218238056bc75e2d6310000021a0511382380ad78ebc5ac6200000a98466a0511382381043561a8829300000a98466a05113823815af1d78b58c400000a98466a051132901ea82381b1ae4d6e2ef500000a98466a0511382382086ac351052600000a98466a05113823825f273933db5700000a98466a05113822056bc75e2d631aa16a98466a05113823830ca024f987b900000a98466a0511382383635c9adc5dea00000a98466a0511382383ba1910bf341b00000a98466a0032a00428238410d586a20a4c00000a98412a08238056bc75e2d63100000a984018064a984004a018232b5e3af16b1880000a101823808f00f760a4b2db55d8238056bc75e2d63100000a984004c01823815af1d78b58c400000a101823927fa27722cc06cc5e28238056bc75e2d63100000a984003830822056bc75e2d631aa18a18261855144814a7ff805980ff0084000005020821b782dace9d9aa17be8e18821b782dace9d9aa17a182501425982cf597cd205cef73809171e20042821b782dace9d9aa18a18288195e54c5dd42177f53a27172fa9ec630262827aa230201203c310103aee03201f62082300de0b6b3a7640000b98e1182300de0b6b3a76400005202a984f03ba3e0702182b05803bcc5cb9634ba4cfb2213f784019318ed4dcb6017880faa35be8e23308288195e54c5dd42177f53a27172fa9ec630262827aa23a904821b782dace9d9aa18de2182708bcc0026baae9e45e470190267a230cfaa18be3302ea8e1c0182501425982cf597cd205cef7380a90401821b782dace9d9aa17a0dea76401a764208261855144814a7ff805980ff0084000be8e2a8238056bc75e2d631000008261855144814a7ff805980ff0084000a98401822056bc75e2d631aa18a001de20824adf0ab5a80a22c61ab5a700bee300203b3402f882403f1fce3da636ea5cf850be8e268238056bc75e2d6310000082403f1fce3da636ea5cf850a98401822056bc75e2d631aa16a001de20823927fa27722cc06cc5e2be8e268238056bc75e2d63100000823927fa27722cc06cc5e2a98401823815af1d78b58c400000a001de208238280e60114edb805d03bee300203a3502f482380ebc5fb41746121110be8e268238056bc75e2d6310000082380ebc5fb41746121110a984018238056bc75e2d63100000a001de20823808f00f760a4b2db55dbe8e258238056bc75e2d63100000823808f00f760a4b2db55da984018232b5e3af16b1880000a001de20823806f5f1775788937937bee30020393601ec823806248f33704b286603be8e258238056bc75e2d63100000823806248f33704b286603a984018230ad78ebc5ac620000a001de20823805c548670b9510e7acbe8e258238056bc75e2d63100000823805c548670b9510e7aca98401823056bc75e2d6310000a001de208238056bc75e2d63100000a13701fe8238056bc75e2d631000005122a012a98453008238056bc75e2d63100000a9845c8238056bc75e2d63100000a9842073a90413a051218238056bc75e2d63100000a9842075a90413a051218238056bc75e2d63100000a9842077a90413a051218238056bc75e2d63100000a9842079a90413a0598238056bc75e2d6310000038001ca984800ba904a0aa00a08064a904004a8238056bc75e2d63100000823806f5f1775788937937a9840182315af1d78b58c40000a001004c8238056bc75e2d631000008238280e60114edb805d03a9840182380ad78ebc5ac6200000a001004e8238056bc75e2d63100000824adf0ab5a80a22c61ab5a700a98401822056bc75e2d631aa17a0010201203e3d0063a46410e0804c45896c678b00d180ef381038c70a023d5486531812d40950025503815210e0002298731819d5016780e4e84001f7d0c8871c02497c0f83434c0fe900c005c6c23890c0c600835c874c7f4cfcc208403e29fa9562f644c383c15483c165c007c1684a2c23c17380074c7f4cfc8a08411903f076ea38b0d16fc157e10f1c17ca8fe900c0831c03c993e10be113e117e11be11fe123e127e12be12fe133e13442afc15b808a08416003133e3f03fcba8ee8345bf055f843c705f2a3d31fd430885210f90001f900baf264218210f00aed53ba8e1bf842f843f844f845f846f847f848f84af84bf84cf84d2b5530f056de018210cdb4d337ba8e1cfb04f842f843f844f845f846f847f848f849f84af84bf84cf84df0569130e2e02282105d456901bae30222821073edc3d2ba47464004f08e4f6c21f055f8435220c705f2a3fa00305122a1820afaf080b9f264c88280576974686472617720636f6d706c6574656401cb8f70c8cb1f01cf17c9718010c8cb055003cf165003fa02cb6accc970fb00e0228210a17f43e1bae302228210c46600a8bae30222821026d65fa9bae30222821079ce8ce5ba4544434101d88e27345bf055f843c705f2a3fa0030f842f843f844f845f846f847f848f849f84af84bf84c550af056e0028210d0d5f405ba8eb1f05501d4d33fd300fa403001f2685444405205ed44ed45ed47955b4130f05ced67ed65ed64747fed118aed41edf101f2ffe05f04840ff2f04200c8f84cf2718209312d00f84aa0820a625a00a0820afaf080a014bef2b002d739f2aad30701c003f2abf84401d3ff59baf2acd43052208040f40e6fa1f2adfa40fa00d31f30f823bbf2a6f847f823bbf2a6f823f848bbf2a623f059f05a13c705f2ae01f05b006e345bf055f843c705f2a3d30030f842f843f844f845f846f847f848f849f84af84bf84d10ab109a1089107810671056104510344130f056006e345bf055f843c705f2a3fa40d31fd31fd3ff305321bef26420c000f264f842f843f845f849f84af84bf84cf84d107b106a10891058f05600923233f055f84312c705f2a3fa0030702082100f8a7ea5c8cb1f14cb3f58fa02f843cf16f843cf1612cb008208989680fa02cb00c9718018c8cb05f846cf1670fa02cb6accc98040fb00004a345bf055f843c705f2a3d33f30f843f844f845f846f847f848f849f84af84bf84cf84df056000030bdf651"}
@@ -1,43 +0,0 @@
1
- export enum OpCode { // CRC32 hash
2
- ChangeAdmin = 1178663965, // 0x4641444d
3
- ChangeCode = 1476445391, // 0x57f8f8f
4
- ChangePaused = 2809239666, // 0xa7a7a7a2
5
- ChangeVersion = 1564829953, // 0x5d5d5d61
6
- DeployLeaf = 2334832459, // 0x8b8b8b8b
7
- Withdraw = 1944962002, // 0x73737372
8
- WithdrawTokens = 2709472225, // 0xa1a1a1a1
9
- Claim = 1346182295, // 0x50505057
10
- ProcessClaim = 3503682565, // 0xd0d5f405
11
- SetBaseParams = 3295019176, // 0xc4c4c4c8
12
- SetPaused = 651583401, // 0x27272729
13
- SetFeelessThreshold = 2043579621, // 0x79CE8CE5
14
- }
15
-
16
- export enum CodeType { // CRC32 hash
17
- Leaf = 4027247955, // 0xf0f0f0f3
18
- TokenDistributor = 3451179831, // 0xcececece
19
- }
20
-
21
- export enum ErrorCode {
22
- UnknownOP = 0xffff, // 65535
23
- ExpiredMessage = 0x20, // 32
24
- RepeatedMessage = 0x21, // 33
25
- InvalidSignature = 0x22, // 34
26
- Unauthorized = 0x23, // 35
27
- InvalidMessageParams = 0x24, // 36
28
- UnsupportedOperation = 0x25, // 37
29
- TimeInactive = 0x26, // 38
30
- InvalidProof = 0x27, // 39
31
- LeafUsed = 0x28, // 40
32
- IncorrectFees = 0x29, // 41
33
- IsProofExotic = 0x2a, // 42
34
- TreeExceeded = 0x2b, // 43
35
- InvalidTree = 0x2c, // 44
36
- NotFound = 0x2d, // 45
37
- WrongSender = 0x2e, // 46
38
- InvalidIndex = 0x2f, // 47
39
- NotEnoughTokens = 0x30, // 48
40
- ContractPaused = 0x31, // 49
41
- }
42
-
43
- export const DICT_CELL_BASE64 = 'te6cckEBBQEAagACA8/YAgEAVdQAOTo5SskfgLMwcypLhB+yLkHhU0qZ/jjQzsVCYiSLoEFAjw0YBf7mYAgCASADAwIBIAQEAFUgAcnRylZI/AWZg5lSXCD9kXIPCppUz/HGhnYqExEkXQIKBHhowC/3MwBAtoUrSg==';
@@ -1,11 +0,0 @@
1
- export function dateToUnixTimestamp(date: Date): number {
2
- return Math.floor(date.getTime() / 1000);
3
- }
4
-
5
- export function unixTimestampToDate(timestamp: number): Date {
6
- return new Date(timestamp * 1000);
7
- }
8
-
9
- export function addOneHour(date: Date): Date {
10
- return new Date(date.getTime() + 60 * 60 * 1000);
11
- }
@@ -1,3 +0,0 @@
1
- export * from './constants';
2
- export * from './date.utils';
3
- export * from './ton.utils';
@@ -1,84 +0,0 @@
1
- import { Address, BitString, Cell, Slice, beginCell, contractAddress, crc32c, toNano } from '@ton/core';
2
-
3
- export function stringToSlice(str: string): Slice {
4
- return beginCell().storeStringTail(str).endCell().asSlice();
5
- }
6
-
7
- export function sliceToString(slice: Slice): string {
8
- const cell = beginCell().storeSlice(slice).endCell();
9
- return cell.beginParse().loadStringTail();
10
- }
11
-
12
- export function stringToInt(str: string): number {
13
- return str ? parseInt(Buffer.from(str).toString('hex'), 16) : 0;
14
- }
15
-
16
- export function intToString(int: number): string {
17
- return Buffer.from(int.toString(16), 'hex').toString('utf-8');
18
- }
19
-
20
- export function bufferToInt(buf: Buffer): number {
21
- return buf.readUInt32BE(0);
22
- }
23
-
24
- export function intToBuffer(int: number): Buffer {
25
- return Buffer.from(int.toString(16), 'hex');
26
- }
27
-
28
- export function sliceToAddress(slice: Slice): Address {
29
- const cell = beginCell().storeSlice(slice).endCell();
30
- return cell.beginParse().loadAddress();
31
- }
32
-
33
- export function addressToSlice(address: Address): Slice {
34
- return beginCell().storeAddress(address).endCell().asSlice();
35
- }
36
-
37
- export function stringToBitString(str: string): BitString {
38
- return new BitString(Buffer.from(str), 0, str.length * 8);
39
- }
40
-
41
- export function bitStringToString(bits: BitString, len: number): string {
42
- const decoder = new TextDecoder();
43
- const subBuffer = bits.subbuffer(0, len);
44
-
45
- return subBuffer ? decoder.decode(subBuffer) : '';
46
- }
47
-
48
- export function stringToCell(str: string): Cell {
49
- return beginCell().storeStringTail(str).endCell();
50
- }
51
-
52
- export function cellToString(cell: Cell): string {
53
- return cell.beginParse().loadStringTail();
54
- }
55
-
56
- export function stringToCrc32(str: string): number {
57
- return crc32c(Buffer.from(str)).readUint32BE();
58
- }
59
-
60
- export function getContractAddress(code: Cell, data: Cell): Address {
61
- return contractAddress(0, { code, data });
62
- }
63
-
64
- export function arraysToCell(arrays: (Slice | Cell | Address | number)[], bits = 32): Cell {
65
- const cell = beginCell();
66
-
67
- arrays.forEach((item) => {
68
- if (item instanceof Slice) {
69
- cell.storeSlice(item);
70
- } else if (item instanceof Cell) {
71
- cell.storeRef(item);
72
- } else if (item instanceof Address) {
73
- cell.storeAddress(item);
74
- } else if (typeof item === 'number') {
75
- cell.storeUint(item, bits);
76
- }
77
- });
78
-
79
- return cell.endCell();
80
- }
81
-
82
- export function coinsToSlice(coins: string): Slice {
83
- return beginCell().storeCoins(toNano(coins)).endCell().asSlice();
84
- }
@@ -1,68 +0,0 @@
1
- import { Address, beginCell, Cell, Contract, contractAddress, ContractProvider, Sender, toNano } from '@ton/core';
2
- import { OpCode } from '../utils';
3
-
4
- export const MIN_CLAIM_FEE = toNano('0.17');
5
-
6
- export type LeafConfig = {
7
- used?: boolean;
8
- distributor: Address;
9
- index: bigint;
10
- };
11
- export function leafConfigToCell(config: LeafConfig): Cell {
12
- const { distributor, index } = config;
13
-
14
- const initState = beginCell().storeBit(false).storeAddress(distributor).storeUint(index, 64).endCell();
15
-
16
- return initState;
17
- }
18
-
19
- export class Leaf implements Contract {
20
- constructor(readonly address: Address, readonly init?: { code: Cell; data: Cell }) {}
21
-
22
- static createFromAddress(address: Address) {
23
- return new Leaf(address);
24
- }
25
-
26
- static createFromConfig(config: LeafConfig, code: Cell, workchain = 0) {
27
- const data = leafConfigToCell(config);
28
- const init = { code, data };
29
- return new Leaf(contractAddress(workchain, init), init);
30
- }
31
-
32
- async getIsUsed(provider: ContractProvider): Promise<boolean> {
33
- const result = await provider.get('get_is_used', []);
34
- const isUsed = result.stack.readNumber();
35
-
36
- return !!isUsed;
37
- }
38
-
39
- async getLeafData(provider: ContractProvider): Promise<LeafConfig> {
40
- const result = await provider.get('get_leaf_data', []);
41
- const cellHash = result.stack.readCell().beginParse();
42
-
43
- const isUsed = cellHash.loadUint(1);
44
- const distributor = cellHash.loadAddress();
45
- const index = cellHash.loadUint(64);
46
-
47
- return {
48
- used: !!isUsed,
49
- index: BigInt(index),
50
- distributor
51
- };
52
- }
53
-
54
- async sendClaim(provider: ContractProvider, via: Sender, proof: Cell, index: bigint, claimFee: bigint) {
55
- const messageBody = beginCell()
56
- .storeUint(OpCode.Claim, 32)
57
- .storeUint(0, 64)
58
- .storeRef(proof)
59
- .storeUint(index, 64)
60
- .endCell();
61
- const result = await provider.internal(via, {
62
- value: MIN_CLAIM_FEE + claimFee,
63
- body: messageBody
64
- });
65
-
66
- return result;
67
- }
68
- }