@sign-global/tokentable 0.2.1 → 0.4.0-beta.1

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 (142) hide show
  1. package/.github/workflows/beta.yml +28 -0
  2. package/dist/cjs/airdrop/AirdropClient.d.ts +46 -0
  3. package/dist/cjs/airdrop/AirdropClient.js +244 -0
  4. package/dist/cjs/airdrop/AirdropClient.js.map +1 -0
  5. package/dist/cjs/airdrop/SignatureAirdropClient.d.ts +26 -0
  6. package/dist/cjs/airdrop/SignatureAirdropClient.js +109 -0
  7. package/dist/cjs/airdrop/SignatureAirdropClient.js.map +1 -0
  8. package/dist/cjs/airdrop/common/index.d.ts +1 -1
  9. package/dist/cjs/airdrop/constants/chain-config.js +1 -1
  10. package/dist/cjs/airdrop/constants/index.d.ts +4 -0
  11. package/dist/cjs/airdrop/constants/index.js +5 -1
  12. package/dist/cjs/airdrop/constants/index.js.map +1 -1
  13. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/WalletBase.d.ts +32 -0
  14. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/WalletBase.js +71 -0
  15. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/WalletBase.js.map +1 -0
  16. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/WalletFactory.d.ts +8 -0
  17. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/WalletFactory.js +38 -0
  18. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/WalletFactory.js.map +1 -0
  19. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/index.d.ts +2 -0
  20. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/index.js +21 -0
  21. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/index.js.map +1 -0
  22. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.d.ts +26 -0
  23. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.js +70 -0
  24. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.js.map +1 -0
  25. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/index.d.ts +9 -0
  26. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/index.js +35 -0
  27. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/index.js.map +1 -0
  28. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/index.d.ts +3 -0
  29. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/index.js +14 -0
  30. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/index.js.map +1 -0
  31. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/solana/index.d.ts +27 -0
  32. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/solana/index.js +119 -0
  33. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/solana/index.js.map +1 -0
  34. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.d.ts +23 -0
  35. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.js +117 -0
  36. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.js.map +1 -0
  37. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/ton/index.d.ts +9 -0
  38. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/ton/index.js +29 -0
  39. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/ton/index.js.map +1 -0
  40. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/types.d.ts +38 -0
  41. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/types.js +30 -0
  42. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/types.js.map +1 -0
  43. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/utils/index.d.ts +8 -0
  44. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/utils/index.js +41 -0
  45. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/utils/index.js.map +1 -0
  46. package/dist/cjs/airdrop/index.d.ts +4 -46
  47. package/dist/cjs/airdrop/index.js +22 -244
  48. package/dist/cjs/airdrop/index.js.map +1 -1
  49. package/dist/cjs/airdrop/services/index.d.ts +15 -0
  50. package/dist/cjs/airdrop/services/index.js +16 -1
  51. package/dist/cjs/airdrop/services/index.js.map +1 -1
  52. package/dist/cjs/airdrop/types/index.d.ts +18 -6
  53. package/dist/cjs/airdrop/types/index.js +7 -1
  54. package/dist/cjs/airdrop/types/index.js.map +1 -1
  55. package/dist/cjs/index.d.ts +1 -1
  56. package/dist/cjs/index.js +7 -1
  57. package/dist/cjs/index.js.map +1 -1
  58. package/dist/cjs/utils/utils.d.ts +1 -0
  59. package/dist/cjs/utils/utils.js +2 -1
  60. package/dist/cjs/utils/utils.js.map +1 -1
  61. package/dist/esm/airdrop/AirdropClient.d.ts +46 -0
  62. package/dist/esm/airdrop/AirdropClient.js +240 -0
  63. package/dist/esm/airdrop/AirdropClient.js.map +1 -0
  64. package/dist/esm/airdrop/SignatureAirdropClient.d.ts +26 -0
  65. package/dist/esm/airdrop/SignatureAirdropClient.js +105 -0
  66. package/dist/esm/airdrop/SignatureAirdropClient.js.map +1 -0
  67. package/dist/esm/airdrop/common/index.d.ts +1 -1
  68. package/dist/esm/airdrop/constants/chain-config.js +1 -1
  69. package/dist/esm/airdrop/constants/index.d.ts +4 -0
  70. package/dist/esm/airdrop/constants/index.js +4 -0
  71. package/dist/esm/airdrop/constants/index.js.map +1 -1
  72. package/dist/esm/airdrop/core/useWeb3ConnectWallet/WalletBase.d.ts +32 -0
  73. package/dist/esm/airdrop/core/useWeb3ConnectWallet/WalletBase.js +67 -0
  74. package/dist/esm/airdrop/core/useWeb3ConnectWallet/WalletBase.js.map +1 -0
  75. package/dist/esm/airdrop/core/useWeb3ConnectWallet/WalletFactory.d.ts +8 -0
  76. package/dist/esm/airdrop/core/useWeb3ConnectWallet/WalletFactory.js +34 -0
  77. package/dist/esm/airdrop/core/useWeb3ConnectWallet/WalletFactory.js.map +1 -0
  78. package/dist/esm/airdrop/core/useWeb3ConnectWallet/index.d.ts +2 -0
  79. package/dist/esm/airdrop/core/useWeb3ConnectWallet/index.js +3 -0
  80. package/dist/esm/airdrop/core/useWeb3ConnectWallet/index.js.map +1 -0
  81. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.d.ts +26 -0
  82. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.js +65 -0
  83. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.js.map +1 -0
  84. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/index.d.ts +9 -0
  85. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/index.js +29 -0
  86. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/index.js.map +1 -0
  87. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/index.d.ts +3 -0
  88. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/index.js +5 -0
  89. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/index.js.map +1 -0
  90. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/solana/index.d.ts +27 -0
  91. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/solana/index.js +109 -0
  92. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/solana/index.js.map +1 -0
  93. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.d.ts +23 -0
  94. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.js +112 -0
  95. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.js.map +1 -0
  96. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/ton/index.d.ts +9 -0
  97. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/ton/index.js +24 -0
  98. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/ton/index.js.map +1 -0
  99. package/dist/esm/airdrop/core/useWeb3ConnectWallet/types.d.ts +38 -0
  100. package/dist/esm/airdrop/core/useWeb3ConnectWallet/types.js +27 -0
  101. package/dist/esm/airdrop/core/useWeb3ConnectWallet/types.js.map +1 -0
  102. package/dist/esm/airdrop/core/useWeb3ConnectWallet/utils/index.d.ts +8 -0
  103. package/dist/esm/airdrop/core/useWeb3ConnectWallet/utils/index.js +35 -0
  104. package/dist/esm/airdrop/core/useWeb3ConnectWallet/utils/index.js.map +1 -0
  105. package/dist/esm/airdrop/index.d.ts +4 -46
  106. package/dist/esm/airdrop/index.js +4 -242
  107. package/dist/esm/airdrop/index.js.map +1 -1
  108. package/dist/esm/airdrop/services/index.d.ts +15 -0
  109. package/dist/esm/airdrop/services/index.js +12 -0
  110. package/dist/esm/airdrop/services/index.js.map +1 -1
  111. package/dist/esm/airdrop/types/index.d.ts +18 -6
  112. package/dist/esm/airdrop/types/index.js +6 -0
  113. package/dist/esm/airdrop/types/index.js.map +1 -1
  114. package/dist/esm/index.d.ts +1 -1
  115. package/dist/esm/index.js +1 -1
  116. package/dist/esm/index.js.map +1 -1
  117. package/dist/esm/utils/utils.d.ts +1 -0
  118. package/dist/esm/utils/utils.js +1 -0
  119. package/dist/esm/utils/utils.js.map +1 -1
  120. package/package.json +15 -3
  121. package/src/airdrop/AirdropClient.ts +301 -0
  122. package/src/airdrop/SignatureAirdropClient.ts +120 -0
  123. package/src/airdrop/constants/chain-config.ts +1 -1
  124. package/src/airdrop/constants/index.ts +5 -0
  125. package/src/airdrop/core/useWeb3ConnectWallet/WalletBase.ts +92 -0
  126. package/src/airdrop/core/useWeb3ConnectWallet/WalletFactory.tsx +35 -0
  127. package/src/airdrop/core/useWeb3ConnectWallet/index.ts +3 -0
  128. package/src/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.ts +90 -0
  129. package/src/airdrop/core/useWeb3ConnectWallet/providers/evm/index.tsx +43 -0
  130. package/src/airdrop/core/useWeb3ConnectWallet/providers/index.ts +4 -0
  131. package/src/airdrop/core/useWeb3ConnectWallet/providers/solana/index.tsx +141 -0
  132. package/src/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.ts +149 -0
  133. package/src/airdrop/core/useWeb3ConnectWallet/providers/ton/index.tsx +41 -0
  134. package/src/airdrop/core/useWeb3ConnectWallet/types.ts +45 -0
  135. package/src/airdrop/core/useWeb3ConnectWallet/utils/index.ts +61 -0
  136. package/src/airdrop/index.ts +4 -309
  137. package/src/airdrop/services/index.ts +29 -1
  138. package/src/airdrop/tests/index.test.ts +5 -8
  139. package/src/airdrop/types/index.ts +22 -6
  140. package/src/index.ts +9 -1
  141. package/src/utils/utils.ts +2 -0
  142. package/tsconfig.json +2 -2
