@primuslabs/fund-js-sdk 0.1.11 → 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 +2223 -1227
- package/dist/index.mjs +2223 -1227
- 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,30 @@ var SUPPORTEDCHAINIDSMAP = {
|
|
|
89
91
|
name: "PHRS",
|
|
90
92
|
symbol: "PHRS"
|
|
91
93
|
},
|
|
92
|
-
contractAddress: "0xD17512B7EC12880Bd94Eca9d774089fF89805F02"
|
|
94
|
+
contractAddress: "0xD17512B7EC12880Bd94Eca9d774089fF89805F02",
|
|
95
|
+
redPacketContractAddress: "0x673D74d95A35B26804475066d9cD1DA3947f4eC3"
|
|
96
|
+
},
|
|
97
|
+
84532: {
|
|
98
|
+
chainId: 84532,
|
|
99
|
+
chainName: "Base Sepolia",
|
|
100
|
+
nativeCurrency: {
|
|
101
|
+
decimals: 18,
|
|
102
|
+
name: "Sepolia Ether",
|
|
103
|
+
symbol: "ETH"
|
|
104
|
+
},
|
|
105
|
+
contractAddress: "0x4E78940F0019EbAEDc6F4995D7B8ABf060F7a341",
|
|
106
|
+
redPacketContractAddress: "0xA33Ed35460C3d06094693956B2d7Cd1a9e7A39a8"
|
|
107
|
+
},
|
|
108
|
+
8453: {
|
|
109
|
+
chainId: 8453,
|
|
110
|
+
chainName: "Base",
|
|
111
|
+
nativeCurrency: {
|
|
112
|
+
decimals: 18,
|
|
113
|
+
name: "Ether",
|
|
114
|
+
symbol: "ETH"
|
|
115
|
+
},
|
|
116
|
+
contractAddress: "0xa2e0700a269Be3158c81E4739518b324d4398588",
|
|
117
|
+
redPacketContractAddress: "0x50bd377EB8D4236Bb587AB3FB1eeafd888AEeC58"
|
|
93
118
|
}
|
|
94
119
|
};
|
|
95
120
|
var NATIVETOKENS = Object.values(SUPPORTEDCHAINIDSMAP).reduce((prev, curr) => {
|
|
@@ -111,6 +136,17 @@ var Fund_CONTRACTS = Object.values(SUPPORTEDCHAINIDSMAP).reduce((prev, curr) =>
|
|
|
111
136
|
};
|
|
112
137
|
}, {});
|
|
113
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));
|
|
114
150
|
|
|
115
151
|
// src/classes/Contract.ts
|
|
116
152
|
var import_ethers = require("ethers");
|
|
@@ -138,14 +174,7 @@ var Contract = class {
|
|
|
138
174
|
}
|
|
139
175
|
this.address = address;
|
|
140
176
|
this.provider = provider;
|
|
141
|
-
|
|
142
|
-
if (provider instanceof import_ethers.ethers.providers.JsonRpcProvider) {
|
|
143
|
-
formatProvider = provider;
|
|
144
|
-
} else {
|
|
145
|
-
const web3Provider = new import_ethers.ethers.providers.Web3Provider(provider);
|
|
146
|
-
formatProvider = web3Provider.getSigner();
|
|
147
|
-
}
|
|
148
|
-
this.contractInstance = new import_ethers.ethers.Contract(this.address, abiJson, formatProvider);
|
|
177
|
+
this.contractInstance = new import_ethers.ethers.Contract(this.address, abiJson, this.provider);
|
|
149
178
|
}
|
|
150
179
|
// Example method to read from the contract
|
|
151
180
|
async callMethod(functionName, functionParams) {
|
|
@@ -188,11 +217,21 @@ var Contract = class {
|
|
|
188
217
|
if (isNoPendingWithdrawals) {
|
|
189
218
|
return reject("no pending withdrawals");
|
|
190
219
|
}
|
|
191
|
-
const insufficientBalanceErrStrArr = ["insufficient balance", "
|
|
220
|
+
const insufficientBalanceErrStrArr = ["insufficient balance", "INSUFFICIENT_FUNDS"];
|
|
192
221
|
const isInsufficientBalance = hasErrorFlagFn(curErrorStrArr, insufficientBalanceErrStrArr);
|
|
193
222
|
if (isInsufficientBalance) {
|
|
194
223
|
return reject("insufficient balance");
|
|
195
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
|
+
}
|
|
196
235
|
return reject(error);
|
|
197
236
|
}
|
|
198
237
|
});
|
|
@@ -200,1432 +239,2370 @@ var Contract = class {
|
|
|
200
239
|
};
|
|
201
240
|
var Contract_default = Contract;
|
|
202
241
|
|
|
203
|
-
// src/
|
|
204
|
-
var
|
|
242
|
+
// src/classes/Erc20Contract.ts
|
|
243
|
+
var import_ethers2 = require("ethers");
|
|
244
|
+
|
|
245
|
+
// src/config/erc20Abi.json
|
|
246
|
+
var erc20Abi_default = [
|
|
205
247
|
{
|
|
206
248
|
type: "function",
|
|
207
|
-
name: "
|
|
249
|
+
name: "allowance",
|
|
208
250
|
inputs: [
|
|
209
|
-
{
|
|
210
|
-
|
|
211
|
-
|
|
251
|
+
{
|
|
252
|
+
name: "owner",
|
|
253
|
+
type: "address",
|
|
254
|
+
internalType: "address"
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
name: "spender",
|
|
258
|
+
type: "address",
|
|
259
|
+
internalType: "address"
|
|
260
|
+
}
|
|
212
261
|
],
|
|
213
|
-
outputs: [
|
|
214
|
-
|
|
262
|
+
outputs: [
|
|
263
|
+
{
|
|
264
|
+
name: "",
|
|
265
|
+
type: "uint256",
|
|
266
|
+
internalType: "uint256"
|
|
267
|
+
}
|
|
268
|
+
],
|
|
269
|
+
stateMutability: "view"
|
|
215
270
|
},
|
|
216
271
|
{
|
|
217
272
|
type: "function",
|
|
218
|
-
name: "
|
|
273
|
+
name: "approve",
|
|
219
274
|
inputs: [
|
|
220
|
-
{ name: "idSources", type: "string[]", internalType: "string[]" },
|
|
221
275
|
{
|
|
222
|
-
name: "
|
|
223
|
-
type: "
|
|
224
|
-
internalType: "
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
internalType: "struct AttNetworkRequest",
|
|
231
|
-
components: [
|
|
232
|
-
{ name: "url", type: "string", internalType: "string" },
|
|
233
|
-
{ name: "header", type: "string", internalType: "string" },
|
|
234
|
-
{ name: "method", type: "string", internalType: "string" },
|
|
235
|
-
{ name: "body", type: "string", internalType: "string" }
|
|
236
|
-
]
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
name: "reponseResolve",
|
|
240
|
-
type: "tuple[]",
|
|
241
|
-
internalType: "struct AttNetworkResponseResolve[]",
|
|
242
|
-
components: [
|
|
243
|
-
{ name: "keyName", type: "string", internalType: "string" },
|
|
244
|
-
{
|
|
245
|
-
name: "parseType",
|
|
246
|
-
type: "string",
|
|
247
|
-
internalType: "string"
|
|
248
|
-
},
|
|
249
|
-
{
|
|
250
|
-
name: "parsePath",
|
|
251
|
-
type: "string",
|
|
252
|
-
internalType: "string"
|
|
253
|
-
}
|
|
254
|
-
]
|
|
255
|
-
},
|
|
256
|
-
{ name: "data", type: "string", internalType: "string" },
|
|
257
|
-
{
|
|
258
|
-
name: "attConditions",
|
|
259
|
-
type: "string",
|
|
260
|
-
internalType: "string"
|
|
261
|
-
},
|
|
262
|
-
{ name: "timestamp", type: "uint64", internalType: "uint64" },
|
|
263
|
-
{
|
|
264
|
-
name: "additionParams",
|
|
265
|
-
type: "string",
|
|
266
|
-
internalType: "string"
|
|
267
|
-
},
|
|
268
|
-
{
|
|
269
|
-
name: "attestors",
|
|
270
|
-
type: "tuple[]",
|
|
271
|
-
internalType: "struct Attestor[]",
|
|
272
|
-
components: [
|
|
273
|
-
{
|
|
274
|
-
name: "attestorAddr",
|
|
275
|
-
type: "address",
|
|
276
|
-
internalType: "address"
|
|
277
|
-
},
|
|
278
|
-
{ name: "url", type: "string", internalType: "string" }
|
|
279
|
-
]
|
|
280
|
-
},
|
|
281
|
-
{ name: "signatures", type: "bytes[]", internalType: "bytes[]" }
|
|
282
|
-
]
|
|
276
|
+
name: "spender",
|
|
277
|
+
type: "address",
|
|
278
|
+
internalType: "address"
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
name: "value",
|
|
282
|
+
type: "uint256",
|
|
283
|
+
internalType: "uint256"
|
|
283
284
|
}
|
|
284
285
|
],
|
|
285
|
-
outputs: [
|
|
286
|
-
|
|
286
|
+
outputs: [
|
|
287
|
+
{
|
|
288
|
+
name: "",
|
|
289
|
+
type: "bool",
|
|
290
|
+
internalType: "bool"
|
|
291
|
+
}
|
|
292
|
+
],
|
|
293
|
+
stateMutability: "nonpayable"
|
|
287
294
|
},
|
|
288
295
|
{
|
|
289
296
|
type: "function",
|
|
290
|
-
name: "
|
|
297
|
+
name: "balanceOf",
|
|
291
298
|
inputs: [
|
|
292
|
-
{ name: "idSource", type: "string", internalType: "string" },
|
|
293
299
|
{
|
|
294
|
-
name: "
|
|
295
|
-
type: "
|
|
296
|
-
internalType: "
|
|
297
|
-
components: [
|
|
298
|
-
{ name: "recipient", type: "address", internalType: "address" },
|
|
299
|
-
{
|
|
300
|
-
name: "request",
|
|
301
|
-
type: "tuple",
|
|
302
|
-
internalType: "struct AttNetworkRequest",
|
|
303
|
-
components: [
|
|
304
|
-
{ name: "url", type: "string", internalType: "string" },
|
|
305
|
-
{ name: "header", type: "string", internalType: "string" },
|
|
306
|
-
{ name: "method", type: "string", internalType: "string" },
|
|
307
|
-
{ name: "body", type: "string", internalType: "string" }
|
|
308
|
-
]
|
|
309
|
-
},
|
|
310
|
-
{
|
|
311
|
-
name: "reponseResolve",
|
|
312
|
-
type: "tuple[]",
|
|
313
|
-
internalType: "struct AttNetworkResponseResolve[]",
|
|
314
|
-
components: [
|
|
315
|
-
{ name: "keyName", type: "string", internalType: "string" },
|
|
316
|
-
{
|
|
317
|
-
name: "parseType",
|
|
318
|
-
type: "string",
|
|
319
|
-
internalType: "string"
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
name: "parsePath",
|
|
323
|
-
type: "string",
|
|
324
|
-
internalType: "string"
|
|
325
|
-
}
|
|
326
|
-
]
|
|
327
|
-
},
|
|
328
|
-
{ name: "data", type: "string", internalType: "string" },
|
|
329
|
-
{
|
|
330
|
-
name: "attConditions",
|
|
331
|
-
type: "string",
|
|
332
|
-
internalType: "string"
|
|
333
|
-
},
|
|
334
|
-
{ name: "timestamp", type: "uint64", internalType: "uint64" },
|
|
335
|
-
{
|
|
336
|
-
name: "additionParams",
|
|
337
|
-
type: "string",
|
|
338
|
-
internalType: "string"
|
|
339
|
-
},
|
|
340
|
-
{
|
|
341
|
-
name: "attestors",
|
|
342
|
-
type: "tuple[]",
|
|
343
|
-
internalType: "struct Attestor[]",
|
|
344
|
-
components: [
|
|
345
|
-
{
|
|
346
|
-
name: "attestorAddr",
|
|
347
|
-
type: "address",
|
|
348
|
-
internalType: "address"
|
|
349
|
-
},
|
|
350
|
-
{ name: "url", type: "string", internalType: "string" }
|
|
351
|
-
]
|
|
352
|
-
},
|
|
353
|
-
{ name: "signatures", type: "bytes[]", internalType: "bytes[]" }
|
|
354
|
-
]
|
|
300
|
+
name: "account",
|
|
301
|
+
type: "address",
|
|
302
|
+
internalType: "address"
|
|
355
303
|
}
|
|
356
304
|
],
|
|
357
|
-
outputs: [
|
|
358
|
-
|
|
305
|
+
outputs: [
|
|
306
|
+
{
|
|
307
|
+
name: "",
|
|
308
|
+
type: "uint256",
|
|
309
|
+
internalType: "uint256"
|
|
310
|
+
}
|
|
311
|
+
],
|
|
312
|
+
stateMutability: "view"
|
|
359
313
|
},
|
|
360
314
|
{
|
|
361
315
|
type: "function",
|
|
362
|
-
name: "
|
|
363
|
-
inputs: [
|
|
364
|
-
|
|
316
|
+
name: "decimals",
|
|
317
|
+
inputs: [],
|
|
318
|
+
outputs: [
|
|
365
319
|
{
|
|
366
|
-
name: "
|
|
367
|
-
type: "
|
|
368
|
-
internalType: "
|
|
369
|
-
|
|
370
|
-
{ name: "recipient", type: "address", internalType: "address" },
|
|
371
|
-
{
|
|
372
|
-
name: "request",
|
|
373
|
-
type: "tuple",
|
|
374
|
-
internalType: "struct AttNetworkRequest",
|
|
375
|
-
components: [
|
|
376
|
-
{ name: "url", type: "string", internalType: "string" },
|
|
377
|
-
{ name: "header", type: "string", internalType: "string" },
|
|
378
|
-
{ name: "method", type: "string", internalType: "string" },
|
|
379
|
-
{ name: "body", type: "string", internalType: "string" }
|
|
380
|
-
]
|
|
381
|
-
},
|
|
382
|
-
{
|
|
383
|
-
name: "reponseResolve",
|
|
384
|
-
type: "tuple[]",
|
|
385
|
-
internalType: "struct AttNetworkResponseResolve[]",
|
|
386
|
-
components: [
|
|
387
|
-
{ name: "keyName", type: "string", internalType: "string" },
|
|
388
|
-
{
|
|
389
|
-
name: "parseType",
|
|
390
|
-
type: "string",
|
|
391
|
-
internalType: "string"
|
|
392
|
-
},
|
|
393
|
-
{
|
|
394
|
-
name: "parsePath",
|
|
395
|
-
type: "string",
|
|
396
|
-
internalType: "string"
|
|
397
|
-
}
|
|
398
|
-
]
|
|
399
|
-
},
|
|
400
|
-
{ name: "data", type: "string", internalType: "string" },
|
|
401
|
-
{
|
|
402
|
-
name: "attConditions",
|
|
403
|
-
type: "string",
|
|
404
|
-
internalType: "string"
|
|
405
|
-
},
|
|
406
|
-
{ name: "timestamp", type: "uint64", internalType: "uint64" },
|
|
407
|
-
{
|
|
408
|
-
name: "additionParams",
|
|
409
|
-
type: "string",
|
|
410
|
-
internalType: "string"
|
|
411
|
-
},
|
|
412
|
-
{
|
|
413
|
-
name: "attestors",
|
|
414
|
-
type: "tuple[]",
|
|
415
|
-
internalType: "struct Attestor[]",
|
|
416
|
-
components: [
|
|
417
|
-
{
|
|
418
|
-
name: "attestorAddr",
|
|
419
|
-
type: "address",
|
|
420
|
-
internalType: "address"
|
|
421
|
-
},
|
|
422
|
-
{ name: "url", type: "string", internalType: "string" }
|
|
423
|
-
]
|
|
424
|
-
},
|
|
425
|
-
{ name: "signatures", type: "bytes[]", internalType: "bytes[]" }
|
|
426
|
-
]
|
|
427
|
-
},
|
|
428
|
-
{ name: "index", type: "uint32", internalType: "uint32" }
|
|
320
|
+
name: "",
|
|
321
|
+
type: "uint8",
|
|
322
|
+
internalType: "uint8"
|
|
323
|
+
}
|
|
429
324
|
],
|
|
430
|
-
outputs: [],
|
|
431
|
-
stateMutability: "payable"
|
|
432
|
-
},
|
|
433
|
-
{
|
|
434
|
-
type: "function",
|
|
435
|
-
name: "claimFee",
|
|
436
|
-
inputs: [],
|
|
437
|
-
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
438
325
|
stateMutability: "view"
|
|
439
326
|
},
|
|
440
327
|
{
|
|
441
328
|
type: "function",
|
|
442
|
-
name: "
|
|
329
|
+
name: "name",
|
|
443
330
|
inputs: [],
|
|
444
|
-
outputs: [
|
|
331
|
+
outputs: [
|
|
332
|
+
{
|
|
333
|
+
name: "",
|
|
334
|
+
type: "string",
|
|
335
|
+
internalType: "string"
|
|
336
|
+
}
|
|
337
|
+
],
|
|
445
338
|
stateMutability: "view"
|
|
446
339
|
},
|
|
447
340
|
{
|
|
448
341
|
type: "function",
|
|
449
|
-
name: "
|
|
450
|
-
inputs: [
|
|
451
|
-
{
|
|
452
|
-
name: "tipRecipient",
|
|
453
|
-
type: "tuple",
|
|
454
|
-
internalType: "struct TipRecipient",
|
|
455
|
-
components: [
|
|
456
|
-
{ name: "idSource", type: "string", internalType: "string" },
|
|
457
|
-
{ name: "id", type: "string", internalType: "string" }
|
|
458
|
-
]
|
|
459
|
-
}
|
|
460
|
-
],
|
|
342
|
+
name: "symbol",
|
|
343
|
+
inputs: [],
|
|
461
344
|
outputs: [
|
|
462
345
|
{
|
|
463
346
|
name: "",
|
|
464
|
-
type: "
|
|
465
|
-
internalType: "
|
|
466
|
-
components: [
|
|
467
|
-
{ name: "amount", type: "uint256", internalType: "uint256" },
|
|
468
|
-
{
|
|
469
|
-
name: "tipToken",
|
|
470
|
-
type: "tuple",
|
|
471
|
-
internalType: "struct TipToken",
|
|
472
|
-
components: [
|
|
473
|
-
{
|
|
474
|
-
name: "tokenType",
|
|
475
|
-
type: "uint32",
|
|
476
|
-
internalType: "uint32"
|
|
477
|
-
},
|
|
478
|
-
{
|
|
479
|
-
name: "tokenAddress",
|
|
480
|
-
type: "address",
|
|
481
|
-
internalType: "address"
|
|
482
|
-
}
|
|
483
|
-
]
|
|
484
|
-
},
|
|
485
|
-
{ name: "timestamp", type: "uint64", internalType: "uint64" },
|
|
486
|
-
{ name: "tipper", type: "address", internalType: "address" },
|
|
487
|
-
{ name: "nftIds", type: "uint256[]", internalType: "uint256[]" }
|
|
488
|
-
]
|
|
347
|
+
type: "string",
|
|
348
|
+
internalType: "string"
|
|
489
349
|
}
|
|
490
350
|
],
|
|
491
351
|
stateMutability: "view"
|
|
492
352
|
},
|
|
493
353
|
{
|
|
494
354
|
type: "function",
|
|
495
|
-
name: "
|
|
496
|
-
inputs: [
|
|
355
|
+
name: "totalSupply",
|
|
356
|
+
inputs: [],
|
|
497
357
|
outputs: [
|
|
498
|
-
{
|
|
499
|
-
|
|
358
|
+
{
|
|
359
|
+
name: "",
|
|
360
|
+
type: "uint256",
|
|
361
|
+
internalType: "uint256"
|
|
362
|
+
}
|
|
500
363
|
],
|
|
501
364
|
stateMutability: "view"
|
|
502
365
|
},
|
|
503
366
|
{
|
|
504
367
|
type: "function",
|
|
505
|
-
name: "
|
|
368
|
+
name: "transfer",
|
|
506
369
|
inputs: [
|
|
507
|
-
{ name: "owner", type: "address", internalType: "address" },
|
|
508
370
|
{
|
|
509
|
-
name: "
|
|
371
|
+
name: "to",
|
|
510
372
|
type: "address",
|
|
511
|
-
internalType: "
|
|
373
|
+
internalType: "address"
|
|
512
374
|
},
|
|
513
|
-
{
|
|
514
|
-
|
|
375
|
+
{
|
|
376
|
+
name: "value",
|
|
377
|
+
type: "uint256",
|
|
378
|
+
internalType: "uint256"
|
|
379
|
+
}
|
|
515
380
|
],
|
|
516
|
-
outputs: [],
|
|
517
|
-
stateMutability: "nonpayable"
|
|
518
|
-
},
|
|
519
|
-
{
|
|
520
|
-
type: "function",
|
|
521
|
-
name: "owner",
|
|
522
|
-
inputs: [],
|
|
523
|
-
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
524
|
-
stateMutability: "view"
|
|
525
|
-
},
|
|
526
|
-
{
|
|
527
|
-
type: "function",
|
|
528
|
-
name: "primusZKTLS",
|
|
529
|
-
inputs: [],
|
|
530
381
|
outputs: [
|
|
531
|
-
{
|
|
382
|
+
{
|
|
383
|
+
name: "",
|
|
384
|
+
type: "bool",
|
|
385
|
+
internalType: "bool"
|
|
386
|
+
}
|
|
532
387
|
],
|
|
533
|
-
stateMutability: "view"
|
|
534
|
-
},
|
|
535
|
-
{
|
|
536
|
-
type: "function",
|
|
537
|
-
name: "renounceOwnership",
|
|
538
|
-
inputs: [],
|
|
539
|
-
outputs: [],
|
|
540
388
|
stateMutability: "nonpayable"
|
|
541
389
|
},
|
|
542
390
|
{
|
|
543
391
|
type: "function",
|
|
544
|
-
name: "
|
|
392
|
+
name: "transferFrom",
|
|
545
393
|
inputs: [
|
|
546
|
-
{
|
|
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
|
+
}
|
|
547
409
|
],
|
|
548
|
-
outputs: [
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
inputs: [
|
|
555
|
-
{ name: "feeRecipient_", type: "address", internalType: "address" }
|
|
410
|
+
outputs: [
|
|
411
|
+
{
|
|
412
|
+
name: "",
|
|
413
|
+
type: "bool",
|
|
414
|
+
internalType: "bool"
|
|
415
|
+
}
|
|
556
416
|
],
|
|
557
|
-
outputs: [],
|
|
558
417
|
stateMutability: "nonpayable"
|
|
559
418
|
},
|
|
560
419
|
{
|
|
561
|
-
type: "
|
|
562
|
-
name: "
|
|
420
|
+
type: "event",
|
|
421
|
+
name: "Approval",
|
|
563
422
|
inputs: [
|
|
564
423
|
{
|
|
565
|
-
name: "
|
|
424
|
+
name: "owner",
|
|
566
425
|
type: "address",
|
|
567
|
-
|
|
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"
|
|
568
440
|
}
|
|
569
441
|
],
|
|
570
|
-
|
|
571
|
-
stateMutability: "nonpayable"
|
|
572
|
-
},
|
|
573
|
-
{
|
|
574
|
-
type: "function",
|
|
575
|
-
name: "setWithdrawDelay",
|
|
576
|
-
inputs: [
|
|
577
|
-
{ name: "delay", type: "uint256", internalType: "uint256" }
|
|
578
|
-
],
|
|
579
|
-
outputs: [],
|
|
580
|
-
stateMutability: "nonpayable"
|
|
442
|
+
anonymous: false
|
|
581
443
|
},
|
|
582
444
|
{
|
|
583
|
-
type: "
|
|
584
|
-
name: "
|
|
445
|
+
type: "event",
|
|
446
|
+
name: "Transfer",
|
|
585
447
|
inputs: [
|
|
586
448
|
{
|
|
587
|
-
name: "
|
|
588
|
-
type: "
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
{ name: "tokenType", type: "uint32", internalType: "uint32" },
|
|
592
|
-
{
|
|
593
|
-
name: "tokenAddress",
|
|
594
|
-
type: "address",
|
|
595
|
-
internalType: "address"
|
|
596
|
-
}
|
|
597
|
-
]
|
|
449
|
+
name: "from",
|
|
450
|
+
type: "address",
|
|
451
|
+
indexed: true,
|
|
452
|
+
internalType: "address"
|
|
598
453
|
},
|
|
599
454
|
{
|
|
600
|
-
name: "
|
|
601
|
-
type: "
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
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"
|
|
609
465
|
}
|
|
610
466
|
],
|
|
611
|
-
|
|
612
|
-
stateMutability: "payable"
|
|
467
|
+
anonymous: false
|
|
613
468
|
},
|
|
614
469
|
{
|
|
615
|
-
type: "
|
|
616
|
-
name: "
|
|
470
|
+
type: "error",
|
|
471
|
+
name: "ERC20InsufficientAllowance",
|
|
617
472
|
inputs: [
|
|
618
473
|
{
|
|
619
|
-
name: "
|
|
620
|
-
type: "
|
|
621
|
-
internalType: "
|
|
622
|
-
components: [
|
|
623
|
-
{ name: "tokenType", type: "uint32", internalType: "uint32" },
|
|
624
|
-
{
|
|
625
|
-
name: "tokenAddress",
|
|
626
|
-
type: "address",
|
|
627
|
-
internalType: "address"
|
|
628
|
-
}
|
|
629
|
-
]
|
|
474
|
+
name: "spender",
|
|
475
|
+
type: "address",
|
|
476
|
+
internalType: "address"
|
|
630
477
|
},
|
|
631
478
|
{
|
|
632
|
-
name: "
|
|
633
|
-
type: "
|
|
634
|
-
internalType: "
|
|
635
|
-
|
|
636
|
-
{ name: "idSource", type: "string", internalType: "string" },
|
|
637
|
-
{ name: "id", type: "string", internalType: "string" },
|
|
638
|
-
{ name: "amount", type: "uint256", internalType: "uint256" },
|
|
639
|
-
{ name: "nftIds", type: "uint256[]", internalType: "uint256[]" }
|
|
640
|
-
]
|
|
641
|
-
}
|
|
642
|
-
],
|
|
643
|
-
outputs: [],
|
|
644
|
-
stateMutability: "payable"
|
|
645
|
-
},
|
|
646
|
-
{
|
|
647
|
-
type: "function",
|
|
648
|
-
name: "tipperWithdraw",
|
|
649
|
-
inputs: [
|
|
479
|
+
name: "allowance",
|
|
480
|
+
type: "uint256",
|
|
481
|
+
internalType: "uint256"
|
|
482
|
+
},
|
|
650
483
|
{
|
|
651
|
-
name: "
|
|
652
|
-
type: "
|
|
653
|
-
internalType: "
|
|
654
|
-
components: [
|
|
655
|
-
{ name: "idSource", type: "string", internalType: "string" },
|
|
656
|
-
{ name: "id", type: "string", internalType: "string" },
|
|
657
|
-
{ name: "tipTimestamp", type: "uint64", internalType: "uint64" }
|
|
658
|
-
]
|
|
484
|
+
name: "needed",
|
|
485
|
+
type: "uint256",
|
|
486
|
+
internalType: "uint256"
|
|
659
487
|
}
|
|
660
|
-
]
|
|
661
|
-
outputs: [],
|
|
662
|
-
stateMutability: "nonpayable"
|
|
663
|
-
},
|
|
664
|
-
{
|
|
665
|
-
type: "function",
|
|
666
|
-
name: "transferOwnership",
|
|
667
|
-
inputs: [
|
|
668
|
-
{ name: "newOwner", type: "address", internalType: "address" }
|
|
669
|
-
],
|
|
670
|
-
outputs: [],
|
|
671
|
-
stateMutability: "nonpayable"
|
|
672
|
-
},
|
|
673
|
-
{
|
|
674
|
-
type: "function",
|
|
675
|
-
name: "withdrawDelay",
|
|
676
|
-
inputs: [],
|
|
677
|
-
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
678
|
-
stateMutability: "view"
|
|
488
|
+
]
|
|
679
489
|
},
|
|
680
490
|
{
|
|
681
|
-
type: "
|
|
682
|
-
name: "
|
|
491
|
+
type: "error",
|
|
492
|
+
name: "ERC20InsufficientBalance",
|
|
683
493
|
inputs: [
|
|
684
494
|
{
|
|
685
|
-
name: "
|
|
686
|
-
type: "address",
|
|
687
|
-
indexed: true,
|
|
688
|
-
internalType: "address"
|
|
689
|
-
},
|
|
690
|
-
{
|
|
691
|
-
name: "claimTime",
|
|
692
|
-
type: "uint64",
|
|
693
|
-
indexed: false,
|
|
694
|
-
internalType: "uint64"
|
|
695
|
-
},
|
|
696
|
-
{
|
|
697
|
-
name: "idSource",
|
|
698
|
-
type: "string",
|
|
699
|
-
indexed: false,
|
|
700
|
-
internalType: "string"
|
|
701
|
-
},
|
|
702
|
-
{
|
|
703
|
-
name: "id",
|
|
704
|
-
type: "string",
|
|
705
|
-
indexed: false,
|
|
706
|
-
internalType: "string"
|
|
707
|
-
},
|
|
708
|
-
{
|
|
709
|
-
name: "tipper",
|
|
710
|
-
type: "address",
|
|
711
|
-
indexed: false,
|
|
712
|
-
internalType: "address"
|
|
713
|
-
},
|
|
714
|
-
{
|
|
715
|
-
name: "tokenAddr",
|
|
495
|
+
name: "sender",
|
|
716
496
|
type: "address",
|
|
717
|
-
indexed: false,
|
|
718
497
|
internalType: "address"
|
|
719
498
|
},
|
|
720
499
|
{
|
|
721
|
-
name: "
|
|
500
|
+
name: "balance",
|
|
722
501
|
type: "uint256",
|
|
723
|
-
indexed: false,
|
|
724
502
|
internalType: "uint256"
|
|
725
503
|
},
|
|
726
504
|
{
|
|
727
|
-
name: "
|
|
728
|
-
type: "
|
|
729
|
-
|
|
730
|
-
internalType: "uint64"
|
|
731
|
-
}
|
|
732
|
-
],
|
|
733
|
-
anonymous: false
|
|
734
|
-
},
|
|
735
|
-
{
|
|
736
|
-
type: "event",
|
|
737
|
-
name: "Initialized",
|
|
738
|
-
inputs: [
|
|
739
|
-
{
|
|
740
|
-
name: "version",
|
|
741
|
-
type: "uint64",
|
|
742
|
-
indexed: false,
|
|
743
|
-
internalType: "uint64"
|
|
505
|
+
name: "needed",
|
|
506
|
+
type: "uint256",
|
|
507
|
+
internalType: "uint256"
|
|
744
508
|
}
|
|
745
|
-
]
|
|
746
|
-
anonymous: false
|
|
509
|
+
]
|
|
747
510
|
},
|
|
748
511
|
{
|
|
749
|
-
type: "
|
|
750
|
-
name: "
|
|
512
|
+
type: "error",
|
|
513
|
+
name: "ERC20InvalidApprover",
|
|
751
514
|
inputs: [
|
|
752
515
|
{
|
|
753
|
-
name: "
|
|
754
|
-
type: "address",
|
|
755
|
-
indexed: true,
|
|
756
|
-
internalType: "address"
|
|
757
|
-
},
|
|
758
|
-
{
|
|
759
|
-
name: "newOwner",
|
|
516
|
+
name: "approver",
|
|
760
517
|
type: "address",
|
|
761
|
-
indexed: true,
|
|
762
518
|
internalType: "address"
|
|
763
519
|
}
|
|
764
|
-
]
|
|
765
|
-
anonymous: false
|
|
520
|
+
]
|
|
766
521
|
},
|
|
767
522
|
{
|
|
768
|
-
type: "
|
|
769
|
-
name: "
|
|
523
|
+
type: "error",
|
|
524
|
+
name: "ERC20InvalidReceiver",
|
|
770
525
|
inputs: [
|
|
771
526
|
{
|
|
772
|
-
name: "
|
|
773
|
-
type: "string",
|
|
774
|
-
indexed: false,
|
|
775
|
-
internalType: "string"
|
|
776
|
-
},
|
|
777
|
-
{
|
|
778
|
-
name: "id",
|
|
779
|
-
type: "string",
|
|
780
|
-
indexed: false,
|
|
781
|
-
internalType: "string"
|
|
782
|
-
},
|
|
783
|
-
{
|
|
784
|
-
name: "tipper",
|
|
785
|
-
type: "address",
|
|
786
|
-
indexed: false,
|
|
787
|
-
internalType: "address"
|
|
788
|
-
},
|
|
789
|
-
{
|
|
790
|
-
name: "tokenAddr",
|
|
527
|
+
name: "receiver",
|
|
791
528
|
type: "address",
|
|
792
|
-
indexed: false,
|
|
793
529
|
internalType: "address"
|
|
794
|
-
},
|
|
795
|
-
{
|
|
796
|
-
name: "amount",
|
|
797
|
-
type: "uint256",
|
|
798
|
-
indexed: false,
|
|
799
|
-
internalType: "uint256"
|
|
800
|
-
},
|
|
801
|
-
{
|
|
802
|
-
name: "tipTime",
|
|
803
|
-
type: "uint64",
|
|
804
|
-
indexed: false,
|
|
805
|
-
internalType: "uint64"
|
|
806
530
|
}
|
|
807
|
-
]
|
|
808
|
-
anonymous: false
|
|
531
|
+
]
|
|
809
532
|
},
|
|
810
533
|
{
|
|
811
|
-
type: "
|
|
812
|
-
name: "
|
|
534
|
+
type: "error",
|
|
535
|
+
name: "ERC20InvalidSender",
|
|
813
536
|
inputs: [
|
|
814
537
|
{
|
|
815
|
-
name: "
|
|
816
|
-
type: "uint64",
|
|
817
|
-
indexed: false,
|
|
818
|
-
internalType: "uint64"
|
|
819
|
-
},
|
|
820
|
-
{
|
|
821
|
-
name: "idSource",
|
|
822
|
-
type: "string",
|
|
823
|
-
indexed: false,
|
|
824
|
-
internalType: "string"
|
|
825
|
-
},
|
|
826
|
-
{
|
|
827
|
-
name: "id",
|
|
828
|
-
type: "string",
|
|
829
|
-
indexed: false,
|
|
830
|
-
internalType: "string"
|
|
831
|
-
},
|
|
832
|
-
{
|
|
833
|
-
name: "tipper",
|
|
834
|
-
type: "address",
|
|
835
|
-
indexed: false,
|
|
836
|
-
internalType: "address"
|
|
837
|
-
},
|
|
838
|
-
{
|
|
839
|
-
name: "tokenAddr",
|
|
538
|
+
name: "sender",
|
|
840
539
|
type: "address",
|
|
841
|
-
indexed: false,
|
|
842
540
|
internalType: "address"
|
|
843
|
-
},
|
|
844
|
-
{
|
|
845
|
-
name: "amount",
|
|
846
|
-
type: "uint256",
|
|
847
|
-
indexed: false,
|
|
848
|
-
internalType: "uint256"
|
|
849
|
-
},
|
|
850
|
-
{
|
|
851
|
-
name: "tipTime",
|
|
852
|
-
type: "uint64",
|
|
853
|
-
indexed: false,
|
|
854
|
-
internalType: "uint64"
|
|
855
541
|
}
|
|
856
|
-
],
|
|
857
|
-
anonymous: false
|
|
858
|
-
},
|
|
859
|
-
{ type: "error", name: "InvalidInitialization", inputs: [] },
|
|
860
|
-
{ type: "error", name: "NotInitializing", inputs: [] },
|
|
861
|
-
{
|
|
862
|
-
type: "error",
|
|
863
|
-
name: "OwnableInvalidOwner",
|
|
864
|
-
inputs: [
|
|
865
|
-
{ name: "owner", type: "address", internalType: "address" }
|
|
866
542
|
]
|
|
867
543
|
},
|
|
868
544
|
{
|
|
869
545
|
type: "error",
|
|
870
|
-
name: "
|
|
871
|
-
inputs: [
|
|
872
|
-
{ name: "account", type: "address", internalType: "address" }
|
|
873
|
-
]
|
|
874
|
-
},
|
|
875
|
-
{ type: "error", name: "ReentrancyGuardReentrantCall", inputs: [] }
|
|
876
|
-
];
|
|
877
|
-
|
|
878
|
-
// src/config/erc20Abi.json
|
|
879
|
-
var erc20Abi_default = [
|
|
880
|
-
{
|
|
881
|
-
type: "function",
|
|
882
|
-
name: "allowance",
|
|
546
|
+
name: "ERC20InvalidSpender",
|
|
883
547
|
inputs: [
|
|
884
|
-
{
|
|
885
|
-
name: "owner",
|
|
886
|
-
type: "address",
|
|
887
|
-
internalType: "address"
|
|
888
|
-
},
|
|
889
548
|
{
|
|
890
549
|
name: "spender",
|
|
891
550
|
type: "address",
|
|
892
551
|
internalType: "address"
|
|
893
552
|
}
|
|
894
|
-
]
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
553
|
+
]
|
|
554
|
+
}
|
|
555
|
+
];
|
|
556
|
+
|
|
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,
|
|
899
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
|
+
]
|
|
900
1898
|
}
|
|
901
1899
|
],
|
|
902
1900
|
stateMutability: "view"
|
|
903
1901
|
},
|
|
904
1902
|
{
|
|
905
1903
|
type: "function",
|
|
906
|
-
name: "
|
|
1904
|
+
name: "idCounter",
|
|
1905
|
+
inputs: [],
|
|
1906
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
1907
|
+
stateMutability: "view"
|
|
1908
|
+
},
|
|
1909
|
+
{
|
|
1910
|
+
type: "function",
|
|
1911
|
+
name: "initialize",
|
|
907
1912
|
inputs: [
|
|
1913
|
+
{ name: "owner", type: "address", internalType: "address" },
|
|
908
1914
|
{
|
|
909
|
-
name: "
|
|
1915
|
+
name: "primusZKTLS_",
|
|
910
1916
|
type: "address",
|
|
911
|
-
internalType: "
|
|
1917
|
+
internalType: "contract IPrimusZKTLS"
|
|
912
1918
|
},
|
|
913
|
-
{
|
|
914
|
-
|
|
915
|
-
type: "uint256",
|
|
916
|
-
internalType: "uint256"
|
|
917
|
-
}
|
|
1919
|
+
{ name: "feeRecipient_", type: "address", internalType: "address" },
|
|
1920
|
+
{ name: "claimFee_", type: "uint256", internalType: "uint256" }
|
|
918
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: [],
|
|
919
1936
|
outputs: [
|
|
920
|
-
{
|
|
921
|
-
name: "",
|
|
922
|
-
type: "bool",
|
|
923
|
-
internalType: "bool"
|
|
924
|
-
}
|
|
1937
|
+
{ name: "", type: "address", internalType: "contract IPrimusZKTLS" }
|
|
925
1938
|
],
|
|
926
|
-
stateMutability: "
|
|
1939
|
+
stateMutability: "view"
|
|
927
1940
|
},
|
|
928
1941
|
{
|
|
929
1942
|
type: "function",
|
|
930
|
-
name: "
|
|
1943
|
+
name: "reCheckClaim",
|
|
931
1944
|
inputs: [
|
|
932
1945
|
{
|
|
933
|
-
name: "
|
|
934
|
-
type: "
|
|
935
|
-
internalType: "
|
|
936
|
-
|
|
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
|
+
]
|
|
2007
|
+
},
|
|
2008
|
+
{ name: "checkParams", type: "bytes", internalType: "bytes" }
|
|
937
2009
|
],
|
|
938
2010
|
outputs: [
|
|
939
|
-
{
|
|
940
|
-
|
|
941
|
-
type: "uint256",
|
|
942
|
-
internalType: "uint256"
|
|
943
|
-
}
|
|
2011
|
+
{ name: "", type: "string", internalType: "string" },
|
|
2012
|
+
{ name: "", type: "address", internalType: "address" }
|
|
944
2013
|
],
|
|
945
2014
|
stateMutability: "view"
|
|
946
2015
|
},
|
|
947
2016
|
{
|
|
948
2017
|
type: "function",
|
|
949
|
-
name: "
|
|
950
|
-
inputs: [
|
|
951
|
-
|
|
2018
|
+
name: "reClaim",
|
|
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
|
],
|
|
958
|
-
|
|
2085
|
+
outputs: [],
|
|
2086
|
+
stateMutability: "payable"
|
|
959
2087
|
},
|
|
960
2088
|
{
|
|
961
2089
|
type: "function",
|
|
962
|
-
name: "
|
|
963
|
-
inputs: [],
|
|
2090
|
+
name: "reRecords",
|
|
2091
|
+
inputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
|
|
964
2092
|
outputs: [
|
|
965
|
-
{
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
}
|
|
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",
|
|
2105
|
+
type: "uint256",
|
|
2106
|
+
internalType: "uint256"
|
|
2107
|
+
},
|
|
2108
|
+
{ name: "checkParams", type: "bytes", internalType: "bytes" }
|
|
970
2109
|
],
|
|
971
2110
|
stateMutability: "view"
|
|
972
2111
|
},
|
|
973
2112
|
{
|
|
974
2113
|
type: "function",
|
|
975
|
-
name: "
|
|
976
|
-
inputs: [
|
|
977
|
-
outputs: [
|
|
2114
|
+
name: "reSend",
|
|
2115
|
+
inputs: [
|
|
978
2116
|
{
|
|
979
|
-
name: "",
|
|
980
|
-
type: "
|
|
981
|
-
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
|
+
]
|
|
982
2144
|
}
|
|
983
2145
|
],
|
|
984
|
-
|
|
2146
|
+
outputs: [],
|
|
2147
|
+
stateMutability: "payable"
|
|
985
2148
|
},
|
|
986
2149
|
{
|
|
987
2150
|
type: "function",
|
|
988
|
-
name: "
|
|
2151
|
+
name: "reSenderWithdraw",
|
|
2152
|
+
inputs: [
|
|
2153
|
+
{ name: "reId", type: "bytes32", internalType: "bytes32" }
|
|
2154
|
+
],
|
|
2155
|
+
outputs: [],
|
|
2156
|
+
stateMutability: "nonpayable"
|
|
2157
|
+
},
|
|
2158
|
+
{
|
|
2159
|
+
type: "function",
|
|
2160
|
+
name: "renounceOwnership",
|
|
989
2161
|
inputs: [],
|
|
990
|
-
outputs: [
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
2162
|
+
outputs: [],
|
|
2163
|
+
stateMutability: "nonpayable"
|
|
2164
|
+
},
|
|
2165
|
+
{
|
|
2166
|
+
type: "function",
|
|
2167
|
+
name: "setClaimFee",
|
|
2168
|
+
inputs: [
|
|
2169
|
+
{ name: "claimFee_", type: "uint256", internalType: "uint256" }
|
|
2170
|
+
],
|
|
2171
|
+
outputs: [],
|
|
2172
|
+
stateMutability: "nonpayable"
|
|
2173
|
+
},
|
|
2174
|
+
{
|
|
2175
|
+
type: "function",
|
|
2176
|
+
name: "setFeeRecipient",
|
|
2177
|
+
inputs: [
|
|
2178
|
+
{ name: "feeRecipient_", type: "address", internalType: "address" }
|
|
996
2179
|
],
|
|
997
|
-
|
|
2180
|
+
outputs: [],
|
|
2181
|
+
stateMutability: "nonpayable"
|
|
998
2182
|
},
|
|
999
2183
|
{
|
|
1000
2184
|
type: "function",
|
|
1001
|
-
name: "
|
|
2185
|
+
name: "setPrimusZKTLS",
|
|
1002
2186
|
inputs: [
|
|
1003
2187
|
{
|
|
1004
|
-
name: "
|
|
2188
|
+
name: "primusZKTLS_",
|
|
1005
2189
|
type: "address",
|
|
1006
|
-
internalType: "
|
|
1007
|
-
},
|
|
1008
|
-
{
|
|
1009
|
-
name: "value",
|
|
1010
|
-
type: "uint256",
|
|
1011
|
-
internalType: "uint256"
|
|
1012
|
-
}
|
|
1013
|
-
],
|
|
1014
|
-
outputs: [
|
|
1015
|
-
{
|
|
1016
|
-
name: "",
|
|
1017
|
-
type: "bool",
|
|
1018
|
-
internalType: "bool"
|
|
2190
|
+
internalType: "contract IPrimusZKTLS"
|
|
1019
2191
|
}
|
|
1020
2192
|
],
|
|
2193
|
+
outputs: [],
|
|
1021
2194
|
stateMutability: "nonpayable"
|
|
1022
2195
|
},
|
|
1023
2196
|
{
|
|
1024
2197
|
type: "function",
|
|
1025
|
-
name: "
|
|
2198
|
+
name: "setWithdrawDelay",
|
|
1026
2199
|
inputs: [
|
|
1027
|
-
{
|
|
1028
|
-
name: "from",
|
|
1029
|
-
type: "address",
|
|
1030
|
-
internalType: "address"
|
|
1031
|
-
},
|
|
1032
|
-
{
|
|
1033
|
-
name: "to",
|
|
1034
|
-
type: "address",
|
|
1035
|
-
internalType: "address"
|
|
1036
|
-
},
|
|
1037
|
-
{
|
|
1038
|
-
name: "value",
|
|
1039
|
-
type: "uint256",
|
|
1040
|
-
internalType: "uint256"
|
|
1041
|
-
}
|
|
2200
|
+
{ name: "delay", type: "uint256", internalType: "uint256" }
|
|
1042
2201
|
],
|
|
1043
|
-
outputs: [
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
2202
|
+
outputs: [],
|
|
2203
|
+
stateMutability: "nonpayable"
|
|
2204
|
+
},
|
|
2205
|
+
{
|
|
2206
|
+
type: "function",
|
|
2207
|
+
name: "transferOwnership",
|
|
2208
|
+
inputs: [
|
|
2209
|
+
{ name: "newOwner", type: "address", internalType: "address" }
|
|
1049
2210
|
],
|
|
2211
|
+
outputs: [],
|
|
1050
2212
|
stateMutability: "nonpayable"
|
|
1051
2213
|
},
|
|
2214
|
+
{
|
|
2215
|
+
type: "function",
|
|
2216
|
+
name: "withdrawDelay",
|
|
2217
|
+
inputs: [],
|
|
2218
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2219
|
+
stateMutability: "view"
|
|
2220
|
+
},
|
|
1052
2221
|
{
|
|
1053
2222
|
type: "event",
|
|
1054
|
-
name: "
|
|
2223
|
+
name: "Initialized",
|
|
1055
2224
|
inputs: [
|
|
1056
2225
|
{
|
|
1057
|
-
name: "
|
|
1058
|
-
type: "
|
|
1059
|
-
indexed: true,
|
|
1060
|
-
internalType: "address"
|
|
1061
|
-
},
|
|
1062
|
-
{
|
|
1063
|
-
name: "spender",
|
|
1064
|
-
type: "address",
|
|
1065
|
-
indexed: true,
|
|
1066
|
-
internalType: "address"
|
|
1067
|
-
},
|
|
1068
|
-
{
|
|
1069
|
-
name: "value",
|
|
1070
|
-
type: "uint256",
|
|
2226
|
+
name: "version",
|
|
2227
|
+
type: "uint64",
|
|
1071
2228
|
indexed: false,
|
|
1072
|
-
internalType: "
|
|
2229
|
+
internalType: "uint64"
|
|
1073
2230
|
}
|
|
1074
2231
|
],
|
|
1075
2232
|
anonymous: false
|
|
1076
2233
|
},
|
|
1077
2234
|
{
|
|
1078
2235
|
type: "event",
|
|
1079
|
-
name: "
|
|
2236
|
+
name: "OwnershipTransferred",
|
|
1080
2237
|
inputs: [
|
|
1081
2238
|
{
|
|
1082
|
-
name: "
|
|
2239
|
+
name: "previousOwner",
|
|
1083
2240
|
type: "address",
|
|
1084
2241
|
indexed: true,
|
|
1085
2242
|
internalType: "address"
|
|
1086
2243
|
},
|
|
1087
2244
|
{
|
|
1088
|
-
name: "
|
|
2245
|
+
name: "newOwner",
|
|
1089
2246
|
type: "address",
|
|
1090
2247
|
indexed: true,
|
|
1091
2248
|
internalType: "address"
|
|
1092
|
-
},
|
|
1093
|
-
{
|
|
1094
|
-
name: "value",
|
|
1095
|
-
type: "uint256",
|
|
1096
|
-
indexed: false,
|
|
1097
|
-
internalType: "uint256"
|
|
1098
2249
|
}
|
|
1099
2250
|
],
|
|
1100
2251
|
anonymous: false
|
|
1101
2252
|
},
|
|
1102
2253
|
{
|
|
1103
|
-
type: "
|
|
1104
|
-
name: "
|
|
2254
|
+
type: "event",
|
|
2255
|
+
name: "REClaimEvent",
|
|
1105
2256
|
inputs: [
|
|
1106
2257
|
{
|
|
1107
|
-
name: "
|
|
1108
|
-
type: "
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
{
|
|
1112
|
-
name: "allowance",
|
|
1113
|
-
type: "uint256",
|
|
1114
|
-
internalType: "uint256"
|
|
2258
|
+
name: "id",
|
|
2259
|
+
type: "bytes32",
|
|
2260
|
+
indexed: true,
|
|
2261
|
+
internalType: "bytes32"
|
|
1115
2262
|
},
|
|
1116
2263
|
{
|
|
1117
|
-
name: "
|
|
1118
|
-
type: "uint256",
|
|
1119
|
-
internalType: "uint256"
|
|
1120
|
-
}
|
|
1121
|
-
]
|
|
1122
|
-
},
|
|
1123
|
-
{
|
|
1124
|
-
type: "error",
|
|
1125
|
-
name: "ERC20InsufficientBalance",
|
|
1126
|
-
inputs: [
|
|
1127
|
-
{
|
|
1128
|
-
name: "sender",
|
|
2264
|
+
name: "recipient",
|
|
1129
2265
|
type: "address",
|
|
2266
|
+
indexed: false,
|
|
1130
2267
|
internalType: "address"
|
|
1131
2268
|
},
|
|
1132
2269
|
{
|
|
1133
|
-
name: "
|
|
1134
|
-
type: "
|
|
1135
|
-
|
|
2270
|
+
name: "userId",
|
|
2271
|
+
type: "string",
|
|
2272
|
+
indexed: false,
|
|
2273
|
+
internalType: "string"
|
|
1136
2274
|
},
|
|
1137
2275
|
{
|
|
1138
|
-
name: "
|
|
2276
|
+
name: "claimAmount",
|
|
1139
2277
|
type: "uint256",
|
|
2278
|
+
indexed: false,
|
|
1140
2279
|
internalType: "uint256"
|
|
1141
|
-
}
|
|
1142
|
-
]
|
|
1143
|
-
},
|
|
1144
|
-
{
|
|
1145
|
-
type: "error",
|
|
1146
|
-
name: "ERC20InvalidApprover",
|
|
1147
|
-
inputs: [
|
|
1148
|
-
{
|
|
1149
|
-
name: "approver",
|
|
1150
|
-
type: "address",
|
|
1151
|
-
internalType: "address"
|
|
1152
|
-
}
|
|
1153
|
-
]
|
|
1154
|
-
},
|
|
1155
|
-
{
|
|
1156
|
-
type: "error",
|
|
1157
|
-
name: "ERC20InvalidReceiver",
|
|
1158
|
-
inputs: [
|
|
1159
|
-
{
|
|
1160
|
-
name: "receiver",
|
|
1161
|
-
type: "address",
|
|
1162
|
-
internalType: "address"
|
|
1163
|
-
}
|
|
1164
|
-
]
|
|
1165
|
-
},
|
|
1166
|
-
{
|
|
1167
|
-
type: "error",
|
|
1168
|
-
name: "ERC20InvalidSender",
|
|
1169
|
-
inputs: [
|
|
2280
|
+
},
|
|
1170
2281
|
{
|
|
1171
|
-
name: "
|
|
1172
|
-
type: "
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
},
|
|
1177
|
-
{
|
|
1178
|
-
type: "error",
|
|
1179
|
-
name: "ERC20InvalidSpender",
|
|
1180
|
-
inputs: [
|
|
2282
|
+
name: "reIndex",
|
|
2283
|
+
type: "uint32",
|
|
2284
|
+
indexed: false,
|
|
2285
|
+
internalType: "uint32"
|
|
2286
|
+
},
|
|
1181
2287
|
{
|
|
1182
|
-
name: "
|
|
1183
|
-
type: "
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
}
|
|
1188
|
-
];
|
|
1189
|
-
|
|
1190
|
-
// src/config/erc721Abi.json
|
|
1191
|
-
var erc721Abi_default = [
|
|
1192
|
-
{
|
|
1193
|
-
type: "function",
|
|
1194
|
-
name: "supportsInterface",
|
|
1195
|
-
stateMutability: "view",
|
|
1196
|
-
inputs: [
|
|
1197
|
-
{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }
|
|
1198
|
-
],
|
|
1199
|
-
outputs: [{ internalType: "bool", name: "", type: "bool" }]
|
|
1200
|
-
},
|
|
1201
|
-
{
|
|
1202
|
-
type: "function",
|
|
1203
|
-
name: "balanceOf",
|
|
1204
|
-
stateMutability: "view",
|
|
1205
|
-
inputs: [
|
|
1206
|
-
{ internalType: "address", name: "owner", type: "address" }
|
|
1207
|
-
],
|
|
1208
|
-
outputs: [{ internalType: "uint256", name: "", type: "uint256" }]
|
|
1209
|
-
},
|
|
1210
|
-
{
|
|
1211
|
-
type: "function",
|
|
1212
|
-
name: "ownerOf",
|
|
1213
|
-
stateMutability: "view",
|
|
1214
|
-
inputs: [
|
|
1215
|
-
{ internalType: "uint256", name: "tokenId", type: "uint256" }
|
|
1216
|
-
],
|
|
1217
|
-
outputs: [{ internalType: "address", name: "", type: "address" }]
|
|
1218
|
-
},
|
|
1219
|
-
{
|
|
1220
|
-
type: "function",
|
|
1221
|
-
name: "tokenURI",
|
|
1222
|
-
stateMutability: "view",
|
|
1223
|
-
inputs: [
|
|
1224
|
-
{ internalType: "uint256", name: "tokenId", type: "uint256" }
|
|
1225
|
-
],
|
|
1226
|
-
outputs: [{ internalType: "string", name: "", type: "string" }]
|
|
1227
|
-
},
|
|
1228
|
-
{
|
|
1229
|
-
type: "function",
|
|
1230
|
-
name: "approve",
|
|
1231
|
-
stateMutability: "nonpayable",
|
|
1232
|
-
inputs: [
|
|
1233
|
-
{ internalType: "address", name: "to", type: "address" },
|
|
1234
|
-
{ internalType: "uint256", name: "tokenId", type: "uint256" }
|
|
1235
|
-
],
|
|
1236
|
-
outputs: []
|
|
1237
|
-
},
|
|
1238
|
-
{
|
|
1239
|
-
type: "function",
|
|
1240
|
-
name: "getApproved",
|
|
1241
|
-
stateMutability: "view",
|
|
1242
|
-
inputs: [
|
|
1243
|
-
{ internalType: "uint256", name: "tokenId", type: "uint256" }
|
|
1244
|
-
],
|
|
1245
|
-
outputs: [{ internalType: "address", name: "", type: "address" }]
|
|
1246
|
-
},
|
|
1247
|
-
{
|
|
1248
|
-
type: "function",
|
|
1249
|
-
name: "setApprovalForAll",
|
|
1250
|
-
stateMutability: "nonpayable",
|
|
1251
|
-
inputs: [
|
|
1252
|
-
{ internalType: "address", name: "operator", type: "address" },
|
|
1253
|
-
{ internalType: "bool", name: "approved", type: "bool" }
|
|
1254
|
-
],
|
|
1255
|
-
outputs: []
|
|
1256
|
-
},
|
|
1257
|
-
{
|
|
1258
|
-
type: "function",
|
|
1259
|
-
name: "isApprovedForAll",
|
|
1260
|
-
stateMutability: "view",
|
|
1261
|
-
inputs: [
|
|
1262
|
-
{ internalType: "address", name: "owner", type: "address" },
|
|
1263
|
-
{ internalType: "address", name: "operator", type: "address" }
|
|
2288
|
+
name: "timestamp",
|
|
2289
|
+
type: "uint64",
|
|
2290
|
+
indexed: false,
|
|
2291
|
+
internalType: "uint64"
|
|
2292
|
+
}
|
|
1264
2293
|
],
|
|
1265
|
-
|
|
2294
|
+
anonymous: false
|
|
1266
2295
|
},
|
|
1267
2296
|
{
|
|
1268
|
-
type: "
|
|
1269
|
-
name: "
|
|
1270
|
-
stateMutability: "nonpayable",
|
|
2297
|
+
type: "event",
|
|
2298
|
+
name: "RESWithdrawEvent",
|
|
1271
2299
|
inputs: [
|
|
1272
|
-
{
|
|
1273
|
-
|
|
1274
|
-
|
|
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
|
+
}
|
|
1275
2330
|
],
|
|
1276
|
-
|
|
2331
|
+
anonymous: false
|
|
1277
2332
|
},
|
|
1278
2333
|
{
|
|
1279
|
-
type: "
|
|
1280
|
-
name: "
|
|
1281
|
-
stateMutability: "nonpayable",
|
|
2334
|
+
type: "event",
|
|
2335
|
+
name: "RESendEvent",
|
|
1282
2336
|
inputs: [
|
|
1283
|
-
{
|
|
1284
|
-
|
|
1285
|
-
|
|
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
|
+
}
|
|
1286
2385
|
],
|
|
1287
|
-
|
|
2386
|
+
anonymous: false
|
|
1288
2387
|
},
|
|
2388
|
+
{ type: "error", name: "InvalidInitialization", inputs: [] },
|
|
2389
|
+
{ type: "error", name: "NotInitializing", inputs: [] },
|
|
1289
2390
|
{
|
|
1290
|
-
type: "
|
|
1291
|
-
name: "
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
2391
|
+
type: "error",
|
|
2392
|
+
name: "OwnableInvalidOwner",
|
|
2393
|
+
inputs: [
|
|
2394
|
+
{ name: "owner", type: "address", internalType: "address" }
|
|
2395
|
+
]
|
|
1295
2396
|
},
|
|
1296
2397
|
{
|
|
1297
|
-
type: "
|
|
1298
|
-
name: "
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
2398
|
+
type: "error",
|
|
2399
|
+
name: "OwnableUnauthorizedAccount",
|
|
2400
|
+
inputs: [
|
|
2401
|
+
{ name: "account", type: "address", internalType: "address" }
|
|
2402
|
+
]
|
|
1302
2403
|
}
|
|
1303
2404
|
];
|
|
1304
2405
|
|
|
1305
|
-
// src/classes/
|
|
1306
|
-
var
|
|
1307
|
-
|
|
1308
|
-
constructor(provider, address) {
|
|
1309
|
-
if (!provider || !address) {
|
|
1310
|
-
throw new Error("provider, address are required");
|
|
1311
|
-
}
|
|
1312
|
-
this.contractInstance = new Contract_default(provider, address, erc721Abi_default);
|
|
1313
|
-
}
|
|
1314
|
-
async approve(address, tokenId) {
|
|
1315
|
-
return new Promise(async (resolve, reject) => {
|
|
1316
|
-
try {
|
|
1317
|
-
const approver = await this.contractInstance.callMethod("getApproved", [tokenId]);
|
|
1318
|
-
if (approver === address) {
|
|
1319
|
-
console.log(`Already approved:: ${approver}`);
|
|
1320
|
-
resolve("Approved");
|
|
1321
|
-
} else {
|
|
1322
|
-
await this.contractInstance.sendTransaction("approve", [address, tokenId]);
|
|
1323
|
-
console.log(`Approved`);
|
|
1324
|
-
resolve("Approved");
|
|
1325
|
-
}
|
|
1326
|
-
} catch (error) {
|
|
1327
|
-
console.error("Approval failed:", error);
|
|
1328
|
-
return reject(error);
|
|
1329
|
-
}
|
|
1330
|
-
});
|
|
1331
|
-
}
|
|
1332
|
-
// ownerAddress: string,
|
|
1333
|
-
async setApprovalForAll(operatorAddress) {
|
|
1334
|
-
return new Promise(async (resolve, reject) => {
|
|
1335
|
-
try {
|
|
1336
|
-
await this.contractInstance.sendTransaction("setApprovalForAll", [operatorAddress, true]);
|
|
1337
|
-
console.log(`Approved`);
|
|
1338
|
-
resolve("Approved");
|
|
1339
|
-
} catch (error) {
|
|
1340
|
-
console.error("Approval failed:", error);
|
|
1341
|
-
return reject(error);
|
|
1342
|
-
}
|
|
1343
|
-
});
|
|
1344
|
-
}
|
|
1345
|
-
async fetchMetaData(nftContractAddress, tokenId) {
|
|
1346
|
-
return new Promise(async (resolve, reject) => {
|
|
1347
|
-
try {
|
|
1348
|
-
let url = await this.contractInstance.callMethod("tokenURI", [tokenId]);
|
|
1349
|
-
if (url.startsWith("ipfs://")) {
|
|
1350
|
-
url = url.replace("ipfs://", "https://ipfs.io/ipfs/");
|
|
1351
|
-
}
|
|
1352
|
-
const res = await fetch(url);
|
|
1353
|
-
if (!res.ok) {
|
|
1354
|
-
return reject(`Failed to fetch metadata from ${url}`);
|
|
1355
|
-
}
|
|
1356
|
-
let metadata = await res.json();
|
|
1357
|
-
if (metadata.image && metadata.image.startsWith("ipfs://")) {
|
|
1358
|
-
metadata.image = metadata.image.replace(
|
|
1359
|
-
"ipfs://",
|
|
1360
|
-
"https://ipfs.io/ipfs/"
|
|
1361
|
-
);
|
|
1362
|
-
}
|
|
1363
|
-
metadata.address = nftContractAddress;
|
|
1364
|
-
metadata.tokenId = tokenId;
|
|
1365
|
-
return resolve(metadata);
|
|
1366
|
-
} catch (error) {
|
|
1367
|
-
return reject(error);
|
|
1368
|
-
}
|
|
1369
|
-
});
|
|
1370
|
-
}
|
|
1371
|
-
};
|
|
1372
|
-
var Erc721Contract_default = Erc721Contract;
|
|
1373
|
-
|
|
1374
|
-
// src/classes/Fund.ts
|
|
1375
|
-
var { parseUnits, formatUnits } = import_ethers2.ethers.utils;
|
|
1376
|
-
var Fund = class {
|
|
1377
|
-
zkTlsSdk;
|
|
2406
|
+
// src/classes/FundForRedPacket.ts
|
|
2407
|
+
var { parseUnits: parseUnits3 } = import_ethers4.ethers.utils;
|
|
2408
|
+
var FundForRedPacket = class {
|
|
1378
2409
|
fundContract;
|
|
1379
2410
|
provider;
|
|
1380
2411
|
formatProvider;
|
|
1381
2412
|
chainId;
|
|
1382
|
-
_dataSourceTemplateMap = DATASOURCETEMPLATESMAP;
|
|
1383
2413
|
constructor() {
|
|
1384
2414
|
}
|
|
1385
|
-
|
|
1386
|
-
return this.zkTlsSdk;
|
|
1387
|
-
}
|
|
1388
|
-
async init(provider, chainId, appId) {
|
|
2415
|
+
async init(provider, chainId) {
|
|
1389
2416
|
return new Promise(async (resolve, reject) => {
|
|
1390
2417
|
try {
|
|
1391
|
-
|
|
1392
|
-
if (provider instanceof import_ethers2.ethers.providers.JsonRpcProvider) {
|
|
1393
|
-
formatProvider = provider;
|
|
1394
|
-
} else {
|
|
1395
|
-
formatProvider = new import_ethers2.ethers.providers.Web3Provider(provider);
|
|
1396
|
-
}
|
|
1397
|
-
const gasPrice = await formatProvider.getGasPrice();
|
|
1398
|
-
console.log("getGasPrice=", gasPrice);
|
|
1399
|
-
await formatProvider.ready;
|
|
1400
|
-
const network = await formatProvider.getNetwork();
|
|
1401
|
-
const providerChainId = network.chainId;
|
|
1402
|
-
console.log("init provider", provider, network);
|
|
1403
|
-
console.log("init providerChainId", providerChainId, chainId);
|
|
1404
|
-
if (providerChainId !== chainId) {
|
|
1405
|
-
return reject(`Please connect to the chain with ID ${chainId} first.`);
|
|
1406
|
-
}
|
|
1407
|
-
const fundContractAddress = Fund_CONTRACTS[chainId];
|
|
2418
|
+
const fundContractAddress = FundForRedPacket_CONTRACTS[chainId];
|
|
1408
2419
|
if (!fundContractAddress) {
|
|
1409
2420
|
return reject(`Unsupported chainId:${chainId}`);
|
|
1410
2421
|
}
|
|
1411
|
-
this.fundContract = new Contract_default(provider, fundContractAddress,
|
|
2422
|
+
this.fundContract = new Contract_default(provider, fundContractAddress, abiForRedPacket_default);
|
|
1412
2423
|
this.provider = provider;
|
|
1413
|
-
this.formatProvider = formatProvider;
|
|
1414
2424
|
this.chainId = chainId;
|
|
1415
|
-
|
|
1416
|
-
this.zkTlsSdk = new import_zktls_js_sdk.PrimusZKTLS();
|
|
1417
|
-
let platformDevice = "pc";
|
|
1418
|
-
const isIpad = () => {
|
|
1419
|
-
const userAgent = navigator.userAgent.toLowerCase();
|
|
1420
|
-
const isTabletSize = window.innerWidth > 768 && window.innerWidth < 1366;
|
|
1421
|
-
return /ipad/.test(userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 0 && isTabletSize;
|
|
1422
|
-
};
|
|
1423
|
-
if (navigator.userAgent.toLocaleLowerCase().includes("android")) {
|
|
1424
|
-
platformDevice = "android";
|
|
1425
|
-
} else if (navigator.userAgent.toLocaleLowerCase().includes("iphone") || isIpad()) {
|
|
1426
|
-
platformDevice = "ios";
|
|
1427
|
-
}
|
|
1428
|
-
console.log("init appId", appId, platformDevice);
|
|
1429
|
-
const extensionVersion = await this.zkTlsSdk.init(
|
|
1430
|
-
appId,
|
|
1431
|
-
"",
|
|
1432
|
-
{ platform: platformDevice }
|
|
1433
|
-
);
|
|
1434
|
-
resolve(extensionVersion);
|
|
1435
|
-
} else {
|
|
1436
|
-
resolve("success");
|
|
1437
|
-
}
|
|
2425
|
+
resolve("success");
|
|
1438
2426
|
} catch (error) {
|
|
1439
2427
|
return reject(error);
|
|
1440
2428
|
}
|
|
1441
2429
|
});
|
|
1442
2430
|
}
|
|
1443
|
-
async
|
|
2431
|
+
async fundForRedPacket(tokenInfo, sendParam) {
|
|
1444
2432
|
return new Promise(async (resolve, reject) => {
|
|
1445
2433
|
try {
|
|
1446
|
-
const recipientInfos = [];
|
|
1447
|
-
recipientInfos[0] = recipientInfo;
|
|
1448
2434
|
let decimals = 18;
|
|
1449
2435
|
let params = [];
|
|
1450
2436
|
if (tokenInfo.tokenType === 0) {
|
|
1451
|
-
await this.
|
|
2437
|
+
await this.approveForRedPacket(tokenInfo, sendParam.amount);
|
|
1452
2438
|
console.log("after approve in fund fn");
|
|
1453
|
-
const
|
|
1454
|
-
|
|
1455
|
-
decimals = await erc20Contract.decimals();
|
|
1456
|
-
} else if (tokenInfo.tokenType === 2) {
|
|
1457
|
-
decimals = 0;
|
|
1458
|
-
const erc721ContractInstance = new Erc721Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
1459
|
-
await erc721ContractInstance.approve(this.fundContract.address, recipientInfo.nftIds[0]);
|
|
2439
|
+
const tokenContract = new Erc20Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
2440
|
+
decimals = await tokenContract.decimals();
|
|
1460
2441
|
}
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
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
|
|
1467
2449
|
};
|
|
1468
2450
|
if (tokenInfo.tokenType === 1) {
|
|
1469
|
-
params = [tokenInfo,
|
|
2451
|
+
params = [tokenInfo, formatSendParam, { value: formatSendAmount }];
|
|
1470
2452
|
} else {
|
|
1471
|
-
params = [tokenInfo,
|
|
2453
|
+
params = [tokenInfo, formatSendParam];
|
|
1472
2454
|
}
|
|
1473
2455
|
if ([97, 56].includes(this.chainId)) {
|
|
1474
|
-
const gasPrice = await this.
|
|
2456
|
+
const gasPrice = await this.provider.getGasPrice();
|
|
1475
2457
|
params[2] = params[2] ? { ...params[2], gasPrice } : { gasPrice };
|
|
1476
2458
|
}
|
|
1477
|
-
console.log("
|
|
1478
|
-
const result = await this.fundContract.sendTransaction("
|
|
2459
|
+
console.log("tipForRedPacket-params", params, this.chainId);
|
|
2460
|
+
const result = await this.fundContract.sendTransaction("reSend", params);
|
|
1479
2461
|
resolve(result);
|
|
1480
2462
|
} catch (error) {
|
|
1481
2463
|
return reject(error);
|
|
1482
2464
|
}
|
|
1483
2465
|
});
|
|
1484
2466
|
}
|
|
1485
|
-
async
|
|
2467
|
+
async onlyFundForRedPacket(tokenInfo, sendParam) {
|
|
1486
2468
|
return new Promise(async (resolve, reject) => {
|
|
1487
2469
|
try {
|
|
1488
|
-
const recipientInfos = [];
|
|
1489
|
-
recipientInfos[0] = recipientInfo;
|
|
1490
2470
|
let decimals = 18;
|
|
1491
2471
|
let params = [];
|
|
1492
2472
|
if (tokenInfo.tokenType === 0) {
|
|
1493
|
-
const
|
|
1494
|
-
|
|
1495
|
-
decimals = await erc20Contract.decimals();
|
|
1496
|
-
} else if (tokenInfo.tokenType === 2) {
|
|
1497
|
-
decimals = 0;
|
|
1498
|
-
const erc721ContractInstance = new Erc721Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
1499
|
-
await erc721ContractInstance.approve(this.fundContract.address, recipientInfo.nftIds[0]);
|
|
2473
|
+
const tokenContract = new Erc20Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
2474
|
+
decimals = await tokenContract.decimals();
|
|
1500
2475
|
}
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
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
|
|
1507
2483
|
};
|
|
1508
2484
|
if (tokenInfo.tokenType === 1) {
|
|
1509
|
-
params = [tokenInfo,
|
|
2485
|
+
params = [tokenInfo, formatSendParam, { value: formatSendAmount }];
|
|
1510
2486
|
} else {
|
|
1511
|
-
params = [tokenInfo,
|
|
2487
|
+
params = [tokenInfo, formatSendParam];
|
|
1512
2488
|
}
|
|
1513
2489
|
if ([97, 56].includes(this.chainId)) {
|
|
1514
|
-
const gasPrice = await this.
|
|
2490
|
+
const gasPrice = await this.provider.getGasPrice();
|
|
1515
2491
|
params[2] = params[2] ? { ...params[2], gasPrice } : { gasPrice };
|
|
1516
2492
|
}
|
|
1517
|
-
console.log("
|
|
1518
|
-
const result = await this.fundContract.sendTransaction("
|
|
2493
|
+
console.log("onlytipForRedPacket-params", params, this.chainId);
|
|
2494
|
+
const result = await this.fundContract.sendTransaction("reSend", params);
|
|
1519
2495
|
resolve(result);
|
|
1520
2496
|
} catch (error) {
|
|
1521
2497
|
return reject(error);
|
|
1522
2498
|
}
|
|
1523
2499
|
});
|
|
1524
2500
|
}
|
|
1525
|
-
async
|
|
2501
|
+
async withdrawForRedPacket(redPacketId) {
|
|
1526
2502
|
return new Promise(async (resolve, reject) => {
|
|
1527
2503
|
try {
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
};
|
|
1534
|
-
}
|
|
1535
|
-
|
|
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
|
+
};
|
|
1536
2525
|
if ([97, 56].includes(this.chainId)) {
|
|
1537
|
-
const gasPrice = await this.
|
|
1538
|
-
|
|
1539
|
-
gasPrice
|
|
1540
|
-
});
|
|
2526
|
+
const gasPrice = await this.provider.getGasPrice();
|
|
2527
|
+
approveParams.otherParams = { gasPrice };
|
|
1541
2528
|
}
|
|
1542
|
-
const
|
|
1543
|
-
|
|
2529
|
+
const tokenContract = new Erc20Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
2530
|
+
await tokenContract.approve(approveParams);
|
|
2531
|
+
resolve("Approved");
|
|
1544
2532
|
} catch (error) {
|
|
1545
2533
|
return reject(error);
|
|
1546
2534
|
}
|
|
1547
2535
|
});
|
|
1548
2536
|
}
|
|
1549
|
-
async
|
|
2537
|
+
async claimForRedPacket(redPacketId, attestation) {
|
|
1550
2538
|
return new Promise(async (resolve, reject) => {
|
|
1551
2539
|
try {
|
|
1552
|
-
|
|
1553
|
-
let params = [];
|
|
1554
|
-
if (tokenInfo.tokenType === 0) {
|
|
1555
|
-
await this.approve(tokenInfo, recipientInfoList);
|
|
1556
|
-
const web3Provider = new import_ethers2.ethers.providers.Web3Provider(this.provider);
|
|
1557
|
-
const erc20Contract = new import_ethers2.ethers.Contract(tokenInfo.tokenAddress, erc20Abi_default, web3Provider);
|
|
1558
|
-
decimals = await erc20Contract.decimals();
|
|
1559
|
-
} else if (tokenInfo.tokenType === 2) {
|
|
1560
|
-
decimals = 0;
|
|
1561
|
-
const erc721ContractInstance = new Erc721Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
1562
|
-
await erc721ContractInstance.setApprovalForAll(this.fundContract.address);
|
|
1563
|
-
}
|
|
1564
|
-
let totalFormatAmount = recipientInfoList.reduce((acc, cur) => acc.add(parseUnits(cur.tokenAmount.toString(), decimals)), import_ethers2.ethers.BigNumber.from(0));
|
|
1565
|
-
const newRecipientInfoList = recipientInfoList.map((i) => {
|
|
1566
|
-
const formatAmount = parseUnits(i.tokenAmount.toString(), decimals);
|
|
1567
|
-
return {
|
|
1568
|
-
idSource: i.socialPlatform,
|
|
1569
|
-
id: i.userIdentifier,
|
|
1570
|
-
amount: formatAmount,
|
|
1571
|
-
nftIds: i.nftIds
|
|
1572
|
-
};
|
|
1573
|
-
});
|
|
1574
|
-
if (tokenInfo.tokenType === 1) {
|
|
1575
|
-
params = [tokenInfo, newRecipientInfoList, { value: totalFormatAmount }];
|
|
1576
|
-
} else {
|
|
1577
|
-
params = [tokenInfo, newRecipientInfoList];
|
|
1578
|
-
}
|
|
2540
|
+
const claimFee = await this.fundContract.callMethod("claimFee", []);
|
|
2541
|
+
let params = [redPacketId, attestation, { value: claimFee }];
|
|
1579
2542
|
if ([97, 56].includes(this.chainId)) {
|
|
1580
|
-
const gasPrice = await this.
|
|
1581
|
-
params[2] =
|
|
2543
|
+
const gasPrice = await this.provider.getGasPrice();
|
|
2544
|
+
params[2].gasPrice = gasPrice;
|
|
1582
2545
|
}
|
|
1583
|
-
const
|
|
1584
|
-
return resolve(
|
|
2546
|
+
const txreceipt = await this.fundContract.sendTransaction("reClaim", params);
|
|
2547
|
+
return resolve(txreceipt);
|
|
1585
2548
|
} catch (error) {
|
|
1586
2549
|
return reject(error);
|
|
1587
2550
|
}
|
|
1588
2551
|
});
|
|
1589
2552
|
}
|
|
1590
|
-
|
|
1591
|
-
async approve(tokenInfo, recipientInfoList) {
|
|
2553
|
+
async getRedPacketInfo(redPacketId) {
|
|
1592
2554
|
return new Promise(async (resolve, reject) => {
|
|
1593
2555
|
try {
|
|
1594
|
-
const
|
|
1595
|
-
|
|
1596
|
-
const address = await signer.getAddress();
|
|
1597
|
-
const erc20Contract = new import_ethers2.ethers.Contract(tokenInfo.tokenAddress, erc20Abi_default, signer);
|
|
1598
|
-
const allowance = await erc20Contract.allowance(address, this.fundContract.address);
|
|
1599
|
-
const decimals = await erc20Contract.decimals();
|
|
1600
|
-
console.log("allowance", formatUnits(allowance.toString(), decimals));
|
|
1601
|
-
const requiredAllowance = recipientInfoList.reduce((acc, cur) => acc.add(parseUnits(cur.tokenAmount.toString(), decimals)), import_ethers2.ethers.BigNumber.from(0));
|
|
1602
|
-
if (allowance.lt(requiredAllowance)) {
|
|
1603
|
-
let params = [this.fundContract.address, requiredAllowance];
|
|
1604
|
-
if ([97, 56].includes(this.chainId)) {
|
|
1605
|
-
const gasPrice = await this.formatProvider.getGasPrice();
|
|
1606
|
-
params.push({ gasPrice });
|
|
1607
|
-
}
|
|
1608
|
-
const tx = await erc20Contract.approve(...params);
|
|
1609
|
-
await tx.wait();
|
|
1610
|
-
console.log(`Approved: ${requiredAllowance.toString()}`);
|
|
1611
|
-
} else {
|
|
1612
|
-
console.log(`Already approved: ${allowance.toString()}`);
|
|
1613
|
-
}
|
|
1614
|
-
resolve("Approved");
|
|
2556
|
+
const redpacketInfo = await this.fundContract.callMethod("getREInfo", [redPacketId]);
|
|
2557
|
+
return resolve(redpacketInfo);
|
|
1615
2558
|
} catch (error) {
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
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";
|
|
1619
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) {
|
|
1620
2597
|
return reject(error);
|
|
1621
2598
|
}
|
|
1622
2599
|
});
|
|
1623
2600
|
}
|
|
1624
|
-
async attest(attestParams,
|
|
2601
|
+
async attest(attestParams, signFn, backUrl) {
|
|
1625
2602
|
return new Promise(async (resolve, reject) => {
|
|
1626
2603
|
console.log("this.zkTlsSdk", this.zkTlsSdk);
|
|
1627
2604
|
const { socialPlatform, userIdentifier, address } = attestParams;
|
|
1628
|
-
const { id: templateId, field } =
|
|
2605
|
+
const { id: templateId, field } = DATASOURCETEMPLATESMAP[socialPlatform];
|
|
1629
2606
|
const attRequest = this.zkTlsSdk.generateRequestParams(
|
|
1630
2607
|
templateId,
|
|
1631
2608
|
address
|
|
@@ -1644,7 +2621,7 @@ var Fund = class {
|
|
|
1644
2621
|
]
|
|
1645
2622
|
]);
|
|
1646
2623
|
const signParams = attRequest.toJsonString();
|
|
1647
|
-
const signature = await
|
|
2624
|
+
const signature = await signFn(signParams);
|
|
1648
2625
|
if (!signature) {
|
|
1649
2626
|
return reject(`appSignature is empty!`);
|
|
1650
2627
|
}
|
|
@@ -1664,121 +2641,41 @@ var Fund = class {
|
|
|
1664
2641
|
}
|
|
1665
2642
|
});
|
|
1666
2643
|
}
|
|
1667
|
-
async
|
|
2644
|
+
async attestCommon(attestParams) {
|
|
2645
|
+
const { templateId, address, signFn, conditions, additionParams, backUrl } = attestParams;
|
|
1668
2646
|
return new Promise(async (resolve, reject) => {
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
} else {
|
|
1677
|
-
const totalFee = claimFee.mul(recordCount);
|
|
1678
|
-
let params = [socialPlatform, attestation, { value: totalFee }];
|
|
1679
|
-
if ([97, 56].includes(this.chainId)) {
|
|
1680
|
-
const gasPrice = await this.formatProvider.getGasPrice();
|
|
1681
|
-
params[2].gasPrice = gasPrice;
|
|
1682
|
-
}
|
|
1683
|
-
const txreceipt = await this.fundContract.sendTransaction("claimBySource", params);
|
|
1684
|
-
return resolve(txreceipt);
|
|
1685
|
-
}
|
|
1686
|
-
} catch (error) {
|
|
1687
|
-
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);
|
|
1688
2654
|
}
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
const fundRecords = await this.fundContract.callMethod("getTipRecords", [{ idSource: value, id: userIdentifiers[index] }]);
|
|
1702
|
-
allFundRecords.push(...fundRecords);
|
|
1703
|
-
recordCount += fundRecords.length;
|
|
1704
|
-
}
|
|
1705
|
-
if (recordCount <= 0) {
|
|
1706
|
-
return reject(`No fund records.`);
|
|
1707
|
-
} else {
|
|
1708
|
-
const totalFee = claimFee.mul(recordCount);
|
|
1709
|
-
let params = [socialPlatforms, userIdentifiers, attestationList, { value: totalFee }];
|
|
1710
|
-
if ([97, 56].includes(this.chainId)) {
|
|
1711
|
-
const gasPrice = await this.formatProvider.getGasPrice();
|
|
1712
|
-
params[3].gasPrice = gasPrice;
|
|
1713
|
-
}
|
|
1714
|
-
const txreceipt = await this.fundContract.sendTransaction("claimByMultiSource", params);
|
|
1715
|
-
return resolve(txreceipt);
|
|
1716
|
-
}
|
|
1717
|
-
} catch (error) {
|
|
1718
|
-
console.error("claimByMultiSource", error);
|
|
1719
|
-
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!`);
|
|
1720
2667
|
}
|
|
1721
|
-
});
|
|
1722
|
-
}
|
|
1723
|
-
async getTipRecords(getFundRecordsParams) {
|
|
1724
|
-
return new Promise(async (resolve, reject) => {
|
|
1725
2668
|
try {
|
|
1726
|
-
const
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
}
|
|
1732
|
-
const
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
const { tipper, timestamp, tipToken: [tokenType, tokenAddress], amount, nftIds } = record;
|
|
1737
|
-
let decimals = 18;
|
|
1738
|
-
let symbol = "";
|
|
1739
|
-
let tokenId = null;
|
|
1740
|
-
let nftInfo = null;
|
|
1741
|
-
if (tokenType === 0) {
|
|
1742
|
-
let formatProvider;
|
|
1743
|
-
if (this.provider instanceof import_ethers2.ethers.providers.JsonRpcProvider) {
|
|
1744
|
-
formatProvider = this.provider;
|
|
1745
|
-
} else {
|
|
1746
|
-
formatProvider = new import_ethers2.ethers.providers.Web3Provider(this.provider);
|
|
1747
|
-
}
|
|
1748
|
-
const erc20Contract = new import_ethers2.ethers.Contract(tokenAddress, erc20Abi_default, formatProvider);
|
|
1749
|
-
decimals = await erc20Contract.decimals();
|
|
1750
|
-
symbol = await erc20Contract.symbol();
|
|
1751
|
-
} else if (tokenType === 1) {
|
|
1752
|
-
symbol = NATIVETOKENS[this.chainId];
|
|
1753
|
-
} else if (tokenType === 2) {
|
|
1754
|
-
decimals = 0;
|
|
1755
|
-
tokenId = parseInt(nftIds[0]);
|
|
1756
|
-
const erc721ContractInstance = new Erc721Contract_default(this.provider, tokenAddress);
|
|
1757
|
-
nftInfo = await erc721ContractInstance.fetchMetaData(tokenAddress, tokenId);
|
|
1758
|
-
}
|
|
1759
|
-
let fundToken = {
|
|
1760
|
-
tokenType,
|
|
1761
|
-
// tokenAmount: formatUnits(amount, decimals),
|
|
1762
|
-
decimals,
|
|
1763
|
-
symbol,
|
|
1764
|
-
chainName: CHAINNAMES[this.chainId],
|
|
1765
|
-
chainId: this.chainId
|
|
1766
|
-
};
|
|
1767
|
-
if (tokenType === 0) {
|
|
1768
|
-
fundToken.tokenAddress = tokenAddress;
|
|
1769
|
-
}
|
|
1770
|
-
if (tokenType === 2) {
|
|
1771
|
-
Object.assign(fundToken, nftInfo ?? {});
|
|
1772
|
-
}
|
|
1773
|
-
formatRecords.push({
|
|
1774
|
-
funder: tipper,
|
|
1775
|
-
fundToken,
|
|
1776
|
-
amount: formatUnits(amount, decimals),
|
|
1777
|
-
timestamp: timestamp.toNumber()
|
|
1778
|
-
});
|
|
1779
|
-
}
|
|
1780
|
-
console.log("formatRecords", formatRecords);
|
|
1781
|
-
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);
|
|
1782
2679
|
} catch (error) {
|
|
1783
2680
|
return reject(error);
|
|
1784
2681
|
}
|
|
@@ -1790,15 +2687,41 @@ var Fund = class {
|
|
|
1790
2687
|
var PrimusFund = class {
|
|
1791
2688
|
supportedChainIds = SUPPORTEDCHAINIDS;
|
|
1792
2689
|
supportedSocialPlatforms = SUPPORTEDSOCIALPLATFORMS;
|
|
2690
|
+
provider;
|
|
1793
2691
|
_fund;
|
|
2692
|
+
_fundForRedPacket;
|
|
2693
|
+
_zkTlsSdk;
|
|
1794
2694
|
async init(provider, chainId, appId) {
|
|
1795
2695
|
return new Promise(async (resolve, reject) => {
|
|
1796
2696
|
try {
|
|
1797
2697
|
if (!this.supportedChainIds.includes(chainId)) {
|
|
1798
2698
|
return reject("chainId is not supported");
|
|
1799
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;
|
|
1800
2717
|
this._fund = new Fund();
|
|
1801
|
-
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
|
+
}
|
|
1802
2725
|
return resolve(result);
|
|
1803
2726
|
} catch (error) {
|
|
1804
2727
|
return reject(error);
|
|
@@ -1817,7 +2740,7 @@ var PrimusFund = class {
|
|
|
1817
2740
|
return reject("socialPlatform is not supported");
|
|
1818
2741
|
}
|
|
1819
2742
|
if (tokenInfo.tokenType === 1) {
|
|
1820
|
-
tokenInfo.tokenAddress =
|
|
2743
|
+
tokenInfo.tokenAddress = import_ethers5.ethers.constants.AddressZero;
|
|
1821
2744
|
}
|
|
1822
2745
|
const newFundRecipientInfos = recipientInfos.map((i) => {
|
|
1823
2746
|
const formatSocialPlatform = i.socialPlatform.toLowerCase();
|
|
@@ -1856,7 +2779,7 @@ var PrimusFund = class {
|
|
|
1856
2779
|
return reject("socialPlatform is not supported");
|
|
1857
2780
|
}
|
|
1858
2781
|
if (tokenInfo.tokenType === 1) {
|
|
1859
|
-
tokenInfo.tokenAddress =
|
|
2782
|
+
tokenInfo.tokenAddress = import_ethers5.ethers.constants.AddressZero;
|
|
1860
2783
|
}
|
|
1861
2784
|
const newFundRecipientInfos = recipientInfos.map((i) => {
|
|
1862
2785
|
const formatSocialPlatform = i.socialPlatform.toLowerCase();
|
|
@@ -1890,7 +2813,7 @@ var PrimusFund = class {
|
|
|
1890
2813
|
return reject("socialPlatform is not supported");
|
|
1891
2814
|
}
|
|
1892
2815
|
if (tokenInfo.tokenType === 1) {
|
|
1893
|
-
tokenInfo.tokenAddress =
|
|
2816
|
+
tokenInfo.tokenAddress = import_ethers5.ethers.constants.AddressZero;
|
|
1894
2817
|
}
|
|
1895
2818
|
const newFundRecipientInfos = recipientInfos.map((i) => {
|
|
1896
2819
|
const formatSocialPlatform = i.socialPlatform.toLowerCase();
|
|
@@ -1932,15 +2855,15 @@ var PrimusFund = class {
|
|
|
1932
2855
|
}
|
|
1933
2856
|
});
|
|
1934
2857
|
}
|
|
1935
|
-
async attest(attestParams,
|
|
2858
|
+
async attest(attestParams, signFn, backUrl) {
|
|
1936
2859
|
return new Promise(async (resolve, reject) => {
|
|
1937
2860
|
try {
|
|
1938
2861
|
const { socialPlatform } = attestParams;
|
|
1939
2862
|
const lcSocialPlatform = socialPlatform.toLowerCase();
|
|
1940
|
-
const attestation = await this.
|
|
2863
|
+
const attestation = await this._zkTlsSdk?.attest({
|
|
1941
2864
|
...attestParams,
|
|
1942
2865
|
socialPlatform: lcSocialPlatform
|
|
1943
|
-
},
|
|
2866
|
+
}, signFn, backUrl);
|
|
1944
2867
|
return resolve(attestation);
|
|
1945
2868
|
} catch (error) {
|
|
1946
2869
|
return reject(error);
|
|
@@ -2008,6 +2931,79 @@ var PrimusFund = class {
|
|
|
2008
2931
|
}
|
|
2009
2932
|
});
|
|
2010
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
|
+
}
|
|
2011
3007
|
};
|
|
2012
3008
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2013
3009
|
0 && (module.exports = {
|