@sign-global/tokentable 0.4.0-beta.9 → 0.4.0

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 (84) hide show
  1. package/dist/cjs/airdrop/AirdropClient.js +2 -9
  2. package/dist/cjs/airdrop/AirdropClient.js.map +1 -1
  3. package/dist/cjs/airdrop/SignatureAirdropClient.d.ts +6 -21
  4. package/dist/cjs/airdrop/SignatureAirdropClient.js +22 -103
  5. package/dist/cjs/airdrop/SignatureAirdropClient.js.map +1 -1
  6. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.d.ts +1 -1
  7. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.js +3 -6
  8. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.js.map +1 -1
  9. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/index.d.ts +1 -2
  10. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/index.js +4 -6
  11. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/index.js.map +1 -1
  12. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/solana/index.d.ts +1 -1
  13. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/solana/index.js +3 -6
  14. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/solana/index.js.map +1 -1
  15. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.d.ts +1 -1
  16. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.js +9 -10
  17. package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.js.map +1 -1
  18. package/dist/cjs/airdrop/services/index.d.ts +8 -25
  19. package/dist/cjs/airdrop/services/index.js +5 -34
  20. package/dist/cjs/airdrop/services/index.js.map +1 -1
  21. package/dist/cjs/airdrop/types/index.d.ts +0 -27
  22. package/dist/cjs/airdrop/types/index.js.map +1 -1
  23. package/dist/cjs/index.d.ts +1 -1
  24. package/dist/cjs/index.js +1 -7
  25. package/dist/cjs/index.js.map +1 -1
  26. package/dist/cjs/utils/api-client.d.ts +0 -1
  27. package/dist/cjs/utils/api-client.js +2 -2
  28. package/dist/cjs/utils/api-client.js.map +1 -1
  29. package/dist/esm/airdrop/AirdropClient.js +2 -9
  30. package/dist/esm/airdrop/AirdropClient.js.map +1 -1
  31. package/dist/esm/airdrop/SignatureAirdropClient.d.ts +6 -21
  32. package/dist/esm/airdrop/SignatureAirdropClient.js +23 -104
  33. package/dist/esm/airdrop/SignatureAirdropClient.js.map +1 -1
  34. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.d.ts +1 -1
  35. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.js +3 -6
  36. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.js.map +1 -1
  37. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/index.d.ts +1 -2
  38. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/index.js +5 -7
  39. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/index.js.map +1 -1
  40. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/solana/index.d.ts +1 -1
  41. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/solana/index.js +3 -6
  42. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/solana/index.js.map +1 -1
  43. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.d.ts +1 -1
  44. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.js +9 -10
  45. package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.js.map +1 -1
  46. package/dist/esm/airdrop/services/index.d.ts +8 -25
  47. package/dist/esm/airdrop/services/index.js +4 -31
  48. package/dist/esm/airdrop/services/index.js.map +1 -1
  49. package/dist/esm/airdrop/types/index.d.ts +0 -27
  50. package/dist/esm/airdrop/types/index.js.map +1 -1
  51. package/dist/esm/index.d.ts +1 -1
  52. package/dist/esm/index.js +1 -1
  53. package/dist/esm/index.js.map +1 -1
  54. package/dist/esm/utils/api-client.d.ts +0 -1
  55. package/dist/esm/utils/api-client.js +2 -2
  56. package/dist/esm/utils/api-client.js.map +1 -1
  57. package/package.json +3 -3
  58. package/src/airdrop/AirdropClient.ts +2 -8
  59. package/src/airdrop/SignatureAirdropClient.ts +29 -161
  60. package/src/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.ts +3 -6
  61. package/src/airdrop/core/useWeb3ConnectWallet/providers/evm/index.tsx +5 -18
  62. package/src/airdrop/core/useWeb3ConnectWallet/providers/solana/index.tsx +3 -6
  63. package/src/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.ts +12 -16
  64. package/src/airdrop/services/index.ts +14 -75
  65. package/src/airdrop/types/index.ts +1 -31
  66. package/src/index.ts +1 -9
  67. package/src/utils/api-client.ts +2 -3
  68. package/dist/cjs/airdrop/core/evm/SignatureAirdropService.d.ts +0 -23
  69. package/dist/cjs/airdrop/core/evm/SignatureAirdropService.js +0 -71
  70. package/dist/cjs/airdrop/core/evm/SignatureAirdropService.js.map +0 -1
  71. package/dist/cjs/airdrop/core/evm/contracts/AirdropSignatureClient.d.ts +0 -16
  72. package/dist/cjs/airdrop/core/evm/contracts/AirdropSignatureClient.js +0 -47
  73. package/dist/cjs/airdrop/core/evm/contracts/AirdropSignatureClient.js.map +0 -1
  74. package/dist/cjs/airdrop/core/evm/contracts/abis/FungibleTokenECDSADistributor.json +0 -564
  75. package/dist/esm/airdrop/core/evm/SignatureAirdropService.d.ts +0 -23
  76. package/dist/esm/airdrop/core/evm/SignatureAirdropService.js +0 -67
  77. package/dist/esm/airdrop/core/evm/SignatureAirdropService.js.map +0 -1
  78. package/dist/esm/airdrop/core/evm/contracts/AirdropSignatureClient.d.ts +0 -16
  79. package/dist/esm/airdrop/core/evm/contracts/AirdropSignatureClient.js +0 -40
  80. package/dist/esm/airdrop/core/evm/contracts/AirdropSignatureClient.js.map +0 -1
  81. package/dist/esm/airdrop/core/evm/contracts/abis/FungibleTokenECDSADistributor.json +0 -564
  82. package/src/airdrop/core/evm/SignatureAirdropService.ts +0 -90
  83. package/src/airdrop/core/evm/contracts/AirdropSignatureClient.ts +0 -56
  84. package/src/airdrop/core/evm/contracts/abis/FungibleTokenECDSADistributor.json +0 -564