@@ -1,310 +1,5 @@
1
- import { TonClient } from '@ton/ton';
2
- import { getAirdropPro, getAirdropProject, getAirdropQuery, getAirdropContractConfig, getAirdropProjectId } from './services';
3
- import {
4
- ChainType,
5
- ETokenType,
6
- EvmAirdropVersionEnum,
7
- IAirdropClaim,
8
- IAirdropOptions,
9
- IContractConfig,
10
- IProject,
11
- IWalletClient
12
- } from './types';
13
- import { getTonProjectIdByAddress } from './common';
14
- import { AirdropStrategyFactory } from './strategies/AirdropStrategyFactory';
15
- import { IAirdropStrategy } from './strategies/IAirdropStrategy';
16
- import { strategyCache } from './strategies/StrategyCache';
1
+ export { AirdropClient } from './AirdropClient';
2
+ export { SignatureAirdropClient } from './SignatureAirdropClient';
17
3
 
18
- export class AirdropClient {
19
- private tonClient?: TonClient;
20
- private slug?: string;
21
- private projectId?: string;
22
- private endpoint?: string;
23
- private project: IProject | undefined;
24
- protected claims?: IAirdropClaim[];
25
- private projectPromise: Promise<void> | undefined;
26
- private claimHook: ((v: any) => any) | undefined;
27
- private contractConfig: IContractConfig | null = null;
28
-
29
- constructor(params: IAirdropOptions) {
30
- if ('slug' in params) {
31
- this.slug = params.slug;
32
- }
33
- this.projectId = params.projectId;
34
- this.endpoint = params.endpoint;
35
- this.projectPromise = this.initializeProjects();
36
- }
37
-
38
- setTonClient(tonClient: TonClient) {
39
- this.tonClient = tonClient;
40
- }
41
-
42
- private getTonClient(): TonClient | undefined {
43
- if (!this.tonClient) {
44
- return undefined;
45
- }
46
- return this.tonClient;
47
- }
48
-
49
-
50
- // move
51
- private async fetchProjectFromSlug(address: string): Promise<string | undefined> {
52
- if (!this.slug) return undefined;
53
-
54
- const res = await getAirdropProjectId({ recipient: address, slug: this.slug }, this.endpoint);
55
-
56
- if(!res.projectIds?.length) return undefined;
57
- return res?.projectIds?.[0];
58
- // const projectMap = res?.childProjectMapping || {};
59
-
60
- // return getTonProjectIdByAddress({
61
- // address,
62
- // slug: this.slug,
63
- // data: projectMap
64
- // });
65
- }
66
-
67
- private async fetchProjectDetails(projectId: string): Promise<void> {
68
- this.project = await getAirdropProject(projectId, this.endpoint);
69
- }
70
-
71
- protected async initializeProjects(address?: string) {
72
- try {
73
- let projectId = this.projectId;
74
-
75
- // If slug is provided, try to fetch project ID from slug
76
- if (!projectId && address) {
77
- projectId = await this.fetchProjectFromSlug(address);
78
- }
79
-
80
- if (!projectId) {
81
- return;
82
- }
83
-
84
- // Fetch project details
85
- await this.fetchProjectDetails(projectId);
86
- } catch (error: any) {
87
- throw new Error(`Failed to initialize project: ${error.message}`);
88
- }
89
- }
90
-
91
- async getProjectInfo() {
92
- await this.projectPromise;
93
- if (!this.project) throw new Error('Project not found');
94
- return this.project;
95
- }
96
-
97
- async getAirdropClaims(data: { address: string }) {
98
- if (this.slug) {
99
- await this.initializeProjects(data.address); // 根据地址
100
- }
101
- const project = await this.getProjectInfo();
102
-
103
- const res = await getAirdropQuery(
104
- {
105
- recipient: data.address,
106
- projectId: project!.id,
107
- recipientType: project!.recipientType
108
- },
109
- this.endpoint
110
- );
111
- const claimsRes = res.claims?.map((it) => ({
112
- ...it,
113
- project: project!,
114
- claimId: project!.chainType === ChainType.Evm ? `${project!.id}:${it.leaf}` : `${project!.id}:${it.index}`
115
- }));
116
- this.claims = claimsRes;
117
- return this.claims;
118
- }
119
-
120
- public async getStrategy(walletClient?: IWalletClient): Promise<IAirdropStrategy> {
121
- const project = await this.getProjectInfo();
122
- const version = this.contractConfig?.version || undefined;
123
-
124
- const hasWallet = !!walletClient;
125
-
126
- // Try to get cached strategy
127
- let strategy = strategyCache.getStrategy(
128
- project.contractAddress,
129
- project.chainId,
130
- project.chainType,
131
- hasWallet
132
- );
133
-
134
- if (!strategy) {
135
- // Create new strategy if not cached
136
- strategy = AirdropStrategyFactory.createStrategy({
137
- chainType: project.chainType,
138
- contractAddress: project.contractAddress,
139
- chainId: project.chainId,
140
- walletClient,
141
- tonClient: this.getTonClient(),
142
- version
143
- });
144
-
145
- // Initialize the strategy
146
- await strategy.initialize(walletClient);
147
-
148
- // Cache the initialized strategy
149
- strategyCache.setStrategy(
150
- project.contractAddress,
151
- project.chainId,
152
- project.chainType,
153
- strategy,
154
- hasWallet
155
- );
156
- } else if (hasWallet) {
157
- // If we have a wallet and the strategy exists, just initialize with the new wallet
158
- await strategy.initialize(walletClient);
159
- }
160
-
161
- return strategy;
162
- }
163
-
164
- private getClaimDataById(claimId: string) {
165
- const claimData = this.claims?.find((it) => it.claimId === claimId);
166
- if (!claimData) throw new Error('Claim data not found');
167
- return claimData;
168
- }
169
-
170
- setClaimHook(fn: (v: any) => any) {
171
- this.claimHook = fn;
172
- }
173
-
174
- private getDefaultExtraData() {
175
- return {
176
- isLegacy: true,
177
- attestationId: BigInt(1)
178
- };
179
- }
180
-
181
- private async calculateClaimFee(project: IProject, claimAmount: string): Promise<string | bigint | undefined> {
182
- if (project.chainType === ChainType.Evm) {
183
- const version = await this.getVersion();
184
- const isNativeFreeVersion =
185
- project.tokenType === ETokenType.Native &&
186
- [EvmAirdropVersionEnum.V3, EvmAirdropVersionEnum.V4].includes(version as EvmAirdropVersionEnum);
187
- return isNativeFreeVersion ? undefined : await this.getClaimFee(BigInt(claimAmount));
188
- }
189
-
190
- if(project.chainType === ChainType.Ton) {
191
- return await this.getClaimFee(BigInt(claimAmount));
192
- }
193
-
194
- return undefined;
195
- }
196
-
197
- async claimAirdrop(
198
- { claimId, walletClient }: { claimId: string; walletClient: IWalletClient },
199
- options?: { onLoading?: () => void }
200
- ) {
201
- // Get claim data and initialize strategy
202
- const claimData = this.getClaimDataById(claimId);
203
- const strategy = await this.getStrategy(walletClient);
204
- const project = await this.getProjectInfo();
205
-
206
- // Process extra data
207
- const extraData = project.chainType === ChainType.Ton
208
- ? undefined
209
- : this.claimHook
210
- ? this.claimHook(claimData)
211
- : this.getDefaultExtraData();
212
-
213
- // Calculate claim value based on project type
214
- const value = await this.calculateClaimFee(project, claimData.amount);
215
-
216
- // Execute claim with processed data
217
- return strategy.claim({
218
- ...claimData,
219
- extraData,
220
- value
221
- }, options);
222
- }
223
-
224
- async checkClaimed(claimId: string): Promise<boolean> {
225
- const claimData = this.getClaimDataById(claimId);
226
- const strategy = await this.getStrategy();
227
- return strategy.checkClaimed(claimData);
228
- }
229
-
230
- private async getContractConfig(): Promise<IContractConfig | null> {
231
- try {
232
- const project = await this.getProjectInfo();
233
-
234
- if (!this.contractConfig) {
235
- this.contractConfig = await getAirdropContractConfig({
236
- chainId: project.chainId,
237
- chainType: project.chainType,
238
- contractAddress: project.contractAddress
239
- }, this.endpoint);
240
- }
241
- return this.contractConfig;
242
- } catch (error) {
243
- console.error('Error fetching contract config:', error);
244
- return null;
245
- }
246
- }
247
-
248
- async getVersion(): Promise<string> {
249
- const config = await this.getContractConfig();
250
- if (config?.version) {
251
- return config.version;
252
- }
253
-
254
- const strategy = await this.getStrategy();
255
- return strategy.getVersion();
256
- }
257
-
258
- async getPaused(): Promise<boolean> {
259
- const config = await this.getContractConfig();
260
- if (config && config?.paused !== null) {
261
- return config.paused;
262
- }
263
-
264
- const strategy = await this.getStrategy();
265
- if (!strategy.getPaused) {
266
- throw new Error('getPaused is not supported for this chain');
267
- }
268
- return strategy.getPaused();
269
- }
270
-
271
- async getClaimFee(amount?: bigint): Promise<string | bigint> {
272
- const config = await this.getContractConfig();
273
- if (config?.claimFee) {
274
- return config.claimFee;
275
- }
276
-
277
- const strategy = await this.getStrategy();
278
- if (!strategy.getClaimFee) {
279
- throw new Error('getClaimFee is not supported for this chain');
280
- }
281
- return strategy.getClaimFee(this.project?.contractAddress || '', amount || BigInt(0));
282
- }
283
-
284
- // params claimId[]
285
- async batchCheckClaimed(): Promise<{ result: boolean; status: string }[]> {
286
- const strategy = await this.getStrategy();
287
- if (!strategy.batchCheckClaimed) {
288
- throw new Error('batchCheckClaimed is not supported for this chain');
289
- }
290
- const leafs = this.claims?.map((it) => it.leaf);
291
- if (!leafs) return [];
292
- return strategy.batchCheckClaimed(leafs);
293
- }
294
-
295
- async getNFT(): Promise<string> {
296
- const strategy = await this.getStrategy();
297
- if (!strategy.getNFT) {
298
- throw new Error('getNFT is not supported for this chain');
299
- }
300
- return strategy.getNFT();
301
- }
302
-
303
- async getKycThreshold(): Promise<bigint> {
304
- const strategy = await this.getStrategy();
305
- if (!strategy.getKycThreshold) {
306
- throw new Error('getKycThreshold is not supported for this chain');
307
- }
308
- return strategy.getKycThreshold();
309
- }
310
- }
4
+ export { CONST } from './constants';
5
+ export * from './core/useWeb3ConnectWallet';
@@ -54,7 +54,10 @@ export const getAirdropQuery = async (
54
54
  return client.post(`/airdrop-open/query`, data);
55
55
  };
