@verified-network/verified-sdk 2.2.1 → 2.2.3

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.
@@ -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("Mee client transaction failed with error: ", "Receipts lesser than one.");
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("Erc20 payment transaction failed with error: ", (err === null || err === void 0 ? void 0 : err.message) || err);
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: [chains_1.base, chains_1.mainnet, chains_1.gnosis, chains_1.polygon],
505
- transports: [(0, viem_1.http)(), (0, viem_1.http)(), (0, viem_1.http)(), (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, (_c = optionsRaw[0]) === null || _c === void 0 ? void 0 : _c.paymentToken);
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 = ((_d = options[0]) === null || _d === void 0 ? void 0 : _d.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 nexusAccount = await (0, abstractjs_1.toMultichainNexusAccount)({
532
- chains: [chains_1.base, chains_1.mainnet, chains_1.gnosis, chains_1.polygon],
533
- transports: [(0, viem_1.http)(), (0, viem_1.http)(), (0, viem_1.http)(), (0, viem_1.http)()],
534
- signer: _signer,
535
- });
536
- if (paymentTokenAddress) {
537
- //construct calldata for function
538
- try {
539
- let fn = this.contract.populateTransaction[functionName];
540
- let _res = await fn(...args);
541
- const tx1 = {
542
- to: this.contract.address,
543
- data: _res.data,
544
- };
545
- const meeClient = await (0, abstractjs_1.createMeeClient)({
546
- account: nexusAccount,
547
- });
548
- const transactionInstruction = await nexusAccount.build({
549
- type: "default",
550
- data: {
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
- calls: [tx1],
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
- else if ((_b = err === null || err === void 0 ? void 0 : err.message) === null || _b === void 0 ? void 0 : _b.includes("code=INVALID_ARGUMENT")) {
574
- throw new TypeError(`Invalid arguments type`);
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
+ console.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
+ console.error(`Invalid arguments type`);
611
+ }
612
+ console.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
  }
@@ -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: string, _ipfslink: string, options?: Options): any;
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: string, options?: Options): any;
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;
@@ -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://rpc.sepolia.org",
14
+ RPC_URL: "https://eth-sepolia.public.blastapi.io",
15
15
  PAYMENT_TOKEN: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
16
16
  },
17
17
  //polgon mainnet
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verified-network/verified-sdk",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
4
4
  "description": "An SDK to develop applications on the Verified Network",
5
5
  "repository": {
6
6
  "type": "git",