@shapeshiftoss/swapper 1.12.0 → 1.13.0

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.
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getZrxSendMaxAmount = void 0;
7
+ const caip_1 = require("@shapeshiftoss/caip");
7
8
  const types_1 = require("@shapeshiftoss/types");
8
9
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
9
10
  const api_1 = require("../../../api");
@@ -23,7 +24,9 @@ async function getZrxSendMaxAmount({ adapterManager }, { wallet, quote, sellAsse
23
24
  const tokenId = (_a = quote.sellAsset) === null || _a === void 0 ? void 0 : _a.tokenId;
24
25
  let balance;
25
26
  if (tokenId) {
26
- balance = (_c = (_b = account.chainSpecific.tokens) === null || _b === void 0 ? void 0 : _b.find((token) => token.contract.toLowerCase() === tokenId.toLowerCase())) === null || _c === void 0 ? void 0 : _c.balance;
27
+ balance = (_c = (_b = account.chainSpecific.tokens) === null || _b === void 0 ? void 0 : _b.find((token) => {
28
+ return caip_1.caip19.fromCAIP19(token.caip19).tokenId === tokenId.toLowerCase();
29
+ })) === null || _c === void 0 ? void 0 : _c.balance;
27
30
  }
28
31
  else {
29
32
  balance = account.balance;
@@ -12,11 +12,16 @@ export declare const chainAdapterMockFuncs: {
12
12
  }>, []>;
13
13
  signTransaction: jest.Mock<Promise<string>, []>;
14
14
  broadcastTransaction: jest.Mock<Promise<string>, []>;
15
+ getInfo: jest.Mock<Promise<{
16
+ data: {
17
+ network: string;
18
+ };
19
+ }>, []>;
15
20
  getAddress: jest.Mock<Promise<string>, []>;
16
21
  getAccount: jest.Mock<Promise<{
17
22
  chainSpecific: {
18
23
  tokens: {
19
- contract: string;
24
+ caip19: string;
20
25
  balance: string;
21
26
  }[];
22
27
  };
@@ -13,9 +13,10 @@ exports.chainAdapterMockFuncs = {
13
13
  buildSendTransaction: jest.fn(() => Promise.resolve({ txToSign: {} })),
14
14
  signTransaction: jest.fn(() => Promise.resolve('signedTx')),
15
15
  broadcastTransaction: jest.fn(() => Promise.resolve('broadcastedTx')),
16
+ getInfo: jest.fn(() => Promise.resolve({ data: { network: 'mainnet' } })),
16
17
  getAddress: jest.fn(() => Promise.resolve('address')),
17
18
  getAccount: jest.fn(() => Promise.resolve({
18
- chainSpecific: { tokens: [{ contract: 'contractAddress', balance: '1000000' }] }
19
+ chainSpecific: { tokens: [{ caip19: 'eip155:1/erc20:contractAddress', balance: '1000000' }] }
19
20
  })),
20
21
  getFeeData: jest.fn(() => Promise.resolve({
21
22
  [types_1.chainAdapters.FeeDataKey.Average]: { txFee: '10000' }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshiftoss/swapper",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
4
4
  "description": "TODO: description",
5
5
  "repository": "https://github.com/shapeshift/lib",
6
6
  "license": "MIT",
@@ -28,12 +28,14 @@
28
28
  },
29
29
  "peerDependencies": {
30
30
  "@shapeshiftoss/asset-service": "^1.6.1",
31
+ "@shapeshiftoss/caip": "^1.6.1",
31
32
  "@shapeshiftoss/chain-adapters": "^1.15.3",
32
33
  "@shapeshiftoss/hdwallet-core": "^1.18.2",
33
34
  "@shapeshiftoss/types": "^1.13.1"
34
35
  },
35
36
  "devDependencies": {
36
37
  "@shapeshiftoss/asset-service": "^1.6.1",
38
+ "@shapeshiftoss/caip": "^1.6.1",
37
39
  "@shapeshiftoss/chain-adapters": "^1.16.2",
38
40
  "@shapeshiftoss/hdwallet-core": "^1.18.2",
39
41
  "@shapeshiftoss/types": "^1.13.1",