@verified-network/verified-sdk 2.2.0 → 2.2.2
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/contract/client/index.js +1 -1
- package/dist/contract/index.js +87 -50
- package/dist/contract/pool/index.d.ts +1 -0
- package/dist/contract/pool/index.js +6 -0
- package/dist/contract/security/index.d.ts +5 -2
- package/dist/contract/security/index.js +13 -0
- package/dist/utils/constants.js +1 -1
- package/package.json +1 -1
|
@@ -35,7 +35,7 @@ class Client extends index_1.VerifiedContract {
|
|
|
35
35
|
async _getMeeQuote(paymentTokenAddress, functionName, args) {
|
|
36
36
|
return await this.getQuote(paymentTokenAddress, functionName, args);
|
|
37
37
|
}
|
|
38
|
-
setSigner(_address, options) {
|
|
38
|
+
async setSigner(_address, options) {
|
|
39
39
|
await this.validateInput(index_1.DATATYPES.ADDRESS, _address);
|
|
40
40
|
return this.callContract(FUNCTIONS.SETSIGNER, _address, options);
|
|
41
41
|
}
|
package/dist/contract/index.js
CHANGED
|
@@ -378,6 +378,15 @@ class VerifiedContract {
|
|
|
378
378
|
console.log("will use ethers....");
|
|
379
379
|
return await this.callFunctionWithEthers(functionName, ...args);
|
|
380
380
|
}
|
|
381
|
+
else {
|
|
382
|
+
//no receipt found?? don't call with ethers transaction may get mined???
|
|
383
|
+
res.status = STATUS.ERROR; //create additional status to mark this???
|
|
384
|
+
res.response = {
|
|
385
|
+
hash: txHash,
|
|
386
|
+
result: [],
|
|
387
|
+
};
|
|
388
|
+
res.message = "Transaction Pending.";
|
|
389
|
+
}
|
|
381
390
|
}
|
|
382
391
|
return res;
|
|
383
392
|
}
|
|
@@ -444,7 +453,7 @@ class VerifiedContract {
|
|
|
444
453
|
return res;
|
|
445
454
|
}
|
|
446
455
|
else {
|
|
447
|
-
console.error("
|
|
456
|
+
console.error("MEE client transaction failed with error: ", "Receipts lesser than one.");
|
|
448
457
|
res.status = STATUS.ERROR;
|
|
449
458
|
res.response = {
|
|
450
459
|
hash: (_c = receipt === null || receipt === void 0 ? void 0 : receipt.receipts[0]) === null || _c === void 0 ? void 0 : _c.transactionHash,
|
|
@@ -455,7 +464,7 @@ class VerifiedContract {
|
|
|
455
464
|
}
|
|
456
465
|
}
|
|
457
466
|
catch (err) {
|
|
458
|
-
console.error("
|
|
467
|
+
console.error("MEE client transaction failed with error: ", (err === null || err === void 0 ? void 0 : err.message) || err);
|
|
459
468
|
res.status = STATUS.ERROR;
|
|
460
469
|
res.response = {
|
|
461
470
|
hash: txHash,
|
|
@@ -466,7 +475,7 @@ class VerifiedContract {
|
|
|
466
475
|
}
|
|
467
476
|
}
|
|
468
477
|
async callContract(functionName, ...args) {
|
|
469
|
-
var _a, _b, _c, _d;
|
|
478
|
+
var _a, _b, _c, _d, _e, _f;
|
|
470
479
|
// Check if the function is a read function
|
|
471
480
|
if (this.isReadFunction(functionName)) {
|
|
472
481
|
console.log("read function will use ethers");
|
|
@@ -500,18 +509,36 @@ class VerifiedContract {
|
|
|
500
509
|
if ((_a = optionsRaw[0]) === null || _a === void 0 ? void 0 : _a.paymentToken) {
|
|
501
510
|
console.log("Using Mee client with paymentToken of: ", (_b = optionsRaw[0]) === null || _b === void 0 ? void 0 : _b.paymentToken);
|
|
502
511
|
const _signer = this.signer;
|
|
512
|
+
const chainToUse = [
|
|
513
|
+
chains_1.base,
|
|
514
|
+
chains_1.mainnet,
|
|
515
|
+
chains_1.gnosis,
|
|
516
|
+
chains_1.polygon,
|
|
517
|
+
chains_1.sepolia,
|
|
518
|
+
chains_1.baseSepolia,
|
|
519
|
+
].find((nt) => Number(nt === null || nt === void 0 ? void 0 : nt.id) === Number(chainId));
|
|
520
|
+
if (!chainToUse) {
|
|
521
|
+
throw new Error(`Chaind id: ${chainId} not supported on Verified Sdk. Supported chain ids are: ${(_d = (_c = [
|
|
522
|
+
chains_1.base,
|
|
523
|
+
chains_1.mainnet,
|
|
524
|
+
chains_1.gnosis,
|
|
525
|
+
chains_1.polygon,
|
|
526
|
+
chains_1.sepolia,
|
|
527
|
+
chains_1.baseSepolia,
|
|
528
|
+
]) === null || _c === void 0 ? void 0 : _c.map((nt) => nt === null || nt === void 0 ? void 0 : nt.id)) === null || _d === void 0 ? void 0 : _d.join(", ")}`);
|
|
529
|
+
}
|
|
503
530
|
const nexusAccount = await (0, abstractjs_1.toMultichainNexusAccount)({
|
|
504
|
-
chains: [
|
|
505
|
-
transports: [(0, viem_1.http)()
|
|
531
|
+
chains: [chainToUse],
|
|
532
|
+
transports: [(0, viem_1.http)()],
|
|
506
533
|
signer: _signer,
|
|
507
534
|
});
|
|
508
535
|
const meeAddress = nexusAccount.addressOn(chainId);
|
|
509
536
|
// console.log("nexus account address: ", meeAddress);
|
|
510
|
-
return await this.callFunctionWithMEEClient(nexusAccount, chainId, tx1, (
|
|
537
|
+
return await this.callFunctionWithMEEClient(nexusAccount, chainId, tx1, (_e = optionsRaw[0]) === null || _e === void 0 ? void 0 : _e.paymentToken);
|
|
511
538
|
}
|
|
512
539
|
else {
|
|
513
540
|
console.log("Using Userop since no payment token...");
|
|
514
|
-
const paymentToken = ((
|
|
541
|
+
const paymentToken = ((_f = options[0]) === null || _f === void 0 ? void 0 : _f.paymentToken) ||
|
|
515
542
|
constants_1.PaymasterConstants[`${chainId}`]["PAYMENT_TOKEN"] ||
|
|
516
543
|
"";
|
|
517
544
|
return await this.callFunctionAsUserOp(smartAccount, tx1, functionName, paymentToken, ...args);
|
|
@@ -528,52 +555,62 @@ class VerifiedContract {
|
|
|
528
555
|
const chainId = await this.signer.getChainId();
|
|
529
556
|
if (this.supportsGasless(chainId)) {
|
|
530
557
|
const _signer = this.signer;
|
|
531
|
-
const
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
558
|
+
const chainToUse = [
|
|
559
|
+
chains_1.base,
|
|
560
|
+
chains_1.mainnet,
|
|
561
|
+
chains_1.gnosis,
|
|
562
|
+
chains_1.polygon,
|
|
563
|
+
chains_1.sepolia,
|
|
564
|
+
chains_1.baseSepolia,
|
|
565
|
+
].find((nt) => Number(nt === null || nt === void 0 ? void 0 : nt.id) === Number(chainId));
|
|
566
|
+
if (chainToUse) {
|
|
567
|
+
const nexusAccount = await (0, abstractjs_1.toMultichainNexusAccount)({
|
|
568
|
+
chains: [chainToUse],
|
|
569
|
+
transports: [(0, viem_1.http)()],
|
|
570
|
+
signer: _signer,
|
|
571
|
+
});
|
|
572
|
+
if (paymentTokenAddress) {
|
|
573
|
+
//construct calldata for function
|
|
574
|
+
try {
|
|
575
|
+
let fn = this.contract.populateTransaction[functionName];
|
|
576
|
+
let _res = await fn(...args);
|
|
577
|
+
const tx1 = {
|
|
578
|
+
to: this.contract.address,
|
|
579
|
+
data: _res.data,
|
|
580
|
+
};
|
|
581
|
+
const meeClient = await (0, abstractjs_1.createMeeClient)({
|
|
582
|
+
account: nexusAccount,
|
|
583
|
+
});
|
|
584
|
+
const transactionInstruction = await nexusAccount.build({
|
|
585
|
+
type: "default",
|
|
586
|
+
data: {
|
|
587
|
+
chainId,
|
|
588
|
+
calls: [tx1],
|
|
589
|
+
},
|
|
590
|
+
});
|
|
591
|
+
const tkAddress = paymentTokenAddress;
|
|
592
|
+
const quote = await meeClient.getQuote({
|
|
593
|
+
instructions: [transactionInstruction],
|
|
594
|
+
feeToken: { address: tkAddress, chainId },
|
|
595
|
+
});
|
|
596
|
+
return {
|
|
597
|
+
tokenAddress: paymentTokenAddress,
|
|
598
|
+
amount: quote === null || quote === void 0 ? void 0 : quote.paymentInfo.tokenAmount,
|
|
599
|
+
amountInWei: quote === null || quote === void 0 ? void 0 : quote.paymentInfo.tokenWeiAmount,
|
|
600
|
+
amouuntValue: quote === null || quote === void 0 ? void 0 : quote.paymentInfo.tokenValue,
|
|
551
601
|
chainId,
|
|
552
|
-
|
|
553
|
-
}
|
|
554
|
-
});
|
|
555
|
-
const tkAddress = paymentTokenAddress;
|
|
556
|
-
const quote = await meeClient.getQuote({
|
|
557
|
-
instructions: [transactionInstruction],
|
|
558
|
-
feeToken: { address: tkAddress, chainId },
|
|
559
|
-
});
|
|
560
|
-
return {
|
|
561
|
-
tokenAddress: paymentTokenAddress,
|
|
562
|
-
amount: quote === null || quote === void 0 ? void 0 : quote.paymentInfo.tokenAmount,
|
|
563
|
-
amountInWei: quote === null || quote === void 0 ? void 0 : quote.paymentInfo.tokenWeiAmount,
|
|
564
|
-
amouuntValue: quote === null || quote === void 0 ? void 0 : quote.paymentInfo.tokenValue,
|
|
565
|
-
chainId,
|
|
566
|
-
functionName,
|
|
567
|
-
};
|
|
568
|
-
}
|
|
569
|
-
catch (err) {
|
|
570
|
-
if ((_a = err === null || err === void 0 ? void 0 : err.message) === null || _a === void 0 ? void 0 : _a.includes("fn is not a function")) {
|
|
571
|
-
throw new Error(`Function ${functionName} not found in contract's ABI`);
|
|
602
|
+
functionName,
|
|
603
|
+
};
|
|
572
604
|
}
|
|
573
|
-
|
|
574
|
-
|
|
605
|
+
catch (err) {
|
|
606
|
+
if ((_a = err === null || err === void 0 ? void 0 : err.message) === null || _a === void 0 ? void 0 : _a.includes("fn is not a function")) {
|
|
607
|
+
throw new Error(`Function ${functionName} not found in contract's ABI`);
|
|
608
|
+
}
|
|
609
|
+
else if ((_b = err === null || err === void 0 ? void 0 : err.message) === null || _b === void 0 ? void 0 : _b.includes("code=INVALID_ARGUMENT")) {
|
|
610
|
+
throw new TypeError(`Invalid arguments type`);
|
|
611
|
+
}
|
|
612
|
+
throw new Error((err === null || err === void 0 ? void 0 : err.message) || "getQuote failed.");
|
|
575
613
|
}
|
|
576
|
-
throw new Error((err === null || err === void 0 ? void 0 : err.message) || "getQuote failed.");
|
|
577
614
|
}
|
|
578
615
|
}
|
|
579
616
|
}
|
|
@@ -35,5 +35,6 @@ export default class PoolContract extends VerifiedContract {
|
|
|
35
35
|
swap(_swap: SingleSwap, _funds: Funds, _limit: string, _deadline: string, options?: Options): any;
|
|
36
36
|
batchSwap(_kind: string, _swaps: Swap[], _assests: string[], _funds: Funds, _limits: string[], _deadline: string, options?: Options): any;
|
|
37
37
|
getPoolTokens(_poolId: string, options?: Options): any;
|
|
38
|
+
getPool(_poolId: string, options?: Options): any;
|
|
38
39
|
}
|
|
39
40
|
export {};
|
|
@@ -13,6 +13,7 @@ var FUNCTIONS;
|
|
|
13
13
|
FUNCTIONS["SWAP"] = "swap";
|
|
14
14
|
FUNCTIONS["BATCHSWAP"] = "batchSwap";
|
|
15
15
|
FUNCTIONS["GETPOOLTOKENS"] = "getPoolTokens";
|
|
16
|
+
FUNCTIONS["GETPOOL"] = "getPool";
|
|
16
17
|
})(FUNCTIONS || (FUNCTIONS = {}));
|
|
17
18
|
class PoolContract extends index_1.VerifiedContract {
|
|
18
19
|
constructor(signer) {
|
|
@@ -57,7 +58,12 @@ class PoolContract extends index_1.VerifiedContract {
|
|
|
57
58
|
return this.callContract(FUNCTIONS.BATCHSWAP, _kind, _swaps, _assests, _funds, _limits, _deadline, options);
|
|
58
59
|
}
|
|
59
60
|
async getPoolTokens(_poolId, options) {
|
|
61
|
+
await this.validateInput(index_1.DATATYPES.BYTE32, _poolId);
|
|
60
62
|
return this.callContract(FUNCTIONS.GETPOOLTOKENS, _poolId, options);
|
|
61
63
|
}
|
|
64
|
+
async getPool(_poolId, options) {
|
|
65
|
+
await this.validateInput(index_1.DATATYPES.BYTE32, _poolId);
|
|
66
|
+
return this.callContract(FUNCTIONS.GETPOOL, _poolId, options);
|
|
67
|
+
}
|
|
62
68
|
}
|
|
63
69
|
exports.default = PoolContract;
|
|
@@ -25,7 +25,7 @@ export default class Security extends VerifiedContract {
|
|
|
25
25
|
schedule(_time: string, options?: Options): any;
|
|
26
26
|
reschedule(_oldtime: string, _newtime: string, options?: Options): any;
|
|
27
27
|
unschedule(_time: string, options?: Options): any;
|
|
28
|
-
createResolution(_time: string, _votes:
|
|
28
|
+
createResolution(_time: string, _votes: boolean, _ipfslink: string, options?: Options): any;
|
|
29
29
|
countVotes(_time: string, options?: Options): any;
|
|
30
30
|
payoutProrata(_time: string, _wallet: string, _token: string, _amount: string, options?: Options): any;
|
|
31
31
|
payout(_time: string, _holder: string, _wallet: string, _token: string, _amount: string, options?: Options): any;
|
|
@@ -37,5 +37,8 @@ export default class Security extends VerifiedContract {
|
|
|
37
37
|
withdrawFunds(options?: Options): any;
|
|
38
38
|
pushFunds(_holder: string, options?: Options): any;
|
|
39
39
|
updateFundsReceived(options?: Options): any;
|
|
40
|
-
vote(_time: string, _ballot:
|
|
40
|
+
vote(_time: string, _ballot: boolean, options?: Options): any;
|
|
41
|
+
scheduleSnapshot(_time: string, options?: Options): any;
|
|
42
|
+
rescheduleSnapshot(old_time: string, new_time: string, options?: Options): any;
|
|
43
|
+
unscheduleSnapshot(_time: string, options?: Options): any;
|
|
41
44
|
}
|
|
@@ -165,5 +165,18 @@ class Security extends index_1.VerifiedContract {
|
|
|
165
165
|
await this.validateInput(index_1.DATATYPES.BOOLEAN, _ballot);
|
|
166
166
|
return this.callContract(FUNCTIONS.VOTE, _time, _ballot, options);
|
|
167
167
|
}
|
|
168
|
+
async scheduleSnapshot(_time, options) {
|
|
169
|
+
await this.validateInput(index_1.DATATYPES.NUMBER, _time);
|
|
170
|
+
return this.callContract(FUNCTIONS.SCHEDULE, _time, options);
|
|
171
|
+
}
|
|
172
|
+
async rescheduleSnapshot(old_time, new_time, options) {
|
|
173
|
+
await this.validateInput(index_1.DATATYPES.NUMBER, old_time);
|
|
174
|
+
await this.validateInput(index_1.DATATYPES.NUMBER, new_time);
|
|
175
|
+
return this.callContract(FUNCTIONS.RESCHEDULE, old_time, new_time, options);
|
|
176
|
+
}
|
|
177
|
+
async unscheduleSnapshot(_time, options) {
|
|
178
|
+
await this.validateInput(index_1.DATATYPES.NUMBER, _time);
|
|
179
|
+
return this.callContract(FUNCTIONS.UNSCHEDULE, _time, options);
|
|
180
|
+
}
|
|
168
181
|
}
|
|
169
182
|
exports.default = Security;
|
package/dist/utils/constants.js
CHANGED
|
@@ -11,7 +11,7 @@ exports.PaymasterConstants = {
|
|
|
11
11
|
11155111: {
|
|
12
12
|
PAYMASTER_API_KEY: "BuFP2-5w-.5b3daf3a-d044-4dda-819c-4c4d8431df88",
|
|
13
13
|
BUNDLER_API_KEY: "nJPK7B3ru.dd7f7861-190d-41bd-af80-6877f74b8f44",
|
|
14
|
-
RPC_URL: "https://
|
|
14
|
+
RPC_URL: "https://eth-sepolia.public.blastapi.io",
|
|
15
15
|
PAYMENT_TOKEN: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
|
|
16
16
|
},
|
|
17
17
|
//polgon mainnet
|