@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,340 +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 sendSetClaimFee(provider: ContractProvider, via: Sender, claimFee: bigint) {
290
- const messageBody = beginCell().storeUint(OpCode.SetClaimFee, 32).storeUint(0, 64).storeCoins(claimFee).endCell();
291
- const result = await provider.internal(via, {
292
- value: '0.01',
293
- body: messageBody
294
- });
295
-
296
- return result;
297
- }
298
-
299
- async sendSetClaimFeeAddress(provider: ContractProvider, via: Sender, claimFeeAddress: Address) {
300
- const messageBody = beginCell()
301
- .storeUint(OpCode.SetClaimFee, 32)
302
- .storeUint(0, 64)
303
- .storeAddress(claimFeeAddress)
304
- .endCell();
305
- const result = await provider.internal(via, {
306
- value: '0.01',
307
- body: messageBody
308
- });
309
-
310
- return result;
311
- }
312
-
313
- async sendSetPaused(provider: ContractProvider, via: Sender, paused: boolean) {
314
- const messageBody = beginCell()
315
- .storeUint(OpCode.SetPaused, 32)
316
- .storeUint(0, 64)
317
- .storeUint(paused ? 1 : 0, 1)
318
- .endCell();
319
- const result = await provider.internal(via, {
320
- value: '0.01',
321
- body: messageBody
322
- });
323
-
324
- return result;
325
- }
326
-
327
- async sendSetFeelessThreshold(provider: ContractProvider, via: Sender, feelessThreshold: bigint) {
328
- const messageBody = beginCell()
329
- .storeUint(OpCode.SetFeelessThreshold, 32)
330
- .storeUint(0, 64)
331
- .storeCoins(feelessThreshold)
332
- .endCell();
333
- const result = await provider.internal(via, {
334
- value: '0.01',
335
- body: messageBody
336
- });
337
-
338
- return result;
339
- }
340
- }
@@ -1,2 +0,0 @@
1
- export * from './Leaf';
2
- export * from './MerkleTokenDistributor';
@@ -1 +0,0 @@
1
- {"hex":"b5ee9c7241022a01000887000114ff00f4a413f4bcf2c80b01020162050202015804030025bbc01f057f844f842c8cb00f843cf16cb3fc98000dbaf13f057f84280202c918060201480c0702012009080019d8164658000e78b659fe4f6aa40201200b0a0025f76a268698000fc317d2000fc31e99f987c32400276be401c1cb232c072c004b2c1f2fff2743e900c20103a3c00d04f62082300de0b6b3a7640000ba9b30823025b946ebc0b36173e08200c354218235c702bd3a30fc0000be228238070c1cc73b00c80000bbb0f2f420c1008e1282300de0b6b3a76400005202a3f04712a984e020821b782dace9d9aa18bee30f01a7648238056bc75e2d6310000021822056bc75e2d631aa18bee300211716150e02f4822056bc75e2d631aa17be8e2701822056bc75e2d631aa17a101824adf0ab5a80a22c61ab5a7008238056bc75e2d63100000a984de21822056bc75e2d631aa16be8e2601822056bc75e2d631aa16a10182403f1fce3da636ea5cf8508238056bc75e2d63100000a984de21823815af1d78b58c400000bee30021140f02f482380ad78ebc5ac6200000be8e260182380ad78ebc5ac6200000a1018238280e60114edb805d038238056bc75e2d63100000a984de218238056bc75e2d63100000be8e26018238056bc75e2d63100000a10182380ebc5fb417461211108238056bc75e2d63100000a984de218232b5e3af16b1880000bee30021131001ec82315af1d78b58c40000be8e250182315af1d78b58c40000a101823806f5f17757889379378238056bc75e2d63100000a984de218238056bc75e2d6310000021a0511382380ad78ebc5ac6200000a98466a0511382381043561a8829300000a98466a05113823815af1d78b58c400000a98466a051131101ea82381b1ae4d6e2ef500000a98466a0511382382086ac351052600000a98466a05113823825f273933db5700000a98466a05113822056bc75e2d631aa16a98466a05113823830ca024f987b900000a98466a0511382383635c9adc5dea00000a98466a0511382383ba1910bf341b00000a98466a0031200428238410d586a20a4c00000a98412a08238056bc75e2d63100000a984018064a984004a018232b5e3af16b1880000a101823808f00f760a4b2db55d8238056bc75e2d63100000a984004c01823815af1d78b58c400000a101823927fa27722cc06cc5e28238056bc75e2d63100000a984003830822056bc75e2d631aa18a18261855144814a7ff805980ff0084000005020821b782dace9d9aa17be8e18821b782dace9d9aa17a182501425982cf597cd205cef73809171e20042821b782dace9d9aa18a18288195e54c5dd42177f53a27172fa9ec630262827aa2302012024190103aee01a01f62082300de0b6b3a7640000b98e1182300de0b6b3a76400005202a984f03ba3e0702182b05803bcc5cb9634ba4cfb2213f784019318ed4dcb6017880faa35be8e23308288195e54c5dd42177f53a27172fa9ec630262827aa23a904821b782dace9d9aa18de2182708bcc0026baae9e45e470190267a230cfaa18be1b02ea8e1c0182501425982cf597cd205cef7380a90401821b782dace9d9aa17a0dea76401a764208261855144814a7ff805980ff0084000be8e2a8238056bc75e2d631000008261855144814a7ff805980ff0084000a98401822056bc75e2d631aa18a001de20824adf0ab5a80a22c61ab5a700bee30020231c02f882403f1fce3da636ea5cf850be8e268238056bc75e2d6310000082403f1fce3da636ea5cf850a98401822056bc75e2d631aa16a001de20823927fa27722cc06cc5e2be8e268238056bc75e2d63100000823927fa27722cc06cc5e2a98401823815af1d78b58c400000a001de208238280e60114edb805d03bee30020221d02f482380ebc5fb41746121110be8e268238056bc75e2d6310000082380ebc5fb41746121110a984018238056bc75e2d63100000a001de20823808f00f760a4b2db55dbe8e258238056bc75e2d63100000823808f00f760a4b2db55da984018232b5e3af16b1880000a001de20823806f5f1775788937937bee30020211e01ec823806248f33704b286603be8e258238056bc75e2d63100000823806248f33704b286603a984018230ad78ebc5ac620000a001de20823805c548670b9510e7acbe8e258238056bc75e2d63100000823805c548670b9510e7aca98401823056bc75e2d6310000a001de208238056bc75e2d63100000a11f01fe8238056bc75e2d631000005122a012a98453008238056bc75e2d63100000a9845c8238056bc75e2d63100000a9842073a90413a051218238056bc75e2d63100000a9842075a90413a051218238056bc75e2d63100000a9842077a90413a051218238056bc75e2d63100000a9842079a90413a0598238056bc75e2d6310000020001ca984800ba904a0aa00a08064a904004a8238056bc75e2d63100000823806f5f1775788937937a9840182315af1d78b58c40000a001004c8238056bc75e2d631000008238280e60114edb805d03a9840182380ad78ebc5ac6200000a001004e8238056bc75e2d63100000824adf0ab5a80a22c61ab5a700a98401822056bc75e2d631aa17a00102012026250063a46410e0804c45896c678b00d180ef381038c70a023d5486531812d40950025503815210e0002298731819d5016780e4e84001d7d0c8871c02497c0f83434c0c05c6c2497c0f83e900c0074c7f4cfc8a08426871dda6ea38d8d16fc15fe10f1c17ca8f4cff4c03e1104eebcabdc3e10fe113c163000244c383e900c1c20043232c15633c5887e80b2dab260103ec03800a084140f4725eeb8c097c12103fcbc22702fcf057038210042c1d80bef2b0f842c001f268d4d33f30f864885210f90001f900baf26420d739f2aad30701c003f2ab21d765aa00a6025220f9415f03f84401d4308040f40e6fa131f2ad71f843f844f058f842f8448210d0d5f405c8cb1f15cb3f12cc13cb3f12cb0001cf16c9718010c8cb05f843cf1670fa02cb6accc9292800088306fb0000006e3bece9"}
@@ -1 +0,0 @@
1
- {"hex":"b5ee9c7241024d01000d83000114ff00f4a413f4bcf2c80b0102016217020201200c030201200504000db8379f055f84d80201200706000db4983e0abf09d00201200b080201200a09000fad15fc13b7911840000dafd9f82afc25c0000db3aafc157e1120020158140d020158110e020120100f0010abe0f055f846f8470010a8e0f055f059f05a0201201312000cab92f055f849000ca82ff055f8430201201615000db1a7fc157e1320000db0643c157e10a00202c932180201482619020120211a0201201c1b0071d41084d0e3bb4e4658f8a659f89659f9163804a99382c65804bb880e5802c678b7164b8c008646582a801e78b387d010965b56664c0207d804020120201d0201201f1e00d70cbe13be13548c2f238bfe12b00063885c7232e3dc3232c7c073c5f25c60043232c17e12f3c5be127e80b2dab3325c7ec0258c3e13be126838b79c20043232c15400f3c59400fe80b2dab260103ec03e10be10fe113e117e11be11fe123e127e12be12fe133e135542fc15a000173e4020c27232c2b2fff274200029570c8cb00f828cf16cb3fc9f84876c8cb04ccccc980201202522020120242300754c85006fa025240cb0004c001945acf16029132e258cb0001fa0201fa02c85005cf1613cb1fcb1fccc901c904c8cb3f5003cf16cbffccccc9ed54800a75ed44d0d33f01f862fa4001f863d3ff01f864d401d0fa4001f865d31f01f866d31f01f867d430f868d430d0fa0001f869d30001f86af84ac00195fa4001f86b936df86be2d30001f86cfa0001f86dfa0030f86e800276be401c1cb232c072c004b2c1f2fff2743e900c20103a3c02704f62082300de0b6b3a7640000ba9b30823025b946ebc0b36173e08200c354218235c702bd3a30fc0000be228238070c1cc73b00c80000bbb0f2f420c1008e1282300de0b6b3a76400005202a3f04712a984e020821b782dace9d9aa18bee30f01a7648238056bc75e2d6310000021822056bc75e2d631aa18bee3002131302f2802f4822056bc75e2d631aa17be8e2701822056bc75e2d631aa17a101824adf0ab5a80a22c61ab5a7008238056bc75e2d63100000a984de21822056bc75e2d631aa16be8e2601822056bc75e2d631aa16a10182403f1fce3da636ea5cf8508238056bc75e2d63100000a984de21823815af1d78b58c400000bee300212e2902f482380ad78ebc5ac6200000be8e260182380ad78ebc5ac6200000a1018238280e60114edb805d038238056bc75e2d63100000a984de218238056bc75e2d63100000be8e26018238056bc75e2d63100000a10182380ebc5fb417461211108238056bc75e2d63100000a984de218232b5e3af16b1880000bee300212d2a01ec82315af1d78b58c40000be8e250182315af1d78b58c40000a101823806f5f17757889379378238056bc75e2d63100000a984de218238056bc75e2d6310000021a0511382380ad78ebc5ac6200000a98466a0511382381043561a8829300000a98466a05113823815af1d78b58c400000a98466a051132b01ea82381b1ae4d6e2ef500000a98466a0511382382086ac351052600000a98466a05113823825f273933db5700000a98466a05113822056bc75e2d631aa16a98466a05113823830ca024f987b900000a98466a0511382383635c9adc5dea00000a98466a0511382383ba1910bf341b00000a98466a0032c00428238410d586a20a4c00000a98412a08238056bc75e2d63100000a984018064a984004a018232b5e3af16b1880000a101823808f00f760a4b2db55d8238056bc75e2d63100000a984004c01823815af1d78b58c400000a101823927fa27722cc06cc5e28238056bc75e2d63100000a984003830822056bc75e2d631aa18a18261855144814a7ff805980ff0084000005020821b782dace9d9aa17be8e18821b782dace9d9aa17a182501425982cf597cd205cef73809171e20042821b782dace9d9aa18a18288195e54c5dd42177f53a27172fa9ec630262827aa230201203e330103aee03401f62082300de0b6b3a7640000b98e1182300de0b6b3a76400005202a984f03ba3e0702182b05803bcc5cb9634ba4cfb2213f784019318ed4dcb6017880faa35be8e23308288195e54c5dd42177f53a27172fa9ec630262827aa23a904821b782dace9d9aa18de2182708bcc0026baae9e45e470190267a230cfaa18be3502ea8e1c0182501425982cf597cd205cef7380a90401821b782dace9d9aa17a0dea76401a764208261855144814a7ff805980ff0084000be8e2a8238056bc75e2d631000008261855144814a7ff805980ff0084000a98401822056bc75e2d631aa18a001de20824adf0ab5a80a22c61ab5a700bee300203d3602f882403f1fce3da636ea5cf850be8e268238056bc75e2d6310000082403f1fce3da636ea5cf850a98401822056bc75e2d631aa16a001de20823927fa27722cc06cc5e2be8e268238056bc75e2d63100000823927fa27722cc06cc5e2a98401823815af1d78b58c400000a001de208238280e60114edb805d03bee300203c3702f482380ebc5fb41746121110be8e268238056bc75e2d6310000082380ebc5fb41746121110a984018238056bc75e2d63100000a001de20823808f00f760a4b2db55dbe8e258238056bc75e2d63100000823808f00f760a4b2db55da984018232b5e3af16b1880000a001de20823806f5f1775788937937bee300203b3801ec823806248f33704b286603be8e258238056bc75e2d63100000823806248f33704b286603a984018230ad78ebc5ac620000a001de20823805c548670b9510e7acbe8e258238056bc75e2d63100000823805c548670b9510e7aca98401823056bc75e2d6310000a001de208238056bc75e2d63100000a13901fe8238056bc75e2d631000005122a012a98453008238056bc75e2d63100000a9845c8238056bc75e2d63100000a9842073a90413a051218238056bc75e2d63100000a9842075a90413a051218238056bc75e2d63100000a9842077a90413a051218238056bc75e2d63100000a9842079a90413a0598238056bc75e2d631000003a001ca984800ba904a0aa00a08064a904004a8238056bc75e2d63100000823806f5f1775788937937a9840182315af1d78b58c40000a001004c8238056bc75e2d631000008238280e60114edb805d03a9840182380ad78ebc5ac6200000a001004e8238056bc75e2d63100000824adf0ab5a80a22c61ab5a700a98401822056bc75e2d631aa17a001020120403f0063a46410e0804c45896c678b00d180ef381038c70a023d5486531812d40950025503815210e0002298731819d5016780e4e84004f3d0c8871c02497c0f83434c0fe900c005c6c2497c0f80074c7f4cfc8a08411903f076ea38b8d16fc157e10f1c17ca8fe900c0831c03c993e10be113e117e11be11fe123e127e12be12fe133e137e13842f3c15b808a08416003133eeb8c088a08417515a406eb8c088a0841cfb70f4aeb8c088a0843e7196352ea4b4a494102fe8e6b10345f04f055f84ac000f264f8435210c705f84b12c705b1f2a3f842f843f844f845f846f847f848f849f84af84bf84cf84d70f056c88280576974686472617720636f6d706c6574656401cb8f70c8cb1f01cf17c9718010c8cb05f84bcf16f84efa02cb6accc98040fb00e0228210c46600a8bae3022282100c281f96484202feba8e3a345bf055f843c705f2a3fa003020c100f264f842f843f844f845f846f847f848f84af84bf84cf84df84e10bc10ab109a1089107810671056f056e022821010354bedbae30222821011faeb88ba8e2510345f04f055f843c705f2a3f842f843f844f845f846f847f84870206df84cf84df84ef056e022821026d65fa9474302b2ba8e3b345bf055f843c705f2a3d30030f842f843f844f845f846f847f848f849f84af84bf84df84e10bc10ab109a1089107810671056104510341023f056e022821079ce8ce5bae302028210d0d5f405bae3025f04840ff2f046440162f05501d4d33fd300fa403001f2685444405205ed44ed45ed47955b4130f05ced67ed65ed64747fed118aed41edf101f2ff4500e6f84cf2718209312d00f849a0820a625a00a0820afaf080a05240bef2b0d739f2aad30701c003f2abf84401d3ff59baf2acd43052108040f40e6fa1f2adfa40fa00d31f30f823bbf2a6f846f823bbf2a6f823f847bbf2a622f059f05a14c705f2ae820afaf080f84ea014a15220bcf27059f05b0076345bf055f843c705f2a3fa0030f842f843f844f845f846f847f848f849f84af84bf84cf84e10bc10ab109a1089107810671056104510344130f056007a345bf055f843c705f2a3fa403020c700f264f842f843f844f845f846f847f848f84971f84cf84df84e10bc10ab109a108910781067105610451034f0560072345bf055f843c705f2a3d31fd31fd3ff305321bef26420c000f264f842f843f845f848f849f84af84bf84cf84df84e109c108b10791078f05600a46c21f055f8435220c705f2a3fa00305122a1820afaf080f84ea0b9f264c88280576974686472617720636f6d706c6574656401cb8f70c8cb1f01cf17c9718010c8cb055003cf165003fa02cb6accc970fb00004e345bf055f843c705f2a3d33f30f843f844f845f846f847f848f849f84af84bf84cf84df84ef05601d8345bf055f843c705f2a3d31fd430885210f90001f900baf264218210f00aed53ba8e1df842f843f844f845f846f847f849f84af84bf84cf84df84e2c5550f056de018210cdb4d337ba8e1efb04f842f843f844f845f846f847f848f849f84af84bf84cf84df84ef0569130e24c000003a41717"}
@@ -1,48 +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
- ClearClaimFeeAddress = 301656968, // 0x1201208
7
- DeployLeaf = 2334832459, // 0x8b8b8b8b
8
- Withdraw = 1944962002, // 0x73737372
9
- WithdrawTokens = 2709472225, // 0xa1a1a1a1
10
- WithdrawFees = 4190525652, // 0xf9f9f9f4
11
- Claim = 1346182295, // 0x50505057
12
- ProcessClaim = 3503682565, // 0xd0d5f405
13
- SetBaseParams = 3295019176, // 0xc4c4c4c8
14
- SetClaimFee = 203956118, // 0xc2c2c2c6
15
- SetClaimFeeAddress = 271928301, // 0x103103d
16
- SetPaused = 651583401, // 0x27272729
17
- SetFeelessThreshold = 2043579621 // 0x79CE8CE5
18
- }
19
-
20
- export enum CodeType { // CRC32 hash
21
- Leaf = 4027247955, // 0xf0f0f0f3
22
- TokenDistributor = 3451179831 // 0xcececece
23
- }
24
-
25
- export enum ErrorCode {
26
- UnknownOP = 0xffff, // 65535
27
- ExpiredMessage = 0x20, // 32
28
- RepeatedMessage = 0x21, // 33
29
- InvalidSignature = 0x22, // 34
30
- Unauthorized = 0x23, // 35
31
- InvalidMessageParams = 0x24, // 36
32
- UnsupportedOperation = 0x25, // 37
33
- TimeInactive = 0x26, // 38
34
- InvalidProof = 0x27, // 39
35
- LeafUsed = 0x28, // 40
36
- IncorrectFees = 0x29, // 41
37
- IsProofExotic = 0x2a, // 42
38
- TreeExceeded = 0x2b, // 43
39
- InvalidTree = 0x2c, // 44
40
- NotFound = 0x2d, // 45
41
- WrongSender = 0x2e, // 46
42
- InvalidIndex = 0x2f, // 47
43
- NotEnoughTokens = 0x30, // 48
44
- ContractPaused = 0x31 // 49
45
- }
46
-
47
- export const DICT_CELL_BASE64 =
48
- '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,69 +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
-
12
- export function leafConfigToCell(config: LeafConfig): Cell {
13
- const { distributor, index } = config;
14
-
15
- const initState = beginCell().storeBit(false).storeAddress(distributor).storeUint(index, 64).endCell();
16
-
17
- return initState;
18
- }
19
-
20
- export class Leaf implements Contract {
21
- constructor(readonly address: Address, readonly init?: { code: Cell; data: Cell }) {}
22
-
23
- static createFromAddress(address: Address) {
24
- return new Leaf(address);
25
- }
26
-
27
- static createFromConfig(config: LeafConfig, code: Cell, workchain = 0) {
28
- const data = leafConfigToCell(config);
29
- const init = { code, data };
30
- return new Leaf(contractAddress(workchain, init), init);
31
- }
32
-
33
- async getIsUsed(provider: ContractProvider): Promise<boolean> {
34
- const result = await provider.get('get_is_used', []);
35
- const isUsed = result.stack.readNumber();
36
-
37
- return !!isUsed;
38
- }
39
-
40
- async getLeafData(provider: ContractProvider): Promise<LeafConfig> {
41
- const result = await provider.get('get_leaf_data', []);
42
- const cellHash = result.stack.readCell().beginParse();
43
-
44
- const isUsed = cellHash.loadUint(1);
45
- const distributor = cellHash.loadAddress();
46
- const index = cellHash.loadUint(64);
47
-
48
- return {
49
- used: !!isUsed,
50
- index: BigInt(index),
51
- distributor
52
- };
53
- }
54
-
55
- async sendClaim(provider: ContractProvider, via: Sender, proof: Cell, index: bigint, claimFee: bigint) {
56
- const messageBody = beginCell()
57
- .storeUint(OpCode.Claim, 32)
58
- .storeUint(0, 64)
59
- .storeRef(proof)
60
- .storeUint(index, 64)
61
- .endCell();
62
- const result = await provider.internal(via, {
63
- value: MIN_CLAIM_FEE + claimFee,
64
- body: messageBody
65
- });
66
-
67
- return result;
68
- }
69
- }