@shapeshiftoss/swapper 15.2.0 → 15.2.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.
@@ -154,6 +154,7 @@ class OsmosisSwapper {
154
154
  };
155
155
  }
156
156
  async executeTrade({ trade, wallet }) {
157
+ var _a;
157
158
  const { sellAsset, buyAsset, sellAmountBeforeFeesCryptoBaseUnit: sellAmountCryptoBaseUnit, accountNumber, receiveAddress, } = trade;
158
159
  const isFromOsmo = sellAsset.assetId === caip_1.osmosisAssetId;
159
160
  const sellAssetDenom = helpers_1.symbolDenomMapping[sellAsset.symbol];
@@ -183,7 +184,7 @@ class OsmosisSwapper {
183
184
  };
184
185
  const responseAccount = await cosmosAdapter.getAccount(sellAddress);
185
186
  const sequence = responseAccount.chainSpecific.sequence || '0';
186
- const { tradeId } = await (0, helpers_1.performIbcTransfer)(transfer, cosmosAdapter, wallet, this.deps.osmoUrl, 'uatom', constants_1.COSMO_OSMO_CHANNEL, feeData.fast.txFee, accountNumber.toString(), sequence, gas, 'uatom');
187
+ const { tradeId } = await (0, helpers_1.performIbcTransfer)(transfer, cosmosAdapter, wallet, this.deps.osmoUrl, 'uatom', constants_1.COSMO_OSMO_CHANNEL, feeData.fast.txFee, accountNumber, sequence, gas, 'uatom');
187
188
  cosmosIbcTradeId = tradeId;
188
189
  // wait till confirmed
189
190
  const pollResult = await (0, helpers_1.pollForComplete)(tradeId, this.deps.cosmosUrl);
@@ -207,6 +208,7 @@ class OsmosisSwapper {
207
208
  const cosmosAddress = isFromOsmo ? receiveAddress : sellAddress;
208
209
  const signTxInput = await (0, helpers_1.buildTradeTx)({
209
210
  osmoAddress,
211
+ accountNumber,
210
212
  adapter: osmosisAdapter,
211
213
  buyAssetDenom,
212
214
  sellAssetDenom,
@@ -229,7 +231,7 @@ class OsmosisSwapper {
229
231
  amount,
230
232
  };
231
233
  const ibcResponseAccount = await osmosisAdapter.getAccount(sellAddress);
232
- const ibcAccountNumber = ibcResponseAccount.chainSpecific.accountNumber || '0';
234
+ const ibcAccountNumber = Number(ibcResponseAccount.chainSpecific.accountNumber);
233
235
  const ibcSequence = ibcResponseAccount.chainSpecific.sequence || '0';
234
236
  // delay to ensure all nodes we interact with are up to date at this point
235
237
  // seeing intermittent bugs that suggest the balances and sequence numbers were sometimes off
@@ -239,7 +241,7 @@ class OsmosisSwapper {
239
241
  pageSize: 1,
240
242
  });
241
243
  await (0, helpers_1.performIbcTransfer)(transfer, osmosisAdapter, wallet, this.deps.cosmosUrl, buyAssetDenom, constants_1.OSMO_COSMO_CHANNEL, '0', ibcAccountNumber, ibcSequence, gas, 'uosmo');
242
- return { tradeId, previousCosmosTxid: cosmosTxHistory.transactions[0].txid, cosmosAddress };
244
+ return { tradeId, previousCosmosTxid: (_a = cosmosTxHistory.transactions[0]) === null || _a === void 0 ? void 0 : _a.txid, cosmosAddress };
243
245
  }
244
246
  return { tradeId, previousCosmosTxid: cosmosIbcTradeId };
245
247
  }
@@ -21,10 +21,11 @@ export declare const getRateInfo: (sellAsset: string, buyAsset: string, sellAmou
21
21
  buyAssetTradeFeeUsd: string;
22
22
  buyAmountCryptoBaseUnit: string;
23
23
  }>;
24
- export declare const performIbcTransfer: (input: IbcTransferInput, adapter: CosmosSdkSupportedChainAdapters, wallet: HDWallet, blockBaseUrl: string, denom: string, sourceChannel: string, feeAmount: string, accountNumber: string, sequence: string, gas: string, feeDenom: string) => Promise<TradeResult>;
25
- export declare const buildTradeTx: ({ osmoAddress, adapter, buyAssetDenom, sellAssetDenom, sellAmount, gas, wallet, }: {
24
+ export declare const performIbcTransfer: (input: IbcTransferInput, adapter: CosmosSdkSupportedChainAdapters, wallet: HDWallet, blockBaseUrl: string, denom: string, sourceChannel: string, feeAmount: string, accountNumber: number, sequence: string, gas: string, feeDenom: string) => Promise<TradeResult>;
25
+ export declare const buildTradeTx: ({ osmoAddress, adapter, accountNumber, buyAssetDenom, sellAssetDenom, sellAmount, gas, wallet, }: {
26
26
  osmoAddress: string;
27
27
  adapter: osmosis.ChainAdapter;
28
+ accountNumber: number;
28
29
  buyAssetDenom: string;
29
30
  sellAssetDenom: string;
30
31
  sellAmount: string;
@@ -206,12 +206,13 @@ const performIbcTransfer = async (input, adapter, wallet, blockBaseUrl, denom, s
206
206
  },
207
207
  ],
208
208
  };
209
+ const bip44Params = adapter.getBIP44Params({ accountNumber });
209
210
  const signed = await adapter.signTransaction({
210
211
  txToSign: {
211
212
  tx,
212
- addressNList: (0, chain_adapters_1.toAddressNList)(adapter.getBIP44Params({ accountNumber: 0 })),
213
+ addressNList: (0, chain_adapters_1.toAddressNList)(bip44Params),
213
214
  chain_id: (0, caip_1.fromChainId)(adapter.getChainId()).chainReference,
214
- account_number: accountNumber,
215
+ account_number: accountNumber.toString(),
215
216
  sequence,
216
217
  },
217
218
  wallet,
@@ -223,9 +224,8 @@ const performIbcTransfer = async (input, adapter, wallet, blockBaseUrl, denom, s
223
224
  };
224
225
  exports.performIbcTransfer = performIbcTransfer;
225
226
  // TODO: move to chain adapters
226
- const buildTradeTx = async ({ osmoAddress, adapter, buyAssetDenom, sellAssetDenom, sellAmount, gas, wallet, }) => {
227
+ const buildTradeTx = async ({ osmoAddress, adapter, accountNumber, buyAssetDenom, sellAssetDenom, sellAmount, gas, wallet, }) => {
227
228
  const responseAccount = await adapter.getAccount(osmoAddress);
228
- const accountNumber = responseAccount.chainSpecific.accountNumber || '0';
229
229
  const sequence = responseAccount.chainSpecific.sequence || '0';
230
230
  const tx = {
231
231
  memo: '',
@@ -259,12 +259,13 @@ const buildTradeTx = async ({ osmoAddress, adapter, buyAssetDenom, sellAssetDeno
259
259
  },
260
260
  ],
261
261
  };
262
+ const bip44Params = adapter.getBIP44Params({ accountNumber });
262
263
  return {
263
264
  txToSign: {
264
265
  tx,
265
- addressNList: (0, chain_adapters_1.toAddressNList)(adapter.getBIP44Params({ accountNumber: 0 })),
266
+ addressNList: (0, chain_adapters_1.toAddressNList)(bip44Params),
266
267
  chain_id: caip_1.CHAIN_REFERENCE.OsmosisMainnet,
267
- account_number: accountNumber,
268
+ account_number: accountNumber.toString(),
268
269
  sequence,
269
270
  },
270
271
  wallet,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshiftoss/swapper",
3
- "version": "15.2.0",
3
+ "version": "15.2.1",
4
4
  "description": "An interface and implementations to trade coins via various protocols",
5
5
  "repository": "https://github.com/shapeshift/lib",
6
6
  "license": "MIT",