56
56
 
57
- export const getAirdropContractConfig = async (data: { chainId: string; chainType: string; contractAddress: string }, baseURL?: string): Promise<IContractConfig> => {
57
+ export const getAirdropContractConfig = async (
58
+ data: { chainId: string; chainType: string; contractAddress: string },
59
+ baseURL?: string
60
+ ): Promise<IContractConfig> => {
58
61
  const client = createApiClient(baseURL);
59
62
  return client.post(`/airdrop-open/contract/config`, data);
60
63
  };
@@ -66,3 +69,28 @@ export const getJettonInfo = async (
66
69
  const client = createApiClient(baseURL);
67
70
  return client.get(`/airdrop-open/jetton/${data.address}?isTestnet=${data.isTestnet}`);
68
71
  };
72
+
73
+ export const connectTwitter = async (data: { code: string; redirectUri: string }, baseURL?: string) => {
74
+ const client = createApiClient(baseURL);
75
+ return client.post('/airdrop-open/connect-twitter', data);
76
+ };
77
+
78
+ export const checkEligibility = async (data: { projectId: string }, baseURL?: string) => {
79
+ const client = createApiClient(baseURL);
80
+ return client.post('/airdrop-open/check-eligibility', data);
81
+ };
82
+
83
+ export const bindWallet = async (
84
+ data: {
85
+ projectId: string;
86
+ key: string;
87
+ signature: string;
88
+ message: string;
89
+ timestamp: number;
90
+ recipientType: string;
91
+ },
92
+ baseURL?: string
93
+ ) => {
94
+ const client = createApiClient(baseURL);
95
+ return client.post('/airdrop-open/connect-wallet', data);
96
+ };
@@ -22,18 +22,15 @@ describe('AirdropClient', () => {
22
22
 
23
23
  const projectInfo = await client.getProjectInfo();
24
24
  expect(projectInfo).toBeDefined();
25
- });
25
+ }, 6000);
26
26
 
