@sign-global/tokentable 0.3.0 → 0.4.0-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.
- package/.github/workflows/beta.yml +28 -0
- package/dist/cjs/airdrop/AirdropClient.d.ts +46 -0
- package/dist/cjs/airdrop/AirdropClient.js +251 -0
- package/dist/cjs/airdrop/AirdropClient.js.map +1 -0
- package/dist/cjs/airdrop/SignatureAirdropClient.d.ts +24 -0
- package/dist/cjs/airdrop/SignatureAirdropClient.js +109 -0
- package/dist/cjs/airdrop/SignatureAirdropClient.js.map +1 -0
- package/dist/cjs/airdrop/common/index.d.ts +1 -1
- package/dist/cjs/airdrop/constants/index.d.ts +4 -0
- package/dist/cjs/airdrop/constants/index.js +5 -1
- package/dist/cjs/airdrop/constants/index.js.map +1 -1
- package/dist/cjs/airdrop/core/evm/contracts/AirdropSignatureClient.d.ts +15 -0
- package/dist/cjs/airdrop/core/evm/contracts/AirdropSignatureClient.js +51 -0
- package/dist/cjs/airdrop/core/evm/contracts/AirdropSignatureClient.js.map +1 -0
- package/dist/cjs/airdrop/core/evm/contracts/abis/FungibleTokenECDSADistributor.json +564 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/WalletBase.d.ts +32 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/WalletBase.js +71 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/WalletBase.js.map +1 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/WalletFactory.d.ts +8 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/WalletFactory.js +38 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/WalletFactory.js.map +1 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/index.d.ts +2 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/index.js +21 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/index.js.map +1 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.d.ts +26 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.js +70 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.js.map +1 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/index.d.ts +9 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/index.js +35 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/index.js.map +1 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/index.d.ts +3 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/index.js +14 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/index.js.map +1 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/solana/index.d.ts +27 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/solana/index.js +119 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/solana/index.js.map +1 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.d.ts +23 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.js +117 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.js.map +1 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/ton/index.d.ts +9 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/ton/index.js +29 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/ton/index.js.map +1 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/types.d.ts +38 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/types.js +30 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/types.js.map +1 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/utils/index.d.ts +8 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/utils/index.js +41 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/utils/index.js.map +1 -0
- package/dist/cjs/airdrop/index.d.ts +4 -46
- package/dist/cjs/airdrop/index.js +22 -241
- package/dist/cjs/airdrop/index.js.map +1 -1
- package/dist/cjs/airdrop/services/index.d.ts +15 -0
- package/dist/cjs/airdrop/services/index.js +16 -1
- package/dist/cjs/airdrop/services/index.js.map +1 -1
- package/dist/cjs/airdrop/types/index.d.ts +19 -4
- package/dist/cjs/airdrop/types/index.js +7 -1
- package/dist/cjs/airdrop/types/index.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +7 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/utils.d.ts +1 -0
- package/dist/cjs/utils/utils.js +2 -1
- package/dist/cjs/utils/utils.js.map +1 -1
- package/dist/esm/airdrop/AirdropClient.d.ts +46 -0
- package/dist/esm/airdrop/AirdropClient.js +247 -0
- package/dist/esm/airdrop/AirdropClient.js.map +1 -0
- package/dist/esm/airdrop/SignatureAirdropClient.d.ts +24 -0
- package/dist/esm/airdrop/SignatureAirdropClient.js +105 -0
- package/dist/esm/airdrop/SignatureAirdropClient.js.map +1 -0
- package/dist/esm/airdrop/common/index.d.ts +1 -1
- package/dist/esm/airdrop/constants/index.d.ts +4 -0
- package/dist/esm/airdrop/constants/index.js +4 -0
- package/dist/esm/airdrop/constants/index.js.map +1 -1
- package/dist/esm/airdrop/core/evm/contracts/AirdropSignatureClient.d.ts +15 -0
- package/dist/esm/airdrop/core/evm/contracts/AirdropSignatureClient.js +44 -0
- package/dist/esm/airdrop/core/evm/contracts/AirdropSignatureClient.js.map +1 -0
- package/dist/esm/airdrop/core/evm/contracts/abis/FungibleTokenECDSADistributor.json +564 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/WalletBase.d.ts +32 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/WalletBase.js +67 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/WalletBase.js.map +1 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/WalletFactory.d.ts +8 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/WalletFactory.js +34 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/WalletFactory.js.map +1 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/index.d.ts +2 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/index.js +3 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/index.js.map +1 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.d.ts +26 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.js +65 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.js.map +1 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/index.d.ts +9 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/index.js +29 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/index.js.map +1 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/index.d.ts +3 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/index.js +5 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/index.js.map +1 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/solana/index.d.ts +27 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/solana/index.js +109 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/solana/index.js.map +1 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.d.ts +23 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.js +112 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.js.map +1 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/ton/index.d.ts +9 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/ton/index.js +24 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/ton/index.js.map +1 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/types.d.ts +38 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/types.js +27 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/types.js.map +1 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/utils/index.d.ts +8 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/utils/index.js +35 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/utils/index.js.map +1 -0
- package/dist/esm/airdrop/index.d.ts +4 -46
- package/dist/esm/airdrop/index.js +4 -239
- package/dist/esm/airdrop/index.js.map +1 -1
- package/dist/esm/airdrop/services/index.d.ts +15 -0
- package/dist/esm/airdrop/services/index.js +12 -0
- package/dist/esm/airdrop/services/index.js.map +1 -1
- package/dist/esm/airdrop/types/index.d.ts +19 -4
- package/dist/esm/airdrop/types/index.js +6 -0
- package/dist/esm/airdrop/types/index.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/utils.d.ts +1 -0
- package/dist/esm/utils/utils.js +1 -0
- package/dist/esm/utils/utils.js.map +1 -1
- package/package.json +15 -3
- package/src/airdrop/AirdropClient.ts +307 -0
- package/src/airdrop/SignatureAirdropClient.ts +120 -0
- package/src/airdrop/constants/index.ts +5 -0
- package/src/airdrop/core/evm/contracts/AirdropSignatureClient.ts +59 -0
- package/src/airdrop/core/evm/contracts/abis/FungibleTokenECDSADistributor.json +564 -0
- package/src/airdrop/core/useWeb3ConnectWallet/WalletBase.ts +92 -0
- package/src/airdrop/core/useWeb3ConnectWallet/WalletFactory.tsx +35 -0
- package/src/airdrop/core/useWeb3ConnectWallet/index.ts +3 -0
- package/src/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.ts +90 -0
- package/src/airdrop/core/useWeb3ConnectWallet/providers/evm/index.tsx +43 -0
- package/src/airdrop/core/useWeb3ConnectWallet/providers/index.ts +4 -0
- package/src/airdrop/core/useWeb3ConnectWallet/providers/solana/index.tsx +141 -0
- package/src/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.ts +149 -0
- package/src/airdrop/core/useWeb3ConnectWallet/providers/ton/index.tsx +41 -0
- package/src/airdrop/core/useWeb3ConnectWallet/types.ts +45 -0
- package/src/airdrop/core/useWeb3ConnectWallet/utils/index.ts +61 -0
- package/src/airdrop/index.ts +4 -304
- package/src/airdrop/services/index.ts +29 -1
- package/src/airdrop/types/index.ts +23 -5
- package/src/index.ts +9 -1
- package/src/utils/utils.ts +2 -0
- package/tsconfig.json +2 -2
package/src/airdrop/index.ts
CHANGED
|
@@ -1,305 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
|
19
|
-
|
|
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
|
-
private async fetchProjectFromSlug(address?: string): Promise<string | undefined> {
|
|
50
|
-
if (!this.slug) return undefined;
|
|
51
|
-
|
|
52
|
-
const res = await getAirdropPro(this.slug, this.endpoint);
|
|
53
|
-
const projectMap = res?.childProjectMapping || {};
|
|
54
|
-
|
|
55
|
-
return getTonProjectIdByAddress({
|
|
56
|
-
address,
|
|
57
|
-
slug: this.slug,
|
|
58
|
-
data: projectMap
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
private async fetchProjectDetails(projectId: string): Promise<void> {
|
|
63
|
-
this.project = await getAirdropProject(projectId, this.endpoint);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
protected async initializeProjects(address?: string) {
|
|
67
|
-
try {
|
|
68
|
-
let projectId = this.projectId;
|
|
69
|
-
|
|
70
|
-
// If slug is provided, try to fetch project ID from slug
|
|
71
|
-
if (!projectId) {
|
|
72
|
-
projectId = await this.fetchProjectFromSlug(address);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (!projectId) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Fetch project details
|
|
80
|
-
await this.fetchProjectDetails(projectId);
|
|
81
|
-
} catch (error: any) {
|
|
82
|
-
throw new Error(`Failed to initialize project: ${error.message}`);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
async getProjectInfo() {
|
|
87
|
-
await this.projectPromise;
|
|
88
|
-
if (!this.project) throw new Error('Project not found');
|
|
89
|
-
return this.project;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
async getAirdropClaims(data: { address: string }) {
|
|
93
|
-
if (this.slug) {
|
|
94
|
-
await this.initializeProjects(data.address); // Fetch project details by address & slug
|
|
95
|
-
}
|
|
96
|
-
const project = await this.getProjectInfo();
|
|
97
|
-
|
|
98
|
-
const res = await getAirdropQuery(
|
|
99
|
-
{
|
|
100
|
-
recipient: data.address,
|
|
101
|
-
projectId: project!.id,
|
|
102
|
-
recipientType: project!.recipientType
|
|
103
|
-
},
|
|
104
|
-
this.endpoint
|
|
105
|
-
);
|
|
106
|
-
const claimsRes = res.claims?.map((it) => ({
|
|
107
|
-
...it,
|
|
108
|
-
project: project!,
|
|
109
|
-
claimId: project!.chainType === ChainType.Evm ? `${project!.id}:${it.leaf}` : `${project!.id}:${it.index}`
|
|
110
|
-
}));
|
|
111
|
-
this.claims = claimsRes;
|
|
112
|
-
return this.claims;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
public async getStrategy(walletClient?: IWalletClient): Promise<IAirdropStrategy> {
|
|
116
|
-
const project = await this.getProjectInfo();
|
|
117
|
-
const version = this.contractConfig?.version || undefined;
|
|
118
|
-
|
|
119
|
-
const hasWallet = !!walletClient;
|
|
120
|
-
|
|
121
|
-
// Try to get cached strategy
|
|
122
|
-
let strategy = strategyCache.getStrategy(
|
|
123
|
-
project.contractAddress,
|
|
124
|
-
project.chainId,
|
|
125
|
-
project.chainType,
|
|
126
|
-
hasWallet
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
if (!strategy) {
|
|
130
|
-
// Create new strategy if not cached
|
|
131
|
-
strategy = AirdropStrategyFactory.createStrategy({
|
|
132
|
-
chainType: project.chainType,
|
|
133
|
-
contractAddress: project.contractAddress,
|
|
134
|
-
chainId: project.chainId,
|
|
135
|
-
walletClient,
|
|
136
|
-
tonClient: this.getTonClient(),
|
|
137
|
-
version
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
// Initialize the strategy
|
|
141
|
-
await strategy.initialize(walletClient);
|
|
142
|
-
|
|
143
|
-
// Cache the initialized strategy
|
|
144
|
-
strategyCache.setStrategy(
|
|
145
|
-
project.contractAddress,
|
|
146
|
-
project.chainId,
|
|
147
|
-
project.chainType,
|
|
148
|
-
strategy,
|
|
149
|
-
hasWallet
|
|
150
|
-
);
|
|
151
|
-
} else if (hasWallet) {
|
|
152
|
-
// If we have a wallet and the strategy exists, just initialize with the new wallet
|
|
153
|
-
await strategy.initialize(walletClient);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return strategy;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
private getClaimDataById(claimId: string) {
|
|
160
|
-
const claimData = this.claims?.find((it) => it.claimId === claimId);
|
|
161
|
-
if (!claimData) throw new Error('Claim data not found');
|
|
162
|
-
return claimData;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
setClaimHook(fn: (v: any) => any) {
|
|
166
|
-
this.claimHook = fn;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
private getDefaultExtraData() {
|
|
170
|
-
return {
|
|
171
|
-
isLegacy: true,
|
|
172
|
-
attestationId: BigInt(1)
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
private async calculateClaimFee(project: IProject, claimAmount: string): Promise<string | bigint | undefined> {
|
|
177
|
-
if (project.chainType === ChainType.Evm) {
|
|
178
|
-
const version = await this.getVersion();
|
|
179
|
-
const isNativeFreeVersion =
|
|
180
|
-
project.tokenType === ETokenType.Native &&
|
|
181
|
-
[EvmAirdropVersionEnum.V3, EvmAirdropVersionEnum.V4].includes(version as EvmAirdropVersionEnum);
|
|
182
|
-
return isNativeFreeVersion ? undefined : await this.getClaimFee(BigInt(claimAmount));
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if(project.chainType === ChainType.Ton) {
|
|
186
|
-
return await this.getClaimFee(BigInt(claimAmount));
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return undefined;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
async claimAirdrop(
|
|
193
|
-
{ claimId, walletClient }: { claimId: string; walletClient: IWalletClient },
|
|
194
|
-
options?: { onLoading?: () => void }
|
|
195
|
-
) {
|
|
196
|
-
// Get claim data and initialize strategy
|
|
197
|
-
const claimData = this.getClaimDataById(claimId);
|
|
198
|
-
const strategy = await this.getStrategy(walletClient);
|
|
199
|
-
const project = await this.getProjectInfo();
|
|
200
|
-
|
|
201
|
-
// Process extra data
|
|
202
|
-
const extraData = project.chainType === ChainType.Ton
|
|
203
|
-
? undefined
|
|
204
|
-
: this.claimHook
|
|
205
|
-
? this.claimHook(claimData)
|
|
206
|
-
: this.getDefaultExtraData();
|
|
207
|
-
|
|
208
|
-
// Calculate claim value based on project type
|
|
209
|
-
const value = await this.calculateClaimFee(project, claimData.amount);
|
|
210
|
-
|
|
211
|
-
// Execute claim with processed data
|
|
212
|
-
return strategy.claim({
|
|
213
|
-
...claimData,
|
|
214
|
-
extraData,
|
|
215
|
-
value
|
|
216
|
-
}, options);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
async checkClaimed(claimId: string): Promise<boolean> {
|
|
220
|
-
const claimData = this.getClaimDataById(claimId);
|
|
221
|
-
const strategy = await this.getStrategy();
|
|
222
|
-
return strategy.checkClaimed(claimData);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
private async getContractConfig(): Promise<IContractConfig | null> {
|
|
226
|
-
try {
|
|
227
|
-
const project = await this.getProjectInfo();
|
|
228
|
-
|
|
229
|
-
if (!this.contractConfig) {
|
|
230
|
-
this.contractConfig = await getAirdropContractConfig({
|
|
231
|
-
chainId: project.chainId,
|
|
232
|
-
chainType: project.chainType,
|
|
233
|
-
contractAddress: project.contractAddress
|
|
234
|
-
}, this.endpoint);
|
|
235
|
-
}
|
|
236
|
-
return this.contractConfig;
|
|
237
|
-
} catch (error) {
|
|
238
|
-
console.error('Error fetching contract config:', error);
|
|
239
|
-
return null;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
async getVersion(): Promise<string> {
|
|
244
|
-
const config = await this.getContractConfig();
|
|
245
|
-
if (config?.version) {
|
|
246
|
-
return config.version;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
const strategy = await this.getStrategy();
|
|
250
|
-
return strategy.getVersion();
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
async getPaused(): Promise<boolean> {
|
|
254
|
-
const config = await this.getContractConfig();
|
|
255
|
-
if (config && config?.paused !== null) {
|
|
256
|
-
return config.paused;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
const strategy = await this.getStrategy();
|
|
260
|
-
if (!strategy.getPaused) {
|
|
261
|
-
throw new Error('getPaused is not supported for this chain');
|
|
262
|
-
}
|
|
263
|
-
return strategy.getPaused();
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
async getClaimFee(amount?: bigint): Promise<string | bigint> {
|
|
267
|
-
const config = await this.getContractConfig();
|
|
268
|
-
if (config?.claimFee) {
|
|
269
|
-
return config.claimFee;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
const strategy = await this.getStrategy();
|
|
273
|
-
if (!strategy.getClaimFee) {
|
|
274
|
-
throw new Error('getClaimFee is not supported for this chain');
|
|
275
|
-
}
|
|
276
|
-
return strategy.getClaimFee(this.project?.contractAddress || '', amount || BigInt(0));
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// params claimId[]
|
|
280
|
-
async batchCheckClaimed(): Promise<{ result: boolean; status: string }[]> {
|
|
281
|
-
const strategy = await this.getStrategy();
|
|
282
|
-
if (!strategy.batchCheckClaimed) {
|
|
283
|
-
throw new Error('batchCheckClaimed is not supported for this chain');
|
|
284
|
-
}
|
|
285
|
-
const leafs = this.claims?.map((it) => it.leaf);
|
|
286
|
-
if (!leafs) return [];
|
|
287
|
-
return strategy.batchCheckClaimed(leafs);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
async getNFT(): Promise<string> {
|
|
291
|
-
const strategy = await this.getStrategy();
|
|
292
|
-
if (!strategy.getNFT) {
|
|
293
|
-
throw new Error('getNFT is not supported for this chain');
|
|
294
|
-
}
|
|
295
|
-
return strategy.getNFT();
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
async getKycThreshold(): Promise<bigint> {
|
|
299
|
-
const strategy = await this.getStrategy();
|
|
300
|
-
if (!strategy.getKycThreshold) {
|
|
301
|
-
throw new Error('getKycThreshold is not supported for this chain');
|
|
302
|
-
}
|
|
303
|
-
return strategy.getKycThreshold();
|
|
304
|
-
}
|
|
305
|
-
}
|
|
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 (
|
|
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
|
+
};
|
|
@@ -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
|
-
|
|
66
|
-
|
|
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,6 +136,7 @@ export type IAirdropService = TonAirdropService | EvmAirdropService;
|
|
|
119
136
|
|
|
120
137
|
type BaseAirdropOptions = {
|
|
121
138
|
endpoint?: string;
|
|
139
|
+
project?: IProject;
|
|
122
140
|
};
|
|
123
141
|
|
|
124
142
|
type ProjectIdOptions = BaseAirdropOptions & {
|
|
@@ -137,4 +155,4 @@ export interface IContractConfig {
|
|
|
137
155
|
version?: string | null;
|
|
138
156
|
paused: boolean | null;
|
|
139
157
|
claimFee?: string | null;
|
|
140
|
-
}
|
|
158
|
+
}
|
package/src/index.ts
CHANGED
package/src/utils/utils.ts
CHANGED
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,
|