carbon-js-sdk 0.11.35 → 0.11.36-beta.2
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/lib/modules/bridge.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import BaseModule from "./base";
|
|
|
4
4
|
export declare class BridgeModule extends BaseModule {
|
|
5
5
|
getRelayFees(relayDenom: string, connectionId: string): Promise<BridgeModule.BridgeRelayFees>;
|
|
6
6
|
withdraw(params: BridgeModule.WithdrawParams, opts?: CarbonTx.SignTxOpts): Promise<import("../CarbonSDK").CarbonWallet.SendTxResponse>;
|
|
7
|
+
withdrawAndExecute(params: BridgeModule.WithdrawAndExecuteParams, opts?: CarbonTx.SignTxOpts): Promise<import("../CarbonSDK").CarbonWallet.SendTxResponse>;
|
|
7
8
|
}
|
|
8
9
|
export declare namespace BridgeModule {
|
|
9
10
|
interface WithdrawParams {
|
|
@@ -15,6 +16,16 @@ export declare namespace BridgeModule {
|
|
|
15
16
|
relayAmount: BigNumber;
|
|
16
17
|
expirySeconds: number;
|
|
17
18
|
}
|
|
19
|
+
interface WithdrawAndExecuteParams {
|
|
20
|
+
connectionId: string;
|
|
21
|
+
executionContract: string;
|
|
22
|
+
executionBytes: Uint8Array;
|
|
23
|
+
tokenDenom: string;
|
|
24
|
+
tokenAmount: BigNumber;
|
|
25
|
+
relayDenom: string;
|
|
26
|
+
relayAmount: BigNumber;
|
|
27
|
+
expirySeconds: number;
|
|
28
|
+
}
|
|
18
29
|
interface BridgeRelayFees {
|
|
19
30
|
deposit: string;
|
|
20
31
|
withdraw: string;
|
package/lib/modules/bridge.js
CHANGED
|
@@ -64,5 +64,37 @@ class BridgeModule extends base_1.default {
|
|
|
64
64
|
}, opts);
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
|
+
// withdrawing + unwrapping to the native token (wETH => ETH)
|
|
68
|
+
withdrawAndExecute(params, opts) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const { connectionId, executionContract, executionBytes, tokenDenom, tokenAmount, relayDenom, relayAmount, expirySeconds, } = params;
|
|
71
|
+
const method = 'withdraw_native';
|
|
72
|
+
const wallet = this.getWallet();
|
|
73
|
+
const walletAddress = wallet.bech32Address;
|
|
74
|
+
const expiryDuration = codec_1.Duration.fromPartial({
|
|
75
|
+
seconds: new long_1.default(expirySeconds),
|
|
76
|
+
});
|
|
77
|
+
const value = CarbonSDK_1.Carbon.Bridge.MsgExecuteFromCarbon.fromPartial({
|
|
78
|
+
creator: walletAddress,
|
|
79
|
+
connectionId,
|
|
80
|
+
executionContract,
|
|
81
|
+
method,
|
|
82
|
+
executionBytes,
|
|
83
|
+
tokens: {
|
|
84
|
+
denom: tokenDenom,
|
|
85
|
+
amount: tokenAmount.toString(10),
|
|
86
|
+
},
|
|
87
|
+
relayFee: {
|
|
88
|
+
denom: relayDenom,
|
|
89
|
+
amount: relayAmount.toString(10),
|
|
90
|
+
},
|
|
91
|
+
expiryDuration,
|
|
92
|
+
});
|
|
93
|
+
return yield wallet.sendTx({
|
|
94
|
+
typeUrl: util_1.CarbonTx.Types.MsgExecuteFromCarbon,
|
|
95
|
+
value,
|
|
96
|
+
}, opts);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
67
99
|
}
|
|
68
100
|
exports.BridgeModule = BridgeModule;
|
|
@@ -27,6 +27,7 @@ const CarbonTx = __importStar(require("../../../util/tx"));
|
|
|
27
27
|
const utils_1 = require("../utils");
|
|
28
28
|
const TxTypes = {
|
|
29
29
|
WithdrawTokenTx: "bridge/MsgWithdrawToken",
|
|
30
|
+
WithdrawAndExecuteTokenTx: "bridge/MsgExecuteFromCarbon",
|
|
30
31
|
};
|
|
31
32
|
const MsgWithdrawToken = {
|
|
32
33
|
aminoType: TxTypes.WithdrawTokenTx,
|
|
@@ -34,7 +35,14 @@ const MsgWithdrawToken = {
|
|
|
34
35
|
expiryDuration: utils_1.ConvertEncType.Duration,
|
|
35
36
|
},
|
|
36
37
|
};
|
|
38
|
+
const MsgWithdrawAndExecuteToken = {
|
|
39
|
+
aminoType: TxTypes.WithdrawAndExecuteTokenTx,
|
|
40
|
+
valueMap: {
|
|
41
|
+
expiryDuration: utils_1.ConvertEncType.Duration,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
37
44
|
const BridgeAmino = {
|
|
38
45
|
[CarbonTx.Types.MsgWithdrawToken]: (0, utils_1.generateAminoType)(MsgWithdrawToken),
|
|
46
|
+
[CarbonTx.Types.MsgExecuteFromCarbon]: (0, utils_1.generateAminoType)(MsgWithdrawAndExecuteToken),
|
|
39
47
|
};
|
|
40
48
|
exports.default = BridgeAmino;
|