@verified-network/verified-sdk 1.4.2 → 1.4.4

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/.env CHANGED
@@ -1,8 +1,8 @@
1
1
  BUNDLER_URL_FIRST_SECTION="https://bundler.biconomy.io/api/v2"
2
2
  BUNDLER_URL_SECTION_SECTION="nJPK7B3ru.dd7f7861-190d-41bd-af80-6877f74b8f44"
3
3
  GENERAL_PAYMASTER_URL="https://paymaster.biconomy.io/api/v1"
4
- 5_PAYMASTER_API_KEY="Al_uud9et.0420c6d3-2343-4fca-9022-c8c8b648444b"
5
- 80001_PAYMASTER_API_KEY="aT9H1rhpM.d1ed09ff-0e2e-4a94-95ef-fdc18422eb41"
6
- 5_CASH_TOKEN_ADDRESS="0x07865c6E87B9F70255377e024ace6630C1Eaa37F"
4
+ # 5_PAYMASTER_API_KEY="Al_uud9et.0420c6d3-2343-4fca-9022-c8c8b648444b" //goerli(chainid 5) not working with biconomy
5
+ 80001_PAYMASTER_API_KEY="aoDXoLOsa.b941e672-e98f-4d56-b9f6-733dca59a87e"
6
+ # 5_CASH_TOKEN_ADDRESS="0x07865c6E87B9F70255377e024ace6630C1Eaa37F" //goerli(chainid 5) not workith biconomy
7
7
  80001_CASH_TOKEN_ADDRESS="0xda5289fcaaf71d52a80a254da614a192b693e977"
8
8
  BICONOMY_REVERT_TOPIC="0x1c4fada7374c0a9ee8841fc38afe82932dc0f8e69012e927f061a8bae611a201"
@@ -44,6 +44,7 @@ class Custody extends index_1.VerifiedContract {
44
44
  }
45
45
  async getCreator(_creator, _pin, options) {
46
46
  await this.validateInput(index_1.DATATYPES.STRING, _creator);
47
+ await this.validateInput(index_1.DATATYPES.NUMBER, _pin);
47
48
  return this.callContract(FUNCTIONS.GETCREATOR, this.sanitiseInput(index_1.DATATYPES.BYTE32, _creator), _pin, options);
48
49
  }
