@sign-global/tokentable 0.4.2-beta.2 → 0.4.2-beta.4

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 (119) hide show
  1. package/dist/cjs/airdrop/common/index.d.ts +1 -1
  2. package/dist/cjs/airdrop/constants/chain-config.d.ts +1 -1
  3. package/dist/cjs/airdrop/constants/chain-config.js +1 -1
  4. package/dist/cjs/airdrop/constants/chain-config.js.map +1 -1
  5. package/dist/esm/airdrop/common/index.d.ts +1 -1
  6. package/dist/esm/airdrop/constants/chain-config.d.ts +1 -1
  7. package/dist/esm/airdrop/constants/chain-config.js +1 -1
  8. package/dist/esm/airdrop/constants/chain-config.js.map +1 -1
  9. package/package.json +2 -9
  10. package/src/airdrop/AirdropClient.ts +0 -307
  11. package/src/airdrop/SignatureAirdropClient.ts +0 -378
  12. package/src/airdrop/common/index.ts +0 -54
  13. package/src/airdrop/common/projectDataForTon.ts +0 -79
  14. package/src/airdrop/constants/chain-config.ts +0 -107
  15. package/src/airdrop/constants/index.ts +0 -9
  16. package/src/airdrop/constants/network.ts +0 -78
  17. package/src/airdrop/contracts/evm/AirdropService.ts +0 -181
  18. package/src/airdrop/contracts/evm/SignatureAirdropService.ts +0 -114
  19. package/src/airdrop/contracts/evm/contracts/AirdropSignatureClient.ts +0 -63
  20. package/src/airdrop/contracts/evm/contracts/AirdropSignatureFeeClient.ts +0 -61
  21. package/src/airdrop/contracts/evm/contracts/AirdropV2Client.ts +0 -37
  22. package/src/airdrop/contracts/evm/contracts/AirdropV3Client.ts +0 -49
  23. package/src/airdrop/contracts/evm/contracts/AirdropV3FeeClient.ts +0 -16
  24. package/src/airdrop/contracts/evm/contracts/AirdropV4Client.ts +0 -36
  25. package/src/airdrop/contracts/evm/contracts/ContractBaseClient.ts +0 -85
  26. package/src/airdrop/contracts/evm/contracts/DeployClient.ts +0 -35
  27. package/src/airdrop/contracts/evm/contracts/FeeCollectorClient.ts +0 -21
  28. package/src/airdrop/contracts/evm/contracts/KycClient.ts +0 -21
  29. package/src/airdrop/contracts/evm/contracts/abis/Airdrop.json +0 -674
  30. package/src/airdrop/contracts/evm/contracts/abis/AirdropV2.json +0 -676
  31. package/src/airdrop/contracts/evm/contracts/abis/AirdropV3.json +0 -740
  32. package/src/airdrop/contracts/evm/contracts/abis/AirdropV3_Fee.json +0 -678
  33. package/src/airdrop/contracts/evm/contracts/abis/CustomFeeNativeAirdropV4.json +0 -701
  34. package/src/airdrop/contracts/evm/contracts/abis/Deployer.json +0 -271
  35. package/src/airdrop/contracts/evm/contracts/abis/ERC721.json +0 -737
  36. package/src/airdrop/contracts/evm/contracts/abis/FeeCollector.json +0 -322
  37. package/src/airdrop/contracts/evm/contracts/abis/FungibleTokenECDSADistributor.json +0 -564
  38. package/src/airdrop/contracts/evm/contracts/abis/FungibleTokenWithFeesECDSADistributor.json +0 -260
  39. package/src/airdrop/contracts/evm/contracts/abis/KycHook.json +0 -312
  40. package/src/airdrop/contracts/index.ts +0 -4
  41. package/src/airdrop/contracts/solana/AirdropSignatureClient.ts +0 -242
  42. package/src/airdrop/contracts/solana/FeeCollectorClient.ts +0 -43
  43. package/src/airdrop/contracts/solana/SignatureAirdropService.ts +0 -51
  44. package/src/airdrop/contracts/solana/SolanaContractClient.ts +0 -126
  45. package/src/airdrop/contracts/solana/fee_collector.json +0 -1063
  46. package/src/airdrop/contracts/solana/fee_collector.ts +0 -1069
  47. package/src/airdrop/contracts/solana/fungible_token_distributor_solana.json +0 -1573
  48. package/src/airdrop/contracts/solana/fungible_token_distributor_solana.ts +0 -1579
  49. package/src/airdrop/contracts/ton/AirdropClientV1.ts +0 -122
  50. package/src/airdrop/contracts/ton/AirdropClientV2.ts +0 -118
  51. package/src/airdrop/contracts/ton/AirdropClientV21.ts +0 -131
  52. package/src/airdrop/contracts/ton/AirdropClientV3.ts +0 -127
  53. package/src/airdrop/contracts/ton/AirdropService.ts +0 -150
  54. package/src/airdrop/contracts/ton/TonContractBaseClient.ts +0 -236
  55. package/src/airdrop/contracts/ton/v1/build/Leaf.compiled.json +0 -1
  56. package/src/airdrop/contracts/ton/v1/build/MerkleTokenDistributor.compiled.json +0 -1
  57. package/src/airdrop/contracts/ton/v1/utils/constants.ts +0 -42
  58. package/src/airdrop/contracts/ton/v1/utils/date.utils.ts +0 -11
  59. package/src/airdrop/contracts/ton/v1/utils/index.ts +0 -3
  60. package/src/airdrop/contracts/ton/v1/utils/ton.utils.ts +0 -84
  61. package/src/airdrop/contracts/ton/v1/wrappers/JettonMinter.ts +0 -81
  62. package/src/airdrop/contracts/ton/v1/wrappers/JettonWallet.ts +0 -73
  63. package/src/airdrop/contracts/ton/v1/wrappers/Leaf.ts +0 -88
  64. package/src/airdrop/contracts/ton/v1/wrappers/MerkleTokenDistributor.ts +0 -317
  65. package/src/airdrop/contracts/ton/v1/wrappers/index.ts +0 -2
  66. package/src/airdrop/contracts/ton/v2/build/Leaf.compiled.json +0 -1
  67. package/src/airdrop/contracts/ton/v2/build/MerkleTokenDistributor.compiled.json +0 -1
  68. package/src/airdrop/contracts/ton/v2/utils/constants.ts +0 -43
  69. package/src/airdrop/contracts/ton/v2/utils/date.utils.ts +0 -11
  70. package/src/airdrop/contracts/ton/v2/utils/index.ts +0 -3
  71. package/src/airdrop/contracts/ton/v2/utils/ton.utils.ts +0 -102
  72. package/src/airdrop/contracts/ton/v2/wrappers/Leaf.ts +0 -69
  73. package/src/airdrop/contracts/ton/v2/wrappers/MerkleTokenDistributor.ts +0 -340
  74. package/src/airdrop/contracts/ton/v2/wrappers/index.ts +0 -2
  75. package/src/airdrop/contracts/ton/v21/build/Leaf.compiled.json +0 -1
  76. package/src/airdrop/contracts/ton/v21/build/MerkleTokenDistributor.compiled.json +0 -1
  77. package/src/airdrop/contracts/ton/v21/utils/constants.ts +0 -48
  78. package/src/airdrop/contracts/ton/v21/utils/date.utils.ts +0 -11
  79. package/src/airdrop/contracts/ton/v21/utils/index.ts +0 -3
  80. package/src/airdrop/contracts/ton/v21/utils/ton.utils.ts +0 -84
  81. package/src/airdrop/contracts/ton/v21/wrappers/Leaf.ts +0 -69
  82. package/src/airdrop/contracts/ton/v21/wrappers/MerkleTokenDistributor.ts +0 -346
  83. package/src/airdrop/contracts/ton/v21/wrappers/index.ts +0 -2
  84. package/src/airdrop/contracts/ton/v3/build/Leaf.compiled.json +0 -1
  85. package/src/airdrop/contracts/ton/v3/build/MerkleTokenDistributor.compiled.json +0 -1
  86. package/src/airdrop/contracts/ton/v3/utils/constants.ts +0 -43
  87. package/src/airdrop/contracts/ton/v3/utils/date.utils.ts +0 -11
  88. package/src/airdrop/contracts/ton/v3/utils/index.ts +0 -3
  89. package/src/airdrop/contracts/ton/v3/utils/ton.utils.ts +0 -84
  90. package/src/airdrop/contracts/ton/v3/wrappers/Leaf.ts +0 -68
  91. package/src/airdrop/contracts/ton/v3/wrappers/MerkleTokenDistributor.ts +0 -316
  92. package/src/airdrop/contracts/ton/v3/wrappers/index.ts +0 -2
  93. package/src/airdrop/index.ts +0 -10
  94. package/src/airdrop/services/index.ts +0 -166
  95. package/src/airdrop/services/wallet-service/ton/WalletService.ts +0 -226
  96. package/src/airdrop/services/wallet-service/ton/index.ts +0 -1
  97. package/src/airdrop/strategies/AirdropStrategyFactory.ts +0 -31
  98. package/src/airdrop/strategies/EvmAirdropStrategy.ts +0 -81
  99. package/src/airdrop/strategies/IAirdropStrategy.ts +0 -26
  100. package/src/airdrop/strategies/StrategyCache.ts +0 -34
  101. package/src/airdrop/strategies/TonAirdropStrategy.ts +0 -77
  102. package/src/airdrop/tests/index.test.ts +0 -387
  103. package/src/airdrop/types/index.ts +0 -200
  104. package/src/index.ts +0 -3
  105. package/src/utils/api-client.ts +0 -69
  106. package/src/utils/index.ts +0 -3
  107. package/src/utils/utils.ts +0 -45
  108. package/src/utils/web3.ts +0 -172
  109. package/src/wallets/WalletBase.ts +0 -92
  110. package/src/wallets/WalletFactory.tsx +0 -35
  111. package/src/wallets/index.ts +0 -3
  112. package/src/wallets/providers/evm/EvmWallet.ts +0 -101
  113. package/src/wallets/providers/evm/index.tsx +0 -56
  114. package/src/wallets/providers/index.ts +0 -4
  115. package/src/wallets/providers/solana/index.tsx +0 -133
  116. package/src/wallets/providers/ton/TonWallet.ts +0 -153
  117. package/src/wallets/providers/ton/index.tsx +0 -41
  118. package/src/wallets/types.ts +0 -45
  119. 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
- }