@sign-global/tokentable 0.4.1-beta.9 → 0.4.2-beta.0
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/contracts/evm/SignatureAirdropService.d.ts +2 -0
- package/dist/cjs/airdrop/contracts/evm/SignatureAirdropService.js +12 -0
- package/dist/cjs/airdrop/contracts/evm/SignatureAirdropService.js.map +1 -1
- package/dist/cjs/airdrop/contracts/evm/contracts/AirdropSignatureFeeClient.d.ts +17 -0
- package/dist/cjs/airdrop/contracts/evm/contracts/AirdropSignatureFeeClient.js +51 -0
- package/dist/cjs/airdrop/contracts/evm/contracts/AirdropSignatureFeeClient.js.map +1 -0
- package/dist/cjs/airdrop/contracts/evm/contracts/abis/FungibleTokenWithFeesECDSADistributor.json +260 -0
- package/dist/cjs/airdrop/contracts/solana/AirdropSignatureClient.js +3 -2
- package/dist/cjs/airdrop/contracts/solana/AirdropSignatureClient.js.map +1 -1
- package/dist/cjs/airdrop/contracts/solana/fee_collector.d.ts +1 -0
- package/dist/cjs/airdrop/contracts/solana/fee_collector.json +2 -1
- package/dist/cjs/airdrop/contracts/solana/fungible_token_distributor_solana.d.ts +1 -0
- package/dist/cjs/airdrop/contracts/solana/fungible_token_distributor_solana.json +2 -1
- package/dist/cjs/airdrop/index.d.ts +1 -0
- package/dist/cjs/airdrop/index.js +6 -1
- package/dist/cjs/airdrop/index.js.map +1 -1
- package/dist/esm/airdrop/contracts/evm/SignatureAirdropService.d.ts +2 -0
- package/dist/esm/airdrop/contracts/evm/SignatureAirdropService.js +12 -0
- package/dist/esm/airdrop/contracts/evm/SignatureAirdropService.js.map +1 -1
- package/dist/esm/airdrop/contracts/evm/contracts/AirdropSignatureFeeClient.d.ts +17 -0
- package/dist/esm/airdrop/contracts/evm/contracts/AirdropSignatureFeeClient.js +44 -0
- package/dist/esm/airdrop/contracts/evm/contracts/AirdropSignatureFeeClient.js.map +1 -0
- package/dist/esm/airdrop/contracts/evm/contracts/abis/FungibleTokenWithFeesECDSADistributor.json +260 -0
- package/dist/esm/airdrop/contracts/solana/AirdropSignatureClient.js +4 -3
- package/dist/esm/airdrop/contracts/solana/AirdropSignatureClient.js.map +1 -1
- package/dist/esm/airdrop/contracts/solana/fee_collector.d.ts +1 -0
- package/dist/esm/airdrop/contracts/solana/fee_collector.json +2 -1
- package/dist/esm/airdrop/contracts/solana/fungible_token_distributor_solana.d.ts +1 -0
- package/dist/esm/airdrop/contracts/solana/fungible_token_distributor_solana.json +2 -1
- package/dist/esm/airdrop/index.d.ts +1 -0
- package/dist/esm/airdrop/index.js +1 -0
- package/dist/esm/airdrop/index.js.map +1 -1
- package/package.json +1 -1
- package/src/airdrop/contracts/evm/SignatureAirdropService.ts +15 -0
- package/src/airdrop/contracts/evm/contracts/AirdropSignatureFeeClient.ts +61 -0
- package/src/airdrop/contracts/evm/contracts/abis/FungibleTokenWithFeesECDSADistributor.json +260 -0
- package/src/airdrop/contracts/solana/AirdropSignatureClient.ts +4 -3
- package/src/airdrop/contracts/solana/fee_collector.json +2 -1
- package/src/airdrop/contracts/solana/fee_collector.ts +2 -1
- package/src/airdrop/contracts/solana/fungible_token_distributor_solana.json +2 -1
- package/src/airdrop/contracts/solana/fungible_token_distributor_solana.ts +2 -1
- package/src/airdrop/index.ts +6 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import ABI from './abis/FungibleTokenWithFeesECDSADistributor.json';
|
|
2
|
+
import { ContractBaseClient } from './ContractBaseClient';
|
|
3
|
+
export class AirdropSignatureFeeClient extends ContractBaseClient {
|
|
4
|
+
constructor(options) {
|
|
5
|
+
super({
|
|
6
|
+
...options,
|
|
7
|
+
abi: ABI
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
async getClaimStatus(userClaimId) {
|
|
11
|
+
return this.readContract({ functionName: 'getClaimStatus', args: [userClaimId] });
|
|
12
|
+
}
|
|
13
|
+
async claim(data, value) {
|
|
14
|
+
const [recipients = [], userClaimIds = [], datas = [], signatures = [], extraDatas = []] = [
|
|
15
|
+
'recipient',
|
|
16
|
+
'claimId',
|
|
17
|
+
'data',
|
|
18
|
+
'signature',
|
|
19
|
+
'extraData'
|
|
20
|
+
].map((key) => data.map((item) => item[key] || ''));
|
|
21
|
+
return this.writeContract({
|
|
22
|
+
functionName: 'claim',
|
|
23
|
+
args: [recipients, userClaimIds, datas, signatures, extraDatas],
|
|
24
|
+
value: value || 0n
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async batchFetchClaimed(userClaimIds) {
|
|
28
|
+
const res = (await this.readContract({ functionName: 'getClaimStatus', args: [userClaimIds] }));
|
|
29
|
+
return res;
|
|
30
|
+
}
|
|
31
|
+
async getDeployer() {
|
|
32
|
+
const res = (await this.readContract({ functionName: 'getStorage' }));
|
|
33
|
+
return res?.[3];
|
|
34
|
+
}
|
|
35
|
+
async getVersion() {
|
|
36
|
+
const res = (await this.readContract({ functionName: 'getStorage' }));
|
|
37
|
+
return res?.[0];
|
|
38
|
+
}
|
|
39
|
+
async getPaused() {
|
|
40
|
+
const res = (await this.readContract({ functionName: 'getStorage' }));
|
|
41
|
+
return res?.[2];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=AirdropSignatureFeeClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AirdropSignatureFeeClient.js","sourceRoot":"","sources":["../../../../../../src/airdrop/contracts/evm/contracts/AirdropSignatureFeeClient.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,mDAAmD,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,OAAO,yBAA0B,SAAQ,kBAAkB;IAC/D,YAAY,OAAgC;QAC1C,KAAK,CAAC;YACJ,GAAG,OAAO;YACV,GAAG,EAAE,GAAG;SACT,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,WAAmB;QACtC,O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CAAC,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC,CAAU,CAAC;QAC/E,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,SAAS;QACb,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC,CAAU,CAAC;QAC/E,OAAO,GAAG,EAAE,CAAC,CAAC,CAAY,CAAC;IAC7B,CAAC;CACF"}
|
package/dist/esm/airdrop/contracts/evm/contracts/abis/FungibleTokenWithFeesECDSADistributor.json
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"inputs": [{ "internalType": "address", "name": "target", "type": "address" }],
|
|
4
|
+
"name": "AddressEmptyCode",
|
|
5
|
+
"type": "error"
|
|
6
|
+
},
|
|
7
|
+
{ "inputs": [], "name": "ClaimClaimed", "type": "error" },
|
|
8
|
+
{
|
|
9
|
+
"inputs": [{ "internalType": "address", "name": "implementation", "type": "address" }],
|
|
10
|
+
"name": "ERC1967InvalidImplementation",
|
|
11
|
+
"type": "error"
|
|
12
|
+
},
|
|
13
|
+
{ "inputs": [], "name": "ERC1967NonPayable", "type": "error" },
|
|
14
|
+
{ "inputs": [], "name": "EnforcedPause", "type": "error" },
|
|
15
|
+
{ "inputs": [], "name": "ExpectedPause", "type": "error" },
|
|
16
|
+
{ "inputs": [], "name": "FailedCall", "type": "error" },
|
|
17
|
+
{ "inputs": [], "name": "IncorrectFees", "type": "error" },
|
|
18
|
+
{ "inputs": [], "name": "InvalidInitialization", "type": "error" },
|
|
19
|
+
{ "inputs": [], "name": "InvalidSignature", "type": "error" },
|
|
20
|
+
{ "inputs": [], "name": "NotInitializing", "type": "error" },
|
|
21
|
+
{ "inputs": [], "name": "OutsideClaimableTimeRange", "type": "error" },
|
|
22
|
+
{
|
|
23
|
+
"inputs": [{ "internalType": "address", "name": "owner", "type": "address" }],
|
|
24
|
+
"name": "OwnableInvalidOwner",
|
|
25
|
+
"type": "error"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"inputs": [{ "internalType": "address", "name": "account", "type": "address" }],
|
|
29
|
+
"name": "OwnableUnauthorizedAccount",
|
|
30
|
+
"type": "error"
|
|
31
|
+
},
|
|
32
|
+
{ "inputs": [], "name": "ReentrancyGuardReentrantCall", "type": "error" },
|
|
33
|
+
{
|
|
34
|
+
"inputs": [{ "internalType": "address", "name": "token", "type": "address" }],
|
|
35
|
+
"name": "SafeERC20FailedOperation",
|
|
36
|
+
"type": "error"
|
|
37
|
+
},
|
|
38
|
+
{ "inputs": [], "name": "TimeInactive", "type": "error" },
|
|
39
|
+
{ "inputs": [], "name": "UUPSUnauthorizedCallContext", "type": "error" },
|
|
40
|
+
{
|
|
41
|
+
"inputs": [{ "internalType": "bytes32", "name": "slot", "type": "bytes32" }],
|
|
42
|
+
"name": "UUPSUnsupportedProxiableUUID",
|
|
43
|
+
"type": "error"
|
|
44
|
+
},
|
|
45
|
+
{ "inputs": [], "name": "UnsupportedOperation", "type": "error" },
|
|
46
|
+
{
|
|
47
|
+
"anonymous": false,
|
|
48
|
+
"inputs": [{ "indexed": false, "internalType": "uint64", "name": "version", "type": "uint64" }],
|
|
49
|
+
"name": "Initialized",
|
|
50
|
+
"type": "event"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"anonymous": false,
|
|
54
|
+
"inputs": [
|
|
55
|
+
{ "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" },
|
|
56
|
+
{ "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" }
|
|
57
|
+
],
|
|
58
|
+
"name": "OwnershipTransferred",
|
|
59
|
+
"type": "event"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"anonymous": false,
|
|
63
|
+
"inputs": [{ "indexed": false, "internalType": "address", "name": "account", "type": "address" }],
|
|
64
|
+
"name": "Paused",
|
|
65
|
+
"type": "event"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"anonymous": false,
|
|
69
|
+
"inputs": [{ "indexed": false, "internalType": "address", "name": "account", "type": "address" }],
|
|
70
|
+
"name": "Unpaused",
|
|
71
|
+
"type": "event"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"anonymous": false,
|
|
75
|
+
"inputs": [{ "indexed": true, "internalType": "address", "name": "implementation", "type": "address" }],
|
|
76
|
+
"name": "Upgraded",
|
|
77
|
+
"type": "event"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"inputs": [],
|
|
81
|
+
"name": "UPGRADE_INTERFACE_VERSION",
|
|
82
|
+
"outputs": [{ "internalType": "string", "name": "", "type": "string" }],
|
|
83
|
+
"stateMutability": "view",
|
|
84
|
+
"type": "function"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"inputs": [
|
|
88
|
+
{ "internalType": "address[]", "name": "recipients", "type": "address[]" },
|
|
89
|
+
{ "internalType": "bytes32[]", "name": "userClaimIds", "type": "bytes32[]" },
|
|
90
|
+
{ "internalType": "bytes[]", "name": "datas", "type": "bytes[]" },
|
|
91
|
+
{ "internalType": "bytes[]", "name": "signatures", "type": "bytes[]" },
|
|
92
|
+
{ "internalType": "bytes[]", "name": "extraDatas", "type": "bytes[]" }
|
|
93
|
+
],
|
|
94
|
+
"name": "claim",
|
|
95
|
+
"outputs": [],
|
|
96
|
+
"stateMutability": "payable",
|
|
97
|
+
"type": "function"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"inputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],
|
|
101
|
+
"name": "decodeUserClaimData",
|
|
102
|
+
"outputs": [
|
|
103
|
+
{
|
|
104
|
+
"components": [
|
|
105
|
+
{ "internalType": "uint256", "name": "claimableTimestamp", "type": "uint256" },
|
|
106
|
+
{ "internalType": "uint256", "name": "claimableAmount", "type": "uint256" }
|
|
107
|
+
],
|
|
108
|
+
"internalType": "struct FungibleTokenECDSADistributorData",
|
|
109
|
+
"name": "",
|
|
110
|
+
"type": "tuple"
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
"stateMutability": "pure",
|
|
114
|
+
"type": "function"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"inputs": [{ "internalType": "bytes", "name": "userClaimData", "type": "bytes" }],
|
|
118
|
+
"name": "decodeUserClaimDataWithFees",
|
|
119
|
+
"outputs": [
|
|
120
|
+
{
|
|
121
|
+
"components": [
|
|
122
|
+
{ "internalType": "uint256", "name": "claimableTimestamp", "type": "uint256" },
|
|
123
|
+
{ "internalType": "uint256", "name": "claimableAmount", "type": "uint256" },
|
|
124
|
+
{ "internalType": "uint256", "name": "fees", "type": "uint256" }
|
|
125
|
+
],
|
|
126
|
+
"internalType": "struct FungibleTokenWithFeesECDSADistributorData",
|
|
127
|
+
"name": "",
|
|
128
|
+
"type": "tuple"
|
|
129
|
+
}
|
|
130
|
+
],
|
|
131
|
+
"stateMutability": "pure",
|
|
132
|
+
"type": "function"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"inputs": [
|
|
136
|
+
{ "internalType": "bytes32", "name": "userClaimId", "type": "bytes32" },
|
|
137
|
+
{ "internalType": "bytes", "name": "userClaimData", "type": "bytes" }
|
|
138
|
+
],
|
|
139
|
+
"name": "encodeHashToBeSigned",
|
|
140
|
+
"outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
|
|
141
|
+
"stateMutability": "view",
|
|
142
|
+
"type": "function"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"inputs": [{ "internalType": "bytes32[]", "name": "userClaimIds", "type": "bytes32[]" }],
|
|
146
|
+
"name": "getClaimStatus",
|
|
147
|
+
"outputs": [{ "internalType": "bool[]", "name": "", "type": "bool[]" }],
|
|
148
|
+
"stateMutability": "view",
|
|
149
|
+
"type": "function"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"inputs": [],
|
|
153
|
+
"name": "getStorage",
|
|
154
|
+
"outputs": [
|
|
155
|
+
{ "internalType": "string", "name": "version_", "type": "string" },
|
|
156
|
+
{ "internalType": "address", "name": "owner", "type": "address" },
|
|
157
|
+
{ "internalType": "bool", "name": "paused", "type": "bool" },
|
|
158
|
+
{ "internalType": "address", "name": "deployer", "type": "address" },
|
|
159
|
+
{ "internalType": "address", "name": "authorizedSigner", "type": "address" },
|
|
160
|
+
{ "internalType": "address", "name": "token", "type": "address" },
|
|
161
|
+
{ "internalType": "address", "name": "claimHook", "type": "address" },
|
|
162
|
+
{ "internalType": "uint256", "name": "startTime", "type": "uint256" },
|
|
163
|
+
{ "internalType": "uint256", "name": "endTime", "type": "uint256" }
|
|
164
|
+
],
|
|
165
|
+
"stateMutability": "view",
|
|
166
|
+
"type": "function"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"inputs": [{ "internalType": "address", "name": "owner_", "type": "address" }],
|
|
170
|
+
"name": "initialize",
|
|
171
|
+
"outputs": [],
|
|
172
|
+
"stateMutability": "nonpayable",
|
|
173
|
+
"type": "function"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"inputs": [],
|
|
177
|
+
"name": "owner",
|
|
178
|
+
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
|
|
179
|
+
"stateMutability": "view",
|
|
180
|
+
"type": "function"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"inputs": [],
|
|
184
|
+
"name": "paused",
|
|
185
|
+
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
|
|
186
|
+
"stateMutability": "view",
|
|
187
|
+
"type": "function"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"inputs": [],
|
|
191
|
+
"name": "proxiableUUID",
|
|
192
|
+
"outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
|
|
193
|
+
"stateMutability": "view",
|
|
194
|
+
"type": "function"
|
|
195
|
+
},
|
|
196
|
+
{ "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
|
|
197
|
+
{
|
|
198
|
+
"inputs": [
|
|
199
|
+
{ "internalType": "address", "name": "token", "type": "address" },
|
|
200
|
+
{ "internalType": "uint256", "name": "startTime", "type": "uint256" },
|
|
201
|
+
{ "internalType": "uint256", "name": "endTime", "type": "uint256" },
|
|
202
|
+
{ "internalType": "address", "name": "authorizedSigner", "type": "address" }
|
|
203
|
+
],
|
|
204
|
+
"name": "setBaseParams",
|
|
205
|
+
"outputs": [],
|
|
206
|
+
"stateMutability": "nonpayable",
|
|
207
|
+
"type": "function"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"inputs": [{ "internalType": "address", "name": "hook", "type": "address" }],
|
|
211
|
+
"name": "setClaimHook",
|
|
212
|
+
"outputs": [],
|
|
213
|
+
"stateMutability": "nonpayable",
|
|
214
|
+
"type": "function"
|
|
215
|
+
},
|
|
216
|
+
{ "inputs": [], "name": "togglePause", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
|
|
217
|
+
{
|
|
218
|
+
"inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }],
|
|
219
|
+
"name": "transferOwnership",
|
|
220
|
+
"outputs": [],
|
|
221
|
+
"stateMutability": "nonpayable",
|
|
222
|
+
"type": "function"
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
"inputs": [
|
|
226
|
+
{ "internalType": "address", "name": "newImplementation", "type": "address" },
|
|
227
|
+
{ "internalType": "bytes", "name": "data", "type": "bytes" }
|
|
228
|
+
],
|
|
229
|
+
"name": "upgradeToAndCall",
|
|
230
|
+
"outputs": [],
|
|
231
|
+
"stateMutability": "payable",
|
|
232
|
+
"type": "function"
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
"inputs": [
|
|
236
|
+
{ "internalType": "address", "name": "signer", "type": "address" },
|
|
237
|
+
{ "internalType": "bytes32", "name": "hash", "type": "bytes32" },
|
|
238
|
+
{ "internalType": "bytes", "name": "signature", "type": "bytes" }
|
|
239
|
+
],
|
|
240
|
+
"name": "verify",
|
|
241
|
+
"outputs": [],
|
|
242
|
+
"stateMutability": "view",
|
|
243
|
+
"type": "function"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
"inputs": [],
|
|
247
|
+
"name": "version",
|
|
248
|
+
"outputs": [{ "internalType": "string", "name": "", "type": "string" }],
|
|
249
|
+
"stateMutability": "pure",
|
|
250
|
+
"type": "function"
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
"inputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],
|
|
254
|
+
"name": "withdraw",
|
|
255
|
+
"outputs": [],
|
|
256
|
+
"stateMutability": "nonpayable",
|
|
257
|
+
"type": "function"
|
|
258
|
+
},
|
|
259
|
+
{ "stateMutability": "payable", "type": "receive" }
|
|
260
|
+
]
|
|
@@ -2,7 +2,7 @@ import { PublicKey } from '@solana/web3.js';
|
|
|
2
2
|
import { SolanaContractClientBase } from './SolanaContractClient';
|
|
3
3
|
import IDL from './fungible_token_distributor_solana.json';
|
|
4
4
|
import * as anchor from '@coral-xyz/anchor';
|
|
5
|
-
import { TOKEN_2022_PROGRAM_ID
|
|
5
|
+
import { TOKEN_2022_PROGRAM_ID } from '@solana/spl-token';
|
|
6
6
|
import { FeeCollectorClient } from './FeeCollectorClient';
|
|
7
7
|
import { fetchTokenVersion, getOrCreateAssociatedTokenAccount, hexStrToU8Array } from '../../../utils';
|
|
8
8
|
export class AirdropSignatureClient extends SolanaContractClientBase {
|
|
@@ -64,8 +64,9 @@ export class AirdropSignatureClient extends SolanaContractClientBase {
|
|
|
64
64
|
async getContractInfo() {
|
|
65
65
|
const airdropPDA = await this.getAirdropPDA();
|
|
66
66
|
const config = await this.fetchAccountData('airdrop', airdropPDA);
|
|
67
|
+
const version = await this.getVersion();
|
|
67
68
|
return {
|
|
68
|
-
version:
|
|
69
|
+
version: version,
|
|
69
70
|
token: config.token.toString(),
|
|
70
71
|
startTime: Number(config.startTime),
|
|
71
72
|
endTime: Number(config.endTime),
|
|
@@ -170,7 +171,7 @@ export class AirdropSignatureClient extends SolanaContractClientBase {
|
|
|
170
171
|
fee: feePDA,
|
|
171
172
|
authorityFeeAta: null,
|
|
172
173
|
tokenProgram: tokenVersion?.programId || TOKEN_2022_PROGRAM_ID,
|
|
173
|
-
feeTokenProgram:
|
|
174
|
+
feeTokenProgram: null,
|
|
174
175
|
feeTokenMint: null
|
|
175
176
|
})
|
|
176
177
|
.transaction());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AirdropSignatureClient.js","sourceRoot":"","sources":["../../../../../src/airdrop/contracts/solana/AirdropSignatureClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAsB,MAAM,wBAAwB,CAAC;AACtF,OAAO,GAAG,MAAM,0CAA0C,CAAC;AAC3D,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,qBAAqB,EAAE,
|
|
1
|
+
{"version":3,"file":"AirdropSignatureClient.js","sourceRoot":"","sources":["../../../../../src/airdrop/contracts/solana/AirdropSignatureClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAsB,MAAM,wBAAwB,CAAC;AACtF,OAAO,GAAG,MAAM,0CAA0C,CAAC;AAC3D,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,iCAAiC,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEvG,MAAM,OAAO,sBAAuB,SAAQ,wBAAwD;IAClG,SAAS,CAAS;IAClB,YAAY,OAA2B;QACrC,KAAK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,sBAAsB;gBAC3C,iBAAiB,EAAE,IAAI;gBACvB,GAAG,EAAE,MAAM;gBACX,eAAe,EAAE,IAAI;gBACrB,YAAY,EAAE,YAAY,EAAE,SAAS,IAAI,qBAAqB;gBAC9D,eAAe,EAAE,IAAI;gBACrB,YAAY,EAAE,IAAI;aACnB,CAAC;iBACD,WAAW,EAAE,CACjB,CAAC;YAEF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE;gBAChE,UAAU,EAAE,WAAW;aACxB,CAAC,CAAC;YAEH,QAAQ,GAAG,IAAK,CAAC;QACnB,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { AirdropClient } from './AirdropClient';
|
|
2
2
|
export { SignatureAirdropClient } from './SignatureAirdropClient';
|
|
3
|
+
export { EvmSignatureAirdropService, SolanaSignatureAirdropService, EvmAirdropService, TonAirdropService } from './contracts';
|
|
3
4
|
export { CONST } from './constants';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { AirdropClient } from './AirdropClient';
|
|
2
2
|
export { SignatureAirdropClient } from './SignatureAirdropClient';
|
|
3
|
+
export { EvmSignatureAirdropService, SolanaSignatureAirdropService, EvmAirdropService, TonAirdropService } from './contracts';
|
|
3
4
|
export { CONST } from './constants';
|
|
4
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/airdrop/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/airdrop/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,EAC7B,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@ import { ChainId, EvmContractClientOption } from '../../types';
|
|
|
4
4
|
import { AirdropSignatureClient } from './contracts/AirdropSignatureClient';
|
|
5
5
|
import { DeployerClient } from './contracts/DeployClient';
|
|
6
6
|
import { FeeCollectorClient } from './contracts/FeeCollectorClient';
|
|
7
|
+
import { AirdropSignatureFeeClient } from './contracts/AirdropSignatureFeeClient';
|
|
7
8
|
|
|
8
9
|
export class SignatureAirdropService {
|
|
9
10
|
options: EvmContractClientOption;
|
|
@@ -18,6 +19,13 @@ export class SignatureAirdropService {
|
|
|
18
19
|
|
|
19
20
|
return new AirdropSignatureClient(this.options);
|
|
20
21
|
}
|
|
22
|
+
private get airdropWithFeeClient(): AirdropSignatureFeeClient {
|
|
23
|
+
if (!this.options) {
|
|
24
|
+
throw new Error('options is empty');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return new AirdropSignatureFeeClient(this.options);
|
|
28
|
+
}
|
|
21
29
|
|
|
22
30
|
async getDeployerClient(): Promise<DeployerClient> {
|
|
23
31
|
const deployer = await this.getDeployer();
|
|
@@ -86,10 +94,17 @@ export class SignatureAirdropService {
|
|
|
86
94
|
claimId: string;
|
|
87
95
|
data: string;
|
|
88
96
|
signature: string;
|
|
97
|
+
fees?: string;
|
|
89
98
|
extraData?: string;
|
|
90
99
|
}[],
|
|
91
100
|
recipient?: string
|
|
92
101
|
) {
|
|
102
|
+
const version = await this.getVersion();
|
|
103
|
+
|
|
104
|
+
if (version.includes('FungibleTokenWithFeesECDSADistributor')) {
|
|
105
|
+
const totalFees = data.map((item) => BigInt(item.fees || '0')).reduce((sum, fee) => sum + fee, BigInt(0));
|
|
106
|
+
return this.airdropWithFeeClient.claim(data, totalFees);
|
|
107
|
+
}
|
|
93
108
|
const defaultRecipient = this.options.walletClient?.account?.address;
|
|
94
109
|
const delegateMode = recipient ? getAddress(recipient) !== defaultRecipient : false;
|
|
95
110
|
const feeData = (await this.getClaimFee(this.options.contractAddress, 1n)) || 0n;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { EvmContractClientOption } from '../../../types';
|
|
2
|
+
import ABI from './abis/FungibleTokenWithFeesECDSADistributor.json';
|
|
3
|
+
import { ContractBaseClient } from './ContractBaseClient';
|
|
4
|
+
|
|
5
|
+
export class AirdropSignatureFeeClient extends ContractBaseClient {
|
|
6
|
+
constructor(options: EvmContractClientOption) {
|
|
7
|
+
super({
|
|
8
|
+
...options,
|
|
9
|
+
abi: ABI
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async getClaimStatus(userClaimId: string) {
|
|
14
|
+
return this.readContract({ functionName: 'getClaimStatus', args: [userClaimId] });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async claim(
|
|
18
|
+
data: {
|
|
19
|
+
recipient: string;
|
|
20
|
+
data: string;
|
|
21
|
+
claimId: string;
|
|
22
|
+
signature: string;
|
|
23
|
+
extraData?: string;
|
|
24
|
+
}[],
|
|
25
|
+
value?: bigint
|
|
26
|
+
) {
|
|
27
|
+
const [recipients = [], userClaimIds = [], datas = [], signatures = [], extraDatas = []] = [
|
|
28
|
+
'recipient',
|
|
29
|
+
'claimId',
|
|
30
|
+
'data',
|
|
31
|
+
'signature',
|
|
32
|
+
'extraData'
|
|
33
|
+
].map((key) => data.map((item) => item[key as keyof (typeof data)[0]] || ''));
|
|
34
|
+
|
|
35
|
+
return this.writeContract({
|
|
36
|
+
functionName: 'claim',
|
|
37
|
+
args: [recipients, userClaimIds, datas, signatures, extraDatas],
|
|
38
|
+
value: value || 0n
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async batchFetchClaimed(userClaimIds: string[]) {
|
|
43
|
+
const res = (await this.readContract({ functionName: 'getClaimStatus', args: [userClaimIds] })) as boolean[];
|
|
44
|
+
return res;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async getDeployer() {
|
|
48
|
+
const res = (await this.readContract({ functionName: 'getStorage' })) as any[];
|
|
49
|
+
return res?.[3] as string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async getVersion() {
|
|
53
|
+
const res = (await this.readContract({ functionName: 'getStorage' })) as any[];
|
|
54
|
+
return res?.[0];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async getPaused() {
|
|
58
|
+
const res = (await this.readContract({ functionName: 'getStorage' })) as any[];
|
|
59
|
+
return res?.[2] as boolean;
|
|
60
|
+
}
|
|
61
|
+
}
|