@sign-global/tokentable 0.0.5 → 0.0.6
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 +115 -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 +117 -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 +140 -139
- 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
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IAirdropStrategy } from './IAirdropStrategy';
|
|
2
|
+
export declare class StrategyCache {
|
|
3
|
+
private readOnlyStrategies;
|
|
4
|
+
private walletStrategies;
|
|
5
|
+
private getCacheKey;
|
|
6
|
+
getStrategy(contractAddress: string, chainId: string | number, chainType: string, hasWallet?: boolean): IAirdropStrategy | undefined;
|
|
7
|
+
setStrategy(contractAddress: string, chainId: string | number, chainType: string, strategy: IAirdropStrategy, hasWallet?: boolean): void;
|
|
8
|
+
clearStrategy(contractAddress: string, chainId: string | number, chainType: string, hasWallet?: boolean): void;
|
|
9
|
+
}
|
|
10
|
+
export declare const strategyCache: StrategyCache;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.strategyCache = exports.StrategyCache = void 0;
|
|
4
|
+
class StrategyCache {
|
|
5
|
+
readOnlyStrategies = new Map();
|
|
6
|
+
walletStrategies = new Map();
|
|
7
|
+
getCacheKey(contractAddress, chainId, chainType) {
|
|
8
|
+
return `${chainType}:${contractAddress}:${chainId}`;
|
|
9
|
+
}
|
|
10
|
+
getStrategy(contractAddress, chainId, chainType, hasWallet = false) {
|
|
11
|
+
const cache = hasWallet ? this.walletStrategies : this.readOnlyStrategies;
|
|
12
|
+
const cacheKey = this.getCacheKey(contractAddress, chainId, chainType);
|
|
13
|
+
return cache.get(cacheKey);
|
|
14
|
+
}
|
|
15
|
+
setStrategy(contractAddress, chainId, chainType, strategy, hasWallet = false) {
|
|
16
|
+
const cache = hasWallet ? this.walletStrategies : this.readOnlyStrategies;
|
|
17
|
+
const cacheKey = this.getCacheKey(contractAddress, chainId, chainType);
|
|
18
|
+
cache.set(cacheKey, strategy);
|
|
19
|
+
}
|
|
20
|
+
clearStrategy(contractAddress, chainId, chainType, hasWallet) {
|
|
21
|
+
const cacheKey = this.getCacheKey(contractAddress, chainId, chainType);
|
|
22
|
+
if (hasWallet === undefined || hasWallet) {
|
|
23
|
+
this.walletStrategies.delete(cacheKey);
|
|
24
|
+
}
|
|
25
|
+
if (hasWallet === undefined || !hasWallet) {
|
|
26
|
+
this.readOnlyStrategies.delete(cacheKey);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.StrategyCache = StrategyCache;
|
|
31
|
+
exports.strategyCache = new StrategyCache();
|
|
32
|
+
//# sourceMappingURL=StrategyCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StrategyCache.js","sourceRoot":"","sources":["../../../../src/airdrop/strategies/StrategyCache.ts"],"names":[],"mappings":";;;AAEA,MAAa,aAAa;IAChB,kBAAkB,GAAkC,IAAI,GAAG,EAAE,CAAC;IAC9D,gBAAgB,GAAkC,IAAI,GAAG,EAAE,CAAC;IAE5D,WAAW,CAAC,eAAuB,EAAE,OAAwB,EAAE,SAAiB;QACtF,OAAO,GAAG,SAAS,IAAI,eAAe,IAAI,OAAO,EAAE,CAAC;IACtD,CAAC;IAED,WAAW,CAAC,eAAuB,EAAE,OAAwB,EAAE,SAAiB,EAAE,YAAqB,KAAK;QAC1G,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC;QAC1E,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QACvE,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;IAED,WAAW,CAAC,eAAuB,EAAE,OAAwB,EAAE,SAAiB,EAAE,QAA0B,EAAE,YAAqB,KAAK;QACtI,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC;QAC1E,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QACvE,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAChC,CAAC;IAED,aAAa,CAAC,eAAuB,EAAE,OAAwB,EAAE,SAAiB,EAAE,SAAmB;QACrG,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QACvE,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,EAAE,CAAC;YACzC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACzC,CAAC;QACD,IAAI,SAAS,KAAK,SAAS,IAAI,CAAC,SAAS,EAAE,CAAC;YAC1C,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;CACF;AA7BD,sCA6BC;AAEY,QAAA,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { TonClient } from '@ton/ton';
|
|
2
|
+
import { IWalletClient } from '../types';
|
|
3
|
+
import { IAirdropStrategy } from './IAirdropStrategy';
|
|
4
|
+
export declare class TonAirdropStrategy implements IAirdropStrategy {
|
|
5
|
+
private service;
|
|
6
|
+
private readonly contractAddress;
|
|
7
|
+
private readonly chainId;
|
|
8
|
+
private readonly tonClient?;
|
|
9
|
+
private walletClient?;
|
|
10
|
+
private cachedVersion;
|
|
11
|
+
constructor(params: {
|
|
12
|
+
contractAddress: string;
|
|
13
|
+
chainId: string | number;
|
|
14
|
+
walletClient?: IWalletClient;
|
|
15
|
+
tonClient?: TonClient;
|
|
16
|
+
});
|
|
17
|
+
initialize(walletClient?: IWalletClient): Promise<void>;
|
|
18
|
+
isInitialized(): boolean;
|
|
19
|
+
getVersion(): Promise<string>;
|
|
20
|
+
claim(claimData: any, options?: {
|
|
21
|
+
onLoading?: () => void;
|
|
22
|
+
}): Promise<any>;
|
|
23
|
+
checkClaimed(claimData: any): Promise<boolean>;
|
|
24
|
+
getPaused(): Promise<boolean>;
|
|
25
|
+
getClaimFee(contractAddress: string, amount: bigint): Promise<string>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TonAirdropStrategy = void 0;
|
|
4
|
+
const AirdropService_1 = require("../core/ton/AirdropService");
|
|
5
|
+
class TonAirdropStrategy {
|
|
6
|
+
service;
|
|
7
|
+
contractAddress;
|
|
8
|
+
chainId;
|
|
9
|
+
tonClient;
|
|
10
|
+
walletClient;
|
|
11
|
+
cachedVersion = null;
|
|
12
|
+
constructor(params) {
|
|
13
|
+
this.contractAddress = params.contractAddress;
|
|
14
|
+
this.chainId = params.chainId.toString();
|
|
15
|
+
this.tonClient = params.tonClient;
|
|
16
|
+
if (params.walletClient) {
|
|
17
|
+
this.walletClient = params.walletClient;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async initialize(walletClient) {
|
|
21
|
+
if (walletClient) {
|
|
22
|
+
this.walletClient = walletClient;
|
|
23
|
+
}
|
|
24
|
+
this.service = new AirdropService_1.AirdropService({
|
|
25
|
+
address: this.contractAddress,
|
|
26
|
+
chainId: this.chainId,
|
|
27
|
+
walletClient: this.walletClient,
|
|
28
|
+
tonClient: this.tonClient
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
isInitialized() {
|
|
32
|
+
return !!this.service;
|
|
33
|
+
}
|
|
34
|
+
async getVersion() {
|
|
35
|
+
if (!this.service)
|
|
36
|
+
throw new Error('Strategy not initialized');
|
|
37
|
+
if (!this.cachedVersion) {
|
|
38
|
+
this.cachedVersion = await this.service.getVersion();
|
|
39
|
+
}
|
|
40
|
+
return this.cachedVersion;
|
|
41
|
+
}
|
|
42
|
+
async claim(claimData, options) {
|
|
43
|
+
if (!this.service)
|
|
44
|
+
throw new Error('Strategy not initialized');
|
|
45
|
+
return this.service.claim(claimData, options);
|
|
46
|
+
}
|
|
47
|
+
async checkClaimed(claimData) {
|
|
48
|
+
if (!this.service)
|
|
49
|
+
throw new Error('Strategy not initialized');
|
|
50
|
+
return this.service.checkClaimed(claimData);
|
|
51
|
+
}
|
|
52
|
+
async getPaused() {
|
|
53
|
+
if (!this.service)
|
|
54
|
+
throw new Error('Strategy not initialized');
|
|
55
|
+
return this.service.getPaused();
|
|
56
|
+
}
|
|
57
|
+
async getClaimFee(contractAddress, amount) {
|
|
58
|
+
if (!this.service)
|
|
59
|
+
throw new Error('Strategy not initialized');
|
|
60
|
+
return this.service.getClaimFee(contractAddress, amount);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.TonAirdropStrategy = TonAirdropStrategy;
|
|
64
|
+
//# sourceMappingURL=TonAirdropStrategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TonAirdropStrategy.js","sourceRoot":"","sources":["../../../../src/airdrop/strategies/TonAirdropStrategy.ts"],"names":[],"mappings":";;;AAEA,+DAAiF;AAIjF,MAAa,kBAAkB;IACrB,OAAO,CAAgC;IAC9B,eAAe,CAAS;IACxB,OAAO,CAAS;IAChB,SAAS,CAAa;IAC/B,YAAY,CAAgB;IAC5B,aAAa,GAAkB,IAAI,CAAC;IAE5C,YAAY,MAKX;QACC,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC;QAC9C,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACzC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;QAClC,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YACxB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAA4B,CAAC;QAC1D,CAAC;IACH,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,YAA4B;QAC3C,IAAI,YAAY,EAAE,CAAC;YACjB,IAAI,CAAC,YAAY,GAAG,YAA4B,CAAC;QACnD,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,+BAAiB,CAAC;YACnC,OAAO,EAAE,IAAI,CAAC,eAAe;YAC7B,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/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AAM,CAAC,CAAC;IAC3D,CAAC;CACF;AAjED,gDAiEC"}
|
|
@@ -114,4 +114,9 @@ type SlugOptions = BaseAirdropOptions & {
|
|
|
114
114
|
projectId?: never;
|
|
115
115
|
};
|
|
116
116
|
export type IAirdropOptions = ProjectIdOptions | SlugOptions;
|
|
117
|
+
export interface IContractConfig {
|
|
118
|
+
version?: string | null;
|
|
119
|
+
paused: boolean | null;
|
|
120
|
+
claimFee?: string | null;
|
|
121
|
+
}
|
|
117
122
|
export {};
|
|
@@ -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,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { getAirdropPro, getAirdropProject, getAirdropQuery } from './services';
|
|
4
|
-
import { ChainType, ETokenType, EvmAirdropVersionEnum } from './types';
|
|
1
|
+
import { getAirdropPro, getAirdropProject, getAirdropQuery, getAirdropContractConfig } from './services';
|
|
2
|
+
import { ChainType } from './types';
|
|
5
3
|
import { getTonProjectIdByAddress } from './common';
|
|
4
|
+
import { AirdropStrategyFactory } from './strategies/AirdropStrategyFactory';
|
|
5
|
+
import { strategyCache } from './strategies/StrategyCache';
|
|
6
6
|
export class AirdropClient {
|
|
7
7
|
tonClient;
|
|
8
8
|
slug;
|
|
@@ -10,11 +10,9 @@ export class AirdropClient {
|
|
|
10
10
|
endpoint;
|
|
11
11
|
project;
|
|
12
12
|
claims;
|
|
13
|
-
contractInstanceWithWallet;
|
|
14
|
-
contractInstanceWithoutWallet;
|
|
15
13
|
projectPromise;
|
|
16
14
|
claimHook;
|
|
17
|
-
|
|
15
|
+
contractConfig = null;
|
|
18
16
|
constructor(params) {
|
|
19
17
|
if ('slug' in params) {
|
|
20
18
|
this.slug = params.slug;
|
|
@@ -24,20 +22,36 @@ export class AirdropClient {
|
|
|
24
22
|
this.endpoint = params.endpoint;
|
|
25
23
|
this.projectPromise = this.initializeProjects();
|
|
26
24
|
}
|
|
25
|
+
async fetchProjectFromSlug(address) {
|
|
26
|
+
if (!this.slug)
|
|
27
|
+
return undefined;
|
|
28
|
+
const res = await getAirdropPro(this.slug, this.endpoint);
|
|
29
|
+
const projectMap = res?.childProjectMapping || {};
|
|
30
|
+
return getTonProjectIdByAddress({
|
|
31
|
+
address,
|
|
32
|
+
slug: this.slug,
|
|
33
|
+
data: projectMap
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async fetchProjectDetails(projectId) {
|
|
37
|
+
this.project = await getAirdropProject(projectId, this.endpoint);
|
|
38
|
+
}
|
|
27
39
|
async initializeProjects(address) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
|
|
40
|
+
try {
|
|
41
|
+
let projectId = this.projectId;
|
|
42
|
+
// If slug is provided, try to fetch project ID from slug
|
|
43
|
+
if (!projectId) {
|
|
44
|
+
projectId = await this.fetchProjectFromSlug(address);
|
|
45
|
+
}
|
|
46
|
+
if (!projectId) {
|
|
47
|
+
throw new Error('Project ID is required and could not be determined');
|
|
36
48
|
}
|
|
49
|
+
// Fetch project details
|
|
50
|
+
await this.fetchProjectDetails(projectId);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
throw new Error(`Failed to initialize project: ${error.message}`);
|
|
37
54
|
}
|
|
38
|
-
if (!projectId)
|
|
39
|
-
throw new Error('Project ID is required');
|
|
40
|
-
this.project = await getAirdropProject(projectId, this.endpoint);
|
|
41
55
|
}
|
|
42
56
|
async getProjectInfo() {
|
|
43
57
|
await this.projectPromise;
|
|
@@ -60,42 +74,30 @@ export class AirdropClient {
|
|
|
60
74
|
this.claims = claimsRes;
|
|
61
75
|
return this.claims;
|
|
62
76
|
}
|
|
63
|
-
async
|
|
77
|
+
async getStrategy(walletClient) {
|
|
64
78
|
const project = await this.getProjectInfo();
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const instance = project.chainType === ChainType.Evm
|
|
86
|
-
? new EvmAirdropService({
|
|
87
|
-
contractAddress: project.contractAddress,
|
|
88
|
-
chainId: Number(project.chainId)
|
|
89
|
-
})
|
|
90
|
-
: new TonAirdropService({
|
|
91
|
-
chainId: project.chainId.toString(),
|
|
92
|
-
address: project.contractAddress,
|
|
93
|
-
tonClient: this.tonClient
|
|
94
|
-
});
|
|
95
|
-
this.contractInstanceWithoutWallet = instance;
|
|
96
|
-
}
|
|
97
|
-
return this.contractInstanceWithoutWallet;
|
|
79
|
+
const hasWallet = !!walletClient;
|
|
80
|
+
// Try to get cached strategy
|
|
81
|
+
let strategy = strategyCache.getStrategy(project.contractAddress, project.chainId, project.chainType, hasWallet);
|
|
82
|
+
if (!strategy) {
|
|
83
|
+
// Create new strategy if not cached
|
|
84
|
+
strategy = AirdropStrategyFactory.createStrategy({
|
|
85
|
+
chainType: project.chainType,
|
|
86
|
+
contractAddress: project.contractAddress,
|
|
87
|
+
chainId: project.chainId,
|
|
88
|
+
walletClient,
|
|
89
|
+
tonClient: this.tonClient
|
|
90
|
+
});
|
|
91
|
+
// Initialize the strategy
|
|
92
|
+
await strategy.initialize(walletClient);
|
|
93
|
+
// Cache the initialized strategy
|
|
94
|
+
strategyCache.setStrategy(project.contractAddress, project.chainId, project.chainType, strategy, hasWallet);
|
|
95
|
+
}
|
|
96
|
+
else if (hasWallet) {
|
|
97
|
+
// If we have a wallet and the strategy exists, just initialize with the new wallet
|
|
98
|
+
await strategy.initialize(walletClient);
|
|
98
99
|
}
|
|
100
|
+
return strategy;
|
|
99
101
|
}
|
|
100
102
|
getClaimDataById(claimId) {
|
|
101
103
|
const claimData = this.claims?.find((it) => it.claimId === claimId);
|
|
@@ -108,88 +110,91 @@ export class AirdropClient {
|
|
|
108
110
|
}
|
|
109
111
|
async claimAirdrop({ claimId, walletClient }, options) {
|
|
110
112
|
const claimData = this.getClaimDataById(claimId);
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
[EvmAirdropVersionEnum.V3, EvmAirdropVersionEnum.V4].includes(version));
|
|
119
|
-
const value = needsFeeData ? await this.getClaimFee(BigInt(claimData.amount)) : undefined;
|
|
120
|
-
let extraData = {
|
|
121
|
-
isLegacy: true,
|
|
122
|
-
attestationId: BigInt(1)
|
|
123
|
-
};
|
|
124
|
-
if (this.claimHook) {
|
|
125
|
-
extraData = this.claimHook(claimData);
|
|
126
|
-
}
|
|
127
|
-
return contractWrapper.claim({
|
|
128
|
-
proof: claimData.proof,
|
|
129
|
-
group: claimData.group,
|
|
130
|
-
data: claimData.data,
|
|
131
|
-
value: value,
|
|
132
|
-
extraData: extraData
|
|
133
|
-
});
|
|
113
|
+
const strategy = await this.getStrategy(walletClient);
|
|
114
|
+
let extraData = {
|
|
115
|
+
isLegacy: true,
|
|
116
|
+
attestationId: BigInt(0)
|
|
117
|
+
};
|
|
118
|
+
if (this.claimHook) {
|
|
119
|
+
extraData = this.claimHook(claimData);
|
|
134
120
|
}
|
|
135
|
-
return
|
|
121
|
+
return strategy.claim(claimData, options);
|
|
136
122
|
}
|
|
137
123
|
async checkClaimed(claimId) {
|
|
138
124
|
const claimData = this.getClaimDataById(claimId);
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
125
|
+
const strategy = await this.getStrategy();
|
|
126
|
+
return strategy.checkClaimed(claimData);
|
|
127
|
+
}
|
|
128
|
+
async getContractConfig() {
|
|
129
|
+
try {
|
|
130
|
+
const project = await this.getProjectInfo();
|
|
131
|
+
if (!this.contractConfig) {
|
|
132
|
+
this.contractConfig = await getAirdropContractConfig({
|
|
133
|
+
chainId: project.chainId,
|
|
134
|
+
chainType: project.chainType,
|
|
135
|
+
contractAddress: project.contractAddress
|
|
136
|
+
}, this.endpoint);
|
|
137
|
+
}
|
|
138
|
+
return this.contractConfig;
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
console.error('Error fetching contract config:', error);
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
async getVersion() {
|
|
146
|
+
const config = await this.getContractConfig();
|
|
147
|
+
if (config?.version) {
|
|
148
|
+
return config.version;
|
|
143
149
|
}
|
|
144
|
-
|
|
150
|
+
const strategy = await this.getStrategy();
|
|
151
|
+
return strategy.getVersion();
|
|
145
152
|
}
|
|
146
153
|
async getPaused() {
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
throw new Error('EVM chain is not supported');
|
|
154
|
+
const config = await this.getContractConfig();
|
|
155
|
+
if (config && config?.paused !== null) {
|
|
156
|
+
return config.paused;
|
|
151
157
|
}
|
|
152
|
-
|
|
158
|
+
const strategy = await this.getStrategy();
|
|
159
|
+
if (!strategy.getPaused) {
|
|
160
|
+
throw new Error('getPaused is not supported for this chain');
|
|
161
|
+
}
|
|
162
|
+
return strategy.getPaused();
|
|
153
163
|
}
|
|
154
|
-
async
|
|
155
|
-
|
|
156
|
-
|
|
164
|
+
async getClaimFee(amount) {
|
|
165
|
+
const config = await this.getContractConfig();
|
|
166
|
+
if (config?.claimFee) {
|
|
167
|
+
return config.claimFee;
|
|
168
|
+
}
|
|
169
|
+
const strategy = await this.getStrategy();
|
|
170
|
+
if (!strategy.getClaimFee) {
|
|
171
|
+
throw new Error('getClaimFee is not supported for this chain');
|
|
157
172
|
}
|
|
158
|
-
|
|
159
|
-
this.cachedVersion = await contractWrapper?.getVersion();
|
|
160
|
-
return this.cachedVersion;
|
|
173
|
+
return strategy.getClaimFee(this.project?.contractAddress || '', amount || BigInt(0));
|
|
161
174
|
}
|
|
162
175
|
async batchCheckClaimed() {
|
|
163
|
-
const
|
|
164
|
-
if (
|
|
165
|
-
throw new Error('
|
|
176
|
+
const strategy = await this.getStrategy();
|
|
177
|
+
if (!strategy.batchCheckClaimed) {
|
|
178
|
+
throw new Error('batchCheckClaimed is not supported for this chain');
|
|
166
179
|
}
|
|
167
|
-
const contractWrapper = await this.getAirdropContractWrapper();
|
|
168
180
|
const leafs = this.claims?.map((it) => it.leaf);
|
|
169
181
|
if (!leafs)
|
|
170
182
|
return [];
|
|
171
|
-
return
|
|
183
|
+
return strategy.batchCheckClaimed(leafs);
|
|
172
184
|
}
|
|
173
185
|
async getNFT() {
|
|
174
|
-
const
|
|
175
|
-
if (
|
|
176
|
-
throw new Error('
|
|
186
|
+
const strategy = await this.getStrategy();
|
|
187
|
+
if (!strategy.getNFT) {
|
|
188
|
+
throw new Error('getNFT is not supported for this chain');
|
|
177
189
|
}
|
|
178
|
-
|
|
179
|
-
return contractWrapper.getNFT();
|
|
190
|
+
return strategy.getNFT();
|
|
180
191
|
}
|
|
181
192
|
async getKycThreshold() {
|
|
182
|
-
const
|
|
183
|
-
if (
|
|
184
|
-
throw new Error('
|
|
193
|
+
const strategy = await this.getStrategy();
|
|
194
|
+
if (!strategy.getKycThreshold) {
|
|
195
|
+
throw new Error('getKycThreshold is not supported for this chain');
|
|
185
196
|
}
|
|
186
|
-
|
|
187
|
-
return contractWrapper.getKycThreshold();
|
|
188
|
-
}
|
|
189
|
-
async getClaimFee(amount) {
|
|
190
|
-
const project = await this.getProjectInfo();
|
|
191
|
-
const contractWrapper = await this.getAirdropContractWrapper({});
|
|
192
|
-
return contractWrapper.getClaimFee(project.contractAddress, amount || BigInt(1));
|
|
197
|
+
return strategy.getKycThreshold();
|
|
193
198
|
}
|
|
194
199
|
}
|
|
195
200
|
//# sourceMappingURL=index.js.map
|
|
@@ -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":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACzG,OAAO,EACL,SAAS,EAMV,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAE7E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,OAAO,aAAa;IAChB,SAAS,CAAa;IACtB,IAAI,CAAU;IACd,SAAS,CAAU;IACnB,QAAQ,CAAU;IAClB,OAAO,CAAuB;IAC5B,MAAM,CAAmB;IAC3B,cAAc,CAA4B;IAC1C,SAAS,CAAgC;IACzC,cAAc,GAA2B,IAAI,CAAC;IAEtD,YAAY,MAAuB;QACjC,IAAI,MAAM,IAAI,MAAM,EAAE,CAAC;YACrB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QAC1B,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,kBA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,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;QAChD,IAAI,CAAC,KAAK;YAAE,OAAO,EAAE,CAAC;QACtB,OAAO,QAAQ,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;QAC1C,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;QAC1C,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,QAAQ,CAAC,eAAe,EAAE,CAAC;IACpC,CAAC;CACF"}
|
|
@@ -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";
|
|
@@ -28,6 +28,10 @@ export const getAirdropQuery = async (data, baseURL) => {
|
|
|
28
28
|
const client = createApiClient(baseURL);
|
|
29
29
|
return client.post(`/airdrop-open/query`, data);
|
|
30
30
|
};
|
|
31
|
+
export const getAirdropContractConfig = async (data, baseURL) => {
|
|
32
|
+
const client = createApiClient(baseURL);
|
|
33
|
+
return client.post(`/airdrop-open/contract/config`, data);
|
|
34
|
+
};
|
|
31
35
|
export const getJettonInfo = async (data, baseURL) => {
|
|
32
36
|
const client = createApiClient(baseURL);
|
|
33
37
|
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,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,eAAe,GAAG,CAAC,OAAgB,EAAE,EAAE;IAC3C,OAAO,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7D,CAAC,CAAC;AAEF,MAAM,CAAC,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,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AAG,eAAe,CAAC,OAAO,CAAC,CAAC;IACxC,OAAO,MAAM,CAAC,IAAI,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC;AAClD,CAAC,CAAC;AAEF,MAAM,CAAC,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;AAEF,MAAM,CAAC,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"}
|
|
@@ -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,18 @@
|
|
|
1
|
+
import { ChainType } from '../types';
|
|
2
|
+
import { EvmAirdropStrategy } from './EvmAirdropStrategy';
|
|
3
|
+
import { TonAirdropStrategy } from './TonAirdropStrategy';
|
|
4
|
+
export class AirdropStrategyFactory {
|
|
5
|
+
static strategyMap = {
|
|
6
|
+
[ChainType.Evm]: EvmAirdropStrategy,
|
|
7
|
+
[ChainType.Ton]: TonAirdropStrategy
|
|
8
|
+
};
|
|
9
|
+
static createStrategy(params) {
|
|
10
|
+
const { chainType, ...strategyParams } = params;
|
|
11
|
+
const StrategyClass = this.strategyMap[chainType];
|
|
12
|
+
if (!StrategyClass) {
|
|
13
|
+
throw new Error(`Unsupported chain type: ${chainType}`);
|
|
14
|
+
}
|
|
15
|
+
return new StrategyClass(strategyParams);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=AirdropStrategyFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AirdropStrategyFactory.js","sourceRoot":"","sources":["../../../../src/airdrop/strategies/AirdropStrategyFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAiB,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,MAAM,OAAO,sBAAsB;IACzB,MAAM,CAAC,WAAW,GAAmD;QAC3E,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,kBAAkB;QACnC,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,kBAAkB;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"}
|