@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.
- package/dist/cjs/airdrop/common/index.d.ts +1 -1
- package/dist/cjs/airdrop/constants/chain-config.d.ts +1 -1
- package/dist/cjs/airdrop/constants/chain-config.js +1 -1
- package/dist/cjs/airdrop/constants/chain-config.js.map +1 -1
- package/dist/esm/airdrop/common/index.d.ts +1 -1
- package/dist/esm/airdrop/constants/chain-config.d.ts +1 -1
- package/dist/esm/airdrop/constants/chain-config.js +1 -1
- package/dist/esm/airdrop/constants/chain-config.js.map +1 -1
- package/package.json +2 -9
- package/src/airdrop/AirdropClient.ts +0 -307
- package/src/airdrop/SignatureAirdropClient.ts +0 -378
- package/src/airdrop/common/index.ts +0 -54
- package/src/airdrop/common/projectDataForTon.ts +0 -79
- package/src/airdrop/constants/chain-config.ts +0 -107
- package/src/airdrop/constants/index.ts +0 -9
- package/src/airdrop/constants/network.ts +0 -78
- package/src/airdrop/contracts/evm/AirdropService.ts +0 -181
- package/src/airdrop/contracts/evm/SignatureAirdropService.ts +0 -114
- package/src/airdrop/contracts/evm/contracts/AirdropSignatureClient.ts +0 -63
- package/src/airdrop/contracts/evm/contracts/AirdropSignatureFeeClient.ts +0 -61
- package/src/airdrop/contracts/evm/contracts/AirdropV2Client.ts +0 -37
- package/src/airdrop/contracts/evm/contracts/AirdropV3Client.ts +0 -49
- package/src/airdrop/contracts/evm/contracts/AirdropV3FeeClient.ts +0 -16
- package/src/airdrop/contracts/evm/contracts/AirdropV4Client.ts +0 -36
- package/src/airdrop/contracts/evm/contracts/ContractBaseClient.ts +0 -85
- package/src/airdrop/contracts/evm/contracts/DeployClient.ts +0 -35
- package/src/airdrop/contracts/evm/contracts/FeeCollectorClient.ts +0 -21
- package/src/airdrop/contracts/evm/contracts/KycClient.ts +0 -21
- package/src/airdrop/contracts/evm/contracts/abis/Airdrop.json +0 -674
- package/src/airdrop/contracts/evm/contracts/abis/AirdropV2.json +0 -676
- package/src/airdrop/contracts/evm/contracts/abis/AirdropV3.json +0 -740
- package/src/airdrop/contracts/evm/contracts/abis/AirdropV3_Fee.json +0 -678
- package/src/airdrop/contracts/evm/contracts/abis/CustomFeeNativeAirdropV4.json +0 -701
- package/src/airdrop/contracts/evm/contracts/abis/Deployer.json +0 -271
- package/src/airdrop/contracts/evm/contracts/abis/ERC721.json +0 -737
- package/src/airdrop/contracts/evm/contracts/abis/FeeCollector.json +0 -322
- package/src/airdrop/contracts/evm/contracts/abis/FungibleTokenECDSADistributor.json +0 -564
- package/src/airdrop/contracts/evm/contracts/abis/FungibleTokenWithFeesECDSADistributor.json +0 -260
- package/src/airdrop/contracts/evm/contracts/abis/KycHook.json +0 -312
- package/src/airdrop/contracts/index.ts +0 -4
- package/src/airdrop/contracts/solana/AirdropSignatureClient.ts +0 -242
- package/src/airdrop/contracts/solana/FeeCollectorClient.ts +0 -43
- package/src/airdrop/contracts/solana/SignatureAirdropService.ts +0 -51
- package/src/airdrop/contracts/solana/SolanaContractClient.ts +0 -126
- package/src/airdrop/contracts/solana/fee_collector.json +0 -1063
- package/src/airdrop/contracts/solana/fee_collector.ts +0 -1069
- package/src/airdrop/contracts/solana/fungible_token_distributor_solana.json +0 -1573
- package/src/airdrop/contracts/solana/fungible_token_distributor_solana.ts +0 -1579
- package/src/airdrop/contracts/ton/AirdropClientV1.ts +0 -122
- package/src/airdrop/contracts/ton/AirdropClientV2.ts +0 -118
- package/src/airdrop/contracts/ton/AirdropClientV21.ts +0 -131
- package/src/airdrop/contracts/ton/AirdropClientV3.ts +0 -127
- package/src/airdrop/contracts/ton/AirdropService.ts +0 -150
- package/src/airdrop/contracts/ton/TonContractBaseClient.ts +0 -236
- package/src/airdrop/contracts/ton/v1/build/Leaf.compiled.json +0 -1
- package/src/airdrop/contracts/ton/v1/build/MerkleTokenDistributor.compiled.json +0 -1
- package/src/airdrop/contracts/ton/v1/utils/constants.ts +0 -42
- package/src/airdrop/contracts/ton/v1/utils/date.utils.ts +0 -11
- package/src/airdrop/contracts/ton/v1/utils/index.ts +0 -3
- package/src/airdrop/contracts/ton/v1/utils/ton.utils.ts +0 -84
- package/src/airdrop/contracts/ton/v1/wrappers/JettonMinter.ts +0 -81
- package/src/airdrop/contracts/ton/v1/wrappers/JettonWallet.ts +0 -73
- package/src/airdrop/contracts/ton/v1/wrappers/Leaf.ts +0 -88
- package/src/airdrop/contracts/ton/v1/wrappers/MerkleTokenDistributor.ts +0 -317
- package/src/airdrop/contracts/ton/v1/wrappers/index.ts +0 -2
- package/src/airdrop/contracts/ton/v2/build/Leaf.compiled.json +0 -1
- package/src/airdrop/contracts/ton/v2/build/MerkleTokenDistributor.compiled.json +0 -1
- package/src/airdrop/contracts/ton/v2/utils/constants.ts +0 -43
- package/src/airdrop/contracts/ton/v2/utils/date.utils.ts +0 -11
- package/src/airdrop/contracts/ton/v2/utils/index.ts +0 -3
- package/src/airdrop/contracts/ton/v2/utils/ton.utils.ts +0 -102
- package/src/airdrop/contracts/ton/v2/wrappers/Leaf.ts +0 -69
- package/src/airdrop/contracts/ton/v2/wrappers/MerkleTokenDistributor.ts +0 -340
- package/src/airdrop/contracts/ton/v2/wrappers/index.ts +0 -2
- package/src/airdrop/contracts/ton/v21/build/Leaf.compiled.json +0 -1
- package/src/airdrop/contracts/ton/v21/build/MerkleTokenDistributor.compiled.json +0 -1
- package/src/airdrop/contracts/ton/v21/utils/constants.ts +0 -48
- package/src/airdrop/contracts/ton/v21/utils/date.utils.ts +0 -11
- package/src/airdrop/contracts/ton/v21/utils/index.ts +0 -3
- package/src/airdrop/contracts/ton/v21/utils/ton.utils.ts +0 -84
- package/src/airdrop/contracts/ton/v21/wrappers/Leaf.ts +0 -69
- package/src/airdrop/contracts/ton/v21/wrappers/MerkleTokenDistributor.ts +0 -346
- package/src/airdrop/contracts/ton/v21/wrappers/index.ts +0 -2
- package/src/airdrop/contracts/ton/v3/build/Leaf.compiled.json +0 -1
- package/src/airdrop/contracts/ton/v3/build/MerkleTokenDistributor.compiled.json +0 -1
- package/src/airdrop/contracts/ton/v3/utils/constants.ts +0 -43
- package/src/airdrop/contracts/ton/v3/utils/date.utils.ts +0 -11
- package/src/airdrop/contracts/ton/v3/utils/index.ts +0 -3
- package/src/airdrop/contracts/ton/v3/utils/ton.utils.ts +0 -84
- package/src/airdrop/contracts/ton/v3/wrappers/Leaf.ts +0 -68
- package/src/airdrop/contracts/ton/v3/wrappers/MerkleTokenDistributor.ts +0 -316
- package/src/airdrop/contracts/ton/v3/wrappers/index.ts +0 -2
- package/src/airdrop/index.ts +0 -10
- package/src/airdrop/services/index.ts +0 -166
- package/src/airdrop/services/wallet-service/ton/WalletService.ts +0 -226
- package/src/airdrop/services/wallet-service/ton/index.ts +0 -1
- package/src/airdrop/strategies/AirdropStrategyFactory.ts +0 -31
- package/src/airdrop/strategies/EvmAirdropStrategy.ts +0 -81
- package/src/airdrop/strategies/IAirdropStrategy.ts +0 -26
- package/src/airdrop/strategies/StrategyCache.ts +0 -34
- package/src/airdrop/strategies/TonAirdropStrategy.ts +0 -77
- package/src/airdrop/tests/index.test.ts +0 -387
- package/src/airdrop/types/index.ts +0 -200
- package/src/index.ts +0 -3
- package/src/utils/api-client.ts +0 -69
- package/src/utils/index.ts +0 -3
- package/src/utils/utils.ts +0 -45
- package/src/utils/web3.ts +0 -172
- package/src/wallets/WalletBase.ts +0 -92
- package/src/wallets/WalletFactory.tsx +0 -35
- package/src/wallets/index.ts +0 -3
- package/src/wallets/providers/evm/EvmWallet.ts +0 -101
- package/src/wallets/providers/evm/index.tsx +0 -56
- package/src/wallets/providers/index.ts +0 -4
- package/src/wallets/providers/solana/index.tsx +0 -133
- package/src/wallets/providers/ton/TonWallet.ts +0 -153
- package/src/wallets/providers/ton/index.tsx +0 -41
- package/src/wallets/types.ts +0 -45
- package/src/wallets/utils/index.ts +0 -61
|
@@ -1,378 +0,0 @@
|
|
|
1
|
-
import { CONST } from './constants';
|
|
2
|
-
import { EvmSignatureAirdropService, SolanaSignatureAirdropService } from './contracts';
|
|
3
|
-
import { WalletFactory } from '../wallets';
|
|
4
|
-
import { ChainType } from '../wallets/types';
|
|
5
|
-
import {
|
|
6
|
-
bindWallet,
|
|
7
|
-
checkEligibility,
|
|
8
|
-
checkGetSignatures,
|
|
9
|
-
connectGoogleApi,
|
|
10
|
-
connectTwitter,
|
|
11
|
-
disconnectRecipient,
|
|
12
|
-
getAirdropProject
|
|
13
|
-
} from './services';
|
|
14
|
-
import {
|
|
15
|
-
AirdropSigIdentityTypeEnum,
|
|
16
|
-
ChainId,
|
|
17
|
-
ErrorCode,
|
|
18
|
-
IAirdropOptions,
|
|
19
|
-
IAirdropSignatureClaim,
|
|
20
|
-
IAirdropSignatureIdentity,
|
|
21
|
-
IClaimSignature,
|
|
22
|
-
IProject,
|
|
23
|
-
IWalletClient,
|
|
24
|
-
SolanaWalletState,
|
|
25
|
-
ViemWalletClient
|
|
26
|
-
} from './types';
|
|
27
|
-
import { cleanUrlParams, isMobile } from '../utils';
|
|
28
|
-
|
|
29
|
-
export class SignatureAirdropClient {
|
|
30
|
-
private projectId?: string;
|
|
31
|
-
private endpoint?: string;
|
|
32
|
-
private project: IProject | undefined;
|
|
33
|
-
protected claims?: IAirdropSignatureClaim[];
|
|
34
|
-
protected identities?: IAirdropSignatureIdentity[];
|
|
35
|
-
private projectPromise: Promise<void> | undefined;
|
|
36
|
-
private authPromise: Promise<void> | undefined;
|
|
37
|
-
private strategyCache: Map<string, EvmSignatureAirdropService | SolanaSignatureAirdropService> = new Map();
|
|
38
|
-
constructor(params: IAirdropOptions) {
|
|
39
|
-
this.projectId = params.projectId;
|
|
40
|
-
this.endpoint = params.endpoint;
|
|
41
|
-
if (this.project) {
|
|
42
|
-
this.project = params.project;
|
|
43
|
-
} else {
|
|
44
|
-
this.projectPromise = this.initializeProjects();
|
|
45
|
-
}
|
|
46
|
-
if (isMobile()) {
|
|
47
|
-
this.authPromise = this.checkAndHandleTwitterCode();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
private readonly LOCAL_STORAGE_SID_PREFIX = 'sid_';
|
|
52
|
-
|
|
53
|
-
private async checkAndHandleTwitterCode() {
|
|
54
|
-
try {
|
|
55
|
-
const urlParams = new URLSearchParams(window.location.search);
|
|
56
|
-
const code = urlParams.get('code');
|
|
57
|
-
const type = urlParams.get('type');
|
|
58
|
-
|
|
59
|
-
if (code && this.projectId) {
|
|
60
|
-
let res;
|
|
61
|
-
if (type === 'twitter') {
|
|
62
|
-
res = await connectTwitter({ code, projectId: this.projectId }, this.endpoint);
|
|
63
|
-
} else if (type === 'google') {
|
|
64
|
-
res = await connectGoogleApi({ code, projectId: this.projectId }, this.endpoint);
|
|
65
|
-
}
|
|
66
|
-
if (res?.sid) {
|
|
67
|
-
this.setSid(this.projectId!, res.sid);
|
|
68
|
-
} else {
|
|
69
|
-
throw new Error('Failed to connect');
|
|
70
|
-
}
|
|
71
|
-
cleanUrlParams(['code', 'type']);
|
|
72
|
-
}
|
|
73
|
-
} catch (error) {
|
|
74
|
-
console.error(error);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
private setSid(projectId: string, sid: string): void {
|
|
79
|
-
window.localStorage.setItem(`${this.LOCAL_STORAGE_SID_PREFIX}${projectId}`, sid);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
private async fetchProjectDetails(projectId: string): Promise<void> {
|
|
83
|
-
this.project = await getAirdropProject(projectId, this.endpoint);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
protected async initializeProjects() {
|
|
87
|
-
try {
|
|
88
|
-
let projectId = this.projectId;
|
|
89
|
-
if (!projectId) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
await this.fetchProjectDetails(projectId);
|
|
93
|
-
} catch (error: any) {
|
|
94
|
-
throw new Error(`Failed to initialize project: ${error.message}`);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
async getProjectInfo() {
|
|
99
|
-
if (this.projectPromise) {
|
|
100
|
-
await this.projectPromise;
|
|
101
|
-
}
|
|
102
|
-
if (!this.project) throw new Error('Project not found');
|
|
103
|
-
return this.project;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
async connectOAuth({
|
|
107
|
-
onSuccess,
|
|
108
|
-
onError,
|
|
109
|
-
type
|
|
110
|
-
}: {
|
|
111
|
-
onSuccess: () => void;
|
|
112
|
-
onError: (error: Error) => void;
|
|
113
|
-
type: AirdropSigIdentityTypeEnum;
|
|
114
|
-
}) {
|
|
115
|
-
const project = await this.getProjectInfo();
|
|
116
|
-
const authorizeUrl = project.identities.find((item: any) => item.identityType === type)?.authorizeUrl;
|
|
117
|
-
if (!authorizeUrl) {
|
|
118
|
-
onError(new Error('Authorize URL not found'));
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
if (isMobile()) {
|
|
122
|
-
const state = encodeURIComponent(window.location.href);
|
|
123
|
-
window.location.href = `${authorizeUrl}&state=${state}`;
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
const onWindowMessage = async (message: any) => {
|
|
127
|
-
const name = message.data?.name;
|
|
128
|
-
if (name && [CONST.TWITTER_AUTH_SUCCESS, CONST.GOOGLE_AUTH_SUCCESS].includes(name)) {
|
|
129
|
-
const { code } = message.data.data || {};
|
|
130
|
-
try {
|
|
131
|
-
let res;
|
|
132
|
-
if (name === CONST.GOOGLE_AUTH_SUCCESS) {
|
|
133
|
-
res = await connectGoogleApi({ code, projectId: project.id }, this.endpoint);
|
|
134
|
-
} else if (name === CONST.TWITTER_AUTH_SUCCESS) {
|
|
135
|
-
res = await connectTwitter({ code, projectId: project.id }, this.endpoint);
|
|
136
|
-
}
|
|
137
|
-
if (res?.sid) {
|
|
138
|
-
this.setSid(project.id, res?.sid);
|
|
139
|
-
onSuccess();
|
|
140
|
-
} else {
|
|
141
|
-
onError(new Error('Failed to connect'));
|
|
142
|
-
}
|
|
143
|
-
} catch (error) {
|
|
144
|
-
onError(error as Error);
|
|
145
|
-
} finally {
|
|
146
|
-
window.removeEventListener('message', onWindowMessage);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
window.addEventListener('message', onWindowMessage);
|
|
152
|
-
window.open(`${authorizeUrl}&state=state`, `twitter_auth_${project.id}`, 'width=600,height=800');
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
async connectX({ onSuccess, onError }: { onSuccess: () => void; onError: (error: Error) => void }) {
|
|
156
|
-
await this.connectOAuth({
|
|
157
|
-
onSuccess,
|
|
158
|
-
onError,
|
|
159
|
-
type: AirdropSigIdentityTypeEnum.Twitter
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
async connectGoogle({ onSuccess, onError }: { onSuccess: () => void; onError: (error: Error) => void }) {
|
|
164
|
-
await this.connectOAuth({
|
|
165
|
-
onSuccess,
|
|
166
|
-
onError,
|
|
167
|
-
type: AirdropSigIdentityTypeEnum.Google
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
async connectWallet({
|
|
172
|
-
chainType,
|
|
173
|
-
onSuccess,
|
|
174
|
-
onError
|
|
175
|
-
}: {
|
|
176
|
-
chainType: ChainType;
|
|
177
|
-
onSuccess?: (address: string) => void;
|
|
178
|
-
onError?: (error: any) => void;
|
|
179
|
-
}) {
|
|
180
|
-
try {
|
|
181
|
-
const project = await this.getProjectInfo();
|
|
182
|
-
const wallet = WalletFactory.getWallet(chainType);
|
|
183
|
-
const timestamp = Date.now();
|
|
184
|
-
const recipientTypeMap = {
|
|
185
|
-
[ChainType.Evm]: AirdropSigIdentityTypeEnum.EVMWallet,
|
|
186
|
-
[ChainType.Solana]: AirdropSigIdentityTypeEnum.SolanaWallet,
|
|
187
|
-
[ChainType.Ton]: AirdropSigIdentityTypeEnum.TONWallet
|
|
188
|
-
};
|
|
189
|
-
const msg = [project.id, recipientTypeMap[chainType], timestamp].join(',');
|
|
190
|
-
const signResult = await wallet.signin(msg, false);
|
|
191
|
-
await wallet.disconnect();
|
|
192
|
-
const { message, signature } = signResult || {};
|
|
193
|
-
|
|
194
|
-
if (this.identities?.find((it) => it.value?.toLowerCase() === wallet.address?.toLowerCase())) {
|
|
195
|
-
onError?.(ErrorCode.WALLET_ALREADY_CONNECTED);
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const payload = {
|
|
200
|
-
signature: signature as string,
|
|
201
|
-
message: message as string,
|
|
202
|
-
key: wallet.publicKey || wallet.address!,
|
|
203
|
-
address: wallet.address!,
|
|
204
|
-
projectId: project.id,
|
|
205
|
-
timestamp: timestamp,
|
|
206
|
-
recipientType: recipientTypeMap[chainType]
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
const res = await bindWallet(payload, this.endpoint);
|
|
210
|
-
if (res?.sid) {
|
|
211
|
-
this.setSid(project.id, res?.sid);
|
|
212
|
-
}
|
|
213
|
-
onSuccess?.(wallet.address!);
|
|
214
|
-
} catch (error) {
|
|
215
|
-
onError?.(error);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
async getClaims() {
|
|
220
|
-
const project = await this.getProjectInfo();
|
|
221
|
-
if (this.authPromise) {
|
|
222
|
-
await this.authPromise;
|
|
223
|
-
}
|
|
224
|
-
const res = await checkEligibility(
|
|
225
|
-
{
|
|
226
|
-
projectId: project.id
|
|
227
|
-
},
|
|
228
|
-
this.endpoint
|
|
229
|
-
);
|
|
230
|
-
this.claims = res.claims;
|
|
231
|
-
this.identities = res.identities;
|
|
232
|
-
return res;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
public async disconnectIdentity({
|
|
236
|
-
recipientType,
|
|
237
|
-
recipient
|
|
238
|
-
}: {
|
|
239
|
-
recipientType: AirdropSigIdentityTypeEnum;
|
|
240
|
-
recipient?: string;
|
|
241
|
-
}) {
|
|
242
|
-
const project = await this.getProjectInfo();
|
|
243
|
-
return await disconnectRecipient(
|
|
244
|
-
{
|
|
245
|
-
projectId: project.id,
|
|
246
|
-
recipientType,
|
|
247
|
-
recipient
|
|
248
|
-
},
|
|
249
|
-
this.endpoint
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
public async getStrategy(
|
|
254
|
-
walletClient?: IWalletClient
|
|
255
|
-
): Promise<EvmSignatureAirdropService | SolanaSignatureAirdropService> {
|
|
256
|
-
const project = await this.getProjectInfo();
|
|
257
|
-
|
|
258
|
-
const cacheKey = walletClient
|
|
259
|
-
? project.chainType === ChainType.Evm
|
|
260
|
-
? (walletClient as ViemWalletClient).account?.address!
|
|
261
|
-
: project.chainType === ChainType.Solana
|
|
262
|
-
? (walletClient as SolanaWalletState).publicKey!.toString()
|
|
263
|
-
: 'walletClient'
|
|
264
|
-
: 'default';
|
|
265
|
-
if (this.strategyCache.has(cacheKey)) {
|
|
266
|
-
return this.strategyCache.get(cacheKey)!;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
const strategy =
|
|
270
|
-
project.chainType === ChainType.Solana
|
|
271
|
-
? new SolanaSignatureAirdropService({
|
|
272
|
-
chainId: project.chainId,
|
|
273
|
-
projectId: project.id,
|
|
274
|
-
token: project.tokenAddress,
|
|
275
|
-
walletClient: walletClient as any
|
|
276
|
-
})
|
|
277
|
-
: new EvmSignatureAirdropService({
|
|
278
|
-
chainId: Number(project.chainId) as ChainId,
|
|
279
|
-
contractAddress: project.contractAddress,
|
|
280
|
-
walletClient: walletClient as any
|
|
281
|
-
});
|
|
282
|
-
this.strategyCache.set(cacheKey, strategy);
|
|
283
|
-
return strategy;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
async getVersion(): Promise<string> {
|
|
287
|
-
const strategy = await this.getStrategy();
|
|
288
|
-
return strategy.getVersion();
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
// solana prams need to wallet
|
|
292
|
-
async getClaimFee(amount?: bigint, walletClient?: IWalletClient): Promise<undefined | bigint> {
|
|
293
|
-
const strategy = await this.getStrategy(walletClient);
|
|
294
|
-
if (!strategy.getClaimFee) {
|
|
295
|
-
throw new Error('getClaimFee is not supported for this chain');
|
|
296
|
-
}
|
|
297
|
-
return await strategy.getClaimFee(this.project?.contractAddress || '', amount || BigInt(1));
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
async claimAirdrop({
|
|
301
|
-
claimIds,
|
|
302
|
-
walletClient,
|
|
303
|
-
recipient
|
|
304
|
-
}: {
|
|
305
|
-
claimIds: string[];
|
|
306
|
-
walletClient: IWalletClient;
|
|
307
|
-
recipient: string;
|
|
308
|
-
}) {
|
|
309
|
-
if (!claimIds.length) {
|
|
310
|
-
throw new Error('Claim IDs cannot be empty');
|
|
311
|
-
}
|
|
312
|
-
if (!walletClient) {
|
|
313
|
-
throw new Error('Wallet client is required');
|
|
314
|
-
}
|
|
315
|
-
if (!this.claims?.length) {
|
|
316
|
-
throw new Error('No claims available');
|
|
317
|
-
}
|
|
318
|
-
const service = await this.getStrategy(walletClient);
|
|
319
|
-
const project = await this.getProjectInfo();
|
|
320
|
-
const res = await checkGetSignatures(
|
|
321
|
-
{
|
|
322
|
-
claimIds,
|
|
323
|
-
projectId: this.projectId!,
|
|
324
|
-
recipient
|
|
325
|
-
},
|
|
326
|
-
this.endpoint
|
|
327
|
-
);
|
|
328
|
-
if (!res?.signatures?.length) {
|
|
329
|
-
throw new Error('Failed to get signatures');
|
|
330
|
-
}
|
|
331
|
-
const signatureMap = res?.signatures?.reduce((map, item) => {
|
|
332
|
-
map[item.claimId] = item;
|
|
333
|
-
return map;
|
|
334
|
-
}, {} as Record<string, IClaimSignature>);
|
|
335
|
-
const filteredClaims = this.claims.filter((it) => claimIds.includes(it.claimId));
|
|
336
|
-
if (!filteredClaims.length) {
|
|
337
|
-
throw new Error('No matching claims found');
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// only evm use
|
|
341
|
-
const defaultRecipient =
|
|
342
|
-
project.chainType === ChainType.Evm ? (walletClient as ViemWalletClient).account?.address! : '';
|
|
343
|
-
|
|
344
|
-
const claimData = filteredClaims.map((it) => {
|
|
345
|
-
const signature = signatureMap[it.claimId];
|
|
346
|
-
if (!signature) {
|
|
347
|
-
throw new Error(`Signature not found for claim ID: ${it.claimId}`);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
return {
|
|
351
|
-
...it,
|
|
352
|
-
recipient: recipient ? recipient : defaultRecipient,
|
|
353
|
-
...signature
|
|
354
|
-
};
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
const hash = (await service!.claim(claimData, recipient)) as `0x${string}`;
|
|
358
|
-
return hash;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
async batchCheckClaimed(): Promise<boolean[]> {
|
|
362
|
-
if (!this.claims?.length) return [];
|
|
363
|
-
const strategy = await this.getStrategy();
|
|
364
|
-
if (!strategy.batchFetchClaimed) {
|
|
365
|
-
throw new Error('batchCheckClaimed is not supported for this chain');
|
|
366
|
-
}
|
|
367
|
-
const claimIds = this.claims?.map((it) => it.claimId);
|
|
368
|
-
return strategy.batchFetchClaimed(claimIds);
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
async getPaused(): Promise<boolean> {
|
|
372
|
-
const strategy = await this.getStrategy();
|
|
373
|
-
if (!strategy.getPaused) {
|
|
374
|
-
throw new Error('getPaused is not supported for this chain');
|
|
375
|
-
}
|
|
376
|
-
return strategy.getPaused();
|
|
377
|
-
}
|
|
378
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { ChainConfig, SupportedChains } from '../constants';
|
|
2
|
-
import { ChainId } from '../types';
|
|
3
|
-
import { projectDataForTon } from './projectDataForTon';
|
|
4
|
-
|
|
5
|
-
export function getChainById(chainId: ChainId) {
|
|
6
|
-
const chain = SupportedChains.find((chain) => chain.id === chainId);
|
|
7
|
-
|
|
8
|
-
if (!chain) {
|
|
9
|
-
throw new Error(`ChainId ${chainId} not supported.`);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return chain;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function getChainConfig(chainId: ChainId) {
|
|
16
|
-
return ChainConfig[chainId];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function getChainRpc(chainId: ChainId): string {
|
|
20
|
-
const config = getChainConfig(chainId as any);
|
|
21
|
-
|
|
22
|
-
if (!config) {
|
|
23
|
-
throw new Error(`ChainId ${chainId} not supported.`);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return config?.rpcUrl;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const getTonProjectIdByAddress = ({
|
|
30
|
-
address,
|
|
31
|
-
slug,
|
|
32
|
-
data
|
|
33
|
-
}: {
|
|
34
|
-
address?: string;
|
|
35
|
-
slug: string;
|
|
36
|
-
data: Record<string, string>;
|
|
37
|
-
}): string | undefined => {
|
|
38
|
-
let project: Record<string, string> = projectDataForTon[slug as keyof typeof projectDataForTon];
|
|
39
|
-
if (!project) {
|
|
40
|
-
project = data;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (!address) {
|
|
44
|
-
const firstProject = Object.values(project)[0];
|
|
45
|
-
return firstProject;
|
|
46
|
-
}
|
|
47
|
-
const lastText = address[address.length - 1];
|
|
48
|
-
|
|
49
|
-
const group = Object.keys(project || {}).find((key) => key.includes(lastText));
|
|
50
|
-
|
|
51
|
-
const projectId = group ? project[group as keyof typeof project] : undefined;
|
|
52
|
-
|
|
53
|
-
return projectId;
|
|
54
|
-
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
export const projectDataForTon = {
|
|
2
|
-
ava: {
|
|
3
|
-
'12345': 'AD_18uwEPKbTXZo',
|
|
4
|
-
'67890': 'AD_XOPhRRGggtjK',
|
|
5
|
-
abcABC: 'AD_qKwG21hnimAB',
|
|
6
|
-
defDEF: 'AD_CfAV1GNekDAQ',
|
|
7
|
-
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
-
yYzZ: 'AD_XQbS0ksJGDrB',
|
|
73
|
-
'90_-': 'AD_LhssByVDm8Q1'
|
|
74
|
-
},
|
|
75
|
-
roolz: {
|
|
76
|
-
abcdefghijklmnopqrstuvwxyz12345_: 'AD_3ZoF8wq7leAI',
|
|
77
|
-
'ABCDEFGHIJKLMNOPQRSTUVWXYZ67890-': 'AD_HMFs2ubSrC1K'
|
|
78
|
-
}
|
|
79
|
-
};
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { CHAIN } from '@tonconnect/ui-react';
|
|
2
|
-
import {
|
|
3
|
-
base,
|
|
4
|
-
baseSepolia,
|
|
5
|
-
cyber,
|
|
6
|
-
mainnet,
|
|
7
|
-
polygonMumbai,
|
|
8
|
-
polygonAmoy,
|
|
9
|
-
sepolia,
|
|
10
|
-
zetachain,
|
|
11
|
-
zetachainAthensTestnet,
|
|
12
|
-
zkSync,
|
|
13
|
-
bsc,
|
|
14
|
-
berachainTestnet,
|
|
15
|
-
arbitrum
|
|
16
|
-
} from 'viem/chains';
|
|
17
|
-
import { mevmDevNet, tonMainNet, tonTestNet } from './network';
|
|
18
|
-
|
|
19
|
-
export const ChainConfig = {
|
|
20
|
-
[mainnet.id]: {
|
|
21
|
-
contractAddress: '0x0993Dd5384BcD116A3543889BC6ffA6C98948631',
|
|
22
|
-
rpcUrl: 'https://eth-mainnet.g.alchemy.com/v2/udrqNPSB6i5n5L6QSM31Ng72h_hFOrVT'
|
|
23
|
-
},
|
|
24
|
-
[bsc.id]: {
|
|
25
|
-
contractAddress: '0x6c241FF6d5c3f074b49aC10872770529d9e27BA4',
|
|
26
|
-
rpcUrl: 'https://bnb-mainnet.g.alchemy.com/v2/udrqNPSB6i5n5L6QSM31Ng72h_hFOrVT'
|
|
27
|
-
},
|
|
28
|
-
[base.id]: {
|
|
29
|
-
contractAddress: '0x3d1abcD56d53f7C8b04A753C6AF397903DC0f0F2',
|
|
30
|
-
rpcUrl: base.rpcUrls.default.http[0]
|
|
31
|
-
},
|
|
32
|
-
[cyber.id]: {
|
|
33
|
-
contractAddress: '0x7915dA247674E430b2a4Dcf01e4471f709428Bc0',
|
|
34
|
-
rpcUrl: cyber.rpcUrls.default.http[0]
|
|
35
|
-
},
|
|
36
|
-
[sepolia.id]: {
|
|
37
|
-
contractAddress: '0xf3f5243B35376c6dea04169983A8c853c8BE6d69',
|
|
38
|
-
rpcUrl: 'https://eth-sepolia.public.blastapi.io'
|
|
39
|
-
},
|
|
40
|
-
[baseSepolia.id]: {
|
|
41
|
-
contractAddress: '0x66c9fe5c76672B06Bf497eFfdaAfDf897D1e68d8',
|
|
42
|
-
rpcUrl: baseSepolia.rpcUrls.default.http[0]
|
|
43
|
-
},
|
|
44
|
-
[zetachainAthensTestnet.id]: {
|
|
45
|
-
contractAddress: '0x63aE2f2260DEfc11932d22410B976Ec29F54498B',
|
|
46
|
-
rpcUrl: zetachainAthensTestnet.rpcUrls.default.http[0]
|
|
47
|
-
},
|
|
48
|
-
[zetachain.id]: {
|
|
49
|
-
contractAddress: '0x00aFD4466E4Afa4F43cCd414b1BC65e574ACA2f5',
|
|
50
|
-
rpcUrl: 'https://zetachain-mainnet.g.alchemy.com/v2/1tmk0FrhwTJHXh0XIyae7_SXw1lDCjgs'
|
|
51
|
-
},
|
|
52
|
-
[arbitrum.id]: {
|
|
53
|
-
contractAddress: '0x759ac3CA33FeeAfB8C41aEbC8687A7Bd849Fc87a',
|
|
54
|
-
rpcUrl: arbitrum.rpcUrls.default.http[0]
|
|
55
|
-
},
|
|
56
|
-
[berachainTestnet.id]: {
|
|
57
|
-
contractAddress: '',
|
|
58
|
-
rpcUrl: '',
|
|
59
|
-
availableSolutions: []
|
|
60
|
-
},
|
|
61
|
-
[polygonMumbai.id]: {
|
|
62
|
-
contractAddress: '',
|
|
63
|
-
rpcUrl: '',
|
|
64
|
-
availableSolutions: []
|
|
65
|
-
},
|
|
66
|
-
[polygonAmoy.id]: {
|
|
67
|
-
contractAddress: '',
|
|
68
|
-
rpcUrl: '',
|
|
69
|
-
availableSolutions: []
|
|
70
|
-
},
|
|
71
|
-
[mevmDevNet.id]: {
|
|
72
|
-
contractAddress: '0x8D92827CdB67A503e9FB21B28a58F9dAb36B4973',
|
|
73
|
-
rpcUrl: mevmDevNet.rpcUrls.default.http[0]
|
|
74
|
-
},
|
|
75
|
-
[CHAIN.TESTNET]: {
|
|
76
|
-
name: 'TestNet',
|
|
77
|
-
contractAddress: '',
|
|
78
|
-
rpcUrl: 'https://testnet.toncenter.com/api/v2/jsonRPC', //https://toncenter.com/api/v2/jsonRPC
|
|
79
|
-
tonApiPrefix: 'https://testnet.tonapi.io',
|
|
80
|
-
blockExplorer: 'https://testnet.tonviewer.com'
|
|
81
|
-
},
|
|
82
|
-
[CHAIN.MAINNET]: {
|
|
83
|
-
name: 'MainNet',
|
|
84
|
-
contractAddress: '',
|
|
85
|
-
rpcUrl: 'https://toncenter.com/api/v2/jsonRPC',
|
|
86
|
-
tonApiPrefix: 'https://tonapi.io',
|
|
87
|
-
blockExplorer: 'https://tonviewer.com'
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export const SupportedChains = [
|
|
92
|
-
mainnet,
|
|
93
|
-
bsc,
|
|
94
|
-
base,
|
|
95
|
-
cyber,
|
|
96
|
-
sepolia,
|
|
97
|
-
baseSepolia,
|
|
98
|
-
zetachain,
|
|
99
|
-
zetachainAthensTestnet,
|
|
100
|
-
berachainTestnet,
|
|
101
|
-
polygonMumbai,
|
|
102
|
-
polygonAmoy,
|
|
103
|
-
mevmDevNet,
|
|
104
|
-
arbitrum,
|
|
105
|
-
tonTestNet,
|
|
106
|
-
tonMainNet
|
|
107
|
-
];
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from './chain-config';
|
|
2
|
-
|
|
3
|
-
export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
4
|
-
|
|
5
|
-
export const CONST = {
|
|
6
|
-
TWITTER_AUTH_SUCCESS: 'twitter:auth:success',
|
|
7
|
-
GOOGLE_AUTH_SUCCESS: 'google:auth:success',
|
|
8
|
-
WELCOME_SIGNATURE_STATEMENT: 'Welcome to TokenTable!'
|
|
9
|
-
} as const;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { CHAIN } from '@tonconnect/ui-react';
|
|
2
|
-
import { defineChain } from 'viem';
|
|
3
|
-
|
|
4
|
-
export const mevmDevNet = defineChain({
|
|
5
|
-
id: 30732,
|
|
6
|
-
name: 'Movement M1 Devnet',
|
|
7
|
-
network: 'mevm',
|
|
8
|
-
nativeCurrency: { name: 'Move', symbol: 'MOVE', decimals: 18 },
|
|
9
|
-
rpcUrls: {
|
|
10
|
-
default: {
|
|
11
|
-
http: ['https://mevm.devnet.imola.movementlabs.xyz']
|
|
12
|
-
},
|
|
13
|
-
public: {
|
|
14
|
-
http: ['https://mevm.devnet.imola.movementlabs.xyz']
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
blockExplorers: {
|
|
18
|
-
etherscan: { name: 'Arbiscan', url: 'https://explorer.devnet.imola.movementlabs.xyz/' },
|
|
19
|
-
default: { name: 'Arbiscan', url: 'https://explorer.devnet.imola.movementlabs.xyz/' }
|
|
20
|
-
},
|
|
21
|
-
contracts: {
|
|
22
|
-
multicall3: {
|
|
23
|
-
address: '0xD67Eca381AAbd0c049554f5714E7d8C21864c560',
|
|
24
|
-
blockCreated: 500
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
export const tonTestNet = {
|
|
30
|
-
id: CHAIN.TESTNET,
|
|
31
|
-
name: 'TON Testnet',
|
|
32
|
-
network: 'TON_TESTNET',
|
|
33
|
-
nativeCurrency: {
|
|
34
|
-
decimals: 9,
|
|
35
|
-
name: 'TON',
|
|
36
|
-
symbol: 'TON'
|
|
37
|
-
},
|
|
38
|
-
rpcUrls: {
|
|
39
|
-
public: {
|
|
40
|
-
http: []
|
|
41
|
-
},
|
|
42
|
-
default: {
|
|
43
|
-
http: []
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
blockExplorers: {
|
|
47
|
-
default: {
|
|
48
|
-
name: 'tonviewer',
|
|
49
|
-
url: 'https://testnet.tonviewer.com'
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
testnet: true
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export const tonMainNet = {
|
|
56
|
-
id: CHAIN.MAINNET,
|
|
57
|
-
name: 'TON Mainnet',
|
|
58
|
-
network: 'TON_MAINNET',
|
|
59
|
-
nativeCurrency: {
|
|
60
|
-
decimals: 9,
|
|
61
|
-
name: 'TON',
|
|
62
|
-
symbol: 'TON'
|
|
63
|
-
},
|
|
64
|
-
rpcUrls: {
|
|
65
|
-
public: {
|
|
66
|
-
http: []
|
|
67
|
-
},
|
|
68
|
-
default: {
|
|
69
|
-
http: []
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
blockExplorers: {
|
|
73
|
-
default: {
|
|
74
|
-
name: 'tonviwer',
|
|
75
|
-
url: 'https://tonviewer.com'
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
};
|