@verified-network/verified-sdk 1.6.0 → 1.6.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.
@@ -1,5 +1,5 @@
1
1
  import { VerifiedContract } from '../index';
2
- import { VerifiedWallet } from "../../../wallet";
2
+ import { VerifiedWallet } from "../../wallet";
3
3
  export default class Client extends VerifiedContract {
4
4
  contractAddress: string;
5
5
  constructor(signer: VerifiedWallet, contractNetworkAddress: string);
@@ -28,6 +28,12 @@ export declare class VerifiedContract {
28
28
  protected validateInput(type: DATATYPES, data: any): Promise<boolean>;
29
29
  protected sanitiseInput(type: DATATYPES, data: any): any;
30
30
  protected sanitiseOutput(type: DATATYPES, data: any): any;
31
+ /**
32
+ * gets a function state mutability to differenciate between read and write functions
33
+ * @param functionName
34
+ * @returns true or false
35
+ */
36
+ private isReadFunction;
31
37
  /**
32
38
  * Parses output to standard response
33
39
  * @param data
@@ -127,6 +127,19 @@ class VerifiedContract {
127
127
  return data;
128
128
  }
129
129
  }
130
+ /**
131
+ * gets a function state mutability to differenciate between read and write functions
132
+ * @param functionName
133
+ * @returns true or false
134
+ */
135
+ isReadFunction(functionName) {
136
+ const functionFragment = this.abiInterface.getFunction(functionName);
137
+ if (!functionFragment) {
138
+ throw new Error(`Function ${functionName} not found in ABI`);
139
+ }
140
+ return (functionFragment.stateMutability === 'view' ||
141
+ functionFragment.stateMutability === 'pure');
142
+ }
130
143
  /**
131
144
  * Parses output to standard response
132
145
  * @param data
@@ -271,6 +284,11 @@ class VerifiedContract {
271
284
  }
272
285
  }
273
286
  async callContract(functionName, ...args) {
287
+ // Check if the function is a read function
288
+ if (this.isReadFunction(functionName)) {
289
+ console.log("read function will use ethers");
290
+ return await this.callFunctionWithEthers(functionName, ...args);
291
+ }
274
292
  const chainId = await this.signer.getChainId();
275
293
  if (this.supportsGasless(chainId)) {
276
294
  console.log("gassless supported will use userop");
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  // SPDX-License-Identifier: BUSL-1.1
3
3
  // @ts-nocheck
4
+ var __importDefault = (this && this.__importDefault) || function (mod) {
5
+ return (mod && mod.__esModule) ? mod : { "default": mod };
6
+ };
4
7
  Object.defineProperty(exports, "__esModule", { value: true });
5
- const tslib_1 = require("tslib");
6
8
  const index_1 = require("../index");
7
9
  const Vault_json_1 = require("../../abi/assetmanager/Vault.json");
8
- const contractAddress_1 = tslib_1.__importDefault(require("../../contractAddress"));
10
+ const contractAddress_1 = __importDefault(require("../../contractAddress"));
9
11
  var FUNCTIONS;
10
12
  (function (FUNCTIONS) {
11
13
  FUNCTIONS["SWAP"] = "swap";
@@ -28,4 +28,24 @@ export default class Token extends VerifiedContract {
28
28
  gasPrice: number;
29
29
  gasLimit: number;
30
30
  }): any;
31
+ name(): any;
32
+ symbol(): any;
33
+ decimals(): any;
34
+ totalSupply(): any;
35
+ approve(_spender: string, _amount: string, options?: {
36
+ gasPrice: number;
37
+ gasLimit: number;
38
+ }): any;
39
+ allowance(_owner: string, _spender: string, options?: {
40
+ gasPrice: number;
41
+ gasLimit: number;
42
+ }): any;
43
+ increaseAllowance(_spender: string, _addedValue: string, options?: {
44
+ gasPrice: number;
45
+ gasLimit: number;
46
+ }): any;
47
+ decreaseAllowance(_spender: string, _subtractedValue: string, options?: {
48
+ gasPrice: number;
49
+ gasLimit: number;
50
+ }): any;
31
51
  }
@@ -8,9 +8,18 @@ var FUNCTIONS;
8
8
  (function (FUNCTIONS) {
9
9
  FUNCTIONS["TRANSFERFROM"] = "transferFrom";
10
10
  FUNCTIONS["BALANCE"] = "balanceOf";
11
+ FUNCTIONS["NAME"] = "name";
12
+ FUNCTIONS["DECIMALS"] = "decimals";
11
13
  FUNCTIONS["GETISSUER"] = "getIssuer";
12
14
  FUNCTIONS["REQUESTTRANSACTION"] = "requestTransaction";
13
15
  FUNCTIONS["REQUESTTRANSFER"] = "requestTransfer";
16
+ FUNCTIONS["SYMBOL"] = "symbol";
17
+ FUNCTIONS["TOTALSUPPLY"] = "totalSupply";
18
+ FUNCTIONS["TRANSFER"] = "transfer";
19
+ FUNCTIONS["APPROVE"] = "approve";
20
+ FUNCTIONS["ALLOWANCE"] = "allowance";
21
+ FUNCTIONS["INCREASEALLOWANCE"] = "increaseAllowance";
22
+ FUNCTIONS["DECREASEALLOWANCE"] = "decreaseAllowance";
14
23
  })(FUNCTIONS || (FUNCTIONS = {}));
15
24
  class Token extends index_1.VerifiedContract {
16
25
  constructor(signer, bondCurrencyAddress) {
@@ -55,5 +64,37 @@ class Token extends index_1.VerifiedContract {
55
64
  await this.validateInput(index_1.DATATYPES.ADDRESS, _collateralContract);
56
65
  return this.callContract(FUNCTIONS.REQUESTTRANSACTION, _amount, _payer, this.sanitiseInput(index_1.DATATYPES.BYTE32, _collateralName), _collateralContract, options);
57
66
  }
67
+ async name() {
68
+ return this.callContract(FUNCTIONS.NAME);
69
+ }
70
+ async symbol() {
71
+ return this.callContract(FUNCTIONS.SYMBOL);
72
+ }
73
+ async decimals() {
74
+ return this.callContract(FUNCTIONS.DECIMALS);
75
+ }
76
+ async totalSupply() {
77
+ return this.callContract(FUNCTIONS.TOTALSUPPLY);
78
+ }
79
+ async approve(_spender, _amount, options) {
80
+ await this.validateInput(index_1.DATATYPES.ADDRESS, _spender);
81
+ await this.validateInput(index_1.DATATYPES.NUMBER, _amount);
82
+ return this.callContract(FUNCTIONS.APPROVE, _spender, _amount, options);
83
+ }
84
+ async allowance(_owner, _spender, options) {
85
+ await this.validateInput(index_1.DATATYPES.ADDRESS, _spender);
86
+ await this.validateInput(index_1.DATATYPES.ADDRESS, _owner);
87
+ return this.callContract(FUNCTIONS.ALLOWANCE, _owner, _spender, options);
88
+ }
89
+ async increaseAllowance(_spender, _addedValue, options) {
90
+ await this.validateInput(index_1.DATATYPES.ADDRESS, _spender);
91
+ await this.validateInput(index_1.DATATYPES.NUMBER, _addedValue);
92
+ return this.callContract(FUNCTIONS.INCREASEALLOWANCE, _spender, _addedValue, options);
93
+ }
94
+ async decreaseAllowance(_spender, _subtractedValue, options) {
95
+ await this.validateInput(index_1.DATATYPES.ADDRESS, _spender);
96
+ await this.validateInput(index_1.DATATYPES.NUMBER, _subtractedValue);
97
+ return this.callContract(FUNCTIONS.DECREASEALLOWANCE, _spender, _subtractedValue, options);
98
+ }
58
99
  }
59
100
  exports.default = Token;
@@ -242,15 +242,15 @@ const contractAddress = {
242
242
  },
243
243
  //Base Sepolia
244
244
  84532: {
245
- 'Client': '',
246
- 'Factory': '',
247
- 'Cash': '',
248
- 'Bond': '',
249
- 'Token': '',
250
- 'Oracle': '',
251
- 'Rates': '',
252
- 'Security': '',
253
- 'SecuritiesFactory': '',
245
+ 'Client': '0x266d35A820B8e7f1CcAf7f14A24eC2232aE3D010',
246
+ 'Factory': '0x1021A1474dC1630E5781B1676Def04fF7f11Cc0b',
247
+ 'Cash': '0x15323E84AFF1dDFfcE321F05D75c5dB4b4491e9F',
248
+ 'Bond': '0x4464fF4e174CABeC48901d0B990C7fD47e0A5d1B',
249
+ 'Token': '0xE18a3Fcad231BA549aA488Fa984BDaEb0F6B30e5',
250
+ 'Oracle': '0x3DBAa50441669fDdd9100a9f4703F8B53ca991F7',
251
+ 'Rates': '0x127C7ef8D3b60Dd3bE78cDB3b349D1a9cf4368bD',
252
+ 'Security': '0x40b8764740149704A09bF7526b82D92E4c0958a9',
253
+ 'SecuritiesFactory': '0x68497F1380f29b2C41Ca8Ff1Da3B5a3BD8327d4D',
254
254
  'Vitta': '',
255
255
  'Liquidity': '',
256
256
  'Distribution': '',
@@ -260,19 +260,19 @@ const contractAddress = {
260
260
  'BalancerSecondaryIssueManager': '',
261
261
  'MarginTradingPoolFactory': '',
262
262
  'BalancerMarginIssueManager': '',
263
- 'Custody': '0xB1ae3Fc5B16d3736bf0db20606fB9a10b435392c',
264
- 'Compound': '',
263
+ 'Custody': '0x48b14BA34CB0c95779B4049C3B994a5ab43a6385',
264
+ 'Compound': '0xc090208AF73839e2Ec074Db27294548e7d19d8FA',
265
265
  'CASH': {
266
- 'VCUSD': '',
267
- 'VCEUR': '',
268
- 'VCCHF': '',
269
- 'VCINR': ''
266
+ 'VCUSD': '0x1C751BA898D01789af51A9022b7A6f45836a5d6c',
267
+ 'VCEUR': '0xF0736Fa9490C45b5dF5129A461fAA1362795A4c0',
268
+ 'VCCHF': '0x1D2D161C36958a71855413b09d60fd537742BD39',
269
+ 'VCINR': '0x4D602f59d2680c9eB99438a4F707954F46b58e83'
270
270
  },
271
271
  'BOND': {
272
- 'VBUSD': '',
273
- 'VBEUR': '',
274
- 'VCCHF': '',
275
- 'VBINR': ''
272
+ 'VBUSD': '0xD84fEeb3232A8578F83A1e64b5F3C0E440676368',
273
+ 'VBEUR': '0x4A37E3Cd9563Dc3685a963AD565cC72117eFF0Dd',
274
+ 'VCCHF': '0x32ecC3e013f300DE51F0Bd3b91441188d8893c21',
275
+ 'VBINR': '0xA1A42bD9eB738Cac2b21e9421cB49e8364Ce697E'
276
276
  },
277
277
  },
278
278
  100: {
package/dist/index.js CHANGED
@@ -1,47 +1,49 @@
1
1
  "use strict";
2
2
  // SPDX-License-Identifier: BUSL-1.1
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
3
6
  Object.defineProperty(exports, "__esModule", { value: true });
4
7
  exports.contractAddress = exports.utils = exports.Compound = exports.Client = exports.Distribution = exports.SecuritiesFactory = exports.Security = exports.MarginIssueManager = exports.SecondaryIssueManager = exports.PrimaryIssueManager = exports.Rates = exports.Liquidity = exports.Custody = exports.Pool = exports.Token = exports.Factory = exports.Cash = exports.Bond = exports.ERC20 = exports.Provider = exports.VerifiedWallet = void 0;
5
- const tslib_1 = require("tslib");
6
8
  const wallet_1 = require("./wallet");
7
9
  Object.defineProperty(exports, "VerifiedWallet", { enumerable: true, get: function () { return wallet_1.VerifiedWallet; } });
8
10
  const utils_1 = require("./utils");
9
11
  Object.defineProperty(exports, "Provider", { enumerable: true, get: function () { return utils_1.Provider; } });
10
- const erc20_1 = tslib_1.__importDefault(require("./contract/erc20"));
12
+ const erc20_1 = __importDefault(require("./contract/erc20"));
11
13
  exports.ERC20 = erc20_1.default;
12
- const bond_1 = tslib_1.__importDefault(require("./contract/bond"));
14
+ const bond_1 = __importDefault(require("./contract/bond"));
13
15
  exports.Bond = bond_1.default;
14
- const cash_1 = tslib_1.__importDefault(require("./contract/cash"));
16
+ const cash_1 = __importDefault(require("./contract/cash"));
15
17
  exports.Cash = cash_1.default;
16
- const factory_1 = tslib_1.__importDefault(require("./contract/factory"));
18
+ const factory_1 = __importDefault(require("./contract/factory"));
17
19
  exports.Factory = factory_1.default;
18
- const token_1 = tslib_1.__importDefault(require("./contract/token"));
20
+ const token_1 = __importDefault(require("./contract/token"));
19
21
  exports.Token = token_1.default;
20
- const pool_1 = tslib_1.__importDefault(require("./contract/pool"));
22
+ const pool_1 = __importDefault(require("./contract/pool"));
21
23
  exports.Pool = pool_1.default;
22
- const custody_1 = tslib_1.__importDefault(require("./contract/custody"));
24
+ const custody_1 = __importDefault(require("./contract/custody"));
23
25
  exports.Custody = custody_1.default;
24
- const liquidity_1 = tslib_1.__importDefault(require("./contract/liquidity"));
26
+ const liquidity_1 = __importDefault(require("./contract/liquidity"));
25
27
  exports.Liquidity = liquidity_1.default;
26
- const rates_1 = tslib_1.__importDefault(require("./contract/rates"));
28
+ const rates_1 = __importDefault(require("./contract/rates"));
27
29
  exports.Rates = rates_1.default;
28
- const primary_1 = tslib_1.__importDefault(require("./contract/amm/primary"));
30
+ const primary_1 = __importDefault(require("./contract/amm/primary"));
29
31
  exports.PrimaryIssueManager = primary_1.default;
30
- const secondary_1 = tslib_1.__importDefault(require("./contract/amm/secondary"));
32
+ const secondary_1 = __importDefault(require("./contract/amm/secondary"));
31
33
  exports.SecondaryIssueManager = secondary_1.default;
32
- const margin_1 = tslib_1.__importDefault(require("./contract/amm/margin"));
34
+ const margin_1 = __importDefault(require("./contract/amm/margin"));
33
35
  exports.MarginIssueManager = margin_1.default;
34
- const security_1 = tslib_1.__importDefault(require("./contract/security"));
36
+ const security_1 = __importDefault(require("./contract/security"));
35
37
  exports.Security = security_1.default;
36
- const securitiesfactory_1 = tslib_1.__importDefault(require("./contract/securitiesfactory"));
38
+ const securitiesfactory_1 = __importDefault(require("./contract/securitiesfactory"));
37
39
  exports.SecuritiesFactory = securitiesfactory_1.default;
38
- const distribution_1 = tslib_1.__importDefault(require("./contract/distribution"));
40
+ const distribution_1 = __importDefault(require("./contract/distribution"));
39
41
  exports.Distribution = distribution_1.default;
40
- const client_1 = tslib_1.__importDefault(require("./contract/client"));
42
+ const client_1 = __importDefault(require("./contract/client"));
41
43
  exports.Client = client_1.default;
42
- const compound_1 = tslib_1.__importDefault(require("./contract/loans/compound"));
44
+ const compound_1 = __importDefault(require("./contract/loans/compound"));
43
45
  exports.Compound = compound_1.default;
44
46
  const ethers_1 = require("ethers");
45
47
  Object.defineProperty(exports, "utils", { enumerable: true, get: function () { return ethers_1.utils; } });
46
- const contractAddress_1 = tslib_1.__importDefault(require("./contractAddress"));
48
+ const contractAddress_1 = __importDefault(require("./contractAddress"));
47
49
  exports.contractAddress = contractAddress_1.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verified-network/verified-sdk",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "description": "An SDK to develop applications on the Verified Network",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,7 +34,8 @@
34
34
  "@biconomy/account": "^4.1.1",
35
35
  "ethereumjs-tx": "^2.1.2",
36
36
  "ethers": "^5.7.2",
37
- "tslib": "^2.6.2"
37
+ "tslib": "^2.6.2",
38
+ "viem": "^2.12.0"
38
39
  },
39
40
  "devDependencies": {
40
41
  "@types/mocha": "^10.0.6",
package/tsconfig.json CHANGED
@@ -20,7 +20,7 @@
20
20
  // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
21
21
  // "removeComments": true, /* Do not emit comments to output. */
22
22
  // "noEmit": true, /* Do not emit outputs. */
23
- "importHelpers": true, /* Import emit helpers from 'tslib'. */
23
+ // "importHelpers": true, /* Import emit helpers from 'tslib'. */
24
24
  // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
25
25
  // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
26
26
 
@@ -1,24 +0,0 @@
1
- "use strict";
2
- // SPDX-License-Identifier: BUSL-1.1
3
- // @ts-nocheck
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- const index_1 = require("../index");
6
- const Oracle_json_1 = require("../../abi/payments/Oracle.json");
7
- var FUNCTIONS;
8
- (function (FUNCTIONS) {
9
- FUNCTIONS["RESULTRECEIVED"] = "UpdatedRequest";
10
- })(FUNCTIONS || (FUNCTIONS = {}));
11
- class OracleContract extends index_1.VerifiedContract {
12
- constructor(signer, contractNetworkAddress) {
13
- const address = contractNetworkAddress;
14
- super(address, JSON.stringify(Oracle_json_1.abi), signer);
15
- this.contractAddress = address;
16
- }
17
- /*
18
- Watches and notifies event that is emitted when the Verified oracle fetches pricing, exchange and interest rate data.
19
- */
20
- notifyResult(callback) {
21
- this.getEvent(FUNCTIONS.RESULTRECEIVED, callback);
22
- }
23
- }
24
- exports.default = OracleContract;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- // SPDX-License-Identifier: BUSL-1.1
3
- // @ts-nocheck
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- const index_1 = require("../index");
6
- const Vault_json_1 = require("../../abi/assetmanager/Vault.json");
7
- var FUNCTIONS;
8
- (function (FUNCTIONS) {
9
- FUNCTIONS["FUNCTIONNAME"] = "funcName";
10
- })(FUNCTIONS || (FUNCTIONS = {}));
11
- class VaultContract extends index_1.VerifiedContract {
12
- constructor(signer, poolAddress) {
13
- const address = poolAddress;
14
- super(address, JSON.stringify(Vault_json_1.abi), signer);
15
- this.contractAddress = address;
16
- }
17
- }
18
- exports.default = VaultContract;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const index_1 = require("../utils/index");
4
- const index_2 = require("../wallet/index");
5
- const index_3 = require("../index");
6
- const ethers_1 = require("ethers");
7
- const testSecurityFactoryIssueProduct = async (securityFactoryAddress) => {
8
- const INFURA_API_KEY = "95c1322d7c0e44de9ea77cc9eea18534";
9
- const SECURITY_HOLDER_MNEMONICS = "correct galaxy various swap chair assault blue improve ivory pear infant oak";
10
- const sender = index_2.VerifiedWallet.importWallet(SECURITY_HOLDER_MNEMONICS);
11
- const signer = sender.setProvider(index_1.Provider.infuraProvider(80001, INFURA_API_KEY));
12
- const securityFactoryContract = new index_3.SecuritiesFactory(signer, securityFactoryAddress);
13
- const zeroAddress = "0x0000000000000000000000000000000000000000";
14
- const BTCShortBytes = "0x425443";
15
- const currency = "0x07865c6E87B9F70255377e024ace6630C1Eaa37F"; //usdc
16
- const defaultBytes = "0x4346440000000000000000000000000000000000000000000000000000000000";
17
- const indiaBytes = "0x496e646961000000000000000000000000000000000000000000000000000000";
18
- const restrictions = [];
19
- const abiCoder = ethers_1.ethers.utils.defaultAbiCoder;
20
- const encodedArray = abiCoder.encode(["bytes32[]"], [restrictions]);
21
- await securityFactoryContract
22
- .issueSecurity(zeroAddress, defaultBytes, BTCShortBytes, BTCShortBytes, currency, sender.address, sender.address, encodedArray, indiaBytes, "false")
23
- .then(async (res) => {
24
- console.log("Security Issued Succesfully with hash: ", res.response.hash);
25
- securityFactoryContract.notifySecuritiesAdded(async (evnt) => {
26
- const security = evnt.response.result[0];
27
- console.log("added security : ", security, "succesfully");
28
- if (security) {
29
- await securityFactoryContract
30
- .addBalance(security, zeroAddress, sender.address, "1000000000000000000000000")
31
- .then(async (_res) => {
32
- console.log("Security Minted succesfully with hash: ", _res.response.hash);
33
- })
34
- .catch((_err) => {
35
- console.error("Mint security failed with error: ", _err);
36
- });
37
- }
38
- });
39
- })
40
- .catch((err) => {
41
- console.error("issueSecurity failed with error: ", err);
42
- });
43
- };
44
- testSecurityFactoryIssueProduct("0xf1f349C2CBDA5BCAfD7F95b20C812b4A17c9333D");
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const index_1 = require("../utils/index");
4
- const index_2 = require("../wallet/index");
5
- const index_3 = require("../index");
6
- const testSecurityTransfer = async (securityAddress, amount, receiverAddress) => {
7
- const INFURA_API_KEY = "95c1322d7c0e44de9ea77cc9eea18534";
8
- const SECURITY_HOLDER_MNEMONICS = "correct galaxy various swap chair assault blue improve ivory pear infant oak";
9
- const sender = index_2.VerifiedWallet.importWallet(SECURITY_HOLDER_MNEMONICS);
10
- const signer = sender.setProvider(index_1.Provider.infuraProvider(80001, INFURA_API_KEY));
11
- const securityContract = new index_3.Security(signer, securityAddress);
12
- await securityContract
13
- .transfer(receiverAddress, amount)
14
- .then((res) => {
15
- console.log("Transfer succesful with hash: ", res.response.hash);
16
- })
17
- .catch((err) => {
18
- console.log("Transfer failed with error: ", err);
19
- });
20
- };
21
- // testSecurityTransfer(
22
- // "0xd7252bfa14C0Dca5A72d90a28Bb513E0f989Ee1e",
23
- // 1000000000000000000n,
24
- // "0x286a759DACfd0C533B88E42b9e7571040008D778"
25
- // );