@rabby-wallet/rabby-swap 0.0.44 → 0.0.45

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.
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import abiCoder from "web3-eth-abi";
11
- import { CHAINS_ENUM, CHAINS } from "@debank/common";
11
+ import { CHAINS_ENUM } from "@debank/common";
12
12
  import { WrapTokenAddressMap } from "../list";
13
13
  import { isSameAddress } from "../utils";
14
14
  export const SUPPORT_CHAINS = [
@@ -36,14 +36,13 @@ export const SUPPORT_CHAINS = [
36
36
  "SONIC",
37
37
  ];
38
38
  export const getQuote = (options) => __awaiter(void 0, void 0, void 0, function* () {
39
- const chain = CHAINS[options.chain];
40
- if (!SUPPORT_CHAINS.includes(options.chain)) {
41
- throw new Error(`${CHAINS[options.chain]} is not support on 1inch`);
39
+ if (!options.chainServerId || !options.nativeTokenAddress) {
40
+ throw new Error(`lack chainServerId or nativeTokenAddress is not support`);
42
41
  }
43
42
  const wrapTokenAddress = WrapTokenAddressMap[options.chain];
44
43
  let calldata = "";
45
44
  let value = "0";
46
- if (options.fromToken === chain.nativeTokenAddress &&
45
+ if (options.fromToken === options.nativeTokenAddress &&
47
46
  isSameAddress(options.toToken, wrapTokenAddress)) {
48
47
  calldata = abiCoder.encodeFunctionCall({
49
48
  constant: false,
package/dist/quote.d.ts CHANGED
@@ -11,8 +11,10 @@ export interface QuoteParams {
11
11
  feeRate?: number;
12
12
  feeAddress?: string;
13
13
  gasPrice?: number;
14
- chain: CHAINS_ENUM;
14
+ chain?: CHAINS_ENUM;
15
15
  fee?: boolean;
16
+ chainServerId: string;
17
+ nativeTokenAddress: string;
16
18
  }
17
19
  export interface Tx {
18
20
  from: string;
package/dist/utils.js CHANGED
@@ -7,7 +7,7 @@ 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 { CHAINS, CHAINS_ENUM } from "@debank/common";
10
+ import { CHAINS_ENUM } from "@debank/common";
11
11
  import { DEX_ENUM } from "./consts";
12
12
  import { DEX_SPENDER_WHITELIST } from "./list";
13
13
  export const isSameAddress = (addr1, addr2) => {
@@ -16,15 +16,15 @@ export const isSameAddress = (addr1, addr2) => {
16
16
  return addr1.toLowerCase() === addr2.toLowerCase();
17
17
  };
18
18
  export const generateGetQuote = ({ SUPPORT_CHAINS, id, dex, }) => (options, api) => __awaiter(void 0, void 0, void 0, function* () {
19
- if (!SUPPORT_CHAINS.includes(options.chain)) {
20
- throw new Error(`${CHAINS[options.chain]} is not support on ${dex}`);
19
+ if (!options.chainServerId || !options.nativeTokenAddress) {
20
+ throw new Error(`lack chainServerId or nativeTokenAddress is not support}`);
21
21
  }
22
22
  const params = {
23
23
  id: options.userAddress,
24
- chain_id: CHAINS[options.chain].serverId,
24
+ chain_id: options.chainServerId,
25
25
  dex_id: options.chain === CHAINS_ENUM.ETH
26
26
  ? id
27
- : `${CHAINS[options.chain].serverId}_${id}`,
27
+ : `${options.chainServerId}_${id}`,
28
28
  pay_token_id: options.fromToken,
29
29
  pay_token_raw_amount: options.amount,
30
30
  receive_token_id: options.toToken,
@@ -34,7 +34,7 @@ export const generateGetQuote = ({ SUPPORT_CHAINS, id, dex, }) => (options, api)
34
34
  params.fee = true;
35
35
  }
36
36
  const data = yield api.getSwapQuote(params);
37
- const isNativeToken = isSameAddress(data.pay_token.id, CHAINS[options.chain].nativeTokenAddress);
37
+ const isNativeToken = isSameAddress(data.pay_token.id, options.nativeTokenAddress);
38
38
  return {
39
39
  dexFeeDesc: data.dex_fee_desc,
40
40
  tx: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabby-wallet/rabby-swap",
3
- "version": "0.0.44",
3
+ "version": "0.0.45",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {