@sign-global/tokentable 0.4.1-beta.4 → 0.4.1-beta.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/SignatureAirdropClient.d.ts +2 -1
- package/dist/cjs/airdrop/SignatureAirdropClient.js +28 -15
- package/dist/cjs/airdrop/SignatureAirdropClient.js.map +1 -1
- package/dist/cjs/airdrop/common/index.d.ts +35 -0
- package/dist/cjs/airdrop/constants/chain-config.d.ts +36 -0
- package/dist/cjs/airdrop/constants/chain-config.js +5 -0
- package/dist/cjs/airdrop/constants/chain-config.js.map +1 -1
- package/dist/cjs/airdrop/contracts/evm/SignatureAirdropService.d.ts +1 -1
- package/dist/cjs/airdrop/contracts/evm/SignatureAirdropService.js +6 -1
- package/dist/cjs/airdrop/contracts/evm/SignatureAirdropService.js.map +1 -1
- package/dist/cjs/airdrop/contracts/solana/AirdropSignatureClient.d.ts +7 -1
- package/dist/cjs/airdrop/contracts/solana/AirdropSignatureClient.js +24 -13
- package/dist/cjs/airdrop/contracts/solana/AirdropSignatureClient.js.map +1 -1
- package/dist/cjs/airdrop/contracts/solana/FeeCollectorClient.d.ts +2 -1
- package/dist/cjs/airdrop/contracts/solana/FeeCollectorClient.js +12 -3
- package/dist/cjs/airdrop/contracts/solana/FeeCollectorClient.js.map +1 -1
- package/dist/cjs/airdrop/contracts/solana/SignatureAirdropService.d.ts +2 -2
- package/dist/cjs/airdrop/contracts/solana/SignatureAirdropService.js +3 -9
- package/dist/cjs/airdrop/contracts/solana/SignatureAirdropService.js.map +1 -1
- package/dist/cjs/airdrop/contracts/solana/SolanaContractClient.d.ts +2 -1
- package/dist/cjs/airdrop/contracts/solana/SolanaContractClient.js +10 -4
- package/dist/cjs/airdrop/contracts/solana/SolanaContractClient.js.map +1 -1
- package/dist/cjs/airdrop/contracts/solana/fee_collector.d.ts +665 -349
- package/dist/cjs/airdrop/contracts/solana/fee_collector.json +79 -12
- package/dist/cjs/airdrop/contracts/solana/fungible_token_distributor_solana.d.ts +994 -504
- package/dist/cjs/airdrop/contracts/solana/fungible_token_distributor_solana.json +58 -3
- package/dist/cjs/airdrop/types/index.d.ts +4 -3
- package/dist/cjs/airdrop/types/index.js.map +1 -1
- package/dist/cjs/wallets/providers/evm/EvmWallet.js +27 -17
- package/dist/cjs/wallets/providers/evm/EvmWallet.js.map +1 -1
- package/dist/esm/airdrop/SignatureAirdropClient.d.ts +2 -1
- package/dist/esm/airdrop/SignatureAirdropClient.js +28 -15
- package/dist/esm/airdrop/SignatureAirdropClient.js.map +1 -1
- package/dist/esm/airdrop/common/index.d.ts +35 -0
- package/dist/esm/airdrop/constants/chain-config.d.ts +36 -0
- package/dist/esm/airdrop/constants/chain-config.js +6 -1
- package/dist/esm/airdrop/constants/chain-config.js.map +1 -1
- package/dist/esm/airdrop/contracts/evm/SignatureAirdropService.d.ts +1 -1
- package/dist/esm/airdrop/contracts/evm/SignatureAirdropService.js +6 -1
- package/dist/esm/airdrop/contracts/evm/SignatureAirdropService.js.map +1 -1
- package/dist/esm/airdrop/contracts/solana/AirdropSignatureClient.d.ts +7 -1
- package/dist/esm/airdrop/contracts/solana/AirdropSignatureClient.js +24 -13
- package/dist/esm/airdrop/contracts/solana/AirdropSignatureClient.js.map +1 -1
- package/dist/esm/airdrop/contracts/solana/FeeCollectorClient.d.ts +2 -1
- package/dist/esm/airdrop/contracts/solana/FeeCollectorClient.js +12 -3
- package/dist/esm/airdrop/contracts/solana/FeeCollectorClient.js.map +1 -1
- package/dist/esm/airdrop/contracts/solana/SignatureAirdropService.d.ts +2 -2
- package/dist/esm/airdrop/contracts/solana/SignatureAirdropService.js +3 -9
- package/dist/esm/airdrop/contracts/solana/SignatureAirdropService.js.map +1 -1
- package/dist/esm/airdrop/contracts/solana/SolanaContractClient.d.ts +2 -1
- package/dist/esm/airdrop/contracts/solana/SolanaContractClient.js +10 -4
- package/dist/esm/airdrop/contracts/solana/SolanaContractClient.js.map +1 -1
- package/dist/esm/airdrop/contracts/solana/fee_collector.d.ts +665 -349
- package/dist/esm/airdrop/contracts/solana/fee_collector.json +79 -12
- package/dist/esm/airdrop/contracts/solana/fungible_token_distributor_solana.d.ts +994 -504
- package/dist/esm/airdrop/contracts/solana/fungible_token_distributor_solana.json +58 -3
- package/dist/esm/airdrop/types/index.d.ts +4 -3
- package/dist/esm/airdrop/types/index.js.map +1 -1
- package/dist/esm/wallets/providers/evm/EvmWallet.js +27 -17
- package/dist/esm/wallets/providers/evm/EvmWallet.js.map +1 -1
- package/package.json +1 -1
- package/src/airdrop/SignatureAirdropClient.ts +40 -23
- package/src/airdrop/constants/chain-config.ts +7 -2
- package/src/airdrop/contracts/evm/SignatureAirdropService.ts +6 -1
- package/src/airdrop/contracts/solana/AirdropSignatureClient.ts +28 -27
- package/src/airdrop/contracts/solana/FeeCollectorClient.ts +12 -3
- package/src/airdrop/contracts/solana/SignatureAirdropService.ts +4 -10
- package/src/airdrop/contracts/solana/SolanaContractClient.ts +19 -11
- package/src/airdrop/contracts/solana/fee_collector.json +79 -12
- package/src/airdrop/contracts/solana/fee_collector.ts +743 -427
- package/src/airdrop/contracts/solana/fungible_token_distributor_solana.json +58 -3
- package/src/airdrop/contracts/solana/fungible_token_distributor_solana.ts +1104 -614
- package/src/airdrop/types/index.ts +4 -2
- package/src/wallets/providers/evm/EvmWallet.ts +27 -19
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"address": "
|
|
2
|
+
"address": "FCkSnf5Qd5Jva3ZdjFNGyZNhpCxmvjikXDkpWgE1vD3R",
|
|
3
3
|
"metadata": {
|
|
4
4
|
"name": "fungible_token_distributor_solana",
|
|
5
5
|
"version": "0.1.0",
|
|
@@ -207,10 +207,15 @@
|
|
|
207
207
|
{
|
|
208
208
|
"name": "fee_collector",
|
|
209
209
|
"optional": true,
|
|
210
|
-
"address": "
|
|
210
|
+
"address": "4dfP4CMvznzUuuYLhybXy71zasrhtjrFkChSFjtqS3on"
|
|
211
211
|
},
|
|
212
212
|
{
|
|
213
|
-
"name": "
|
|
213
|
+
"name": "fee_token_mint",
|
|
214
|
+
"writable": true,
|
|
215
|
+
"optional": true
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
"name": "fee",
|
|
214
219
|
"writable": true
|
|
215
220
|
},
|
|
216
221
|
{
|
|
@@ -489,6 +494,20 @@
|
|
|
489
494
|
]
|
|
490
495
|
}
|
|
491
496
|
},
|
|
497
|
+
{
|
|
498
|
+
"name": "fee_collector",
|
|
499
|
+
"optional": true,
|
|
500
|
+
"address": "4dfP4CMvznzUuuYLhybXy71zasrhtjrFkChSFjtqS3on"
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
"name": "fee_collector_storage",
|
|
504
|
+
"optional": true
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
"name": "fee",
|
|
508
|
+
"writable": true,
|
|
509
|
+
"optional": true
|
|
510
|
+
},
|
|
492
511
|
{
|
|
493
512
|
"name": "authority",
|
|
494
513
|
"writable": true,
|
|
@@ -504,6 +523,10 @@
|
|
|
504
523
|
"name": "project_id",
|
|
505
524
|
"type": "string"
|
|
506
525
|
},
|
|
526
|
+
{
|
|
527
|
+
"name": "project_token",
|
|
528
|
+
"type": "pubkey"
|
|
529
|
+
},
|
|
507
530
|
{
|
|
508
531
|
"name": "owner",
|
|
509
532
|
"type": "pubkey"
|
|
@@ -511,6 +534,10 @@
|
|
|
511
534
|
{
|
|
512
535
|
"name": "fee_collector",
|
|
513
536
|
"type": "pubkey"
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
"name": "init_fee_account",
|
|
540
|
+
"type": "bool"
|
|
514
541
|
}
|
|
515
542
|
]
|
|
516
543
|
},
|
|
@@ -644,6 +671,20 @@
|
|
|
644
671
|
]
|
|
645
672
|
}
|
|
646
673
|
},
|
|
674
|
+
{
|
|
675
|
+
"name": "fee_collector",
|
|
676
|
+
"optional": true,
|
|
677
|
+
"address": "4dfP4CMvznzUuuYLhybXy71zasrhtjrFkChSFjtqS3on"
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
"name": "fee_collector_storage",
|
|
681
|
+
"optional": true
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
"name": "fee",
|
|
685
|
+
"writable": true,
|
|
686
|
+
"optional": true
|
|
687
|
+
},
|
|
647
688
|
{
|
|
648
689
|
"name": "system_program",
|
|
649
690
|
"address": "11111111111111111111111111111111"
|
|
@@ -657,6 +698,10 @@
|
|
|
657
698
|
{
|
|
658
699
|
"name": "fee_collector",
|
|
659
700
|
"type": "pubkey"
|
|
701
|
+
},
|
|
702
|
+
{
|
|
703
|
+
"name": "init_fee_account",
|
|
704
|
+
"type": "bool"
|
|
660
705
|
}
|
|
661
706
|
]
|
|
662
707
|
},
|
|
@@ -832,6 +877,11 @@
|
|
|
832
877
|
"writable": true,
|
|
833
878
|
"signer": true
|
|
834
879
|
},
|
|
880
|
+
{
|
|
881
|
+
"name": "new_owner",
|
|
882
|
+
"writable": true,
|
|
883
|
+
"signer": true
|
|
884
|
+
},
|
|
835
885
|
{
|
|
836
886
|
"name": "system_program",
|
|
837
887
|
"address": "11111111111111111111111111111111"
|
|
@@ -885,6 +935,11 @@
|
|
|
885
935
|
"writable": true,
|
|
886
936
|
"signer": true
|
|
887
937
|
},
|
|
938
|
+
{
|
|
939
|
+
"name": "new_admin",
|
|
940
|
+
"writable": true,
|
|
941
|
+
"signer": true
|
|
942
|
+
},
|
|
888
943
|
{
|
|
889
944
|
"name": "system_program",
|
|
890
945
|
"address": "11111111111111111111111111111111"
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { TonConnectUI } from '@tonconnect/ui-react';
|
|
1
|
+
import { TonConnectUI as TonWalletClient } from '@tonconnect/ui-react';
|
|
2
2
|
import { AirdropService as TonAirdropService } from '../contracts/ton/AirdropService';
|
|
3
3
|
import { AirdropService as EvmAirdropService } from '../contracts/evm/AirdropService';
|
|
4
4
|
import { ChainConfig } from '../constants';
|
|
5
5
|
import { WalletClient as ViemWalletClient } from 'viem';
|
|
6
|
+
import { WalletContextState as SolanaWalletState } from '@solana/wallet-adapter-react';
|
|
6
7
|
export type ChainId = keyof typeof ChainConfig;
|
|
7
8
|
export interface EvmContractClientOption {
|
|
8
9
|
chainId: ChainId;
|
|
@@ -143,7 +144,8 @@ export declare enum EvmAirdropVersionEnum {
|
|
|
143
144
|
V3 = "0.3.0",// zeta 收费
|
|
144
145
|
V4 = "0.4.0"
|
|
145
146
|
}
|
|
146
|
-
export type IWalletClient =
|
|
147
|
+
export type IWalletClient = TonWalletClient | ViemWalletClient | SolanaWalletState;
|
|
148
|
+
export type { TonWalletClient, ViemWalletClient, SolanaWalletState };
|
|
147
149
|
export type IAirdropService = TonAirdropService | EvmAirdropService;
|
|
148
150
|
type BaseAirdropOptions = {
|
|
149
151
|
endpoint?: string;
|
|
@@ -166,4 +168,3 @@ export interface IContractConfig {
|
|
|
166
168
|
export declare enum ErrorCode {
|
|
167
169
|
WALLET_ALREADY_CONNECTED = "Wallet already connected"
|
|
168
170
|
}
|
|
169
|
-
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/airdrop/types/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/airdrop/types/index.ts"],"names":[],"mappings":"AAgBA,MAAM,CAAN,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,wBAAW,CAAA;IACX,wBAAW,CAAA;IACX,8BAAiB,CAAA;AACnB,CAAC,EAJW,SAAS,KAAT,SAAS,QAIpB;AAsDD,MAAM,CAAN,IAAY,0BAKX;AALD,WAAY,0BAA0B;IACpC,mDAAqB,CAAA;IACrB,4DAA8B,CAAA;IAC9B,sDAAwB,CAAA;IACxB,sDAAwB,CAAA;AAC1B,CAAC,EALW,0BAA0B,KAA1B,0BAA0B,QAKrC;AAUD,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,6BAAe,CAAA;IACf,qCAAuB,CAAA;IACvB,4BAAc,CAAA;AAChB,CAAC,EAJW,UAAU,KAAV,UAAU,QAIrB;AA6DD,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;AA8BD,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,6BAA6B;IAC7B,kEAAqD,CAAA;AACvD,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB"}
|
|
@@ -25,26 +25,36 @@ export class EvmWallet extends WalletBase {
|
|
|
25
25
|
await disconnect(evmStore.config);
|
|
26
26
|
}
|
|
27
27
|
async sign(_message) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
try {
|
|
29
|
+
const sign = await signMessage(evmStore.config, {
|
|
30
|
+
message: _message
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
message: _message,
|
|
34
|
+
signature: sign
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
35
40
|
}
|
|
36
41
|
async signin(statement, prepare = true) {
|
|
37
|
-
return new Promise((resolve) => {
|
|
38
|
-
const signCallback = (data) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
const signCallback = async (data) => {
|
|
44
|
+
try {
|
|
45
|
+
this.address = data.address;
|
|
46
|
+
this.chainId = data.chainId;
|
|
47
|
+
let fullMessage = statement;
|
|
48
|
+
if (prepare) {
|
|
49
|
+
const msg = prepareSignMessage({ statement, chainId: data.chainId, address: data.address });
|
|
50
|
+
fullMessage = get4361Message(msg);
|
|
51
|
+
}
|
|
52
|
+
const res = await this.sign(fullMessage);
|
|
53
|
+
resolve(res);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
reject(error);
|
|
45
57
|
}
|
|
46
|
-
const res = this.sign(fullMessage);
|
|
47
|
-
resolve(res);
|
|
48
58
|
};
|
|
49
59
|
const account = getAccount(evmStore.config);
|
|
50
60
|
this.provider = evmStore.walletClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EvmWallet.js","sourceRoot":"","sources":["../../../../../src/wallets/providers/evm/EvmWallet.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjE,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,YAAY,EAAE,CAAC;AAE3C,MAAM,aAAa,GAAG,YAAY,CAAC;AAUnC,MAAM,CAAC,MAAM,QAAQ,GAAiB;IACpC,OAAO,EAAE,IAAI;IACb,YAAY,EAAE,SAAS;IACvB,YAAY,EAAE,SAAS;IACvB,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE,CAAC;CACX,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE;IAC9B,OAAO,GAAG,aAAa,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;AAChD,CAAC,CAA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M,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;oBAEzC,OAAO,CAAC,GAAG,CAAC,CAAC;gBACf,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,CAAC,KAAK,CAAC,CAAC;gBAChB,CAAC;YACH,CAAC,CAAC;YAEF,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,MAAO,CAAC,CAAC;YAC7C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC;YAEtC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBACrB,YAAY,CAAC,OAAO,CAAC,CAAC;gBACtB,OAAO;YACT,CAAC;YAED,QAAQ,CAAC,OAAO,EAAE,CAAC;YACnB,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;YAC/B,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE;gBAC/B,OAAO,CAAC,GAAG,CAAC,qDAAqD,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;gBACnF,YAAY,CAAC,IAAI,CAAC,CAAC;YACrB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED,QAAQ;QACN,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getAddress } from 'viem';
|
|
2
1
|
import { CONST } from './constants';
|
|
3
2
|
import { EvmSignatureAirdropService, SolanaSignatureAirdropService } from './contracts';
|
|
4
3
|
import { WalletFactory } from '../wallets';
|
|
@@ -20,7 +19,9 @@ import {
|
|
|
20
19
|
IAirdropSignatureIdentity,
|
|
21
20
|
IClaimSignature,
|
|
22
21
|
IProject,
|
|
23
|
-
IWalletClient
|
|
22
|
+
IWalletClient,
|
|
23
|
+
SolanaWalletState,
|
|
24
|
+
ViemWalletClient
|
|
24
25
|
} from './types';
|
|
25
26
|
import { cleanUrlParams, isMobile } from '../utils';
|
|
26
27
|
|
|
@@ -32,6 +33,7 @@ export class SignatureAirdropClient {
|
|
|
32
33
|
protected identities?: IAirdropSignatureIdentity[];
|
|
33
34
|
private projectPromise: Promise<void> | undefined;
|
|
34
35
|
private twitterPromise: Promise<void> | undefined;
|
|
36
|
+
private strategyCache: Map<string, EvmSignatureAirdropService | SolanaSignatureAirdropService> = new Map();
|
|
35
37
|
constructor(params: IAirdropOptions) {
|
|
36
38
|
this.projectId = params.projectId;
|
|
37
39
|
this.endpoint = params.endpoint;
|
|
@@ -212,19 +214,32 @@ export class SignatureAirdropClient {
|
|
|
212
214
|
): Promise<EvmSignatureAirdropService | SolanaSignatureAirdropService> {
|
|
213
215
|
const project = await this.getProjectInfo();
|
|
214
216
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
217
|
+
const cacheKey = walletClient
|
|
218
|
+
? project.chainType === ChainType.Evm
|
|
219
|
+
? (walletClient as ViemWalletClient).account?.address!
|
|
220
|
+
: project.chainType === ChainType.Solana
|
|
221
|
+
? (walletClient as SolanaWalletState).publicKey!.toString()
|
|
222
|
+
: 'walletClient'
|
|
223
|
+
: 'default';
|
|
224
|
+
if (this.strategyCache.has(cacheKey)) {
|
|
225
|
+
return this.strategyCache.get(cacheKey)!;
|
|
222
226
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
227
|
+
|
|
228
|
+
const strategy =
|
|
229
|
+
project.chainType === ChainType.Solana
|
|
230
|
+
? new SolanaSignatureAirdropService({
|
|
231
|
+
chainId: project.chainId,
|
|
232
|
+
projectId: project.id,
|
|
233
|
+
token: project.tokenAddress,
|
|
234
|
+
walletClient: walletClient as any
|
|
235
|
+
})
|
|
236
|
+
: new EvmSignatureAirdropService({
|
|
237
|
+
chainId: Number(project.chainId) as ChainId,
|
|
238
|
+
contractAddress: project.contractAddress,
|
|
239
|
+
walletClient: walletClient as any
|
|
240
|
+
});
|
|
241
|
+
this.strategyCache.set(cacheKey, strategy);
|
|
242
|
+
return strategy;
|
|
228
243
|
}
|
|
229
244
|
|
|
230
245
|
async getVersion(): Promise<string> {
|
|
@@ -232,8 +247,9 @@ export class SignatureAirdropClient {
|
|
|
232
247
|
return strategy.getVersion();
|
|
233
248
|
}
|
|
234
249
|
|
|
235
|
-
|
|
236
|
-
|
|
250
|
+
// solana prams need to wallet
|
|
251
|
+
async getClaimFee(amount?: bigint, walletClient?: IWalletClient): Promise<undefined | bigint> {
|
|
252
|
+
const strategy = await this.getStrategy(walletClient);
|
|
237
253
|
if (!strategy.getClaimFee) {
|
|
238
254
|
throw new Error('getClaimFee is not supported for this chain');
|
|
239
255
|
}
|
|
@@ -259,6 +275,7 @@ export class SignatureAirdropClient {
|
|
|
259
275
|
throw new Error('No claims available');
|
|
260
276
|
}
|
|
261
277
|
const service = await this.getStrategy(walletClient);
|
|
278
|
+
const project = await this.getProjectInfo();
|
|
262
279
|
const res = await checkGetSignatures(
|
|
263
280
|
{
|
|
264
281
|
claimIds,
|
|
@@ -278,6 +295,10 @@ export class SignatureAirdropClient {
|
|
|
278
295
|
throw new Error('No matching claims found');
|
|
279
296
|
}
|
|
280
297
|
|
|
298
|
+
// only evm use
|
|
299
|
+
const defaultRecipient =
|
|
300
|
+
project.chainType === ChainType.Evm ? (walletClient as ViemWalletClient).account?.address! : '';
|
|
301
|
+
|
|
281
302
|
const claimData = filteredClaims.map((it) => {
|
|
282
303
|
const signature = signatureMap[it.claimId];
|
|
283
304
|
if (!signature) {
|
|
@@ -286,16 +307,12 @@ export class SignatureAirdropClient {
|
|
|
286
307
|
|
|
287
308
|
return {
|
|
288
309
|
...it,
|
|
289
|
-
recipient: recipient ? recipient :
|
|
310
|
+
recipient: recipient ? recipient : defaultRecipient,
|
|
290
311
|
...signature
|
|
291
312
|
};
|
|
292
313
|
});
|
|
293
|
-
|
|
294
|
-
const
|
|
295
|
-
const hash = (await service!.claim(
|
|
296
|
-
claimData,
|
|
297
|
-
delegateMode ? feeData * BigInt(claimData.length) : feeData
|
|
298
|
-
)) as `0x${string}`;
|
|
314
|
+
|
|
315
|
+
const hash = (await service!.claim(claimData, recipient)) as `0x${string}`;
|
|
299
316
|
return hash;
|
|
300
317
|
}
|
|
301
318
|
|
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
baseSepolia,
|
|
5
5
|
cyber,
|
|
6
6
|
mainnet,
|
|
7
|
-
mantaTestnet,
|
|
8
7
|
polygonMumbai,
|
|
9
8
|
polygonAmoy,
|
|
10
9
|
sepolia,
|
|
@@ -12,7 +11,8 @@ import {
|
|
|
12
11
|
zetachainAthensTestnet,
|
|
13
12
|
zkSync,
|
|
14
13
|
bsc,
|
|
15
|
-
berachainTestnet
|
|
14
|
+
berachainTestnet,
|
|
15
|
+
arbitrum
|
|
16
16
|
} from 'viem/chains';
|
|
17
17
|
import { mevmDevNet, tonMainNet, tonTestNet } from './network';
|
|
18
18
|
|
|
@@ -49,6 +49,10 @@ export const ChainConfig = {
|
|
|
49
49
|
contractAddress: '0x00aFD4466E4Afa4F43cCd414b1BC65e574ACA2f5',
|
|
50
50
|
rpcUrl: 'https://zetachain-mainnet.g.alchemy.com/v2/1tmk0FrhwTJHXh0XIyae7_SXw1lDCjgs'
|
|
51
51
|
},
|
|
52
|
+
[arbitrum.id]: {
|
|
53
|
+
contractAddress: '0x759ac3CA33FeeAfB8C41aEbC8687A7Bd849Fc87a',
|
|
54
|
+
rpcUrl: arbitrum.rpcUrls.default.http[0]
|
|
55
|
+
},
|
|
52
56
|
[berachainTestnet.id]: {
|
|
53
57
|
contractAddress: '',
|
|
54
58
|
rpcUrl: '',
|
|
@@ -97,6 +101,7 @@ export const SupportedChains = [
|
|
|
97
101
|
polygonMumbai,
|
|
98
102
|
polygonAmoy,
|
|
99
103
|
mevmDevNet,
|
|
104
|
+
arbitrum,
|
|
100
105
|
tonTestNet,
|
|
101
106
|
tonMainNet
|
|
102
107
|
];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getAddress } from 'viem';
|
|
1
2
|
import { ZERO_ADDRESS } from '../../constants';
|
|
2
3
|
import { ChainId, EvmContractClientOption } from '../../types';
|
|
3
4
|
import { AirdropSignatureClient } from './contracts/AirdropSignatureClient';
|
|
@@ -87,8 +88,12 @@ export class SignatureAirdropService {
|
|
|
87
88
|
signature: string;
|
|
88
89
|
extraData?: string;
|
|
89
90
|
}[],
|
|
90
|
-
|
|
91
|
+
recipient?: string
|
|
91
92
|
) {
|
|
93
|
+
const defaultRecipient = this.options.walletClient?.account?.address;
|
|
94
|
+
const delegateMode = recipient ? getAddress(recipient) !== defaultRecipient : false;
|
|
95
|
+
const feeData = (await this.getClaimFee(this.options.contractAddress, 1n)) || 0n;
|
|
96
|
+
const value = delegateMode ? feeData * BigInt(data.length) : feeData;
|
|
92
97
|
return this.airdropClient.claim(data, value);
|
|
93
98
|
}
|
|
94
99
|
}
|
|
@@ -17,8 +17,16 @@ export class AirdropSignatureClient extends SolanaContractClientBase<FungibleTok
|
|
|
17
17
|
this.projectId = options.projectId;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
async getVersionPDA(): Promise<PublicKey> {
|
|
21
|
+
const [versionPDA] = await this.findProgramAddress([anchor.utils.bytes.utf8.encode('version')]);
|
|
22
|
+
|
|
23
|
+
return versionPDA;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async getVersion() {
|
|
27
|
+
const versionPDA = await this.getVersionPDA();
|
|
28
|
+
const versionData = await this.fetchAccountData('version', versionPDA);
|
|
29
|
+
return versionData.version;
|
|
22
30
|
}
|
|
23
31
|
|
|
24
32
|
get FeeCollector() {
|
|
@@ -29,6 +37,10 @@ export class AirdropSignatureClient extends SolanaContractClientBase<FungibleTok
|
|
|
29
37
|
});
|
|
30
38
|
}
|
|
31
39
|
|
|
40
|
+
async getClaimFee(amount: bigint) {
|
|
41
|
+
return this.FeeCollector.getClaimFee(amount.toString());
|
|
42
|
+
}
|
|
43
|
+
|
|
32
44
|
async getStoragePDA(): Promise<PublicKey> {
|
|
33
45
|
const [storagePDA] = await this.findProgramAddress([
|
|
34
46
|
anchor.utils.bytes.utf8.encode('storage'),
|
|
@@ -133,6 +145,15 @@ export class AirdropSignatureClient extends SolanaContractClientBase<FungibleTok
|
|
|
133
145
|
await this.invokeInstruction('togglePause', {}, [this.projectId]);
|
|
134
146
|
}
|
|
135
147
|
|
|
148
|
+
async getFeeInfo() {
|
|
149
|
+
const airdropPDA = await this.getAirdropPDA();
|
|
150
|
+
const config = await this.fetchAccountData('airdrop', airdropPDA);
|
|
151
|
+
return {
|
|
152
|
+
feeToken: config.feeToken.toString(),
|
|
153
|
+
feeCollector: config.feeCollector.toString()
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
136
157
|
async claim(
|
|
137
158
|
data: {
|
|
138
159
|
recipient: string;
|
|
@@ -148,7 +169,7 @@ export class AirdropSignatureClient extends SolanaContractClientBase<FungibleTok
|
|
|
148
169
|
const config = await this.getContractInfo();
|
|
149
170
|
|
|
150
171
|
const feeCollectorStoragePDA = await this.FeeCollector.getStoragePDA();
|
|
151
|
-
const
|
|
172
|
+
const feePDA = await this.FeeCollector.getProjectFeePDA();
|
|
152
173
|
const airdropPDA = await this.getAirdropPDA();
|
|
153
174
|
const vaultPDA = await this.getVaultPDA();
|
|
154
175
|
|
|
@@ -172,32 +193,12 @@ export class AirdropSignatureClient extends SolanaContractClientBase<FungibleTok
|
|
|
172
193
|
})
|
|
173
194
|
);
|
|
174
195
|
|
|
175
|
-
console.log(
|
|
176
|
-
anchor.web3.Ed25519Program.programId.toString(),
|
|
177
|
-
{
|
|
178
|
-
publicKey: new PublicKey(config.signer).toBytes(),
|
|
179
|
-
message: Uint8Array.from(hexStrToU8Array(claim.hash)),
|
|
180
|
-
signature: new Uint8Array(hexStrToU8Array(claim.signature))
|
|
181
|
-
},
|
|
182
|
-
'sign'
|
|
183
|
-
);
|
|
184
|
-
|
|
185
196
|
const claimPDA = await this.getClaimPDA(claim.claimId);
|
|
186
197
|
|
|
187
198
|
const decodedData = {
|
|
188
199
|
claimableTimestamp: new anchor.BN(claim.unlockingAt),
|
|
189
200
|
claimableAmount: new anchor.BN(claim.value)
|
|
190
201
|
};
|
|
191
|
-
console.log(
|
|
192
|
-
airdropPDA.toString(),
|
|
193
|
-
claimPDA,
|
|
194
|
-
this.projectId,
|
|
195
|
-
new Uint8Array(hexStrToU8Array(claim.claimId)),
|
|
196
|
-
[],
|
|
197
|
-
decodedData,
|
|
198
|
-
Buffer.from(hexStrToU8Array(claim.signature)),
|
|
199
|
-
'txdata'
|
|
200
|
-
);
|
|
201
202
|
|
|
202
203
|
tx.add(
|
|
203
204
|
await this.program.methods
|
|
@@ -212,18 +213,18 @@ export class AirdropSignatureClient extends SolanaContractClientBase<FungibleTok
|
|
|
212
213
|
authority: this.wallet.publicKey,
|
|
213
214
|
airdrop: airdropPDA,
|
|
214
215
|
claim: claimPDA,
|
|
215
|
-
vault: vaultPDA,
|
|
216
|
+
// vault: vaultPDA,
|
|
216
217
|
authorityAta: authorityATA.address,
|
|
217
218
|
tokenMint: new PublicKey(config.token),
|
|
218
219
|
feeCollectorStorage: feeCollectorStoragePDA,
|
|
219
220
|
feeCollectorVault: null,
|
|
220
|
-
|
|
221
|
+
fee: feePDA,
|
|
221
222
|
authorityFeeAta: null,
|
|
222
|
-
tokenProgram: TOKEN_2022_PROGRAM_ID
|
|
223
|
+
tokenProgram: TOKEN_2022_PROGRAM_ID,
|
|
224
|
+
feeTokenMint: null
|
|
223
225
|
})
|
|
224
226
|
.transaction()
|
|
225
227
|
);
|
|
226
|
-
console.log(tx);
|
|
227
228
|
}
|
|
228
229
|
|
|
229
230
|
return await this.program.provider.sendAndConfirm?.(tx);
|
|
@@ -20,15 +20,24 @@ export class FeeCollectorClient extends SolanaContractClientBase<FeeCollector> {
|
|
|
20
20
|
return storagePDA;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
async
|
|
24
|
-
const [
|
|
23
|
+
async getProjectFeePDA(): Promise<PublicKey> {
|
|
24
|
+
const [projectFeePDA] = await this.findProgramAddress([
|
|
25
25
|
anchor.utils.bytes.utf8.encode('fee'),
|
|
26
26
|
anchor.utils.bytes.utf8.encode(this.projectId)
|
|
27
27
|
]);
|
|
28
|
-
return
|
|
28
|
+
return projectFeePDA;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
async setDefaultFee(fee: string) {
|
|
32
32
|
return this.invokeInstruction('setDefaultFee', {}, [new anchor.BN(fee)]);
|
|
33
33
|
}
|
|
34
|
+
|
|
35
|
+
async getClaimFee(tokenAmount: string): Promise<bigint> {
|
|
36
|
+
try {
|
|
37
|
+
const fee = await this.invokeView('getFee', [this.projectId, new anchor.BN(tokenAmount)]);
|
|
38
|
+
return BigInt(fee);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
return BigInt(0);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
34
43
|
}
|
|
@@ -39,15 +39,9 @@ export class SignatureAirdropService {
|
|
|
39
39
|
return '';
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
async getClaimFee(address: string, amount: bigint): Promise<bigint
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// return undefined;
|
|
46
|
-
// }
|
|
47
|
-
// const feeClient = this.getFeeClient(feeCollector as string);
|
|
48
|
-
// const fee = (await feeClient.getFee(address, amount)) as bigint;
|
|
49
|
-
// return fee;
|
|
50
|
-
return 0n;
|
|
42
|
+
async getClaimFee(address: string, amount: bigint): Promise<bigint> {
|
|
43
|
+
const fee = await this.airdropClient.getClaimFee(amount);
|
|
44
|
+
return fee;
|
|
51
45
|
}
|
|
52
46
|
|
|
53
47
|
async batchFetchClaimed(userClaimIds: string[]): Promise<boolean[]> {
|
|
@@ -70,7 +64,7 @@ export class SignatureAirdropService {
|
|
|
70
64
|
value: string;
|
|
71
65
|
hash: string;
|
|
72
66
|
}[],
|
|
73
|
-
|
|
67
|
+
recipient?: string
|
|
74
68
|
) {
|
|
75
69
|
return this.airdropClient.claim(data);
|
|
76
70
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Program, AnchorProvider, setProvider, Wallet, Idl
|
|
1
|
+
import { Program, AnchorProvider, setProvider, Wallet, Idl } from '@coral-xyz/anchor';
|
|
2
2
|
import {
|
|
3
3
|
AllAccountsMap,
|
|
4
4
|
AllInstructions,
|
|
@@ -70,7 +70,7 @@ export abstract class SolanaContractClientBase<T extends Idl = Idl> {
|
|
|
70
70
|
async invokeView<M extends keyof MakeMethodsNamespace<T, AllInstructions<T>>>(
|
|
71
71
|
methodName: M,
|
|
72
72
|
args: Parameters<MakeMethodsNamespace<T, AllInstructions<T>>[M]>
|
|
73
|
-
): Promise<
|
|
73
|
+
): Promise<any> {
|
|
74
74
|
try {
|
|
75
75
|
if (!this.program.methods[methodName]) {
|
|
76
76
|
throw new Error(`Method ${methodName} not found in program`);
|
|
@@ -91,27 +91,35 @@ export abstract class SolanaContractClientBase<T extends Idl = Idl> {
|
|
|
91
91
|
args: any,
|
|
92
92
|
options?: { signers?: Signer[] }
|
|
93
93
|
): Promise<string> {
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
if (!this.program.methods[methodName]) {
|
|
95
|
+
throw new Error(`Method ${methodName} not found in program`);
|
|
96
|
+
}
|
|
96
97
|
let instruction = this.program.methods[methodName](...args).accounts(accounts);
|
|
97
98
|
|
|
98
99
|
if (options?.signers?.length) {
|
|
99
100
|
instruction = instruction.signers(options.signers);
|
|
100
101
|
}
|
|
101
102
|
|
|
102
|
-
console.log(instruction, 'in');
|
|
103
|
-
|
|
104
103
|
const tx = await instruction.rpc();
|
|
105
104
|
|
|
106
|
-
await this.
|
|
107
|
-
signature: tx,
|
|
108
|
-
blockhash: latestBlockhash.blockhash,
|
|
109
|
-
lastValidBlockHeight: latestBlockhash.lastValidBlockHeight
|
|
110
|
-
});
|
|
105
|
+
await this.confirmTransaction(tx);
|
|
111
106
|
console.log(tx);
|
|
112
107
|
|
|
113
108
|
return tx;
|
|
114
109
|
}
|
|
110
|
+
|
|
111
|
+
async confirmTransaction(tx: string): Promise<string> {
|
|
112
|
+
const latestBlockhash = await this.connection.getLatestBlockhash();
|
|
113
|
+
await this.connection.confirmTransaction(
|
|
114
|
+
{
|
|
115
|
+
signature: tx,
|
|
116
|
+
blockhash: latestBlockhash.blockhash,
|
|
117
|
+
lastValidBlockHeight: latestBlockhash.lastValidBlockHeight
|
|
118
|
+
},
|
|
119
|
+
'confirmed'
|
|
120
|
+
);
|
|
121
|
+
return tx;
|
|
122
|
+
}
|
|
115
123
|
// protected abstract getProgramAccount(accountName: string, address: PublicKey): Promise<any>;
|
|
116
124
|
|
|
117
125
|
// protected abstract getEventLogs(signature: string, eventName: string): Promise<any[]>;
|