@sign-global/tokentable 0.4.0-beta.2 → 0.4.0-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/SignatureAirdropClient.d.ts +12 -4
- package/dist/cjs/airdrop/SignatureAirdropClient.js +63 -17
- package/dist/cjs/airdrop/SignatureAirdropClient.js.map +1 -1
- package/dist/cjs/airdrop/core/evm/SignatureAirdropService.d.ts +22 -0
- package/dist/cjs/airdrop/core/evm/SignatureAirdropService.js +68 -0
- package/dist/cjs/airdrop/core/evm/SignatureAirdropService.js.map +1 -0
- package/dist/cjs/airdrop/core/evm/contracts/AirdropSignatureClient.d.ts +2 -2
- package/dist/cjs/airdrop/core/evm/contracts/AirdropSignatureClient.js +4 -12
- package/dist/cjs/airdrop/core/evm/contracts/AirdropSignatureClient.js.map +1 -1
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.d.ts +1 -1
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.js +6 -3
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.js.map +1 -1
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/index.d.ts +2 -1
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/index.js +6 -4
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/index.js.map +1 -1
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/solana/index.d.ts +1 -1
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/solana/index.js +6 -3
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/solana/index.js.map +1 -1
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.d.ts +1 -1
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.js +10 -9
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.js.map +1 -1
- package/dist/cjs/airdrop/services/index.d.ts +8 -4
- package/dist/cjs/airdrop/services/index.js +16 -3
- package/dist/cjs/airdrop/services/index.js.map +1 -1
- package/dist/cjs/airdrop/types/index.d.ts +1 -0
- package/dist/cjs/airdrop/types/index.js.map +1 -1
- package/dist/cjs/utils/api-client.d.ts +1 -0
- package/dist/cjs/utils/api-client.js +2 -2
- package/dist/cjs/utils/api-client.js.map +1 -1
- package/dist/esm/airdrop/SignatureAirdropClient.d.ts +12 -4
- package/dist/esm/airdrop/SignatureAirdropClient.js +64 -18
- package/dist/esm/airdrop/SignatureAirdropClient.js.map +1 -1
- package/dist/esm/airdrop/core/evm/SignatureAirdropService.d.ts +22 -0
- package/dist/esm/airdrop/core/evm/SignatureAirdropService.js +64 -0
- package/dist/esm/airdrop/core/evm/SignatureAirdropService.js.map +1 -0
- package/dist/esm/airdrop/core/evm/contracts/AirdropSignatureClient.d.ts +2 -2
- package/dist/esm/airdrop/core/evm/contracts/AirdropSignatureClient.js +4 -12
- package/dist/esm/airdrop/core/evm/contracts/AirdropSignatureClient.js.map +1 -1
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.d.ts +1 -1
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.js +6 -3
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.js.map +1 -1
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/index.d.ts +2 -1
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/index.js +7 -5
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/index.js.map +1 -1
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/solana/index.d.ts +1 -1
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/solana/index.js +6 -3
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/solana/index.js.map +1 -1
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.d.ts +1 -1
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.js +10 -9
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.js.map +1 -1
- package/dist/esm/airdrop/services/index.d.ts +8 -4
- package/dist/esm/airdrop/services/index.js +16 -3
- package/dist/esm/airdrop/services/index.js.map +1 -1
- package/dist/esm/airdrop/types/index.d.ts +1 -0
- package/dist/esm/airdrop/types/index.js.map +1 -1
- package/dist/esm/utils/api-client.d.ts +1 -0
- package/dist/esm/utils/api-client.js +2 -2
- package/dist/esm/utils/api-client.js.map +1 -1
- package/package.json +1 -1
- package/src/airdrop/SignatureAirdropClient.ts +79 -23
- package/src/airdrop/core/evm/SignatureAirdropService.ts +86 -0
- package/src/airdrop/core/evm/contracts/AirdropSignatureClient.ts +4 -12
- package/src/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.ts +6 -3
- package/src/airdrop/core/useWeb3ConnectWallet/providers/evm/index.tsx +18 -5
- package/src/airdrop/core/useWeb3ConnectWallet/providers/solana/index.tsx +6 -3
- package/src/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.ts +16 -12
- package/src/airdrop/services/index.ts +22 -7
- package/src/airdrop/types/index.ts +1 -0
- package/src/utils/api-client.ts +3 -2
|
@@ -38,14 +38,27 @@ export const getJettonInfo = async (data, baseURL) => {
|
|
|
38
38
|
};
|
|
39
39
|
export const connectTwitter = async (data, baseURL) => {
|
|
40
40
|
const client = createApiClient(baseURL);
|
|
41
|
-
return client.post('/airdrop-open/connect-twitter', data
|
|
41
|
+
return client.post('/airdrop-open/connect-twitter', data, {
|
|
42
|
+
headers: {
|
|
43
|
+
sid: window.localStorage.getItem('sid_' + data.projectId) || ''
|
|
44
|
+
}
|
|
45
|
+
});
|
|
42
46
|
};
|
|
47
|
+
//{{ttApi}}/airdrop-open/check-eligibility
|
|
43
48
|
export const checkEligibility = async (data, baseURL) => {
|
|
44
49
|
const client = createApiClient(baseURL);
|
|
45
|
-
return client.post('/airdrop-open/check-eligibility', data
|
|
50
|
+
return client.post('/airdrop-open/check-eligibility', data, {
|
|
51
|
+
headers: {
|
|
52
|
+
sid: window.localStorage.getItem('sid_' + data.projectId) || ''
|
|
53
|
+
}
|
|
54
|
+
});
|
|
46
55
|
};
|
|
47
56
|
export const bindWallet = async (data, baseURL) => {
|
|
48
57
|
const client = createApiClient(baseURL);
|
|
49
|
-
return client.post('/airdrop-open/connect-wallet', data
|
|
58
|
+
return client.post('/airdrop-open/connect-wallet', data, {
|
|
59
|
+
headers: {
|
|
60
|
+
sid: window.localStorage.getItem('sid_' + data.projectId) || ''
|
|
61
|
+
}
|
|
62
|
+
});
|
|
50
63
|
};
|
|
51
64
|
//# sourceMappingURL=index.js.map
|
|
@@ -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,M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I,EAAE;SAChE;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AACF,0CAA0C;AAC1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,IAA2B,EAAE,OAAgB,EAAgB,EAAE;IACpG,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IACxC,OAAO,MAAM,CAAC,IAAI,CAAC,iCAAiC,EAAE,IAAI,EAAE;QAC1D,OAAO,EAAE;YACP,GAAG,EAAE,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;SAChE;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAC7B,IAOC,EACD,OAAgB,EACU,EAAE;IAC5B,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IACxC,OAAO,MAAM,CAAC,IAAI,CAAC,8BAA8B,EAAE,IAAI,EAAE;QACvD,OAAO,EAAE;YACP,GAAG,EAAE,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;SAChE;KACF,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/airdrop/types/index.ts"],"names":[],"mappings":"AAgBA,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,wBAAW,CAAA;IACX,wBAAW,CAAA;AACb,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/airdrop/types/index.ts"],"names":[],"mappings":"AAgBA,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,wBAAW,CAAA;IACX,wBAAW,CAAA;AACb,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;AAsDD,MAAM,CAAN,IAAY,0BAIX;AAJD,WAAY,0BAA0B;IACpC,mDAAqB,CAAA;IACrB,4DAA8B,CAAA;IAC9B,sDAAwB,CAAA;AAC1B,CAAC,EAJW,0BAA0B,KAA1B,0BAA0B,QAIrC;AAUD,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,6BAAe,CAAA;IACf,qCAAuB,CAAA;IACvB,4BAAc,CAAA;AAChB,CAAC,EAJW,UAAU,KAAV,UAAU,QAIrB;AA6BD,MAAM,CAAN,IAAY,qBAKX;AALD,WAAY,qBAAqB;IAC/B,qCAAY,CAAA;IACZ,qCAAY,CAAA;IACZ,0CAAiB,CAAA;IACjB,4CAAmB,CAAA;AACrB,CAAC,EALW,qBAAqB,KAArB,qBAAqB,QAKhC;AAED,MAAM,CAAN,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC/B,qCAAY,CAAA;IACZ,qCAAY,CAAA;IACZ,qCAAY,CAAA,CAAC,yBAAyB;AACxC,CAAC,EAJW,qBAAqB,KAArB,qBAAqB,QAIhC"}
|
|
@@ -23,12 +23,12 @@ export class ApiClient {
|
|
|
23
23
|
}
|
|
24
24
|
async request(method, url, data, options) {
|
|
25
25
|
const finalUrl = (this.options?.baseURL || '') + url;
|
|
26
|
-
const init = { method };
|
|
26
|
+
const init = { method, headers: options?.headers || {} };
|
|
27
27
|
if (data instanceof FormData) {
|
|
28
28
|
init.body = data;
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
|
-
init.headers = { 'content-type': 'application/json' };
|
|
31
|
+
init.headers = { 'content-type': 'application/json', ...init.headers };
|
|
32
32
|
init.body = data ? JSON.stringify(data) : void 0;
|
|
33
33
|
}
|
|
34
34
|
const res = await fetch(finalUrl, init);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../../src/utils/api-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../../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AI,CAAC;QACnB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAAO,GAAG,EAAE,cAAc,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;YACvE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACnD,CAAC;QAED,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACxC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAA0B,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,EAAS,CAAC,CAAC,CAAC;QACpG,IAAI,CAAC,MAAM,GAAG,GAAG,IAAI,MAAM,IAAI,GAAG,CAAC,IAAI,OAAO,EAAE,OAAO,KAAK,IAAI,EAAE,CAAC;YACjE,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,OAAO,CAAC,IAAI,CAAC;IACtB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,EAAE,OAAO,EAAE,kCAAkC,EAAE,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { CONST } from './constants';
|
|
2
|
+
import { SignatureAirdropService } from './core/evm/SignatureAirdropService';
|
|
2
3
|
import { WalletFactory } from './core/useWeb3ConnectWallet';
|
|
3
4
|
import { ChainType } from './core/useWeb3ConnectWallet/types';
|
|
4
|
-
import { bindWallet, connectTwitter, getAirdropProject } from './services';
|
|
5
|
-
import { AirdropSigIdentityTypeEnum, IAirdropOptions, IProject } from './types';
|
|
5
|
+
import { bindWallet, checkEligibility, connectTwitter, getAirdropProject } from './services';
|
|
6
|
+
import { AirdropSigIdentityTypeEnum, ChainId, IAirdropOptions, IProject, IWalletClient } from './types';
|
|
6
7
|
|
|
7
8
|
export class SignatureAirdropClient {
|
|
8
|
-
private slug?: string;
|
|
9
9
|
private projectId?: string;
|
|
10
10
|
private endpoint?: string;
|
|
11
11
|
private project: IProject | undefined;
|
|
@@ -14,9 +14,9 @@ export class SignatureAirdropClient {
|
|
|
14
14
|
private claimHook: ((v: any) => any) | undefined;
|
|
15
15
|
// private contractConfig: IContractConfig | null = null;
|
|
16
16
|
constructor(params: IAirdropOptions) {
|
|
17
|
-
if ('slug' in params) {
|
|
18
|
-
|
|
19
|
-
}
|
|
17
|
+
// if ('slug' in params) {
|
|
18
|
+
// this.slug = params.slug;
|
|
19
|
+
// }
|
|
20
20
|
this.projectId = params.projectId;
|
|
21
21
|
this.endpoint = params.endpoint;
|
|
22
22
|
if (this.project) {
|
|
@@ -56,13 +56,12 @@ export class SignatureAirdropClient {
|
|
|
56
56
|
const project = await this.getProjectInfo();
|
|
57
57
|
const onWindowMessage = async (message: any) => {
|
|
58
58
|
if (message.data.name && message.data.name === CONST.TWITTER_AUTH_SUCCESS) {
|
|
59
|
-
const {
|
|
59
|
+
const { code } = message.data.data || {};
|
|
60
60
|
try {
|
|
61
|
-
await connectTwitter({ code,
|
|
61
|
+
const res = await connectTwitter({ code, projectId: project.id }, this.endpoint);
|
|
62
|
+
|
|
63
|
+
if (res?.sid) window.localStorage.setItem('sid_' + project.id, res?.sid);
|
|
62
64
|
onSuccess();
|
|
63
|
-
if (isError) {
|
|
64
|
-
onError();
|
|
65
|
-
}
|
|
66
65
|
} catch (error) {
|
|
67
66
|
onError();
|
|
68
67
|
} finally {
|
|
@@ -84,37 +83,94 @@ export class SignatureAirdropClient {
|
|
|
84
83
|
onError
|
|
85
84
|
}: {
|
|
86
85
|
chainType: ChainType;
|
|
87
|
-
onSuccess
|
|
88
|
-
onError
|
|
86
|
+
onSuccess?: () => void;
|
|
87
|
+
onError?: (error: any) => void;
|
|
89
88
|
}) {
|
|
90
89
|
try {
|
|
91
90
|
const project = await this.getProjectInfo();
|
|
92
91
|
const wallet = WalletFactory.getWallet(chainType);
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
const { message, signature } = signResult || {};
|
|
96
|
-
|
|
92
|
+
const timestamp = Date.now();
|
|
97
93
|
const recipientTypeMap = {
|
|
98
94
|
[ChainType.Evm]: AirdropSigIdentityTypeEnum.EVMWallet,
|
|
99
95
|
[ChainType.Solana]: AirdropSigIdentityTypeEnum.SolanaWallet,
|
|
100
96
|
[ChainType.Ton]: ''
|
|
101
97
|
};
|
|
98
|
+
const msg = [project.id, recipientTypeMap[chainType], timestamp].join(',');
|
|
99
|
+
const signResult = await wallet.signin(msg);
|
|
100
|
+
|
|
101
|
+
const { message, signature } = signResult || {};
|
|
102
102
|
|
|
103
103
|
const payload = {
|
|
104
104
|
signature: signature as string,
|
|
105
105
|
message: message as string,
|
|
106
106
|
key: wallet.publicKey || wallet.address!,
|
|
107
107
|
projectId: project.id,
|
|
108
|
-
timestamp:
|
|
108
|
+
timestamp: timestamp,
|
|
109
109
|
recipientType: recipientTypeMap[chainType]
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
-
await bindWallet(payload, this.endpoint);
|
|
113
|
-
|
|
112
|
+
const res = await bindWallet(payload, this.endpoint);
|
|
113
|
+
if (res?.sid) window.localStorage.setItem('sid_' + project.id, res?.sid);
|
|
114
|
+
onSuccess?.();
|
|
114
115
|
} catch (error) {
|
|
115
|
-
onError(error);
|
|
116
|
-
}
|
|
117
|
-
|
|
116
|
+
onError?.(error);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async getClaims() {
|
|
121
|
+
const project = await this.getProjectInfo();
|
|
122
|
+
const res = await checkEligibility(
|
|
123
|
+
{
|
|
124
|
+
projectId: project.id
|
|
125
|
+
},
|
|
126
|
+
this.endpoint
|
|
127
|
+
);
|
|
128
|
+
this.claims = res.claims;
|
|
129
|
+
return this.claims;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
public async getStrategy(walletClient?: IWalletClient): Promise<SignatureAirdropService> {
|
|
133
|
+
const project = await this.getProjectInfo();
|
|
134
|
+
|
|
135
|
+
return new SignatureAirdropService({
|
|
136
|
+
chainId: Number(project.chainId) as ChainId,
|
|
137
|
+
contractAddress: project.contractAddress,
|
|
138
|
+
walletClient: walletClient as any
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async getClaimFee(amount?: bigint): Promise<bigint> {
|
|
143
|
+
const strategy = await this.getStrategy();
|
|
144
|
+
if (!strategy.getClaimFee) {
|
|
145
|
+
throw new Error('getClaimFee is not supported for this chain');
|
|
146
|
+
}
|
|
147
|
+
return strategy.getClaimFee(this.project?.contractAddress || '', amount || BigInt(0)) as unknown as bigint;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
async claimAirdrop({ claimIds, walletClient }: { claimIds: string[]; walletClient: IWalletClient }) {
|
|
151
|
+
const service = await this.getStrategy(walletClient);
|
|
152
|
+
const claimData = this.claims?.filter((it) => claimIds.includes(it.claimId)) || [];
|
|
153
|
+
let delegateMode = false;
|
|
154
|
+
claimData.forEach((it) => {
|
|
155
|
+
if (it.recipient !== walletClient.account?.address) {
|
|
156
|
+
delegateMode = true;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
const feeData = await this.getClaimFee(1n);
|
|
160
|
+
const hash = (await service!.claim(
|
|
161
|
+
claimData,
|
|
162
|
+
delegateMode ? feeData * BigInt(claimData.length) : feeData
|
|
163
|
+
)) as unknown as `0x${string}`;
|
|
164
|
+
return hash;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async batchCheckClaimed(): Promise<boolean[]> {
|
|
168
|
+
const strategy = await this.getStrategy();
|
|
169
|
+
if (!strategy.batchFetchClaimed) {
|
|
170
|
+
throw new Error('batchCheckClaimed is not supported for this chain');
|
|
118
171
|
}
|
|
172
|
+
const claimIds = this.claims?.map((it) => it.claimId);
|
|
173
|
+
if (!claimIds) return [];
|
|
174
|
+
return strategy.batchFetchClaimed(claimIds);
|
|
119
175
|
}
|
|
120
176
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { ZERO_ADDRESS } from '../../constants';
|
|
2
|
+
import { ChainId, EvmContractClientOption } from '../../types';
|
|
3
|
+
import { AirdropSignatureClient } from './contracts/AirdropSignatureClient';
|
|
4
|
+
import { DeployerClient } from './contracts/DeployClient';
|
|
5
|
+
import { FeeCollectorClient } from './contracts/FeeCollectorClient';
|
|
6
|
+
|
|
7
|
+
export class SignatureAirdropService {
|
|
8
|
+
options: EvmContractClientOption;
|
|
9
|
+
constructor(options: EvmContractClientOption) {
|
|
10
|
+
this.options = options;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
private get airdropClient(): AirdropSignatureClient {
|
|
14
|
+
if (!this.options) {
|
|
15
|
+
throw new Error('options is empty');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return new AirdropSignatureClient(this.options);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async getDeployerClient(): Promise<DeployerClient> {
|
|
22
|
+
const deployer = await this.getDeployer();
|
|
23
|
+
return new DeployerClient({
|
|
24
|
+
...this.options,
|
|
25
|
+
contractAddress: deployer
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private getFeeClient(address: string): FeeCollectorClient {
|
|
30
|
+
if (!this.options) {
|
|
31
|
+
throw new Error('options is empty');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return new FeeCollectorClient({
|
|
35
|
+
...this.options,
|
|
36
|
+
chainId: this.options.chainId as ChainId,
|
|
37
|
+
contractAddress: address
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async getDeployer() {
|
|
42
|
+
return this.airdropClient.getDeployer();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
feeCollectors = async (address: string) => {
|
|
46
|
+
const deployerClient = await this.getDeployerClient();
|
|
47
|
+
return await deployerClient.feeCollectors(address);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
feeTokens = async (address: string) => {
|
|
51
|
+
const deployerClient = await this.getDeployerClient();
|
|
52
|
+
return await deployerClient.feeTokens(address);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
async getFeelessThreshold() {
|
|
56
|
+
// return this.airdropClient.getFeelessThreshold();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async getClaimFee(address: string, amount: bigint): Promise<bigint | undefined> {
|
|
60
|
+
const feeCollector = await this.feeCollectors(this.options.contractAddress as string);
|
|
61
|
+
if (!feeCollector || feeCollector === ZERO_ADDRESS) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
const feeClient = this.getFeeClient(feeCollector as string);
|
|
65
|
+
const fee = await feeClient.getFee(address, amount);
|
|
66
|
+
return fee;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async batchFetchClaimed(userClaimIds: string[]): Promise<boolean[]> {
|
|
70
|
+
const res = await this.airdropClient.batchFetchClaimed(userClaimIds);
|
|
71
|
+
return res;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async claim(
|
|
75
|
+
data: {
|
|
76
|
+
recipient: string;
|
|
77
|
+
group: string;
|
|
78
|
+
data: string;
|
|
79
|
+
signature: string;
|
|
80
|
+
extraData: string;
|
|
81
|
+
}[],
|
|
82
|
+
value?: bigint
|
|
83
|
+
) {
|
|
84
|
+
return this.airdropClient.claim(data, value);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -40,20 +40,12 @@ export class AirdropSignatureClient extends ContractBaseClient {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
async batchFetchClaimed(userClaimIds: string[]) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// contracts: userClaimIds?.map((userClaimId) => {
|
|
46
|
-
// return {
|
|
47
|
-
// address: this.contractAddress,
|
|
48
|
-
// abi: this.abi,
|
|
49
|
-
// functionName: 'getClaimStatus',
|
|
50
|
-
// args: [userClaimId]
|
|
51
|
-
// };
|
|
52
|
-
// })
|
|
53
|
-
// });
|
|
43
|
+
const res: any = await this.readContract({ functionName: 'getClaimStatus', args: [userClaimIds] });
|
|
44
|
+
return res;
|
|
54
45
|
}
|
|
55
46
|
|
|
56
47
|
async getDeployer() {
|
|
57
|
-
|
|
48
|
+
const res: any = await this.readContract({ functionName: 'getStorage' });
|
|
49
|
+
return res?.[3];
|
|
58
50
|
}
|
|
59
51
|
}
|
|
@@ -53,13 +53,16 @@ export class EvmWallet extends WalletBase<EVMStoreType> {
|
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
override async signin(statement
|
|
56
|
+
override async signin(statement: string, prepare = true): Promise<ISignResult> {
|
|
57
57
|
return new Promise((resolve) => {
|
|
58
58
|
const signCallback = (data: ReturnType<typeof useAccount>) => {
|
|
59
59
|
this.address = data.address;
|
|
60
60
|
this.chainId = data.chainId;
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
let fullMessage = statement;
|
|
62
|
+
if (prepare) {
|
|
63
|
+
const msg = prepareSignMessage({ statement, chainId: data.chainId!, address: data.address! });
|
|
64
|
+
fullMessage = get4361Message(msg);
|
|
65
|
+
}
|
|
63
66
|
|
|
64
67
|
const res = this.sign(fullMessage);
|
|
65
68
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '@rainbow-me/rainbowkit/styles.css';
|
|
2
|
-
import { RainbowKitProvider,
|
|
2
|
+
import { RainbowKitProvider, darkTheme, useConnectModal } from '@rainbow-me/rainbowkit';
|
|
3
3
|
import { ResolvedRegister, WagmiProvider, useAccount, useWalletClient } from 'wagmi';
|
|
4
4
|
import { ReactNode, useEffect } from 'react';
|
|
5
5
|
|
|
@@ -26,14 +26,27 @@ export const EVMConnector = () => {
|
|
|
26
26
|
return null;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
export const EvmProvider = ({
|
|
29
|
+
export const EvmProvider = ({
|
|
30
|
+
children,
|
|
31
|
+
config,
|
|
32
|
+
theme
|
|
33
|
+
}: {
|
|
34
|
+
children: ReactNode;
|
|
35
|
+
config: ResolvedRegister['config'];
|
|
36
|
+
theme?: any;
|
|
37
|
+
}) => {
|
|
30
38
|
evmStore.config = config;
|
|
31
39
|
return (
|
|
32
40
|
<WagmiProvider config={config}>
|
|
33
41
|
<RainbowKitProvider
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
locale="en-US"
|
|
43
|
+
theme={
|
|
44
|
+
theme ||
|
|
45
|
+
darkTheme({
|
|
46
|
+
accentColor: 'var(--t-primary)',
|
|
47
|
+
accentColorForeground: 'var(--t-button-primary-foreground)'
|
|
48
|
+
})
|
|
49
|
+
}
|
|
37
50
|
>
|
|
38
51
|
{children}
|
|
39
52
|
<EVMConnector />
|
|
@@ -63,14 +63,17 @@ export class SolWallet extends WalletBase<SolStoreType> {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
signin(statement
|
|
66
|
+
signin(statement: string, prepare = true): Promise<ISignResult> {
|
|
67
67
|
return new Promise((resolve) => {
|
|
68
68
|
const signCallback = (data: ReturnType<typeof useWallet>) => {
|
|
69
69
|
this.publicKey = data.publicKey?.toString();
|
|
70
70
|
this.address = this.publicKey;
|
|
71
71
|
this.chainId = 1;
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
let fullMessage = statement;
|
|
73
|
+
if (prepare) {
|
|
74
|
+
const msg = prepareSignMessage({ statement, chainId: '1', address: this.address! });
|
|
75
|
+
fullMessage = get4361Message(msg);
|
|
76
|
+
}
|
|
74
77
|
|
|
75
78
|
const res = this.sign(fullMessage);
|
|
76
79
|
|
|
@@ -57,11 +57,11 @@ export class TonWallet extends WalletBase<TonStoreType> {
|
|
|
57
57
|
|
|
58
58
|
async sign(originMsg: string): Promise<ISignResult> {
|
|
59
59
|
const message = await hashSha256(originMsg);
|
|
60
|
-
const tonConnectUI = tonStore.walletClient as
|
|
60
|
+
const tonConnectUI = tonStore.walletClient as any;
|
|
61
61
|
// const walletInfo = tonConnectUI?.wallet;
|
|
62
62
|
const authType = '';
|
|
63
63
|
// if (walletInfo?.jsBridgeKey && walletInfo?.openMethod !== 'qrcode') {
|
|
64
|
-
// authType = walletInfo.jsBridgeKey;
|
|
64
|
+
// authType = walletInfo.jsBridgeKey;
|
|
65
65
|
// }
|
|
66
66
|
|
|
67
67
|
console.log(this.isConnected, tonConnectUI, 'connected');
|
|
@@ -72,12 +72,10 @@ export class TonWallet extends WalletBase<TonStoreType> {
|
|
|
72
72
|
if (authType) {
|
|
73
73
|
const wallets = await tonConnectUI.getWallets();
|
|
74
74
|
|
|
75
|
-
const currentWallet = wallets.find((wallet) =>
|
|
75
|
+
const currentWallet = wallets.find((wallet: any) =>
|
|
76
76
|
[wallet.name, wallet.appName].includes(authType)
|
|
77
77
|
) as WalletInfoRemote;
|
|
78
78
|
|
|
79
|
-
console.log(wallets, currentWallet, 'ww');
|
|
80
|
-
|
|
81
79
|
const link = tonConnectUI.connector.connect(
|
|
82
80
|
{
|
|
83
81
|
bridgeUrl: currentWallet.bridgeUrl,
|
|
@@ -133,13 +131,19 @@ export class TonWallet extends WalletBase<TonStoreType> {
|
|
|
133
131
|
};
|
|
134
132
|
}
|
|
135
133
|
|
|
136
|
-
override async signin(statement
|
|
137
|
-
const fullMessage =
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
134
|
+
override async signin(statement: string, prepare = true): Promise<ISignResult> {
|
|
135
|
+
const fullMessage = prepare
|
|
136
|
+
? JSON.stringify(
|
|
137
|
+
{
|
|
138
|
+
statement: statement || 'Welcome to EthSign',
|
|
139
|
+
issuedAt: new Date().toISOString(),
|
|
140
|
+
nonce: getCustomNaNoId()
|
|
141
|
+
},
|
|
142
|
+
null,
|
|
143
|
+
' '
|
|
144
|
+
)
|
|
145
|
+
: statement;
|
|
146
|
+
const signRes = await this.sign(fullMessage);
|
|
143
147
|
return signRes;
|
|
144
148
|
}
|
|
145
149
|
|
|
@@ -70,14 +70,25 @@ export const getJettonInfo = async (
|
|
|
70
70
|
return client.get(`/airdrop-open/jetton/${data.address}?isTestnet=${data.isTestnet}`);
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
export const connectTwitter = async (
|
|
73
|
+
export const connectTwitter = async (
|
|
74
|
+
data: { code: string; projectId: string },
|
|
75
|
+
baseURL?: string
|
|
76
|
+
): Promise<{ sid: string }> => {
|
|
74
77
|
const client = createApiClient(baseURL);
|
|
75
|
-
return client.post('/airdrop-open/connect-twitter', data
|
|
78
|
+
return client.post('/airdrop-open/connect-twitter', data, {
|
|
79
|
+
headers: {
|
|
80
|
+
sid: window.localStorage.getItem('sid_' + data.projectId) || ''
|
|
81
|
+
}
|
|
82
|
+
});
|
|
76
83
|
};
|
|
77
|
-
|
|
78
|
-
export const checkEligibility = async (data: { projectId: string }, baseURL?: string) => {
|
|
84
|
+
//{{ttApi}}/airdrop-open/check-eligibility
|
|
85
|
+
export const checkEligibility = async (data: { projectId: string }, baseURL?: string): Promise<any> => {
|
|
79
86
|
const client = createApiClient(baseURL);
|
|
80
|
-
return client.post('/airdrop-open/check-eligibility', data
|
|
87
|
+
return client.post('/airdrop-open/check-eligibility', data, {
|
|
88
|
+
headers: {
|
|
89
|
+
sid: window.localStorage.getItem('sid_' + data.projectId) || ''
|
|
90
|
+
}
|
|
91
|
+
});
|
|
81
92
|
};
|
|
82
93
|
|
|
83
94
|
export const bindWallet = async (
|
|
@@ -90,7 +101,11 @@ export const bindWallet = async (
|
|
|
90
101
|
recipientType: string;
|
|
91
102
|
},
|
|
92
103
|
baseURL?: string
|
|
93
|
-
) => {
|
|
104
|
+
): Promise<{ sid: string }> => {
|
|
94
105
|
const client = createApiClient(baseURL);
|
|
95
|
-
return client.post('/airdrop-open/connect-wallet', data
|
|
106
|
+
return client.post('/airdrop-open/connect-wallet', data, {
|
|
107
|
+
headers: {
|
|
108
|
+
sid: window.localStorage.getItem('sid_' + data.projectId) || ''
|
|
109
|
+
}
|
|
110
|
+
});
|
|
96
111
|
};
|
package/src/utils/api-client.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type ApiClientOptions = {
|
|
|
5
5
|
export type ApiRequestOptions = {
|
|
6
6
|
params?: Record<string, string | number>;
|
|
7
7
|
skipHandleError?: boolean;
|
|
8
|
+
headers?: Record<string, string>;
|
|
8
9
|
};
|
|
9
10
|
|
|
10
11
|
type ApiResponse = {
|
|
@@ -48,11 +49,11 @@ export class ApiClient {
|
|
|
48
49
|
): Promise<unknown> {
|
|
49
50
|
const finalUrl = (this.options?.baseURL || '') + url;
|
|
50
51
|
|
|
51
|
-
const init: RequestInit = { method };
|
|
52
|
+
const init: RequestInit = { method, headers: options?.headers || {} };
|
|
52
53
|
if (data instanceof FormData) {
|
|
53
54
|
init.body = data;
|
|
54
55
|
} else {
|
|
55
|
-
init.headers = { 'content-type': 'application/json' };
|
|
56
|
+
init.headers = { 'content-type': 'application/json', ...init.headers };
|
|
56
57
|
init.body = data ? JSON.stringify(data) : void 0;
|
|
57
58
|
}
|
|
58
59
|
|