@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,181 +0,0 @@
1
- import { AirdropV3Client } from './contracts/AirdropV3Client';
2
- import { FeeCollectorClient } from './contracts/FeeCollectorClient';
3
- import { DeployerClient } from './contracts/DeployClient';
4
- import { AirdropV3FeeClient } from './contracts/AirdropV3FeeClient';
5
- import { BigNumber } from 'bignumber.js';
6
- import { AirdropV4Client } from './contracts/AirdropV4Client';
7
- import { encodeAbiParameters } from 'viem';
8
- import { KycClientClient } from './contracts/KycClient';
9
- import { ZERO_ADDRESS } from '../../constants';
10
- import { EvmAirdropVersionEnum as AirdropVersionEnum, ChainId, EvmContractClientOption } from '../../types';
11
-
12
- export class AirdropService {
13
- options: EvmContractClientOption;
14
- constructor(options: EvmContractClientOption) {
15
- this.options = options;
16
- }
17
-
18
- private get airdropV3Client(): AirdropV3Client {
19
- if (!this.options) {
20
- throw new Error('options is empty');
21
- }
22
-
23
- return new AirdropV3Client(this.options);
24
- }
25
-
26
- private get airdropV3FeeClient(): AirdropV3FeeClient {
27
- if (!this.options) {
28
- throw new Error('options is empty');
29
- }
30
-
31
- return new AirdropV3FeeClient(this.options);
32
- }
33
-
34
- private get airdropV4Client(): AirdropV4Client {
35
- if (!this.options) {
36
- throw new Error('options is empty');
37
- }
38
-
39
- return new AirdropV4Client(this.options);
40
- }
41
-
42
- async getDeployerClient(): Promise<DeployerClient> {
43
- const deployer = await this.getDeployer();
44
- return new DeployerClient({
45
- ...this.options,
46
- contractAddress: deployer
47
- });
48
- }
49
-
50
- private getFeeClient(address: string): FeeCollectorClient {
51
- if (!this.options) {
52
- throw new Error('options is empty');
53
- }
54
-
55
- return new FeeCollectorClient({
56
- ...this.options,
57
- chainId: this.options.chainId as ChainId,
58
- contractAddress: address
59
- });
60
- }
61
-
62
- async getKycClient() {
63
- const claimHook = await this.airdropV4Client.getClaimHook();
64
-
65
- return new KycClientClient({
66
- ...this.options,
67
- contractAddress: claimHook
68
- });
69
- }
70
-
71
- async isLeafUsed(leaf: string): Promise<boolean> {
72
- return this.airdropV3Client.isLeafUsed(leaf) as Promise<boolean>;
73
- }
74
-
75
- async batchFetchClaimed(leafs: string[]) {
76
- return this.airdropV3Client.batchFetchClaimed(leafs) as Promise<{ result: boolean; status: string }[]>;
77
- }
78
-
79
- async claim({
80
- proof,
81
- group,
82
- data,
83
- value,
84
- extraData
85
- }: {
86
- proof: string[];
87
- group: string;
88
- data: string;
89
- value?: bigint;
90
- extraData?: {
91
- isLegacy: boolean;
92
- attestationId: bigint;
93
- };
94
- }) {
95
- const version = await this.getVersion();
96
-
97
- if (version === AirdropVersionEnum.V4) {
98
- const encodeData = encodeAbiParameters(
99
- [
100
- {
101
- type: 'tuple',
102
- components: [
103
- {
104
- name: 'isLegacy',
105
- type: 'bool'
106
- },
107
- {
108
- name: 'attestationId',
109
- type: 'uint'
110
- }
111
- ]
112
- }
113
- ],
114
- [extraData!]
115
- );
116
- return this.airdropV4Client.claim({
117
- proof,
118
- group,
119
- data,
120
- value,
121
- extraData: encodeData
122
- });
123
- }
124
- return this.airdropV3Client.claim({
125
- proof,
126
- group,
127
- data,
128
- value
129
- });
130
- }
131
-
132
- async getNFT() {
133
- return this.airdropV3Client.getNFT();
134
- }
135
-
136
- async getVersion() {
137
- return this.airdropV3Client.version();
138
- }
139
-
140
- async getDeployer() {
141
- return this.airdropV3Client.getDeployer();
142
- }
143
-
144
- feeCollectors = async (address: string) => {
145
- const deployerClient = await this.getDeployerClient();
146
- return await deployerClient.feeCollectors(address);
147
- };
148
-
149
- feeTokens = async (address: string) => {
150
- const deployerClient = await this.getDeployerClient();
151
- return await deployerClient.feeTokens(address);
152
- };
153
-
154
- async getFeelessThreshold() {
155
- return this.airdropV3FeeClient.getFeelessThreshold();
156
- }
157
-
158
- async getClaimFee(address: string, amount: bigint): Promise<bigint | undefined> {
159
- const feeCollector = await this.feeCollectors(this.options.contractAddress as string);
160
- if (!feeCollector || feeCollector === ZERO_ADDRESS) {
161
- return undefined;
162
- }
163
- const feeClient = this.getFeeClient(feeCollector as string);
164
- const fee = await feeClient.getFee(address, amount);
165
- const version = await this.getVersion();
166
- if (version === AirdropVersionEnum.V3) {
167
- const threshold = await this.getFeelessThreshold();
168
- if (BigNumber(Number(amount)).gt(BigNumber(Number(threshold)))) {
169
- return fee;
170
- } else {
171
- return undefined;
172
- }
173
- }
174
- return fee;
175
- }
176
-
177
- async getKycThreshold() {
178
- const kycClient = await this.getKycClient();
179
- return kycClient.kycThreshold();
180
- }
181
- }
@@ -1,114 +0,0 @@
1
- import { getAddress } from 'viem';
2
- import { ZERO_ADDRESS } from '../../constants';
3
- import { ChainId, EvmContractClientOption } from '../../types';
4
- import { AirdropSignatureClient } from './contracts/AirdropSignatureClient';
5
- import { DeployerClient } from './contracts/DeployClient';
6
- import { FeeCollectorClient } from './contracts/FeeCollectorClient';
7
- import { AirdropSignatureFeeClient } from './contracts/AirdropSignatureFeeClient';
8
-
9
- export class SignatureAirdropService {
10
- options: EvmContractClientOption;
11
- constructor(options: EvmContractClientOption) {
12
- this.options = options;
13
- }
14
-
15
- private get airdropClient(): AirdropSignatureClient {
16
- if (!this.options) {
17
- throw new Error('options is empty');
18
- }
19
-
20
- return new AirdropSignatureClient(this.options);
21
- }
22
- private get airdropWithFeeClient(): AirdropSignatureFeeClient {
23
- if (!this.options) {
24
- throw new Error('options is empty');
25
- }
26
-
27
- return new AirdropSignatureFeeClient(this.options);
28
- }
29
-
30
- async getDeployerClient(): Promise<DeployerClient> {
31
- const deployer = await this.getDeployer();
32
- return new DeployerClient({
33
- ...this.options,
34
- contractAddress: deployer
35
- });
36
- }
37
-
38
- private getFeeClient(address: string): FeeCollectorClient {
39
- if (!this.options) {
40
- throw new Error('options is empty');
41
- }
42
-
43
- return new FeeCollectorClient({
44
- ...this.options,
45
- chainId: this.options.chainId as ChainId,
46
- contractAddress: address
47
- });
48
- }
49
-
50
- async getDeployer() {
51
- return this.airdropClient.getDeployer();
52
- }
53
-
54
- async getVersion() {
55
- return this.airdropClient.getVersion();
56
- }
57
-
58
- feeCollectors = async (address: string) => {
59
- const deployerClient = await this.getDeployerClient();
60
- return await deployerClient.feeCollectors(address);
61
- };
62
-
63
- feeTokens = async (address: string) => {
64
- const deployerClient = await this.getDeployerClient();
65
- return await deployerClient.feeTokens(address);
66
- };
67
-
68
- async getFeelessThreshold() {
69
- // return this.airdropClient.getFeelessThreshold();
70
- }
71
-
72
- async getClaimFee(address: string, amount: bigint): Promise<bigint | undefined> {
73
- const feeCollector = await this.feeCollectors(this.options.contractAddress as string);
74
- if (!feeCollector || feeCollector === ZERO_ADDRESS) {
75
- return undefined;
76
- }
77
- const feeClient = this.getFeeClient(feeCollector as string);
78
- const fee = (await feeClient.getFee(address, amount)) as bigint;
79
- return fee;
80
- }
81
-
82
- async batchFetchClaimed(userClaimIds: string[]): Promise<boolean[]> {
83
- const res = await this.airdropClient.batchFetchClaimed(userClaimIds);
84
- return res;
85
- }
86
-
87
- async getPaused() {
88
- return this.airdropClient.getPaused();
89
- }
90
-
91
- async claim(
92
- data: {
93
- recipient: string;
94
- claimId: string;
95
- data: string;
96
- signature: string;
97
- fees?: string;
98
- extraData?: string;
99
- }[],
100
- recipient?: string
101
- ) {
102
- const version = await this.getVersion();
103
-
104
- if (version.includes('FungibleTokenWithFeesECDSADistributor')) {
105
- const totalFees = data.map((item) => BigInt(item.fees || '0')).reduce((sum, fee) => sum + fee, BigInt(0));
106
- return this.airdropWithFeeClient.claim(data, totalFees);
107
- }
108
- const defaultRecipient = this.options.walletClient?.account?.address;
109
- const delegateMode = recipient ? getAddress(recipient) !== defaultRecipient : false;
110
- const feeData = (await this.getClaimFee(this.options.contractAddress, 1n)) || 0n;
111
- const value = delegateMode ? feeData * BigInt(data.length) : feeData;
112
- return this.airdropClient.claim(data, value);
113
- }
114
- }
@@ -1,63 +0,0 @@
1
- import { EvmContractClientOption } from '../../../types';
2
- import ABI from './abis/FungibleTokenECDSADistributor.json';
3
- import { ContractBaseClient } from './ContractBaseClient';
4
-
5
- export class AirdropSignatureClient extends ContractBaseClient {
6
- constructor(options: EvmContractClientOption) {
7
- super({
8
- ...options,
9
- abi: ABI
10
- });
11
- }
12
-
13
- async getClaimStatus(userClaimId: string) {
14
- return this.readContract({ functionName: 'getClaimStatus', args: [userClaimId] });
15
- }
16
-
17
- async claim(
18
- data: {
19
- recipient: string;
20
- data: string;
21
- claimId: string;
22
- signature: string;
23
- extraData?: string;
24
- }[],
25
- value?: bigint
26
- ) {
27
- const [recipients = [], userClaimIds = [], datas = [], signatures = [], extraDatas = []] = [
28
- 'recipient',
29
- 'claimId',
30
- 'data',
31
- 'signature',
32
- 'extraData'
33
- ].map((key) => data.map((item) => item[key as keyof (typeof data)[0]] || ''));
34
-
35
- console.log('params', [recipients, userClaimIds, datas, signatures, extraDatas], value);
36
-
37
- return this.writeContract({
38
- functionName: 'claim',
39
- args: [recipients, userClaimIds, datas, signatures, extraDatas],
40
- value: value || 0n
41
- });
42
- }
43
-
44
- async batchFetchClaimed(userClaimIds: string[]) {
45
- const res = (await this.readContract({ functionName: 'getClaimStatus', args: [userClaimIds] })) as boolean[];
46
- return res;
47
- }
48
-
49
- async getDeployer() {
50
- const res = (await this.readContract({ functionName: 'getStorage' })) as any[];
51
- return res?.[3] as string;
52
- }
53
-
54
- async getVersion() {
55
- const res = (await this.readContract({ functionName: 'getStorage' })) as any[];
56
- return res?.[0];
57
- }
58
-
59
- async getPaused() {
60
- const res = (await this.readContract({ functionName: 'getStorage' })) as any[];
61
- return res?.[2] as boolean;
62
- }
63
- }
@@ -1,61 +0,0 @@
1
- import { EvmContractClientOption } from '../../../types';
2
- import ABI from './abis/FungibleTokenWithFeesECDSADistributor.json';
3
- import { ContractBaseClient } from './ContractBaseClient';
4
-
5
- export class AirdropSignatureFeeClient extends ContractBaseClient {
6
- constructor(options: EvmContractClientOption) {
7
- super({
8
- ...options,
9
- abi: ABI
10
- });
11
- }
12
-
13
- async getClaimStatus(userClaimId: string) {
14
- return this.readContract({ functionName: 'getClaimStatus', args: [userClaimId] });
15
- }
16
-
17
- async claim(
18
- data: {
19
- recipient: string;
20
- data: string;
21
- claimId: string;
22
- signature: string;
23
- extraData?: string;
24
- }[],
25
- value?: bigint
26
- ) {
27
- const [recipients = [], userClaimIds = [], datas = [], signatures = [], extraDatas = []] = [
28
- 'recipient',
29
- 'claimId',
30
- 'data',
31
- 'signature',
32
- 'extraData'
33
- ].map((key) => data.map((item) => item[key as keyof (typeof data)[0]] || ''));
34
-
35
- return this.writeContract({
36
- functionName: 'claim',
37
- args: [recipients, userClaimIds, datas, signatures, extraDatas],
38
- value: value || 0n
39
- });
40
- }
41
-
42
- async batchFetchClaimed(userClaimIds: string[]) {
43
- const res = (await this.readContract({ functionName: 'getClaimStatus', args: [userClaimIds] })) as boolean[];
44
- return res;
45
- }
46
-
47
- async getDeployer() {
48
- const res = (await this.readContract({ functionName: 'getStorage' })) as any[];
49
- return res?.[3] as string;
50
- }
51
-
52
- async getVersion() {
53
- const res = (await this.readContract({ functionName: 'getStorage' })) as any[];
54
- return res?.[0];
55
- }
56
-
57
- async getPaused() {
58
- const res = (await this.readContract({ functionName: 'getStorage' })) as any[];
59
- return res?.[2] as boolean;
60
- }
61
- }
@@ -1,37 +0,0 @@
1
- import { EvmContractClientOption } from '../../../types';
2
- import AirdropAbi from './abis/AirdropV2.json';
3
- import { ContractBaseClient } from './ContractBaseClient';
4
-
5
- export class AirdropV2Client extends ContractBaseClient {
6
- constructor(options: EvmContractClientOption) {
7
- super({
8
- ...options,
9
- abi: AirdropAbi
10
- });
11
- }
12
-
13
- async isLeafUsed(leaf: string) {
14
- return this.readContract({ functionName: 'isLeafUsed', args: ['0x' + leaf] });
15
- }
16
-
17
- async claim(proof: string[], group: string, data: string, value?: bigint) {
18
- return this.writeContract({
19
- functionName: 'claim',
20
- args: [proof, group, data],
21
- value: value || 0n
22
- });
23
- }
24
-
25
- async batchFetchClaimed(leafs: string[]) {
26
- return this.multiCall({
27
- contracts: leafs?.map((leaf) => {
28
- return {
29
- address: this.contractAddress,
30
- abi: this.abi,
31
- functionName: 'isLeafUsed',
32
- args: ['0x' + leaf]
33
- };
34
- })
35
- });
36
- }
37
- }
@@ -1,49 +0,0 @@
1
- import { EvmContractClientOption } from '../../../types';
2
- import AirdropAbi from './abis/AirdropV3.json';
3
- import { ContractBaseClient } from './ContractBaseClient';
4
-
5
- export class AirdropV3Client extends ContractBaseClient {
6
- constructor(options: EvmContractClientOption) {
7
- super({
8
- ...options,
9
- abi: options.abi || AirdropAbi
10
- });
11
- }
12
-
13
- async isLeafUsed(leaf: string) {
14
- return this.readContract({ functionName: 'isLeafUsed', args: ['0x' + leaf] });
15
- }
16
-
17
- async claim({ proof, group, data, value }: { proof: string[]; group: string; data: string; value?: bigint }) {
18
- return this.writeContract({
19
- functionName: 'claim',
20
- args: [proof, group, data],
21
- value: value || 0n
22
- });
23
- }
24
-
25
- async batchFetchClaimed(leafs: string[]) {
26
- return this.multiCall({
27
- contracts: leafs?.map((leaf) => {
28
- return {
29
- address: this.contractAddress,
30
- abi: this.abi,
31
- functionName: 'isLeafUsed',
32
- args: ['0x' + leaf]
33
- };
34
- })
35
- });
36
- }
37
-
38
- async getNFT() {
39
- return this.readContract({ functionName: 'getNFT' });
40
- }
41
-
42
- async version() {
43
- return this.readContract({ functionName: 'version' }) as Promise<string>;
44
- }
45
-
46
- async getDeployer() {
47
- return this.readContract({ functionName: 'getDeployer' }) as Promise<string>;
48
- }
49
- }
@@ -1,16 +0,0 @@
1
- import { EvmContractClientOption } from '../../../types';
2
- import AirdropAbi from './abis/AirdropV3_Fee.json';
3
- import { ContractBaseClient } from './ContractBaseClient';
4
-
5
- export class AirdropV3FeeClient extends ContractBaseClient {
6
- constructor(options: EvmContractClientOption) {
7
- super({
8
- ...options,
9
- abi: options.abi || AirdropAbi
10
- });
11
- }
12
-
13
- async getFeelessThreshold() {
14
- return this.readContract({ functionName: 'getFeelessThreshold' });
15
- }
16
- }
@@ -1,36 +0,0 @@
1
- import { EvmContractClientOption } from '../../../types';
2
- import AirdropAbi from './abis/CustomFeeNativeAirdropV4.json';
3
- import { AirdropV3Client } from './AirdropV3Client';
4
-
5
- export class AirdropV4Client extends AirdropV3Client {
6
- constructor(options: EvmContractClientOption) {
7
- super({
8
- ...options,
9
- abi: options.abi || AirdropAbi
10
- });
11
- }
12
-
13
- async claim({
14
- proof,
15
- group,
16
- data,
17
- value,
18
- extraData
19
- }: {
20
- proof: string[];
21
- group: string;
22
- data: string;
23
- value?: bigint;
24
- extraData?: string;
25
- }) {
26
- return this.writeContract({
27
- functionName: 'claim',
28
- args: [proof, group, data, extraData],
29
- value: value || 0n
30
- });
31
- }
32
-
33
- async getClaimHook() {
34
- return this.readContract({ functionName: 'getClaimHook' }) as Promise<string>;
35
- }
36
- }
@@ -1,85 +0,0 @@
1
- import {
2
- Chain,
3
- createPublicClient,
4
- http,
5
- PublicClient,
6
- WalletClient,
7
- createWalletClient,
8
- MulticallParameters
9
- } from 'viem';
10
- import { getChainById, getChainRpc } from '../../../common';
11
- import { ChainId } from '../../../types';
12
-
13
- export class ContractBaseClient {
14
- contractAddress: string;
15
- chainId: ChainId;
16
- connector?: WalletClient;
17
- abi: any;
18
- chain: Chain;
19
- chainRpc: string;
20
-
21
- constructor({
22
- contractAddress,
23
- chainId,
24
- walletClient,
25
- abi
26
- }: {
27
- contractAddress: string;
28
- chainId: ChainId;
29
- walletClient?: WalletClient;
30
- abi: any;
31
- }) {
32
- this.contractAddress = contractAddress;
33
- this.chainId = chainId;
34
- this.connector = walletClient;
35
- this.abi = abi;
36
- this.chain = getChainById(chainId) as any;
37
- this.chainRpc = getChainRpc(chainId);
38
- }
39
-
40
- protected get publicClient(): PublicClient {
41
- return createPublicClient({
42
- chain: this.chain,
43
- transport: http(this.chainRpc)
44
- }) as any;
45
- }
46
-
47
- protected get walletClient(): WalletClient {
48
- return (
49
- this.connector ||
50
- createWalletClient({
51
- chain: this.chain,
52
- transport: http(this.chainRpc)
53
- })
54
- );
55
- }
56
-
57
- async readContract({ functionName, args }: { functionName: string; args?: any }) {
58
- const result = await this.publicClient.readContract({
59
- abi: this.abi,
60
- address: this.contractAddress as `0x${string}`,
61
- functionName: functionName,
62
- args: args
63
- });
64
-
65
- return result;
66
- }
67
-
68
- async writeContract({ functionName, args, value }: { functionName: string; args?: any; value?: bigint }) {
69
- const { request } = await this.publicClient.simulateContract({
70
- abi: this.abi,
71
- address: this.contractAddress as `0x${string}`,
72
- functionName: functionName,
73
- args: args,
74
- account: this.walletClient?.account,
75
- value: value
76
- });
77
- const result = await this.walletClient.writeContract(request);
78
-
79
- return result;
80
- }
81
-
82
- async multiCall(parameters: MulticallParameters<any[], boolean>) {
83
- return await this.publicClient.multicall(parameters);
84
- }
85
- }
@@ -1,35 +0,0 @@
1
- import { EvmContractClientOption } from '../../../types';
2
- import TTUDeployerContractABI from './abis/Deployer.json';
3
- import { ContractBaseClient } from './ContractBaseClient';
4
-
5
- export class DeployerClient extends ContractBaseClient {
6
- constructor(options: EvmContractClientOption) {
7
- const address = options.contractAddress;
8
-
9
- if (!address) {
10
- throw new Error(`TTDeployerContract address not found on chain ${options.chainId}`);
11
- }
12
- super({
13
- abi: TTUDeployerContractABI.abi,
14
- contractAddress: address,
15
- chainId: options.chainId,
16
- walletClient: options.walletClient
17
- });
18
- }
19
-
20
- async feeCollectors(address: string) {
21
- const result = await this.readContract({
22
- functionName: 'feeCollectors',
23
- args: [address]
24
- });
25
- return result;
26
- }
27
-
28
- async feeTokens(address: string) {
29
- const result = await this.readContract({
30
- functionName: 'feeTokens',
31
- args: [address]
32
- });
33
- return result;
34
- }
35
- }
@@ -1,21 +0,0 @@
1
- import { EvmContractClientOption } from '../../../types';
2
- import FeeCollectorABI from './abis/FeeCollector.json';
3
- import { ContractBaseClient } from './ContractBaseClient';
4
-
5
- export class FeeCollectorClient extends ContractBaseClient {
6
- constructor(options: EvmContractClientOption) {
7
- const address = options.contractAddress;
8
- if (!address) {
9
- throw new Error(`FeeCollectorService address not found on chain ${options.chainId}`);
10
- }
11
- super({
12
- ...options,
13
- contractAddress: address,
14
- abi: FeeCollectorABI
15
- });
16
- }
17
-
18
- async getFee(address: string, tokenTransferred: bigint): Promise<bigint> {
19
- return (await this.readContract({ functionName: 'getFee', args: [address, tokenTransferred] })) as bigint;
20
- }
21
- }