@shapeshiftoss/swapper 1.14.0 → 1.14.1
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/dist/swappers/zrx/ZrxApprovalNeeded/ZrxApprovalNeeded.js +2 -2
- package/dist/swappers/zrx/ZrxApproveInfinite/ZrxApproveInfinite.js +2 -2
- package/dist/swappers/zrx/ZrxBuildQuoteTx/ZrxBuildQuoteTx.js +2 -2
- package/dist/swappers/zrx/ZrxExecuteQuote/ZrxExecuteQuote.js +2 -2
- package/dist/swappers/zrx/getZrxSendMaxAmount/getZrxSendMaxAmount.js +2 -2
- package/dist/swappers/zrx/utils/helpers/helpers.js +2 -2
- package/dist/swappers/zrx/utils/test-data/setupZrxDeps.d.ts +1 -1
- package/dist/swappers/zrx/utils/test-data/setupZrxDeps.js +1 -1
- package/package.json +1 -1
|
@@ -18,8 +18,8 @@ async function ZrxApprovalNeeded({ adapterManager, web3 }, { quote, wallet }) {
|
|
|
18
18
|
}
|
|
19
19
|
const accountNumber = quote.sellAssetAccountId ? Number(quote.sellAssetAccountId) : 0;
|
|
20
20
|
const adapter = adapterManager.byChain(sellAsset.chain);
|
|
21
|
-
const
|
|
22
|
-
const receiveAddress = await adapter.getAddress({ wallet,
|
|
21
|
+
const bip44Params = adapter.buildBIP44Params({ accountNumber });
|
|
22
|
+
const receiveAddress = await adapter.getAddress({ wallet, bip44Params });
|
|
23
23
|
/**
|
|
24
24
|
* /swap/v1/quote
|
|
25
25
|
* params: {
|
|
@@ -10,10 +10,10 @@ const helpers_1 = require("../utils/helpers/helpers");
|
|
|
10
10
|
const zrxService_1 = require("../utils/zrxService");
|
|
11
11
|
async function ZrxApproveInfinite({ adapterManager, web3 }, { quote, wallet }) {
|
|
12
12
|
const adapter = adapterManager.byChain(types_1.ChainTypes.Ethereum);
|
|
13
|
-
const
|
|
13
|
+
const bip44Params = adapter.buildBIP44Params({
|
|
14
14
|
accountNumber: (0, bignumber_1.bnOrZero)(quote.sellAssetAccountId).toNumber()
|
|
15
15
|
}); // TODO: Add account number
|
|
16
|
-
const receiveAddress = await adapter.getAddress({ wallet,
|
|
16
|
+
const receiveAddress = await adapter.getAddress({ wallet, bip44Params });
|
|
17
17
|
/**
|
|
18
18
|
* /swap/v1/quote
|
|
19
19
|
* params: {
|
|
@@ -53,8 +53,8 @@ async function ZrxBuildQuoteTx({ adapterManager, web3 }, { input, wallet }) {
|
|
|
53
53
|
throw new __1.SwapError(`ZrxSwapper:ZrxBuildQuoteTx buyAsset must be on chain [${types_1.ChainTypes.Ethereum}]`);
|
|
54
54
|
}
|
|
55
55
|
const adapter = adapterManager.byChain(buyAsset.chain);
|
|
56
|
-
const
|
|
57
|
-
const receiveAddress = await adapter.getAddress({ wallet,
|
|
56
|
+
const bip44Params = adapter.buildBIP44Params({ accountNumber: Number(buyAssetAccountId) });
|
|
57
|
+
const receiveAddress = await adapter.getAddress({ wallet, bip44Params });
|
|
58
58
|
if (new bignumber_js_1.default(slippage || 0).gt(constants_1.MAX_SLIPPAGE)) {
|
|
59
59
|
throw new __1.SwapError(`ZrxSwapper:ZrxBuildQuoteTx slippage value of ${slippage} is greater than max slippage value of ${constants_1.MAX_SLIPPAGE}`);
|
|
60
60
|
}
|
|
@@ -24,7 +24,7 @@ async function ZrxExecuteQuote({ adapterManager }, { quote, wallet }) {
|
|
|
24
24
|
// value is 0 for erc20s
|
|
25
25
|
const value = sellAsset.symbol === 'ETH' ? quote.sellAmount : '0';
|
|
26
26
|
const adapter = adapterManager.byChain(sellAsset.chain);
|
|
27
|
-
const
|
|
27
|
+
const bip44Params = adapter.buildBIP44Params({
|
|
28
28
|
accountNumber: Number(quote.sellAssetAccountId)
|
|
29
29
|
});
|
|
30
30
|
let buildTxResponse, signedTx, txid;
|
|
@@ -37,7 +37,7 @@ async function ZrxExecuteQuote({ adapterManager }, { quote, wallet }) {
|
|
|
37
37
|
gasPrice: (0, web3_utils_1.numberToHex)(((_b = (_a = quote.feeData) === null || _a === void 0 ? void 0 : _a.chainSpecific) === null || _b === void 0 ? void 0 : _b.gasPrice) || 0),
|
|
38
38
|
gasLimit: (0, web3_utils_1.numberToHex)(((_d = (_c = quote.feeData) === null || _c === void 0 ? void 0 : _c.chainSpecific) === null || _d === void 0 ? void 0 : _d.estimatedGas) || 0)
|
|
39
39
|
},
|
|
40
|
-
|
|
40
|
+
bip44Params
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
catch (error) {
|
|
@@ -13,10 +13,10 @@ const constants_1 = require("../utils/constants");
|
|
|
13
13
|
async function getZrxSendMaxAmount({ adapterManager }, { wallet, quote, sellAssetAccountId, feeEstimateKey = types_1.chainAdapters.FeeDataKey.Average }) {
|
|
14
14
|
var _a, _b, _c;
|
|
15
15
|
const adapter = adapterManager.byChain(types_1.ChainTypes.Ethereum);
|
|
16
|
-
const
|
|
16
|
+
const bip44Params = adapter.buildBIP44Params({
|
|
17
17
|
accountNumber: (0, bignumber_1.bnOrZero)(sellAssetAccountId).toNumber()
|
|
18
18
|
});
|
|
19
|
-
const ethAddress = await adapter.getAddress({ wallet,
|
|
19
|
+
const ethAddress = await adapter.getAddress({ wallet, bip44Params });
|
|
20
20
|
const account = await adapter.getAccount(ethAddress);
|
|
21
21
|
if (!quote.sellAsset) {
|
|
22
22
|
throw new api_1.SwapError('quote.sellAsset is required');
|
|
@@ -81,7 +81,7 @@ const grantAllowance = async ({ quote, wallet, adapter, erc20Abi, web3 }) => {
|
|
|
81
81
|
const approveTx = erc20Contract.methods
|
|
82
82
|
.approve(quote.allowanceContract, quote.sellAmount)
|
|
83
83
|
.encodeABI();
|
|
84
|
-
const
|
|
84
|
+
const bip44Params = adapter.buildBIP44Params({
|
|
85
85
|
accountNumber: Number(quote.sellAssetAccountId) || 0
|
|
86
86
|
});
|
|
87
87
|
let grantAllowanceTxToSign, signedTx, broadcastedTxId;
|
|
@@ -89,7 +89,7 @@ const grantAllowance = async ({ quote, wallet, adapter, erc20Abi, web3 }) => {
|
|
|
89
89
|
const { txToSign } = await adapter.buildSendTransaction({
|
|
90
90
|
wallet,
|
|
91
91
|
to: quote.sellAsset.tokenId,
|
|
92
|
-
|
|
92
|
+
bip44Params,
|
|
93
93
|
value: '0',
|
|
94
94
|
chainSpecific: {
|
|
95
95
|
erc20ContractAddress: quote.sellAsset.tokenId,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { ChainAdapterManager } from '@shapeshiftoss/chain-adapters';
|
|
3
3
|
import Web3 from 'web3';
|
|
4
4
|
export declare const chainAdapterMockFuncs: {
|
|
5
|
-
|
|
5
|
+
buildBIP44Params: jest.Mock<{
|
|
6
6
|
purpose: number;
|
|
7
7
|
coinType: number;
|
|
8
8
|
accountNumber: number;
|
|
@@ -9,7 +9,7 @@ const types_1 = require("@shapeshiftoss/types");
|
|
|
9
9
|
const web3_1 = __importDefault(require("web3"));
|
|
10
10
|
jest.mock('@shapeshiftoss/chain-adapters');
|
|
11
11
|
exports.chainAdapterMockFuncs = {
|
|
12
|
-
|
|
12
|
+
buildBIP44Params: jest.fn(() => ({ purpose: 44, coinType: 60, accountNumber: 0 })),
|
|
13
13
|
buildSendTransaction: jest.fn(() => Promise.resolve({ txToSign: {} })),
|
|
14
14
|
signTransaction: jest.fn(() => Promise.resolve('signedTx')),
|
|
15
15
|
broadcastTransaction: jest.fn(() => Promise.resolve('broadcastedTx')),
|