@defisaver/sdk 1.1.6 → 1.1.7

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,6 +1,6 @@
1
1
  import { AccessListItem, EthAddress } from './types';
2
- type ParamTypes = Array<string | Array<any>>;
3
- type Args = Array<any>;
2
+ declare type ParamTypes = Array<string | Array<any>>;
3
+ declare type Args = Array<any>;
4
4
  /**
5
5
  * Single action that can be executed directly, or combined into a set (ie. supply a vault)
6
6
  *
@@ -7,7 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import Dec from 'decimal.js';
11
10
  import AbiCoder from 'web3-eth-abi';
12
11
  import { Action } from './Action';
13
12
  import ActionAbi from './abis/Action.json';
@@ -42,8 +41,6 @@ export class ActionWithL2 extends Action {
42
41
  return hexNumber.padStart(2, '0');
43
42
  }
44
43
  numberToBytes32(number) {
45
- let hexNumber = new Dec(number).toHex();
46
- hexNumber = hexNumber.slice(2);
47
- return hexNumber.padStart(64, '0');
44
+ return AbiCoder.encodeParameter('bytes32', AbiCoder.encodeParameter('uint256', number)).slice(2);
48
45
  }
49
46
  }
@@ -6,7 +6,7 @@ import { ActionWithL2 } from '../../ActionWithL2';
6
6
  *
7
7
  * @category Flashloans
8
8
  */
9
- type SpecificFlashLoanAction = (Action & FlashLoanId) | (ActionWithL2 & FlashLoanId);
9
+ declare type SpecificFlashLoanAction = (Action & FlashLoanId) | (ActionWithL2 & FlashLoanId);
10
10
  export declare class FLAction extends Action {
11
11
  #private;
12
12
  constructor(specificFLAction: SpecificFlashLoanAction);
@@ -1,17 +1,17 @@
1
- type AccessListItem = {
1
+ declare type AccessListItem = {
2
2
  address: EthAddress;
3
3
  storageKeys: Array<any>;
4
4
  };
5
- type AccessList = Array<Array<any>>;
6
- type AccessLists = {
5
+ declare type AccessList = Array<Array<any>>;
6
+ declare type AccessLists = {
7
7
  [key: string]: AccessList;
8
8
  };
9
- type Config = {
9
+ declare type Config = {
10
10
  chainId: number;
11
11
  testingMode: boolean;
12
12
  [key: string]: any;
13
13
  };
14
- type Network = {
14
+ declare type Network = {
15
15
  chainId: number;
16
16
  chainName: string;
17
17
  blockExplorerUrls: Array<string>;
@@ -23,24 +23,24 @@ type Network = {
23
23
  symbol: string;
24
24
  };
25
25
  };
26
- type Networks = {
26
+ declare type Networks = {
27
27
  ethereum: Network;
28
28
  optimism: Network;
29
29
  arbitrum: Network;
30
30
  base: Network;
31
31
  };
32
- type EthAddress = string;
33
- type bytes32 = string;
34
- type bytes = string | Array<any>;
35
- type uint256 = string;
36
- type uint32 = string;
37
- type uint160 = string;
38
- type uint128 = string;
39
- type uint80 = string;
40
- type uint64 = string;
41
- type uint24 = string;
42
- type uint16 = string;
43
- type uint8 = string;
44
- type int256 = string;
45
- type int24 = string;
32
+ declare type EthAddress = string;
33
+ declare type bytes32 = string;
34
+ declare type bytes = string | Array<any>;
35
+ declare type uint256 = string;
36
+ declare type uint32 = string;
37
+ declare type uint160 = string;
38
+ declare type uint128 = string;
39
+ declare type uint80 = string;
40
+ declare type uint64 = string;
41
+ declare type uint24 = string;
42
+ declare type uint16 = string;
43
+ declare type uint8 = string;
44
+ declare type int256 = string;
45
+ declare type int24 = string;
46
46
  export { AccessList, AccessListItem, AccessLists, Config, Network, Networks, EthAddress, bytes32, bytes, uint256, uint160, uint32, uint128, uint80, uint64, uint24, uint16, uint8, int256, int24, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/sdk",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "",
5
5
  "main": "./umd/index.js",
6
6
  "module": "./esm/src/index.js",
@@ -40,9 +40,9 @@ export class ActionWithL2 extends Action {
40
40
  }
41
41
 
42
42
  numberToBytes32(number:number) {
43
- let hexNumber = new Dec(number).toHex();
44
- hexNumber = hexNumber.slice(2);
45
-
46
- return hexNumber.padStart(64, '0');
43
+ return AbiCoder.encodeParameter(
44
+ 'bytes32',
45
+ AbiCoder.encodeParameter('uint256', number),
46
+ ).slice(2);
47
47
  }
48
48
  }
@@ -0,0 +1,27 @@
1
+ const dfs = require('../umd');
2
+ const {encodeForDsProxyCall, encodeForRecipe} = require('./_actionUtils');
3
+ const {assert} = require('chai');
4
+
5
+ const MAXUINT = '115792089237316195423570985008687907853269984665640564039457584007913129639935';
6
+ const MAXUINT_HEX = 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff';
7
+ describe('ActionWithL2', () => {
8
+
9
+ context('Basic', () => {
10
+ let action;
11
+ it('Constructor', () => {
12
+ action = new dfs.ActionWithL2('MockSwap', '0x0a80C3C540eEF99811f4579fa7b1A0617294e06f', ['uint256', 'address'], [MAXUINT, '0x6b175474e89094c44da98b954eedeac495271d0f'])
13
+ })
14
+ it('numberToBytes32', () => {
15
+ assert(MAXUINT_HEX === action.numberToBytes32(MAXUINT));
16
+ });
17
+ });
18
+ context('AaveV3WithdrawAction', () => {
19
+ let action;
20
+ it('Constructor', () => {
21
+ action = new dfs.actions.aaveV3.AaveV3WithdrawAction(true, '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb', MAXUINT, "0x6b175474e89094c44da98b954eedeac495271d0f", 9);
22
+ })
23
+ it('numberToBytes32', () => {
24
+ assert(action.encodeForL2DsProxyCall() === '0x2895f3aa000901ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6b175474e89094c44da98b954eedeac495271d0f');
25
+ });
26
+ });
27
+ })