27
27
  it('should use slug correctly', async () => {
28
28
  client = new AirdropClient({
29
- slug: 'move',
30
- });
31
- const claims = await client.getAirdropClaims({ address: '0xEa53D21c05ebc87865558a2F8769074DA3bE3821' });
29
+ slug: 'wat',
30
+ });
31
+
32
32
  const projectInfo = await client.getProjectInfo();
33
- console.log(projectInfo);
34
- console.log(claims);
35
- expect(projectInfo).toBeDefined();
36
- expect(claims.length).toBeTruthy();
33
+ expect(projectInfo).toBeTruthy();
37
34
  });
38
35
  });
39
36
 
@@ -61,10 +61,27 @@ export interface IProject {
61
61
  blockCountries: Record<string, string>;
62
62
  themeConf: ThemeConfig | null;
63
63
  version: string;
64
- extra?: {
65
- kyc: boolean;
66
- tag: string;
67
- };
64
+ extra?: IProjectExtra;
65
+ identities: Identity[];
66
+ }
67
+
68
+ export interface Identity {
69
+ identityType: string;
70
+ authorizeUrl?: string;
71
+ }
72
+
73
+ export enum AirdropSigIdentityTypeEnum {
74
+ Twitter = 'X Account',
75
+ SolanaWallet = 'Solana Wallet',
76
+ EVMWallet = 'EVM Wallet'
77
+ }
78
+
79
+ export interface IProjectExtra {
80
+ kyc: boolean;
81
+ tag: string;
82
+ seed: number;
83
+ signer: string;
84
+ identities: string[];
68
85
  }