49
50
  async addParticipant(_creator, _id, _participant, _shard, options) {
@@ -63,6 +64,7 @@ class Custody extends index_1.VerifiedContract {
63
64
  await this.validateInput(index_1.DATATYPES.STRING, _creator);
64
65
  await this.validateInput(index_1.DATATYPES.STRING, _id);
65
66
  await this.validateInput(index_1.DATATYPES.STRING, _participant);
67
+ await this.validateInput(index_1.DATATYPES.NUMBER, _pin);
66
68
  return this.callContract(FUNCTIONS.CONFIRMPARTICIPANT, this.sanitiseInput(index_1.DATATYPES.BYTE32, _creator), _id, this.sanitiseInput(index_1.DATATYPES.BYTE32, _participant), _pin, options);
67
69
  }
68
70
  async defineQuorum(_creator, _id, _minParticipants, options) {
@@ -80,6 +82,8 @@ class Custody extends index_1.VerifiedContract {
80
82
  await this.validateInput(index_1.DATATYPES.STRING, _creator);
81
83
  await this.validateInput(index_1.DATATYPES.STRING, _id);
82
84
  await this.validateInput(index_1.DATATYPES.STRING, _participant);
85
+ await this.validateInput(index_1.DATATYPES.STRING, _tx);
86
+ await this.validateInput(index_1.DATATYPES.NUMBER, _pin);
83
87
  return this.callContract(FUNCTIONS.SIGNTRANSACTION, this.sanitiseInput(index_1.DATATYPES.BYTE32, _creator), _id, this.sanitiseInput(index_1.DATATYPES.BYTE32, _participant), _tx, _pin, options);
84
88
  }
85
89
  async checkQuorum(_creator, _id, _participant, _txid, options) {
@@ -10,8 +10,8 @@ const Vault_json_1 = require("../../abi/assetmanager/Vault.json");
10
10
  const contractAddress_1 = __importDefault(require("../../contractAddress"));
11
11
  var FUNCTIONS;
12
12
  (function (FUNCTIONS) {
13
+ FUNCTIONS["SWAP"] = "swap";
13
14
  FUNCTIONS["BATCHSWAP"] = "batchSwap";
14
- FUNCTIONS["SINGLESWAP"] = "swap";
15
15
  FUNCTIONS["GETPOOLTOKENS"] = "getPoolTokens";
16
16
  })(FUNCTIONS || (FUNCTIONS = {}));
17
17
  class PoolContract extends index_1.VerifiedContract {
@@ -20,73 +20,40 @@ class PoolContract extends index_1.VerifiedContract {
20
20
  super(address, JSON.stringify(Vault_json_1.abi), signer);
21
21
  this.contractAddress = address;
22
22
  }
23
- //API below for single and batch swaps, and price and volume data from verified subgraphs for pool
24
- /**
25
- * API to perform Balancer Batch swap
26
- * @params (string _poolId,)
27
- * @returns {address[] memory}
28
- */
29
- async batchSwap(_poolId, _swapType, _limitAmount, _assetIn, _assetOut, _amount, _account, options) {
30
- await this.validateInput(index_1.DATATYPES.STRING, _poolId);
31
- await this.validateInput(index_1.DATATYPES.STRING, _swapType);
32
- await this.validateInput(index_1.DATATYPES.NUMBER, _limitAmount);
33
- await this.validateInput(index_1.DATATYPES.NUMBER, _amount);
34
- await this.validateInput(index_1.DATATYPES.ADDRESS, _account);
35
- await this.validateInput(index_1.DATATYPES.ADDRESS, _assetIn);
36
- await this.validateInput(index_1.DATATYPES.ADDRESS, _assetOut);
37
- const poolTokens = (await this.fetchPoolTokens(_poolId)).response.result[0];
38
- const _assetInIndex = poolTokens.findIndex(address => address.toLowerCase() === _assetIn.toLowerCase());
39
- const _assetOutIndex = poolTokens.findIndex(address => address.toLowerCase() === _assetOut.toLowerCase());
40
- let limitArr = new Array(3).fill(0);
41
- limitArr[_assetInIndex] = _limitAmount;
42
- // Where are the tokens coming from/going to?
43
- const fund_struct = {
44
- "sender": _account,
45
- "recipient": _account,
46
- "fromInternalBalance": false,
47
- "toInternalBalance": false
48
- };
49
- // When should the transaction timeout?
50
- const deadline = "999999999999999999";
51
- const swap_step_struct = [{
52
- poolId: _poolId,
53
- assetInIndex: _assetInIndex,
54
- assetOutIndex: _assetOutIndex,
55
- amount: _amount,
56
- userData: '0x'
57
- }];
58
- const swapKind = _swapType === "Sell" ? 0 : 1;
59
- return this.callContract(FUNCTIONS.BATCHSWAP, swapKind, swap_step_struct, poolTokens, fund_struct, limitArr, deadline, options);
23
+ async swap(_swap, _funds, _limit, _deadline, options) {
24
+ const { poolId, kind, assetIn, assetOut, amount, userData } = _swap;
25
+ const { sender, fromInternalBalance, recipient, toInternalBalance } = _funds;
26
+ await this.validateInput(index_1.DATATYPES.NUMBER, kind);
27
+ await this.validateInput(index_1.DATATYPES.ADDRESS, assetIn);
28
+ await this.validateInput(index_1.DATATYPES.ADDRESS, assetOut);
29
+ await this.validateInput(index_1.DATATYPES.NUMBER, amount);
30
+ await this.validateInput(index_1.DATATYPES.ADDRESS, sender);
31
+ await this.validateInput(index_1.DATATYPES.ADDRESS, recipient);
32
+ await this.validateInput(index_1.DATATYPES.NUMBER, _limit);
33
+ await this.validateInput(index_1.DATATYPES.NUMBER, _deadline);
34
+ return this.callContract(FUNCTIONS.SWAP, _swap, _funds, _limit, _deadline, options);
60
35
  }
61
- async singleSwap(_poolId, _swapType, _assetIn, _assetOut, _limitAmount, _amount, _account, options) {
62
- await this.validateInput(index_1.DATATYPES.STRING, _poolId);
63
- await this.validateInput(index_1.DATATYPES.STRING, _swapType);
64
- await this.validateInput(index_1.DATATYPES.ADDRESS, _assetIn);
65
- await this.validateInput(index_1.DATATYPES.ADDRESS, _assetOut);
66
- await this.validateInput(index_1.DATATYPES.NUMBER, _limitAmount);
67
- await this.validateInput(index_1.DATATYPES.NUMBER, _amount);
68
- await this.validateInput(index_1.DATATYPES.ADDRESS, _account);
69
- const swapKind = _swapType === "Sell" ? 0 : 1;
70
- // Where are the tokens coming from/going to?
71
- const fund_struct = {
72
- "sender": _account,
73
- "recipient": _account,
74
- "fromInternalBalance": false,
75
- "toInternalBalance": false
76
- };
77
- // When should the transaction timeout?
78
- const deadline = "999999999999999999";
79
- const swap_struct = {
80
- poolId: _poolId,
81
- kind: swapKind,
82
- assetIn: _assetIn,
83
- assetOut: _assetOut,
84
- amount: _amount,
85
- userData: '0x'
86
- };
87
- return this.callContract(FUNCTIONS.SINGLESWAP, swap_struct, fund_struct, _limitAmount, deadline, options);
36
+ async batchSwap(_kind, _swaps, _assests, _funds, _limits, _deadline, options) {
37
+ await this.validateInput(index_1.DATATYPES.NUMBER, _kind);
38
+ _swaps.map(async (swp) => {
39
+ const { poolId, assetInIndex, assetOutIndex, amount, userData } = swp;
40
+ await this.validateInput(index_1.DATATYPES.NUMBER, assetInIndex);
41
+ await this.validateInput(index_1.DATATYPES.NUMBER, assetOutIndex);
42
+ await this.validateInput(index_1.DATATYPES.NUMBER, amount);
43
+ });
44
+ _assests.map(async (asst) => {
45
+ await this.validateInput(index_1.DATATYPES.ADDRESS, asst);
46
+ });
47
+ const { sender, fromInternalBalance, recipient, toInternalBalance } = _funds;
48
+ await this.validateInput(index_1.DATATYPES.ADDRESS, sender);
49
+ await this.validateInput(index_1.DATATYPES.ADDRESS, recipient);
50
+ _limits.map(async (lmt) => {
51
+ await this.validateInput(index_1.DATATYPES.NUMBER, lmt);
52
+ });
53
+ await this.validateInput(index_1.DATATYPES.NUMBER, _deadline);
54
+ return this.callContract(FUNCTIONS.BATCHSWAP, _kind, _swaps, _assests, _funds, _limits, _deadline, options);
88
55
  }
89
- async fetchPoolTokens(_poolId, options) {
56
+ async getPoolTokens(_poolId, options) {
90
57
  return this.callContract(FUNCTIONS.GETPOOLTOKENS, _poolId, options);
91
58
  }
92
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verified-network/verified-sdk",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "An SDK to develop applications on the Verified Network",
5
5
  "repository": {
6
6
  "type": "git",