@sign-global/tokentable 0.0.5 → 0.0.7
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/index.d.ts +10 -12
- package/dist/cjs/airdrop/index.js +118 -110
- package/dist/cjs/airdrop/index.js.map +1 -1
- package/dist/cjs/airdrop/services/index.d.ts +6 -1
- package/dist/cjs/airdrop/services/index.js +6 -1
- package/dist/cjs/airdrop/services/index.js.map +1 -1
- package/dist/cjs/airdrop/strategies/AirdropStrategyFactory.d.ts +13 -0
- package/dist/cjs/airdrop/strategies/AirdropStrategyFactory.js +22 -0
- package/dist/cjs/airdrop/strategies/AirdropStrategyFactory.js.map +1 -0
- package/dist/cjs/airdrop/strategies/EvmAirdropStrategy.d.ts +26 -0
- package/dist/cjs/airdrop/strategies/EvmAirdropStrategy.js +79 -0
- package/dist/cjs/airdrop/strategies/EvmAirdropStrategy.js.map +1 -0
- package/dist/cjs/airdrop/strategies/IAirdropStrategy.d.ts +27 -0
- package/dist/cjs/airdrop/strategies/IAirdropStrategy.js +3 -0
- package/dist/cjs/airdrop/strategies/IAirdropStrategy.js.map +1 -0
- package/dist/cjs/airdrop/strategies/StrategyCache.d.ts +10 -0
- package/dist/cjs/airdrop/strategies/StrategyCache.js +32 -0
- package/dist/cjs/airdrop/strategies/StrategyCache.js.map +1 -0
- package/dist/cjs/airdrop/strategies/TonAirdropStrategy.d.ts +26 -0
- package/dist/cjs/airdrop/strategies/TonAirdropStrategy.js +64 -0
- package/dist/cjs/airdrop/strategies/TonAirdropStrategy.js.map +1 -0
- package/dist/cjs/airdrop/types/index.d.ts +5 -0
- package/dist/esm/airdrop/index.d.ts +10 -12
- package/dist/esm/airdrop/index.js +120 -112
- package/dist/esm/airdrop/index.js.map +1 -1
- package/dist/esm/airdrop/services/index.d.ts +6 -1
- package/dist/esm/airdrop/services/index.js +4 -0
- package/dist/esm/airdrop/services/index.js.map +1 -1
- package/dist/esm/airdrop/strategies/AirdropStrategyFactory.d.ts +13 -0
- package/dist/esm/airdrop/strategies/AirdropStrategyFactory.js +18 -0
- package/dist/esm/airdrop/strategies/AirdropStrategyFactory.js.map +1 -0
- package/dist/esm/airdrop/strategies/EvmAirdropStrategy.d.ts +26 -0
- package/dist/esm/airdrop/strategies/EvmAirdropStrategy.js +75 -0
- package/dist/esm/airdrop/strategies/EvmAirdropStrategy.js.map +1 -0
- package/dist/esm/airdrop/strategies/IAirdropStrategy.d.ts +27 -0
- package/dist/esm/airdrop/strategies/IAirdropStrategy.js +2 -0
- package/dist/esm/airdrop/strategies/IAirdropStrategy.js.map +1 -0
- package/dist/esm/airdrop/strategies/StrategyCache.d.ts +10 -0
- package/dist/esm/airdrop/strategies/StrategyCache.js +28 -0
- package/dist/esm/airdrop/strategies/StrategyCache.js.map +1 -0
- package/dist/esm/airdrop/strategies/TonAirdropStrategy.d.ts +26 -0
- package/dist/esm/airdrop/strategies/TonAirdropStrategy.js +60 -0
- package/dist/esm/airdrop/strategies/TonAirdropStrategy.js.map +1 -0
- package/dist/esm/airdrop/types/index.d.ts +5 -0
- package/package.json +1 -1
- package/src/airdrop/index.ts +144 -140
- package/src/airdrop/services/index.ts +6 -1
- package/src/airdrop/strategies/AirdropStrategyFactory.ts +29 -0
- package/src/airdrop/strategies/EvmAirdropStrategy.ts +85 -0
- package/src/airdrop/strategies/IAirdropStrategy.ts +25 -0
- package/src/airdrop/strategies/StrategyCache.ts +34 -0
- package/src/airdrop/strategies/TonAirdropStrategy.ts +72 -0
- package/src/airdrop/tests/index.test.ts +85 -0
- package/src/airdrop/types/index.ts +6 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { AirdropService as TonAirdropService } from './core/ton/AirdropService';
|
|
2
|
-
import { AirdropService as EvmAirdropService } from './core/evm/AirdropService';
|
|
3
1
|
import { IAirdropClaim, IAirdropOptions, IProject, IWalletClient } from './types';
|
|
2
|
+
import { IAirdropStrategy } from './strategies/IAirdropStrategy';
|
|
4
3
|
export declare class AirdropClient {
|
|
5
4
|
private tonClient?;
|
|
6
5
|
private slug?;
|
|
@@ -8,20 +7,18 @@ export declare class AirdropClient {
|
|
|
8
7
|
private endpoint?;
|
|
9
8
|
private project;
|
|
10
9
|
protected claims?: IAirdropClaim[];
|
|
11
|
-
private contractInstanceWithWallet;
|
|
12
|
-
private contractInstanceWithoutWallet;
|
|
13
10
|
private projectPromise;
|
|
14
11
|
private claimHook;
|
|
15
|
-
private
|
|
12
|
+
private contractConfig;
|
|
16
13
|
constructor(params: IAirdropOptions);
|
|
14
|
+
private fetchProjectFromSlug;
|
|
15
|
+
private fetchProjectDetails;
|
|
17
16
|
protected initializeProjects(address?: string): Promise<void>;
|
|
18
17
|
getProjectInfo(): Promise<IProject>;
|
|
19
18
|
getAirdropClaims(data: {
|
|
20
19
|
address: string;
|
|
21
20
|
}): Promise<IAirdropClaim[]>;
|
|
22
|
-
|
|
23
|
-
walletClient?: IWalletClient;
|
|
24
|
-
}): Promise<TonAirdropService | EvmAirdropService>;
|
|
21
|
+
getStrategy(walletClient?: IWalletClient): Promise<IAirdropStrategy>;
|
|
25
22
|
private getClaimDataById;
|
|
26
23
|
setClaimHook(fn: (v: any) => any): void;
|
|
27
24
|
claimAirdrop({ claimId, walletClient }: {
|
|
@@ -29,15 +26,16 @@ export declare class AirdropClient {
|
|
|
29
26
|
walletClient: IWalletClient;
|
|
30
27
|
}, options?: {
|
|
31
28
|
onLoading?: () => void;
|
|
32
|
-
}): Promise
|
|
29
|
+
}): Promise<any>;
|
|
33
30
|
checkClaimed(claimId: string): Promise<boolean>;
|
|
34
|
-
|
|
31
|
+
private getContractConfig;
|
|
35
32
|
getVersion(): Promise<string>;
|
|
33
|
+
getPaused(): Promise<boolean>;
|
|
34
|
+
getClaimFee(amount?: bigint): Promise<string | bigint>;
|
|
36
35
|
batchCheckClaimed(): Promise<{
|
|
37
36
|
result: boolean;
|
|
38
37
|
status: string;
|
|
39
38
|
}[]>;
|
|
40
|
-
getNFT(): Promise<
|
|
39
|
+
getNFT(): Promise<string>;
|
|
41
40
|
getKycThreshold(): Promise<bigint>;
|
|
42
|
-
getClaimFee(amount?: bigint): Promise<string | bigint | undefined>;
|
|
43
41
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AirdropClient = void 0;
|
|
4
|
-
const AirdropService_1 = require("./core/ton/AirdropService");
|
|
5
|
-
const AirdropService_2 = require("./core/evm/AirdropService");
|
|
6
4
|
const services_1 = require("./services");
|
|
7
5
|
const types_1 = require("./types");
|
|
8
6
|
const common_1 = require("./common");
|
|
7
|
+
const AirdropStrategyFactory_1 = require("./strategies/AirdropStrategyFactory");
|
|
8
|
+
const StrategyCache_1 = require("./strategies/StrategyCache");
|
|
9
9
|
class AirdropClient {
|
|
10
10
|
tonClient;
|
|
11
11
|
slug;
|
|
@@ -13,11 +13,9 @@ class AirdropClient {
|
|
|
13
13
|
endpoint;
|
|
14
14
|
project;
|
|
15
15
|
claims;
|
|
16
|
-
contractInstanceWithWallet;
|
|
17
|
-
contractInstanceWithoutWallet;
|
|
18
16
|
projectPromise;
|
|
19
17
|
claimHook;
|
|
20
|
-
|
|
18
|
+
contractConfig = null;
|
|
21
19
|
constructor(params) {
|
|
22
20
|
if ('slug' in params) {
|
|
23
21
|
this.slug = params.slug;
|
|
@@ -27,20 +25,36 @@ class AirdropClient {
|
|
|
27
25
|
this.endpoint = params.endpoint;
|
|
28
26
|
this.projectPromise = this.initializeProjects();
|
|
29
27
|
}
|
|
28
|
+
async fetchProjectFromSlug(address) {
|
|
29
|
+
if (!this.slug)
|
|
30
|
+
return undefined;
|
|
31
|
+
const res = await (0, services_1.getAirdropPro)(this.slug, this.endpoint);
|
|
32
|
+
const projectMap = res?.childProjectMapping || {};
|
|
33
|
+
return (0, common_1.getTonProjectIdByAddress)({
|
|
34
|
+
address,
|
|
35
|
+
slug: this.slug,
|
|
36
|
+
data: projectMap
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async fetchProjectDetails(projectId) {
|
|
40
|
+
this.project = await (0, services_1.getAirdropProject)(projectId, this.endpoint);
|
|
41
|
+
}
|
|
30
42
|
async initializeProjects(address) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
|
|
43
|
+
try {
|
|
44
|
+
let projectId = this.projectId;
|
|
45
|
+
// If slug is provided, try to fetch project ID from slug
|
|
46
|
+
if (!projectId) {
|
|
47
|
+
projectId = await this.fetchProjectFromSlug(address);
|
|
48
|
+
}
|
|
49
|
+
if (!projectId) {
|
|
50
|
+
throw new Error('Project ID is required and could not be determined');
|
|
39
51
|
}
|
|
52
|
+
// Fetch project details
|
|
53
|
+
await this.fetchProjectDetails(projectId);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
throw new Error(`Failed to initialize project: ${error.message}`);
|
|
40
57
|
}
|
|
41
|
-
if (!projectId)
|
|
42
|
-
throw new Error('Project ID is required');
|
|
43
|
-
this.project = await (0, services_1.getAirdropProject)(projectId, this.endpoint);
|
|
44
58
|
}
|
|
45
59
|
async getProjectInfo() {
|
|
46
60
|
await this.projectPromise;
|
|
@@ -63,42 +77,30 @@ class AirdropClient {
|
|
|
63
77
|
this.claims = claimsRes;
|
|
64
78
|
return this.claims;
|
|
65
79
|
}
|
|
66
|
-
async
|
|
80
|
+
async getStrategy(walletClient) {
|
|
67
81
|
const project = await this.getProjectInfo();
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const instance = project.chainType === types_1.ChainType.Evm
|
|
89
|
-
? new AirdropService_2.AirdropService({
|
|
90
|
-
contractAddress: project.contractAddress,
|
|
91
|
-
chainId: Number(project.chainId)
|
|
92
|
-
})
|
|
93
|
-
: new AirdropService_1.AirdropService({
|
|
94
|
-
chainId: project.chainId.toString(),
|
|
95
|
-
address: project.contractAddress,
|
|
96
|
-
tonClient: this.tonClient
|
|
97
|
-
});
|
|
98
|
-
this.contractInstanceWithoutWallet = instance;
|
|
99
|
-
}
|
|
100
|
-
return this.contractInstanceWithoutWallet;
|
|
82
|
+
const hasWallet = !!walletClient;
|
|
83
|
+
// Try to get cached strategy
|
|
84
|
+
let strategy = StrategyCache_1.strategyCache.getStrategy(project.contractAddress, project.chainId, project.chainType, hasWallet);
|
|
85
|
+
if (!strategy) {
|
|
86
|
+
// Create new strategy if not cached
|
|
87
|
+
strategy = AirdropStrategyFactory_1.AirdropStrategyFactory.createStrategy({
|
|
88
|
+
chainType: project.chainType,
|
|
89
|
+
contractAddress: project.contractAddress,
|
|
90
|
+
chainId: project.chainId,
|
|
91
|
+
walletClient,
|
|
92
|
+
tonClient: this.tonClient
|
|
93
|
+
});
|
|
94
|
+
// Initialize the strategy
|
|
95
|
+
await strategy.initialize(walletClient);
|
|
96
|
+
// Cache the initialized strategy
|
|
97
|
+
StrategyCache_1.strategyCache.setStrategy(project.contractAddress, project.chainId, project.chainType, strategy, hasWallet);
|
|
98
|
+
}
|
|
99
|
+
else if (hasWallet) {
|
|
100
|
+
// If we have a wallet and the strategy exists, just initialize with the new wallet
|
|
101
|
+
await strategy.initialize(walletClient);
|
|
101
102
|
}
|
|
103
|
+
return strategy;
|
|
102
104
|
}
|
|
103
105
|
getClaimDataById(claimId) {
|
|
104
106
|
const claimData = this.claims?.find((it) => it.claimId === claimId);
|
|
@@ -111,88 +113,94 @@ class AirdropClient {
|
|
|
111
113
|
}
|
|
112
114
|
async claimAirdrop({ claimId, walletClient }, options) {
|
|
113
115
|
const claimData = this.getClaimDataById(claimId);
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
[types_1.EvmAirdropVersionEnum.V3, types_1.EvmAirdropVersionEnum.V4].includes(version));
|
|
122
|
-
const value = needsFeeData ? await this.getClaimFee(BigInt(claimData.amount)) : undefined;
|
|
123
|
-
let extraData = {
|
|
124
|
-
isLegacy: true,
|
|
125
|
-
attestationId: BigInt(1)
|
|
126
|
-
};
|
|
127
|
-
if (this.claimHook) {
|
|
128
|
-
extraData = this.claimHook(claimData);
|
|
129
|
-
}
|
|
130
|
-
return contractWrapper.claim({
|
|
131
|
-
proof: claimData.proof,
|
|
132
|
-
group: claimData.group,
|
|
133
|
-
data: claimData.data,
|
|
134
|
-
value: value,
|
|
135
|
-
extraData: extraData
|
|
136
|
-
});
|
|
116
|
+
const strategy = await this.getStrategy(walletClient);
|
|
117
|
+
let extraData = {
|
|
118
|
+
isLegacy: true,
|
|
119
|
+
attestationId: BigInt(1)
|
|
120
|
+
};
|
|
121
|
+
if (this.claimHook) {
|
|
122
|
+
extraData = this.claimHook(claimData);
|
|
137
123
|
}
|
|
138
|
-
return
|
|
124
|
+
return strategy.claim({
|
|
125
|
+
...claimData,
|
|
126
|
+
extraData
|
|
127
|
+
}, options);
|
|
139
128
|
}
|
|
140
129
|
async checkClaimed(claimId) {
|
|
141
130
|
const claimData = this.getClaimDataById(claimId);
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
131
|
+
const strategy = await this.getStrategy();
|
|
132
|
+
return strategy.checkClaimed(claimData);
|
|
133
|
+
}
|
|
134
|
+
async getContractConfig() {
|
|
135
|
+
try {
|
|
136
|
+
const project = await this.getProjectInfo();
|
|
137
|
+
if (!this.contractConfig) {
|
|
138
|
+
this.contractConfig = await (0, services_1.getAirdropContractConfig)({
|
|
139
|
+
chainId: project.chainId,
|
|
140
|
+
chainType: project.chainType,
|
|
141
|
+
contractAddress: project.contractAddress
|
|
142
|
+
}, this.endpoint);
|
|
143
|
+
}
|
|
144
|
+
return this.contractConfig;
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
console.error('Error fetching contract config:', error);
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
async getVersion() {
|
|
152
|
+
const config = await this.getContractConfig();
|
|
153
|
+
if (config?.version) {
|
|
154
|
+
return config.version;
|
|
146
155
|
}
|
|
147
|
-
|
|
156
|
+
const strategy = await this.getStrategy();
|
|
157
|
+
return strategy.getVersion();
|
|
148
158
|
}
|
|
149
159
|
async getPaused() {
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
throw new Error('EVM chain is not supported');
|
|
160
|
+
const config = await this.getContractConfig();
|
|
161
|
+
if (config && config?.paused !== null) {
|
|
162
|
+
return config.paused;
|
|
154
163
|
}
|
|
155
|
-
|
|
164
|
+
const strategy = await this.getStrategy();
|
|
165
|
+
if (!strategy.getPaused) {
|
|
166
|
+
throw new Error('getPaused is not supported for this chain');
|
|
167
|
+
}
|
|
168
|
+
return strategy.getPaused();
|
|
156
169
|
}
|
|
157
|
-
async
|
|
158
|
-
|
|
159
|
-
|
|
170
|
+
async getClaimFee(amount) {
|
|
171
|
+
const config = await this.getContractConfig();
|
|
172
|
+
if (config?.claimFee) {
|
|
173
|
+
return config.claimFee;
|
|
174
|
+
}
|
|
175
|
+
const strategy = await this.getStrategy();
|
|
176
|
+
if (!strategy.getClaimFee) {
|
|
177
|
+
throw new Error('getClaimFee is not supported for this chain');
|
|
160
178
|
}
|
|
161
|
-
|
|
162
|
-
this.cachedVersion = await contractWrapper?.getVersion();
|
|
163
|
-
return this.cachedVersion;
|
|
179
|
+
return strategy.getClaimFee(this.project?.contractAddress || '', amount || BigInt(0));
|
|
164
180
|
}
|
|
165
181
|
async batchCheckClaimed() {
|
|
166
|
-
const
|
|
167
|
-
if (
|
|
168
|
-
throw new Error('
|
|
182
|
+
const strategy = await this.getStrategy();
|
|
183
|
+
if (!strategy.batchCheckClaimed) {
|
|
184
|
+
throw new Error('batchCheckClaimed is not supported for this chain');
|
|
169
185
|
}
|
|
170
|
-
const contractWrapper = await this.getAirdropContractWrapper();
|
|
171
186
|
const leafs = this.claims?.map((it) => it.leaf);
|
|
172
187
|
if (!leafs)
|
|
173
188
|
return [];
|
|
174
|
-
return
|
|
189
|
+
return strategy.batchCheckClaimed(leafs);
|
|
175
190
|
}
|
|
176
191
|
async getNFT() {
|
|
177
|
-
const
|
|
178
|
-
if (
|
|
179
|
-
throw new Error('
|
|
192
|
+
const strategy = await this.getStrategy();
|
|
193
|
+
if (!strategy.getNFT) {
|
|
194
|
+
throw new Error('getNFT is not supported for this chain');
|
|
180
195
|
}
|
|
181
|
-
|
|
182
|
-
return contractWrapper.getNFT();
|
|
196
|
+
return strategy.getNFT();
|
|
183
197
|
}
|
|
184
198
|
async getKycThreshold() {
|
|
185
|
-
const
|
|
186
|
-
if (
|
|
187
|
-
throw new Error('
|
|
199
|
+
const strategy = await this.getStrategy();
|
|
200
|
+
if (!strategy.getKycThreshold) {
|
|
201
|
+
throw new Error('getKycThreshold is not supported for this chain');
|
|
188
202
|
}
|
|
189
|
-
|
|
190
|
-
return contractWrapper.getKycThreshold();
|
|
191
|
-
}
|
|
192
|
-
async getClaimFee(amount) {
|
|
193
|
-
const project = await this.getProjectInfo();
|
|
194
|
-
const contractWrapper = await this.getAirdropContractWrapper({});
|
|
195
|
-
return contractWrapper.getClaimFee(project.contractAddress, amount || BigInt(1));
|
|
203
|
+
return strategy.getKycThreshold();
|
|
196
204
|
}
|
|
197
205
|
}
|
|
198
206
|
exports.AirdropClient = AirdropClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/airdrop/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/airdrop/index.ts"],"names":[],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AQ,CAAC,eAAe,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,QAAQ,CAAC,eAAe,EAAE,CAAC;IACpC,CAAC;CACF;AAjPD,sCAiPC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IAirdropData, IProject } from '../types';
|
|
1
|
+
import { IAirdropData, IContractConfig, IProject } from '../types';
|
|
2
2
|
export { TonWalletService } from './wallet-service/ton';
|
|
3
3
|
export declare const getAirdropProject: (projectId: string, baseURL?: string) => Promise<IProject>;
|
|
4
4
|
export declare const getAirdropProjectId: (data: {
|
|
@@ -17,6 +17,11 @@ export declare const getAirdropQuery: (data: {
|
|
|
17
17
|
projectId: string;
|
|
18
18
|
recipientType: string;
|
|
19
19
|
}, baseURL?: string) => Promise<IAirdropData>;
|
|
20
|
+
export declare const getAirdropContractConfig: (data: {
|
|
21
|
+
chainId: string;
|
|
22
|
+
chainType: string;
|
|
23
|
+
contractAddress: string;
|
|
24
|
+
}, baseURL?: string) => Promise<IContractConfig>;
|
|
20
25
|
export declare const getJettonInfo: (data: {
|
|
21
26
|
address: string;
|
|
22
27
|
isTestnet: "true" | "false";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getJettonInfo = exports.getAirdropQuery = exports.getAirdropPro = exports.getAirdropProjectId = exports.getAirdropProject = exports.TonWalletService = void 0;
|
|
3
|
+
exports.getJettonInfo = exports.getAirdropContractConfig = exports.getAirdropQuery = exports.getAirdropPro = exports.getAirdropProjectId = exports.getAirdropProject = exports.TonWalletService = void 0;
|
|
4
4
|
const api_client_1 = require("../../utils/api-client");
|
|
5
5
|
const utils_1 = require("../../utils/utils");
|
|
6
6
|
var ton_1 = require("./wallet-service/ton");
|
|
@@ -36,6 +36,11 @@ const getAirdropQuery = async (data, baseURL) => {
|
|
|
36
36
|
return client.post(`/airdrop-open/query`, data);
|
|
37
37
|
};
|
|
38
38
|
exports.getAirdropQuery = getAirdropQuery;
|
|
39
|
+
const getAirdropContractConfig = async (data, baseURL) => {
|
|
40
|
+
const client = createApiClient(baseURL);
|
|
41
|
+
return client.post(`/airdrop-open/contract/config`, data);
|
|
42
|
+
};
|
|
43
|
+
exports.getAirdropContractConfig = getAirdropContractConfig;
|
|
39
44
|
const getJettonInfo = async (data, baseURL) => {
|
|
40
45
|
const client = createApiClient(baseURL);
|
|
41
46
|
return client.get(`/airdrop-open/jetton/${data.address}?isTestnet=${data.isTestnet}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/airdrop/services/index.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AACnD,6CAAkD;AAGlD,4CAAwD;AAA/C,uGAAA,gBAAgB,OAAA;AAEzB,MAAM,eAAe,GAAG,CAAC,OAAgB,EAAE,EAAE;IAC3C,OAAO,OAAO,CAAC,CAAC,CAAC,sBAAS,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,sBAAS,CAAC;AAC7D,CAAC,CAAC;AAEK,MAAM,iBAAiB,GAAG,KAAK,EAAE,SAAiB,EAAE,OAAgB,EAAqB,EAAE;IAChG,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,GAAG,CAAM,0BAA0B,SAAS,EAAE,CAAC,CAAC;IACzE,IAAI,CAAC,GAAG;QAAE,OAAO,GAAG,CAAC,CAAC,WAAW;IACjC,MAAM,aAAa,GAAG,GAAG,EAAE,SAAS,CAAC;IACrC,MAAM,cAAc,GAAG,IAAA,qBAAa,EAAC,aAAa,EAAE,cAAc,CAAC,CAAC;IACpE,OAAO;QACL,GAAG,GAAG;QACN,cAAc;KACf,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,iBAAiB,qBAU5B;A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AClD,CAAC,CAAC;AAVW,QAAA,eAAe,mBAU1B;AAEK,MAAM,wBAAwB,GAAG,KAAK,EAAE,IAAqE,EAAE,OAAgB,EAA4B,EAAE;IAClK,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IACxC,OAAO,MAAM,CAAC,IAAI,CAAC,+BAA+B,EAAE,IAAI,CAAC,CAAC;AAC5D,CAAC,CAAC;AAHW,QAAA,wBAAwB,4BAGnC;AAEK,MAAM,aAAa,GAAG,KAAK,EAChC,IAAsD,EACtD,OAAgB,EACF,EAAE;IAChB,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IACxC,OAAO,MAAM,CAAC,GAAG,CAAC,wBAAwB,IAAI,CAAC,OAAO,cAAc,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;AACxF,CAAC,CAAC;AANW,QAAA,aAAa,iBAMxB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ChainType, IWalletClient } from '../types';
|
|
2
|
+
import { IAirdropStrategy } from './IAirdropStrategy';
|
|
3
|
+
import { TonClient } from '@ton/ton';
|
|
4
|
+
export declare class AirdropStrategyFactory {
|
|
5
|
+
private static strategyMap;
|
|
6
|
+
static createStrategy(params: {
|
|
7
|
+
chainType: ChainType;
|
|
8
|
+
contractAddress: string;
|
|
9
|
+
chainId: string | number;
|
|
10
|
+
walletClient?: IWalletClient;
|
|
11
|
+
tonClient?: TonClient;
|
|
12
|
+
}): IAirdropStrategy;
|
|
13
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AirdropStrategyFactory = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
const EvmAirdropStrategy_1 = require("./EvmAirdropStrategy");
|
|
6
|
+
const TonAirdropStrategy_1 = require("./TonAirdropStrategy");
|
|
7
|
+
class AirdropStrategyFactory {
|
|
8
|
+
static strategyMap = {
|
|
9
|
+
[types_1.ChainType.Evm]: EvmAirdropStrategy_1.EvmAirdropStrategy,
|
|
10
|
+
[types_1.ChainType.Ton]: TonAirdropStrategy_1.TonAirdropStrategy
|
|
11
|
+
};
|
|
12
|
+
static createStrategy(params) {
|
|
13
|
+
const { chainType, ...strategyParams } = params;
|
|
14
|
+
const StrategyClass = this.strategyMap[chainType];
|
|
15
|
+
if (!StrategyClass) {
|
|
16
|
+
throw new Error(`Unsupported chain type: ${chainType}`);
|
|
17
|
+
}
|
|
18
|
+
return new StrategyClass(strategyParams);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.AirdropStrategyFactory = AirdropStrategyFactory;
|
|
22
|
+
//# sourceMappingURL=AirdropStrategyFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AirdropStrategyFactory.js","sourceRoot":"","sources":["../../../../src/airdrop/strategies/AirdropStrategyFactory.ts"],"names":[],"mappings":";;;AAAA,oCAAoD;AACpD,6DAA0D;AAE1D,6DAA0D;AAG1D,MAAa,sBAAsB;IACzB,MAAM,CAAC,WAAW,GAAmD;QAC3E,CAAC,iBAAS,CAAC,GAAG,CAAC,EAAE,uCAAkB;QACnC,CAAC,iBAAS,CAAC,GAAG,CAAC,EAAE,uCAAkB;KACpC,CAAC;IAEF,MAAM,CAAC,cAAc,CAAC,MAMrB;QACC,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,EAAE,GAAG,MAAM,CAAC;QAChD,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QAElD,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,2BAA2B,SAAS,EAAE,CAAC,CAAC;QAC1D,CAAC;QAED,OAAO,IAAI,aAAa,CAAC,cAAc,CAAC,CAAC;IAC3C,CAAC;;AArBH,wDAsBC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { IWalletClient } from '../types';
|
|
2
|
+
import { IAirdropStrategy } from './IAirdropStrategy';
|
|
3
|
+
export declare class EvmAirdropStrategy implements IAirdropStrategy {
|
|
4
|
+
private service;
|
|
5
|
+
private readonly contractAddress;
|
|
6
|
+
private readonly chainId;
|
|
7
|
+
private walletClient?;
|
|
8
|
+
private cachedVersion;
|
|
9
|
+
constructor(params: {
|
|
10
|
+
contractAddress: string;
|
|
11
|
+
chainId: string | number;
|
|
12
|
+
walletClient?: IWalletClient;
|
|
13
|
+
});
|
|
14
|
+
initialize(walletClient?: IWalletClient): Promise<void>;
|
|
15
|
+
isInitialized(): boolean;
|
|
16
|
+
getVersion(): Promise<string>;
|
|
17
|
+
claim(claimData: any): Promise<any>;
|
|
18
|
+
checkClaimed(claimData: any): Promise<boolean>;
|
|
19
|
+
batchCheckClaimed(leafs: string[]): Promise<{
|
|
20
|
+
result: boolean;
|
|
21
|
+
status: string;
|
|
22
|
+
}[]>;
|
|
23
|
+
getNFT(): Promise<string>;
|
|
24
|
+
getKycThreshold(): Promise<bigint>;
|
|
25
|
+
getClaimFee(contractAddress: string, amount: bigint): Promise<bigint>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EvmAirdropStrategy = void 0;
|
|
4
|
+
const AirdropService_1 = require("../core/evm/AirdropService");
|
|
5
|
+
class EvmAirdropStrategy {
|
|
6
|
+
service;
|
|
7
|
+
contractAddress;
|
|
8
|
+
chainId;
|
|
9
|
+
walletClient;
|
|
10
|
+
cachedVersion = null;
|
|
11
|
+
constructor(params) {
|
|
12
|
+
this.contractAddress = params.contractAddress;
|
|
13
|
+
this.chainId = Number(params.chainId);
|
|
14
|
+
if (params.walletClient) {
|
|
15
|
+
this.walletClient = params.walletClient;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
async initialize(walletClient) {
|
|
19
|
+
if (walletClient) {
|
|
20
|
+
this.walletClient = walletClient;
|
|
21
|
+
}
|
|
22
|
+
this.service = new AirdropService_1.AirdropService({
|
|
23
|
+
contractAddress: this.contractAddress,
|
|
24
|
+
chainId: this.chainId,
|
|
25
|
+
walletClient: this.walletClient
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
isInitialized() {
|
|
29
|
+
return !!this.service;
|
|
30
|
+
}
|
|
31
|
+
async getVersion() {
|
|
32
|
+
if (this.cachedVersion) {
|
|
33
|
+
return this.cachedVersion;
|
|
34
|
+
}
|
|
35
|
+
if (!this.service)
|
|
36
|
+
throw new Error('Strategy not initialized');
|
|
37
|
+
this.cachedVersion = await this.service.getVersion();
|
|
38
|
+
return this.cachedVersion;
|
|
39
|
+
}
|
|
40
|
+
async claim(claimData) {
|
|
41
|
+
if (!this.service)
|
|
42
|
+
throw new Error('Strategy not initialized');
|
|
43
|
+
const { proof, group, data, value, extraData } = claimData;
|
|
44
|
+
return this.service.claim({
|
|
45
|
+
proof,
|
|
46
|
+
group,
|
|
47
|
+
data,
|
|
48
|
+
value,
|
|
49
|
+
extraData
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async checkClaimed(claimData) {
|
|
53
|
+
if (!this.service)
|
|
54
|
+
throw new Error('Strategy not initialized');
|
|
55
|
+
return this.service.isLeafUsed(claimData.leaf);
|
|
56
|
+
}
|
|
57
|
+
async batchCheckClaimed(leafs) {
|
|
58
|
+
if (!this.service)
|
|
59
|
+
throw new Error('Strategy not initialized');
|
|
60
|
+
return this.service.batchFetchClaimed(leafs);
|
|
61
|
+
}
|
|
62
|
+
async getNFT() {
|
|
63
|
+
if (!this.service)
|
|
64
|
+
throw new Error('Strategy not initialized');
|
|
65
|
+
return this.service.getNFT();
|
|
66
|
+
}
|
|
67
|
+
async getKycThreshold() {
|
|
68
|
+
if (!this.service)
|
|
69
|
+
throw new Error('Strategy not initialized');
|
|
70
|
+
return this.service.getKycThreshold();
|
|
71
|
+
}
|
|
72
|
+
async getClaimFee(contractAddress, amount) {
|
|
73
|
+
if (!this.service)
|
|
74
|
+
throw new Error('Strategy not initialized');
|
|
75
|
+
return this.service.getClaimFee(contractAddress, amount);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.EvmAirdropStrategy = EvmAirdropStrategy;
|
|
79
|
+
//# sourceMappingURL=EvmAirdropStrategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EvmAirdropStrategy.js","sourceRoot":"","sources":["../../../../src/airdrop/strategies/EvmAirdropStrategy.ts"],"names":[],"mappings":";;;AAAA,+DAAiF;AAKjF,MAAa,kBAAkB;IACrB,OAAO,CAAgC;IAC9B,eAAe,CAAS;IACxB,OAAO,CAAU;IAC1B,YAAY,CAAoB;IAChC,aAAa,GAAkB,IAAI,CAAC;IAE5C,YAAY,MAIX;QACC,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC;QAC9C,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAY,CAAC;QACjD,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YACxB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAgC,CAAC;QAC9D,CAAC;IACH,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,YAA4B;QAC3C,IAAI,YAAY,EAAE,CAAC;YACjB,IAAI,CAAC,YAAY,GAAG,YAAgC,CAAC;QACvD,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,+BAAiB,CAAC;YACnC,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC,CAAC;IACL,CAAC;IAED,aAAa;QACX,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,UAAU;QACd,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC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IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,eAAuB,EAAE,MAAc;QACvD,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,eAAe,EAAE,MAAM,CAAsB,CAAC;IAChF,CAAC;CACF;AA/ED,gDA+EC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { IWalletClient } from '../types';
|
|
2
|
+
import { TonClient } from '@ton/ton';
|
|
3
|
+
export interface IAirdropStrategy {
|
|
4
|
+
getVersion(): Promise<string>;
|
|
5
|
+
claim(claimData: any, options?: {
|
|
6
|
+
onLoading?: () => void;
|
|
7
|
+
}): Promise<any>;
|
|
8
|
+
checkClaimed(claimData: any): Promise<boolean>;
|
|
9
|
+
isInitialized(): boolean;
|
|
10
|
+
initialize(walletClient?: IWalletClient): Promise<void>;
|
|
11
|
+
getPaused?(): Promise<boolean>;
|
|
12
|
+
batchCheckClaimed?(leafs: string[]): Promise<Array<{
|
|
13
|
+
result: boolean;
|
|
14
|
+
status: string;
|
|
15
|
+
}>>;
|
|
16
|
+
getNFT?(): Promise<string>;
|
|
17
|
+
getKycThreshold?(): Promise<bigint>;
|
|
18
|
+
getClaimFee?(contractAddress: string, amount: bigint): Promise<string | bigint>;
|
|
19
|
+
}
|
|
20
|
+
export interface IAirdropStrategyConstructor {
|
|
21
|
+
new (params: {
|
|
22
|
+
contractAddress: string;
|
|
23
|
+
chainId: string | number;
|
|
24
|
+
walletClient?: IWalletClient;
|
|
25
|
+
tonClient?: TonClient;
|
|
26
|
+
}): IAirdropStrategy;
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IAirdropStrategy.js","sourceRoot":"","sources":["../../../../src/airdrop/strategies/IAirdropStrategy.ts"],"names":[],"mappings":""}
|