@@ -1,46 +1,25 @@
1
- import { getAddress } from 'viem';
2
1
  import { CONST } from './constants';
3
- import { SignatureAirdropService } from './core/evm/SignatureAirdropService';
4
2
  import { WalletFactory } from './core/useWeb3ConnectWallet';
5
3
  import { ChainType } from './core/useWeb3ConnectWallet/types';
6
- import {
7
- bindWallet,
8
- checkEligibility,
9
- checkGetSignatures,
10
- connectTwitter,
11
- disconnectRecipient,
12
- getAirdropProject
13
- } from './services';
14
- import {
15
- AirdropSigIdentityTypeEnum,
16
- ChainId,
17
- IAirdropOptions,
18
- IAirdropSignatureClaim,
19
- IClaimSignature,
20
- IProject,
21
- IWalletClient
22
- } from './types';
4
+ import { bindWallet, connectTwitter, getAirdropProject } from './services';
5
+ import { AirdropSigIdentityTypeEnum, IAirdropOptions, IProject } from './types';
23
6
 
24
7
  export class SignatureAirdropClient {
8
+ private slug?: string;
25
9
  private projectId?: string;
26
10
  private endpoint?: string;
27
11
  private project: IProject | undefined;
28
- protected claims?: IAirdropSignatureClaim[];
12
+ protected claims?: any[];
29
13
  private projectPromise: Promise<void> | undefined;
14
+ private claimHook: ((v: any) => any) | undefined;
15
+ // private contractConfig: IContractConfig | null = null;
30
16
  constructor(params: IAirdropOptions) {
17
+ if ('slug' in params) {
18
+ this.slug = params.slug;
19
+ }
31
20
  this.projectId = params.projectId;
32
21
  this.endpoint = params.endpoint;
33
- if (this.project) {
34
- this.project = params.project;
35
- } else {
36
- this.projectPromise = this.initializeProjects();
37
- }
38
- }
39
-
40
- private readonly LOCAL_STORAGE_SID_PREFIX = 'sid_';
41
-
42
- private setSid(projectId: string, sid: string): void {
43
- window.localStorage.setItem(`${this.LOCAL_STORAGE_SID_PREFIX}${projectId}`, sid);
22
+ this.projectPromise = this.initializeProjects();
44
23
  }
45
24
 
46
25
  private async fetchProjectDetails(projectId: string): Promise<void> {
@@ -55,6 +34,7 @@ export class SignatureAirdropClient {
55
34
  return;
56
35
  }
57
36
 
37
+ // Fetch project details
58
38
  await this.fetchProjectDetails(projectId);
59
39
  } catch (error: any) {
60
40
  throw new Error(`Failed to initialize project: ${error.message}`);
@@ -62,9 +42,7 @@ export class SignatureAirdropClient {
62
42
  }
63
43
 
64
44
  async getProjectInfo() {
65
- if (this.projectPromise) {
66
- await this.projectPromise;
67
- }
45
+ await this.projectPromise;
68
46
  if (!this.project) throw new Error('Project not found');
69
47
  return this.project;
70
48
  }
@@ -73,14 +51,13 @@ export class SignatureAirdropClient {
73
51
  const project = await this.getProjectInfo();
74
52
  const onWindowMessage = async (message: any) => {
75
53
  if (message.data.name && message.data.name === CONST.TWITTER_AUTH_SUCCESS) {
76
- const { code } = message.data.data || {};
54
+ const { isError, code, redirectUri } = message.data.data || {};
77
55
  try {
78
- const res = await connectTwitter({ code, projectId: project.id }, this.endpoint);
79
-
80
- if (res?.sid) {
81
- this.setSid(project.id, res?.sid);
82
- }
56
+ await connectTwitter({ code, redirectUri: redirectUri }, this.endpoint);
83
57
  onSuccess();
58
+ if (isError) {
59
+ onError();
60
+ }
84
61
  } catch (error) {
85
62
  onError();
86
63
  } finally {
@@ -102,146 +79,37 @@ export class SignatureAirdropClient {
102
79
  onError
103
80
  }: {
104
81
  chainType: ChainType;
105
- onSuccess?: () => void;
106
- onError?: (error: any) => void;
82
+ onSuccess: () => void;
83
+ onError: (error: any) => void;
107
84
  }) {
108
85
  try {
109
86
  const project = await this.getProjectInfo();
110
87
  const wallet = WalletFactory.getWallet(chainType);
111
- const timestamp = Date.now();
88
+ const signResult = await wallet.signin(CONST.WELCOME_SIGNATURE_STATEMENT);
89
+
90
+ const { message, signature } = signResult || {};
91
+
112
92
  const recipientTypeMap = {
113
93
  [ChainType.Evm]: AirdropSigIdentityTypeEnum.EVMWallet,
114
94
  [ChainType.Solana]: AirdropSigIdentityTypeEnum.SolanaWallet,
115
95
  [ChainType.Ton]: ''
116
96
  };
117
- const msg = [project.id, recipientTypeMap[chainType], timestamp].join(',');
118
- const signResult = await wallet.signin(msg, false);
119
-
120
- const { message, signature } = signResult || {};
121
97
 
122
98
  const payload = {
123
99
  signature: signature as string,
124
100
  message: message as string,
125
101
  key: wallet.publicKey || wallet.address!,
126
102
  projectId: project.id,
127
- timestamp: timestamp,
103
+ timestamp: Date.now(),
128
104
  recipientType: recipientTypeMap[chainType]
129
105
  };
130
106
 
131
- const res = await bindWallet(payload, this.endpoint);
132
- if (res?.sid) {
133
- this.setSid(project.id, res?.sid);
134
- }
135
- onSuccess?.();
107
+ await bindWallet(payload, this.endpoint);
108
+ onSuccess();
136
109
  } catch (error) {
137
- onError?.(error);
138
- }
139
- }
140
-
141
- async getClaims() {
142
- const project = await this.getProjectInfo();
143
- const res = await checkEligibility(
144
- {
145
- projectId: project.id
146
- },
147
- this.endpoint
148
- );
149
- this.claims = res.claims;
150
- return res;
151
- }
152
-
153
- public async disconnectIdentity({
154
- recipientType,
155
- recipient
156
- }: {
157
- recipientType: AirdropSigIdentityTypeEnum;
158
- recipient?: string;
159
- }) {
160
- const project = await this.getProjectInfo();
161
- return await disconnectRecipient(
162
- {
163
- projectId: project.id,
164
- recipientType,
165
- recipient
166
- },
167
- this.endpoint
168
- );
169
- }
170
-
171
- public async getStrategy(walletClient?: IWalletClient): Promise<SignatureAirdropService> {
172
- const project = await this.getProjectInfo();
173
-
174
- return new SignatureAirdropService({
175
- chainId: Number(project.chainId) as ChainId,
176
- contractAddress: project.contractAddress,
177
- walletClient: walletClient as any
178
- });
179
- }
180
-
181
- async getVersion(): Promise<string> {
182
- const strategy = await this.getStrategy();
183
- return strategy.getVersion();
184
- }
185
-
186
- async getClaimFee(amount?: bigint): Promise<undefined | bigint> {
187
- const strategy = await this.getStrategy();
188
- if (!strategy.getClaimFee) {
189
- throw new Error('getClaimFee is not supported for this chain');
190
- }
191
- return await strategy.getClaimFee(this.project?.contractAddress || '', amount || BigInt(1));
192
- }
193
-
194
- async claimAirdrop({
195
- claimIds,
196
- walletClient,
197
- recipient
198
- }: {
199
- claimIds: string[];
200
- walletClient: IWalletClient;
201
- recipient?: string;
202
- }) {
203
- if (!claimIds.length) {
204
- throw new Error('Claim IDs cannot be empty');
205
- }
206
- if (!walletClient) {
207
- throw new Error('Wallet client is required');
208
- }
209
- const service = await this.getStrategy(walletClient);
210
- const res = await checkGetSignatures(
211
- {
212
- claimIds,
213
- projectId: this.projectId!
214
- },
215
- this.endpoint
216
- );
217
- const signatureMap = res?.signatures?.reduce((map, item) => {
218
- map[item.claimId] = item;
219
- return map;
220
- }, {} as Record<string, IClaimSignature>);
221
- const claimData =
222
- this.claims
223
- ?.filter((it) => claimIds.includes(it.claimId))
224
- .map((it) => ({
225
- ...it,
226
- recipient: recipient ? recipient : walletClient.account?.address!,
227
- ...signatureMap?.[it.claimId]
228
- })) || [];
229
- const delegateMode = recipient ? getAddress(recipient) !== walletClient.account?.address : false;
230
- const feeData = (await this.getClaimFee(1n)) || 0n;
231
- const hash = (await service!.claim(
232
- claimData,
233
- delegateMode ? feeData * BigInt(claimData.length) : feeData
234
- )) as `0x${string}`;
235
- return hash;
236
- }
237
-
238
- async batchCheckClaimed(): Promise<boolean[]> {
239
- if (!this.claims?.length) return [];
240
- const strategy = await this.getStrategy();
241
- if (!strategy.batchFetchClaimed) {
242
- throw new Error('batchCheckClaimed is not supported for this chain');
110
+ onError(error);
111
+ } finally {
112
+ onSuccess();
243
113
  }
244
- const claimIds = this.claims?.map((it) => it.claimId);
245
- return strategy.batchFetchClaimed(claimIds);
246
114
  }
247
115
  }
@@ -53,16 +53,13 @@ export class EvmWallet extends WalletBase<EVMStoreType> {
53
53
  };
54
54
  }
55
55
 
56
- override async signin(statement: string, prepare = true): Promise<ISignResult> {
56
+ override async signin(statement?: string): Promise<ISignResult> {
57
57
  return new Promise((resolve) => {
58
58
  const signCallback = (data: ReturnType<typeof useAccount>) => {
59
59
  this.address = data.address;
60
60
  this.chainId = data.chainId;
61
- let fullMessage = statement;
62
- if (prepare) {
63
- const msg = prepareSignMessage({ statement, chainId: data.chainId!, address: data.address! });
64
- fullMessage = get4361Message(msg);
65
- }
61
+ const msg = prepareSignMessage({ statement, chainId: data.chainId!, address: data.address! });
62
+ const fullMessage = get4361Message(msg);
66
63
 
67
64
  const res = this.sign(fullMessage);
68
65
 
@@ -1,5 +1,5 @@
1
1
  import '@rainbow-me/rainbowkit/styles.css';
2
- import { RainbowKitProvider, darkTheme, useConnectModal } from '@rainbow-me/rainbowkit';
2
+ import { RainbowKitProvider, lightTheme, useConnectModal } from '@rainbow-me/rainbowkit';
3
3
  import { ResolvedRegister, WagmiProvider, useAccount, useWalletClient } from 'wagmi';
4
4
  import { ReactNode, useEffect } from 'react';
5
5
 
@@ -26,27 +26,14 @@ export const EVMConnector = () => {
26
26
  return null;
27
27
  };
28
28
 
29
- export const EvmProvider = ({
30
- children,
31
- config,
32
- theme
33
- }: {
34
- children: ReactNode;
35
- config: ResolvedRegister['config'];
36
- theme?: any;
37
- }) => {
29
+ export const EvmProvider = ({ children, config }: { children: ReactNode; config: ResolvedRegister['config'] }) => {
38
30
  evmStore.config = config;
39
31
  return (
40
32
  <WagmiProvider config={config}>
41
33
  <RainbowKitProvider
42
- locale="en-US"
43
- theme={
44
- theme ||
45
- darkTheme({
46
- accentColor: 'var(--t-primary)',
47
- accentColorForeground: 'var(--t-button-primary-foreground)'
48
- })
49
- }
34
+ theme={lightTheme({
35
+ accentColor: '#DD8D58'
36
+ })}
50
37
  >
51
38
  {children}
52
39
  <EVMConnector />
@@ -63,17 +63,14 @@ export class SolWallet extends WalletBase<SolStoreType> {
63
63
  }
64
64
  }
65
65
 
66
- signin(statement: string, prepare = true): Promise<ISignResult> {
66
+ signin(statement?: string): Promise<ISignResult> {
67
67
  return new Promise((resolve) => {
68
68
  const signCallback = (data: ReturnType<typeof useWallet>) => {
69
69
  this.publicKey = data.publicKey?.toString();
70
70
  this.address = this.publicKey;
71
71
  this.chainId = 1;
72
- let fullMessage = statement;
73
- if (prepare) {
74
- const msg = prepareSignMessage({ statement, chainId: '1', address: this.address! });
75
- fullMessage = get4361Message(msg);
76
- }
72
+ const msg = prepareSignMessage({ statement, chainId: '1', address: this.address! });
73
+ const fullMessage = get4361Message(msg);
77
74
 
78
75
  const res = this.sign(fullMessage);
79
76
 
@@ -57,11 +57,11 @@ export class TonWallet extends WalletBase<TonStoreType> {
57
57
 
58
58
  async sign(originMsg: string): Promise<ISignResult> {
59
59
  const message = await hashSha256(originMsg);
60
- const tonConnectUI = tonStore.walletClient as any;
60
+ const tonConnectUI = tonStore.walletClient as TonConnectUI;
61
61
  // const walletInfo = tonConnectUI?.wallet;
62
62
  const authType = '';
63
63
  // if (walletInfo?.jsBridgeKey && walletInfo?.openMethod !== 'qrcode') {
64
- // authType = walletInfo.jsBridgeKey;
64
+ // authType = walletInfo.jsBridgeKey;
65
65
  // }
66
66
 
67
67
  console.log(this.isConnected, tonConnectUI, 'connected');
@@ -72,10 +72,12 @@ export class TonWallet extends WalletBase<TonStoreType> {
72
72
  if (authType) {
73
73
  const wallets = await tonConnectUI.getWallets();
74
74
 
75
- const currentWallet = wallets.find((wallet: any) =>
75
+ const currentWallet = wallets.find((wallet) =>
76
76
  [wallet.name, wallet.appName].includes(authType)
77
77
  ) as WalletInfoRemote;
78
78
 
79
+ console.log(wallets, currentWallet, 'ww');
80
+
79
81
  const link = tonConnectUI.connector.connect(
80
82
  {
81
83
  bridgeUrl: currentWallet.bridgeUrl,
@@ -131,19 +133,13 @@ export class TonWallet extends WalletBase<TonStoreType> {
131
133
  };
132
134
  }
133
135
 
134
- override async signin(statement: string, prepare = true): Promise<ISignResult> {
135
- const fullMessage = prepare
136
- ? JSON.stringify(
137
- {
138
- statement: statement || 'Welcome to EthSign',
139
- issuedAt: new Date().toISOString(),
140
- nonce: getCustomNaNoId()
141
- },
142
- null,
143
- ' '
144
- )
145
- : statement;
146
- const signRes = await this.sign(fullMessage);
136
+ override async signin(statement?: string): Promise<ISignResult> {
137
+ const fullMessage = {
138
+ statement: statement || 'Welcome to EthSign',
139
+ issuedAt: new Date().toISOString(),
140
+ nonce: getCustomNaNoId()
141
+ };
142
+ const signRes = await this.sign(JSON.stringify(fullMessage, null, ' '));
147
143
  return signRes;
148
144
  }
149
145
 
@@ -1,13 +1,6 @@
1
1
  import { apiClient } from '../../utils/api-client';
2
2
  import { safeParseJSON } from '../../utils/utils';
3
- import {
4
- AirdropSigIdentityTypeEnum,
5
- IAirdropData,
6
- IAirdropSignatureData,
7
- IClaimSignature,
8
- IContractConfig,
9
- IProject
10
- } from '../types';
3
+ import { IAirdropData, IContractConfig, IProject } from '../types';
11
4
 
12
5
  export { TonWalletService } from './wallet-service/ton';
13
6
 
@@ -18,7 +11,7 @@ const createApiClient = (baseURL?: string) => {
18
11
  export const getAirdropProject = async (projectId: string, baseURL?: string): Promise<IProject> => {
19
12
  const client = createApiClient(baseURL);
20
13
  const res = await client.get<any>(`/airdrop-open/projects/${projectId}`);
21
- if (!res) return res; // res is null
14
+ if (!res) return res; // resnull
22
15
  const projectConfig = res?.themeConf;
23
16
  const blockCountries = safeParseJSON(projectConfig?.blockCountries);
24
17
  return {
@@ -77,81 +70,27 @@ export const getJettonInfo = async (
77
70
  return client.get(`/airdrop-open/jetton/${data.address}?isTestnet=${data.isTestnet}`);
78
71
  };
79
72
 
80
- interface SidResponse {
81
- sid: string;
82
- }
83
-
84
- interface TwitterConnectParams {
85
- code: string;
86
- projectId: string;
87
- }
88
-
89
- interface WalletBindParams {
90
- projectId: string;
91
- key: string;
92
- signature: string;
93
- message: string;
94
- timestamp: number;
95
- recipientType: string;
96
- }
97
-
98
- const getSidHeader = (projectId: string) => ({
99
- sid: window.localStorage.getItem(`sid_${projectId}`) || ''
100
- });
101
-
102
- export const connectTwitter = async (data: TwitterConnectParams, baseURL?: string): Promise<SidResponse> => {
103
- const client = createApiClient(baseURL);
104
- return client.post('/airdrop-open/connect-twitter', data, {
105
- headers: getSidHeader(data.projectId)
106
- });
107
- };
108
-
109
- export const checkEligibility = async (
110
- data: { projectId: string },
111
- baseURL?: string
112
- ): Promise<IAirdropSignatureData> => {
113
- const headers = getSidHeader(data.projectId);
114
- if (!headers.sid)
115
- return {
116
- claims: [],
117
- identities: []
118
- };
73
+ export const connectTwitter = async (data: { code: string; redirectUri: string }, baseURL?: string) => {
119
74
  const client = createApiClient(baseURL);
120
-
121
- return client.post('/airdrop-open/check-eligibility', data, {
122
- headers: headers
123
- });
75
+ return client.post('/airdrop-open/connect-twitter', data);
124
76
  };
125
77
 
126
- export const bindWallet = async (data: WalletBindParams, baseURL?: string): Promise<SidResponse> => {
78
+ export const checkEligibility = async (data: { projectId: string }, baseURL?: string) => {
127
79
  const client = createApiClient(baseURL);
128
- return client.post('/airdrop-open/connect-wallet', data, {
129
- headers: getSidHeader(data.projectId)
130
- });
80
+ return client.post('/airdrop-open/check-eligibility', data);
131
81
  };
132
82
 
133
- interface DisconnectParams {
134
- projectId: string;
135
- recipientType: AirdropSigIdentityTypeEnum;
136
- recipient?: string;
137
- }
138
-
139
- export const disconnectRecipient = async (data: DisconnectParams, baseURL?: string): Promise<void> => {
140
- const client = createApiClient(baseURL);
141
- return client.post('/airdrop-open/disconnect', data, {
142
- headers: getSidHeader(data.projectId)
143
- });
144
- };
145
-
146
- export const checkGetSignatures = async (
83
+ export const bindWallet = async (
147
84
  data: {
148
85
  projectId: string;
149
- claimIds: string[];
86
+ key: string;
87
+ signature: string;
88
+ message: string;
89
+ timestamp: number;
90
+ recipientType: string;
150
91
  },
151
92
  baseURL?: string
152
- ): Promise<{ signatures: IClaimSignature[] }> => {
93
+ ) => {
153
94
  const client = createApiClient(baseURL);
154
- return client.post('/airdrop-open/check-get-signatures', data, {
155
- headers: getSidHeader(data.projectId)
156
- });
95
+ return client.post('/airdrop-open/connect-wallet', data);
157
96
  };
@@ -1,6 +1,7 @@
1
1
  import { TonConnectUI } from '@tonconnect/ui-react';
2
2
  import { AirdropService as TonAirdropService } from '../core/ton/AirdropService';
3
3
  import { AirdropService as EvmAirdropService } from '../core/evm/AirdropService';
4
+ import { TonClient } from '@ton/ton';
4
5
  import { ChainConfig } from '../constants';
5
6
  import { WalletClient as ViemWalletClient } from 'viem';
6
7
 
@@ -62,7 +63,6 @@ export interface IProject {
62
63
  version: string;
63
64
  extra?: IProjectExtra;
64
65
  identities: Identity[];
65
- projectTag: string;
66
66
  }
67
67
 
68
68
  export interface Identity {
@@ -113,39 +113,10 @@ export type IAirdropClaim = {
113
113
  project: IProject;
114
114
  };
115
115
 
116
- export type IAirdropSignatureClaim = {
117
- percent: number;
118
- unlockingAt: number;
119
- claimDeadline: number;
120
- value: string;
121
- recipient: string;
122
- recipientType: string;
123
- claimId: string;
124
- data?: string;
125
- signature?: string;
126
- claimed?: boolean;
127
- };
128
-
129
- export interface IAirdropSignatureIdentity {
130
- type: AirdropSigIdentityTypeEnum;
131
- value: string;
132
- }
133
-
134
116
  export interface IAirdropData {
135
117
  claims: IAirdropClaim[];
136
118
  }
137
119
 
138
- export interface IAirdropSignatureData {
139
- claims: IAirdropSignatureClaim[];
140
- identities: IAirdropSignatureIdentity[];
141
- }
142
-
143
- export interface IClaimSignature {
144
- claimId: string;
145
- data: string;
146
- signature: string;
147
- }
148
-
149
120
  export enum TonAirdropVersionEnum {
150
121
  V1 = '1.0.0',
151
122
  V2 = '2.0.0',
@@ -165,7 +136,6 @@ export type IAirdropService = TonAirdropService | EvmAirdropService;
165
136
 
166
137
  type BaseAirdropOptions = {
167
138
  endpoint?: string;
168
- project?: IProject;
169
139
  };
170
140
 
171
141
  type ProjectIdOptions = BaseAirdropOptions & {
package/src/index.ts CHANGED
@@ -1,10 +1,2 @@
1
- export {
2
- AirdropClient,
3
- SignatureAirdropClient,
4
- CONST,
5
- WalletFactory,
6
- EvmProvider,
7
- SolanaProvider,
8
- TonProvider
9
- } from './airdrop';
1
+ export { AirdropClient } from './airdrop';
10
2
  export * from './airdrop/types';
@@ -5,7 +5,6 @@ export type ApiClientOptions = {
5
5
  export type ApiRequestOptions = {
6
6
  params?: Record<string, string | number>;
7
7
  skipHandleError?: boolean;
8
- headers?: Record<string, string>;
9
8
  };
10
9
 
11
10
  type ApiResponse = {
@@ -49,11 +48,11 @@ export class ApiClient {
49
48
  ): Promise<unknown> {
50
49
  const finalUrl = (this.options?.baseURL || '') + url;
51
50
 
52
- const init: RequestInit = { method, headers: options?.headers || {} };
51
+ const init: RequestInit = { method };
53
52
  if (data instanceof FormData) {
54
53
  init.body = data;
55
54
  } else {
56
- init.headers = { 'content-type': 'application/json', ...init.headers };
55
+ init.headers = { 'content-type': 'application/json' };
57
56
  init.body = data ? JSON.stringify(data) : void 0;
58
57
  }
59
58
 
@@ -1,23 +0,0 @@
1
- import { EvmContractClientOption } from '../../types';
2
- import { DeployerClient } from './contracts/DeployClient';
3
- export declare class SignatureAirdropService {
4
- options: EvmContractClientOption;
5
- constructor(options: EvmContractClientOption);
6
- private get airdropClient();
7
- getDeployerClient(): Promise<DeployerClient>;
8
- private getFeeClient;
9
- getDeployer(): Promise<string>;
10
- getVersion(): Promise<any>;
11
- feeCollectors: (address: string) => Promise<unknown>;
12
- feeTokens: (address: string) => Promise<unknown>;
13
- getFeelessThreshold(): Promise<void>;
14
- getClaimFee(address: string, amount: bigint): Promise<bigint | undefined>;
15
- batchFetchClaimed(userClaimIds: string[]): Promise<boolean[]>;
16
- claim(data: {
17
- recipient: string;
18
- claimId: string;
19
- data: string;
20
- signature: string;
21
- extraData?: string;
22
- }[], value?: bigint): Promise<`0x${string}`>;
23
- }