@shapeshiftoss/swapper 5.12.1 → 6.1.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AssetId } from '@shapeshiftoss/caip';
|
|
2
2
|
import { Asset, SupportedChainIds } from '@shapeshiftoss/types';
|
|
3
|
-
import { ApprovalNeededOutput, BuyAssetBySellIdInput, Swapper, SwapperType, Trade, TradeQuote, TradeResult, TradeTxs } from '../../api';
|
|
3
|
+
import { ApprovalNeededOutput, BuyAssetBySellIdInput, ExecuteTradeInput, Swapper, SwapperType, Trade, TradeQuote, TradeResult, TradeTxs } from '../../api';
|
|
4
4
|
import { ThorchainSwapperDeps } from './types';
|
|
5
5
|
export declare class ThorchainSwapper implements Swapper {
|
|
6
6
|
private swapSupportedChainIds;
|
|
@@ -16,6 +16,6 @@ export declare class ThorchainSwapper implements Swapper {
|
|
|
16
16
|
filterAssetIdsBySellable(): AssetId[];
|
|
17
17
|
buildTrade(): Promise<Trade<SupportedChainIds>>;
|
|
18
18
|
getTradeQuote(): Promise<TradeQuote<SupportedChainIds>>;
|
|
19
|
-
executeTrade(): Promise<TradeResult>;
|
|
19
|
+
executeTrade(args: ExecuteTradeInput<SupportedChainIds>): Promise<TradeResult>;
|
|
20
20
|
getTradeTxs(): Promise<TradeTxs>;
|
|
21
21
|
}
|
|
@@ -58,8 +58,21 @@ class ThorchainSwapper {
|
|
|
58
58
|
async getTradeQuote() {
|
|
59
59
|
throw new Error('ThorchainSwapper: getTradeQuote unimplemented');
|
|
60
60
|
}
|
|
61
|
-
async executeTrade() {
|
|
62
|
-
|
|
61
|
+
async executeTrade(args) {
|
|
62
|
+
const { trade, wallet } = args;
|
|
63
|
+
const adapter = await this.deps.adapterManager.byChainId(trade.sellAsset.chainId);
|
|
64
|
+
if (trade.sellAsset.chainId === 'eip155:1') {
|
|
65
|
+
const thorTradeEth = trade;
|
|
66
|
+
const signedTx = await adapter.signTransaction({ txToSign: thorTradeEth.txData, wallet });
|
|
67
|
+
const txid = await adapter.broadcastTransaction(signedTx);
|
|
68
|
+
return { tradeId: txid };
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
throw new api_1.SwapError('[executeTrade]: unsupported trade', {
|
|
72
|
+
code: api_1.SwapErrorTypes.SIGN_AND_BROADCAST_FAILED,
|
|
73
|
+
fn: 'executeTrade'
|
|
74
|
+
});
|
|
75
|
+
}
|
|
63
76
|
}
|
|
64
77
|
async getTradeTxs() {
|
|
65
78
|
throw new Error('ThorchainSwapper: executeTrade unimplemented');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapeshiftoss/swapper",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "TODO: description",
|
|
5
5
|
"repository": "https://github.com/shapeshift/lib",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@shapeshiftoss/asset-service": "^4.6.0",
|
|
34
34
|
"@shapeshiftoss/caip": "^5.2.2",
|
|
35
|
-
"@shapeshiftoss/chain-adapters": "^
|
|
35
|
+
"@shapeshiftoss/chain-adapters": "^5.0.0",
|
|
36
36
|
"@shapeshiftoss/errors": "^1.1.1",
|
|
37
37
|
"@shapeshiftoss/hdwallet-core": "^1.23.0",
|
|
38
38
|
"@shapeshiftoss/types": "^4.4.0"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@shapeshiftoss/asset-service": "^4.6.0",
|
|
42
42
|
"@shapeshiftoss/caip": "^5.2.2",
|
|
43
|
-
"@shapeshiftoss/chain-adapters": "^
|
|
43
|
+
"@shapeshiftoss/chain-adapters": "^5.0.0",
|
|
44
44
|
"@shapeshiftoss/errors": "^1.1.1",
|
|
45
45
|
"@shapeshiftoss/hdwallet-core": "^1.23.0",
|
|
46
46
|
"@shapeshiftoss/types": "^4.4.0",
|