@shapeshiftoss/swapper 8.5.0 → 8.5.3
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.
|
@@ -25,12 +25,6 @@ class SwapperManager {
|
|
|
25
25
|
addSwapper(swapperInstance) {
|
|
26
26
|
validateSwapper(swapperInstance);
|
|
27
27
|
const swapperType = swapperInstance.getType();
|
|
28
|
-
const swapper = this.swappers.get(swapperType);
|
|
29
|
-
if (swapper)
|
|
30
|
-
throw new api_1.SwapError('[addSwapper] - swapper already exists', {
|
|
31
|
-
code: api_1.SwapErrorTypes.MANAGER_ERROR,
|
|
32
|
-
details: { swapperType }
|
|
33
|
-
});
|
|
34
28
|
this.swappers.set(swapperType, swapperInstance);
|
|
35
29
|
return this;
|
|
36
30
|
}
|
|
@@ -4,7 +4,7 @@ import { ApprovalNeededOutput, BuildTradeInput, BuyAssetBySellIdInput, ExecuteTr
|
|
|
4
4
|
import { OsmoSwapperDeps } from './utils/types';
|
|
5
5
|
export declare class OsmosisSwapper implements Swapper<ChainId> {
|
|
6
6
|
readonly name = "Osmosis";
|
|
7
|
-
|
|
7
|
+
supportedAssetIds: string[];
|
|
8
8
|
deps: OsmoSwapperDeps;
|
|
9
9
|
getType(): SwapperType;
|
|
10
10
|
constructor(deps: OsmoSwapperDeps);
|
|
@@ -10,7 +10,7 @@ class OsmosisSwapper {
|
|
|
10
10
|
constructor(deps) {
|
|
11
11
|
this.name = 'Osmosis';
|
|
12
12
|
this.deps = deps;
|
|
13
|
-
this.
|
|
13
|
+
this.supportedAssetIds = [caip_1.cosmosAssetId, caip_1.osmosisAssetId];
|
|
14
14
|
}
|
|
15
15
|
getType() {
|
|
16
16
|
return api_1.SwapperType.Osmosis;
|
|
@@ -52,13 +52,13 @@ class OsmosisSwapper {
|
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
filterBuyAssetsBySellAssetId(args) {
|
|
55
|
-
const { sellAssetId } = args;
|
|
56
|
-
if (!this.
|
|
55
|
+
const { assetIds = [], sellAssetId } = args;
|
|
56
|
+
if (!this.supportedAssetIds.includes(sellAssetId))
|
|
57
57
|
return [];
|
|
58
|
-
return this.
|
|
58
|
+
return assetIds.filter((assetId) => this.supportedAssetIds.includes(assetId) && assetId !== sellAssetId);
|
|
59
59
|
}
|
|
60
60
|
filterAssetIdsBySellable() {
|
|
61
|
-
return this.
|
|
61
|
+
return this.supportedAssetIds;
|
|
62
62
|
}
|
|
63
63
|
async buildTrade(args) {
|
|
64
64
|
const { sellAsset, buyAsset, sellAmount, receiveAddress } = args;
|
|
@@ -174,7 +174,7 @@ const performIbcTransfer = async (input, adapter, wallet, blockBaseUrl, denom, s
|
|
|
174
174
|
})();
|
|
175
175
|
const latestBlock = responseLatestBlock.data.block.header.height;
|
|
176
176
|
const bip44Params = adapter.buildBIP44Params({
|
|
177
|
-
accountNumber:
|
|
177
|
+
accountNumber: 0 // TODO: Use real accountNumbers
|
|
178
178
|
});
|
|
179
179
|
const path = (0, chain_adapters_1.toPath)(bip44Params);
|
|
180
180
|
const addressNList = (0, hdwallet_core_1.bip32ToAddressNList)(path);
|
|
@@ -232,7 +232,7 @@ const buildTradeTx = async ({ osmoAddress, adapter, trade, buyAssetDenom, sellAs
|
|
|
232
232
|
const accountNumber = responseAccount.chainSpecific.accountNumber || '0';
|
|
233
233
|
const sequence = responseAccount.chainSpecific.sequence || '0';
|
|
234
234
|
const bip44Params = adapter.buildBIP44Params({
|
|
235
|
-
accountNumber:
|
|
235
|
+
accountNumber: 0 // TODO: Use real accountNumbers
|
|
236
236
|
});
|
|
237
237
|
const path = (0, chain_adapters_1.toPath)(bip44Params);
|
|
238
238
|
const osmoAddressNList = (0, hdwallet_core_1.bip32ToAddressNList)(path);
|
package/package.json
CHANGED