69
86
 
70
87
  export enum ETokenType {
@@ -119,7 +136,6 @@ export type IAirdropService = TonAirdropService | EvmAirdropService;
119
136
 
120
137
  type BaseAirdropOptions = {
121
138
  endpoint?: string;
122
- tonClient?: TonClient;
123
139
  };
124
140
 
125
141
  type ProjectIdOptions = BaseAirdropOptions & {
@@ -138,4 +154,4 @@ export interface IContractConfig {
138
154
  version?: string | null;
139
155
  paused: boolean | null;
140
156
  claimFee?: string | null;
141
- }
157
+ }
package/src/index.ts CHANGED
@@ -1,2 +1,10 @@
1
- export { AirdropClient } from './airdrop';
1
+ export {
2
+ AirdropClient,
3
+ SignatureAirdropClient,
4
+ CONST,
5
+ WalletFactory,
6
+ EvmProvider,
7
+ SolanaProvider,
8
+ TonProvider
9
+ } from './airdrop';
2
10
  export * from './airdrop/types';
@@ -28,3 +28,5 @@ export async function retry<T>(fn: () => Promise<T>, options: { retries: number;
28
28
  }
29
29
  throw lastError;
30
30
  }
31
+
32
+ export const isLocal = window.location.href.includes('localhost');
package/tsconfig.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  // Enable latest features
4
- "lib": ["ESNext"],
4
+ "lib": ["ESNext", "DOM", "DOM.Iterable"],
5
5
  "target": "ESNext",
6
6
  "module": "ESNext",
7
7
 
@@ -14,7 +14,7 @@
14
14
  "moduleResolution": "node",
15
15
  "esModuleInterop": true,
16
16
  "resolveJsonModule": true,
17
-
17
+ "jsx": "react-jsx",
18
18
  // Best practices
19
19
  "strict": true,
20
20
  "skipLibCheck": true,