@primuslabs/fund-js-sdk 0.1.12 → 0.1.13
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/index.d.mts +43 -4
- package/dist/index.d.ts +43 -4
- package/dist/index.js +2210 -1234
- package/dist/index.mjs +2210 -1234
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23,11 +23,10 @@ __export(index_exports, {
|
|
|
23
23
|
PrimusFund: () => PrimusFund
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(index_exports);
|
|
26
|
-
var
|
|
26
|
+
var import_ethers5 = require("ethers");
|
|
27
27
|
|
|
28
28
|
// src/classes/Fund.ts
|
|
29
|
-
var
|
|
30
|
-
var import_zktls_js_sdk = require("@primuslabs/zktls-js-sdk");
|
|
29
|
+
var import_ethers3 = require("ethers");
|
|
31
30
|
|
|
32
31
|
// src/config/constants.ts
|
|
33
32
|
var DATASOURCETEMPLATESMAP = {
|
|
@@ -58,7 +57,8 @@ var SUPPORTEDCHAINIDSMAP = {
|
|
|
58
57
|
symbol: "MON",
|
|
59
58
|
decimals: 18
|
|
60
59
|
},
|
|
61
|
-
contractAddress: "0xcd1Ed9C1595A7e9DADe76808dd5e66aA95940A92"
|
|
60
|
+
contractAddress: "0xcd1Ed9C1595A7e9DADe76808dd5e66aA95940A92",
|
|
61
|
+
redPacketContractAddress: "0x5508fC45d930B5dE36647Dbbe5B9414e43C4F614"
|
|
62
62
|
},
|
|
63
63
|
// monad testnet
|
|
64
64
|
97: {
|
|
@@ -69,7 +69,8 @@ var SUPPORTEDCHAINIDSMAP = {
|
|
|
69
69
|
name: "tBNB",
|
|
70
70
|
symbol: "tBNB"
|
|
71
71
|
},
|
|
72
|
-
contractAddress: "0x1C5bfc91789DB3130A07a06407E02745945C3218"
|
|
72
|
+
contractAddress: "0x1C5bfc91789DB3130A07a06407E02745945C3218",
|
|
73
|
+
redPacketContractAddress: "0xC75901570dB65070caDEBB74d6702E299Ac8e019"
|
|
73
74
|
},
|
|
74
75
|
56: {
|
|
75
76
|
chainId: 56,
|
|
@@ -79,7 +80,8 @@ var SUPPORTEDCHAINIDSMAP = {
|
|
|
79
80
|
name: "BNB",
|
|
80
81
|
symbol: "BNB"
|
|
81
82
|
},
|
|
82
|
-
contractAddress: "0x1fb86db904caF7c12100EA64024E5dfd7505E484"
|
|
83
|
+
contractAddress: "0x1fb86db904caF7c12100EA64024E5dfd7505E484",
|
|
84
|
+
redPacketContractAddress: "0x083693C148e30b3A231D325366E76b38293FCa10"
|
|
83
85
|
},
|
|
84
86
|
688688: {
|
|
85
87
|
chainId: 688688,
|
|
@@ -89,7 +91,8 @@ var SUPPORTEDCHAINIDSMAP = {
|
|
|
89
91
|
name: "PHRS",
|
|
90
92
|
symbol: "PHRS"
|
|
91
93
|
},
|
|
92
|
-
contractAddress: "0xD17512B7EC12880Bd94Eca9d774089fF89805F02"
|
|
94
|
+
contractAddress: "0xD17512B7EC12880Bd94Eca9d774089fF89805F02",
|
|
95
|
+
redPacketContractAddress: "0x673D74d95A35B26804475066d9cD1DA3947f4eC3"
|
|
93
96
|
},
|
|
94
97
|
84532: {
|
|
95
98
|
chainId: 84532,
|
|
@@ -99,7 +102,8 @@ var SUPPORTEDCHAINIDSMAP = {
|
|
|
99
102
|
name: "Sepolia Ether",
|
|
100
103
|
symbol: "ETH"
|
|
101
104
|
},
|
|
102
|
-
contractAddress: "0x4E78940F0019EbAEDc6F4995D7B8ABf060F7a341"
|
|
105
|
+
contractAddress: "0x4E78940F0019EbAEDc6F4995D7B8ABf060F7a341",
|
|
106
|
+
redPacketContractAddress: "0xA33Ed35460C3d06094693956B2d7Cd1a9e7A39a8"
|
|
103
107
|
},
|
|
104
108
|
8453: {
|
|
105
109
|
chainId: 8453,
|
|
@@ -109,7 +113,8 @@ var SUPPORTEDCHAINIDSMAP = {
|
|
|
109
113
|
name: "Ether",
|
|
110
114
|
symbol: "ETH"
|
|
111
115
|
},
|
|
112
|
-
contractAddress: "0xa2e0700a269Be3158c81E4739518b324d4398588"
|
|
116
|
+
contractAddress: "0xa2e0700a269Be3158c81E4739518b324d4398588",
|
|
117
|
+
redPacketContractAddress: "0x50bd377EB8D4236Bb587AB3FB1eeafd888AEeC58"
|
|
113
118
|
}
|
|
114
119
|
};
|
|
115
120
|
var NATIVETOKENS = Object.values(SUPPORTEDCHAINIDSMAP).reduce((prev, curr) => {
|
|
@@ -131,6 +136,17 @@ var Fund_CONTRACTS = Object.values(SUPPORTEDCHAINIDSMAP).reduce((prev, curr) =>
|
|
|
131
136
|
};
|
|
132
137
|
}, {});
|
|
133
138
|
var SUPPORTEDCHAINIDS = Object.keys(Fund_CONTRACTS).map((i) => Number(i));
|
|
139
|
+
var FundForRedPacket_CONTRACTS = Object.values(SUPPORTEDCHAINIDSMAP).filter(
|
|
140
|
+
(item) => {
|
|
141
|
+
return item.redPacketContractAddress;
|
|
142
|
+
}
|
|
143
|
+
).reduce((prev, curr) => {
|
|
144
|
+
return {
|
|
145
|
+
...prev,
|
|
146
|
+
[curr.chainId]: curr.redPacketContractAddress
|
|
147
|
+
};
|
|
148
|
+
}, {});
|
|
149
|
+
var SUPPORTEDCHAINIDSForRedPacket = Object.keys(FundForRedPacket_CONTRACTS).map((i) => Number(i));
|
|
134
150
|
|
|
135
151
|
// src/classes/Contract.ts
|
|
136
152
|
var import_ethers = require("ethers");
|
|
@@ -158,14 +174,7 @@ var Contract = class {
|
|
|
158
174
|
}
|
|
159
175
|
this.address = address;
|
|
160
176
|
this.provider = provider;
|
|
161
|
-
|
|
162
|
-
if (provider instanceof import_ethers.ethers.providers.JsonRpcProvider) {
|
|
163
|
-
formatProvider = provider;
|
|
164
|
-
} else {
|
|
165
|
-
const web3Provider = new import_ethers.ethers.providers.Web3Provider(provider);
|
|
166
|
-
formatProvider = web3Provider.getSigner();
|
|
167
|
-
}
|
|
168
|
-
this.contractInstance = new import_ethers.ethers.Contract(this.address, abiJson, formatProvider);
|
|
177
|
+
this.contractInstance = new import_ethers.ethers.Contract(this.address, abiJson, this.provider);
|
|
169
178
|
}
|
|
170
179
|
// Example method to read from the contract
|
|
171
180
|
async callMethod(functionName, functionParams) {
|
|
@@ -208,11 +217,21 @@ var Contract = class {
|
|
|
208
217
|
if (isNoPendingWithdrawals) {
|
|
209
218
|
return reject("no pending withdrawals");
|
|
210
219
|
}
|
|
211
|
-
const insufficientBalanceErrStrArr = ["insufficient balance", "
|
|
220
|
+
const insufficientBalanceErrStrArr = ["insufficient balance", "INSUFFICIENT_FUNDS"];
|
|
212
221
|
const isInsufficientBalance = hasErrorFlagFn(curErrorStrArr, insufficientBalanceErrStrArr);
|
|
213
222
|
if (isInsufficientBalance) {
|
|
214
223
|
return reject("insufficient balance");
|
|
215
224
|
}
|
|
225
|
+
const alreadyClaimedErrStrArr = ["Already claimed"];
|
|
226
|
+
const isAlreadyClaimed = hasErrorFlagFn(curErrorStrArr, alreadyClaimedErrStrArr);
|
|
227
|
+
if (isAlreadyClaimed) {
|
|
228
|
+
return reject("already claimed");
|
|
229
|
+
}
|
|
230
|
+
const allClaimedErrStrArr = ["All claimed"];
|
|
231
|
+
const isAllClaimed = hasErrorFlagFn(curErrorStrArr, allClaimedErrStrArr);
|
|
232
|
+
if (isAllClaimed) {
|
|
233
|
+
return reject("all claimed");
|
|
234
|
+
}
|
|
216
235
|
return reject(error);
|
|
217
236
|
}
|
|
218
237
|
});
|
|
@@ -220,1432 +239,2370 @@ var Contract = class {
|
|
|
220
239
|
};
|
|
221
240
|
var Contract_default = Contract;
|
|
222
241
|
|
|
223
|
-
// src/
|
|
224
|
-
var
|
|
242
|
+
// src/classes/Erc20Contract.ts
|
|
243
|
+
var import_ethers2 = require("ethers");
|
|
244
|
+
|
|
245
|
+
// src/config/erc20Abi.json
|
|
246
|
+
var erc20Abi_default = [
|
|
225
247
|
{
|
|
226
248
|
type: "function",
|
|
227
|
-
name: "
|
|
249
|
+
name: "allowance",
|
|
228
250
|
inputs: [
|
|
229
|
-
{
|
|
230
|
-
|
|
231
|
-
|
|
251
|
+
{
|
|
252
|
+
name: "owner",
|
|
253
|
+
type: "address",
|
|
254
|
+
internalType: "address"
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
name: "spender",
|
|
258
|
+
type: "address",
|
|
259
|
+
internalType: "address"
|
|
260
|
+
}
|
|
232
261
|
],
|
|
233
|
-
outputs: [
|
|
234
|
-
|
|
262
|
+
outputs: [
|
|
263
|
+
{
|
|
264
|
+
name: "",
|
|
265
|
+
type: "uint256",
|
|
266
|
+
internalType: "uint256"
|
|
267
|
+
}
|
|
268
|
+
],
|
|
269
|
+
stateMutability: "view"
|
|
235
270
|
},
|
|
236
271
|
{
|
|
237
272
|
type: "function",
|
|
238
|
-
name: "
|
|
273
|
+
name: "approve",
|
|
239
274
|
inputs: [
|
|
240
|
-
{ name: "idSources", type: "string[]", internalType: "string[]" },
|
|
241
275
|
{
|
|
242
|
-
name: "
|
|
243
|
-
type: "
|
|
244
|
-
internalType: "
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
internalType: "struct AttNetworkRequest",
|
|
251
|
-
components: [
|
|
252
|
-
{ name: "url", type: "string", internalType: "string" },
|
|
253
|
-
{ name: "header", type: "string", internalType: "string" },
|
|
254
|
-
{ name: "method", type: "string", internalType: "string" },
|
|
255
|
-
{ name: "body", type: "string", internalType: "string" }
|
|
256
|
-
]
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
name: "reponseResolve",
|
|
260
|
-
type: "tuple[]",
|
|
261
|
-
internalType: "struct AttNetworkResponseResolve[]",
|
|
262
|
-
components: [
|
|
263
|
-
{ name: "keyName", type: "string", internalType: "string" },
|
|
264
|
-
{
|
|
265
|
-
name: "parseType",
|
|
266
|
-
type: "string",
|
|
267
|
-
internalType: "string"
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
name: "parsePath",
|
|
271
|
-
type: "string",
|
|
272
|
-
internalType: "string"
|
|
273
|
-
}
|
|
274
|
-
]
|
|
275
|
-
},
|
|
276
|
-
{ name: "data", type: "string", internalType: "string" },
|
|
277
|
-
{
|
|
278
|
-
name: "attConditions",
|
|
279
|
-
type: "string",
|
|
280
|
-
internalType: "string"
|
|
281
|
-
},
|
|
282
|
-
{ name: "timestamp", type: "uint64", internalType: "uint64" },
|
|
283
|
-
{
|
|
284
|
-
name: "additionParams",
|
|
285
|
-
type: "string",
|
|
286
|
-
internalType: "string"
|
|
287
|
-
},
|
|
288
|
-
{
|
|
289
|
-
name: "attestors",
|
|
290
|
-
type: "tuple[]",
|
|
291
|
-
internalType: "struct Attestor[]",
|
|
292
|
-
components: [
|
|
293
|
-
{
|
|
294
|
-
name: "attestorAddr",
|
|
295
|
-
type: "address",
|
|
296
|
-
internalType: "address"
|
|
297
|
-
},
|
|
298
|
-
{ name: "url", type: "string", internalType: "string" }
|
|
299
|
-
]
|
|
300
|
-
},
|
|
301
|
-
{ name: "signatures", type: "bytes[]", internalType: "bytes[]" }
|
|
302
|
-
]
|
|
276
|
+
name: "spender",
|
|
277
|
+
type: "address",
|
|
278
|
+
internalType: "address"
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
name: "value",
|
|
282
|
+
type: "uint256",
|
|
283
|
+
internalType: "uint256"
|
|
303
284
|
}
|
|
304
285
|
],
|
|
305
|
-
outputs: [
|
|
306
|
-
|
|
286
|
+
outputs: [
|
|
287
|
+
{
|
|
288
|
+
name: "",
|
|
289
|
+
type: "bool",
|
|
290
|
+
internalType: "bool"
|
|
291
|
+
}
|
|
292
|
+
],
|
|
293
|
+
stateMutability: "nonpayable"
|
|
307
294
|
},
|
|
308
295
|
{
|
|
309
296
|
type: "function",
|
|
310
|
-
name: "
|
|
297
|
+
name: "balanceOf",
|
|
311
298
|
inputs: [
|
|
312
|
-
{ name: "idSource", type: "string", internalType: "string" },
|
|
313
299
|
{
|
|
314
|
-
name: "
|
|
315
|
-
type: "
|
|
316
|
-
internalType: "
|
|
317
|
-
components: [
|
|
318
|
-
{ name: "recipient", type: "address", internalType: "address" },
|
|
319
|
-
{
|
|
320
|
-
name: "request",
|
|
321
|
-
type: "tuple",
|
|
322
|
-
internalType: "struct AttNetworkRequest",
|
|
323
|
-
components: [
|
|
324
|
-
{ name: "url", type: "string", internalType: "string" },
|
|
325
|
-
{ name: "header", type: "string", internalType: "string" },
|
|
326
|
-
{ name: "method", type: "string", internalType: "string" },
|
|
327
|
-
{ name: "body", type: "string", internalType: "string" }
|
|
328
|
-
]
|
|
329
|
-
},
|
|
330
|
-
{
|
|
331
|
-
name: "reponseResolve",
|
|
332
|
-
type: "tuple[]",
|
|
333
|
-
internalType: "struct AttNetworkResponseResolve[]",
|
|
334
|
-
components: [
|
|
335
|
-
{ name: "keyName", type: "string", internalType: "string" },
|
|
336
|
-
{
|
|
337
|
-
name: "parseType",
|
|
338
|
-
type: "string",
|
|
339
|
-
internalType: "string"
|
|
340
|
-
},
|
|
341
|
-
{
|
|
342
|
-
name: "parsePath",
|
|
343
|
-
type: "string",
|
|
344
|
-
internalType: "string"
|
|
345
|
-
}
|
|
346
|
-
]
|
|
347
|
-
},
|
|
348
|
-
{ name: "data", type: "string", internalType: "string" },
|
|
349
|
-
{
|
|
350
|
-
name: "attConditions",
|
|
351
|
-
type: "string",
|
|
352
|
-
internalType: "string"
|
|
353
|
-
},
|
|
354
|
-
{ name: "timestamp", type: "uint64", internalType: "uint64" },
|
|
355
|
-
{
|
|
356
|
-
name: "additionParams",
|
|
357
|
-
type: "string",
|
|
358
|
-
internalType: "string"
|
|
359
|
-
},
|
|
360
|
-
{
|
|
361
|
-
name: "attestors",
|
|
362
|
-
type: "tuple[]",
|
|
363
|
-
internalType: "struct Attestor[]",
|
|
364
|
-
components: [
|
|
365
|
-
{
|
|
366
|
-
name: "attestorAddr",
|
|
367
|
-
type: "address",
|
|
368
|
-
internalType: "address"
|
|
369
|
-
},
|
|
370
|
-
{ name: "url", type: "string", internalType: "string" }
|
|
371
|
-
]
|
|
372
|
-
},
|
|
373
|
-
{ name: "signatures", type: "bytes[]", internalType: "bytes[]" }
|
|
374
|
-
]
|
|
300
|
+
name: "account",
|
|
301
|
+
type: "address",
|
|
302
|
+
internalType: "address"
|
|
375
303
|
}
|
|
376
304
|
],
|
|
377
|
-
outputs: [
|
|
378
|
-
|
|
305
|
+
outputs: [
|
|
306
|
+
{
|
|
307
|
+
name: "",
|
|
308
|
+
type: "uint256",
|
|
309
|
+
internalType: "uint256"
|
|
310
|
+
}
|
|
311
|
+
],
|
|
312
|
+
stateMutability: "view"
|
|
379
313
|
},
|
|
380
314
|
{
|
|
381
315
|
type: "function",
|
|
382
|
-
name: "
|
|
383
|
-
inputs: [
|
|
384
|
-
|
|
316
|
+
name: "decimals",
|
|
317
|
+
inputs: [],
|
|
318
|
+
outputs: [
|
|
385
319
|
{
|
|
386
|
-
name: "
|
|
387
|
-
type: "
|
|
388
|
-
internalType: "
|
|
389
|
-
|
|
390
|
-
{ name: "recipient", type: "address", internalType: "address" },
|
|
391
|
-
{
|
|
392
|
-
name: "request",
|
|
393
|
-
type: "tuple",
|
|
394
|
-
internalType: "struct AttNetworkRequest",
|
|
395
|
-
components: [
|
|
396
|
-
{ name: "url", type: "string", internalType: "string" },
|
|
397
|
-
{ name: "header", type: "string", internalType: "string" },
|
|
398
|
-
{ name: "method", type: "string", internalType: "string" },
|
|
399
|
-
{ name: "body", type: "string", internalType: "string" }
|
|
400
|
-
]
|
|
401
|
-
},
|
|
402
|
-
{
|
|
403
|
-
name: "reponseResolve",
|
|
404
|
-
type: "tuple[]",
|
|
405
|
-
internalType: "struct AttNetworkResponseResolve[]",
|
|
406
|
-
components: [
|
|
407
|
-
{ name: "keyName", type: "string", internalType: "string" },
|
|
408
|
-
{
|
|
409
|
-
name: "parseType",
|
|
410
|
-
type: "string",
|
|
411
|
-
internalType: "string"
|
|
412
|
-
},
|
|
413
|
-
{
|
|
414
|
-
name: "parsePath",
|
|
415
|
-
type: "string",
|
|
416
|
-
internalType: "string"
|
|
417
|
-
}
|
|
418
|
-
]
|
|
419
|
-
},
|
|
420
|
-
{ name: "data", type: "string", internalType: "string" },
|
|
421
|
-
{
|
|
422
|
-
name: "attConditions",
|
|
423
|
-
type: "string",
|
|
424
|
-
internalType: "string"
|
|
425
|
-
},
|
|
426
|
-
{ name: "timestamp", type: "uint64", internalType: "uint64" },
|
|
427
|
-
{
|
|
428
|
-
name: "additionParams",
|
|
429
|
-
type: "string",
|
|
430
|
-
internalType: "string"
|
|
431
|
-
},
|
|
432
|
-
{
|
|
433
|
-
name: "attestors",
|
|
434
|
-
type: "tuple[]",
|
|
435
|
-
internalType: "struct Attestor[]",
|
|
436
|
-
components: [
|
|
437
|
-
{
|
|
438
|
-
name: "attestorAddr",
|
|
439
|
-
type: "address",
|
|
440
|
-
internalType: "address"
|
|
441
|
-
},
|
|
442
|
-
{ name: "url", type: "string", internalType: "string" }
|
|
443
|
-
]
|
|
444
|
-
},
|
|
445
|
-
{ name: "signatures", type: "bytes[]", internalType: "bytes[]" }
|
|
446
|
-
]
|
|
447
|
-
},
|
|
448
|
-
{ name: "index", type: "uint32", internalType: "uint32" }
|
|
320
|
+
name: "",
|
|
321
|
+
type: "uint8",
|
|
322
|
+
internalType: "uint8"
|
|
323
|
+
}
|
|
449
324
|
],
|
|
450
|
-
outputs: [],
|
|
451
|
-
stateMutability: "payable"
|
|
452
|
-
},
|
|
453
|
-
{
|
|
454
|
-
type: "function",
|
|
455
|
-
name: "claimFee",
|
|
456
|
-
inputs: [],
|
|
457
|
-
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
458
325
|
stateMutability: "view"
|
|
459
326
|
},
|
|
460
327
|
{
|
|
461
328
|
type: "function",
|
|
462
|
-
name: "
|
|
329
|
+
name: "name",
|
|
463
330
|
inputs: [],
|
|
464
|
-
outputs: [
|
|
331
|
+
outputs: [
|
|
332
|
+
{
|
|
333
|
+
name: "",
|
|
334
|
+
type: "string",
|
|
335
|
+
internalType: "string"
|
|
336
|
+
}
|
|
337
|
+
],
|
|
465
338
|
stateMutability: "view"
|
|
466
339
|
},
|
|
467
340
|
{
|
|
468
341
|
type: "function",
|
|
469
|
-
name: "
|
|
470
|
-
inputs: [
|
|
471
|
-
{
|
|
472
|
-
name: "tipRecipient",
|
|
473
|
-
type: "tuple",
|
|
474
|
-
internalType: "struct TipRecipient",
|
|
475
|
-
components: [
|
|
476
|
-
{ name: "idSource", type: "string", internalType: "string" },
|
|
477
|
-
{ name: "id", type: "string", internalType: "string" }
|
|
478
|
-
]
|
|
479
|
-
}
|
|
480
|
-
],
|
|
342
|
+
name: "symbol",
|
|
343
|
+
inputs: [],
|
|
481
344
|
outputs: [
|
|
482
345
|
{
|
|
483
346
|
name: "",
|
|
484
|
-
type: "
|
|
485
|
-
internalType: "
|
|
486
|
-
components: [
|
|
487
|
-
{ name: "amount", type: "uint256", internalType: "uint256" },
|
|
488
|
-
{
|
|
489
|
-
name: "tipToken",
|
|
490
|
-
type: "tuple",
|
|
491
|
-
internalType: "struct TipToken",
|
|
492
|
-
components: [
|
|
493
|
-
{
|
|
494
|
-
name: "tokenType",
|
|
495
|
-
type: "uint32",
|
|
496
|
-
internalType: "uint32"
|
|
497
|
-
},
|
|
498
|
-
{
|
|
499
|
-
name: "tokenAddress",
|
|
500
|
-
type: "address",
|
|
501
|
-
internalType: "address"
|
|
502
|
-
}
|
|
503
|
-
]
|
|
504
|
-
},
|
|
505
|
-
{ name: "timestamp", type: "uint64", internalType: "uint64" },
|
|
506
|
-
{ name: "tipper", type: "address", internalType: "address" },
|
|
507
|
-
{ name: "nftIds", type: "uint256[]", internalType: "uint256[]" }
|
|
508
|
-
]
|
|
347
|
+
type: "string",
|
|
348
|
+
internalType: "string"
|
|
509
349
|
}
|
|
510
350
|
],
|
|
511
351
|
stateMutability: "view"
|
|
512
352
|
},
|
|
513
353
|
{
|
|
514
354
|
type: "function",
|
|
515
|
-
name: "
|
|
516
|
-
inputs: [
|
|
355
|
+
name: "totalSupply",
|
|
356
|
+
inputs: [],
|
|
517
357
|
outputs: [
|
|
518
|
-
{
|
|
519
|
-
|
|
358
|
+
{
|
|
359
|
+
name: "",
|
|
360
|
+
type: "uint256",
|
|
361
|
+
internalType: "uint256"
|
|
362
|
+
}
|
|
520
363
|
],
|
|
521
364
|
stateMutability: "view"
|
|
522
365
|
},
|
|
523
366
|
{
|
|
524
367
|
type: "function",
|
|
525
|
-
name: "
|
|
368
|
+
name: "transfer",
|
|
526
369
|
inputs: [
|
|
527
|
-
{ name: "owner", type: "address", internalType: "address" },
|
|
528
370
|
{
|
|
529
|
-
name: "
|
|
371
|
+
name: "to",
|
|
530
372
|
type: "address",
|
|
531
|
-
internalType: "
|
|
373
|
+
internalType: "address"
|
|
532
374
|
},
|
|
533
|
-
{
|
|
534
|
-
|
|
375
|
+
{
|
|
376
|
+
name: "value",
|
|
377
|
+
type: "uint256",
|
|
378
|
+
internalType: "uint256"
|
|
379
|
+
}
|
|
535
380
|
],
|
|
536
|
-
outputs: [],
|
|
537
|
-
stateMutability: "nonpayable"
|
|
538
|
-
},
|
|
539
|
-
{
|
|
540
|
-
type: "function",
|
|
541
|
-
name: "owner",
|
|
542
|
-
inputs: [],
|
|
543
|
-
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
544
|
-
stateMutability: "view"
|
|
545
|
-
},
|
|
546
|
-
{
|
|
547
|
-
type: "function",
|
|
548
|
-
name: "primusZKTLS",
|
|
549
|
-
inputs: [],
|
|
550
381
|
outputs: [
|
|
551
|
-
{
|
|
382
|
+
{
|
|
383
|
+
name: "",
|
|
384
|
+
type: "bool",
|
|
385
|
+
internalType: "bool"
|
|
386
|
+
}
|
|
552
387
|
],
|
|
553
|
-
stateMutability: "view"
|
|
554
|
-
},
|
|
555
|
-
{
|
|
556
|
-
type: "function",
|
|
557
|
-
name: "renounceOwnership",
|
|
558
|
-
inputs: [],
|
|
559
|
-
outputs: [],
|
|
560
388
|
stateMutability: "nonpayable"
|
|
561
389
|
},
|
|
562
390
|
{
|
|
563
391
|
type: "function",
|
|
564
|
-
name: "
|
|
392
|
+
name: "transferFrom",
|
|
565
393
|
inputs: [
|
|
566
|
-
{
|
|
394
|
+
{
|
|
395
|
+
name: "from",
|
|
396
|
+
type: "address",
|
|
397
|
+
internalType: "address"
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
name: "to",
|
|
401
|
+
type: "address",
|
|
402
|
+
internalType: "address"
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
name: "value",
|
|
406
|
+
type: "uint256",
|
|
407
|
+
internalType: "uint256"
|
|
408
|
+
}
|
|
567
409
|
],
|
|
568
|
-
outputs: [
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
inputs: [
|
|
575
|
-
{ name: "feeRecipient_", type: "address", internalType: "address" }
|
|
410
|
+
outputs: [
|
|
411
|
+
{
|
|
412
|
+
name: "",
|
|
413
|
+
type: "bool",
|
|
414
|
+
internalType: "bool"
|
|
415
|
+
}
|
|
576
416
|
],
|
|
577
|
-
outputs: [],
|
|
578
417
|
stateMutability: "nonpayable"
|
|
579
418
|
},
|
|
580
419
|
{
|
|
581
|
-
type: "
|
|
582
|
-
name: "
|
|
420
|
+
type: "event",
|
|
421
|
+
name: "Approval",
|
|
583
422
|
inputs: [
|
|
584
423
|
{
|
|
585
|
-
name: "
|
|
424
|
+
name: "owner",
|
|
586
425
|
type: "address",
|
|
587
|
-
|
|
426
|
+
indexed: true,
|
|
427
|
+
internalType: "address"
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
name: "spender",
|
|
431
|
+
type: "address",
|
|
432
|
+
indexed: true,
|
|
433
|
+
internalType: "address"
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
name: "value",
|
|
437
|
+
type: "uint256",
|
|
438
|
+
indexed: false,
|
|
439
|
+
internalType: "uint256"
|
|
588
440
|
}
|
|
589
441
|
],
|
|
590
|
-
|
|
591
|
-
stateMutability: "nonpayable"
|
|
442
|
+
anonymous: false
|
|
592
443
|
},
|
|
593
444
|
{
|
|
594
|
-
type: "
|
|
595
|
-
name: "
|
|
445
|
+
type: "event",
|
|
446
|
+
name: "Transfer",
|
|
596
447
|
inputs: [
|
|
597
|
-
{
|
|
448
|
+
{
|
|
449
|
+
name: "from",
|
|
450
|
+
type: "address",
|
|
451
|
+
indexed: true,
|
|
452
|
+
internalType: "address"
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
name: "to",
|
|
456
|
+
type: "address",
|
|
457
|
+
indexed: true,
|
|
458
|
+
internalType: "address"
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
name: "value",
|
|
462
|
+
type: "uint256",
|
|
463
|
+
indexed: false,
|
|
464
|
+
internalType: "uint256"
|
|
465
|
+
}
|
|
598
466
|
],
|
|
599
|
-
|
|
600
|
-
stateMutability: "nonpayable"
|
|
467
|
+
anonymous: false
|
|
601
468
|
},
|
|
602
469
|
{
|
|
603
|
-
type: "
|
|
604
|
-
name: "
|
|
470
|
+
type: "error",
|
|
471
|
+
name: "ERC20InsufficientAllowance",
|
|
605
472
|
inputs: [
|
|
606
473
|
{
|
|
607
|
-
name: "
|
|
608
|
-
type: "
|
|
609
|
-
internalType: "
|
|
610
|
-
components: [
|
|
611
|
-
{ name: "tokenType", type: "uint32", internalType: "uint32" },
|
|
612
|
-
{
|
|
613
|
-
name: "tokenAddress",
|
|
614
|
-
type: "address",
|
|
615
|
-
internalType: "address"
|
|
616
|
-
}
|
|
617
|
-
]
|
|
474
|
+
name: "spender",
|
|
475
|
+
type: "address",
|
|
476
|
+
internalType: "address"
|
|
618
477
|
},
|
|
619
478
|
{
|
|
620
|
-
name: "
|
|
621
|
-
type: "
|
|
622
|
-
internalType: "
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
]
|
|
479
|
+
name: "allowance",
|
|
480
|
+
type: "uint256",
|
|
481
|
+
internalType: "uint256"
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
name: "needed",
|
|
485
|
+
type: "uint256",
|
|
486
|
+
internalType: "uint256"
|
|
629
487
|
}
|
|
630
|
-
]
|
|
631
|
-
outputs: [],
|
|
632
|
-
stateMutability: "payable"
|
|
488
|
+
]
|
|
633
489
|
},
|
|
634
490
|
{
|
|
635
|
-
type: "
|
|
636
|
-
name: "
|
|
491
|
+
type: "error",
|
|
492
|
+
name: "ERC20InsufficientBalance",
|
|
637
493
|
inputs: [
|
|
638
494
|
{
|
|
639
|
-
name: "
|
|
640
|
-
type: "tuple",
|
|
641
|
-
internalType: "struct TipToken",
|
|
642
|
-
components: [
|
|
643
|
-
{ name: "tokenType", type: "uint32", internalType: "uint32" },
|
|
644
|
-
{
|
|
645
|
-
name: "tokenAddress",
|
|
646
|
-
type: "address",
|
|
647
|
-
internalType: "address"
|
|
648
|
-
}
|
|
649
|
-
]
|
|
650
|
-
},
|
|
651
|
-
{
|
|
652
|
-
name: "recipients",
|
|
653
|
-
type: "tuple[]",
|
|
654
|
-
internalType: "struct TipRecipientInfo[]",
|
|
655
|
-
components: [
|
|
656
|
-
{ name: "idSource", type: "string", internalType: "string" },
|
|
657
|
-
{ name: "id", type: "string", internalType: "string" },
|
|
658
|
-
{ name: "amount", type: "uint256", internalType: "uint256" },
|
|
659
|
-
{ name: "nftIds", type: "uint256[]", internalType: "uint256[]" }
|
|
660
|
-
]
|
|
661
|
-
}
|
|
662
|
-
],
|
|
663
|
-
outputs: [],
|
|
664
|
-
stateMutability: "payable"
|
|
665
|
-
},
|
|
666
|
-
{
|
|
667
|
-
type: "function",
|
|
668
|
-
name: "tipperWithdraw",
|
|
669
|
-
inputs: [
|
|
670
|
-
{
|
|
671
|
-
name: "tipRecipients",
|
|
672
|
-
type: "tuple[]",
|
|
673
|
-
internalType: "struct TipWithdrawInfo[]",
|
|
674
|
-
components: [
|
|
675
|
-
{ name: "idSource", type: "string", internalType: "string" },
|
|
676
|
-
{ name: "id", type: "string", internalType: "string" },
|
|
677
|
-
{ name: "tipTimestamp", type: "uint64", internalType: "uint64" }
|
|
678
|
-
]
|
|
679
|
-
}
|
|
680
|
-
],
|
|
681
|
-
outputs: [],
|
|
682
|
-
stateMutability: "nonpayable"
|
|
683
|
-
},
|
|
684
|
-
{
|
|
685
|
-
type: "function",
|
|
686
|
-
name: "transferOwnership",
|
|
687
|
-
inputs: [
|
|
688
|
-
{ name: "newOwner", type: "address", internalType: "address" }
|
|
689
|
-
],
|
|
690
|
-
outputs: [],
|
|
691
|
-
stateMutability: "nonpayable"
|
|
692
|
-
},
|
|
693
|
-
{
|
|
694
|
-
type: "function",
|
|
695
|
-
name: "withdrawDelay",
|
|
696
|
-
inputs: [],
|
|
697
|
-
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
698
|
-
stateMutability: "view"
|
|
699
|
-
},
|
|
700
|
-
{
|
|
701
|
-
type: "event",
|
|
702
|
-
name: "ClaimEvent",
|
|
703
|
-
inputs: [
|
|
704
|
-
{
|
|
705
|
-
name: "recipient",
|
|
706
|
-
type: "address",
|
|
707
|
-
indexed: true,
|
|
708
|
-
internalType: "address"
|
|
709
|
-
},
|
|
710
|
-
{
|
|
711
|
-
name: "claimTime",
|
|
712
|
-
type: "uint64",
|
|
713
|
-
indexed: false,
|
|
714
|
-
internalType: "uint64"
|
|
715
|
-
},
|
|
716
|
-
{
|
|
717
|
-
name: "idSource",
|
|
718
|
-
type: "string",
|
|
719
|
-
indexed: false,
|
|
720
|
-
internalType: "string"
|
|
721
|
-
},
|
|
722
|
-
{
|
|
723
|
-
name: "id",
|
|
724
|
-
type: "string",
|
|
725
|
-
indexed: false,
|
|
726
|
-
internalType: "string"
|
|
727
|
-
},
|
|
728
|
-
{
|
|
729
|
-
name: "tipper",
|
|
730
|
-
type: "address",
|
|
731
|
-
indexed: false,
|
|
732
|
-
internalType: "address"
|
|
733
|
-
},
|
|
734
|
-
{
|
|
735
|
-
name: "tokenAddr",
|
|
495
|
+
name: "sender",
|
|
736
496
|
type: "address",
|
|
737
|
-
indexed: false,
|
|
738
497
|
internalType: "address"
|
|
739
498
|
},
|
|
740
499
|
{
|
|
741
|
-
name: "
|
|
500
|
+
name: "balance",
|
|
742
501
|
type: "uint256",
|
|
743
|
-
indexed: false,
|
|
744
502
|
internalType: "uint256"
|
|
745
503
|
},
|
|
746
504
|
{
|
|
747
|
-
name: "
|
|
748
|
-
type: "
|
|
749
|
-
|
|
750
|
-
internalType: "uint64"
|
|
751
|
-
}
|
|
752
|
-
],
|
|
753
|
-
anonymous: false
|
|
754
|
-
},
|
|
755
|
-
{
|
|
756
|
-
type: "event",
|
|
757
|
-
name: "Initialized",
|
|
758
|
-
inputs: [
|
|
759
|
-
{
|
|
760
|
-
name: "version",
|
|
761
|
-
type: "uint64",
|
|
762
|
-
indexed: false,
|
|
763
|
-
internalType: "uint64"
|
|
505
|
+
name: "needed",
|
|
506
|
+
type: "uint256",
|
|
507
|
+
internalType: "uint256"
|
|
764
508
|
}
|
|
765
|
-
]
|
|
766
|
-
anonymous: false
|
|
509
|
+
]
|
|
767
510
|
},
|
|
768
511
|
{
|
|
769
|
-
type: "
|
|
770
|
-
name: "
|
|
512
|
+
type: "error",
|
|
513
|
+
name: "ERC20InvalidApprover",
|
|
771
514
|
inputs: [
|
|
772
515
|
{
|
|
773
|
-
name: "
|
|
774
|
-
type: "address",
|
|
775
|
-
indexed: true,
|
|
776
|
-
internalType: "address"
|
|
777
|
-
},
|
|
778
|
-
{
|
|
779
|
-
name: "newOwner",
|
|
516
|
+
name: "approver",
|
|
780
517
|
type: "address",
|
|
781
|
-
indexed: true,
|
|
782
518
|
internalType: "address"
|
|
783
519
|
}
|
|
784
|
-
]
|
|
785
|
-
anonymous: false
|
|
520
|
+
]
|
|
786
521
|
},
|
|
787
522
|
{
|
|
788
|
-
type: "
|
|
789
|
-
name: "
|
|
523
|
+
type: "error",
|
|
524
|
+
name: "ERC20InvalidReceiver",
|
|
790
525
|
inputs: [
|
|
791
526
|
{
|
|
792
|
-
name: "
|
|
793
|
-
type: "string",
|
|
794
|
-
indexed: false,
|
|
795
|
-
internalType: "string"
|
|
796
|
-
},
|
|
797
|
-
{
|
|
798
|
-
name: "id",
|
|
799
|
-
type: "string",
|
|
800
|
-
indexed: false,
|
|
801
|
-
internalType: "string"
|
|
802
|
-
},
|
|
803
|
-
{
|
|
804
|
-
name: "tipper",
|
|
805
|
-
type: "address",
|
|
806
|
-
indexed: false,
|
|
807
|
-
internalType: "address"
|
|
808
|
-
},
|
|
809
|
-
{
|
|
810
|
-
name: "tokenAddr",
|
|
527
|
+
name: "receiver",
|
|
811
528
|
type: "address",
|
|
812
|
-
indexed: false,
|
|
813
529
|
internalType: "address"
|
|
814
|
-
},
|
|
815
|
-
{
|
|
816
|
-
name: "amount",
|
|
817
|
-
type: "uint256",
|
|
818
|
-
indexed: false,
|
|
819
|
-
internalType: "uint256"
|
|
820
|
-
},
|
|
821
|
-
{
|
|
822
|
-
name: "tipTime",
|
|
823
|
-
type: "uint64",
|
|
824
|
-
indexed: false,
|
|
825
|
-
internalType: "uint64"
|
|
826
530
|
}
|
|
827
|
-
]
|
|
828
|
-
anonymous: false
|
|
531
|
+
]
|
|
829
532
|
},
|
|
830
533
|
{
|
|
831
|
-
type: "
|
|
832
|
-
name: "
|
|
534
|
+
type: "error",
|
|
535
|
+
name: "ERC20InvalidSender",
|
|
833
536
|
inputs: [
|
|
834
537
|
{
|
|
835
|
-
name: "
|
|
836
|
-
type: "uint64",
|
|
837
|
-
indexed: false,
|
|
838
|
-
internalType: "uint64"
|
|
839
|
-
},
|
|
840
|
-
{
|
|
841
|
-
name: "idSource",
|
|
842
|
-
type: "string",
|
|
843
|
-
indexed: false,
|
|
844
|
-
internalType: "string"
|
|
845
|
-
},
|
|
846
|
-
{
|
|
847
|
-
name: "id",
|
|
848
|
-
type: "string",
|
|
849
|
-
indexed: false,
|
|
850
|
-
internalType: "string"
|
|
851
|
-
},
|
|
852
|
-
{
|
|
853
|
-
name: "tipper",
|
|
854
|
-
type: "address",
|
|
855
|
-
indexed: false,
|
|
856
|
-
internalType: "address"
|
|
857
|
-
},
|
|
858
|
-
{
|
|
859
|
-
name: "tokenAddr",
|
|
538
|
+
name: "sender",
|
|
860
539
|
type: "address",
|
|
861
|
-
indexed: false,
|
|
862
540
|
internalType: "address"
|
|
863
|
-
},
|
|
864
|
-
{
|
|
865
|
-
name: "amount",
|
|
866
|
-
type: "uint256",
|
|
867
|
-
indexed: false,
|
|
868
|
-
internalType: "uint256"
|
|
869
|
-
},
|
|
870
|
-
{
|
|
871
|
-
name: "tipTime",
|
|
872
|
-
type: "uint64",
|
|
873
|
-
indexed: false,
|
|
874
|
-
internalType: "uint64"
|
|
875
541
|
}
|
|
876
|
-
],
|
|
877
|
-
anonymous: false
|
|
878
|
-
},
|
|
879
|
-
{ type: "error", name: "InvalidInitialization", inputs: [] },
|
|
880
|
-
{ type: "error", name: "NotInitializing", inputs: [] },
|
|
881
|
-
{
|
|
882
|
-
type: "error",
|
|
883
|
-
name: "OwnableInvalidOwner",
|
|
884
|
-
inputs: [
|
|
885
|
-
{ name: "owner", type: "address", internalType: "address" }
|
|
886
542
|
]
|
|
887
543
|
},
|
|
888
544
|
{
|
|
889
545
|
type: "error",
|
|
890
|
-
name: "
|
|
546
|
+
name: "ERC20InvalidSpender",
|
|
891
547
|
inputs: [
|
|
892
|
-
{
|
|
548
|
+
{
|
|
549
|
+
name: "spender",
|
|
550
|
+
type: "address",
|
|
551
|
+
internalType: "address"
|
|
552
|
+
}
|
|
893
553
|
]
|
|
894
|
-
}
|
|
895
|
-
{ type: "error", name: "ReentrancyGuardReentrantCall", inputs: [] }
|
|
554
|
+
}
|
|
896
555
|
];
|
|
897
556
|
|
|
898
|
-
// src/
|
|
899
|
-
var
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
557
|
+
// src/classes/Erc20Contract.ts
|
|
558
|
+
var { parseUnits, formatUnits } = import_ethers2.ethers.utils;
|
|
559
|
+
var Erc20Contract = class {
|
|
560
|
+
provider;
|
|
561
|
+
contractInstance;
|
|
562
|
+
constructor(provider, address) {
|
|
563
|
+
if (!provider || !address) {
|
|
564
|
+
throw new Error("provider, address are required");
|
|
565
|
+
}
|
|
566
|
+
this.provider = provider;
|
|
567
|
+
this.contractInstance = new import_ethers2.ethers.Contract(address, erc20Abi_default, provider);
|
|
568
|
+
}
|
|
569
|
+
async decimals() {
|
|
570
|
+
const res = await this.contractInstance.decimals();
|
|
571
|
+
return res;
|
|
572
|
+
}
|
|
573
|
+
async symbol() {
|
|
574
|
+
const res = await this.contractInstance.symbol();
|
|
575
|
+
return res;
|
|
576
|
+
}
|
|
577
|
+
async allowance(userAddress, spenderAddress) {
|
|
578
|
+
const res = await this.contractInstance.allowance(userAddress, spenderAddress);
|
|
579
|
+
return res;
|
|
580
|
+
}
|
|
581
|
+
async getAddress() {
|
|
582
|
+
const address = await this.provider.getAddress();
|
|
583
|
+
return address;
|
|
584
|
+
}
|
|
585
|
+
async approve(approveParams) {
|
|
586
|
+
const { spenderAddress, approveAmount, otherParams } = approveParams;
|
|
587
|
+
return new Promise(async (resolve, reject) => {
|
|
588
|
+
try {
|
|
589
|
+
const userAddress = await this.getAddress();
|
|
590
|
+
const allowance = await this.allowance(userAddress, spenderAddress);
|
|
591
|
+
const decimals = await this.decimals();
|
|
592
|
+
const formatApproveAmount = parseUnits(approveAmount.toString(), decimals);
|
|
593
|
+
const formatAllowance = formatUnits(allowance.toString(), decimals);
|
|
594
|
+
console.log("allowance:", formatAllowance);
|
|
595
|
+
if (allowance.lt(formatApproveAmount)) {
|
|
596
|
+
let params = [spenderAddress, formatApproveAmount];
|
|
597
|
+
if (otherParams) {
|
|
598
|
+
params.push(otherParams);
|
|
599
|
+
}
|
|
600
|
+
const tx = await this.contractInstance.approve(...params);
|
|
601
|
+
await tx.wait();
|
|
602
|
+
console.log(`Approved: ${approveAmount.toString()}`);
|
|
603
|
+
} else {
|
|
604
|
+
console.log(`Already approved`);
|
|
605
|
+
}
|
|
606
|
+
resolve("Approved");
|
|
607
|
+
} catch (error) {
|
|
608
|
+
console.error("Approval failed:", error);
|
|
609
|
+
return reject(error);
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
};
|
|
614
|
+
var Erc20Contract_default = Erc20Contract;
|
|
615
|
+
|
|
616
|
+
// src/config/abi.json
|
|
617
|
+
var abi_default = [
|
|
618
|
+
{
|
|
619
|
+
type: "function",
|
|
620
|
+
name: "addBatchIdSource",
|
|
621
|
+
inputs: [
|
|
622
|
+
{ name: "sourceName_", type: "string[]", internalType: "string[]" },
|
|
623
|
+
{ name: "url_", type: "string[]", internalType: "string[]" },
|
|
624
|
+
{ name: "jsonPath_", type: "string[]", internalType: "string[]" }
|
|
625
|
+
],
|
|
626
|
+
outputs: [],
|
|
627
|
+
stateMutability: "nonpayable"
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
type: "function",
|
|
631
|
+
name: "claimByMultiSource",
|
|
632
|
+
inputs: [
|
|
633
|
+
{ name: "idSources", type: "string[]", internalType: "string[]" },
|
|
634
|
+
{
|
|
635
|
+
name: "att",
|
|
636
|
+
type: "tuple[]",
|
|
637
|
+
internalType: "struct Attestation[]",
|
|
638
|
+
components: [
|
|
639
|
+
{ name: "recipient", type: "address", internalType: "address" },
|
|
640
|
+
{
|
|
641
|
+
name: "request",
|
|
642
|
+
type: "tuple",
|
|
643
|
+
internalType: "struct AttNetworkRequest",
|
|
644
|
+
components: [
|
|
645
|
+
{ name: "url", type: "string", internalType: "string" },
|
|
646
|
+
{ name: "header", type: "string", internalType: "string" },
|
|
647
|
+
{ name: "method", type: "string", internalType: "string" },
|
|
648
|
+
{ name: "body", type: "string", internalType: "string" }
|
|
649
|
+
]
|
|
650
|
+
},
|
|
651
|
+
{
|
|
652
|
+
name: "reponseResolve",
|
|
653
|
+
type: "tuple[]",
|
|
654
|
+
internalType: "struct AttNetworkResponseResolve[]",
|
|
655
|
+
components: [
|
|
656
|
+
{ name: "keyName", type: "string", internalType: "string" },
|
|
657
|
+
{
|
|
658
|
+
name: "parseType",
|
|
659
|
+
type: "string",
|
|
660
|
+
internalType: "string"
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
name: "parsePath",
|
|
664
|
+
type: "string",
|
|
665
|
+
internalType: "string"
|
|
666
|
+
}
|
|
667
|
+
]
|
|
668
|
+
},
|
|
669
|
+
{ name: "data", type: "string", internalType: "string" },
|
|
670
|
+
{
|
|
671
|
+
name: "attConditions",
|
|
672
|
+
type: "string",
|
|
673
|
+
internalType: "string"
|
|
674
|
+
},
|
|
675
|
+
{ name: "timestamp", type: "uint64", internalType: "uint64" },
|
|
676
|
+
{
|
|
677
|
+
name: "additionParams",
|
|
678
|
+
type: "string",
|
|
679
|
+
internalType: "string"
|
|
680
|
+
},
|
|
681
|
+
{
|
|
682
|
+
name: "attestors",
|
|
683
|
+
type: "tuple[]",
|
|
684
|
+
internalType: "struct Attestor[]",
|
|
685
|
+
components: [
|
|
686
|
+
{
|
|
687
|
+
name: "attestorAddr",
|
|
688
|
+
type: "address",
|
|
689
|
+
internalType: "address"
|
|
690
|
+
},
|
|
691
|
+
{ name: "url", type: "string", internalType: "string" }
|
|
692
|
+
]
|
|
693
|
+
},
|
|
694
|
+
{ name: "signatures", type: "bytes[]", internalType: "bytes[]" }
|
|
695
|
+
]
|
|
696
|
+
}
|
|
697
|
+
],
|
|
698
|
+
outputs: [],
|
|
699
|
+
stateMutability: "payable"
|
|
700
|
+
},
|
|
701
|
+
{
|
|
702
|
+
type: "function",
|
|
703
|
+
name: "claimBySource",
|
|
704
|
+
inputs: [
|
|
705
|
+
{ name: "idSource", type: "string", internalType: "string" },
|
|
706
|
+
{
|
|
707
|
+
name: "att",
|
|
708
|
+
type: "tuple",
|
|
709
|
+
internalType: "struct Attestation",
|
|
710
|
+
components: [
|
|
711
|
+
{ name: "recipient", type: "address", internalType: "address" },
|
|
712
|
+
{
|
|
713
|
+
name: "request",
|
|
714
|
+
type: "tuple",
|
|
715
|
+
internalType: "struct AttNetworkRequest",
|
|
716
|
+
components: [
|
|
717
|
+
{ name: "url", type: "string", internalType: "string" },
|
|
718
|
+
{ name: "header", type: "string", internalType: "string" },
|
|
719
|
+
{ name: "method", type: "string", internalType: "string" },
|
|
720
|
+
{ name: "body", type: "string", internalType: "string" }
|
|
721
|
+
]
|
|
722
|
+
},
|
|
723
|
+
{
|
|
724
|
+
name: "reponseResolve",
|
|
725
|
+
type: "tuple[]",
|
|
726
|
+
internalType: "struct AttNetworkResponseResolve[]",
|
|
727
|
+
components: [
|
|
728
|
+
{ name: "keyName", type: "string", internalType: "string" },
|
|
729
|
+
{
|
|
730
|
+
name: "parseType",
|
|
731
|
+
type: "string",
|
|
732
|
+
internalType: "string"
|
|
733
|
+
},
|
|
734
|
+
{
|
|
735
|
+
name: "parsePath",
|
|
736
|
+
type: "string",
|
|
737
|
+
internalType: "string"
|
|
738
|
+
}
|
|
739
|
+
]
|
|
740
|
+
},
|
|
741
|
+
{ name: "data", type: "string", internalType: "string" },
|
|
742
|
+
{
|
|
743
|
+
name: "attConditions",
|
|
744
|
+
type: "string",
|
|
745
|
+
internalType: "string"
|
|
746
|
+
},
|
|
747
|
+
{ name: "timestamp", type: "uint64", internalType: "uint64" },
|
|
748
|
+
{
|
|
749
|
+
name: "additionParams",
|
|
750
|
+
type: "string",
|
|
751
|
+
internalType: "string"
|
|
752
|
+
},
|
|
753
|
+
{
|
|
754
|
+
name: "attestors",
|
|
755
|
+
type: "tuple[]",
|
|
756
|
+
internalType: "struct Attestor[]",
|
|
757
|
+
components: [
|
|
758
|
+
{
|
|
759
|
+
name: "attestorAddr",
|
|
760
|
+
type: "address",
|
|
761
|
+
internalType: "address"
|
|
762
|
+
},
|
|
763
|
+
{ name: "url", type: "string", internalType: "string" }
|
|
764
|
+
]
|
|
765
|
+
},
|
|
766
|
+
{ name: "signatures", type: "bytes[]", internalType: "bytes[]" }
|
|
767
|
+
]
|
|
768
|
+
}
|
|
769
|
+
],
|
|
770
|
+
outputs: [],
|
|
771
|
+
stateMutability: "payable"
|
|
772
|
+
},
|
|
773
|
+
{
|
|
774
|
+
type: "function",
|
|
775
|
+
name: "claimBySourceAndTipIndex",
|
|
776
|
+
inputs: [
|
|
777
|
+
{ name: "idSource", type: "string", internalType: "string" },
|
|
778
|
+
{
|
|
779
|
+
name: "att",
|
|
780
|
+
type: "tuple",
|
|
781
|
+
internalType: "struct Attestation",
|
|
782
|
+
components: [
|
|
783
|
+
{ name: "recipient", type: "address", internalType: "address" },
|
|
784
|
+
{
|
|
785
|
+
name: "request",
|
|
786
|
+
type: "tuple",
|
|
787
|
+
internalType: "struct AttNetworkRequest",
|
|
788
|
+
components: [
|
|
789
|
+
{ name: "url", type: "string", internalType: "string" },
|
|
790
|
+
{ name: "header", type: "string", internalType: "string" },
|
|
791
|
+
{ name: "method", type: "string", internalType: "string" },
|
|
792
|
+
{ name: "body", type: "string", internalType: "string" }
|
|
793
|
+
]
|
|
794
|
+
},
|
|
795
|
+
{
|
|
796
|
+
name: "reponseResolve",
|
|
797
|
+
type: "tuple[]",
|
|
798
|
+
internalType: "struct AttNetworkResponseResolve[]",
|
|
799
|
+
components: [
|
|
800
|
+
{ name: "keyName", type: "string", internalType: "string" },
|
|
801
|
+
{
|
|
802
|
+
name: "parseType",
|
|
803
|
+
type: "string",
|
|
804
|
+
internalType: "string"
|
|
805
|
+
},
|
|
806
|
+
{
|
|
807
|
+
name: "parsePath",
|
|
808
|
+
type: "string",
|
|
809
|
+
internalType: "string"
|
|
810
|
+
}
|
|
811
|
+
]
|
|
812
|
+
},
|
|
813
|
+
{ name: "data", type: "string", internalType: "string" },
|
|
814
|
+
{
|
|
815
|
+
name: "attConditions",
|
|
816
|
+
type: "string",
|
|
817
|
+
internalType: "string"
|
|
818
|
+
},
|
|
819
|
+
{ name: "timestamp", type: "uint64", internalType: "uint64" },
|
|
820
|
+
{
|
|
821
|
+
name: "additionParams",
|
|
822
|
+
type: "string",
|
|
823
|
+
internalType: "string"
|
|
824
|
+
},
|
|
825
|
+
{
|
|
826
|
+
name: "attestors",
|
|
827
|
+
type: "tuple[]",
|
|
828
|
+
internalType: "struct Attestor[]",
|
|
829
|
+
components: [
|
|
830
|
+
{
|
|
831
|
+
name: "attestorAddr",
|
|
832
|
+
type: "address",
|
|
833
|
+
internalType: "address"
|
|
834
|
+
},
|
|
835
|
+
{ name: "url", type: "string", internalType: "string" }
|
|
836
|
+
]
|
|
837
|
+
},
|
|
838
|
+
{ name: "signatures", type: "bytes[]", internalType: "bytes[]" }
|
|
839
|
+
]
|
|
840
|
+
},
|
|
841
|
+
{ name: "index", type: "uint32", internalType: "uint32" }
|
|
842
|
+
],
|
|
843
|
+
outputs: [],
|
|
844
|
+
stateMutability: "payable"
|
|
845
|
+
},
|
|
846
|
+
{
|
|
847
|
+
type: "function",
|
|
848
|
+
name: "claimFee",
|
|
849
|
+
inputs: [],
|
|
850
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
851
|
+
stateMutability: "view"
|
|
852
|
+
},
|
|
853
|
+
{
|
|
854
|
+
type: "function",
|
|
855
|
+
name: "feeRecipient",
|
|
856
|
+
inputs: [],
|
|
857
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
858
|
+
stateMutability: "view"
|
|
859
|
+
},
|
|
860
|
+
{
|
|
861
|
+
type: "function",
|
|
862
|
+
name: "getTipRecords",
|
|
863
|
+
inputs: [
|
|
864
|
+
{
|
|
865
|
+
name: "tipRecipient",
|
|
866
|
+
type: "tuple",
|
|
867
|
+
internalType: "struct TipRecipient",
|
|
868
|
+
components: [
|
|
869
|
+
{ name: "idSource", type: "string", internalType: "string" },
|
|
870
|
+
{ name: "id", type: "string", internalType: "string" }
|
|
871
|
+
]
|
|
872
|
+
}
|
|
873
|
+
],
|
|
874
|
+
outputs: [
|
|
875
|
+
{
|
|
876
|
+
name: "",
|
|
877
|
+
type: "tuple[]",
|
|
878
|
+
internalType: "struct TipRecord[]",
|
|
879
|
+
components: [
|
|
880
|
+
{ name: "amount", type: "uint256", internalType: "uint256" },
|
|
881
|
+
{
|
|
882
|
+
name: "tipToken",
|
|
883
|
+
type: "tuple",
|
|
884
|
+
internalType: "struct TipToken",
|
|
885
|
+
components: [
|
|
886
|
+
{
|
|
887
|
+
name: "tokenType",
|
|
888
|
+
type: "uint32",
|
|
889
|
+
internalType: "uint32"
|
|
890
|
+
},
|
|
891
|
+
{
|
|
892
|
+
name: "tokenAddress",
|
|
893
|
+
type: "address",
|
|
894
|
+
internalType: "address"
|
|
895
|
+
}
|
|
896
|
+
]
|
|
897
|
+
},
|
|
898
|
+
{ name: "timestamp", type: "uint64", internalType: "uint64" },
|
|
899
|
+
{ name: "tipper", type: "address", internalType: "address" },
|
|
900
|
+
{ name: "nftIds", type: "uint256[]", internalType: "uint256[]" }
|
|
901
|
+
]
|
|
902
|
+
}
|
|
903
|
+
],
|
|
904
|
+
stateMutability: "view"
|
|
905
|
+
},
|
|
906
|
+
{
|
|
907
|
+
type: "function",
|
|
908
|
+
name: "idSourceCache",
|
|
909
|
+
inputs: [{ name: "", type: "string", internalType: "string" }],
|
|
910
|
+
outputs: [
|
|
911
|
+
{ name: "url", type: "string", internalType: "string" },
|
|
912
|
+
{ name: "jsonPath", type: "string", internalType: "string" }
|
|
913
|
+
],
|
|
914
|
+
stateMutability: "view"
|
|
915
|
+
},
|
|
916
|
+
{
|
|
917
|
+
type: "function",
|
|
918
|
+
name: "initialize",
|
|
919
|
+
inputs: [
|
|
920
|
+
{ name: "owner", type: "address", internalType: "address" },
|
|
921
|
+
{
|
|
922
|
+
name: "primusZKTLS_",
|
|
923
|
+
type: "address",
|
|
924
|
+
internalType: "contract IPrimusZKTLS"
|
|
925
|
+
},
|
|
926
|
+
{ name: "feeRecipient_", type: "address", internalType: "address" },
|
|
927
|
+
{ name: "claimFee_", type: "uint256", internalType: "uint256" }
|
|
928
|
+
],
|
|
929
|
+
outputs: [],
|
|
930
|
+
stateMutability: "nonpayable"
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
type: "function",
|
|
934
|
+
name: "owner",
|
|
935
|
+
inputs: [],
|
|
936
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
937
|
+
stateMutability: "view"
|
|
938
|
+
},
|
|
939
|
+
{
|
|
940
|
+
type: "function",
|
|
941
|
+
name: "primusZKTLS",
|
|
942
|
+
inputs: [],
|
|
943
|
+
outputs: [
|
|
944
|
+
{ name: "", type: "address", internalType: "contract IPrimusZKTLS" }
|
|
945
|
+
],
|
|
946
|
+
stateMutability: "view"
|
|
947
|
+
},
|
|
948
|
+
{
|
|
949
|
+
type: "function",
|
|
950
|
+
name: "renounceOwnership",
|
|
951
|
+
inputs: [],
|
|
952
|
+
outputs: [],
|
|
953
|
+
stateMutability: "nonpayable"
|
|
954
|
+
},
|
|
955
|
+
{
|
|
956
|
+
type: "function",
|
|
957
|
+
name: "setClaimFee",
|
|
958
|
+
inputs: [
|
|
959
|
+
{ name: "claimFee_", type: "uint256", internalType: "uint256" }
|
|
960
|
+
],
|
|
961
|
+
outputs: [],
|
|
962
|
+
stateMutability: "nonpayable"
|
|
963
|
+
},
|
|
964
|
+
{
|
|
965
|
+
type: "function",
|
|
966
|
+
name: "setFeeRecipient",
|
|
967
|
+
inputs: [
|
|
968
|
+
{ name: "feeRecipient_", type: "address", internalType: "address" }
|
|
969
|
+
],
|
|
970
|
+
outputs: [],
|
|
971
|
+
stateMutability: "nonpayable"
|
|
972
|
+
},
|
|
973
|
+
{
|
|
974
|
+
type: "function",
|
|
975
|
+
name: "setPrimusZKTLS",
|
|
976
|
+
inputs: [
|
|
977
|
+
{
|
|
978
|
+
name: "primusZKTLS_",
|
|
979
|
+
type: "address",
|
|
980
|
+
internalType: "contract IPrimusZKTLS"
|
|
981
|
+
}
|
|
982
|
+
],
|
|
983
|
+
outputs: [],
|
|
984
|
+
stateMutability: "nonpayable"
|
|
985
|
+
},
|
|
986
|
+
{
|
|
987
|
+
type: "function",
|
|
988
|
+
name: "setWithdrawDelay",
|
|
989
|
+
inputs: [
|
|
990
|
+
{ name: "delay", type: "uint256", internalType: "uint256" }
|
|
991
|
+
],
|
|
992
|
+
outputs: [],
|
|
993
|
+
stateMutability: "nonpayable"
|
|
994
|
+
},
|
|
995
|
+
{
|
|
996
|
+
type: "function",
|
|
997
|
+
name: "tip",
|
|
998
|
+
inputs: [
|
|
999
|
+
{
|
|
1000
|
+
name: "token",
|
|
1001
|
+
type: "tuple",
|
|
1002
|
+
internalType: "struct TipToken",
|
|
1003
|
+
components: [
|
|
1004
|
+
{ name: "tokenType", type: "uint32", internalType: "uint32" },
|
|
1005
|
+
{
|
|
1006
|
+
name: "tokenAddress",
|
|
1007
|
+
type: "address",
|
|
1008
|
+
internalType: "address"
|
|
1009
|
+
}
|
|
1010
|
+
]
|
|
1011
|
+
},
|
|
1012
|
+
{
|
|
1013
|
+
name: "recipient",
|
|
1014
|
+
type: "tuple",
|
|
1015
|
+
internalType: "struct TipRecipientInfo",
|
|
1016
|
+
components: [
|
|
1017
|
+
{ name: "idSource", type: "string", internalType: "string" },
|
|
1018
|
+
{ name: "id", type: "string", internalType: "string" },
|
|
1019
|
+
{ name: "amount", type: "uint256", internalType: "uint256" },
|
|
1020
|
+
{ name: "nftIds", type: "uint256[]", internalType: "uint256[]" }
|
|
1021
|
+
]
|
|
1022
|
+
}
|
|
1023
|
+
],
|
|
1024
|
+
outputs: [],
|
|
1025
|
+
stateMutability: "payable"
|
|
1026
|
+
},
|
|
1027
|
+
{
|
|
1028
|
+
type: "function",
|
|
1029
|
+
name: "tipBatch",
|
|
1030
|
+
inputs: [
|
|
1031
|
+
{
|
|
1032
|
+
name: "token",
|
|
1033
|
+
type: "tuple",
|
|
1034
|
+
internalType: "struct TipToken",
|
|
1035
|
+
components: [
|
|
1036
|
+
{ name: "tokenType", type: "uint32", internalType: "uint32" },
|
|
1037
|
+
{
|
|
1038
|
+
name: "tokenAddress",
|
|
1039
|
+
type: "address",
|
|
1040
|
+
internalType: "address"
|
|
1041
|
+
}
|
|
1042
|
+
]
|
|
1043
|
+
},
|
|
1044
|
+
{
|
|
1045
|
+
name: "recipients",
|
|
1046
|
+
type: "tuple[]",
|
|
1047
|
+
internalType: "struct TipRecipientInfo[]",
|
|
1048
|
+
components: [
|
|
1049
|
+
{ name: "idSource", type: "string", internalType: "string" },
|
|
1050
|
+
{ name: "id", type: "string", internalType: "string" },
|
|
1051
|
+
{ name: "amount", type: "uint256", internalType: "uint256" },
|
|
1052
|
+
{ name: "nftIds", type: "uint256[]", internalType: "uint256[]" }
|
|
1053
|
+
]
|
|
1054
|
+
}
|
|
1055
|
+
],
|
|
1056
|
+
outputs: [],
|
|
1057
|
+
stateMutability: "payable"
|
|
1058
|
+
},
|
|
1059
|
+
{
|
|
1060
|
+
type: "function",
|
|
1061
|
+
name: "tipperWithdraw",
|
|
1062
|
+
inputs: [
|
|
1063
|
+
{
|
|
1064
|
+
name: "tipRecipients",
|
|
1065
|
+
type: "tuple[]",
|
|
1066
|
+
internalType: "struct TipWithdrawInfo[]",
|
|
1067
|
+
components: [
|
|
1068
|
+
{ name: "idSource", type: "string", internalType: "string" },
|
|
1069
|
+
{ name: "id", type: "string", internalType: "string" },
|
|
1070
|
+
{ name: "tipTimestamp", type: "uint64", internalType: "uint64" }
|
|
1071
|
+
]
|
|
1072
|
+
}
|
|
1073
|
+
],
|
|
1074
|
+
outputs: [],
|
|
1075
|
+
stateMutability: "nonpayable"
|
|
1076
|
+
},
|
|
1077
|
+
{
|
|
1078
|
+
type: "function",
|
|
1079
|
+
name: "transferOwnership",
|
|
1080
|
+
inputs: [
|
|
1081
|
+
{ name: "newOwner", type: "address", internalType: "address" }
|
|
1082
|
+
],
|
|
1083
|
+
outputs: [],
|
|
1084
|
+
stateMutability: "nonpayable"
|
|
1085
|
+
},
|
|
1086
|
+
{
|
|
1087
|
+
type: "function",
|
|
1088
|
+
name: "withdrawDelay",
|
|
1089
|
+
inputs: [],
|
|
1090
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
1091
|
+
stateMutability: "view"
|
|
1092
|
+
},
|
|
1093
|
+
{
|
|
1094
|
+
type: "event",
|
|
1095
|
+
name: "ClaimEvent",
|
|
1096
|
+
inputs: [
|
|
1097
|
+
{
|
|
1098
|
+
name: "recipient",
|
|
1099
|
+
type: "address",
|
|
1100
|
+
indexed: true,
|
|
1101
|
+
internalType: "address"
|
|
1102
|
+
},
|
|
1103
|
+
{
|
|
1104
|
+
name: "claimTime",
|
|
1105
|
+
type: "uint64",
|
|
1106
|
+
indexed: false,
|
|
1107
|
+
internalType: "uint64"
|
|
1108
|
+
},
|
|
1109
|
+
{
|
|
1110
|
+
name: "idSource",
|
|
1111
|
+
type: "string",
|
|
1112
|
+
indexed: false,
|
|
1113
|
+
internalType: "string"
|
|
1114
|
+
},
|
|
1115
|
+
{
|
|
1116
|
+
name: "id",
|
|
1117
|
+
type: "string",
|
|
1118
|
+
indexed: false,
|
|
1119
|
+
internalType: "string"
|
|
1120
|
+
},
|
|
1121
|
+
{
|
|
1122
|
+
name: "tipper",
|
|
1123
|
+
type: "address",
|
|
1124
|
+
indexed: false,
|
|
1125
|
+
internalType: "address"
|
|
1126
|
+
},
|
|
1127
|
+
{
|
|
1128
|
+
name: "tokenAddr",
|
|
1129
|
+
type: "address",
|
|
1130
|
+
indexed: false,
|
|
1131
|
+
internalType: "address"
|
|
1132
|
+
},
|
|
1133
|
+
{
|
|
1134
|
+
name: "amount",
|
|
1135
|
+
type: "uint256",
|
|
1136
|
+
indexed: false,
|
|
1137
|
+
internalType: "uint256"
|
|
1138
|
+
},
|
|
1139
|
+
{
|
|
1140
|
+
name: "tipTime",
|
|
1141
|
+
type: "uint64",
|
|
1142
|
+
indexed: false,
|
|
1143
|
+
internalType: "uint64"
|
|
1144
|
+
}
|
|
1145
|
+
],
|
|
1146
|
+
anonymous: false
|
|
1147
|
+
},
|
|
1148
|
+
{
|
|
1149
|
+
type: "event",
|
|
1150
|
+
name: "Initialized",
|
|
1151
|
+
inputs: [
|
|
1152
|
+
{
|
|
1153
|
+
name: "version",
|
|
1154
|
+
type: "uint64",
|
|
1155
|
+
indexed: false,
|
|
1156
|
+
internalType: "uint64"
|
|
1157
|
+
}
|
|
1158
|
+
],
|
|
1159
|
+
anonymous: false
|
|
1160
|
+
},
|
|
1161
|
+
{
|
|
1162
|
+
type: "event",
|
|
1163
|
+
name: "OwnershipTransferred",
|
|
1164
|
+
inputs: [
|
|
1165
|
+
{
|
|
1166
|
+
name: "previousOwner",
|
|
1167
|
+
type: "address",
|
|
1168
|
+
indexed: true,
|
|
1169
|
+
internalType: "address"
|
|
1170
|
+
},
|
|
1171
|
+
{
|
|
1172
|
+
name: "newOwner",
|
|
1173
|
+
type: "address",
|
|
1174
|
+
indexed: true,
|
|
1175
|
+
internalType: "address"
|
|
1176
|
+
}
|
|
1177
|
+
],
|
|
1178
|
+
anonymous: false
|
|
1179
|
+
},
|
|
1180
|
+
{
|
|
1181
|
+
type: "event",
|
|
1182
|
+
name: "TipEvent",
|
|
1183
|
+
inputs: [
|
|
1184
|
+
{
|
|
1185
|
+
name: "idSource",
|
|
1186
|
+
type: "string",
|
|
1187
|
+
indexed: false,
|
|
1188
|
+
internalType: "string"
|
|
1189
|
+
},
|
|
1190
|
+
{
|
|
1191
|
+
name: "id",
|
|
1192
|
+
type: "string",
|
|
1193
|
+
indexed: false,
|
|
1194
|
+
internalType: "string"
|
|
1195
|
+
},
|
|
1196
|
+
{
|
|
1197
|
+
name: "tipper",
|
|
1198
|
+
type: "address",
|
|
1199
|
+
indexed: false,
|
|
1200
|
+
internalType: "address"
|
|
1201
|
+
},
|
|
1202
|
+
{
|
|
1203
|
+
name: "tokenAddr",
|
|
1204
|
+
type: "address",
|
|
1205
|
+
indexed: false,
|
|
1206
|
+
internalType: "address"
|
|
1207
|
+
},
|
|
1208
|
+
{
|
|
1209
|
+
name: "amount",
|
|
1210
|
+
type: "uint256",
|
|
1211
|
+
indexed: false,
|
|
1212
|
+
internalType: "uint256"
|
|
1213
|
+
},
|
|
1214
|
+
{
|
|
1215
|
+
name: "tipTime",
|
|
1216
|
+
type: "uint64",
|
|
1217
|
+
indexed: false,
|
|
1218
|
+
internalType: "uint64"
|
|
1219
|
+
}
|
|
1220
|
+
],
|
|
1221
|
+
anonymous: false
|
|
1222
|
+
},
|
|
1223
|
+
{
|
|
1224
|
+
type: "event",
|
|
1225
|
+
name: "WithdrawEvent",
|
|
1226
|
+
inputs: [
|
|
1227
|
+
{
|
|
1228
|
+
name: "withdrawTime",
|
|
1229
|
+
type: "uint64",
|
|
1230
|
+
indexed: false,
|
|
1231
|
+
internalType: "uint64"
|
|
1232
|
+
},
|
|
1233
|
+
{
|
|
1234
|
+
name: "idSource",
|
|
1235
|
+
type: "string",
|
|
1236
|
+
indexed: false,
|
|
1237
|
+
internalType: "string"
|
|
1238
|
+
},
|
|
1239
|
+
{
|
|
1240
|
+
name: "id",
|
|
1241
|
+
type: "string",
|
|
1242
|
+
indexed: false,
|
|
1243
|
+
internalType: "string"
|
|
1244
|
+
},
|
|
1245
|
+
{
|
|
1246
|
+
name: "tipper",
|
|
1247
|
+
type: "address",
|
|
1248
|
+
indexed: false,
|
|
1249
|
+
internalType: "address"
|
|
1250
|
+
},
|
|
1251
|
+
{
|
|
1252
|
+
name: "tokenAddr",
|
|
1253
|
+
type: "address",
|
|
1254
|
+
indexed: false,
|
|
1255
|
+
internalType: "address"
|
|
1256
|
+
},
|
|
1257
|
+
{
|
|
1258
|
+
name: "amount",
|
|
1259
|
+
type: "uint256",
|
|
1260
|
+
indexed: false,
|
|
1261
|
+
internalType: "uint256"
|
|
1262
|
+
},
|
|
1263
|
+
{
|
|
1264
|
+
name: "tipTime",
|
|
1265
|
+
type: "uint64",
|
|
1266
|
+
indexed: false,
|
|
1267
|
+
internalType: "uint64"
|
|
1268
|
+
}
|
|
1269
|
+
],
|
|
1270
|
+
anonymous: false
|
|
1271
|
+
},
|
|
1272
|
+
{ type: "error", name: "InvalidInitialization", inputs: [] },
|
|
1273
|
+
{ type: "error", name: "NotInitializing", inputs: [] },
|
|
1274
|
+
{
|
|
1275
|
+
type: "error",
|
|
1276
|
+
name: "OwnableInvalidOwner",
|
|
1277
|
+
inputs: [
|
|
1278
|
+
{ name: "owner", type: "address", internalType: "address" }
|
|
1279
|
+
]
|
|
1280
|
+
},
|
|
1281
|
+
{
|
|
1282
|
+
type: "error",
|
|
1283
|
+
name: "OwnableUnauthorizedAccount",
|
|
1284
|
+
inputs: [
|
|
1285
|
+
{ name: "account", type: "address", internalType: "address" }
|
|
1286
|
+
]
|
|
1287
|
+
},
|
|
1288
|
+
{ type: "error", name: "ReentrancyGuardReentrantCall", inputs: [] }
|
|
1289
|
+
];
|
|
1290
|
+
|
|
1291
|
+
// src/config/erc721Abi.json
|
|
1292
|
+
var erc721Abi_default = [
|
|
1293
|
+
{
|
|
1294
|
+
type: "function",
|
|
1295
|
+
name: "supportsInterface",
|
|
1296
|
+
stateMutability: "view",
|
|
1297
|
+
inputs: [
|
|
1298
|
+
{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }
|
|
1299
|
+
],
|
|
1300
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }]
|
|
1301
|
+
},
|
|
1302
|
+
{
|
|
1303
|
+
type: "function",
|
|
1304
|
+
name: "balanceOf",
|
|
1305
|
+
stateMutability: "view",
|
|
1306
|
+
inputs: [
|
|
1307
|
+
{ internalType: "address", name: "owner", type: "address" }
|
|
1308
|
+
],
|
|
1309
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }]
|
|
1310
|
+
},
|
|
1311
|
+
{
|
|
1312
|
+
type: "function",
|
|
1313
|
+
name: "ownerOf",
|
|
1314
|
+
stateMutability: "view",
|
|
1315
|
+
inputs: [
|
|
1316
|
+
{ internalType: "uint256", name: "tokenId", type: "uint256" }
|
|
1317
|
+
],
|
|
1318
|
+
outputs: [{ internalType: "address", name: "", type: "address" }]
|
|
1319
|
+
},
|
|
1320
|
+
{
|
|
1321
|
+
type: "function",
|
|
1322
|
+
name: "tokenURI",
|
|
1323
|
+
stateMutability: "view",
|
|
1324
|
+
inputs: [
|
|
1325
|
+
{ internalType: "uint256", name: "tokenId", type: "uint256" }
|
|
1326
|
+
],
|
|
1327
|
+
outputs: [{ internalType: "string", name: "", type: "string" }]
|
|
1328
|
+
},
|
|
1329
|
+
{
|
|
1330
|
+
type: "function",
|
|
1331
|
+
name: "approve",
|
|
1332
|
+
stateMutability: "nonpayable",
|
|
1333
|
+
inputs: [
|
|
1334
|
+
{ internalType: "address", name: "to", type: "address" },
|
|
1335
|
+
{ internalType: "uint256", name: "tokenId", type: "uint256" }
|
|
1336
|
+
],
|
|
1337
|
+
outputs: []
|
|
1338
|
+
},
|
|
1339
|
+
{
|
|
1340
|
+
type: "function",
|
|
1341
|
+
name: "getApproved",
|
|
1342
|
+
stateMutability: "view",
|
|
1343
|
+
inputs: [
|
|
1344
|
+
{ internalType: "uint256", name: "tokenId", type: "uint256" }
|
|
1345
|
+
],
|
|
1346
|
+
outputs: [{ internalType: "address", name: "", type: "address" }]
|
|
1347
|
+
},
|
|
1348
|
+
{
|
|
1349
|
+
type: "function",
|
|
1350
|
+
name: "setApprovalForAll",
|
|
1351
|
+
stateMutability: "nonpayable",
|
|
1352
|
+
inputs: [
|
|
1353
|
+
{ internalType: "address", name: "operator", type: "address" },
|
|
1354
|
+
{ internalType: "bool", name: "approved", type: "bool" }
|
|
1355
|
+
],
|
|
1356
|
+
outputs: []
|
|
1357
|
+
},
|
|
1358
|
+
{
|
|
1359
|
+
type: "function",
|
|
1360
|
+
name: "isApprovedForAll",
|
|
1361
|
+
stateMutability: "view",
|
|
1362
|
+
inputs: [
|
|
1363
|
+
{ internalType: "address", name: "owner", type: "address" },
|
|
1364
|
+
{ internalType: "address", name: "operator", type: "address" }
|
|
1365
|
+
],
|
|
1366
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }]
|
|
1367
|
+
},
|
|
1368
|
+
{
|
|
1369
|
+
type: "function",
|
|
1370
|
+
name: "transferFrom",
|
|
1371
|
+
stateMutability: "nonpayable",
|
|
1372
|
+
inputs: [
|
|
1373
|
+
{ internalType: "address", name: "from", type: "address" },
|
|
1374
|
+
{ internalType: "address", name: "to", type: "address" },
|
|
1375
|
+
{ internalType: "uint256", name: "tokenId", type: "uint256" }
|
|
1376
|
+
],
|
|
1377
|
+
outputs: []
|
|
1378
|
+
},
|
|
1379
|
+
{
|
|
1380
|
+
type: "function",
|
|
1381
|
+
name: "safeTransferFrom",
|
|
1382
|
+
stateMutability: "nonpayable",
|
|
1383
|
+
inputs: [
|
|
1384
|
+
{ internalType: "address", name: "from", type: "address" },
|
|
1385
|
+
{ internalType: "address", name: "to", type: "address" },
|
|
1386
|
+
{ internalType: "uint256", name: "tokenId", type: "uint256" }
|
|
1387
|
+
],
|
|
1388
|
+
outputs: []
|
|
1389
|
+
},
|
|
1390
|
+
{
|
|
1391
|
+
type: "function",
|
|
1392
|
+
name: "name",
|
|
1393
|
+
stateMutability: "view",
|
|
1394
|
+
inputs: [],
|
|
1395
|
+
outputs: [{ internalType: "string", name: "", type: "string" }]
|
|
1396
|
+
},
|
|
1397
|
+
{
|
|
1398
|
+
type: "function",
|
|
1399
|
+
name: "symbol",
|
|
1400
|
+
stateMutability: "view",
|
|
1401
|
+
inputs: [],
|
|
1402
|
+
outputs: [{ internalType: "string", name: "", type: "string" }]
|
|
1403
|
+
}
|
|
1404
|
+
];
|
|
1405
|
+
|
|
1406
|
+
// src/classes/Erc721Contract.ts
|
|
1407
|
+
var Erc721Contract = class {
|
|
1408
|
+
contractInstance;
|
|
1409
|
+
constructor(provider, address) {
|
|
1410
|
+
if (!provider || !address) {
|
|
1411
|
+
throw new Error("provider, address are required");
|
|
1412
|
+
}
|
|
1413
|
+
this.contractInstance = new Contract_default(provider, address, erc721Abi_default);
|
|
1414
|
+
}
|
|
1415
|
+
async approve(address, tokenId) {
|
|
1416
|
+
return new Promise(async (resolve, reject) => {
|
|
1417
|
+
try {
|
|
1418
|
+
const approver = await this.contractInstance.callMethod("getApproved", [tokenId]);
|
|
1419
|
+
if (approver === address) {
|
|
1420
|
+
console.log(`Already approved:: ${approver}`);
|
|
1421
|
+
resolve("Approved");
|
|
1422
|
+
} else {
|
|
1423
|
+
await this.contractInstance.sendTransaction("approve", [address, tokenId]);
|
|
1424
|
+
console.log(`Approved`);
|
|
1425
|
+
resolve("Approved");
|
|
1426
|
+
}
|
|
1427
|
+
} catch (error) {
|
|
1428
|
+
console.error("Approval failed:", error);
|
|
1429
|
+
return reject(error);
|
|
1430
|
+
}
|
|
1431
|
+
});
|
|
1432
|
+
}
|
|
1433
|
+
// ownerAddress: string,
|
|
1434
|
+
async setApprovalForAll(operatorAddress) {
|
|
1435
|
+
return new Promise(async (resolve, reject) => {
|
|
1436
|
+
try {
|
|
1437
|
+
await this.contractInstance.sendTransaction("setApprovalForAll", [operatorAddress, true]);
|
|
1438
|
+
console.log(`Approved`);
|
|
1439
|
+
resolve("Approved");
|
|
1440
|
+
} catch (error) {
|
|
1441
|
+
console.error("Approval failed:", error);
|
|
1442
|
+
return reject(error);
|
|
1443
|
+
}
|
|
1444
|
+
});
|
|
1445
|
+
}
|
|
1446
|
+
async fetchMetaData(nftContractAddress, tokenId) {
|
|
1447
|
+
return new Promise(async (resolve, reject) => {
|
|
1448
|
+
try {
|
|
1449
|
+
let url = await this.contractInstance.callMethod("tokenURI", [tokenId]);
|
|
1450
|
+
if (url.startsWith("ipfs://")) {
|
|
1451
|
+
url = url.replace("ipfs://", "https://ipfs.io/ipfs/");
|
|
1452
|
+
}
|
|
1453
|
+
const res = await fetch(url);
|
|
1454
|
+
if (!res.ok) {
|
|
1455
|
+
return reject(`Failed to fetch metadata from ${url}`);
|
|
1456
|
+
}
|
|
1457
|
+
let metadata = await res.json();
|
|
1458
|
+
if (metadata.image && metadata.image.startsWith("ipfs://")) {
|
|
1459
|
+
metadata.image = metadata.image.replace(
|
|
1460
|
+
"ipfs://",
|
|
1461
|
+
"https://ipfs.io/ipfs/"
|
|
1462
|
+
);
|
|
1463
|
+
}
|
|
1464
|
+
metadata.address = nftContractAddress;
|
|
1465
|
+
metadata.tokenId = tokenId;
|
|
1466
|
+
return resolve(metadata);
|
|
1467
|
+
} catch (error) {
|
|
1468
|
+
return reject(error);
|
|
1469
|
+
}
|
|
1470
|
+
});
|
|
1471
|
+
}
|
|
1472
|
+
};
|
|
1473
|
+
var Erc721Contract_default = Erc721Contract;
|
|
1474
|
+
|
|
1475
|
+
// src/classes/Fund.ts
|
|
1476
|
+
var { parseUnits: parseUnits2, formatUnits: formatUnits2 } = import_ethers3.ethers.utils;
|
|
1477
|
+
var Fund = class {
|
|
1478
|
+
fundContract;
|
|
1479
|
+
provider;
|
|
1480
|
+
formatProvider;
|
|
1481
|
+
chainId;
|
|
1482
|
+
constructor() {
|
|
1483
|
+
}
|
|
1484
|
+
async init(provider, chainId) {
|
|
1485
|
+
return new Promise(async (resolve, reject) => {
|
|
1486
|
+
try {
|
|
1487
|
+
const fundContractAddress = Fund_CONTRACTS[chainId];
|
|
1488
|
+
if (!fundContractAddress) {
|
|
1489
|
+
return reject(`Unsupported chainId:${chainId}`);
|
|
1490
|
+
}
|
|
1491
|
+
this.fundContract = new Contract_default(provider, fundContractAddress, abi_default);
|
|
1492
|
+
this.provider = provider;
|
|
1493
|
+
this.chainId = chainId;
|
|
1494
|
+
resolve("success");
|
|
1495
|
+
} catch (error) {
|
|
1496
|
+
return reject(error);
|
|
1497
|
+
}
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1500
|
+
async fund(tokenInfo, recipientInfo) {
|
|
1501
|
+
return new Promise(async (resolve, reject) => {
|
|
1502
|
+
try {
|
|
1503
|
+
const recipientInfos = [];
|
|
1504
|
+
recipientInfos[0] = recipientInfo;
|
|
1505
|
+
let decimals = 18;
|
|
1506
|
+
let params = [];
|
|
1507
|
+
if (tokenInfo.tokenType === 0) {
|
|
1508
|
+
await this.approve(tokenInfo, recipientInfos);
|
|
1509
|
+
console.log("after approve in fund fn");
|
|
1510
|
+
const tokenContract = new Erc20Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
1511
|
+
decimals = await tokenContract.decimals();
|
|
1512
|
+
} else if (tokenInfo.tokenType === 2) {
|
|
1513
|
+
decimals = 0;
|
|
1514
|
+
const erc721ContractInstance = new Erc721Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
1515
|
+
await erc721ContractInstance.approve(this.fundContract.address, recipientInfo.nftIds[0]);
|
|
1516
|
+
}
|
|
1517
|
+
const tokenAmount = parseUnits2(recipientInfo.tokenAmount.toString(), decimals);
|
|
1518
|
+
const newFundRecipientInfo = {
|
|
1519
|
+
idSource: recipientInfo.socialPlatform,
|
|
1520
|
+
id: recipientInfo.userIdentifier,
|
|
1521
|
+
amount: tokenAmount,
|
|
1522
|
+
nftIds: recipientInfo.nftIds
|
|
1523
|
+
};
|
|
1524
|
+
if (tokenInfo.tokenType === 1) {
|
|
1525
|
+
params = [tokenInfo, newFundRecipientInfo, { value: tokenAmount }];
|
|
1526
|
+
} else {
|
|
1527
|
+
params = [tokenInfo, newFundRecipientInfo];
|
|
1528
|
+
}
|
|
1529
|
+
if ([97, 56].includes(this.chainId)) {
|
|
1530
|
+
const gasPrice = await this.provider.getGasPrice();
|
|
1531
|
+
params[2] = params[2] ? { ...params[2], gasPrice } : { gasPrice };
|
|
1532
|
+
}
|
|
1533
|
+
console.log("tip-params", params, this.chainId);
|
|
1534
|
+
const result = await this.fundContract.sendTransaction("tip", params);
|
|
1535
|
+
resolve(result);
|
|
1536
|
+
} catch (error) {
|
|
1537
|
+
return reject(error);
|
|
1538
|
+
}
|
|
1539
|
+
});
|
|
1540
|
+
}
|
|
1541
|
+
async onlyFund(tokenInfo, recipientInfo) {
|
|
1542
|
+
return new Promise(async (resolve, reject) => {
|
|
1543
|
+
try {
|
|
1544
|
+
const recipientInfos = [];
|
|
1545
|
+
recipientInfos[0] = recipientInfo;
|
|
1546
|
+
let decimals = 18;
|
|
1547
|
+
let params = [];
|
|
1548
|
+
if (tokenInfo.tokenType === 0) {
|
|
1549
|
+
const tokenContract = new Erc20Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
1550
|
+
decimals = await tokenContract.decimals();
|
|
1551
|
+
} else if (tokenInfo.tokenType === 2) {
|
|
1552
|
+
decimals = 0;
|
|
1553
|
+
const erc721ContractInstance = new Erc721Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
1554
|
+
await erc721ContractInstance.approve(this.fundContract.address, recipientInfo.nftIds[0]);
|
|
1555
|
+
}
|
|
1556
|
+
const tokenAmount = parseUnits2(recipientInfo.tokenAmount.toString(), decimals);
|
|
1557
|
+
const newFundRecipientInfo = {
|
|
1558
|
+
idSource: recipientInfo.socialPlatform,
|
|
1559
|
+
id: recipientInfo.userIdentifier,
|
|
1560
|
+
amount: tokenAmount,
|
|
1561
|
+
nftIds: recipientInfo.nftIds
|
|
1562
|
+
};
|
|
1563
|
+
if (tokenInfo.tokenType === 1) {
|
|
1564
|
+
params = [tokenInfo, newFundRecipientInfo, { value: tokenAmount }];
|
|
1565
|
+
} else {
|
|
1566
|
+
params = [tokenInfo, newFundRecipientInfo];
|
|
1567
|
+
}
|
|
1568
|
+
if ([97, 56].includes(this.chainId)) {
|
|
1569
|
+
const gasPrice = await this.provider.getGasPrice();
|
|
1570
|
+
params[2] = params[2] ? { ...params[2], gasPrice } : { gasPrice };
|
|
1571
|
+
}
|
|
1572
|
+
console.log("tip-params", params, this.chainId);
|
|
1573
|
+
const result = await this.fundContract.sendTransaction("tip", params);
|
|
1574
|
+
resolve(result);
|
|
1575
|
+
} catch (error) {
|
|
1576
|
+
return reject(error);
|
|
1577
|
+
}
|
|
1578
|
+
});
|
|
1579
|
+
}
|
|
1580
|
+
async refund(recipients) {
|
|
1581
|
+
return new Promise(async (resolve, reject) => {
|
|
1582
|
+
try {
|
|
1583
|
+
const newRecipients = recipients.map((i) => {
|
|
1584
|
+
return {
|
|
1585
|
+
idSource: i.socialPlatform,
|
|
1586
|
+
id: i.userIdentifier,
|
|
1587
|
+
tipTimestamp: i.tipTimestamp
|
|
1588
|
+
};
|
|
1589
|
+
});
|
|
1590
|
+
let params = [newRecipients];
|
|
1591
|
+
if ([97, 56].includes(this.chainId)) {
|
|
1592
|
+
const gasPrice = await this.provider.getGasPrice();
|
|
1593
|
+
params.push({
|
|
1594
|
+
gasPrice
|
|
1595
|
+
});
|
|
1596
|
+
}
|
|
1597
|
+
const result = await this.fundContract.sendTransaction("tipperWithdraw", params);
|
|
1598
|
+
return resolve(result);
|
|
1599
|
+
} catch (error) {
|
|
1600
|
+
return reject(error);
|
|
1601
|
+
}
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1604
|
+
async fundBatch(tokenInfo, recipientInfoList) {
|
|
1605
|
+
return new Promise(async (resolve, reject) => {
|
|
1606
|
+
try {
|
|
1607
|
+
let decimals = 18;
|
|
1608
|
+
let params = [];
|
|
1609
|
+
if (tokenInfo.tokenType === 0) {
|
|
1610
|
+
await this.approve(tokenInfo, recipientInfoList);
|
|
1611
|
+
const tokenContract = new Erc20Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
1612
|
+
decimals = await tokenContract.decimals();
|
|
1613
|
+
} else if (tokenInfo.tokenType === 2) {
|
|
1614
|
+
decimals = 0;
|
|
1615
|
+
const erc721ContractInstance = new Erc721Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
1616
|
+
await erc721ContractInstance.setApprovalForAll(this.fundContract.address);
|
|
1617
|
+
}
|
|
1618
|
+
let totalFormatAmount = recipientInfoList.reduce((acc, cur) => acc.add(parseUnits2(cur.tokenAmount.toString(), decimals)), import_ethers3.ethers.BigNumber.from(0));
|
|
1619
|
+
const newRecipientInfoList = recipientInfoList.map((i) => {
|
|
1620
|
+
const formatAmount = parseUnits2(i.tokenAmount.toString(), decimals);
|
|
1621
|
+
return {
|
|
1622
|
+
idSource: i.socialPlatform,
|
|
1623
|
+
id: i.userIdentifier,
|
|
1624
|
+
amount: formatAmount,
|
|
1625
|
+
nftIds: i.nftIds
|
|
1626
|
+
};
|
|
1627
|
+
});
|
|
1628
|
+
if (tokenInfo.tokenType === 1) {
|
|
1629
|
+
params = [tokenInfo, newRecipientInfoList, { value: totalFormatAmount }];
|
|
1630
|
+
} else {
|
|
1631
|
+
params = [tokenInfo, newRecipientInfoList];
|
|
1632
|
+
}
|
|
1633
|
+
if ([97, 56].includes(this.chainId)) {
|
|
1634
|
+
const gasPrice = await this.provider.getGasPrice();
|
|
1635
|
+
params[2] = params[2] ? { ...params[2], gasPrice } : { gasPrice };
|
|
1636
|
+
}
|
|
1637
|
+
const result = await this.fundContract.sendTransaction("tipBatch", params);
|
|
1638
|
+
return resolve(result);
|
|
1639
|
+
} catch (error) {
|
|
1640
|
+
return reject(error);
|
|
1641
|
+
}
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1644
|
+
// TODO-nft
|
|
1645
|
+
async approve(tokenInfo, recipientInfoList) {
|
|
1646
|
+
return new Promise(async (resolve, reject) => {
|
|
1647
|
+
try {
|
|
1648
|
+
const approveAmount = recipientInfoList.reduce((acc, cur) => acc.add(parseUnits2(cur.tokenAmount.toString(), 0)), import_ethers3.ethers.BigNumber.from(0)).toString();
|
|
1649
|
+
let approveParams = {
|
|
1650
|
+
spenderAddress: this.fundContract.address,
|
|
1651
|
+
approveAmount
|
|
1652
|
+
};
|
|
1653
|
+
if ([97, 56].includes(this.chainId)) {
|
|
1654
|
+
const gasPrice = await this.provider.getGasPrice();
|
|
1655
|
+
approveParams.otherParams = { gasPrice };
|
|
1656
|
+
}
|
|
1657
|
+
const tokenContract = new Erc20Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
1658
|
+
await tokenContract.approve(approveParams);
|
|
1659
|
+
resolve("Approved");
|
|
1660
|
+
} catch (error) {
|
|
1661
|
+
return reject(error);
|
|
1662
|
+
}
|
|
1663
|
+
});
|
|
1664
|
+
}
|
|
1665
|
+
// TODO-nft
|
|
1666
|
+
// async approve(tokenInfo: TokenInfo, recipientInfoList: RecipientInfo[]) {
|
|
1667
|
+
// return new Promise(async (resolve, reject) => {
|
|
1668
|
+
// try {
|
|
1669
|
+
// const web3Provider = new ethers.providers.Web3Provider(this.provider)
|
|
1670
|
+
// const signer = web3Provider.getSigner();
|
|
1671
|
+
// const address = await signer.getAddress();
|
|
1672
|
+
// const erc20Contract = new ethers.Contract(tokenInfo.tokenAddress as string, erc20Abi, signer);
|
|
1673
|
+
// const allowance = await erc20Contract.allowance(address, this.fundContract.address);
|
|
1674
|
+
// const decimals = await erc20Contract.decimals();
|
|
1675
|
+
// console.log('allowance', formatUnits(allowance.toString(), decimals))
|
|
1676
|
+
// // Compute total amount
|
|
1677
|
+
// const requiredAllowance = recipientInfoList.reduce((acc, cur) =>
|
|
1678
|
+
// acc.add(parseUnits(cur.tokenAmount.toString(), decimals)), ethers.BigNumber.from(0))
|
|
1679
|
+
// if (allowance.lt(requiredAllowance)) {
|
|
1680
|
+
// let params = [this.fundContract.address, requiredAllowance]
|
|
1681
|
+
// if ([97, 56].includes(this.chainId)) {
|
|
1682
|
+
// const gasPrice = await this.formatProvider.getGasPrice();
|
|
1683
|
+
// params.push({ gasPrice })
|
|
1684
|
+
// }
|
|
1685
|
+
// const tx = await erc20Contract.approve(...params);
|
|
1686
|
+
// // Wait for the transaction to be mined
|
|
1687
|
+
// await tx.wait();
|
|
1688
|
+
// console.log(`Approved: ${requiredAllowance.toString()}`);
|
|
1689
|
+
// } else {
|
|
1690
|
+
// console.log(`Already approved: ${allowance.toString()}`);
|
|
1691
|
+
// }
|
|
1692
|
+
// resolve('Approved');
|
|
1693
|
+
// } catch (error: any) {
|
|
1694
|
+
// console.error('Approval failed:', error);
|
|
1695
|
+
// if (error?.code === 'ACTION_REJECTED') {
|
|
1696
|
+
// return reject('user rejected transaction')
|
|
1697
|
+
// }
|
|
1698
|
+
// return reject(error);
|
|
1699
|
+
// }
|
|
1700
|
+
// });
|
|
1701
|
+
// }
|
|
1702
|
+
async claimBySource(socialPlatform, userIdentifier, attestation) {
|
|
1703
|
+
return new Promise(async (resolve, reject) => {
|
|
1704
|
+
try {
|
|
1705
|
+
const claimFee = await this.fundContract.callMethod("claimFee", []);
|
|
1706
|
+
const fundRecords = await this.fundContract.callMethod("getTipRecords", [{ idSource: socialPlatform, id: userIdentifier }]);
|
|
1707
|
+
console.log("fundRecords", fundRecords);
|
|
1708
|
+
const recordCount = fundRecords.length;
|
|
1709
|
+
if (recordCount <= 0) {
|
|
1710
|
+
return reject(`No fund records.`);
|
|
1711
|
+
} else {
|
|
1712
|
+
const totalFee = claimFee.mul(recordCount);
|
|
1713
|
+
let params = [socialPlatform, attestation, { value: totalFee }];
|
|
1714
|
+
if ([97, 56].includes(this.chainId)) {
|
|
1715
|
+
const gasPrice = await this.provider.getGasPrice();
|
|
1716
|
+
params[2].gasPrice = gasPrice;
|
|
1717
|
+
}
|
|
1718
|
+
const txreceipt = await this.fundContract.sendTransaction("claimBySource", params);
|
|
1719
|
+
return resolve(txreceipt);
|
|
1720
|
+
}
|
|
1721
|
+
} catch (error) {
|
|
1722
|
+
return reject(error);
|
|
1723
|
+
}
|
|
1724
|
+
});
|
|
1725
|
+
}
|
|
1726
|
+
async claimByMultiSource(socialPlatforms, userIdentifiers, attestationList) {
|
|
1727
|
+
return new Promise(async (resolve, reject) => {
|
|
1728
|
+
try {
|
|
1729
|
+
if (socialPlatforms.length !== userIdentifiers.length || socialPlatforms.length !== attestationList.length) {
|
|
1730
|
+
return reject(`socialPlatforms, userIdentifiers, attestationList length must be equal.`);
|
|
1731
|
+
}
|
|
1732
|
+
const claimFee = await this.fundContract.callMethod("claimFee", []);
|
|
1733
|
+
let allFundRecords = [];
|
|
1734
|
+
let recordCount = 0;
|
|
1735
|
+
for (const [index, value] of socialPlatforms.entries()) {
|
|
1736
|
+
const fundRecords = await this.fundContract.callMethod("getTipRecords", [{ idSource: value, id: userIdentifiers[index] }]);
|
|
1737
|
+
allFundRecords.push(...fundRecords);
|
|
1738
|
+
recordCount += fundRecords.length;
|
|
1739
|
+
}
|
|
1740
|
+
if (recordCount <= 0) {
|
|
1741
|
+
return reject(`No fund records.`);
|
|
1742
|
+
} else {
|
|
1743
|
+
const totalFee = claimFee.mul(recordCount);
|
|
1744
|
+
let params = [socialPlatforms, userIdentifiers, attestationList, { value: totalFee }];
|
|
1745
|
+
if ([97, 56].includes(this.chainId)) {
|
|
1746
|
+
const gasPrice = await this.provider.getGasPrice();
|
|
1747
|
+
params[3].gasPrice = gasPrice;
|
|
1748
|
+
}
|
|
1749
|
+
const txreceipt = await this.fundContract.sendTransaction("claimByMultiSource", params);
|
|
1750
|
+
return resolve(txreceipt);
|
|
1751
|
+
}
|
|
1752
|
+
} catch (error) {
|
|
1753
|
+
console.error("claimByMultiSource", error);
|
|
1754
|
+
return reject(error);
|
|
1755
|
+
}
|
|
1756
|
+
});
|
|
1757
|
+
}
|
|
1758
|
+
async getTipRecords(getFundRecordsParams) {
|
|
1759
|
+
return new Promise(async (resolve, reject) => {
|
|
1760
|
+
try {
|
|
1761
|
+
const formatGetFundRecordsParams = getFundRecordsParams.map((item) => {
|
|
1762
|
+
return {
|
|
1763
|
+
idSource: item.socialPlatform,
|
|
1764
|
+
id: item.userIdentifier
|
|
1765
|
+
};
|
|
1766
|
+
});
|
|
1767
|
+
const fundRecords = await this.fundContract.callMethod("getTipRecords", formatGetFundRecordsParams);
|
|
1768
|
+
console.log("fundRecords", fundRecords);
|
|
1769
|
+
let formatRecords = [];
|
|
1770
|
+
for (const record of fundRecords) {
|
|
1771
|
+
const { tipper, timestamp, tipToken: [tokenType, tokenAddress], amount, nftIds } = record;
|
|
1772
|
+
let decimals = 18;
|
|
1773
|
+
let symbol = "";
|
|
1774
|
+
let tokenId = null;
|
|
1775
|
+
let nftInfo = null;
|
|
1776
|
+
if (tokenType === 0) {
|
|
1777
|
+
const tokenContract = new Erc20Contract_default(this.provider, tokenAddress);
|
|
1778
|
+
decimals = await tokenContract.decimals();
|
|
1779
|
+
symbol = await tokenContract.symbol();
|
|
1780
|
+
} else if (tokenType === 1) {
|
|
1781
|
+
symbol = NATIVETOKENS[this.chainId];
|
|
1782
|
+
} else if (tokenType === 2) {
|
|
1783
|
+
decimals = 0;
|
|
1784
|
+
tokenId = parseInt(nftIds[0]);
|
|
1785
|
+
const erc721ContractInstance = new Erc721Contract_default(this.provider, tokenAddress);
|
|
1786
|
+
nftInfo = await erc721ContractInstance.fetchMetaData(tokenAddress, tokenId);
|
|
1787
|
+
}
|
|
1788
|
+
let fundToken = {
|
|
1789
|
+
tokenType,
|
|
1790
|
+
// tokenAmount: formatUnits(amount, decimals),
|
|
1791
|
+
decimals,
|
|
1792
|
+
symbol,
|
|
1793
|
+
chainName: CHAINNAMES[this.chainId],
|
|
1794
|
+
chainId: this.chainId
|
|
1795
|
+
};
|
|
1796
|
+
if (tokenType === 0) {
|
|
1797
|
+
fundToken.tokenAddress = tokenAddress;
|
|
1798
|
+
}
|
|
1799
|
+
if (tokenType === 2) {
|
|
1800
|
+
Object.assign(fundToken, nftInfo ?? {});
|
|
1801
|
+
}
|
|
1802
|
+
formatRecords.push({
|
|
1803
|
+
funder: tipper,
|
|
1804
|
+
fundToken,
|
|
1805
|
+
amount: formatUnits2(amount, decimals),
|
|
1806
|
+
timestamp: timestamp.toNumber()
|
|
1807
|
+
});
|
|
1808
|
+
}
|
|
1809
|
+
console.log("formatRecords", formatRecords);
|
|
1810
|
+
return resolve(formatRecords);
|
|
1811
|
+
} catch (error) {
|
|
1812
|
+
return reject(error);
|
|
1813
|
+
}
|
|
1814
|
+
});
|
|
1815
|
+
}
|
|
1816
|
+
};
|
|
1817
|
+
|
|
1818
|
+
// src/classes/FundForRedPacket.ts
|
|
1819
|
+
var import_ethers4 = require("ethers");
|
|
1820
|
+
|
|
1821
|
+
// src/config/abiForRedPacket.json
|
|
1822
|
+
var abiForRedPacket_default = [
|
|
1823
|
+
{
|
|
1824
|
+
type: "function",
|
|
1825
|
+
name: "claimFee",
|
|
1826
|
+
inputs: [],
|
|
1827
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
1828
|
+
stateMutability: "view"
|
|
1829
|
+
},
|
|
1830
|
+
{
|
|
1831
|
+
type: "function",
|
|
1832
|
+
name: "feeRecipient",
|
|
1833
|
+
inputs: [],
|
|
1834
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
1835
|
+
stateMutability: "view"
|
|
1836
|
+
},
|
|
1837
|
+
{
|
|
1838
|
+
type: "function",
|
|
1839
|
+
name: "getClaimed",
|
|
1840
|
+
inputs: [
|
|
1841
|
+
{ name: "reId", type: "bytes32", internalType: "bytes32" },
|
|
1842
|
+
{ name: "userid", type: "string", internalType: "string" }
|
|
1843
|
+
],
|
|
1844
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
1845
|
+
stateMutability: "view"
|
|
1846
|
+
},
|
|
1847
|
+
{
|
|
1848
|
+
type: "function",
|
|
1849
|
+
name: "getPrev",
|
|
1850
|
+
inputs: [],
|
|
1851
|
+
outputs: [
|
|
1852
|
+
{ name: "", type: "uint256", internalType: "uint256" },
|
|
1853
|
+
{ name: "", type: "uint256", internalType: "uint256" }
|
|
1854
|
+
],
|
|
1855
|
+
stateMutability: "view"
|
|
1856
|
+
},
|
|
1857
|
+
{
|
|
1858
|
+
type: "function",
|
|
1859
|
+
name: "getREInfo",
|
|
1860
|
+
inputs: [
|
|
1861
|
+
{ name: "reId", type: "bytes32", internalType: "bytes32" }
|
|
1862
|
+
],
|
|
1863
|
+
outputs: [
|
|
1864
|
+
{
|
|
1865
|
+
name: "",
|
|
1866
|
+
type: "tuple",
|
|
1867
|
+
internalType: "struct RERecord",
|
|
1868
|
+
components: [
|
|
1869
|
+
{ name: "id", type: "bytes32", internalType: "bytes32" },
|
|
1870
|
+
{ name: "tokenType", type: "uint32", internalType: "uint32" },
|
|
1871
|
+
{ name: "reType", type: "uint32", internalType: "uint32" },
|
|
1872
|
+
{ name: "number", type: "uint32", internalType: "uint32" },
|
|
1873
|
+
{
|
|
1874
|
+
name: "remainingNumber",
|
|
1875
|
+
type: "uint32",
|
|
1876
|
+
internalType: "uint32"
|
|
1877
|
+
},
|
|
1878
|
+
{ name: "timestamp", type: "uint64", internalType: "uint64" },
|
|
1879
|
+
{
|
|
1880
|
+
name: "tokenAddress",
|
|
1881
|
+
type: "address",
|
|
1882
|
+
internalType: "address"
|
|
1883
|
+
},
|
|
1884
|
+
{ name: "reSender", type: "address", internalType: "address" },
|
|
1885
|
+
{
|
|
1886
|
+
name: "checkContract",
|
|
1887
|
+
type: "address",
|
|
1888
|
+
internalType: "address"
|
|
1889
|
+
},
|
|
1890
|
+
{ name: "amount", type: "uint256", internalType: "uint256" },
|
|
1891
|
+
{
|
|
1892
|
+
name: "remainingAmount",
|
|
1893
|
+
type: "uint256",
|
|
1894
|
+
internalType: "uint256"
|
|
1895
|
+
},
|
|
1896
|
+
{ name: "checkParams", type: "bytes", internalType: "bytes" }
|
|
1897
|
+
]
|
|
1898
|
+
}
|
|
1899
|
+
],
|
|
1900
|
+
stateMutability: "view"
|
|
1901
|
+
},
|
|
1902
|
+
{
|
|
1903
|
+
type: "function",
|
|
1904
|
+
name: "idCounter",
|
|
1905
|
+
inputs: [],
|
|
1906
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
1907
|
+
stateMutability: "view"
|
|
1908
|
+
},
|
|
1909
|
+
{
|
|
1910
|
+
type: "function",
|
|
1911
|
+
name: "initialize",
|
|
903
1912
|
inputs: [
|
|
1913
|
+
{ name: "owner", type: "address", internalType: "address" },
|
|
904
1914
|
{
|
|
905
|
-
name: "
|
|
1915
|
+
name: "primusZKTLS_",
|
|
906
1916
|
type: "address",
|
|
907
|
-
internalType: "
|
|
1917
|
+
internalType: "contract IPrimusZKTLS"
|
|
908
1918
|
},
|
|
909
|
-
{
|
|
910
|
-
|
|
911
|
-
type: "address",
|
|
912
|
-
internalType: "address"
|
|
913
|
-
}
|
|
1919
|
+
{ name: "feeRecipient_", type: "address", internalType: "address" },
|
|
1920
|
+
{ name: "claimFee_", type: "uint256", internalType: "uint256" }
|
|
914
1921
|
],
|
|
1922
|
+
outputs: [],
|
|
1923
|
+
stateMutability: "nonpayable"
|
|
1924
|
+
},
|
|
1925
|
+
{
|
|
1926
|
+
type: "function",
|
|
1927
|
+
name: "owner",
|
|
1928
|
+
inputs: [],
|
|
1929
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
1930
|
+
stateMutability: "view"
|
|
1931
|
+
},
|
|
1932
|
+
{
|
|
1933
|
+
type: "function",
|
|
1934
|
+
name: "primusZKTLS",
|
|
1935
|
+
inputs: [],
|
|
915
1936
|
outputs: [
|
|
916
|
-
{
|
|
917
|
-
name: "",
|
|
918
|
-
type: "uint256",
|
|
919
|
-
internalType: "uint256"
|
|
920
|
-
}
|
|
1937
|
+
{ name: "", type: "address", internalType: "contract IPrimusZKTLS" }
|
|
921
1938
|
],
|
|
922
1939
|
stateMutability: "view"
|
|
923
1940
|
},
|
|
924
1941
|
{
|
|
925
1942
|
type: "function",
|
|
926
|
-
name: "
|
|
1943
|
+
name: "reCheckClaim",
|
|
927
1944
|
inputs: [
|
|
928
1945
|
{
|
|
929
|
-
name: "
|
|
930
|
-
type: "
|
|
931
|
-
internalType: "
|
|
1946
|
+
name: "att",
|
|
1947
|
+
type: "tuple",
|
|
1948
|
+
internalType: "struct Attestation",
|
|
1949
|
+
components: [
|
|
1950
|
+
{ name: "recipient", type: "address", internalType: "address" },
|
|
1951
|
+
{
|
|
1952
|
+
name: "request",
|
|
1953
|
+
type: "tuple",
|
|
1954
|
+
internalType: "struct AttNetworkRequest",
|
|
1955
|
+
components: [
|
|
1956
|
+
{ name: "url", type: "string", internalType: "string" },
|
|
1957
|
+
{ name: "header", type: "string", internalType: "string" },
|
|
1958
|
+
{ name: "method", type: "string", internalType: "string" },
|
|
1959
|
+
{ name: "body", type: "string", internalType: "string" }
|
|
1960
|
+
]
|
|
1961
|
+
},
|
|
1962
|
+
{
|
|
1963
|
+
name: "reponseResolve",
|
|
1964
|
+
type: "tuple[]",
|
|
1965
|
+
internalType: "struct AttNetworkResponseResolve[]",
|
|
1966
|
+
components: [
|
|
1967
|
+
{ name: "keyName", type: "string", internalType: "string" },
|
|
1968
|
+
{
|
|
1969
|
+
name: "parseType",
|
|
1970
|
+
type: "string",
|
|
1971
|
+
internalType: "string"
|
|
1972
|
+
},
|
|
1973
|
+
{
|
|
1974
|
+
name: "parsePath",
|
|
1975
|
+
type: "string",
|
|
1976
|
+
internalType: "string"
|
|
1977
|
+
}
|
|
1978
|
+
]
|
|
1979
|
+
},
|
|
1980
|
+
{ name: "data", type: "string", internalType: "string" },
|
|
1981
|
+
{
|
|
1982
|
+
name: "attConditions",
|
|
1983
|
+
type: "string",
|
|
1984
|
+
internalType: "string"
|
|
1985
|
+
},
|
|
1986
|
+
{ name: "timestamp", type: "uint64", internalType: "uint64" },
|
|
1987
|
+
{
|
|
1988
|
+
name: "additionParams",
|
|
1989
|
+
type: "string",
|
|
1990
|
+
internalType: "string"
|
|
1991
|
+
},
|
|
1992
|
+
{
|
|
1993
|
+
name: "attestors",
|
|
1994
|
+
type: "tuple[]",
|
|
1995
|
+
internalType: "struct Attestor[]",
|
|
1996
|
+
components: [
|
|
1997
|
+
{
|
|
1998
|
+
name: "attestorAddr",
|
|
1999
|
+
type: "address",
|
|
2000
|
+
internalType: "address"
|
|
2001
|
+
},
|
|
2002
|
+
{ name: "url", type: "string", internalType: "string" }
|
|
2003
|
+
]
|
|
2004
|
+
},
|
|
2005
|
+
{ name: "signatures", type: "bytes[]", internalType: "bytes[]" }
|
|
2006
|
+
]
|
|
932
2007
|
},
|
|
933
|
-
{
|
|
934
|
-
name: "value",
|
|
935
|
-
type: "uint256",
|
|
936
|
-
internalType: "uint256"
|
|
937
|
-
}
|
|
2008
|
+
{ name: "checkParams", type: "bytes", internalType: "bytes" }
|
|
938
2009
|
],
|
|
939
2010
|
outputs: [
|
|
940
|
-
{
|
|
941
|
-
|
|
942
|
-
type: "bool",
|
|
943
|
-
internalType: "bool"
|
|
944
|
-
}
|
|
2011
|
+
{ name: "", type: "string", internalType: "string" },
|
|
2012
|
+
{ name: "", type: "address", internalType: "address" }
|
|
945
2013
|
],
|
|
946
|
-
stateMutability: "
|
|
2014
|
+
stateMutability: "view"
|
|
947
2015
|
},
|
|
948
2016
|
{
|
|
949
2017
|
type: "function",
|
|
950
|
-
name: "
|
|
2018
|
+
name: "reClaim",
|
|
951
2019
|
inputs: [
|
|
2020
|
+
{ name: "reId", type: "bytes32", internalType: "bytes32" },
|
|
952
2021
|
{
|
|
953
|
-
name: "
|
|
954
|
-
type: "
|
|
955
|
-
internalType: "
|
|
2022
|
+
name: "att",
|
|
2023
|
+
type: "tuple",
|
|
2024
|
+
internalType: "struct Attestation",
|
|
2025
|
+
components: [
|
|
2026
|
+
{ name: "recipient", type: "address", internalType: "address" },
|
|
2027
|
+
{
|
|
2028
|
+
name: "request",
|
|
2029
|
+
type: "tuple",
|
|
2030
|
+
internalType: "struct AttNetworkRequest",
|
|
2031
|
+
components: [
|
|
2032
|
+
{ name: "url", type: "string", internalType: "string" },
|
|
2033
|
+
{ name: "header", type: "string", internalType: "string" },
|
|
2034
|
+
{ name: "method", type: "string", internalType: "string" },
|
|
2035
|
+
{ name: "body", type: "string", internalType: "string" }
|
|
2036
|
+
]
|
|
2037
|
+
},
|
|
2038
|
+
{
|
|
2039
|
+
name: "reponseResolve",
|
|
2040
|
+
type: "tuple[]",
|
|
2041
|
+
internalType: "struct AttNetworkResponseResolve[]",
|
|
2042
|
+
components: [
|
|
2043
|
+
{ name: "keyName", type: "string", internalType: "string" },
|
|
2044
|
+
{
|
|
2045
|
+
name: "parseType",
|
|
2046
|
+
type: "string",
|
|
2047
|
+
internalType: "string"
|
|
2048
|
+
},
|
|
2049
|
+
{
|
|
2050
|
+
name: "parsePath",
|
|
2051
|
+
type: "string",
|
|
2052
|
+
internalType: "string"
|
|
2053
|
+
}
|
|
2054
|
+
]
|
|
2055
|
+
},
|
|
2056
|
+
{ name: "data", type: "string", internalType: "string" },
|
|
2057
|
+
{
|
|
2058
|
+
name: "attConditions",
|
|
2059
|
+
type: "string",
|
|
2060
|
+
internalType: "string"
|
|
2061
|
+
},
|
|
2062
|
+
{ name: "timestamp", type: "uint64", internalType: "uint64" },
|
|
2063
|
+
{
|
|
2064
|
+
name: "additionParams",
|
|
2065
|
+
type: "string",
|
|
2066
|
+
internalType: "string"
|
|
2067
|
+
},
|
|
2068
|
+
{
|
|
2069
|
+
name: "attestors",
|
|
2070
|
+
type: "tuple[]",
|
|
2071
|
+
internalType: "struct Attestor[]",
|
|
2072
|
+
components: [
|
|
2073
|
+
{
|
|
2074
|
+
name: "attestorAddr",
|
|
2075
|
+
type: "address",
|
|
2076
|
+
internalType: "address"
|
|
2077
|
+
},
|
|
2078
|
+
{ name: "url", type: "string", internalType: "string" }
|
|
2079
|
+
]
|
|
2080
|
+
},
|
|
2081
|
+
{ name: "signatures", type: "bytes[]", internalType: "bytes[]" }
|
|
2082
|
+
]
|
|
956
2083
|
}
|
|
957
2084
|
],
|
|
2085
|
+
outputs: [],
|
|
2086
|
+
stateMutability: "payable"
|
|
2087
|
+
},
|
|
2088
|
+
{
|
|
2089
|
+
type: "function",
|
|
2090
|
+
name: "reRecords",
|
|
2091
|
+
inputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
|
|
958
2092
|
outputs: [
|
|
959
|
-
{
|
|
960
|
-
|
|
2093
|
+
{ name: "id", type: "bytes32", internalType: "bytes32" },
|
|
2094
|
+
{ name: "tokenType", type: "uint32", internalType: "uint32" },
|
|
2095
|
+
{ name: "reType", type: "uint32", internalType: "uint32" },
|
|
2096
|
+
{ name: "number", type: "uint32", internalType: "uint32" },
|
|
2097
|
+
{ name: "remainingNumber", type: "uint32", internalType: "uint32" },
|
|
2098
|
+
{ name: "timestamp", type: "uint64", internalType: "uint64" },
|
|
2099
|
+
{ name: "tokenAddress", type: "address", internalType: "address" },
|
|
2100
|
+
{ name: "reSender", type: "address", internalType: "address" },
|
|
2101
|
+
{ name: "checkContract", type: "address", internalType: "address" },
|
|
2102
|
+
{ name: "amount", type: "uint256", internalType: "uint256" },
|
|
2103
|
+
{
|
|
2104
|
+
name: "remainingAmount",
|
|
961
2105
|
type: "uint256",
|
|
962
2106
|
internalType: "uint256"
|
|
963
|
-
}
|
|
2107
|
+
},
|
|
2108
|
+
{ name: "checkParams", type: "bytes", internalType: "bytes" }
|
|
964
2109
|
],
|
|
965
2110
|
stateMutability: "view"
|
|
966
2111
|
},
|
|
967
2112
|
{
|
|
968
2113
|
type: "function",
|
|
969
|
-
name: "
|
|
970
|
-
inputs: [
|
|
971
|
-
outputs: [
|
|
2114
|
+
name: "reSend",
|
|
2115
|
+
inputs: [
|
|
972
2116
|
{
|
|
973
|
-
name: "",
|
|
974
|
-
type: "
|
|
975
|
-
internalType: "
|
|
2117
|
+
name: "token",
|
|
2118
|
+
type: "tuple",
|
|
2119
|
+
internalType: "struct TipToken",
|
|
2120
|
+
components: [
|
|
2121
|
+
{ name: "tokenType", type: "uint32", internalType: "uint32" },
|
|
2122
|
+
{
|
|
2123
|
+
name: "tokenAddress",
|
|
2124
|
+
type: "address",
|
|
2125
|
+
internalType: "address"
|
|
2126
|
+
}
|
|
2127
|
+
]
|
|
2128
|
+
},
|
|
2129
|
+
{
|
|
2130
|
+
name: "sendParam",
|
|
2131
|
+
type: "tuple",
|
|
2132
|
+
internalType: "struct RESendParam",
|
|
2133
|
+
components: [
|
|
2134
|
+
{ name: "reType", type: "uint32", internalType: "uint32" },
|
|
2135
|
+
{ name: "number", type: "uint32", internalType: "uint32" },
|
|
2136
|
+
{ name: "amount", type: "uint256", internalType: "uint256" },
|
|
2137
|
+
{
|
|
2138
|
+
name: "checkContract",
|
|
2139
|
+
type: "address",
|
|
2140
|
+
internalType: "address"
|
|
2141
|
+
},
|
|
2142
|
+
{ name: "checkParams", type: "bytes", internalType: "bytes" }
|
|
2143
|
+
]
|
|
976
2144
|
}
|
|
977
2145
|
],
|
|
978
|
-
|
|
2146
|
+
outputs: [],
|
|
2147
|
+
stateMutability: "payable"
|
|
979
2148
|
},
|
|
980
2149
|
{
|
|
981
2150
|
type: "function",
|
|
982
|
-
name: "
|
|
983
|
-
inputs: [
|
|
984
|
-
|
|
985
|
-
{
|
|
986
|
-
name: "",
|
|
987
|
-
type: "string",
|
|
988
|
-
internalType: "string"
|
|
989
|
-
}
|
|
2151
|
+
name: "reSenderWithdraw",
|
|
2152
|
+
inputs: [
|
|
2153
|
+
{ name: "reId", type: "bytes32", internalType: "bytes32" }
|
|
990
2154
|
],
|
|
991
|
-
|
|
2155
|
+
outputs: [],
|
|
2156
|
+
stateMutability: "nonpayable"
|
|
992
2157
|
},
|
|
993
2158
|
{
|
|
994
2159
|
type: "function",
|
|
995
|
-
name: "
|
|
2160
|
+
name: "renounceOwnership",
|
|
996
2161
|
inputs: [],
|
|
997
|
-
outputs: [
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
2162
|
+
outputs: [],
|
|
2163
|
+
stateMutability: "nonpayable"
|
|
2164
|
+
},
|
|
2165
|
+
{
|
|
2166
|
+
type: "function",
|
|
2167
|
+
name: "setClaimFee",
|
|
2168
|
+
inputs: [
|
|
2169
|
+
{ name: "claimFee_", type: "uint256", internalType: "uint256" }
|
|
1003
2170
|
],
|
|
1004
|
-
|
|
2171
|
+
outputs: [],
|
|
2172
|
+
stateMutability: "nonpayable"
|
|
1005
2173
|
},
|
|
1006
2174
|
{
|
|
1007
2175
|
type: "function",
|
|
1008
|
-
name: "
|
|
1009
|
-
inputs: [
|
|
1010
|
-
|
|
1011
|
-
{
|
|
1012
|
-
name: "",
|
|
1013
|
-
type: "uint256",
|
|
1014
|
-
internalType: "uint256"
|
|
1015
|
-
}
|
|
2176
|
+
name: "setFeeRecipient",
|
|
2177
|
+
inputs: [
|
|
2178
|
+
{ name: "feeRecipient_", type: "address", internalType: "address" }
|
|
1016
2179
|
],
|
|
1017
|
-
|
|
2180
|
+
outputs: [],
|
|
2181
|
+
stateMutability: "nonpayable"
|
|
1018
2182
|
},
|
|
1019
2183
|
{
|
|
1020
2184
|
type: "function",
|
|
1021
|
-
name: "
|
|
2185
|
+
name: "setPrimusZKTLS",
|
|
1022
2186
|
inputs: [
|
|
1023
2187
|
{
|
|
1024
|
-
name: "
|
|
2188
|
+
name: "primusZKTLS_",
|
|
1025
2189
|
type: "address",
|
|
1026
|
-
internalType: "
|
|
1027
|
-
},
|
|
1028
|
-
{
|
|
1029
|
-
name: "value",
|
|
1030
|
-
type: "uint256",
|
|
1031
|
-
internalType: "uint256"
|
|
1032
|
-
}
|
|
1033
|
-
],
|
|
1034
|
-
outputs: [
|
|
1035
|
-
{
|
|
1036
|
-
name: "",
|
|
1037
|
-
type: "bool",
|
|
1038
|
-
internalType: "bool"
|
|
2190
|
+
internalType: "contract IPrimusZKTLS"
|
|
1039
2191
|
}
|
|
1040
2192
|
],
|
|
2193
|
+
outputs: [],
|
|
1041
2194
|
stateMutability: "nonpayable"
|
|
1042
2195
|
},
|
|
1043
2196
|
{
|
|
1044
2197
|
type: "function",
|
|
1045
|
-
name: "
|
|
2198
|
+
name: "setWithdrawDelay",
|
|
1046
2199
|
inputs: [
|
|
1047
|
-
{
|
|
1048
|
-
name: "from",
|
|
1049
|
-
type: "address",
|
|
1050
|
-
internalType: "address"
|
|
1051
|
-
},
|
|
1052
|
-
{
|
|
1053
|
-
name: "to",
|
|
1054
|
-
type: "address",
|
|
1055
|
-
internalType: "address"
|
|
1056
|
-
},
|
|
1057
|
-
{
|
|
1058
|
-
name: "value",
|
|
1059
|
-
type: "uint256",
|
|
1060
|
-
internalType: "uint256"
|
|
1061
|
-
}
|
|
2200
|
+
{ name: "delay", type: "uint256", internalType: "uint256" }
|
|
1062
2201
|
],
|
|
1063
|
-
outputs: [
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
2202
|
+
outputs: [],
|
|
2203
|
+
stateMutability: "nonpayable"
|
|
2204
|
+
},
|
|
2205
|
+
{
|
|
2206
|
+
type: "function",
|
|
2207
|
+
name: "transferOwnership",
|
|
2208
|
+
inputs: [
|
|
2209
|
+
{ name: "newOwner", type: "address", internalType: "address" }
|
|
1069
2210
|
],
|
|
2211
|
+
outputs: [],
|
|
1070
2212
|
stateMutability: "nonpayable"
|
|
1071
2213
|
},
|
|
2214
|
+
{
|
|
2215
|
+
type: "function",
|
|
2216
|
+
name: "withdrawDelay",
|
|
2217
|
+
inputs: [],
|
|
2218
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2219
|
+
stateMutability: "view"
|
|
2220
|
+
},
|
|
1072
2221
|
{
|
|
1073
2222
|
type: "event",
|
|
1074
|
-
name: "
|
|
2223
|
+
name: "Initialized",
|
|
1075
2224
|
inputs: [
|
|
1076
2225
|
{
|
|
1077
|
-
name: "
|
|
1078
|
-
type: "
|
|
1079
|
-
indexed: true,
|
|
1080
|
-
internalType: "address"
|
|
1081
|
-
},
|
|
1082
|
-
{
|
|
1083
|
-
name: "spender",
|
|
1084
|
-
type: "address",
|
|
1085
|
-
indexed: true,
|
|
1086
|
-
internalType: "address"
|
|
1087
|
-
},
|
|
1088
|
-
{
|
|
1089
|
-
name: "value",
|
|
1090
|
-
type: "uint256",
|
|
2226
|
+
name: "version",
|
|
2227
|
+
type: "uint64",
|
|
1091
2228
|
indexed: false,
|
|
1092
|
-
internalType: "
|
|
2229
|
+
internalType: "uint64"
|
|
1093
2230
|
}
|
|
1094
2231
|
],
|
|
1095
2232
|
anonymous: false
|
|
1096
2233
|
},
|
|
1097
2234
|
{
|
|
1098
2235
|
type: "event",
|
|
1099
|
-
name: "
|
|
2236
|
+
name: "OwnershipTransferred",
|
|
1100
2237
|
inputs: [
|
|
1101
2238
|
{
|
|
1102
|
-
name: "
|
|
2239
|
+
name: "previousOwner",
|
|
1103
2240
|
type: "address",
|
|
1104
2241
|
indexed: true,
|
|
1105
2242
|
internalType: "address"
|
|
1106
2243
|
},
|
|
1107
2244
|
{
|
|
1108
|
-
name: "
|
|
2245
|
+
name: "newOwner",
|
|
1109
2246
|
type: "address",
|
|
1110
2247
|
indexed: true,
|
|
1111
2248
|
internalType: "address"
|
|
1112
|
-
},
|
|
1113
|
-
{
|
|
1114
|
-
name: "value",
|
|
1115
|
-
type: "uint256",
|
|
1116
|
-
indexed: false,
|
|
1117
|
-
internalType: "uint256"
|
|
1118
2249
|
}
|
|
1119
2250
|
],
|
|
1120
2251
|
anonymous: false
|
|
1121
2252
|
},
|
|
1122
2253
|
{
|
|
1123
|
-
type: "
|
|
1124
|
-
name: "
|
|
2254
|
+
type: "event",
|
|
2255
|
+
name: "REClaimEvent",
|
|
1125
2256
|
inputs: [
|
|
1126
2257
|
{
|
|
1127
|
-
name: "
|
|
1128
|
-
type: "
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
{
|
|
1132
|
-
name: "allowance",
|
|
1133
|
-
type: "uint256",
|
|
1134
|
-
internalType: "uint256"
|
|
2258
|
+
name: "id",
|
|
2259
|
+
type: "bytes32",
|
|
2260
|
+
indexed: true,
|
|
2261
|
+
internalType: "bytes32"
|
|
1135
2262
|
},
|
|
1136
2263
|
{
|
|
1137
|
-
name: "
|
|
1138
|
-
type: "uint256",
|
|
1139
|
-
internalType: "uint256"
|
|
1140
|
-
}
|
|
1141
|
-
]
|
|
1142
|
-
},
|
|
1143
|
-
{
|
|
1144
|
-
type: "error",
|
|
1145
|
-
name: "ERC20InsufficientBalance",
|
|
1146
|
-
inputs: [
|
|
1147
|
-
{
|
|
1148
|
-
name: "sender",
|
|
2264
|
+
name: "recipient",
|
|
1149
2265
|
type: "address",
|
|
2266
|
+
indexed: false,
|
|
1150
2267
|
internalType: "address"
|
|
1151
2268
|
},
|
|
1152
2269
|
{
|
|
1153
|
-
name: "
|
|
1154
|
-
type: "
|
|
1155
|
-
|
|
2270
|
+
name: "userId",
|
|
2271
|
+
type: "string",
|
|
2272
|
+
indexed: false,
|
|
2273
|
+
internalType: "string"
|
|
1156
2274
|
},
|
|
1157
2275
|
{
|
|
1158
|
-
name: "
|
|
2276
|
+
name: "claimAmount",
|
|
1159
2277
|
type: "uint256",
|
|
2278
|
+
indexed: false,
|
|
1160
2279
|
internalType: "uint256"
|
|
1161
|
-
}
|
|
1162
|
-
]
|
|
1163
|
-
},
|
|
1164
|
-
{
|
|
1165
|
-
type: "error",
|
|
1166
|
-
name: "ERC20InvalidApprover",
|
|
1167
|
-
inputs: [
|
|
1168
|
-
{
|
|
1169
|
-
name: "approver",
|
|
1170
|
-
type: "address",
|
|
1171
|
-
internalType: "address"
|
|
1172
|
-
}
|
|
1173
|
-
]
|
|
1174
|
-
},
|
|
1175
|
-
{
|
|
1176
|
-
type: "error",
|
|
1177
|
-
name: "ERC20InvalidReceiver",
|
|
1178
|
-
inputs: [
|
|
1179
|
-
{
|
|
1180
|
-
name: "receiver",
|
|
1181
|
-
type: "address",
|
|
1182
|
-
internalType: "address"
|
|
1183
|
-
}
|
|
1184
|
-
]
|
|
1185
|
-
},
|
|
1186
|
-
{
|
|
1187
|
-
type: "error",
|
|
1188
|
-
name: "ERC20InvalidSender",
|
|
1189
|
-
inputs: [
|
|
2280
|
+
},
|
|
1190
2281
|
{
|
|
1191
|
-
name: "
|
|
1192
|
-
type: "
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
},
|
|
1197
|
-
{
|
|
1198
|
-
type: "error",
|
|
1199
|
-
name: "ERC20InvalidSpender",
|
|
1200
|
-
inputs: [
|
|
2282
|
+
name: "reIndex",
|
|
2283
|
+
type: "uint32",
|
|
2284
|
+
indexed: false,
|
|
2285
|
+
internalType: "uint32"
|
|
2286
|
+
},
|
|
1201
2287
|
{
|
|
1202
|
-
name: "
|
|
1203
|
-
type: "
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
}
|
|
1208
|
-
];
|
|
1209
|
-
|
|
1210
|
-
// src/config/erc721Abi.json
|
|
1211
|
-
var erc721Abi_default = [
|
|
1212
|
-
{
|
|
1213
|
-
type: "function",
|
|
1214
|
-
name: "supportsInterface",
|
|
1215
|
-
stateMutability: "view",
|
|
1216
|
-
inputs: [
|
|
1217
|
-
{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }
|
|
1218
|
-
],
|
|
1219
|
-
outputs: [{ internalType: "bool", name: "", type: "bool" }]
|
|
1220
|
-
},
|
|
1221
|
-
{
|
|
1222
|
-
type: "function",
|
|
1223
|
-
name: "balanceOf",
|
|
1224
|
-
stateMutability: "view",
|
|
1225
|
-
inputs: [
|
|
1226
|
-
{ internalType: "address", name: "owner", type: "address" }
|
|
1227
|
-
],
|
|
1228
|
-
outputs: [{ internalType: "uint256", name: "", type: "uint256" }]
|
|
1229
|
-
},
|
|
1230
|
-
{
|
|
1231
|
-
type: "function",
|
|
1232
|
-
name: "ownerOf",
|
|
1233
|
-
stateMutability: "view",
|
|
1234
|
-
inputs: [
|
|
1235
|
-
{ internalType: "uint256", name: "tokenId", type: "uint256" }
|
|
1236
|
-
],
|
|
1237
|
-
outputs: [{ internalType: "address", name: "", type: "address" }]
|
|
1238
|
-
},
|
|
1239
|
-
{
|
|
1240
|
-
type: "function",
|
|
1241
|
-
name: "tokenURI",
|
|
1242
|
-
stateMutability: "view",
|
|
1243
|
-
inputs: [
|
|
1244
|
-
{ internalType: "uint256", name: "tokenId", type: "uint256" }
|
|
1245
|
-
],
|
|
1246
|
-
outputs: [{ internalType: "string", name: "", type: "string" }]
|
|
1247
|
-
},
|
|
1248
|
-
{
|
|
1249
|
-
type: "function",
|
|
1250
|
-
name: "approve",
|
|
1251
|
-
stateMutability: "nonpayable",
|
|
1252
|
-
inputs: [
|
|
1253
|
-
{ internalType: "address", name: "to", type: "address" },
|
|
1254
|
-
{ internalType: "uint256", name: "tokenId", type: "uint256" }
|
|
1255
|
-
],
|
|
1256
|
-
outputs: []
|
|
1257
|
-
},
|
|
1258
|
-
{
|
|
1259
|
-
type: "function",
|
|
1260
|
-
name: "getApproved",
|
|
1261
|
-
stateMutability: "view",
|
|
1262
|
-
inputs: [
|
|
1263
|
-
{ internalType: "uint256", name: "tokenId", type: "uint256" }
|
|
1264
|
-
],
|
|
1265
|
-
outputs: [{ internalType: "address", name: "", type: "address" }]
|
|
1266
|
-
},
|
|
1267
|
-
{
|
|
1268
|
-
type: "function",
|
|
1269
|
-
name: "setApprovalForAll",
|
|
1270
|
-
stateMutability: "nonpayable",
|
|
1271
|
-
inputs: [
|
|
1272
|
-
{ internalType: "address", name: "operator", type: "address" },
|
|
1273
|
-
{ internalType: "bool", name: "approved", type: "bool" }
|
|
1274
|
-
],
|
|
1275
|
-
outputs: []
|
|
1276
|
-
},
|
|
1277
|
-
{
|
|
1278
|
-
type: "function",
|
|
1279
|
-
name: "isApprovedForAll",
|
|
1280
|
-
stateMutability: "view",
|
|
1281
|
-
inputs: [
|
|
1282
|
-
{ internalType: "address", name: "owner", type: "address" },
|
|
1283
|
-
{ internalType: "address", name: "operator", type: "address" }
|
|
2288
|
+
name: "timestamp",
|
|
2289
|
+
type: "uint64",
|
|
2290
|
+
indexed: false,
|
|
2291
|
+
internalType: "uint64"
|
|
2292
|
+
}
|
|
1284
2293
|
],
|
|
1285
|
-
|
|
2294
|
+
anonymous: false
|
|
1286
2295
|
},
|
|
1287
2296
|
{
|
|
1288
|
-
type: "
|
|
1289
|
-
name: "
|
|
1290
|
-
stateMutability: "nonpayable",
|
|
2297
|
+
type: "event",
|
|
2298
|
+
name: "RESWithdrawEvent",
|
|
1291
2299
|
inputs: [
|
|
1292
|
-
{
|
|
1293
|
-
|
|
1294
|
-
|
|
2300
|
+
{
|
|
2301
|
+
name: "id",
|
|
2302
|
+
type: "bytes32",
|
|
2303
|
+
indexed: true,
|
|
2304
|
+
internalType: "bytes32"
|
|
2305
|
+
},
|
|
2306
|
+
{
|
|
2307
|
+
name: "reSender",
|
|
2308
|
+
type: "address",
|
|
2309
|
+
indexed: false,
|
|
2310
|
+
internalType: "address"
|
|
2311
|
+
},
|
|
2312
|
+
{
|
|
2313
|
+
name: "amount",
|
|
2314
|
+
type: "uint256",
|
|
2315
|
+
indexed: false,
|
|
2316
|
+
internalType: "uint256"
|
|
2317
|
+
},
|
|
2318
|
+
{
|
|
2319
|
+
name: "remainingNumber",
|
|
2320
|
+
type: "uint32",
|
|
2321
|
+
indexed: false,
|
|
2322
|
+
internalType: "uint32"
|
|
2323
|
+
},
|
|
2324
|
+
{
|
|
2325
|
+
name: "timestamp",
|
|
2326
|
+
type: "uint64",
|
|
2327
|
+
indexed: false,
|
|
2328
|
+
internalType: "uint64"
|
|
2329
|
+
}
|
|
1295
2330
|
],
|
|
1296
|
-
|
|
2331
|
+
anonymous: false
|
|
1297
2332
|
},
|
|
1298
2333
|
{
|
|
1299
|
-
type: "
|
|
1300
|
-
name: "
|
|
1301
|
-
stateMutability: "nonpayable",
|
|
2334
|
+
type: "event",
|
|
2335
|
+
name: "RESendEvent",
|
|
1302
2336
|
inputs: [
|
|
1303
|
-
{
|
|
1304
|
-
|
|
1305
|
-
|
|
2337
|
+
{
|
|
2338
|
+
name: "id",
|
|
2339
|
+
type: "bytes32",
|
|
2340
|
+
indexed: true,
|
|
2341
|
+
internalType: "bytes32"
|
|
2342
|
+
},
|
|
2343
|
+
{
|
|
2344
|
+
name: "reSender",
|
|
2345
|
+
type: "address",
|
|
2346
|
+
indexed: false,
|
|
2347
|
+
internalType: "address"
|
|
2348
|
+
},
|
|
2349
|
+
{
|
|
2350
|
+
name: "tokenType",
|
|
2351
|
+
type: "uint32",
|
|
2352
|
+
indexed: false,
|
|
2353
|
+
internalType: "uint32"
|
|
2354
|
+
},
|
|
2355
|
+
{
|
|
2356
|
+
name: "tokenAddress",
|
|
2357
|
+
type: "address",
|
|
2358
|
+
indexed: false,
|
|
2359
|
+
internalType: "address"
|
|
2360
|
+
},
|
|
2361
|
+
{
|
|
2362
|
+
name: "amount",
|
|
2363
|
+
type: "uint256",
|
|
2364
|
+
indexed: false,
|
|
2365
|
+
internalType: "uint256"
|
|
2366
|
+
},
|
|
2367
|
+
{
|
|
2368
|
+
name: "reType",
|
|
2369
|
+
type: "uint32",
|
|
2370
|
+
indexed: false,
|
|
2371
|
+
internalType: "uint32"
|
|
2372
|
+
},
|
|
2373
|
+
{
|
|
2374
|
+
name: "number",
|
|
2375
|
+
type: "uint32",
|
|
2376
|
+
indexed: false,
|
|
2377
|
+
internalType: "uint32"
|
|
2378
|
+
},
|
|
2379
|
+
{
|
|
2380
|
+
name: "timestamp",
|
|
2381
|
+
type: "uint64",
|
|
2382
|
+
indexed: false,
|
|
2383
|
+
internalType: "uint64"
|
|
2384
|
+
}
|
|
1306
2385
|
],
|
|
1307
|
-
|
|
2386
|
+
anonymous: false
|
|
1308
2387
|
},
|
|
2388
|
+
{ type: "error", name: "InvalidInitialization", inputs: [] },
|
|
2389
|
+
{ type: "error", name: "NotInitializing", inputs: [] },
|
|
1309
2390
|
{
|
|
1310
|
-
type: "
|
|
1311
|
-
name: "
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
2391
|
+
type: "error",
|
|
2392
|
+
name: "OwnableInvalidOwner",
|
|
2393
|
+
inputs: [
|
|
2394
|
+
{ name: "owner", type: "address", internalType: "address" }
|
|
2395
|
+
]
|
|
1315
2396
|
},
|
|
1316
2397
|
{
|
|
1317
|
-
type: "
|
|
1318
|
-
name: "
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
2398
|
+
type: "error",
|
|
2399
|
+
name: "OwnableUnauthorizedAccount",
|
|
2400
|
+
inputs: [
|
|
2401
|
+
{ name: "account", type: "address", internalType: "address" }
|
|
2402
|
+
]
|
|
1322
2403
|
}
|
|
1323
2404
|
];
|
|
1324
2405
|
|
|
1325
|
-
// src/classes/
|
|
1326
|
-
var
|
|
1327
|
-
|
|
1328
|
-
constructor(provider, address) {
|
|
1329
|
-
if (!provider || !address) {
|
|
1330
|
-
throw new Error("provider, address are required");
|
|
1331
|
-
}
|
|
1332
|
-
this.contractInstance = new Contract_default(provider, address, erc721Abi_default);
|
|
1333
|
-
}
|
|
1334
|
-
async approve(address, tokenId) {
|
|
1335
|
-
return new Promise(async (resolve, reject) => {
|
|
1336
|
-
try {
|
|
1337
|
-
const approver = await this.contractInstance.callMethod("getApproved", [tokenId]);
|
|
1338
|
-
if (approver === address) {
|
|
1339
|
-
console.log(`Already approved:: ${approver}`);
|
|
1340
|
-
resolve("Approved");
|
|
1341
|
-
} else {
|
|
1342
|
-
await this.contractInstance.sendTransaction("approve", [address, tokenId]);
|
|
1343
|
-
console.log(`Approved`);
|
|
1344
|
-
resolve("Approved");
|
|
1345
|
-
}
|
|
1346
|
-
} catch (error) {
|
|
1347
|
-
console.error("Approval failed:", error);
|
|
1348
|
-
return reject(error);
|
|
1349
|
-
}
|
|
1350
|
-
});
|
|
1351
|
-
}
|
|
1352
|
-
// ownerAddress: string,
|
|
1353
|
-
async setApprovalForAll(operatorAddress) {
|
|
1354
|
-
return new Promise(async (resolve, reject) => {
|
|
1355
|
-
try {
|
|
1356
|
-
await this.contractInstance.sendTransaction("setApprovalForAll", [operatorAddress, true]);
|
|
1357
|
-
console.log(`Approved`);
|
|
1358
|
-
resolve("Approved");
|
|
1359
|
-
} catch (error) {
|
|
1360
|
-
console.error("Approval failed:", error);
|
|
1361
|
-
return reject(error);
|
|
1362
|
-
}
|
|
1363
|
-
});
|
|
1364
|
-
}
|
|
1365
|
-
async fetchMetaData(nftContractAddress, tokenId) {
|
|
1366
|
-
return new Promise(async (resolve, reject) => {
|
|
1367
|
-
try {
|
|
1368
|
-
let url = await this.contractInstance.callMethod("tokenURI", [tokenId]);
|
|
1369
|
-
if (url.startsWith("ipfs://")) {
|
|
1370
|
-
url = url.replace("ipfs://", "https://ipfs.io/ipfs/");
|
|
1371
|
-
}
|
|
1372
|
-
const res = await fetch(url);
|
|
1373
|
-
if (!res.ok) {
|
|
1374
|
-
return reject(`Failed to fetch metadata from ${url}`);
|
|
1375
|
-
}
|
|
1376
|
-
let metadata = await res.json();
|
|
1377
|
-
if (metadata.image && metadata.image.startsWith("ipfs://")) {
|
|
1378
|
-
metadata.image = metadata.image.replace(
|
|
1379
|
-
"ipfs://",
|
|
1380
|
-
"https://ipfs.io/ipfs/"
|
|
1381
|
-
);
|
|
1382
|
-
}
|
|
1383
|
-
metadata.address = nftContractAddress;
|
|
1384
|
-
metadata.tokenId = tokenId;
|
|
1385
|
-
return resolve(metadata);
|
|
1386
|
-
} catch (error) {
|
|
1387
|
-
return reject(error);
|
|
1388
|
-
}
|
|
1389
|
-
});
|
|
1390
|
-
}
|
|
1391
|
-
};
|
|
1392
|
-
var Erc721Contract_default = Erc721Contract;
|
|
1393
|
-
|
|
1394
|
-
// src/classes/Fund.ts
|
|
1395
|
-
var { parseUnits, formatUnits } = import_ethers2.ethers.utils;
|
|
1396
|
-
var Fund = class {
|
|
1397
|
-
zkTlsSdk;
|
|
2406
|
+
// src/classes/FundForRedPacket.ts
|
|
2407
|
+
var { parseUnits: parseUnits3 } = import_ethers4.ethers.utils;
|
|
2408
|
+
var FundForRedPacket = class {
|
|
1398
2409
|
fundContract;
|
|
1399
2410
|
provider;
|
|
1400
2411
|
formatProvider;
|
|
1401
2412
|
chainId;
|
|
1402
|
-
_dataSourceTemplateMap = DATASOURCETEMPLATESMAP;
|
|
1403
2413
|
constructor() {
|
|
1404
2414
|
}
|
|
1405
|
-
|
|
1406
|
-
return this.zkTlsSdk;
|
|
1407
|
-
}
|
|
1408
|
-
async init(provider, chainId, appId) {
|
|
2415
|
+
async init(provider, chainId) {
|
|
1409
2416
|
return new Promise(async (resolve, reject) => {
|
|
1410
2417
|
try {
|
|
1411
|
-
|
|
1412
|
-
if (provider instanceof import_ethers2.ethers.providers.JsonRpcProvider) {
|
|
1413
|
-
formatProvider = provider;
|
|
1414
|
-
} else {
|
|
1415
|
-
formatProvider = new import_ethers2.ethers.providers.Web3Provider(provider);
|
|
1416
|
-
}
|
|
1417
|
-
const gasPrice = await formatProvider.getGasPrice();
|
|
1418
|
-
console.log("getGasPrice=", gasPrice);
|
|
1419
|
-
await formatProvider.ready;
|
|
1420
|
-
const network = await formatProvider.getNetwork();
|
|
1421
|
-
const providerChainId = network.chainId;
|
|
1422
|
-
console.log("init provider", provider, network);
|
|
1423
|
-
console.log("init providerChainId", providerChainId, chainId);
|
|
1424
|
-
if (providerChainId !== chainId) {
|
|
1425
|
-
return reject(`Please connect to the chain with ID ${chainId} first.`);
|
|
1426
|
-
}
|
|
1427
|
-
const fundContractAddress = Fund_CONTRACTS[chainId];
|
|
2418
|
+
const fundContractAddress = FundForRedPacket_CONTRACTS[chainId];
|
|
1428
2419
|
if (!fundContractAddress) {
|
|
1429
2420
|
return reject(`Unsupported chainId:${chainId}`);
|
|
1430
2421
|
}
|
|
1431
|
-
this.fundContract = new Contract_default(provider, fundContractAddress,
|
|
2422
|
+
this.fundContract = new Contract_default(provider, fundContractAddress, abiForRedPacket_default);
|
|
1432
2423
|
this.provider = provider;
|
|
1433
|
-
this.formatProvider = formatProvider;
|
|
1434
2424
|
this.chainId = chainId;
|
|
1435
|
-
|
|
1436
|
-
this.zkTlsSdk = new import_zktls_js_sdk.PrimusZKTLS();
|
|
1437
|
-
let platformDevice = "pc";
|
|
1438
|
-
const isIpad = () => {
|
|
1439
|
-
const userAgent = navigator.userAgent.toLowerCase();
|
|
1440
|
-
const isTabletSize = window.innerWidth > 768 && window.innerWidth < 1366;
|
|
1441
|
-
return /ipad/.test(userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 0 && isTabletSize;
|
|
1442
|
-
};
|
|
1443
|
-
if (navigator.userAgent.toLocaleLowerCase().includes("android")) {
|
|
1444
|
-
platformDevice = "android";
|
|
1445
|
-
} else if (navigator.userAgent.toLocaleLowerCase().includes("iphone") || isIpad()) {
|
|
1446
|
-
platformDevice = "ios";
|
|
1447
|
-
}
|
|
1448
|
-
console.log("init appId", appId, platformDevice);
|
|
1449
|
-
const extensionVersion = await this.zkTlsSdk.init(
|
|
1450
|
-
appId,
|
|
1451
|
-
"",
|
|
1452
|
-
{ platform: platformDevice }
|
|
1453
|
-
);
|
|
1454
|
-
resolve(extensionVersion);
|
|
1455
|
-
} else {
|
|
1456
|
-
resolve("success");
|
|
1457
|
-
}
|
|
2425
|
+
resolve("success");
|
|
1458
2426
|
} catch (error) {
|
|
1459
2427
|
return reject(error);
|
|
1460
2428
|
}
|
|
1461
2429
|
});
|
|
1462
2430
|
}
|
|
1463
|
-
async
|
|
2431
|
+
async fundForRedPacket(tokenInfo, sendParam) {
|
|
1464
2432
|
return new Promise(async (resolve, reject) => {
|
|
1465
2433
|
try {
|
|
1466
|
-
const recipientInfos = [];
|
|
1467
|
-
recipientInfos[0] = recipientInfo;
|
|
1468
2434
|
let decimals = 18;
|
|
1469
2435
|
let params = [];
|
|
1470
2436
|
if (tokenInfo.tokenType === 0) {
|
|
1471
|
-
await this.
|
|
2437
|
+
await this.approveForRedPacket(tokenInfo, sendParam.amount);
|
|
1472
2438
|
console.log("after approve in fund fn");
|
|
1473
|
-
const
|
|
1474
|
-
|
|
1475
|
-
decimals = await erc20Contract.decimals();
|
|
1476
|
-
} else if (tokenInfo.tokenType === 2) {
|
|
1477
|
-
decimals = 0;
|
|
1478
|
-
const erc721ContractInstance = new Erc721Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
1479
|
-
await erc721ContractInstance.approve(this.fundContract.address, recipientInfo.nftIds[0]);
|
|
2439
|
+
const tokenContract = new Erc20Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
2440
|
+
decimals = await tokenContract.decimals();
|
|
1480
2441
|
}
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
2442
|
+
if (tokenInfo.tokenType === 1) {
|
|
2443
|
+
tokenInfo.tokenAddress = import_ethers4.ethers.constants.AddressZero;
|
|
2444
|
+
}
|
|
2445
|
+
const formatSendAmount = parseUnits3(sendParam.amount.toString(), decimals);
|
|
2446
|
+
const formatSendParam = {
|
|
2447
|
+
...sendParam,
|
|
2448
|
+
amount: formatSendAmount
|
|
1487
2449
|
};
|
|
1488
2450
|
if (tokenInfo.tokenType === 1) {
|
|
1489
|
-
params = [tokenInfo,
|
|
2451
|
+
params = [tokenInfo, formatSendParam, { value: formatSendAmount }];
|
|
1490
2452
|
} else {
|
|
1491
|
-
params = [tokenInfo,
|
|
2453
|
+
params = [tokenInfo, formatSendParam];
|
|
1492
2454
|
}
|
|
1493
2455
|
if ([97, 56].includes(this.chainId)) {
|
|
1494
|
-
const gasPrice = await this.
|
|
2456
|
+
const gasPrice = await this.provider.getGasPrice();
|
|
1495
2457
|
params[2] = params[2] ? { ...params[2], gasPrice } : { gasPrice };
|
|
1496
2458
|
}
|
|
1497
|
-
console.log("
|
|
1498
|
-
const result = await this.fundContract.sendTransaction("
|
|
2459
|
+
console.log("tipForRedPacket-params", params, this.chainId);
|
|
2460
|
+
const result = await this.fundContract.sendTransaction("reSend", params);
|
|
1499
2461
|
resolve(result);
|
|
1500
2462
|
} catch (error) {
|
|
1501
2463
|
return reject(error);
|
|
1502
2464
|
}
|
|
1503
2465
|
});
|
|
1504
2466
|
}
|
|
1505
|
-
async
|
|
2467
|
+
async onlyFundForRedPacket(tokenInfo, sendParam) {
|
|
1506
2468
|
return new Promise(async (resolve, reject) => {
|
|
1507
2469
|
try {
|
|
1508
|
-
const recipientInfos = [];
|
|
1509
|
-
recipientInfos[0] = recipientInfo;
|
|
1510
2470
|
let decimals = 18;
|
|
1511
2471
|
let params = [];
|
|
1512
2472
|
if (tokenInfo.tokenType === 0) {
|
|
1513
|
-
const
|
|
1514
|
-
|
|
1515
|
-
decimals = await erc20Contract.decimals();
|
|
1516
|
-
} else if (tokenInfo.tokenType === 2) {
|
|
1517
|
-
decimals = 0;
|
|
1518
|
-
const erc721ContractInstance = new Erc721Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
1519
|
-
await erc721ContractInstance.approve(this.fundContract.address, recipientInfo.nftIds[0]);
|
|
2473
|
+
const tokenContract = new Erc20Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
2474
|
+
decimals = await tokenContract.decimals();
|
|
1520
2475
|
}
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
2476
|
+
if (tokenInfo.tokenType === 1) {
|
|
2477
|
+
tokenInfo.tokenAddress = import_ethers4.ethers.constants.AddressZero;
|
|
2478
|
+
}
|
|
2479
|
+
const formatSendAmount = parseUnits3(sendParam.amount.toString(), decimals);
|
|
2480
|
+
const formatSendParam = {
|
|
2481
|
+
...sendParam,
|
|
2482
|
+
amount: formatSendAmount
|
|
1527
2483
|
};
|
|
1528
2484
|
if (tokenInfo.tokenType === 1) {
|
|
1529
|
-
params = [tokenInfo,
|
|
2485
|
+
params = [tokenInfo, formatSendParam, { value: formatSendAmount }];
|
|
1530
2486
|
} else {
|
|
1531
|
-
params = [tokenInfo,
|
|
2487
|
+
params = [tokenInfo, formatSendParam];
|
|
1532
2488
|
}
|
|
1533
2489
|
if ([97, 56].includes(this.chainId)) {
|
|
1534
|
-
const gasPrice = await this.
|
|
2490
|
+
const gasPrice = await this.provider.getGasPrice();
|
|
1535
2491
|
params[2] = params[2] ? { ...params[2], gasPrice } : { gasPrice };
|
|
1536
2492
|
}
|
|
1537
|
-
console.log("
|
|
1538
|
-
const result = await this.fundContract.sendTransaction("
|
|
2493
|
+
console.log("onlytipForRedPacket-params", params, this.chainId);
|
|
2494
|
+
const result = await this.fundContract.sendTransaction("reSend", params);
|
|
1539
2495
|
resolve(result);
|
|
1540
2496
|
} catch (error) {
|
|
1541
2497
|
return reject(error);
|
|
1542
2498
|
}
|
|
1543
2499
|
});
|
|
1544
2500
|
}
|
|
1545
|
-
async
|
|
2501
|
+
async withdrawForRedPacket(redPacketId) {
|
|
1546
2502
|
return new Promise(async (resolve, reject) => {
|
|
1547
2503
|
try {
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
};
|
|
1554
|
-
}
|
|
1555
|
-
|
|
2504
|
+
let params = [redPacketId];
|
|
2505
|
+
if ([97, 56].includes(this.chainId)) {
|
|
2506
|
+
const gasPrice = await this.provider.getGasPrice();
|
|
2507
|
+
params.push({
|
|
2508
|
+
gasPrice
|
|
2509
|
+
});
|
|
2510
|
+
}
|
|
2511
|
+
const result = await this.fundContract.sendTransaction("reSenderWithdraw", params);
|
|
2512
|
+
return resolve(result);
|
|
2513
|
+
} catch (error) {
|
|
2514
|
+
return reject(error);
|
|
2515
|
+
}
|
|
2516
|
+
});
|
|
2517
|
+
}
|
|
2518
|
+
async approveForRedPacket(tokenInfo, approveAmount) {
|
|
2519
|
+
return new Promise(async (resolve, reject) => {
|
|
2520
|
+
try {
|
|
2521
|
+
let approveParams = {
|
|
2522
|
+
spenderAddress: this.fundContract.address,
|
|
2523
|
+
approveAmount
|
|
2524
|
+
};
|
|
1556
2525
|
if ([97, 56].includes(this.chainId)) {
|
|
1557
|
-
const gasPrice = await this.
|
|
1558
|
-
|
|
1559
|
-
gasPrice
|
|
1560
|
-
});
|
|
2526
|
+
const gasPrice = await this.provider.getGasPrice();
|
|
2527
|
+
approveParams.otherParams = { gasPrice };
|
|
1561
2528
|
}
|
|
1562
|
-
const
|
|
1563
|
-
|
|
2529
|
+
const tokenContract = new Erc20Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
2530
|
+
await tokenContract.approve(approveParams);
|
|
2531
|
+
resolve("Approved");
|
|
1564
2532
|
} catch (error) {
|
|
1565
2533
|
return reject(error);
|
|
1566
2534
|
}
|
|
1567
2535
|
});
|
|
1568
2536
|
}
|
|
1569
|
-
async
|
|
2537
|
+
async claimForRedPacket(redPacketId, attestation) {
|
|
1570
2538
|
return new Promise(async (resolve, reject) => {
|
|
1571
2539
|
try {
|
|
1572
|
-
|
|
1573
|
-
let params = [];
|
|
1574
|
-
if (tokenInfo.tokenType === 0) {
|
|
1575
|
-
await this.approve(tokenInfo, recipientInfoList);
|
|
1576
|
-
const web3Provider = new import_ethers2.ethers.providers.Web3Provider(this.provider);
|
|
1577
|
-
const erc20Contract = new import_ethers2.ethers.Contract(tokenInfo.tokenAddress, erc20Abi_default, web3Provider);
|
|
1578
|
-
decimals = await erc20Contract.decimals();
|
|
1579
|
-
} else if (tokenInfo.tokenType === 2) {
|
|
1580
|
-
decimals = 0;
|
|
1581
|
-
const erc721ContractInstance = new Erc721Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
1582
|
-
await erc721ContractInstance.setApprovalForAll(this.fundContract.address);
|
|
1583
|
-
}
|
|
1584
|
-
let totalFormatAmount = recipientInfoList.reduce((acc, cur) => acc.add(parseUnits(cur.tokenAmount.toString(), decimals)), import_ethers2.ethers.BigNumber.from(0));
|
|
1585
|
-
const newRecipientInfoList = recipientInfoList.map((i) => {
|
|
1586
|
-
const formatAmount = parseUnits(i.tokenAmount.toString(), decimals);
|
|
1587
|
-
return {
|
|
1588
|
-
idSource: i.socialPlatform,
|
|
1589
|
-
id: i.userIdentifier,
|
|
1590
|
-
amount: formatAmount,
|
|
1591
|
-
nftIds: i.nftIds
|
|
1592
|
-
};
|
|
1593
|
-
});
|
|
1594
|
-
if (tokenInfo.tokenType === 1) {
|
|
1595
|
-
params = [tokenInfo, newRecipientInfoList, { value: totalFormatAmount }];
|
|
1596
|
-
} else {
|
|
1597
|
-
params = [tokenInfo, newRecipientInfoList];
|
|
1598
|
-
}
|
|
2540
|
+
const claimFee = await this.fundContract.callMethod("claimFee", []);
|
|
2541
|
+
let params = [redPacketId, attestation, { value: claimFee }];
|
|
1599
2542
|
if ([97, 56].includes(this.chainId)) {
|
|
1600
|
-
const gasPrice = await this.
|
|
1601
|
-
params[2] =
|
|
2543
|
+
const gasPrice = await this.provider.getGasPrice();
|
|
2544
|
+
params[2].gasPrice = gasPrice;
|
|
1602
2545
|
}
|
|
1603
|
-
const
|
|
1604
|
-
return resolve(
|
|
2546
|
+
const txreceipt = await this.fundContract.sendTransaction("reClaim", params);
|
|
2547
|
+
return resolve(txreceipt);
|
|
1605
2548
|
} catch (error) {
|
|
1606
2549
|
return reject(error);
|
|
1607
2550
|
}
|
|
1608
2551
|
});
|
|
1609
2552
|
}
|
|
1610
|
-
|
|
1611
|
-
async approve(tokenInfo, recipientInfoList) {
|
|
2553
|
+
async getRedPacketInfo(redPacketId) {
|
|
1612
2554
|
return new Promise(async (resolve, reject) => {
|
|
1613
2555
|
try {
|
|
1614
|
-
const
|
|
1615
|
-
|
|
1616
|
-
const address = await signer.getAddress();
|
|
1617
|
-
const erc20Contract = new import_ethers2.ethers.Contract(tokenInfo.tokenAddress, erc20Abi_default, signer);
|
|
1618
|
-
const allowance = await erc20Contract.allowance(address, this.fundContract.address);
|
|
1619
|
-
const decimals = await erc20Contract.decimals();
|
|
1620
|
-
console.log("allowance", formatUnits(allowance.toString(), decimals));
|
|
1621
|
-
const requiredAllowance = recipientInfoList.reduce((acc, cur) => acc.add(parseUnits(cur.tokenAmount.toString(), decimals)), import_ethers2.ethers.BigNumber.from(0));
|
|
1622
|
-
if (allowance.lt(requiredAllowance)) {
|
|
1623
|
-
let params = [this.fundContract.address, requiredAllowance];
|
|
1624
|
-
if ([97, 56].includes(this.chainId)) {
|
|
1625
|
-
const gasPrice = await this.formatProvider.getGasPrice();
|
|
1626
|
-
params.push({ gasPrice });
|
|
1627
|
-
}
|
|
1628
|
-
const tx = await erc20Contract.approve(...params);
|
|
1629
|
-
await tx.wait();
|
|
1630
|
-
console.log(`Approved: ${requiredAllowance.toString()}`);
|
|
1631
|
-
} else {
|
|
1632
|
-
console.log(`Already approved: ${allowance.toString()}`);
|
|
1633
|
-
}
|
|
1634
|
-
resolve("Approved");
|
|
2556
|
+
const redpacketInfo = await this.fundContract.callMethod("getREInfo", [redPacketId]);
|
|
2557
|
+
return resolve(redpacketInfo);
|
|
1635
2558
|
} catch (error) {
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
2559
|
+
return reject(error);
|
|
2560
|
+
}
|
|
2561
|
+
});
|
|
2562
|
+
}
|
|
2563
|
+
};
|
|
2564
|
+
|
|
2565
|
+
// src/classes/ZktlsSdk.ts
|
|
2566
|
+
var import_zktls_js_sdk = require("@primuslabs/zktls-js-sdk");
|
|
2567
|
+
var ZktlsSdk = class {
|
|
2568
|
+
zkTlsSdk;
|
|
2569
|
+
constructor() {
|
|
2570
|
+
}
|
|
2571
|
+
getZkTlsSdk() {
|
|
2572
|
+
return this.zkTlsSdk;
|
|
2573
|
+
}
|
|
2574
|
+
async init(appId) {
|
|
2575
|
+
return new Promise(async (resolve, reject) => {
|
|
2576
|
+
try {
|
|
2577
|
+
this.zkTlsSdk = new import_zktls_js_sdk.PrimusZKTLS();
|
|
2578
|
+
let platformDevice = "pc";
|
|
2579
|
+
const isIpad = () => {
|
|
2580
|
+
const userAgent = navigator.userAgent.toLowerCase();
|
|
2581
|
+
const isTabletSize = window.innerWidth > 768 && window.innerWidth < 1366;
|
|
2582
|
+
return /ipad/.test(userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 0 && isTabletSize;
|
|
2583
|
+
};
|
|
2584
|
+
if (navigator.userAgent.toLocaleLowerCase().includes("android")) {
|
|
2585
|
+
platformDevice = "android";
|
|
2586
|
+
} else if (navigator.userAgent.toLocaleLowerCase().includes("iphone") || isIpad()) {
|
|
2587
|
+
platformDevice = "ios";
|
|
1639
2588
|
}
|
|
2589
|
+
console.log("init appId", appId, platformDevice);
|
|
2590
|
+
const extensionVersion = await this.zkTlsSdk.init(
|
|
2591
|
+
appId,
|
|
2592
|
+
"",
|
|
2593
|
+
{ platform: platformDevice }
|
|
2594
|
+
);
|
|
2595
|
+
resolve(extensionVersion);
|
|
2596
|
+
} catch (error) {
|
|
1640
2597
|
return reject(error);
|
|
1641
2598
|
}
|
|
1642
2599
|
});
|
|
1643
2600
|
}
|
|
1644
|
-
async attest(attestParams,
|
|
2601
|
+
async attest(attestParams, signFn, backUrl) {
|
|
1645
2602
|
return new Promise(async (resolve, reject) => {
|
|
1646
2603
|
console.log("this.zkTlsSdk", this.zkTlsSdk);
|
|
1647
2604
|
const { socialPlatform, userIdentifier, address } = attestParams;
|
|
1648
|
-
const { id: templateId, field } =
|
|
2605
|
+
const { id: templateId, field } = DATASOURCETEMPLATESMAP[socialPlatform];
|
|
1649
2606
|
const attRequest = this.zkTlsSdk.generateRequestParams(
|
|
1650
2607
|
templateId,
|
|
1651
2608
|
address
|
|
@@ -1664,7 +2621,7 @@ var Fund = class {
|
|
|
1664
2621
|
]
|
|
1665
2622
|
]);
|
|
1666
2623
|
const signParams = attRequest.toJsonString();
|
|
1667
|
-
const signature = await
|
|
2624
|
+
const signature = await signFn(signParams);
|
|
1668
2625
|
if (!signature) {
|
|
1669
2626
|
return reject(`appSignature is empty!`);
|
|
1670
2627
|
}
|
|
@@ -1684,121 +2641,41 @@ var Fund = class {
|
|
|
1684
2641
|
}
|
|
1685
2642
|
});
|
|
1686
2643
|
}
|
|
1687
|
-
async
|
|
2644
|
+
async attestCommon(attestParams) {
|
|
2645
|
+
const { templateId, address, signFn, conditions, additionParams, backUrl } = attestParams;
|
|
1688
2646
|
return new Promise(async (resolve, reject) => {
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
} else {
|
|
1697
|
-
const totalFee = claimFee.mul(recordCount);
|
|
1698
|
-
let params = [socialPlatform, attestation, { value: totalFee }];
|
|
1699
|
-
if ([97, 56].includes(this.chainId)) {
|
|
1700
|
-
const gasPrice = await this.formatProvider.getGasPrice();
|
|
1701
|
-
params[2].gasPrice = gasPrice;
|
|
1702
|
-
}
|
|
1703
|
-
const txreceipt = await this.fundContract.sendTransaction("claimBySource", params);
|
|
1704
|
-
return resolve(txreceipt);
|
|
1705
|
-
}
|
|
1706
|
-
} catch (error) {
|
|
1707
|
-
return reject(error);
|
|
2647
|
+
console.log("this.zkTlsSdk", this.zkTlsSdk);
|
|
2648
|
+
const attRequest = this.zkTlsSdk.generateRequestParams(
|
|
2649
|
+
templateId,
|
|
2650
|
+
address
|
|
2651
|
+
);
|
|
2652
|
+
if (backUrl) {
|
|
2653
|
+
attRequest.setBackUrl(backUrl);
|
|
1708
2654
|
}
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
const fundRecords = await this.fundContract.callMethod("getTipRecords", [{ idSource: value, id: userIdentifiers[index] }]);
|
|
1722
|
-
allFundRecords.push(...fundRecords);
|
|
1723
|
-
recordCount += fundRecords.length;
|
|
1724
|
-
}
|
|
1725
|
-
if (recordCount <= 0) {
|
|
1726
|
-
return reject(`No fund records.`);
|
|
1727
|
-
} else {
|
|
1728
|
-
const totalFee = claimFee.mul(recordCount);
|
|
1729
|
-
let params = [socialPlatforms, userIdentifiers, attestationList, { value: totalFee }];
|
|
1730
|
-
if ([97, 56].includes(this.chainId)) {
|
|
1731
|
-
const gasPrice = await this.formatProvider.getGasPrice();
|
|
1732
|
-
params[3].gasPrice = gasPrice;
|
|
1733
|
-
}
|
|
1734
|
-
const txreceipt = await this.fundContract.sendTransaction("claimByMultiSource", params);
|
|
1735
|
-
return resolve(txreceipt);
|
|
1736
|
-
}
|
|
1737
|
-
} catch (error) {
|
|
1738
|
-
console.error("claimByMultiSource", error);
|
|
1739
|
-
return reject(error);
|
|
2655
|
+
console.log(`attRequest: ${JSON.stringify(attRequest)}`);
|
|
2656
|
+
if (conditions) {
|
|
2657
|
+
attRequest.setAttConditions(conditions);
|
|
2658
|
+
}
|
|
2659
|
+
if (additionParams) {
|
|
2660
|
+
console.log("setAdditionParams--", additionParams);
|
|
2661
|
+
attRequest.setAdditionParams(additionParams);
|
|
2662
|
+
}
|
|
2663
|
+
const signParams = attRequest.toJsonString();
|
|
2664
|
+
const signature = await signFn(signParams);
|
|
2665
|
+
if (!signature) {
|
|
2666
|
+
return reject(`appSignature is empty!`);
|
|
1740
2667
|
}
|
|
1741
|
-
});
|
|
1742
|
-
}
|
|
1743
|
-
async getTipRecords(getFundRecordsParams) {
|
|
1744
|
-
return new Promise(async (resolve, reject) => {
|
|
1745
2668
|
try {
|
|
1746
|
-
const
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
}
|
|
1752
|
-
const
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
const { tipper, timestamp, tipToken: [tokenType, tokenAddress], amount, nftIds } = record;
|
|
1757
|
-
let decimals = 18;
|
|
1758
|
-
let symbol = "";
|
|
1759
|
-
let tokenId = null;
|
|
1760
|
-
let nftInfo = null;
|
|
1761
|
-
if (tokenType === 0) {
|
|
1762
|
-
let formatProvider;
|
|
1763
|
-
if (this.provider instanceof import_ethers2.ethers.providers.JsonRpcProvider) {
|
|
1764
|
-
formatProvider = this.provider;
|
|
1765
|
-
} else {
|
|
1766
|
-
formatProvider = new import_ethers2.ethers.providers.Web3Provider(this.provider);
|
|
1767
|
-
}
|
|
1768
|
-
const erc20Contract = new import_ethers2.ethers.Contract(tokenAddress, erc20Abi_default, formatProvider);
|
|
1769
|
-
decimals = await erc20Contract.decimals();
|
|
1770
|
-
symbol = await erc20Contract.symbol();
|
|
1771
|
-
} else if (tokenType === 1) {
|
|
1772
|
-
symbol = NATIVETOKENS[this.chainId];
|
|
1773
|
-
} else if (tokenType === 2) {
|
|
1774
|
-
decimals = 0;
|
|
1775
|
-
tokenId = parseInt(nftIds[0]);
|
|
1776
|
-
const erc721ContractInstance = new Erc721Contract_default(this.provider, tokenAddress);
|
|
1777
|
-
nftInfo = await erc721ContractInstance.fetchMetaData(tokenAddress, tokenId);
|
|
1778
|
-
}
|
|
1779
|
-
let fundToken = {
|
|
1780
|
-
tokenType,
|
|
1781
|
-
// tokenAmount: formatUnits(amount, decimals),
|
|
1782
|
-
decimals,
|
|
1783
|
-
symbol,
|
|
1784
|
-
chainName: CHAINNAMES[this.chainId],
|
|
1785
|
-
chainId: this.chainId
|
|
1786
|
-
};
|
|
1787
|
-
if (tokenType === 0) {
|
|
1788
|
-
fundToken.tokenAddress = tokenAddress;
|
|
1789
|
-
}
|
|
1790
|
-
if (tokenType === 2) {
|
|
1791
|
-
Object.assign(fundToken, nftInfo ?? {});
|
|
1792
|
-
}
|
|
1793
|
-
formatRecords.push({
|
|
1794
|
-
funder: tipper,
|
|
1795
|
-
fundToken,
|
|
1796
|
-
amount: formatUnits(amount, decimals),
|
|
1797
|
-
timestamp: timestamp.toNumber()
|
|
1798
|
-
});
|
|
1799
|
-
}
|
|
1800
|
-
console.log("formatRecords", formatRecords);
|
|
1801
|
-
return resolve(formatRecords);
|
|
2669
|
+
const formatAttestParams = {
|
|
2670
|
+
attRequest: {
|
|
2671
|
+
...JSON.parse(signParams)
|
|
2672
|
+
},
|
|
2673
|
+
appSignature: signature
|
|
2674
|
+
};
|
|
2675
|
+
const attestation = await this.zkTlsSdk.startAttestation(
|
|
2676
|
+
JSON.stringify(formatAttestParams)
|
|
2677
|
+
);
|
|
2678
|
+
return resolve(attestation);
|
|
1802
2679
|
} catch (error) {
|
|
1803
2680
|
return reject(error);
|
|
1804
2681
|
}
|
|
@@ -1810,15 +2687,41 @@ var Fund = class {
|
|
|
1810
2687
|
var PrimusFund = class {
|
|
1811
2688
|
supportedChainIds = SUPPORTEDCHAINIDS;
|
|
1812
2689
|
supportedSocialPlatforms = SUPPORTEDSOCIALPLATFORMS;
|
|
2690
|
+
provider;
|
|
1813
2691
|
_fund;
|
|
2692
|
+
_fundForRedPacket;
|
|
2693
|
+
_zkTlsSdk;
|
|
1814
2694
|
async init(provider, chainId, appId) {
|
|
1815
2695
|
return new Promise(async (resolve, reject) => {
|
|
1816
2696
|
try {
|
|
1817
2697
|
if (!this.supportedChainIds.includes(chainId)) {
|
|
1818
2698
|
return reject("chainId is not supported");
|
|
1819
2699
|
}
|
|
2700
|
+
let formatProvider;
|
|
2701
|
+
let signer;
|
|
2702
|
+
if (provider instanceof import_ethers5.ethers.providers.JsonRpcProvider) {
|
|
2703
|
+
formatProvider = provider;
|
|
2704
|
+
} else {
|
|
2705
|
+
formatProvider = new import_ethers5.ethers.providers.Web3Provider(provider);
|
|
2706
|
+
signer = formatProvider.getSigner();
|
|
2707
|
+
}
|
|
2708
|
+
await formatProvider.ready;
|
|
2709
|
+
const network = await formatProvider.getNetwork();
|
|
2710
|
+
const providerChainId = network.chainId;
|
|
2711
|
+
console.log("init provider", provider, network);
|
|
2712
|
+
console.log("init providerChainId", providerChainId, chainId);
|
|
2713
|
+
if (providerChainId !== chainId) {
|
|
2714
|
+
return reject(`Please connect to the chain with ID ${chainId} first.`);
|
|
2715
|
+
}
|
|
2716
|
+
this.provider = signer ?? formatProvider;
|
|
1820
2717
|
this._fund = new Fund();
|
|
1821
|
-
const result = await this._fund.init(provider, chainId
|
|
2718
|
+
const result = await this._fund.init(this.provider, chainId);
|
|
2719
|
+
this._fundForRedPacket = new FundForRedPacket();
|
|
2720
|
+
await this._fundForRedPacket.init(this.provider, chainId);
|
|
2721
|
+
if (appId) {
|
|
2722
|
+
this._zkTlsSdk = new ZktlsSdk();
|
|
2723
|
+
await this._zkTlsSdk.init(appId);
|
|
2724
|
+
}
|
|
1822
2725
|
return resolve(result);
|
|
1823
2726
|
} catch (error) {
|
|
1824
2727
|
return reject(error);
|
|
@@ -1837,7 +2740,7 @@ var PrimusFund = class {
|
|
|
1837
2740
|
return reject("socialPlatform is not supported");
|
|
1838
2741
|
}
|
|
1839
2742
|
if (tokenInfo.tokenType === 1) {
|
|
1840
|
-
tokenInfo.tokenAddress =
|
|
2743
|
+
tokenInfo.tokenAddress = import_ethers5.ethers.constants.AddressZero;
|
|
1841
2744
|
}
|
|
1842
2745
|
const newFundRecipientInfos = recipientInfos.map((i) => {
|
|
1843
2746
|
const formatSocialPlatform = i.socialPlatform.toLowerCase();
|
|
@@ -1876,7 +2779,7 @@ var PrimusFund = class {
|
|
|
1876
2779
|
return reject("socialPlatform is not supported");
|
|
1877
2780
|
}
|
|
1878
2781
|
if (tokenInfo.tokenType === 1) {
|
|
1879
|
-
tokenInfo.tokenAddress =
|
|
2782
|
+
tokenInfo.tokenAddress = import_ethers5.ethers.constants.AddressZero;
|
|
1880
2783
|
}
|
|
1881
2784
|
const newFundRecipientInfos = recipientInfos.map((i) => {
|
|
1882
2785
|
const formatSocialPlatform = i.socialPlatform.toLowerCase();
|
|
@@ -1910,7 +2813,7 @@ var PrimusFund = class {
|
|
|
1910
2813
|
return reject("socialPlatform is not supported");
|
|
1911
2814
|
}
|
|
1912
2815
|
if (tokenInfo.tokenType === 1) {
|
|
1913
|
-
tokenInfo.tokenAddress =
|
|
2816
|
+
tokenInfo.tokenAddress = import_ethers5.ethers.constants.AddressZero;
|
|
1914
2817
|
}
|
|
1915
2818
|
const newFundRecipientInfos = recipientInfos.map((i) => {
|
|
1916
2819
|
const formatSocialPlatform = i.socialPlatform.toLowerCase();
|
|
@@ -1952,15 +2855,15 @@ var PrimusFund = class {
|
|
|
1952
2855
|
}
|
|
1953
2856
|
});
|
|
1954
2857
|
}
|
|
1955
|
-
async attest(attestParams,
|
|
2858
|
+
async attest(attestParams, signFn, backUrl) {
|
|
1956
2859
|
return new Promise(async (resolve, reject) => {
|
|
1957
2860
|
try {
|
|
1958
2861
|
const { socialPlatform } = attestParams;
|
|
1959
2862
|
const lcSocialPlatform = socialPlatform.toLowerCase();
|
|
1960
|
-
const attestation = await this.
|
|
2863
|
+
const attestation = await this._zkTlsSdk?.attest({
|
|
1961
2864
|
...attestParams,
|
|
1962
2865
|
socialPlatform: lcSocialPlatform
|
|
1963
|
-
},
|
|
2866
|
+
}, signFn, backUrl);
|
|
1964
2867
|
return resolve(attestation);
|
|
1965
2868
|
} catch (error) {
|
|
1966
2869
|
return reject(error);
|
|
@@ -2028,6 +2931,79 @@ var PrimusFund = class {
|
|
|
2028
2931
|
}
|
|
2029
2932
|
});
|
|
2030
2933
|
}
|
|
2934
|
+
async fundForRedPacket(fundParam) {
|
|
2935
|
+
return new Promise(async (resolve, reject) => {
|
|
2936
|
+
try {
|
|
2937
|
+
const { tokenInfo, sendParam } = fundParam;
|
|
2938
|
+
const result = await this._fundForRedPacket?.fundForRedPacket(tokenInfo, sendParam);
|
|
2939
|
+
return resolve(result);
|
|
2940
|
+
} catch (error) {
|
|
2941
|
+
return reject(error);
|
|
2942
|
+
}
|
|
2943
|
+
});
|
|
2944
|
+
}
|
|
2945
|
+
async onlyFundForRedPacket(fundParam) {
|
|
2946
|
+
return new Promise(async (resolve, reject) => {
|
|
2947
|
+
try {
|
|
2948
|
+
const { tokenInfo, sendParam } = fundParam;
|
|
2949
|
+
const result = await this._fundForRedPacket?.onlyFundForRedPacket(tokenInfo, sendParam);
|
|
2950
|
+
return resolve(result);
|
|
2951
|
+
} catch (error) {
|
|
2952
|
+
return reject(error);
|
|
2953
|
+
}
|
|
2954
|
+
});
|
|
2955
|
+
}
|
|
2956
|
+
async withdrawForRedPacket(redPacketId) {
|
|
2957
|
+
return new Promise(async (resolve, reject) => {
|
|
2958
|
+
try {
|
|
2959
|
+
const result = await this._fundForRedPacket?.withdrawForRedPacket(redPacketId);
|
|
2960
|
+
return resolve(result);
|
|
2961
|
+
} catch (error) {
|
|
2962
|
+
return reject(error);
|
|
2963
|
+
}
|
|
2964
|
+
});
|
|
2965
|
+
}
|
|
2966
|
+
async getRedPacketInfo(redPacketId) {
|
|
2967
|
+
return new Promise(async (resolve, reject) => {
|
|
2968
|
+
try {
|
|
2969
|
+
const result = await this._fundForRedPacket?.getRedPacketInfo(redPacketId);
|
|
2970
|
+
return resolve(result);
|
|
2971
|
+
} catch (error) {
|
|
2972
|
+
return reject(error);
|
|
2973
|
+
}
|
|
2974
|
+
});
|
|
2975
|
+
}
|
|
2976
|
+
async approveForRedPacket(fundParam) {
|
|
2977
|
+
return new Promise(async (resolve, reject) => {
|
|
2978
|
+
try {
|
|
2979
|
+
const { tokenInfo, sendParam: { amount } } = fundParam;
|
|
2980
|
+
const result = await this._fundForRedPacket?.approveForRedPacket(tokenInfo, amount);
|
|
2981
|
+
return resolve(result);
|
|
2982
|
+
} catch (error) {
|
|
2983
|
+
return reject(error);
|
|
2984
|
+
}
|
|
2985
|
+
});
|
|
2986
|
+
}
|
|
2987
|
+
async claimForRedPacket(redPacketId, attestation) {
|
|
2988
|
+
return new Promise(async (resolve, reject) => {
|
|
2989
|
+
try {
|
|
2990
|
+
const result = await this._fundForRedPacket?.claimForRedPacket(redPacketId, attestation);
|
|
2991
|
+
return resolve(result);
|
|
2992
|
+
} catch (error) {
|
|
2993
|
+
return reject(error);
|
|
2994
|
+
}
|
|
2995
|
+
});
|
|
2996
|
+
}
|
|
2997
|
+
async attestCommon(attestParams) {
|
|
2998
|
+
return new Promise(async (resolve, reject) => {
|
|
2999
|
+
try {
|
|
3000
|
+
const attestation = await this._zkTlsSdk?.attestCommon(attestParams);
|
|
3001
|
+
return resolve(attestation);
|
|
3002
|
+
} catch (error) {
|
|
3003
|
+
return reject(error);
|
|
3004
|
+
}
|
|
3005
|
+
});
|
|
3006
|
+
}
|
|
2031
3007
|
};
|
|
2032
3008
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2033
3009
|
0 && (module.exports = {
|