@skip-go/client 1.0.1-alpha-0 → 1.0.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/api/getAssets.js +15 -2
- package/dist/api/getAssetsBetweenChains.js +11 -2
- package/dist/api/getBridges.js +11 -2
- package/dist/api/getChains.js +11 -2
- package/dist/api/getVenues.js +11 -2
- package/dist/api/postAssetsFromSource.js +12 -3
- package/dist/api/postBalances.js +11 -2
- package/dist/api/postIbcOriginAssets.js +11 -2
- package/dist/api/postMessages.js +11 -2
- package/dist/api/postMessagesDirect.js +11 -2
- package/dist/api/postRecommendAssets.js +11 -2
- package/dist/api/postRoute.js +11 -2
- package/dist/api/postSubmitTransaction.js +11 -2
- package/dist/api/postTrackTransaction.js +11 -2
- package/dist/api/postTransactionStatus.js +11 -2
- package/dist/{chunk-DAMZSSOH.cjs → chunk-2WHYWV4Y.js} +2 -2
- package/dist/{chunk-J4LI33TK.cjs → chunk-4XWIXR2P.js} +24 -18
- package/dist/chunk-5KVRQLI5.js +17 -0
- package/dist/{chunk-VI7UMBQ7.cjs → chunk-5ZJBR5AQ.js} +2 -2
- package/dist/{chunk-ISHM4QWP.cjs → chunk-6BTWKTNM.js} +4 -4
- package/dist/chunk-6GJEXV5J.js +130 -0
- package/dist/chunk-ASPVKNJ7.js +242 -0
- package/dist/{chunk-7SK3IFXJ.cjs → chunk-CG5CQQBW.js} +36 -32
- package/dist/chunk-EQLA2SEZ.js +2361 -0
- package/dist/{chunk-32MRDO7V.cjs → chunk-FVSSCQ6C.js} +2 -2
- package/dist/{chunk-5IAEEEOQ.cjs → chunk-GFRPLEJR.js} +227 -217
- package/dist/{chunk-L5V5PASH.cjs → chunk-KYFTM3PI.js} +2 -2
- package/dist/chunk-L2Q5RP6O.js +25 -0
- package/dist/{chunk-URLFWBSC.cjs → chunk-LRIPQQ4M.js} +2 -2
- package/dist/{chunk-ZNXE6PUV.cjs → chunk-PKPZTO4H.js} +10 -9
- package/dist/{chunk-RDOSNDAQ.cjs → chunk-RE2QZJWE.js} +2 -2
- package/dist/{chunk-7OIZPQJB.cjs → chunk-RT5TZAMU.js} +138 -101
- package/dist/chunk-SWYON2RG.js +4 -1
- package/dist/chunk-VQ5SIQWU.js +3 -1
- package/dist/{chunk-LXYLWTNZ.cjs → chunk-X2E2TKVR.js} +2 -2
- package/dist/{chunk-SW3SEQMJ.cjs → chunk-X2YPYBVN.js} +30 -25
- package/dist/{chunk-KDN7RCGP.cjs → chunk-YYNIFO2A.js} +2 -2
- package/dist/{chunk-77ITCT75.cjs → chunk-Z4ZKOUGH.js} +2 -2
- package/dist/{chunk-PNWIJSMA.cjs → chunk-ZG23Z3WY.js} +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +209 -24
- package/dist/public-functions/executeRoute.js +21 -12
- package/dist/public-functions/getFeeInfoForChain.js +14 -5
- package/dist/public-functions/getRecommendedGasPrice.d.ts +1 -1
- package/dist/public-functions/getRecommendedGasPrice.js +16 -7
- package/dist/public-functions/getSigningStargateClient.d.ts +1 -1
- package/dist/public-functions/getSigningStargateClient.js +13 -4
- package/dist/public-functions/setApiOptions.js +11 -2
- package/dist/public-functions/setClientOptions.js +13 -4
- package/package.json +1 -10
- package/dist/api/getAssets.cjs +0 -15
- package/dist/api/getAssets.d.cts +0 -19
- package/dist/api/getAssetsBetweenChains.cjs +0 -11
- package/dist/api/getAssetsBetweenChains.d.cts +0 -56
- package/dist/api/getBridges.cjs +0 -11
- package/dist/api/getBridges.d.cts +0 -54
- package/dist/api/getChains.cjs +0 -11
- package/dist/api/getChains.d.cts +0 -41
- package/dist/api/getVenues.cjs +0 -11
- package/dist/api/getVenues.d.cts +0 -13
- package/dist/api/postAssetsFromSource.cjs +0 -12
- package/dist/api/postAssetsFromSource.d.cts +0 -13
- package/dist/api/postBalances.cjs +0 -11
- package/dist/api/postBalances.d.cts +0 -35
- package/dist/api/postIbcOriginAssets.cjs +0 -11
- package/dist/api/postIbcOriginAssets.d.cts +0 -32
- package/dist/api/postMessages.cjs +0 -11
- package/dist/api/postMessages.d.cts +0 -528
- package/dist/api/postMessagesDirect.cjs +0 -11
- package/dist/api/postMessagesDirect.d.cts +0 -568
- package/dist/api/postRecommendAssets.cjs +0 -11
- package/dist/api/postRecommendAssets.d.cts +0 -40
- package/dist/api/postRoute.cjs +0 -11
- package/dist/api/postRoute.d.cts +0 -460
- package/dist/api/postSubmitTransaction.cjs +0 -11
- package/dist/api/postSubmitTransaction.d.cts +0 -13
- package/dist/api/postTrackTransaction.cjs +0 -11
- package/dist/api/postTrackTransaction.d.cts +0 -13
- package/dist/api/postTransactionStatus.cjs +0 -11
- package/dist/api/postTransactionStatus.d.cts +0 -559
- package/dist/apiState-CdzxTxYd.d.cts +0 -6
- package/dist/chunk-33K6EESX.js +0 -10
- package/dist/chunk-3N7XVGLX.js +0 -269
- package/dist/chunk-3OZQ35X3.js +0 -3597
- package/dist/chunk-44PBLFB5.cjs +0 -24
- package/dist/chunk-4JJWOILI.js +0 -13
- package/dist/chunk-4R6OCWRR.cjs +0 -1346
- package/dist/chunk-BQTQJQ5E.js +0 -10
- package/dist/chunk-BRJDNGYH.js +0 -22
- package/dist/chunk-BRMONS6A.js +0 -130
- package/dist/chunk-C2EDPY6J.js +0 -10
- package/dist/chunk-DW4U6YI6.js +0 -10
- package/dist/chunk-ED2OY55G.cjs +0 -136
- package/dist/chunk-GARVPN2H.js +0 -16
- package/dist/chunk-HAR3IXDE.cjs +0 -705
- package/dist/chunk-JTIHU43D.js +0 -183
- package/dist/chunk-KNV72XRZ.js +0 -10
- package/dist/chunk-KZOSEIWH.cjs +0 -10
- package/dist/chunk-MGVXJ2U4.js +0 -11
- package/dist/chunk-MTMPHY3Y.js +0 -9
- package/dist/chunk-PRQ2NHRZ.js +0 -11
- package/dist/chunk-RDRDFJQE.js +0 -10
- package/dist/chunk-RMP3HM5N.js +0 -14
- package/dist/chunk-SFMBRLUS.cjs +0 -18
- package/dist/chunk-SQGWZAUC.js +0 -2229
- package/dist/chunk-TW77BXMT.js +0 -44
- package/dist/chunk-VMPFHQ7U.js +0 -93
- package/dist/chunk-W2U2UOFA.js +0 -1790
- package/dist/chunk-W6TBGBV3.js +0 -675
- package/dist/chunk-WWNTHZ6I.cjs +0 -1812
- package/dist/client-types-qvyKvyFh.d.cts +0 -60
- package/dist/executeRoute-BKRpODCc.d.cts +0 -69
- package/dist/generateApi-C0amiydg.d.cts +0 -22
- package/dist/index.cjs +0 -209
- package/dist/index.d.cts +0 -35
- package/dist/public-functions/executeRoute.cjs +0 -21
- package/dist/public-functions/executeRoute.d.cts +0 -9
- package/dist/public-functions/getFeeInfoForChain.cjs +0 -14
- package/dist/public-functions/getFeeInfoForChain.d.cts +0 -9
- package/dist/public-functions/getRecommendedGasPrice.cjs +0 -16
- package/dist/public-functions/getRecommendedGasPrice.d.cts +0 -9
- package/dist/public-functions/getSigningStargateClient.cjs +0 -13
- package/dist/public-functions/getSigningStargateClient.d.cts +0 -13
- package/dist/public-functions/setApiOptions.cjs +0 -11
- package/dist/public-functions/setApiOptions.d.cts +0 -9
- package/dist/public-functions/setClientOptions.cjs +0 -13
- package/dist/public-functions/setClientOptions.d.cts +0 -9
- package/dist/setClientOptions-CT6CHI9I.d.cts +0 -19
- package/dist/swaggerTypes-O9-gvCT1.d.cts +0 -1890
|
@@ -0,0 +1,2361 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkVQ5SIQWU_js = require('./chunk-VQ5SIQWU.js');
|
|
4
|
+
var chunkSWYON2RG_js = require('./chunk-SWYON2RG.js');
|
|
5
|
+
var chunkX2YPYBVN_js = require('./chunk-X2YPYBVN.js');
|
|
6
|
+
var chunkCG5CQQBW_js = require('./chunk-CG5CQQBW.js');
|
|
7
|
+
var chunkRT5TZAMU_js = require('./chunk-RT5TZAMU.js');
|
|
8
|
+
var chunkFVSSCQ6C_js = require('./chunk-FVSSCQ6C.js');
|
|
9
|
+
var chunkKYFTM3PI_js = require('./chunk-KYFTM3PI.js');
|
|
10
|
+
var chunkYYNIFO2A_js = require('./chunk-YYNIFO2A.js');
|
|
11
|
+
var chunk2WHYWV4Y_js = require('./chunk-2WHYWV4Y.js');
|
|
12
|
+
var chunk6GJEXV5J_js = require('./chunk-6GJEXV5J.js');
|
|
13
|
+
var chunkASPVKNJ7_js = require('./chunk-ASPVKNJ7.js');
|
|
14
|
+
var web3_js = require('@solana/web3.js');
|
|
15
|
+
var bech32 = require('bech32');
|
|
16
|
+
var stargateclient = require('@cosmjs/stargate/build/stargateclient');
|
|
17
|
+
var tx = require('cosmjs-types/cosmos/tx/v1beta1/tx');
|
|
18
|
+
var signer = require('@cosmjs/proto-signing/build/signer');
|
|
19
|
+
var base64 = require('@cosmjs/encoding/build/base64');
|
|
20
|
+
var encoding = require('@cosmjs/encoding');
|
|
21
|
+
var sdkTs = require('@injectivelabs/sdk-ts');
|
|
22
|
+
var tx$3 = require('cosmjs-types/cosmos/bank/v1beta1/tx');
|
|
23
|
+
var tx$2 = require('cosmjs-types/cosmwasm/wasm/v1/tx');
|
|
24
|
+
var tx$1 = require('cosmjs-types/ibc/applications/transfer/v1/tx');
|
|
25
|
+
var _m0 = require('protobufjs/minimal');
|
|
26
|
+
var utils = require('@injectivelabs/utils');
|
|
27
|
+
var signing = require('@cosmjs/proto-signing/build/signing');
|
|
28
|
+
var amino = require('@cosmjs/amino');
|
|
29
|
+
var protoSigning = require('@cosmjs/proto-signing');
|
|
30
|
+
var keys = require('cosmjs-types/cosmos/crypto/secp256k1/keys');
|
|
31
|
+
var any = require('cosmjs-types/google/protobuf/any');
|
|
32
|
+
var integers = require('@cosmjs/math/build/integers');
|
|
33
|
+
var signing$1 = require('cosmjs-types/cosmos/tx/signing/v1beta1/signing');
|
|
34
|
+
var viem = require('viem');
|
|
35
|
+
var fee = require('@cosmjs/stargate/build/fee');
|
|
36
|
+
var decimal = require('@cosmjs/math/build/decimal');
|
|
37
|
+
|
|
38
|
+
function _interopNamespace(e) {
|
|
39
|
+
if (e && e.__esModule) return e;
|
|
40
|
+
var n = Object.create(null);
|
|
41
|
+
if (e) {
|
|
42
|
+
Object.keys(e).forEach(function (k) {
|
|
43
|
+
if (k !== 'default') {
|
|
44
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
45
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function () { return e[k]; }
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
n.default = e;
|
|
53
|
+
return Object.freeze(n);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
var _m0__namespace = /*#__PURE__*/_interopNamespace(_m0);
|
|
57
|
+
|
|
58
|
+
// src/types/swaggerTypes.ts
|
|
59
|
+
var AutopilotAction = /* @__PURE__ */ ((AutopilotAction2) => {
|
|
60
|
+
AutopilotAction2["LIQUID_STAKE"] = "LIQUID_STAKE";
|
|
61
|
+
AutopilotAction2["CLAIM"] = "CLAIM";
|
|
62
|
+
return AutopilotAction2;
|
|
63
|
+
})(AutopilotAction || {});
|
|
64
|
+
var AxelarTransferState = /* @__PURE__ */ ((AxelarTransferState2) => {
|
|
65
|
+
AxelarTransferState2["AXELAR_TRANSFER_UNKNOWN"] = "AXELAR_TRANSFER_UNKNOWN";
|
|
66
|
+
AxelarTransferState2["AXELAR_TRANSFER_PENDING_CONFIRMATION"] = "AXELAR_TRANSFER_PENDING_CONFIRMATION";
|
|
67
|
+
AxelarTransferState2["AXELAR_TRANSFER_PENDING_RECEIPT"] = "AXELAR_TRANSFER_PENDING_RECEIPT";
|
|
68
|
+
AxelarTransferState2["AXELAR_TRANSFER_SUCCESS"] = "AXELAR_TRANSFER_SUCCESS";
|
|
69
|
+
AxelarTransferState2["AXELAR_TRANSFER_FAILURE"] = "AXELAR_TRANSFER_FAILURE";
|
|
70
|
+
return AxelarTransferState2;
|
|
71
|
+
})(AxelarTransferState || {});
|
|
72
|
+
var AxelarTransferType = /* @__PURE__ */ ((AxelarTransferType2) => {
|
|
73
|
+
AxelarTransferType2["AXELAR_TRANSFER_CONTRACT_CALL_WITH_TOKEN"] = "AXELAR_TRANSFER_CONTRACT_CALL_WITH_TOKEN";
|
|
74
|
+
AxelarTransferType2["AXELAR_TRANSFER_SEND_TOKEN"] = "AXELAR_TRANSFER_SEND_TOKEN";
|
|
75
|
+
return AxelarTransferType2;
|
|
76
|
+
})(AxelarTransferType || {});
|
|
77
|
+
var CCTPTransferState = /* @__PURE__ */ ((CCTPTransferState2) => {
|
|
78
|
+
CCTPTransferState2["CCTP_TRANSFER_UNKNOWN"] = "CCTP_TRANSFER_UNKNOWN";
|
|
79
|
+
CCTPTransferState2["CCTP_TRANSFER_SENT"] = "CCTP_TRANSFER_SENT";
|
|
80
|
+
CCTPTransferState2["CCTP_TRANSFER_PENDING_CONFIRMATION"] = "CCTP_TRANSFER_PENDING_CONFIRMATION";
|
|
81
|
+
CCTPTransferState2["CCTP_TRANSFER_CONFIRMED"] = "CCTP_TRANSFER_CONFIRMED";
|
|
82
|
+
CCTPTransferState2["CCTP_TRANSFER_RECEIVED"] = "CCTP_TRANSFER_RECEIVED";
|
|
83
|
+
return CCTPTransferState2;
|
|
84
|
+
})(CCTPTransferState || {});
|
|
85
|
+
var StargateTransferState = /* @__PURE__ */ ((StargateTransferState2) => {
|
|
86
|
+
StargateTransferState2["STARGATE_TRANSFER_UNKNOWN"] = "STARGATE_TRANSFER_UNKNOWN";
|
|
87
|
+
StargateTransferState2["STARGATE_TRANSFER_SENT"] = "STARGATE_TRANSFER_SENT";
|
|
88
|
+
StargateTransferState2["STARGATE_TRANSFER_PENDING_CONFIRMATION"] = "STARGATE_TRANSFER_PENDING_CONFIRMATION";
|
|
89
|
+
StargateTransferState2["STARGATE_TRANSFER_CONFIRMED"] = "STARGATE_TRANSFER_CONFIRMED";
|
|
90
|
+
StargateTransferState2["STARGATE_TRANSFER_RECEIVED"] = "STARGATE_TRANSFER_RECEIVED";
|
|
91
|
+
StargateTransferState2["STARGATE_TRANSFER_FAILED"] = "STARGATE_TRANSFER_FAILED";
|
|
92
|
+
return StargateTransferState2;
|
|
93
|
+
})(StargateTransferState || {});
|
|
94
|
+
var GoFastTransferState = /* @__PURE__ */ ((GoFastTransferState2) => {
|
|
95
|
+
GoFastTransferState2["GO_FAST_TRANSFER_UNKNOWN"] = "GO_FAST_TRANSFER_UNKNOWN";
|
|
96
|
+
GoFastTransferState2["GO_FAST_TRANSFER_SENT"] = "GO_FAST_TRANSFER_SENT";
|
|
97
|
+
GoFastTransferState2["GO_FAST_POST_ACTION_FAILED"] = "GO_FAST_POST_ACTION_FAILED";
|
|
98
|
+
GoFastTransferState2["GO_FAST_TRANSFER_TIMEOUT"] = "GO_FAST_TRANSFER_TIMEOUT";
|
|
99
|
+
GoFastTransferState2["GO_FAST_TRANSFER_FILLED"] = "GO_FAST_TRANSFER_FILLED";
|
|
100
|
+
GoFastTransferState2["GO_FAST_TRANSFER_REFUNDED"] = "GO_FAST_TRANSFER_REFUNDED";
|
|
101
|
+
return GoFastTransferState2;
|
|
102
|
+
})(GoFastTransferState || {});
|
|
103
|
+
var BridgeType = /* @__PURE__ */ ((BridgeType2) => {
|
|
104
|
+
BridgeType2["IBC"] = "IBC";
|
|
105
|
+
BridgeType2["AXELAR"] = "AXELAR";
|
|
106
|
+
BridgeType2["CCTP"] = "CCTP";
|
|
107
|
+
BridgeType2["HYPERLANE"] = "HYPERLANE";
|
|
108
|
+
BridgeType2["OPINIT"] = "OPINIT";
|
|
109
|
+
BridgeType2["GO_FAST"] = "GO_FAST";
|
|
110
|
+
BridgeType2["STARGATE"] = "STARGATE";
|
|
111
|
+
BridgeType2["EUREKA"] = "EUREKA";
|
|
112
|
+
return BridgeType2;
|
|
113
|
+
})(BridgeType || {});
|
|
114
|
+
var ChainType = /* @__PURE__ */ ((ChainType2) => {
|
|
115
|
+
ChainType2["Cosmos"] = "cosmos";
|
|
116
|
+
ChainType2["Evm"] = "evm";
|
|
117
|
+
ChainType2["Svm"] = "svm";
|
|
118
|
+
return ChainType2;
|
|
119
|
+
})(ChainType || {});
|
|
120
|
+
var ContractCallWithTokenErrorType = /* @__PURE__ */ ((ContractCallWithTokenErrorType2) => {
|
|
121
|
+
ContractCallWithTokenErrorType2["CONTRACT_CALL_WITH_TOKEN_EXECUTION_ERROR"] = "CONTRACT_CALL_WITH_TOKEN_EXECUTION_ERROR";
|
|
122
|
+
return ContractCallWithTokenErrorType2;
|
|
123
|
+
})(ContractCallWithTokenErrorType || {});
|
|
124
|
+
var HyperlaneTransferState = /* @__PURE__ */ ((HyperlaneTransferState2) => {
|
|
125
|
+
HyperlaneTransferState2["HYPERLANE_TRANSFER_UNKNOWN"] = "HYPERLANE_TRANSFER_UNKNOWN";
|
|
126
|
+
HyperlaneTransferState2["HYPERLANE_TRANSFER_SENT"] = "HYPERLANE_TRANSFER_SENT";
|
|
127
|
+
HyperlaneTransferState2["HYPERLANE_TRANSFER_FAILED"] = "HYPERLANE_TRANSFER_FAILED";
|
|
128
|
+
HyperlaneTransferState2["HYPERLANE_TRANSFER_RECEIVED"] = "HYPERLANE_TRANSFER_RECEIVED";
|
|
129
|
+
return HyperlaneTransferState2;
|
|
130
|
+
})(HyperlaneTransferState || {});
|
|
131
|
+
var PacketErrorType = /* @__PURE__ */ ((PacketErrorType2) => {
|
|
132
|
+
PacketErrorType2["PACKET_ERROR_UNKNOWN"] = "PACKET_ERROR_UNKNOWN";
|
|
133
|
+
PacketErrorType2["PACKET_ERROR_ACKNOWLEDGEMENT"] = "PACKET_ERROR_ACKNOWLEDGEMENT";
|
|
134
|
+
PacketErrorType2["PACKET_ERROR_TIMEOUT"] = "PACKET_ERROR_TIMEOUT";
|
|
135
|
+
return PacketErrorType2;
|
|
136
|
+
})(PacketErrorType || {});
|
|
137
|
+
var Reason = /* @__PURE__ */ ((Reason2) => {
|
|
138
|
+
Reason2["UNKNOWN"] = "UNKNOWN";
|
|
139
|
+
Reason2["MOST_LIQUID"] = "MOST_LIQUID";
|
|
140
|
+
Reason2["BASE_TOKEN"] = "BASE_TOKEN";
|
|
141
|
+
Reason2["DIRECT"] = "DIRECT";
|
|
142
|
+
return Reason2;
|
|
143
|
+
})(Reason || {});
|
|
144
|
+
var RoutePriceWarningType = /* @__PURE__ */ ((RoutePriceWarningType2) => {
|
|
145
|
+
RoutePriceWarningType2["LOW_INFO_WARNING"] = "LOW_INFO_WARNING";
|
|
146
|
+
RoutePriceWarningType2["BAD_PRICE_WARNING"] = "BAD_PRICE_WARNING";
|
|
147
|
+
return RoutePriceWarningType2;
|
|
148
|
+
})(RoutePriceWarningType || {});
|
|
149
|
+
var SendTokenErrorType = /* @__PURE__ */ ((SendTokenErrorType2) => {
|
|
150
|
+
SendTokenErrorType2["SEND_TOKEN_EXECUTION_ERROR"] = "SEND_TOKEN_EXECUTION_ERROR";
|
|
151
|
+
return SendTokenErrorType2;
|
|
152
|
+
})(SendTokenErrorType || {});
|
|
153
|
+
var StatusErrorType = /* @__PURE__ */ ((StatusErrorType2) => {
|
|
154
|
+
StatusErrorType2["STATUS_ERROR_UNKNOWN"] = "STATUS_ERROR_UNKNOWN";
|
|
155
|
+
StatusErrorType2["STATUS_ERROR_TRANSACTION_EXECUTION"] = "STATUS_ERROR_TRANSACTION_EXECUTION";
|
|
156
|
+
StatusErrorType2["STATUS_ERROR_INDEXING"] = "STATUS_ERROR_INDEXING";
|
|
157
|
+
StatusErrorType2["STATUS_ERROR_TRANSFER"] = "STATUS_ERROR_TRANSFER";
|
|
158
|
+
return StatusErrorType2;
|
|
159
|
+
})(StatusErrorType || {});
|
|
160
|
+
var TransactionState = /* @__PURE__ */ ((TransactionState2) => {
|
|
161
|
+
TransactionState2["STATE_SUBMITTED"] = "STATE_SUBMITTED";
|
|
162
|
+
TransactionState2["STATE_PENDING"] = "STATE_PENDING";
|
|
163
|
+
TransactionState2["STATE_COMPLETED_SUCCESS"] = "STATE_COMPLETED_SUCCESS";
|
|
164
|
+
TransactionState2["STATE_COMPLETED_ERROR"] = "STATE_COMPLETED_ERROR";
|
|
165
|
+
TransactionState2["STATE_ABANDONED"] = "STATE_ABANDONED";
|
|
166
|
+
TransactionState2["STATE_PENDING_ERROR"] = "STATE_PENDING_ERROR";
|
|
167
|
+
return TransactionState2;
|
|
168
|
+
})(TransactionState || {});
|
|
169
|
+
var OPInitTransferState = /* @__PURE__ */ ((OPInitTransferState2) => {
|
|
170
|
+
OPInitTransferState2["OPINIT_TRANSFER_UNKNOWN"] = "OPINIT_TRANSFER_UNKNOWN";
|
|
171
|
+
OPInitTransferState2["OPINIT_TRANSFER_SENT"] = "OPINIT_TRANSFER_SENT";
|
|
172
|
+
OPInitTransferState2["OPINIT_TRANSFER_RECEIVED"] = "OPINIT_TRANSFER_RECEIVED";
|
|
173
|
+
return OPInitTransferState2;
|
|
174
|
+
})(OPInitTransferState || {});
|
|
175
|
+
var LayerZeroTransferState = /* @__PURE__ */ ((LayerZeroTransferState2) => {
|
|
176
|
+
LayerZeroTransferState2["LAYER_ZERO_TRANSFER_UNKNOWN"] = "LAYER_ZERO_TRANSFER_UNKNOWN";
|
|
177
|
+
LayerZeroTransferState2["LAYER_ZERO_TRANSFER_SENT"] = "LAYER_ZERO_TRANSFER_SENT";
|
|
178
|
+
LayerZeroTransferState2["LAYER_ZERO_TRANSFER_RECEIVED"] = "LAYER_ZERO_TRANSFER_RECEIVED";
|
|
179
|
+
LayerZeroTransferState2["LAYER_ZERO_TRANSFER_FAILED"] = "LAYER_ZERO_TRANSFER_FAILED";
|
|
180
|
+
return LayerZeroTransferState2;
|
|
181
|
+
})(LayerZeroTransferState || {});
|
|
182
|
+
var TransferState = /* @__PURE__ */ ((TransferState2) => {
|
|
183
|
+
TransferState2["TRANSFER_UNKNOWN"] = "TRANSFER_UNKNOWN";
|
|
184
|
+
TransferState2["TRANSFER_PENDING"] = "TRANSFER_PENDING";
|
|
185
|
+
TransferState2["TRANSFER_RECEIVED"] = "TRANSFER_RECEIVED";
|
|
186
|
+
TransferState2["TRANSFER_SUCCESS"] = "TRANSFER_SUCCESS";
|
|
187
|
+
TransferState2["TRANSFER_FAILURE"] = "TRANSFER_FAILURE";
|
|
188
|
+
return TransferState2;
|
|
189
|
+
})(TransferState || {});
|
|
190
|
+
var FeeType = /* @__PURE__ */ ((FeeType2) => {
|
|
191
|
+
FeeType2["SMART_RELAY"] = "SMART_RELAY";
|
|
192
|
+
return FeeType2;
|
|
193
|
+
})(FeeType || {});
|
|
194
|
+
var ContentType = /* @__PURE__ */ ((ContentType2) => {
|
|
195
|
+
ContentType2["Json"] = "application/json";
|
|
196
|
+
ContentType2["FormData"] = "multipart/form-data";
|
|
197
|
+
ContentType2["UrlEncoded"] = "application/x-www-form-urlencoded";
|
|
198
|
+
ContentType2["Text"] = "text/plain";
|
|
199
|
+
return ContentType2;
|
|
200
|
+
})(ContentType || {});
|
|
201
|
+
var HttpClient = class {
|
|
202
|
+
constructor(apiConfig = {}) {
|
|
203
|
+
this.baseUrl = "https://api.skip.build";
|
|
204
|
+
this.securityData = null;
|
|
205
|
+
this.abortControllers = /* @__PURE__ */ new Map();
|
|
206
|
+
this.customFetch = (...fetchParams) => fetch(...fetchParams);
|
|
207
|
+
this.baseApiParams = {
|
|
208
|
+
credentials: "same-origin",
|
|
209
|
+
headers: {},
|
|
210
|
+
redirect: "follow",
|
|
211
|
+
referrerPolicy: "no-referrer"
|
|
212
|
+
};
|
|
213
|
+
this.setSecurityData = (data) => {
|
|
214
|
+
this.securityData = data;
|
|
215
|
+
};
|
|
216
|
+
this.contentFormatters = {
|
|
217
|
+
["application/json" /* Json */]: (input) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
|
|
218
|
+
["text/plain" /* Text */]: (input) => input !== null && typeof input !== "string" ? JSON.stringify(input) : input,
|
|
219
|
+
["multipart/form-data" /* FormData */]: (input) => Object.keys(input || {}).reduce((formData, key) => {
|
|
220
|
+
const property = input[key];
|
|
221
|
+
formData.append(
|
|
222
|
+
key,
|
|
223
|
+
property instanceof Blob ? property : typeof property === "object" && property !== null ? JSON.stringify(property) : `${property}`
|
|
224
|
+
);
|
|
225
|
+
return formData;
|
|
226
|
+
}, new FormData()),
|
|
227
|
+
["application/x-www-form-urlencoded" /* UrlEncoded */]: (input) => this.toQueryString(input)
|
|
228
|
+
};
|
|
229
|
+
this.createAbortSignal = (cancelToken) => {
|
|
230
|
+
if (this.abortControllers.has(cancelToken)) {
|
|
231
|
+
const abortController2 = this.abortControllers.get(cancelToken);
|
|
232
|
+
if (abortController2) {
|
|
233
|
+
return abortController2.signal;
|
|
234
|
+
}
|
|
235
|
+
return void 0;
|
|
236
|
+
}
|
|
237
|
+
const abortController = new AbortController();
|
|
238
|
+
this.abortControllers.set(cancelToken, abortController);
|
|
239
|
+
return abortController.signal;
|
|
240
|
+
};
|
|
241
|
+
this.abortRequest = (cancelToken) => {
|
|
242
|
+
const abortController = this.abortControllers.get(cancelToken);
|
|
243
|
+
if (abortController) {
|
|
244
|
+
abortController.abort();
|
|
245
|
+
this.abortControllers.delete(cancelToken);
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
this.request = (_a) => chunkASPVKNJ7_js.__async(this, null, function* () {
|
|
249
|
+
var _b = _a, {
|
|
250
|
+
body,
|
|
251
|
+
secure,
|
|
252
|
+
path,
|
|
253
|
+
type,
|
|
254
|
+
query,
|
|
255
|
+
format,
|
|
256
|
+
baseUrl,
|
|
257
|
+
cancelToken
|
|
258
|
+
} = _b, params = chunkASPVKNJ7_js.__objRest(_b, [
|
|
259
|
+
"body",
|
|
260
|
+
"secure",
|
|
261
|
+
"path",
|
|
262
|
+
"type",
|
|
263
|
+
"query",
|
|
264
|
+
"format",
|
|
265
|
+
"baseUrl",
|
|
266
|
+
"cancelToken"
|
|
267
|
+
]);
|
|
268
|
+
const secureParams = (typeof secure === "boolean" ? secure : this.baseApiParams.secure) && this.securityWorker && (yield this.securityWorker(this.securityData)) || {};
|
|
269
|
+
const requestParams = this.mergeRequestParams(params, secureParams);
|
|
270
|
+
const queryString = query && this.toQueryString(query);
|
|
271
|
+
const payloadFormatter = this.contentFormatters[type || "application/json" /* Json */];
|
|
272
|
+
const responseFormat = format || requestParams.format;
|
|
273
|
+
return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, chunkASPVKNJ7_js.__spreadProps(chunkASPVKNJ7_js.__spreadValues({}, requestParams), {
|
|
274
|
+
headers: chunkASPVKNJ7_js.__spreadValues(chunkASPVKNJ7_js.__spreadValues({}, requestParams.headers || {}), type && type !== "multipart/form-data" /* FormData */ ? { "Content-Type": type } : {}),
|
|
275
|
+
signal: (cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal) || null,
|
|
276
|
+
body: typeof body === "undefined" || body === null ? null : payloadFormatter(body)
|
|
277
|
+
})).then((response) => chunkASPVKNJ7_js.__async(this, null, function* () {
|
|
278
|
+
const r = response.clone();
|
|
279
|
+
r.data = null;
|
|
280
|
+
r.error = null;
|
|
281
|
+
const data = !responseFormat ? r : yield response[responseFormat]().then((data2) => {
|
|
282
|
+
if (r.ok) {
|
|
283
|
+
r.data = data2;
|
|
284
|
+
} else {
|
|
285
|
+
r.error = data2;
|
|
286
|
+
}
|
|
287
|
+
return r;
|
|
288
|
+
}).catch((e) => {
|
|
289
|
+
r.error = e;
|
|
290
|
+
return r;
|
|
291
|
+
});
|
|
292
|
+
if (cancelToken) {
|
|
293
|
+
this.abortControllers.delete(cancelToken);
|
|
294
|
+
}
|
|
295
|
+
if (!response.ok) throw data;
|
|
296
|
+
return data;
|
|
297
|
+
}));
|
|
298
|
+
});
|
|
299
|
+
Object.assign(this, apiConfig);
|
|
300
|
+
}
|
|
301
|
+
encodeQueryParam(key, value) {
|
|
302
|
+
const encodedKey = encodeURIComponent(key);
|
|
303
|
+
return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`;
|
|
304
|
+
}
|
|
305
|
+
addQueryParam(query, key) {
|
|
306
|
+
return this.encodeQueryParam(key, query[key]);
|
|
307
|
+
}
|
|
308
|
+
addArrayQueryParam(query, key) {
|
|
309
|
+
const value = query[key];
|
|
310
|
+
return value.map((v) => this.encodeQueryParam(key, v)).join("&");
|
|
311
|
+
}
|
|
312
|
+
toQueryString(rawQuery) {
|
|
313
|
+
const query = rawQuery || {};
|
|
314
|
+
const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]);
|
|
315
|
+
return keys.map((key) => Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key)).join("&");
|
|
316
|
+
}
|
|
317
|
+
addQueryParams(rawQuery) {
|
|
318
|
+
const queryString = this.toQueryString(rawQuery);
|
|
319
|
+
return queryString ? `?${queryString}` : "";
|
|
320
|
+
}
|
|
321
|
+
mergeRequestParams(params1, params2) {
|
|
322
|
+
return chunkASPVKNJ7_js.__spreadProps(chunkASPVKNJ7_js.__spreadValues(chunkASPVKNJ7_js.__spreadValues(chunkASPVKNJ7_js.__spreadValues({}, this.baseApiParams), params1), params2 || {}), {
|
|
323
|
+
headers: chunkASPVKNJ7_js.__spreadValues(chunkASPVKNJ7_js.__spreadValues(chunkASPVKNJ7_js.__spreadValues({}, this.baseApiParams.headers || {}), params1.headers || {}), params2 && params2.headers || {})
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
var Api = class extends HttpClient {
|
|
328
|
+
constructor() {
|
|
329
|
+
super(...arguments);
|
|
330
|
+
/**
|
|
331
|
+
* @description Get all supported chains along with additional data useful for building applications + frontends that interface with them (e.g. logo URI, IBC capabilities, fee assets, bech32 prefix, etc...)
|
|
332
|
+
*
|
|
333
|
+
* @tags Info
|
|
334
|
+
* @name GetChains
|
|
335
|
+
* @request GET:/v2/info/chains
|
|
336
|
+
*/
|
|
337
|
+
this.getChains = (query, params = {}) => this.request(chunkASPVKNJ7_js.__spreadValues({
|
|
338
|
+
path: `/v2/info/chains`,
|
|
339
|
+
method: "GET",
|
|
340
|
+
query,
|
|
341
|
+
format: "json"
|
|
342
|
+
}, params));
|
|
343
|
+
/**
|
|
344
|
+
* @description Get the balances of a given set of assets on a given chain and wallet address. Compatible with all Skip Go-supported assets, excluding CW20 assets, across SVM, EVM, and Cosmos chains.
|
|
345
|
+
*
|
|
346
|
+
* @tags Info
|
|
347
|
+
* @name GetBalances
|
|
348
|
+
* @request POST:/v2/info/balances
|
|
349
|
+
*/
|
|
350
|
+
this.getBalances = (data, params = {}) => this.request(chunkASPVKNJ7_js.__spreadValues({
|
|
351
|
+
path: `/v2/info/balances`,
|
|
352
|
+
method: "POST",
|
|
353
|
+
body: data,
|
|
354
|
+
type: "application/json" /* Json */,
|
|
355
|
+
format: "json"
|
|
356
|
+
}, params));
|
|
357
|
+
/**
|
|
358
|
+
* @description Get all supported bridges
|
|
359
|
+
*
|
|
360
|
+
* @tags Info
|
|
361
|
+
* @name GetBridges
|
|
362
|
+
* @request GET:/v2/info/bridges
|
|
363
|
+
*/
|
|
364
|
+
this.getBridges = (params = {}) => this.request(chunkASPVKNJ7_js.__spreadValues({
|
|
365
|
+
path: `/v2/info/bridges`,
|
|
366
|
+
method: "GET",
|
|
367
|
+
format: "json"
|
|
368
|
+
}, params));
|
|
369
|
+
/**
|
|
370
|
+
* @description Get supported swap venues.
|
|
371
|
+
*
|
|
372
|
+
* @tags Fungible
|
|
373
|
+
* @name GetVenues
|
|
374
|
+
* @request GET:/v2/fungible/venues
|
|
375
|
+
*/
|
|
376
|
+
this.getVenues = (query, params = {}) => this.request(chunkASPVKNJ7_js.__spreadValues({
|
|
377
|
+
path: `/v2/fungible/venues`,
|
|
378
|
+
method: "GET",
|
|
379
|
+
query,
|
|
380
|
+
format: "json"
|
|
381
|
+
}, params));
|
|
382
|
+
/**
|
|
383
|
+
* @description Get supported assets. Optionally limit to assets on a given chain and/or native assets.
|
|
384
|
+
*
|
|
385
|
+
* @tags Fungible
|
|
386
|
+
* @name GetAssets
|
|
387
|
+
* @request GET:/v2/fungible/assets
|
|
388
|
+
*/
|
|
389
|
+
this.getAssets = (query, params = {}) => this.request(chunkASPVKNJ7_js.__spreadValues({
|
|
390
|
+
path: `/v2/fungible/assets`,
|
|
391
|
+
method: "GET",
|
|
392
|
+
query,
|
|
393
|
+
format: "json"
|
|
394
|
+
}, params));
|
|
395
|
+
/**
|
|
396
|
+
* @description Get assets that can be reached from a source via transfers under different conditions (e.g. single vs multiple txs)
|
|
397
|
+
*
|
|
398
|
+
* @tags Fungible
|
|
399
|
+
* @name GetAssetsFromSource
|
|
400
|
+
* @request POST:/v2/fungible/assets_from_source
|
|
401
|
+
*/
|
|
402
|
+
this.getAssetsFromSource = (data, params = {}) => this.request(chunkASPVKNJ7_js.__spreadValues({
|
|
403
|
+
path: `/v2/fungible/assets_from_source`,
|
|
404
|
+
method: "POST",
|
|
405
|
+
body: data,
|
|
406
|
+
type: "application/json" /* Json */,
|
|
407
|
+
format: "json"
|
|
408
|
+
}, params));
|
|
409
|
+
/**
|
|
410
|
+
* @description This supports cross-chain actions among EVM chains, Cosmos chains, and between them. Returns the sequence of transfers and/or swaps to reach the given destination asset from the given source asset, along with estimated amount out. Commonly called before /msgs to generate route info and quote.
|
|
411
|
+
*
|
|
412
|
+
* @tags Fungible
|
|
413
|
+
* @name GetRouteV2
|
|
414
|
+
* @request POST:/v2/fungible/route
|
|
415
|
+
*/
|
|
416
|
+
this.getRouteV2 = (data, params = {}) => this.request(chunkASPVKNJ7_js.__spreadValues({
|
|
417
|
+
path: `/v2/fungible/route`,
|
|
418
|
+
method: "POST",
|
|
419
|
+
body: data,
|
|
420
|
+
type: "application/json" /* Json */,
|
|
421
|
+
format: "json"
|
|
422
|
+
}, params));
|
|
423
|
+
/**
|
|
424
|
+
* @description This supports cross-chain actions among EVM chains, Cosmos chains, and between them. Returns minimal number of messages required to execute a multi-chain swap or transfer. Input consists of the output of route with additional information required for message construction (e.g. destination addresses for each chain)
|
|
425
|
+
*
|
|
426
|
+
* @tags Fungible
|
|
427
|
+
* @name GetMsgsV2
|
|
428
|
+
* @request POST:/v2/fungible/msgs
|
|
429
|
+
*/
|
|
430
|
+
this.getMsgsV2 = (data, params = {}) => this.request(chunkASPVKNJ7_js.__spreadValues({
|
|
431
|
+
path: `/v2/fungible/msgs`,
|
|
432
|
+
method: "POST",
|
|
433
|
+
body: data,
|
|
434
|
+
type: "application/json" /* Json */,
|
|
435
|
+
format: "json"
|
|
436
|
+
}, params));
|
|
437
|
+
/**
|
|
438
|
+
* @description This supports cross-chain actions among EVM chains, Cosmos chains, and between them. Returns minimal number of messages required to execute a multi-chain swap or transfer. This is a convenience endpoint that combines /route and /msgs into a single call.
|
|
439
|
+
*
|
|
440
|
+
* @tags Fungible
|
|
441
|
+
* @name GetMsgsDirectV2
|
|
442
|
+
* @request POST:/v2/fungible/msgs_direct
|
|
443
|
+
*/
|
|
444
|
+
this.getMsgsDirectV2 = (data, params = {}) => this.request(chunkASPVKNJ7_js.__spreadValues({
|
|
445
|
+
path: `/v2/fungible/msgs_direct`,
|
|
446
|
+
method: "POST",
|
|
447
|
+
body: data,
|
|
448
|
+
type: "application/json" /* Json */,
|
|
449
|
+
format: "json"
|
|
450
|
+
}, params));
|
|
451
|
+
/**
|
|
452
|
+
* @description Request asset recommendations for the given source assets on a given destination chain. The response includes recommended destination assets and recommendation reasons.
|
|
453
|
+
*
|
|
454
|
+
* @tags Fungible
|
|
455
|
+
* @name GetAssetRecommendations
|
|
456
|
+
* @request POST:/v2/fungible/recommend_assets
|
|
457
|
+
*/
|
|
458
|
+
this.getAssetRecommendations = (data, params = {}) => this.request(chunkASPVKNJ7_js.__spreadValues({
|
|
459
|
+
path: `/v2/fungible/recommend_assets`,
|
|
460
|
+
method: "POST",
|
|
461
|
+
body: data,
|
|
462
|
+
type: "application/json" /* Json */,
|
|
463
|
+
format: "json"
|
|
464
|
+
}, params));
|
|
465
|
+
/**
|
|
466
|
+
* @description Submit a signed base64 encoded transaction to be broadcast to the specified network. On successful submission, the status of the transaction and any subsequent IBC or Axelar transfers can be queried through the /status endpoint.
|
|
467
|
+
*
|
|
468
|
+
* @tags Transaction
|
|
469
|
+
* @name SubmitTransactionV2
|
|
470
|
+
* @request POST:/v2/tx/submit
|
|
471
|
+
*/
|
|
472
|
+
this.submitTransactionV2 = (data, params = {}) => this.request(chunkASPVKNJ7_js.__spreadValues({
|
|
473
|
+
path: `/v2/tx/submit`,
|
|
474
|
+
method: "POST",
|
|
475
|
+
body: data,
|
|
476
|
+
type: "application/json" /* Json */,
|
|
477
|
+
format: "json"
|
|
478
|
+
}, params));
|
|
479
|
+
/**
|
|
480
|
+
* @description Requests tracking of a transaction that has already landed on-chain but was not broadcast through the Skip Go API. The status of a tracked transaction and subsequent IBC or Axelar transfers if routing assets cross chain can be queried through the /status endpoint.
|
|
481
|
+
*
|
|
482
|
+
* @tags Transaction
|
|
483
|
+
* @name TrackTransactionV2
|
|
484
|
+
* @request POST:/v2/tx/track
|
|
485
|
+
*/
|
|
486
|
+
this.trackTransactionV2 = (data, params = {}) => this.request(chunkASPVKNJ7_js.__spreadValues({
|
|
487
|
+
path: `/v2/tx/track`,
|
|
488
|
+
method: "POST",
|
|
489
|
+
body: data,
|
|
490
|
+
type: "application/json" /* Json */,
|
|
491
|
+
format: "json"
|
|
492
|
+
}, params));
|
|
493
|
+
/**
|
|
494
|
+
* @description Get the status of the specified transaction and any subsequent IBC or Axelar transfers if routing assets cross chain. The transaction must have previously been submitted to either the /submit or /track endpoints.
|
|
495
|
+
*
|
|
496
|
+
* @tags Transaction
|
|
497
|
+
* @name GetTransactionStatusV2
|
|
498
|
+
* @request GET:/v2/tx/status
|
|
499
|
+
*/
|
|
500
|
+
this.getTransactionStatusV2 = (query, params = {}) => this.request(chunkASPVKNJ7_js.__spreadValues({
|
|
501
|
+
path: `/v2/tx/status`,
|
|
502
|
+
method: "GET",
|
|
503
|
+
query,
|
|
504
|
+
format: "json"
|
|
505
|
+
}, params));
|
|
506
|
+
/**
|
|
507
|
+
* @description Get origin assets from a given list of denoms and chain IDs.
|
|
508
|
+
*
|
|
509
|
+
* @tags Fungible
|
|
510
|
+
* @name GetOriginAssets
|
|
511
|
+
* @request POST:/v2/fungible/ibc_origin_assets
|
|
512
|
+
*/
|
|
513
|
+
this.getOriginAssets = (data, params = {}) => this.request(chunkASPVKNJ7_js.__spreadValues({
|
|
514
|
+
path: `/v2/fungible/ibc_origin_assets`,
|
|
515
|
+
method: "POST",
|
|
516
|
+
body: data,
|
|
517
|
+
type: "application/json" /* Json */,
|
|
518
|
+
format: "json"
|
|
519
|
+
}, params));
|
|
520
|
+
/**
|
|
521
|
+
* @description Given 2 chain IDs, returns a list of equivalent assets that can be transferred
|
|
522
|
+
*
|
|
523
|
+
* @tags Fungible
|
|
524
|
+
* @name FungibleAssetsBetweenChainsCreate
|
|
525
|
+
* @request POST:/v2/fungible/assets_between_chains
|
|
526
|
+
*/
|
|
527
|
+
this.fungibleAssetsBetweenChainsCreate = (data, params = {}) => this.request(chunkASPVKNJ7_js.__spreadValues({
|
|
528
|
+
path: `/v2/fungible/assets_between_chains`,
|
|
529
|
+
method: "POST",
|
|
530
|
+
body: data,
|
|
531
|
+
type: "application/json" /* Json */,
|
|
532
|
+
format: "json"
|
|
533
|
+
}, params));
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
// src/private-functions/getRestEndpointForChain.ts
|
|
538
|
+
var getRestEndpointForChain = (chainId) => chunkASPVKNJ7_js.__async(void 0, null, function* () {
|
|
539
|
+
var _a, _b, _c, _d, _e;
|
|
540
|
+
if (chunk6GJEXV5J_js.ClientState.endpointOptions.getRestEndpointForChain) {
|
|
541
|
+
return chunk6GJEXV5J_js.ClientState.endpointOptions.getRestEndpointForChain(chainId);
|
|
542
|
+
}
|
|
543
|
+
if (chunk6GJEXV5J_js.ClientState.endpointOptions.endpoints && chunk6GJEXV5J_js.ClientState.endpointOptions.endpoints[chainId]) {
|
|
544
|
+
const endpointOptions = chunk6GJEXV5J_js.ClientState.endpointOptions.endpoints[chainId];
|
|
545
|
+
if (endpointOptions == null ? void 0 : endpointOptions.rest) {
|
|
546
|
+
return endpointOptions.rest;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
const chain = chunkCG5CQQBW_js.chains().find((chain2) => chain2.chain_id === chainId);
|
|
550
|
+
if (!chain) {
|
|
551
|
+
throw new Error(
|
|
552
|
+
`getRestEndpointForChain error: failed to find chain id '${chainId}' in registry`
|
|
553
|
+
);
|
|
554
|
+
}
|
|
555
|
+
if (((_b = (_a = chain.apis) == null ? void 0 : _a.rest) == null ? void 0 : _b.length) === 0 || !((_c = chain.apis) == null ? void 0 : _c.rest)) {
|
|
556
|
+
throw new Error(
|
|
557
|
+
`getRpcEndpointForChain error: failed to find RPC endpoint for chain '${chainId}'`
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
const endpoints = (_e = (_d = chain.apis) == null ? void 0 : _d.rest) == null ? void 0 : _e.map((api) => api.address);
|
|
561
|
+
const endpoint = yield chunkCG5CQQBW_js.findFirstWorkingEndpoint(endpoints, "rest");
|
|
562
|
+
if (!endpoint) {
|
|
563
|
+
throw new Error(
|
|
564
|
+
`getRestEndpointForChain error: failed to find REST endpoint for chain '${chainId}'`
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
return endpoint;
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
// src/private-functions/getAccountNumberAndSequence.ts
|
|
571
|
+
var getAccountNumberAndSequence = (address, chainId) => chunkASPVKNJ7_js.__async(void 0, null, function* () {
|
|
572
|
+
var _a;
|
|
573
|
+
if (chainId.includes("dymension")) {
|
|
574
|
+
return getAccountNumberAndSequenceFromDymension(address, chainId);
|
|
575
|
+
}
|
|
576
|
+
const endpoint = yield chunkX2YPYBVN_js.getRpcEndpointForChain(chainId);
|
|
577
|
+
const client = (_a = chunk6GJEXV5J_js.ClientState.signingStargateClientByChainId[chainId]) != null ? _a : yield stargateclient.StargateClient.connect(endpoint, {
|
|
578
|
+
accountParser: chunkX2YPYBVN_js.accountParser
|
|
579
|
+
});
|
|
580
|
+
const account = yield client.getAccount(address);
|
|
581
|
+
if (!account) {
|
|
582
|
+
throw new Error("getAccountNumberAndSequence: failed to retrieve account");
|
|
583
|
+
}
|
|
584
|
+
client.disconnect();
|
|
585
|
+
return {
|
|
586
|
+
accountNumber: account.accountNumber,
|
|
587
|
+
sequence: account.sequence
|
|
588
|
+
};
|
|
589
|
+
});
|
|
590
|
+
var getAccountNumberAndSequenceFromDymension = (address, chainId) => chunkASPVKNJ7_js.__async(void 0, null, function* () {
|
|
591
|
+
const endpoint = yield getRestEndpointForChain(chainId);
|
|
592
|
+
const jsonResponse = yield chunkASPVKNJ7_js.createRequestClient({
|
|
593
|
+
baseUrl: `${endpoint}/cosmos/auth/v1beta1/accounts/${address}`
|
|
594
|
+
}).get();
|
|
595
|
+
const response = chunkASPVKNJ7_js.toCamel(jsonResponse);
|
|
596
|
+
let sequence = 0;
|
|
597
|
+
let accountNumber = 0;
|
|
598
|
+
if (response.account.baseAccount) {
|
|
599
|
+
sequence = response.account.baseAccount.sequence;
|
|
600
|
+
accountNumber = response.account.baseAccount.accountNumber;
|
|
601
|
+
} else {
|
|
602
|
+
sequence = response.account.sequence;
|
|
603
|
+
accountNumber = response.account.accountNumber;
|
|
604
|
+
}
|
|
605
|
+
return {
|
|
606
|
+
accountNumber,
|
|
607
|
+
sequence
|
|
608
|
+
};
|
|
609
|
+
});
|
|
610
|
+
function createBaseClawbackVestingAccount() {
|
|
611
|
+
return {
|
|
612
|
+
baseVestingAccount: void 0,
|
|
613
|
+
funderAddress: "",
|
|
614
|
+
startTime: /* @__PURE__ */ new Date(),
|
|
615
|
+
lockupPeriods: [],
|
|
616
|
+
vestingPeriods: []
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
var ClawbackVestingAccount = {
|
|
620
|
+
typeUrl: "/evmos.vesting.v2.ClawbackVestingAccount",
|
|
621
|
+
encode(message, writer = _m0__namespace.Writer.create()) {
|
|
622
|
+
if (message.baseVestingAccount !== void 0) {
|
|
623
|
+
chunkRT5TZAMU_js.BaseVestingAccount.encode(message.baseVestingAccount, writer.uint32(10).fork()).ldelim();
|
|
624
|
+
}
|
|
625
|
+
if (message.funderAddress !== "") {
|
|
626
|
+
writer.uint32(18).string(message.funderAddress);
|
|
627
|
+
}
|
|
628
|
+
if (message.startTime !== void 0) {
|
|
629
|
+
chunkRT5TZAMU_js.Timestamp.encode(chunkRT5TZAMU_js.toTimestamp(message.startTime), writer.uint32(26).fork()).ldelim();
|
|
630
|
+
}
|
|
631
|
+
for (const v of message.lockupPeriods) {
|
|
632
|
+
chunkRT5TZAMU_js.Period.encode(v, writer.uint32(34).fork()).ldelim();
|
|
633
|
+
}
|
|
634
|
+
for (const v of message.vestingPeriods) {
|
|
635
|
+
chunkRT5TZAMU_js.Period.encode(v, writer.uint32(42).fork()).ldelim();
|
|
636
|
+
}
|
|
637
|
+
return writer;
|
|
638
|
+
},
|
|
639
|
+
decode(input, length) {
|
|
640
|
+
const reader = input instanceof _m0__namespace.Reader ? input : new _m0__namespace.Reader(input);
|
|
641
|
+
let end = length === void 0 ? reader.len : reader.pos + length;
|
|
642
|
+
const message = createBaseClawbackVestingAccount();
|
|
643
|
+
while (reader.pos < end) {
|
|
644
|
+
const tag = reader.uint32();
|
|
645
|
+
switch (tag >>> 3) {
|
|
646
|
+
case 1:
|
|
647
|
+
message.baseVestingAccount = chunkRT5TZAMU_js.BaseVestingAccount.decode(reader, reader.uint32());
|
|
648
|
+
break;
|
|
649
|
+
case 2:
|
|
650
|
+
message.funderAddress = reader.string();
|
|
651
|
+
break;
|
|
652
|
+
case 3:
|
|
653
|
+
message.startTime = chunkRT5TZAMU_js.fromTimestamp(chunkRT5TZAMU_js.Timestamp.decode(reader, reader.uint32()));
|
|
654
|
+
break;
|
|
655
|
+
case 4:
|
|
656
|
+
message.lockupPeriods.push(chunkRT5TZAMU_js.Period.decode(reader, reader.uint32()));
|
|
657
|
+
break;
|
|
658
|
+
case 5:
|
|
659
|
+
message.vestingPeriods.push(chunkRT5TZAMU_js.Period.decode(reader, reader.uint32()));
|
|
660
|
+
break;
|
|
661
|
+
default:
|
|
662
|
+
reader.skipType(tag & 7);
|
|
663
|
+
break;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
return message;
|
|
667
|
+
},
|
|
668
|
+
fromJSON(object) {
|
|
669
|
+
return {
|
|
670
|
+
baseVestingAccount: chunkRT5TZAMU_js.isSet(object.baseVestingAccount) ? chunkRT5TZAMU_js.BaseVestingAccount.fromJSON(object.baseVestingAccount) : void 0,
|
|
671
|
+
funderAddress: chunkRT5TZAMU_js.isSet(object.funderAddress) ? String(object.funderAddress) : "",
|
|
672
|
+
startTime: chunkRT5TZAMU_js.isSet(object.startTime) ? chunkRT5TZAMU_js.fromJsonTimestamp(object.startTime) : void 0,
|
|
673
|
+
lockupPeriods: Array.isArray(object == null ? void 0 : object.lockupPeriods) ? object.lockupPeriods.map((e) => chunkRT5TZAMU_js.Period.fromJSON(e)) : [],
|
|
674
|
+
vestingPeriods: Array.isArray(object == null ? void 0 : object.vestingPeriods) ? object.vestingPeriods.map((e) => chunkRT5TZAMU_js.Period.fromJSON(e)) : []
|
|
675
|
+
};
|
|
676
|
+
},
|
|
677
|
+
toJSON(message) {
|
|
678
|
+
const obj = {};
|
|
679
|
+
message.baseVestingAccount !== void 0 && (obj.baseVestingAccount = message.baseVestingAccount ? chunkRT5TZAMU_js.BaseVestingAccount.toJSON(message.baseVestingAccount) : void 0);
|
|
680
|
+
message.funderAddress !== void 0 && (obj.funderAddress = message.funderAddress);
|
|
681
|
+
message.startTime !== void 0 && (obj.startTime = message.startTime.toISOString());
|
|
682
|
+
if (message.lockupPeriods) {
|
|
683
|
+
obj.lockupPeriods = message.lockupPeriods.map((e) => e ? chunkRT5TZAMU_js.Period.toJSON(e) : void 0);
|
|
684
|
+
} else {
|
|
685
|
+
obj.lockupPeriods = [];
|
|
686
|
+
}
|
|
687
|
+
if (message.vestingPeriods) {
|
|
688
|
+
obj.vestingPeriods = message.vestingPeriods.map((e) => e ? chunkRT5TZAMU_js.Period.toJSON(e) : void 0);
|
|
689
|
+
} else {
|
|
690
|
+
obj.vestingPeriods = [];
|
|
691
|
+
}
|
|
692
|
+
return obj;
|
|
693
|
+
},
|
|
694
|
+
fromPartial(object) {
|
|
695
|
+
var _a, _b, _c, _d;
|
|
696
|
+
const message = createBaseClawbackVestingAccount();
|
|
697
|
+
message.baseVestingAccount = object.baseVestingAccount !== void 0 && object.baseVestingAccount !== null ? chunkRT5TZAMU_js.BaseVestingAccount.fromPartial(object.baseVestingAccount) : void 0;
|
|
698
|
+
message.funderAddress = (_a = object.funderAddress) != null ? _a : "";
|
|
699
|
+
message.startTime = (_b = object.startTime) != null ? _b : void 0;
|
|
700
|
+
message.lockupPeriods = ((_c = object.lockupPeriods) == null ? void 0 : _c.map((e) => chunkRT5TZAMU_js.Period.fromPartial(e))) || [];
|
|
701
|
+
message.vestingPeriods = ((_d = object.vestingPeriods) == null ? void 0 : _d.map((e) => chunkRT5TZAMU_js.Period.fromPartial(e))) || [];
|
|
702
|
+
return message;
|
|
703
|
+
},
|
|
704
|
+
fromAmino(object) {
|
|
705
|
+
var _a, _b;
|
|
706
|
+
const message = createBaseClawbackVestingAccount();
|
|
707
|
+
if (object.base_vesting_account !== void 0 && object.base_vesting_account !== null) {
|
|
708
|
+
message.baseVestingAccount = chunkRT5TZAMU_js.BaseVestingAccount.fromAmino(object.base_vesting_account);
|
|
709
|
+
}
|
|
710
|
+
if (object.funder_address !== void 0 && object.funder_address !== null) {
|
|
711
|
+
message.funderAddress = object.funder_address;
|
|
712
|
+
}
|
|
713
|
+
if (object.start_time !== void 0 && object.start_time !== null) {
|
|
714
|
+
message.startTime = chunkRT5TZAMU_js.fromTimestamp(chunkRT5TZAMU_js.Timestamp.fromAmino(object.start_time));
|
|
715
|
+
}
|
|
716
|
+
message.lockupPeriods = ((_a = object.lockup_periods) == null ? void 0 : _a.map((e) => chunkRT5TZAMU_js.Period.fromAmino(e))) || [];
|
|
717
|
+
message.vestingPeriods = ((_b = object.vesting_periods) == null ? void 0 : _b.map((e) => chunkRT5TZAMU_js.Period.fromAmino(e))) || [];
|
|
718
|
+
return message;
|
|
719
|
+
},
|
|
720
|
+
toAmino(message) {
|
|
721
|
+
const obj = {};
|
|
722
|
+
obj.base_vesting_account = message.baseVestingAccount ? chunkRT5TZAMU_js.BaseVestingAccount.toAmino(message.baseVestingAccount) : void 0;
|
|
723
|
+
obj.funder_address = message.funderAddress === "" ? void 0 : message.funderAddress;
|
|
724
|
+
obj.start_time = message.startTime ? chunkRT5TZAMU_js.Timestamp.toAmino(chunkRT5TZAMU_js.toTimestamp(message.startTime)) : void 0;
|
|
725
|
+
if (message.lockupPeriods) {
|
|
726
|
+
obj.lockup_periods = message.lockupPeriods.map((e) => e ? chunkRT5TZAMU_js.Period.toAmino(e) : void 0);
|
|
727
|
+
} else {
|
|
728
|
+
obj.lockup_periods = message.lockupPeriods;
|
|
729
|
+
}
|
|
730
|
+
if (message.vestingPeriods) {
|
|
731
|
+
obj.vesting_periods = message.vestingPeriods.map((e) => e ? chunkRT5TZAMU_js.Period.toAmino(e) : void 0);
|
|
732
|
+
} else {
|
|
733
|
+
obj.vesting_periods = message.vestingPeriods;
|
|
734
|
+
}
|
|
735
|
+
return obj;
|
|
736
|
+
},
|
|
737
|
+
fromAminoMsg(object) {
|
|
738
|
+
return ClawbackVestingAccount.fromAmino(object.value);
|
|
739
|
+
},
|
|
740
|
+
toAminoMsg(message) {
|
|
741
|
+
return {
|
|
742
|
+
type: "vesting/ClawbackVestingAccount",
|
|
743
|
+
value: ClawbackVestingAccount.toAmino(message)
|
|
744
|
+
};
|
|
745
|
+
},
|
|
746
|
+
fromProtoMsg(message) {
|
|
747
|
+
return ClawbackVestingAccount.decode(message.value);
|
|
748
|
+
},
|
|
749
|
+
toProto(message) {
|
|
750
|
+
return ClawbackVestingAccount.encode(message).finish();
|
|
751
|
+
},
|
|
752
|
+
toProtoMsg(message) {
|
|
753
|
+
return {
|
|
754
|
+
typeUrl: "/evmos.vesting.v2.ClawbackVestingAccount",
|
|
755
|
+
value: ClawbackVestingAccount.encode(message).finish()
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
};
|
|
759
|
+
|
|
760
|
+
// src/private-functions/cosmos/getEncodeObjectFromCosmosMessage.ts
|
|
761
|
+
function getEncodeObjectFromCosmosMessage(message) {
|
|
762
|
+
var _a, _b;
|
|
763
|
+
const msgJson = JSON.parse((_a = message.msg) != null ? _a : "");
|
|
764
|
+
if (message.msgTypeUrl === "/ibc.applications.transfer.v1.MsgTransfer") {
|
|
765
|
+
return {
|
|
766
|
+
typeUrl: "/ibc.applications.transfer.v1.MsgTransfer",
|
|
767
|
+
value: tx$1.MsgTransfer.fromJSON({
|
|
768
|
+
sourcePort: msgJson.source_port,
|
|
769
|
+
sourceChannel: msgJson.source_channel,
|
|
770
|
+
token: msgJson.token,
|
|
771
|
+
sender: msgJson.sender,
|
|
772
|
+
receiver: msgJson.receiver,
|
|
773
|
+
timeoutHeight: msgJson.timeout_height,
|
|
774
|
+
timeoutTimestamp: msgJson.timeout_timestamp,
|
|
775
|
+
memo: msgJson.memo
|
|
776
|
+
})
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
if (message.msgTypeUrl === "/cosmwasm.wasm.v1.MsgExecuteContract") {
|
|
780
|
+
return {
|
|
781
|
+
typeUrl: message.msgTypeUrl,
|
|
782
|
+
value: tx$2.MsgExecuteContract.fromPartial({
|
|
783
|
+
sender: msgJson.sender,
|
|
784
|
+
contract: msgJson.contract,
|
|
785
|
+
msg: encoding.toUtf8(JSON.stringify(msgJson.msg)),
|
|
786
|
+
funds: msgJson.funds
|
|
787
|
+
})
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
if (message.msgTypeUrl === "/cosmos.bank.v1beta1.MsgSend") {
|
|
791
|
+
return {
|
|
792
|
+
typeUrl: message.msgTypeUrl,
|
|
793
|
+
value: tx$3.MsgSend.fromPartial({
|
|
794
|
+
fromAddress: msgJson.from_address,
|
|
795
|
+
toAddress: msgJson.to_address,
|
|
796
|
+
amount: msgJson.amount
|
|
797
|
+
})
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
if (message.msgTypeUrl === "/circle.cctp.v1.MsgDepositForBurn") {
|
|
801
|
+
return {
|
|
802
|
+
typeUrl: message.msgTypeUrl,
|
|
803
|
+
value: chunkRT5TZAMU_js.MsgDepositForBurn.fromAmino(msgJson)
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
if (message.msgTypeUrl === "/circle.cctp.v1.MsgDepositForBurnWithCaller") {
|
|
807
|
+
return {
|
|
808
|
+
typeUrl: message.msgTypeUrl,
|
|
809
|
+
value: chunkRT5TZAMU_js.MsgDepositForBurnWithCaller.fromAmino(msgJson)
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
if (message.msgTypeUrl === "/initia.move.v1.MsgExecute") {
|
|
813
|
+
return {
|
|
814
|
+
typeUrl: message.msgTypeUrl,
|
|
815
|
+
value: chunkRT5TZAMU_js.MsgExecute.fromPartial({
|
|
816
|
+
sender: msgJson.sender,
|
|
817
|
+
moduleAddress: msgJson.module_address,
|
|
818
|
+
moduleName: msgJson.module_name,
|
|
819
|
+
functionName: msgJson.function_name,
|
|
820
|
+
args: msgJson.args
|
|
821
|
+
})
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
if (message.msgTypeUrl === "/opinit.ophost.v1.MsgInitiateTokenDeposit") {
|
|
825
|
+
return {
|
|
826
|
+
typeUrl: message.msgTypeUrl,
|
|
827
|
+
value: chunkRT5TZAMU_js.MsgInitiateTokenDeposit.fromPartial({
|
|
828
|
+
sender: msgJson.sender,
|
|
829
|
+
to: msgJson.to,
|
|
830
|
+
amount: msgJson.amount,
|
|
831
|
+
bridgeId: msgJson.bridge_id
|
|
832
|
+
})
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
if (message.msgTypeUrl === "/evmos.vesting.v2.ClawbackVestingAccount") {
|
|
836
|
+
return {
|
|
837
|
+
typeUrl: message.msgTypeUrl,
|
|
838
|
+
value: ClawbackVestingAccount.fromPartial({
|
|
839
|
+
baseVestingAccount: msgJson.base_vesting_account,
|
|
840
|
+
funderAddress: msgJson.funder_address,
|
|
841
|
+
lockupPeriods: msgJson.lockup_periods,
|
|
842
|
+
startTime: msgJson.start_time,
|
|
843
|
+
vestingPeriods: msgJson.vesting_periods
|
|
844
|
+
})
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
return {
|
|
848
|
+
typeUrl: (_b = message.msgTypeUrl) != null ? _b : "",
|
|
849
|
+
value: msgJson
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
function getEncodeObjectFromCosmosMessageInjective(message) {
|
|
853
|
+
var _a;
|
|
854
|
+
const msgJson = JSON.parse((_a = message.msg) != null ? _a : "");
|
|
855
|
+
if (message.msgTypeUrl === "/ibc.applications.transfer.v1.MsgTransfer") {
|
|
856
|
+
return sdkTs.MsgTransfer.fromJSON({
|
|
857
|
+
port: msgJson.source_port,
|
|
858
|
+
channelId: msgJson.source_channel,
|
|
859
|
+
amount: msgJson.token,
|
|
860
|
+
sender: msgJson.sender,
|
|
861
|
+
receiver: msgJson.receiver,
|
|
862
|
+
timeout: msgJson.timeout_timestamp,
|
|
863
|
+
memo: msgJson.memo
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
if (message.msgTypeUrl === "/cosmwasm.wasm.v1.MsgExecuteContract") {
|
|
867
|
+
return sdkTs.MsgExecuteContractCompat.fromJSON({
|
|
868
|
+
sender: msgJson.sender,
|
|
869
|
+
contractAddress: msgJson.contract,
|
|
870
|
+
msg: msgJson.msg,
|
|
871
|
+
funds: msgJson.funds
|
|
872
|
+
});
|
|
873
|
+
}
|
|
874
|
+
throw new Error("Unsupported message type");
|
|
875
|
+
}
|
|
876
|
+
function createTransaction({
|
|
877
|
+
chainId,
|
|
878
|
+
message,
|
|
879
|
+
timeoutHeight,
|
|
880
|
+
memo = "",
|
|
881
|
+
fee = utils.DEFAULT_STD_FEE,
|
|
882
|
+
signMode = 1,
|
|
883
|
+
pubKey,
|
|
884
|
+
accountNumber,
|
|
885
|
+
sequence
|
|
886
|
+
}) {
|
|
887
|
+
const signers = {
|
|
888
|
+
pubKey,
|
|
889
|
+
accountNumber,
|
|
890
|
+
sequence
|
|
891
|
+
};
|
|
892
|
+
return sdkTs.createTransactionWithSigners({
|
|
893
|
+
fee,
|
|
894
|
+
memo,
|
|
895
|
+
message,
|
|
896
|
+
signers,
|
|
897
|
+
chainId,
|
|
898
|
+
signMode,
|
|
899
|
+
timeoutHeight
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
// src/private-functions/cosmos/signCosmosMessageDirectEvmos.ts
|
|
904
|
+
var signCosmosMessageDirectEvmos = (_0, _1, _2, _3, _4) => chunkASPVKNJ7_js.__async(void 0, [_0, _1, _2, _3, _4], function* (signerAddress, signer, cosmosMsgs, fee, { accountNumber, sequence, chainId }) {
|
|
905
|
+
const accounts = yield signer.getAccounts();
|
|
906
|
+
const accountFromSigner = accounts.find((account) => account.address === signerAddress);
|
|
907
|
+
if (!accountFromSigner) {
|
|
908
|
+
throw new Error("signCosmosMessageDirectEvmos: failed to retrieve account from signer");
|
|
909
|
+
}
|
|
910
|
+
const messages2 = cosmosMsgs.map(
|
|
911
|
+
(cosmosMsg) => getEncodeObjectFromCosmosMessageInjective(cosmosMsg)
|
|
912
|
+
);
|
|
913
|
+
const pk = Buffer.from(accountFromSigner.pubkey).toString("base64");
|
|
914
|
+
const { signDoc } = createTransaction({
|
|
915
|
+
pubKey: pk,
|
|
916
|
+
chainId,
|
|
917
|
+
message: messages2,
|
|
918
|
+
sequence,
|
|
919
|
+
accountNumber,
|
|
920
|
+
timeoutHeight: 0,
|
|
921
|
+
fee
|
|
922
|
+
});
|
|
923
|
+
const directSignResponse = yield signer.signDirect(signerAddress, signDoc);
|
|
924
|
+
return tx.TxRaw.fromPartial({
|
|
925
|
+
bodyBytes: directSignResponse.signed.bodyBytes,
|
|
926
|
+
authInfoBytes: directSignResponse.signed.authInfoBytes,
|
|
927
|
+
signatures: [base64.fromBase64(directSignResponse.signature.signature)]
|
|
928
|
+
});
|
|
929
|
+
});
|
|
930
|
+
var signCosmosMessageDirectInjective = (_0, _1, _2, _3, _4) => chunkASPVKNJ7_js.__async(void 0, [_0, _1, _2, _3, _4], function* (signerAddress, signer, cosmosMsgs, fee, { accountNumber, sequence, chainId }) {
|
|
931
|
+
const accounts = yield signer.getAccounts();
|
|
932
|
+
const accountFromSigner = accounts.find((account) => account.address === signerAddress);
|
|
933
|
+
if (!accountFromSigner) {
|
|
934
|
+
throw new Error("signCosmosMessageDirectInjective: failed to retrieve account from signer");
|
|
935
|
+
}
|
|
936
|
+
const restEndpoint = yield getRestEndpointForChain(chainId);
|
|
937
|
+
const chainRestTendermintApi = new sdkTs.ChainRestTendermintApi(restEndpoint);
|
|
938
|
+
const latestBlock = yield chainRestTendermintApi.fetchLatestBlock();
|
|
939
|
+
const latestHeight = latestBlock.header.height;
|
|
940
|
+
const timeoutHeight = new utils.BigNumberInBase(latestHeight).plus(utils.DEFAULT_BLOCK_TIMEOUT_HEIGHT);
|
|
941
|
+
const pk = Buffer.from(accountFromSigner.pubkey).toString("base64");
|
|
942
|
+
const messages2 = cosmosMsgs.map(
|
|
943
|
+
(cosmosMsg) => getEncodeObjectFromCosmosMessageInjective(cosmosMsg)
|
|
944
|
+
);
|
|
945
|
+
const { signDoc } = createTransaction({
|
|
946
|
+
pubKey: pk,
|
|
947
|
+
chainId,
|
|
948
|
+
message: messages2,
|
|
949
|
+
sequence,
|
|
950
|
+
accountNumber,
|
|
951
|
+
timeoutHeight: timeoutHeight.toNumber(),
|
|
952
|
+
fee
|
|
953
|
+
});
|
|
954
|
+
const directSignResponse = yield signer.signDirect(
|
|
955
|
+
signerAddress,
|
|
956
|
+
// @ts-expect-error TODO: Fix this
|
|
957
|
+
signDoc
|
|
958
|
+
);
|
|
959
|
+
return tx.TxRaw.fromPartial({
|
|
960
|
+
bodyBytes: directSignResponse.signed.bodyBytes,
|
|
961
|
+
authInfoBytes: directSignResponse.signed.authInfoBytes,
|
|
962
|
+
signatures: [base64.fromBase64(directSignResponse.signature.signature)]
|
|
963
|
+
});
|
|
964
|
+
});
|
|
965
|
+
var pubkeyType = chunkASPVKNJ7_js.__spreadValues({
|
|
966
|
+
ethsecp256k1: "ethermint/PubKeyEthSecp256k1"
|
|
967
|
+
}, amino.pubkeyType);
|
|
968
|
+
|
|
969
|
+
// src/amino/encoding.ts
|
|
970
|
+
function encodeEthSecp256k1Pubkey(pubkey) {
|
|
971
|
+
if (pubkey.length !== 33 || pubkey[0] !== 2 && pubkey[0] !== 3) {
|
|
972
|
+
throw new Error(
|
|
973
|
+
"Public key must be compressed secp256k1, i.e. 33 bytes starting with 0x02 or 0x03"
|
|
974
|
+
);
|
|
975
|
+
}
|
|
976
|
+
return {
|
|
977
|
+
type: pubkeyType.ethsecp256k1,
|
|
978
|
+
value: encoding.toBase64(pubkey)
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
// src/proto-signing/pubkey.ts
|
|
983
|
+
function makePubkeyAnyFromAccount(account, chainId) {
|
|
984
|
+
const isEthermint = chunkCG5CQQBW_js.getIsEthermint(chainId);
|
|
985
|
+
const pubkey = isEthermint ? encodeEthSecp256k1Pubkey(account.pubkey) : amino.encodeSecp256k1Pubkey(account.pubkey);
|
|
986
|
+
const pubkeyAny = encodePubkeyToAny(pubkey, chainId, isEthermint);
|
|
987
|
+
return pubkeyAny;
|
|
988
|
+
}
|
|
989
|
+
function encodePubkeyToAny(pubkey, chainId, isEthermint) {
|
|
990
|
+
if (isEthermint) {
|
|
991
|
+
const pubkeyProto = keys.PubKey.fromPartial({
|
|
992
|
+
key: encoding.fromBase64(pubkey.value)
|
|
993
|
+
});
|
|
994
|
+
let typeUrl = "";
|
|
995
|
+
if (chainId == null ? void 0 : chainId.includes("injective")) {
|
|
996
|
+
typeUrl = "/injective.crypto.v1beta1.ethsecp256k1.PubKey";
|
|
997
|
+
} else {
|
|
998
|
+
typeUrl = "/ethermint.crypto.v1.ethsecp256k1.PubKey";
|
|
999
|
+
}
|
|
1000
|
+
return any.Any.fromPartial({
|
|
1001
|
+
typeUrl,
|
|
1002
|
+
value: Uint8Array.from(keys.PubKey.encode(pubkeyProto).finish())
|
|
1003
|
+
});
|
|
1004
|
+
} else {
|
|
1005
|
+
const isInitia = chunkCG5CQQBW_js.getIsInitia(chainId);
|
|
1006
|
+
const pubkeyProto = keys.PubKey.fromPartial({
|
|
1007
|
+
key: encoding.fromBase64(pubkey.value)
|
|
1008
|
+
});
|
|
1009
|
+
if (isInitia) {
|
|
1010
|
+
return any.Any.fromPartial({
|
|
1011
|
+
typeUrl: "/initia.crypto.v1beta1.ethsecp256k1.PubKey",
|
|
1012
|
+
value: Uint8Array.from(keys.PubKey.encode(pubkeyProto).finish())
|
|
1013
|
+
});
|
|
1014
|
+
}
|
|
1015
|
+
return protoSigning.encodePubkey(pubkey);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
var signCosmosMessageDirect = (options) => chunkASPVKNJ7_js.__async(void 0, null, function* () {
|
|
1019
|
+
const {
|
|
1020
|
+
signer,
|
|
1021
|
+
signerAddress,
|
|
1022
|
+
chainId,
|
|
1023
|
+
cosmosMsgs,
|
|
1024
|
+
fee,
|
|
1025
|
+
signerData: { accountNumber, sequence, chainId: signerChainId }
|
|
1026
|
+
} = options;
|
|
1027
|
+
if (chainId.includes("evmos")) {
|
|
1028
|
+
return signCosmosMessageDirectEvmos(signerAddress, signer, cosmosMsgs, fee, {
|
|
1029
|
+
accountNumber,
|
|
1030
|
+
sequence,
|
|
1031
|
+
chainId: signerChainId
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
1034
|
+
if (chainId.includes("injective")) {
|
|
1035
|
+
return signCosmosMessageDirectInjective(signerAddress, signer, cosmosMsgs, fee, {
|
|
1036
|
+
accountNumber,
|
|
1037
|
+
sequence,
|
|
1038
|
+
chainId: signerChainId
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
const accounts = yield signer.getAccounts();
|
|
1042
|
+
const accountFromSigner = accounts.find((account) => account.address === signerAddress);
|
|
1043
|
+
if (!accountFromSigner) {
|
|
1044
|
+
throw new Error("signCosmosMessageDirect error: failed to retrieve account from signer");
|
|
1045
|
+
}
|
|
1046
|
+
const messages2 = cosmosMsgs.map((cosmosMsg) => getEncodeObjectFromCosmosMessage(cosmosMsg));
|
|
1047
|
+
const txBodyEncodeObject = {
|
|
1048
|
+
typeUrl: "/cosmos.tx.v1beta1.TxBody",
|
|
1049
|
+
value: {
|
|
1050
|
+
messages: messages2
|
|
1051
|
+
}
|
|
1052
|
+
};
|
|
1053
|
+
const txBodyBytes = chunk6GJEXV5J_js.ClientState.registry.encode(txBodyEncodeObject);
|
|
1054
|
+
const gasLimit = integers.Int53.fromString(fee.gas).toNumber();
|
|
1055
|
+
const pubkeyAny = makePubkeyAnyFromAccount(accountFromSigner, chainId);
|
|
1056
|
+
const authInfoBytes = signing.makeAuthInfoBytes(
|
|
1057
|
+
[{ pubkey: pubkeyAny, sequence }],
|
|
1058
|
+
fee.amount,
|
|
1059
|
+
gasLimit,
|
|
1060
|
+
fee.granter,
|
|
1061
|
+
fee.payer
|
|
1062
|
+
);
|
|
1063
|
+
const signDoc = signing.makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber);
|
|
1064
|
+
const { signature, signed } = yield signer.signDirect(signerAddress, signDoc);
|
|
1065
|
+
return tx.TxRaw.fromPartial({
|
|
1066
|
+
bodyBytes: signed.bodyBytes,
|
|
1067
|
+
authInfoBytes: signed.authInfoBytes,
|
|
1068
|
+
signatures: [base64.fromBase64(signature.signature)]
|
|
1069
|
+
});
|
|
1070
|
+
});
|
|
1071
|
+
var signCosmosMessageAmino = (options) => chunkASPVKNJ7_js.__async(void 0, null, function* () {
|
|
1072
|
+
const {
|
|
1073
|
+
signer,
|
|
1074
|
+
signerAddress,
|
|
1075
|
+
chainId,
|
|
1076
|
+
cosmosMsgs,
|
|
1077
|
+
fee,
|
|
1078
|
+
signerData: { accountNumber, sequence, chainId: signerChainId }
|
|
1079
|
+
} = options;
|
|
1080
|
+
const accounts = yield signer.getAccounts();
|
|
1081
|
+
const accountFromSigner = accounts.find((account) => account.address === signerAddress);
|
|
1082
|
+
if (!accountFromSigner) {
|
|
1083
|
+
throw new Error("signCosmosMessageAmino: failed to retrieve account from signer");
|
|
1084
|
+
}
|
|
1085
|
+
const messages2 = cosmosMsgs.map((cosmosMsg) => getEncodeObjectFromCosmosMessage(cosmosMsg));
|
|
1086
|
+
const signMode = signing$1.SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
|
|
1087
|
+
const msgs = messages2.map((msg) => chunk6GJEXV5J_js.ClientState.aminoTypes.toAmino(msg));
|
|
1088
|
+
console.log("sign cosmos message amino", msgs, fee, signerChainId, "", accountNumber, sequence);
|
|
1089
|
+
const signDoc = amino.makeSignDoc(msgs, fee, signerChainId, "", accountNumber, sequence);
|
|
1090
|
+
const { signature, signed } = yield signer.signAmino(signerAddress, signDoc);
|
|
1091
|
+
const signedTxBody = {
|
|
1092
|
+
messages: signed.msgs.map((msg) => chunk6GJEXV5J_js.ClientState.aminoTypes.fromAmino(msg)),
|
|
1093
|
+
memo: signed.memo
|
|
1094
|
+
};
|
|
1095
|
+
signedTxBody.messages[0].value.memo = messages2[0].value.memo;
|
|
1096
|
+
const signedTxBodyEncodeObject = {
|
|
1097
|
+
typeUrl: "/cosmos.tx.v1beta1.TxBody",
|
|
1098
|
+
value: signedTxBody
|
|
1099
|
+
};
|
|
1100
|
+
const signedTxBodyBytes = chunk6GJEXV5J_js.ClientState.registry.encode(signedTxBodyEncodeObject);
|
|
1101
|
+
const signedGasLimit = integers.Int53.fromString(signed.fee.gas).toNumber();
|
|
1102
|
+
const signedSequence = integers.Int53.fromString(signed.sequence).toNumber();
|
|
1103
|
+
const pubkeyAny = makePubkeyAnyFromAccount(accountFromSigner, chainId);
|
|
1104
|
+
const signedAuthInfoBytes = signing.makeAuthInfoBytes(
|
|
1105
|
+
[{ pubkey: pubkeyAny, sequence: signedSequence }],
|
|
1106
|
+
signed.fee.amount,
|
|
1107
|
+
signedGasLimit,
|
|
1108
|
+
signed.fee.granter,
|
|
1109
|
+
signed.fee.payer,
|
|
1110
|
+
signMode
|
|
1111
|
+
);
|
|
1112
|
+
return tx.TxRaw.fromPartial({
|
|
1113
|
+
bodyBytes: signedTxBodyBytes,
|
|
1114
|
+
authInfoBytes: signedAuthInfoBytes,
|
|
1115
|
+
signatures: [base64.fromBase64(signature.signature)]
|
|
1116
|
+
});
|
|
1117
|
+
});
|
|
1118
|
+
|
|
1119
|
+
// src/private-functions/cosmos/executeCosmosTransaction.ts
|
|
1120
|
+
var executeCosmosTransaction = (_0) => chunkASPVKNJ7_js.__async(void 0, [_0], function* ({
|
|
1121
|
+
tx: tx$1,
|
|
1122
|
+
options,
|
|
1123
|
+
index
|
|
1124
|
+
}) {
|
|
1125
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1126
|
+
const { userAddresses } = options;
|
|
1127
|
+
if (tx$1 === void 0) {
|
|
1128
|
+
throw new Error("executeCosmosTransaction error: tx is undefined");
|
|
1129
|
+
}
|
|
1130
|
+
const chainId = (_a = tx$1.cosmosTx) == null ? void 0 : _a.chainId;
|
|
1131
|
+
const messages2 = (_b = tx$1.cosmosTx) == null ? void 0 : _b.msgs;
|
|
1132
|
+
const currentUserAddress = (_c = userAddresses.find((x) => {
|
|
1133
|
+
var _a2;
|
|
1134
|
+
return x.chainId === ((_a2 = tx$1.cosmosTx) == null ? void 0 : _a2.chainId);
|
|
1135
|
+
})) == null ? void 0 : _c.address;
|
|
1136
|
+
const gasArray = chunk6GJEXV5J_js.ClientState.validateGasResults;
|
|
1137
|
+
const gas = gasArray == null ? void 0 : gasArray.find((gas2) => (gas2 == null ? void 0 : gas2.error) !== null && (gas2 == null ? void 0 : gas2.error) !== void 0);
|
|
1138
|
+
if (typeof (gas == null ? void 0 : gas.error) === "string") {
|
|
1139
|
+
throw new Error(gas == null ? void 0 : gas.error);
|
|
1140
|
+
}
|
|
1141
|
+
const gasUsed = gasArray == null ? void 0 : gasArray[index];
|
|
1142
|
+
if (!gasUsed) {
|
|
1143
|
+
throw new Error(`executeRoute error: invalid gas at index ${index}`);
|
|
1144
|
+
}
|
|
1145
|
+
if (chainId === void 0) {
|
|
1146
|
+
throw new Error("no chainId found for tx");
|
|
1147
|
+
}
|
|
1148
|
+
if (messages2 === void 0) {
|
|
1149
|
+
throw new Error("no messages found for tx");
|
|
1150
|
+
}
|
|
1151
|
+
const { stargateClient, signer: signer$1 } = yield chunkX2YPYBVN_js.getSigningStargateClient({
|
|
1152
|
+
chainId,
|
|
1153
|
+
getOfflineSigner: options == null ? void 0 : options.getCosmosSigner
|
|
1154
|
+
});
|
|
1155
|
+
if (!currentUserAddress) {
|
|
1156
|
+
throw new Error(
|
|
1157
|
+
`executeCosmosTransaction error: invalid address for chain '${(_d = tx$1.cosmosTx) == null ? void 0 : _d.chainId}'`
|
|
1158
|
+
);
|
|
1159
|
+
}
|
|
1160
|
+
const accounts = yield signer$1.getAccounts();
|
|
1161
|
+
const accountFromSigner = accounts.find((account) => account.address === currentUserAddress);
|
|
1162
|
+
if (!accountFromSigner) {
|
|
1163
|
+
throw new Error("executeCosmosTransaction error: failed to retrieve account from signer");
|
|
1164
|
+
}
|
|
1165
|
+
const fee = gasUsed == null ? void 0 : gasUsed.fee;
|
|
1166
|
+
if (!fee) {
|
|
1167
|
+
throw new Error("executeCosmosTransaction error: failed to retrieve fee from gas");
|
|
1168
|
+
}
|
|
1169
|
+
const { accountNumber, sequence } = yield getAccountNumberAndSequence(
|
|
1170
|
+
currentUserAddress,
|
|
1171
|
+
chainId
|
|
1172
|
+
);
|
|
1173
|
+
let rawTx;
|
|
1174
|
+
const commonRawTxBody = {
|
|
1175
|
+
signerAddress: currentUserAddress,
|
|
1176
|
+
chainId,
|
|
1177
|
+
cosmosMsgs: messages2,
|
|
1178
|
+
fee,
|
|
1179
|
+
signerData: {
|
|
1180
|
+
accountNumber,
|
|
1181
|
+
sequence,
|
|
1182
|
+
chainId
|
|
1183
|
+
}
|
|
1184
|
+
};
|
|
1185
|
+
if (signer.isOfflineDirectSigner(signer$1)) {
|
|
1186
|
+
rawTx = yield signCosmosMessageDirect(chunkASPVKNJ7_js.__spreadProps(chunkASPVKNJ7_js.__spreadValues({}, commonRawTxBody), {
|
|
1187
|
+
signer: signer$1
|
|
1188
|
+
}));
|
|
1189
|
+
} else {
|
|
1190
|
+
rawTx = yield signCosmosMessageAmino(chunkASPVKNJ7_js.__spreadProps(chunkASPVKNJ7_js.__spreadValues({}, commonRawTxBody), { signer: signer$1 }));
|
|
1191
|
+
}
|
|
1192
|
+
(_e = options == null ? void 0 : options.onTransactionSigned) == null ? void 0 : _e.call(options, {
|
|
1193
|
+
chainId
|
|
1194
|
+
});
|
|
1195
|
+
const txBytes = tx.TxRaw.encode(rawTx).finish();
|
|
1196
|
+
const txResponse = yield stargateClient.broadcastTx(txBytes);
|
|
1197
|
+
return {
|
|
1198
|
+
chainId: (_g = (_f = tx$1 == null ? void 0 : tx$1.cosmosTx) == null ? void 0 : _f.chainId) != null ? _g : "",
|
|
1199
|
+
txHash: txResponse.transactionHash
|
|
1200
|
+
};
|
|
1201
|
+
});
|
|
1202
|
+
|
|
1203
|
+
// src/constants/abis.ts
|
|
1204
|
+
function createAbi(abi) {
|
|
1205
|
+
return abi;
|
|
1206
|
+
}
|
|
1207
|
+
var erc20ABI = /* @__PURE__ */ createAbi([
|
|
1208
|
+
{
|
|
1209
|
+
type: "event",
|
|
1210
|
+
name: "Approval",
|
|
1211
|
+
inputs: [
|
|
1212
|
+
{
|
|
1213
|
+
indexed: true,
|
|
1214
|
+
name: "owner",
|
|
1215
|
+
type: "address"
|
|
1216
|
+
},
|
|
1217
|
+
{
|
|
1218
|
+
indexed: true,
|
|
1219
|
+
name: "spender",
|
|
1220
|
+
type: "address"
|
|
1221
|
+
},
|
|
1222
|
+
{
|
|
1223
|
+
indexed: false,
|
|
1224
|
+
name: "value",
|
|
1225
|
+
type: "uint256"
|
|
1226
|
+
}
|
|
1227
|
+
]
|
|
1228
|
+
},
|
|
1229
|
+
{
|
|
1230
|
+
type: "event",
|
|
1231
|
+
name: "Transfer",
|
|
1232
|
+
inputs: [
|
|
1233
|
+
{
|
|
1234
|
+
indexed: true,
|
|
1235
|
+
name: "from",
|
|
1236
|
+
type: "address"
|
|
1237
|
+
},
|
|
1238
|
+
{
|
|
1239
|
+
indexed: true,
|
|
1240
|
+
name: "to",
|
|
1241
|
+
type: "address"
|
|
1242
|
+
},
|
|
1243
|
+
{
|
|
1244
|
+
indexed: false,
|
|
1245
|
+
name: "value",
|
|
1246
|
+
type: "uint256"
|
|
1247
|
+
}
|
|
1248
|
+
]
|
|
1249
|
+
},
|
|
1250
|
+
{
|
|
1251
|
+
type: "function",
|
|
1252
|
+
name: "allowance",
|
|
1253
|
+
stateMutability: "view",
|
|
1254
|
+
inputs: [
|
|
1255
|
+
{
|
|
1256
|
+
name: "owner",
|
|
1257
|
+
type: "address"
|
|
1258
|
+
},
|
|
1259
|
+
{
|
|
1260
|
+
name: "spender",
|
|
1261
|
+
type: "address"
|
|
1262
|
+
}
|
|
1263
|
+
],
|
|
1264
|
+
outputs: [
|
|
1265
|
+
{
|
|
1266
|
+
name: "",
|
|
1267
|
+
type: "uint256"
|
|
1268
|
+
}
|
|
1269
|
+
]
|
|
1270
|
+
},
|
|
1271
|
+
{
|
|
1272
|
+
type: "function",
|
|
1273
|
+
name: "approve",
|
|
1274
|
+
stateMutability: "nonpayable",
|
|
1275
|
+
inputs: [
|
|
1276
|
+
{
|
|
1277
|
+
name: "spender",
|
|
1278
|
+
type: "address"
|
|
1279
|
+
},
|
|
1280
|
+
{
|
|
1281
|
+
name: "amount",
|
|
1282
|
+
type: "uint256"
|
|
1283
|
+
}
|
|
1284
|
+
],
|
|
1285
|
+
outputs: [
|
|
1286
|
+
{
|
|
1287
|
+
name: "",
|
|
1288
|
+
type: "bool"
|
|
1289
|
+
}
|
|
1290
|
+
]
|
|
1291
|
+
},
|
|
1292
|
+
{
|
|
1293
|
+
type: "function",
|
|
1294
|
+
name: "balanceOf",
|
|
1295
|
+
stateMutability: "view",
|
|
1296
|
+
inputs: [
|
|
1297
|
+
{
|
|
1298
|
+
name: "account",
|
|
1299
|
+
type: "address"
|
|
1300
|
+
}
|
|
1301
|
+
],
|
|
1302
|
+
outputs: [
|
|
1303
|
+
{
|
|
1304
|
+
name: "",
|
|
1305
|
+
type: "uint256"
|
|
1306
|
+
}
|
|
1307
|
+
]
|
|
1308
|
+
},
|
|
1309
|
+
{
|
|
1310
|
+
type: "function",
|
|
1311
|
+
name: "decimals",
|
|
1312
|
+
stateMutability: "view",
|
|
1313
|
+
inputs: [],
|
|
1314
|
+
outputs: [
|
|
1315
|
+
{
|
|
1316
|
+
name: "",
|
|
1317
|
+
type: "uint8"
|
|
1318
|
+
}
|
|
1319
|
+
]
|
|
1320
|
+
},
|
|
1321
|
+
{
|
|
1322
|
+
type: "function",
|
|
1323
|
+
name: "name",
|
|
1324
|
+
stateMutability: "view",
|
|
1325
|
+
inputs: [],
|
|
1326
|
+
outputs: [
|
|
1327
|
+
{
|
|
1328
|
+
name: "",
|
|
1329
|
+
type: "string"
|
|
1330
|
+
}
|
|
1331
|
+
]
|
|
1332
|
+
},
|
|
1333
|
+
{
|
|
1334
|
+
type: "function",
|
|
1335
|
+
name: "symbol",
|
|
1336
|
+
stateMutability: "view",
|
|
1337
|
+
inputs: [],
|
|
1338
|
+
outputs: [
|
|
1339
|
+
{
|
|
1340
|
+
name: "",
|
|
1341
|
+
type: "string"
|
|
1342
|
+
}
|
|
1343
|
+
]
|
|
1344
|
+
},
|
|
1345
|
+
{
|
|
1346
|
+
type: "function",
|
|
1347
|
+
name: "totalSupply",
|
|
1348
|
+
stateMutability: "view",
|
|
1349
|
+
inputs: [],
|
|
1350
|
+
outputs: [
|
|
1351
|
+
{
|
|
1352
|
+
name: "",
|
|
1353
|
+
type: "uint256"
|
|
1354
|
+
}
|
|
1355
|
+
]
|
|
1356
|
+
},
|
|
1357
|
+
{
|
|
1358
|
+
type: "function",
|
|
1359
|
+
name: "transfer",
|
|
1360
|
+
stateMutability: "nonpayable",
|
|
1361
|
+
inputs: [
|
|
1362
|
+
{
|
|
1363
|
+
name: "recipient",
|
|
1364
|
+
type: "address"
|
|
1365
|
+
},
|
|
1366
|
+
{
|
|
1367
|
+
name: "amount",
|
|
1368
|
+
type: "uint256"
|
|
1369
|
+
}
|
|
1370
|
+
],
|
|
1371
|
+
outputs: [
|
|
1372
|
+
{
|
|
1373
|
+
name: "",
|
|
1374
|
+
type: "bool"
|
|
1375
|
+
}
|
|
1376
|
+
]
|
|
1377
|
+
},
|
|
1378
|
+
{
|
|
1379
|
+
type: "function",
|
|
1380
|
+
name: "transferFrom",
|
|
1381
|
+
stateMutability: "nonpayable",
|
|
1382
|
+
inputs: [
|
|
1383
|
+
{
|
|
1384
|
+
name: "sender",
|
|
1385
|
+
type: "address"
|
|
1386
|
+
},
|
|
1387
|
+
{
|
|
1388
|
+
name: "recipient",
|
|
1389
|
+
type: "address"
|
|
1390
|
+
},
|
|
1391
|
+
{
|
|
1392
|
+
name: "amount",
|
|
1393
|
+
type: "uint256"
|
|
1394
|
+
}
|
|
1395
|
+
],
|
|
1396
|
+
outputs: [
|
|
1397
|
+
{
|
|
1398
|
+
name: "",
|
|
1399
|
+
type: "bool"
|
|
1400
|
+
}
|
|
1401
|
+
]
|
|
1402
|
+
}
|
|
1403
|
+
]);
|
|
1404
|
+
|
|
1405
|
+
// src/private-functions/evm/executeEvmTransaction.ts
|
|
1406
|
+
var executeEvmTransaction = (message, options) => chunkASPVKNJ7_js.__async(void 0, null, function* () {
|
|
1407
|
+
const gasArray = chunk6GJEXV5J_js.ClientState.validateGasResults;
|
|
1408
|
+
const gas = gasArray == null ? void 0 : gasArray.find((gas2) => (gas2 == null ? void 0 : gas2.error) !== null && (gas2 == null ? void 0 : gas2.error) !== void 0);
|
|
1409
|
+
if (typeof (gas == null ? void 0 : gas.error) === "string") {
|
|
1410
|
+
throw new Error(gas == null ? void 0 : gas.error);
|
|
1411
|
+
}
|
|
1412
|
+
const { evmTx } = message;
|
|
1413
|
+
const getEvmSigner = options.getEvmSigner || chunk6GJEXV5J_js.ClientState.getEvmSigner;
|
|
1414
|
+
if (!getEvmSigner) {
|
|
1415
|
+
throw new Error("Unable to get EVM signer");
|
|
1416
|
+
}
|
|
1417
|
+
if (!(evmTx == null ? void 0 : evmTx.chainId)) {
|
|
1418
|
+
throw new Error("chain id not found in evmTx");
|
|
1419
|
+
}
|
|
1420
|
+
const evmSigner = yield getEvmSigner(evmTx.chainId);
|
|
1421
|
+
if (!evmSigner.account) {
|
|
1422
|
+
throw new Error("executeEVMTransaction error: failed to retrieve account from signer");
|
|
1423
|
+
}
|
|
1424
|
+
if (!evmTx.chainId) {
|
|
1425
|
+
throw new Error("executeEVMTransaction error: chainId not found for evmTx");
|
|
1426
|
+
}
|
|
1427
|
+
if (!evmTx.value) {
|
|
1428
|
+
throw new Error("executeEVMTransaction error: no value found in evmTx");
|
|
1429
|
+
}
|
|
1430
|
+
const { onApproveAllowance, onTransactionSigned, bypassApprovalCheck, useUnlimitedApproval } = options;
|
|
1431
|
+
const extendedSigner = evmSigner.extend(viem.publicActions);
|
|
1432
|
+
if (!bypassApprovalCheck && evmTx.requiredErc20Approvals) {
|
|
1433
|
+
for (const requiredApproval of evmTx.requiredErc20Approvals) {
|
|
1434
|
+
const allowance = yield extendedSigner.readContract({
|
|
1435
|
+
address: requiredApproval.tokenContract,
|
|
1436
|
+
abi: erc20ABI,
|
|
1437
|
+
functionName: "allowance",
|
|
1438
|
+
args: [
|
|
1439
|
+
evmSigner.account.address,
|
|
1440
|
+
requiredApproval.spender
|
|
1441
|
+
]
|
|
1442
|
+
});
|
|
1443
|
+
if (!requiredApproval.amount) {
|
|
1444
|
+
throw new Error("executeEVMTransaction error: no amount found in a requiredApproval");
|
|
1445
|
+
}
|
|
1446
|
+
if (allowance > BigInt(requiredApproval.amount)) {
|
|
1447
|
+
continue;
|
|
1448
|
+
}
|
|
1449
|
+
onApproveAllowance == null ? void 0 : onApproveAllowance({
|
|
1450
|
+
status: "pending",
|
|
1451
|
+
allowance: requiredApproval
|
|
1452
|
+
});
|
|
1453
|
+
const txHash2 = yield extendedSigner.writeContract({
|
|
1454
|
+
account: evmSigner.account,
|
|
1455
|
+
address: requiredApproval.tokenContract,
|
|
1456
|
+
abi: erc20ABI,
|
|
1457
|
+
functionName: "approve",
|
|
1458
|
+
args: [
|
|
1459
|
+
requiredApproval.spender,
|
|
1460
|
+
useUnlimitedApproval ? viem.maxUint256 : BigInt(requiredApproval.amount) + BigInt(1e3)
|
|
1461
|
+
],
|
|
1462
|
+
chain: evmSigner.chain
|
|
1463
|
+
});
|
|
1464
|
+
const receipt2 = yield extendedSigner.waitForTransactionReceipt({
|
|
1465
|
+
hash: txHash2
|
|
1466
|
+
});
|
|
1467
|
+
if (receipt2.status === "reverted") {
|
|
1468
|
+
throw new Error(
|
|
1469
|
+
`executeEVMTransaction error: evm tx reverted for hash ${receipt2.transactionHash}`
|
|
1470
|
+
);
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
onApproveAllowance == null ? void 0 : onApproveAllowance({
|
|
1474
|
+
status: "completed"
|
|
1475
|
+
});
|
|
1476
|
+
}
|
|
1477
|
+
const txHash = yield extendedSigner.sendTransaction({
|
|
1478
|
+
account: evmSigner.account,
|
|
1479
|
+
to: evmTx.to,
|
|
1480
|
+
data: `0x${evmTx.data}`,
|
|
1481
|
+
chain: evmSigner.chain,
|
|
1482
|
+
value: evmTx.value === "" ? void 0 : BigInt(evmTx.value)
|
|
1483
|
+
});
|
|
1484
|
+
onTransactionSigned == null ? void 0 : onTransactionSigned({
|
|
1485
|
+
chainId: evmTx.chainId
|
|
1486
|
+
});
|
|
1487
|
+
const receipt = yield extendedSigner.waitForTransactionReceipt({
|
|
1488
|
+
hash: txHash
|
|
1489
|
+
});
|
|
1490
|
+
return receipt;
|
|
1491
|
+
});
|
|
1492
|
+
var executeSvmTransaction = (tx, options) => chunkASPVKNJ7_js.__async(void 0, null, function* () {
|
|
1493
|
+
var _a, _b, _c;
|
|
1494
|
+
const gasArray = chunk6GJEXV5J_js.ClientState.validateGasResults;
|
|
1495
|
+
if (tx === void 0) {
|
|
1496
|
+
throw new Error("executeSvmTransaction error: tx is undefined");
|
|
1497
|
+
}
|
|
1498
|
+
const gas = gasArray == null ? void 0 : gasArray.find((gas2) => (gas2 == null ? void 0 : gas2.error) !== null && (gas2 == null ? void 0 : gas2.error) !== void 0);
|
|
1499
|
+
if (typeof (gas == null ? void 0 : gas.error) === "string") {
|
|
1500
|
+
throw new Error(gas == null ? void 0 : gas.error);
|
|
1501
|
+
}
|
|
1502
|
+
const svmTx = tx == null ? void 0 : tx.svmTx;
|
|
1503
|
+
const getSvmSigner = (options == null ? void 0 : options.getSvmSigner) || chunk6GJEXV5J_js.ClientState.getSvmSigner;
|
|
1504
|
+
if (!getSvmSigner) {
|
|
1505
|
+
throw new Error(
|
|
1506
|
+
"executeRoute error: 'getSVMSigner' is not provided or configured in skip router"
|
|
1507
|
+
);
|
|
1508
|
+
}
|
|
1509
|
+
const signer = yield getSvmSigner();
|
|
1510
|
+
if (!(svmTx == null ? void 0 : svmTx.chainId)) {
|
|
1511
|
+
throw new Error("executeSvmTransaction error: chainId not found in svmTx");
|
|
1512
|
+
}
|
|
1513
|
+
const txBuffer = Buffer.from((_a = svmTx.tx) != null ? _a : "", "base64");
|
|
1514
|
+
const transaction = web3_js.Transaction.from(txBuffer);
|
|
1515
|
+
const endpoint = yield chunkX2YPYBVN_js.getRpcEndpointForChain(svmTx.chainId);
|
|
1516
|
+
const connection = new web3_js.Connection(endpoint);
|
|
1517
|
+
let signature;
|
|
1518
|
+
if ("signTransaction" in signer) {
|
|
1519
|
+
const signedTx = yield signer.signTransaction(transaction);
|
|
1520
|
+
(_b = options == null ? void 0 : options.onTransactionSigned) == null ? void 0 : _b.call(options, { chainId: svmTx.chainId });
|
|
1521
|
+
const serializedTx = signedTx.serialize();
|
|
1522
|
+
yield chunkKYFTM3PI_js.submitTransaction({
|
|
1523
|
+
chainId: svmTx.chainId,
|
|
1524
|
+
tx: serializedTx.toString("base64")
|
|
1525
|
+
}).then((res) => {
|
|
1526
|
+
signature = res == null ? void 0 : res.txHash;
|
|
1527
|
+
});
|
|
1528
|
+
const rpcSig = yield connection.sendRawTransaction(serializedTx, {
|
|
1529
|
+
preflightCommitment: "confirmed",
|
|
1530
|
+
maxRetries: 5
|
|
1531
|
+
});
|
|
1532
|
+
signature = rpcSig;
|
|
1533
|
+
}
|
|
1534
|
+
if (!signature) {
|
|
1535
|
+
throw new Error("executeSvmTransaction error: signature not found");
|
|
1536
|
+
}
|
|
1537
|
+
let getStatusCount = 0;
|
|
1538
|
+
let errorCount = 0;
|
|
1539
|
+
while (true) {
|
|
1540
|
+
try {
|
|
1541
|
+
const status = yield connection.getSignatureStatus(signature, {
|
|
1542
|
+
searchTransactionHistory: true
|
|
1543
|
+
});
|
|
1544
|
+
if (((_c = status == null ? void 0 : status.value) == null ? void 0 : _c.confirmationStatus) === "confirmed") {
|
|
1545
|
+
return {
|
|
1546
|
+
chainId: svmTx.chainId,
|
|
1547
|
+
txHash: signature
|
|
1548
|
+
};
|
|
1549
|
+
}
|
|
1550
|
+
if (getStatusCount > 12) {
|
|
1551
|
+
yield chunkASPVKNJ7_js.wait(3e3);
|
|
1552
|
+
throw new Error(
|
|
1553
|
+
`executeSvmTransaction error: waiting finalized status timed out for ${signature}`
|
|
1554
|
+
);
|
|
1555
|
+
}
|
|
1556
|
+
getStatusCount++;
|
|
1557
|
+
yield chunkASPVKNJ7_js.wait(3e3);
|
|
1558
|
+
} catch (error) {
|
|
1559
|
+
errorCount++;
|
|
1560
|
+
if (errorCount > 12) {
|
|
1561
|
+
throw error;
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
});
|
|
1566
|
+
|
|
1567
|
+
// src/private-functions/cosmos/getCosmosGasAmountForMessage.ts
|
|
1568
|
+
var DEFAULT_GAS_MULTIPLIER = 1.5;
|
|
1569
|
+
function getCosmosGasAmountForMessage(_0, _1, _2, _3, _4) {
|
|
1570
|
+
return chunkASPVKNJ7_js.__async(this, arguments, function* (client, signerAddress, chainId, messages2, encodedMsgs, multiplier = DEFAULT_GAS_MULTIPLIER) {
|
|
1571
|
+
if (!messages2 && !encodedMsgs) {
|
|
1572
|
+
throw new Error("Either message or encodedMsg must be provided");
|
|
1573
|
+
}
|
|
1574
|
+
const _encodedMsgs = messages2 == null ? void 0 : messages2.map((message) => getEncodeObjectFromCosmosMessage(message));
|
|
1575
|
+
encodedMsgs = encodedMsgs || _encodedMsgs;
|
|
1576
|
+
if (!encodedMsgs) {
|
|
1577
|
+
throw new Error("Either message or encodedMsg must be provided");
|
|
1578
|
+
}
|
|
1579
|
+
if (chainId.includes("evmos") || chainId.includes("injective") || chainId.includes("dymension") || (process == null ? void 0 : process.env.NODE_ENV) === "test") {
|
|
1580
|
+
if (messages2 == null ? void 0 : messages2.find((i) => i.msgTypeUrl === "/cosmwasm.wasm.v1.MsgExecuteContract")) {
|
|
1581
|
+
return "2400000";
|
|
1582
|
+
}
|
|
1583
|
+
return "280000";
|
|
1584
|
+
}
|
|
1585
|
+
const estimatedGas = yield client.simulate(signerAddress, encodedMsgs, "");
|
|
1586
|
+
const estimatedGasWithBuffer = estimatedGas * multiplier;
|
|
1587
|
+
return Math.ceil(estimatedGasWithBuffer).toFixed(0);
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
// src/private-functions/cosmos/validateCosmosGasBalance.ts
|
|
1592
|
+
var validateCosmosGasBalance = (_0) => chunkASPVKNJ7_js.__async(void 0, [_0], function* ({
|
|
1593
|
+
chainId,
|
|
1594
|
+
signerAddress,
|
|
1595
|
+
messages: messages2,
|
|
1596
|
+
getFallbackGasAmount,
|
|
1597
|
+
getOfflineSigner,
|
|
1598
|
+
txIndex,
|
|
1599
|
+
simulate
|
|
1600
|
+
}) {
|
|
1601
|
+
var _a, _b, _c;
|
|
1602
|
+
const skipAssets = (_a = yield chunk6GJEXV5J_js.ClientState.getSkipAssets({ chainId })) == null ? void 0 : _a[chainId];
|
|
1603
|
+
const skipChains = yield chunk6GJEXV5J_js.ClientState.getSkipChains();
|
|
1604
|
+
const chain = skipChains == null ? void 0 : skipChains.find((c) => c.chainId === chainId);
|
|
1605
|
+
if (!chain) {
|
|
1606
|
+
throw new Error(`failed to find chain id for '${chainId}'`);
|
|
1607
|
+
}
|
|
1608
|
+
const { feeAssets } = chain;
|
|
1609
|
+
if (!feeAssets) {
|
|
1610
|
+
throw new Error(`failed to find fee assets for chain '${chainId}'`);
|
|
1611
|
+
}
|
|
1612
|
+
const estimatedGasAmount = yield (() => chunkASPVKNJ7_js.__async(void 0, null, function* () {
|
|
1613
|
+
try {
|
|
1614
|
+
if (!simulate) throw new Error("simulate");
|
|
1615
|
+
if (txIndex !== 0 && chainId === "noble-1") {
|
|
1616
|
+
return "0";
|
|
1617
|
+
}
|
|
1618
|
+
const { stargateClient } = yield chunkX2YPYBVN_js.getSigningStargateClient({
|
|
1619
|
+
chainId,
|
|
1620
|
+
getOfflineSigner
|
|
1621
|
+
});
|
|
1622
|
+
const estimatedGas = yield getCosmosGasAmountForMessage(
|
|
1623
|
+
stargateClient,
|
|
1624
|
+
signerAddress,
|
|
1625
|
+
chainId,
|
|
1626
|
+
messages2
|
|
1627
|
+
);
|
|
1628
|
+
return estimatedGas;
|
|
1629
|
+
} catch (e) {
|
|
1630
|
+
const error = e;
|
|
1631
|
+
if (error.message === "simulate" && !getFallbackGasAmount) {
|
|
1632
|
+
throw new Error(`unable to get gas amount for ${chainId}'s message(s)`);
|
|
1633
|
+
}
|
|
1634
|
+
if (getFallbackGasAmount) {
|
|
1635
|
+
const fallbackGasAmount = yield getFallbackGasAmount(chainId, "cosmos" /* Cosmos */);
|
|
1636
|
+
if (!fallbackGasAmount) {
|
|
1637
|
+
throw new Error(`unable to estimate gas for message(s) ${messages2}`);
|
|
1638
|
+
}
|
|
1639
|
+
return String(fallbackGasAmount);
|
|
1640
|
+
}
|
|
1641
|
+
throw error;
|
|
1642
|
+
}
|
|
1643
|
+
}))();
|
|
1644
|
+
const fees = feeAssets.map((asset) => {
|
|
1645
|
+
const gasPrice = (() => {
|
|
1646
|
+
var _a2;
|
|
1647
|
+
if (!(asset == null ? void 0 : asset.gasPrice)) return void 0;
|
|
1648
|
+
let price = asset.gasPrice.average;
|
|
1649
|
+
if (price === "") {
|
|
1650
|
+
price = asset.gasPrice.high;
|
|
1651
|
+
}
|
|
1652
|
+
if (price === "") {
|
|
1653
|
+
price = asset.gasPrice.low;
|
|
1654
|
+
}
|
|
1655
|
+
if (!price) return;
|
|
1656
|
+
return new fee.GasPrice(
|
|
1657
|
+
decimal.Decimal.fromUserInput(chunkVQ5SIQWU_js.BigNumber(price).toFixed(), 18),
|
|
1658
|
+
(_a2 = asset == null ? void 0 : asset.denom) != null ? _a2 : ""
|
|
1659
|
+
);
|
|
1660
|
+
})();
|
|
1661
|
+
if (!gasPrice) {
|
|
1662
|
+
return null;
|
|
1663
|
+
}
|
|
1664
|
+
if (chainId === "noble-1") {
|
|
1665
|
+
const fee$1 = fee.calculateFee(2e5, gasPrice);
|
|
1666
|
+
return fee$1;
|
|
1667
|
+
}
|
|
1668
|
+
return fee.calculateFee(Math.ceil(parseFloat(estimatedGasAmount)), gasPrice);
|
|
1669
|
+
});
|
|
1670
|
+
const feeBalance = yield chunk6GJEXV5J_js.balances({
|
|
1671
|
+
chains: {
|
|
1672
|
+
[chainId]: {
|
|
1673
|
+
address: signerAddress,
|
|
1674
|
+
denoms: feeAssets.map((asset) => {
|
|
1675
|
+
var _a2;
|
|
1676
|
+
return (_a2 = asset.denom) != null ? _a2 : "";
|
|
1677
|
+
})
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
});
|
|
1681
|
+
const validatedAssets = feeAssets.map((asset, index) => {
|
|
1682
|
+
var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j;
|
|
1683
|
+
const chainAsset = skipAssets == null ? void 0 : skipAssets.find((x) => x.denom === asset.denom);
|
|
1684
|
+
const symbol = (_a2 = chainAsset == null ? void 0 : chainAsset.recommendedSymbol) == null ? void 0 : _a2.toUpperCase();
|
|
1685
|
+
const decimal = Number(chainAsset == null ? void 0 : chainAsset.decimals);
|
|
1686
|
+
if (!chainAsset) {
|
|
1687
|
+
return {
|
|
1688
|
+
error: `(${chain == null ? void 0 : chain.prettyName}) Unable to find asset for ${asset.denom}`
|
|
1689
|
+
};
|
|
1690
|
+
}
|
|
1691
|
+
if (isNaN(decimal))
|
|
1692
|
+
return {
|
|
1693
|
+
error: `(${chain == null ? void 0 : chain.prettyName}) Unable to find decimal for ${symbol}`
|
|
1694
|
+
};
|
|
1695
|
+
const fee = fees[index];
|
|
1696
|
+
if (!fee) {
|
|
1697
|
+
return {
|
|
1698
|
+
error: `(${chain == null ? void 0 : chain.prettyName}) Unable to calculate fee for ${symbol}`,
|
|
1699
|
+
asset
|
|
1700
|
+
};
|
|
1701
|
+
}
|
|
1702
|
+
if (txIndex !== 0 && chainId === "noble-1") {
|
|
1703
|
+
return {
|
|
1704
|
+
error: null,
|
|
1705
|
+
asset,
|
|
1706
|
+
fee
|
|
1707
|
+
};
|
|
1708
|
+
}
|
|
1709
|
+
let balance = (_e = (_c2 = (_b2 = feeBalance == null ? void 0 : feeBalance.chains) == null ? void 0 : _b2[chainId]) == null ? void 0 : _c2.denoms) == null ? void 0 : _e[(_d = asset == null ? void 0 : asset.denom) != null ? _d : ""];
|
|
1710
|
+
if (!balance) {
|
|
1711
|
+
balance = {
|
|
1712
|
+
amount: "0",
|
|
1713
|
+
formattedAmount: "0"
|
|
1714
|
+
};
|
|
1715
|
+
}
|
|
1716
|
+
if (!((_f = fee.amount[0]) == null ? void 0 : _f.amount)) {
|
|
1717
|
+
return {
|
|
1718
|
+
error: `(${chain == null ? void 0 : chain.prettyName}) Unable to get fee for ${symbol}`,
|
|
1719
|
+
asset
|
|
1720
|
+
};
|
|
1721
|
+
}
|
|
1722
|
+
if (parseInt((_g = balance == null ? void 0 : balance.amount) != null ? _g : "") < parseInt((_h = fee.amount[0]) == null ? void 0 : _h.amount)) {
|
|
1723
|
+
const userAmount = new chunkVQ5SIQWU_js.BigNumber(parseFloat((_i = balance == null ? void 0 : balance.amount) != null ? _i : "")).shiftedBy(-decimal).toFixed(decimal);
|
|
1724
|
+
const feeAmount = new chunkVQ5SIQWU_js.BigNumber(parseFloat((_j = fee.amount[0]) == null ? void 0 : _j.amount)).shiftedBy(-decimal).toFixed(decimal);
|
|
1725
|
+
return {
|
|
1726
|
+
error: `Insufficient balance for gas on ${chain == null ? void 0 : chain.prettyName}. Need ${feeAmount} ${symbol} but only have ${userAmount} ${symbol}.`,
|
|
1727
|
+
asset
|
|
1728
|
+
};
|
|
1729
|
+
}
|
|
1730
|
+
return {
|
|
1731
|
+
error: null,
|
|
1732
|
+
asset,
|
|
1733
|
+
fee
|
|
1734
|
+
};
|
|
1735
|
+
});
|
|
1736
|
+
const feeUsed = validatedAssets.find((res) => (res == null ? void 0 : res.error) === null);
|
|
1737
|
+
if (!feeUsed) {
|
|
1738
|
+
if (validatedAssets.length > 1) {
|
|
1739
|
+
throw new Error(
|
|
1740
|
+
((_b = validatedAssets[0]) == null ? void 0 : _b.error) || `Insufficient fee token to initiate transfer on ${chainId}.`
|
|
1741
|
+
);
|
|
1742
|
+
}
|
|
1743
|
+
throw new Error(
|
|
1744
|
+
((_c = validatedAssets[0]) == null ? void 0 : _c.error) || `Insufficient fee token to initiate transfer on ${chainId}.`
|
|
1745
|
+
);
|
|
1746
|
+
}
|
|
1747
|
+
return feeUsed;
|
|
1748
|
+
});
|
|
1749
|
+
var validateEvmTokenApproval = (_0) => chunkASPVKNJ7_js.__async(void 0, [_0], function* ({
|
|
1750
|
+
requiredErc20Approvals,
|
|
1751
|
+
signer,
|
|
1752
|
+
chain,
|
|
1753
|
+
gasBalance,
|
|
1754
|
+
tx,
|
|
1755
|
+
useUnlimitedApproval
|
|
1756
|
+
}) {
|
|
1757
|
+
var _a, _b;
|
|
1758
|
+
if (!((_a = signer.account) == null ? void 0 : _a.address)) {
|
|
1759
|
+
throw new Error("validateEvmGasBalance: Signer address not found");
|
|
1760
|
+
}
|
|
1761
|
+
for (const requiredApproval of requiredErc20Approvals) {
|
|
1762
|
+
const extendedSigner = signer.extend(viem.publicActions);
|
|
1763
|
+
const allowance = yield extendedSigner.readContract({
|
|
1764
|
+
address: requiredApproval.tokenContract,
|
|
1765
|
+
abi: erc20ABI,
|
|
1766
|
+
functionName: "allowance",
|
|
1767
|
+
args: [(_b = signer.account) == null ? void 0 : _b.address, requiredApproval.spender]
|
|
1768
|
+
});
|
|
1769
|
+
if (allowance > BigInt(requiredApproval.amount)) {
|
|
1770
|
+
continue;
|
|
1771
|
+
}
|
|
1772
|
+
const fee = yield extendedSigner.estimateFeesPerGas();
|
|
1773
|
+
const allowanceGasFee = BigInt(fee.maxFeePerGas) * BigInt(1e5);
|
|
1774
|
+
if (!gasBalance) {
|
|
1775
|
+
const chainAssets = (yield chunk6GJEXV5J_js.ClientState.getSkipAssets({ chainId: tx.chainId }))[tx.chainId];
|
|
1776
|
+
const nativeAsset = chainAssets == null ? void 0 : chainAssets.find((x) => x.denom.includes("-native"));
|
|
1777
|
+
const zeroAddressAsset = chainAssets == null ? void 0 : chainAssets.find(
|
|
1778
|
+
(x) => x.denom.toLowerCase() === "0x0000000000000000000000000000000000000000"
|
|
1779
|
+
);
|
|
1780
|
+
const asset = nativeAsset || zeroAddressAsset;
|
|
1781
|
+
if (!(asset == null ? void 0 : asset.decimals)) {
|
|
1782
|
+
throw new Error(
|
|
1783
|
+
`Insufficient balance for gas on ${chain.prettyName}. Need ${allowanceGasFee} gwei.`
|
|
1784
|
+
);
|
|
1785
|
+
}
|
|
1786
|
+
const formattedGasAmount = viem.formatUnits(allowanceGasFee, asset == null ? void 0 : asset.decimals);
|
|
1787
|
+
throw new Error(
|
|
1788
|
+
`Insufficient balance for gas on ${chain.prettyName}. Need ${formattedGasAmount} ${asset.symbol}.`
|
|
1789
|
+
);
|
|
1790
|
+
}
|
|
1791
|
+
if (chunkVQ5SIQWU_js.BigNumber(gasBalance.amount).lt(Number(allowanceGasFee))) {
|
|
1792
|
+
const chainAssets = (yield chunk6GJEXV5J_js.ClientState.getSkipAssets({ chainId: tx.chainId }))[tx.chainId];
|
|
1793
|
+
const asset = chainAssets == null ? void 0 : chainAssets.find(
|
|
1794
|
+
(x) => x.denom.includes("-native") || x.denom.toLowerCase() === "0x0000000000000000000000000000000000000000"
|
|
1795
|
+
);
|
|
1796
|
+
if (!(asset == null ? void 0 : asset.decimals)) {
|
|
1797
|
+
return {
|
|
1798
|
+
error: `Insufficient balance for gas on ${chain.prettyName}. Need ${allowanceGasFee} gwei but only have ${gasBalance.amount} gwei.`,
|
|
1799
|
+
asset: null,
|
|
1800
|
+
fee: null
|
|
1801
|
+
};
|
|
1802
|
+
}
|
|
1803
|
+
const formattedGasAmount = viem.formatUnits(allowanceGasFee, asset == null ? void 0 : asset.decimals);
|
|
1804
|
+
return {
|
|
1805
|
+
error: `Insufficient balance for gas on ${chain.prettyName}. Need ${formattedGasAmount} ${asset.symbol} but only have ${gasBalance.formattedAmount} ${asset.symbol}.`,
|
|
1806
|
+
asset: null,
|
|
1807
|
+
fee: null
|
|
1808
|
+
};
|
|
1809
|
+
}
|
|
1810
|
+
const txHash = yield extendedSigner.writeContract({
|
|
1811
|
+
account: signer.account,
|
|
1812
|
+
address: requiredApproval.tokenContract,
|
|
1813
|
+
abi: erc20ABI,
|
|
1814
|
+
functionName: "approve",
|
|
1815
|
+
args: [
|
|
1816
|
+
requiredApproval.spender,
|
|
1817
|
+
useUnlimitedApproval ? viem.maxUint256 : BigInt(requiredApproval.amount) + BigInt(1e3)
|
|
1818
|
+
],
|
|
1819
|
+
chain: signer.chain
|
|
1820
|
+
});
|
|
1821
|
+
const receipt = yield extendedSigner.waitForTransactionReceipt({
|
|
1822
|
+
hash: txHash
|
|
1823
|
+
});
|
|
1824
|
+
if (receipt.status === "reverted") {
|
|
1825
|
+
throw new Error(
|
|
1826
|
+
`executeEVMTransaction error: evm tx reverted for hash ${receipt.transactionHash}`
|
|
1827
|
+
);
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
});
|
|
1831
|
+
function getEVMGasAmountForMessage(signer, tx, getFallbackGasAmount) {
|
|
1832
|
+
return chunkASPVKNJ7_js.__async(this, null, function* () {
|
|
1833
|
+
var _a;
|
|
1834
|
+
const { to, data, value } = tx;
|
|
1835
|
+
if (!signer.account) throw new Error("estimateGasForEvmTx: No account found");
|
|
1836
|
+
const extendedSigner = signer.extend(viem.publicActions);
|
|
1837
|
+
const fee = yield extendedSigner.estimateFeesPerGas();
|
|
1838
|
+
try {
|
|
1839
|
+
const gasAmount = yield extendedSigner.estimateGas({
|
|
1840
|
+
account: signer.account,
|
|
1841
|
+
to,
|
|
1842
|
+
data: `0x${data}`,
|
|
1843
|
+
value: value === "" ? void 0 : BigInt(value != null ? value : "")
|
|
1844
|
+
});
|
|
1845
|
+
return gasAmount * fee.maxFeePerGas;
|
|
1846
|
+
} catch (error) {
|
|
1847
|
+
const fallbackGasAmount = yield getFallbackGasAmount == null ? void 0 : getFallbackGasAmount((_a = tx.chainId) != null ? _a : "", "evm" /* Evm */);
|
|
1848
|
+
if (fallbackGasAmount) {
|
|
1849
|
+
return BigInt(fallbackGasAmount) * fee.maxFeePerGas;
|
|
1850
|
+
}
|
|
1851
|
+
throw error;
|
|
1852
|
+
}
|
|
1853
|
+
});
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1856
|
+
// src/private-functions/evm/validateEvmGasBalance.ts
|
|
1857
|
+
var validateEvmGasBalance = (_0) => chunkASPVKNJ7_js.__async(void 0, [_0], function* ({
|
|
1858
|
+
signer,
|
|
1859
|
+
tx,
|
|
1860
|
+
getFallbackGasAmount,
|
|
1861
|
+
useUnlimitedApproval
|
|
1862
|
+
}) {
|
|
1863
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
1864
|
+
const chainId = (_a = tx == null ? void 0 : tx.chainId) != null ? _a : "";
|
|
1865
|
+
const skipAssets = (_b = yield chunk6GJEXV5J_js.ClientState.getSkipAssets({ chainId })) == null ? void 0 : _b[chainId];
|
|
1866
|
+
const skipChains = yield chunk6GJEXV5J_js.ClientState.getSkipChains();
|
|
1867
|
+
const chain = (_c = skipChains == null ? void 0 : skipChains.find) == null ? void 0 : _c.call(skipChains, (chain2) => chain2.chainId === chainId);
|
|
1868
|
+
if (!chain) {
|
|
1869
|
+
throw new Error(`failed to find chain for chainId: '${chainId}'`);
|
|
1870
|
+
}
|
|
1871
|
+
if (!((_d = signer.account) == null ? void 0 : _d.address)) {
|
|
1872
|
+
throw new Error("validateEvmGasBalance: Signer address not found");
|
|
1873
|
+
}
|
|
1874
|
+
const skipBalances = (_j = (_i = (_g = yield chunk6GJEXV5J_js.balances({
|
|
1875
|
+
chains: {
|
|
1876
|
+
[(_e = tx == null ? void 0 : tx.chainId) != null ? _e : ""]: {
|
|
1877
|
+
address: (_f = signer.account) == null ? void 0 : _f.address
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
})) == null ? void 0 : _g.chains) == null ? void 0 : _i[(_h = tx == null ? void 0 : tx.chainId) != null ? _h : ""]) == null ? void 0 : _j.denoms;
|
|
1881
|
+
const nativeGasBalance = skipBalances && ((_k = Object.entries(skipBalances).find(([denom]) => denom.includes("-native"))) == null ? void 0 : _k[1]);
|
|
1882
|
+
const zeroAddressGasBalance = skipBalances && ((_l = Object.entries(skipBalances).find(
|
|
1883
|
+
([denom]) => denom.toLowerCase() === "0x0000000000000000000000000000000000000000"
|
|
1884
|
+
)) == null ? void 0 : _l[1]);
|
|
1885
|
+
const gasBalance = nativeGasBalance || zeroAddressGasBalance;
|
|
1886
|
+
const { requiredErc20Approvals } = tx;
|
|
1887
|
+
if (requiredErc20Approvals) {
|
|
1888
|
+
try {
|
|
1889
|
+
yield validateEvmTokenApproval({
|
|
1890
|
+
requiredErc20Approvals,
|
|
1891
|
+
signer,
|
|
1892
|
+
chain,
|
|
1893
|
+
gasBalance,
|
|
1894
|
+
tx,
|
|
1895
|
+
useUnlimitedApproval
|
|
1896
|
+
});
|
|
1897
|
+
} catch (error) {
|
|
1898
|
+
const err = error;
|
|
1899
|
+
return {
|
|
1900
|
+
error: err.message,
|
|
1901
|
+
asset: null,
|
|
1902
|
+
fee: null
|
|
1903
|
+
};
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
const gasAmount = yield getEVMGasAmountForMessage(signer, tx, getFallbackGasAmount);
|
|
1907
|
+
if (!gasBalance) {
|
|
1908
|
+
const nativeAsset = skipAssets == null ? void 0 : skipAssets.find((x) => {
|
|
1909
|
+
var _a2;
|
|
1910
|
+
return (_a2 = x.denom) == null ? void 0 : _a2.includes("-native");
|
|
1911
|
+
});
|
|
1912
|
+
const zeroAddressAsset = skipAssets == null ? void 0 : skipAssets.find(
|
|
1913
|
+
(x) => {
|
|
1914
|
+
var _a2;
|
|
1915
|
+
return ((_a2 = x.denom) == null ? void 0 : _a2.toLowerCase()) === "0x0000000000000000000000000000000000000000";
|
|
1916
|
+
}
|
|
1917
|
+
);
|
|
1918
|
+
const asset = nativeAsset || zeroAddressAsset;
|
|
1919
|
+
if (!(asset == null ? void 0 : asset.decimals)) {
|
|
1920
|
+
return {
|
|
1921
|
+
error: `Insufficient balance for gas on ${chain.prettyName}. Need ${gasAmount} gwei.`,
|
|
1922
|
+
asset: null,
|
|
1923
|
+
fee: null
|
|
1924
|
+
};
|
|
1925
|
+
}
|
|
1926
|
+
const formattedGasAmount = viem.formatUnits(gasAmount, asset == null ? void 0 : asset.decimals);
|
|
1927
|
+
return {
|
|
1928
|
+
error: `Insufficient balance for gas on ${chain.prettyName}. Need ${formattedGasAmount} ${asset.symbol}.`,
|
|
1929
|
+
asset: null,
|
|
1930
|
+
fee: null
|
|
1931
|
+
};
|
|
1932
|
+
}
|
|
1933
|
+
if (chunkVQ5SIQWU_js.BigNumber((_m = gasBalance.amount) != null ? _m : "").lt(Number(gasAmount))) {
|
|
1934
|
+
const asset = skipAssets == null ? void 0 : skipAssets.find(
|
|
1935
|
+
(x) => {
|
|
1936
|
+
var _a2, _b2;
|
|
1937
|
+
return ((_a2 = x.denom) == null ? void 0 : _a2.includes("-native")) || ((_b2 = x.denom) == null ? void 0 : _b2.toLowerCase()) === "0x0000000000000000000000000000000000000000";
|
|
1938
|
+
}
|
|
1939
|
+
);
|
|
1940
|
+
if (!(asset == null ? void 0 : asset.decimals)) {
|
|
1941
|
+
return {
|
|
1942
|
+
error: `Insufficient balance for gas on ${chain.prettyName}. Need ${gasAmount} gwei but only have ${gasBalance.amount} gwei.`,
|
|
1943
|
+
asset: null,
|
|
1944
|
+
fee: null
|
|
1945
|
+
};
|
|
1946
|
+
}
|
|
1947
|
+
const formattedGasAmount = viem.formatUnits(gasAmount, asset == null ? void 0 : asset.decimals);
|
|
1948
|
+
return {
|
|
1949
|
+
error: `Insufficient balance for gas on ${chain.prettyName}. Need ${formattedGasAmount} ${asset.symbol} but only have ${gasBalance.formattedAmount} ${asset.symbol}.`,
|
|
1950
|
+
asset: null,
|
|
1951
|
+
fee: null
|
|
1952
|
+
};
|
|
1953
|
+
}
|
|
1954
|
+
});
|
|
1955
|
+
var validateSvmGasBalance = (_0) => chunkASPVKNJ7_js.__async(void 0, [_0], function* ({
|
|
1956
|
+
tx
|
|
1957
|
+
}) {
|
|
1958
|
+
var _a, _b, _c;
|
|
1959
|
+
if (!tx) throw new Error("Transaction is required");
|
|
1960
|
+
const endpoint = yield chunkX2YPYBVN_js.getRpcEndpointForChain((_a = tx.chainId) != null ? _a : "");
|
|
1961
|
+
const connection = new web3_js.Connection(endpoint);
|
|
1962
|
+
if (!connection) throw new Error(`Failed to connect to ${tx.chainId}`);
|
|
1963
|
+
if (!tx.tx) {
|
|
1964
|
+
throw new Error("Transaction is required");
|
|
1965
|
+
}
|
|
1966
|
+
const txBuffer = Buffer.from(tx.tx, "base64");
|
|
1967
|
+
let transaction;
|
|
1968
|
+
try {
|
|
1969
|
+
transaction = web3_js.Transaction.from(txBuffer);
|
|
1970
|
+
} catch (decodeError) {
|
|
1971
|
+
return {
|
|
1972
|
+
success: false,
|
|
1973
|
+
error: { decodeError: decodeError.message },
|
|
1974
|
+
asset: null,
|
|
1975
|
+
fee: null
|
|
1976
|
+
};
|
|
1977
|
+
}
|
|
1978
|
+
const simulation = yield connection.simulateTransaction(transaction);
|
|
1979
|
+
if (simulation.value.err) {
|
|
1980
|
+
const logs = (_b = simulation.value.logs) != null ? _b : [];
|
|
1981
|
+
const shortfall = getSolShortfall(logs);
|
|
1982
|
+
const insufficientLamports = logs.some((log) => log.includes("insufficient lamports")) && shortfall !== null;
|
|
1983
|
+
const insufficientFundsForRent = Object.keys(simulation.value.err).includes(
|
|
1984
|
+
"InsufficientFundsForRent"
|
|
1985
|
+
);
|
|
1986
|
+
const errMsg = insufficientLamports ? `Insufficient balance for gas on Solana. You need ${shortfall.toFixed(6)} SOL to proceed.` : insufficientFundsForRent ? "Insufficient funds for rent on Solana. You need to fund your account." : "Simulation failed";
|
|
1987
|
+
return {
|
|
1988
|
+
success: false,
|
|
1989
|
+
logs,
|
|
1990
|
+
error: errMsg,
|
|
1991
|
+
asset: null,
|
|
1992
|
+
fee: null
|
|
1993
|
+
};
|
|
1994
|
+
}
|
|
1995
|
+
return {
|
|
1996
|
+
success: true,
|
|
1997
|
+
logs: (_c = simulation.value.logs) != null ? _c : [],
|
|
1998
|
+
error: null,
|
|
1999
|
+
asset: null,
|
|
2000
|
+
fee: null
|
|
2001
|
+
};
|
|
2002
|
+
});
|
|
2003
|
+
function getSolShortfall(logs) {
|
|
2004
|
+
var _a, _b;
|
|
2005
|
+
const line = logs.find((l) => l.includes("insufficient lamports"));
|
|
2006
|
+
if (!line) return null;
|
|
2007
|
+
const m = line.match(/insufficient lamports (\d+), need (\d+)/);
|
|
2008
|
+
if (!m) return null;
|
|
2009
|
+
const have = parseInt((_a = m[1]) != null ? _a : "0", 10);
|
|
2010
|
+
const need = parseInt((_b = m[2]) != null ? _b : "0", 10);
|
|
2011
|
+
const shortfallLamports = need - have;
|
|
2012
|
+
return shortfallLamports / web3_js.LAMPORTS_PER_SOL;
|
|
2013
|
+
}
|
|
2014
|
+
|
|
2015
|
+
// src/private-functions/validateGasBalances.ts
|
|
2016
|
+
var validateGasBalances = (_0) => chunkASPVKNJ7_js.__async(void 0, [_0], function* ({
|
|
2017
|
+
txs,
|
|
2018
|
+
onValidateGasBalance,
|
|
2019
|
+
getFallbackGasAmount,
|
|
2020
|
+
getCosmosSigner,
|
|
2021
|
+
getEvmSigner,
|
|
2022
|
+
simulate,
|
|
2023
|
+
disabledChainIds,
|
|
2024
|
+
enabledChainIds,
|
|
2025
|
+
useUnlimitedApproval
|
|
2026
|
+
}) {
|
|
2027
|
+
if (txs.every((tx) => "cosmosTx" in tx === void 0) || txs.every((tx) => "svmTx" in tx === void 0)) {
|
|
2028
|
+
return;
|
|
2029
|
+
}
|
|
2030
|
+
onValidateGasBalance == null ? void 0 : onValidateGasBalance({
|
|
2031
|
+
status: "pending"
|
|
2032
|
+
});
|
|
2033
|
+
const validateResult = yield Promise.all(
|
|
2034
|
+
txs.map((tx, i) => chunkASPVKNJ7_js.__async(void 0, null, function* () {
|
|
2035
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
2036
|
+
if (!tx) {
|
|
2037
|
+
throw new Error(`invalid tx at index ${i}`);
|
|
2038
|
+
}
|
|
2039
|
+
if ("cosmosTx" in tx && !(disabledChainIds == null ? void 0 : disabledChainIds.includes((_b = (_a = tx == null ? void 0 : tx.cosmosTx) == null ? void 0 : _a.chainId) != null ? _b : "")) && (enabledChainIds === void 0 || enabledChainIds.includes((_d = (_c = tx == null ? void 0 : tx.cosmosTx) == null ? void 0 : _c.chainId) != null ? _d : ""))) {
|
|
2040
|
+
if (!((_e = tx == null ? void 0 : tx.cosmosTx) == null ? void 0 : _e.msgs)) {
|
|
2041
|
+
throw new Error(`invalid msgs ${(_f = tx == null ? void 0 : tx.cosmosTx) == null ? void 0 : _f.msgs}`);
|
|
2042
|
+
}
|
|
2043
|
+
try {
|
|
2044
|
+
const res = yield validateCosmosGasBalance({
|
|
2045
|
+
chainId: (_g = tx.cosmosTx.chainId) != null ? _g : "",
|
|
2046
|
+
signerAddress: (_h = tx.cosmosTx.signerAddress) != null ? _h : "",
|
|
2047
|
+
messages: tx.cosmosTx.msgs,
|
|
2048
|
+
getFallbackGasAmount,
|
|
2049
|
+
getOfflineSigner: getCosmosSigner,
|
|
2050
|
+
txIndex: i,
|
|
2051
|
+
simulate
|
|
2052
|
+
});
|
|
2053
|
+
return res;
|
|
2054
|
+
} catch (e) {
|
|
2055
|
+
const error = e;
|
|
2056
|
+
return {
|
|
2057
|
+
error: error.message,
|
|
2058
|
+
asset: null,
|
|
2059
|
+
fee: null
|
|
2060
|
+
};
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
if ("evmTx" in tx && !(disabledChainIds == null ? void 0 : disabledChainIds.includes((_j = (_i = tx == null ? void 0 : tx.evmTx) == null ? void 0 : _i.chainId) != null ? _j : "")) && (enabledChainIds === void 0 || enabledChainIds.includes((_l = (_k = tx == null ? void 0 : tx.evmTx) == null ? void 0 : _k.chainId) != null ? _l : ""))) {
|
|
2064
|
+
const signer = yield getEvmSigner == null ? void 0 : getEvmSigner((_n = (_m = tx == null ? void 0 : tx.evmTx) == null ? void 0 : _m.chainId) != null ? _n : "");
|
|
2065
|
+
if (!signer) {
|
|
2066
|
+
throw new Error(`failed to get signer for chain ${(_o = tx == null ? void 0 : tx.evmTx) == null ? void 0 : _o.chainId}`);
|
|
2067
|
+
}
|
|
2068
|
+
try {
|
|
2069
|
+
const res = yield validateEvmGasBalance({
|
|
2070
|
+
tx: tx.evmTx,
|
|
2071
|
+
signer,
|
|
2072
|
+
getFallbackGasAmount,
|
|
2073
|
+
useUnlimitedApproval
|
|
2074
|
+
});
|
|
2075
|
+
return res;
|
|
2076
|
+
} catch (e) {
|
|
2077
|
+
const error = e;
|
|
2078
|
+
return {
|
|
2079
|
+
error: error.message,
|
|
2080
|
+
asset: null,
|
|
2081
|
+
fee: null
|
|
2082
|
+
};
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
if ("svmTx" in tx && !(disabledChainIds == null ? void 0 : disabledChainIds.includes((_q = (_p = tx == null ? void 0 : tx.svmTx) == null ? void 0 : _p.chainId) != null ? _q : "")) && (enabledChainIds === void 0 || enabledChainIds.includes((_s = (_r = tx == null ? void 0 : tx.svmTx) == null ? void 0 : _r.chainId) != null ? _s : ""))) {
|
|
2086
|
+
try {
|
|
2087
|
+
const res = yield validateSvmGasBalance({
|
|
2088
|
+
tx: tx.svmTx
|
|
2089
|
+
});
|
|
2090
|
+
return res;
|
|
2091
|
+
} catch (e) {
|
|
2092
|
+
const error = e;
|
|
2093
|
+
return {
|
|
2094
|
+
error: error.message,
|
|
2095
|
+
asset: null,
|
|
2096
|
+
fee: null
|
|
2097
|
+
};
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
}))
|
|
2101
|
+
);
|
|
2102
|
+
if (validateResult.filter(Boolean).length === 0) {
|
|
2103
|
+
return;
|
|
2104
|
+
}
|
|
2105
|
+
const txError = validateResult.find((res) => res && (res == null ? void 0 : res.error) !== null);
|
|
2106
|
+
if (txError) {
|
|
2107
|
+
onValidateGasBalance == null ? void 0 : onValidateGasBalance({
|
|
2108
|
+
status: "error"
|
|
2109
|
+
});
|
|
2110
|
+
chunk6GJEXV5J_js.ClientState.validateGasResults = validateResult;
|
|
2111
|
+
throw new Error(`${txError.error}`);
|
|
2112
|
+
}
|
|
2113
|
+
onValidateGasBalance == null ? void 0 : onValidateGasBalance({
|
|
2114
|
+
status: "completed"
|
|
2115
|
+
});
|
|
2116
|
+
chunk6GJEXV5J_js.ClientState.validateGasResults = validateResult;
|
|
2117
|
+
});
|
|
2118
|
+
|
|
2119
|
+
// src/private-functions/waitForTransaction.ts
|
|
2120
|
+
var waitForTransaction = (_0) => chunkASPVKNJ7_js.__async(void 0, [_0], function* ({
|
|
2121
|
+
chainId,
|
|
2122
|
+
txHash,
|
|
2123
|
+
onTransactionTracked
|
|
2124
|
+
}) {
|
|
2125
|
+
var _a, _b;
|
|
2126
|
+
const { explorerLink } = yield chunkYYNIFO2A_js.trackTransaction({
|
|
2127
|
+
chainId,
|
|
2128
|
+
txHash
|
|
2129
|
+
});
|
|
2130
|
+
yield onTransactionTracked == null ? void 0 : onTransactionTracked({ txHash, chainId, explorerLink });
|
|
2131
|
+
while (true) {
|
|
2132
|
+
const txStatusResponse = yield chunk2WHYWV4Y_js.transactionStatus({
|
|
2133
|
+
chainId,
|
|
2134
|
+
txHash
|
|
2135
|
+
});
|
|
2136
|
+
if (txStatusResponse.state === "STATE_COMPLETED_SUCCESS") {
|
|
2137
|
+
return txStatusResponse;
|
|
2138
|
+
}
|
|
2139
|
+
if (txStatusResponse.state === "STATE_COMPLETED_ERROR") {
|
|
2140
|
+
throw new Error(`${(_a = txStatusResponse.error) == null ? void 0 : _a.type}: ${(_b = txStatusResponse.error) == null ? void 0 : _b.message}`);
|
|
2141
|
+
}
|
|
2142
|
+
if (txStatusResponse.state === "STATE_ABANDONED") {
|
|
2143
|
+
throw new Error("Tracking for the transaction has been abandoned");
|
|
2144
|
+
}
|
|
2145
|
+
yield chunkASPVKNJ7_js.wait(1e3);
|
|
2146
|
+
}
|
|
2147
|
+
});
|
|
2148
|
+
|
|
2149
|
+
// src/private-functions/executeTransactions.ts
|
|
2150
|
+
var executeTransactions = (options) => chunkASPVKNJ7_js.__async(void 0, null, function* () {
|
|
2151
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2152
|
+
const {
|
|
2153
|
+
txs,
|
|
2154
|
+
onTransactionBroadcast,
|
|
2155
|
+
onTransactionCompleted,
|
|
2156
|
+
simulate = true,
|
|
2157
|
+
batchSimulate = true
|
|
2158
|
+
} = options;
|
|
2159
|
+
if (txs === void 0) {
|
|
2160
|
+
throw new Error("executeTransactions error: txs is undefined in executeTransactions");
|
|
2161
|
+
}
|
|
2162
|
+
const chainIds = txs.map((tx) => {
|
|
2163
|
+
var _a2, _b2, _c2;
|
|
2164
|
+
if ("cosmosTx" in tx) {
|
|
2165
|
+
return {
|
|
2166
|
+
chainType: "cosmos",
|
|
2167
|
+
chainId: (_a2 = tx.cosmosTx) == null ? void 0 : _a2.chainId
|
|
2168
|
+
};
|
|
2169
|
+
}
|
|
2170
|
+
if ("svmTx" in tx) {
|
|
2171
|
+
return {
|
|
2172
|
+
chainType: "svm",
|
|
2173
|
+
chainId: (_b2 = tx.svmTx) == null ? void 0 : _b2.chainId
|
|
2174
|
+
};
|
|
2175
|
+
}
|
|
2176
|
+
if ("evmTx" in tx) {
|
|
2177
|
+
return {
|
|
2178
|
+
chainType: "evm",
|
|
2179
|
+
chainId: (_c2 = tx.evmTx) == null ? void 0 : _c2.chainId
|
|
2180
|
+
};
|
|
2181
|
+
}
|
|
2182
|
+
});
|
|
2183
|
+
const isGasStationSourceEVM = chainIds.find((item, i, array) => {
|
|
2184
|
+
var _a2, _b2;
|
|
2185
|
+
return chunkSWYON2RG_js.GAS_STATION_CHAIN_IDS.includes((_a2 = item == null ? void 0 : item.chainId) != null ? _a2 : "") && ((_b2 = array[i - 1]) == null ? void 0 : _b2.chainType) === "evm";
|
|
2186
|
+
});
|
|
2187
|
+
chunk6GJEXV5J_js.ClientState.validateGasResults = void 0;
|
|
2188
|
+
const validateChainIds = !batchSimulate ? chainIds.map((x) => {
|
|
2189
|
+
var _a2;
|
|
2190
|
+
return (_a2 = x == null ? void 0 : x.chainId) != null ? _a2 : "";
|
|
2191
|
+
}) : isGasStationSourceEVM ? chunkSWYON2RG_js.GAS_STATION_CHAIN_IDS : [];
|
|
2192
|
+
yield validateGasBalances({
|
|
2193
|
+
txs,
|
|
2194
|
+
getFallbackGasAmount: options.getFallbackGasAmount,
|
|
2195
|
+
getCosmosSigner: options.getCosmosSigner,
|
|
2196
|
+
getEvmSigner: options.getEvmSigner,
|
|
2197
|
+
onValidateGasBalance: options.onValidateGasBalance,
|
|
2198
|
+
simulate,
|
|
2199
|
+
disabledChainIds: validateChainIds
|
|
2200
|
+
});
|
|
2201
|
+
const validateEnabledChainIds = (chainId) => chunkASPVKNJ7_js.__async(void 0, null, function* () {
|
|
2202
|
+
yield validateGasBalances({
|
|
2203
|
+
txs,
|
|
2204
|
+
getFallbackGasAmount: options.getFallbackGasAmount,
|
|
2205
|
+
getCosmosSigner: options.getCosmosSigner,
|
|
2206
|
+
getEvmSigner: options.getEvmSigner,
|
|
2207
|
+
onValidateGasBalance: options.onValidateGasBalance,
|
|
2208
|
+
simulate,
|
|
2209
|
+
enabledChainIds: !batchSimulate ? [chainId] : validateChainIds
|
|
2210
|
+
});
|
|
2211
|
+
});
|
|
2212
|
+
for (let i = 0; i < txs.length; i++) {
|
|
2213
|
+
const tx = txs[i];
|
|
2214
|
+
if (!tx) {
|
|
2215
|
+
throw new Error(`executeRoute error: invalid message at index ${i}`);
|
|
2216
|
+
}
|
|
2217
|
+
let txResult;
|
|
2218
|
+
if ("cosmosTx" in tx) {
|
|
2219
|
+
yield validateEnabledChainIds((_b = (_a = tx.cosmosTx) == null ? void 0 : _a.chainId) != null ? _b : "");
|
|
2220
|
+
txResult = yield executeCosmosTransaction({
|
|
2221
|
+
tx,
|
|
2222
|
+
options,
|
|
2223
|
+
index: i
|
|
2224
|
+
});
|
|
2225
|
+
} else if ("evmTx" in tx) {
|
|
2226
|
+
yield validateEnabledChainIds((_d = (_c = tx.evmTx) == null ? void 0 : _c.chainId) != null ? _d : "");
|
|
2227
|
+
const txResponse = yield executeEvmTransaction(tx, options);
|
|
2228
|
+
txResult = {
|
|
2229
|
+
chainId: (_f = (_e = tx == null ? void 0 : tx.evmTx) == null ? void 0 : _e.chainId) != null ? _f : "",
|
|
2230
|
+
txHash: txResponse.transactionHash
|
|
2231
|
+
};
|
|
2232
|
+
} else if ("svmTx" in tx) {
|
|
2233
|
+
yield validateEnabledChainIds((_h = (_g = tx.svmTx) == null ? void 0 : _g.chainId) != null ? _h : "");
|
|
2234
|
+
txResult = yield executeSvmTransaction(tx, options);
|
|
2235
|
+
} else {
|
|
2236
|
+
throw new Error("executeRoute error: invalid message type");
|
|
2237
|
+
}
|
|
2238
|
+
yield onTransactionBroadcast == null ? void 0 : onTransactionBroadcast(chunkASPVKNJ7_js.__spreadValues({}, txResult));
|
|
2239
|
+
const txStatusResponse = yield waitForTransaction(chunkASPVKNJ7_js.__spreadProps(chunkASPVKNJ7_js.__spreadValues({}, txResult), {
|
|
2240
|
+
onTransactionTracked: options.onTransactionTracked
|
|
2241
|
+
}));
|
|
2242
|
+
yield onTransactionCompleted == null ? void 0 : onTransactionCompleted({
|
|
2243
|
+
chainId: txResult.chainId,
|
|
2244
|
+
txHash: txResult.txHash,
|
|
2245
|
+
status: txStatusResponse
|
|
2246
|
+
});
|
|
2247
|
+
}
|
|
2248
|
+
});
|
|
2249
|
+
var executeRoute = (options) => chunkASPVKNJ7_js.__async(void 0, null, function* () {
|
|
2250
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2251
|
+
const { route, userAddresses, beforeMsg, afterMsg, timeoutSeconds } = options;
|
|
2252
|
+
let addressList = [];
|
|
2253
|
+
userAddresses.forEach((userAddress, index) => {
|
|
2254
|
+
const requiredChainAddress = route.requiredChainAddresses[index];
|
|
2255
|
+
if (requiredChainAddress === (userAddress == null ? void 0 : userAddress.chainId)) {
|
|
2256
|
+
addressList.push(userAddress.address);
|
|
2257
|
+
}
|
|
2258
|
+
});
|
|
2259
|
+
if (addressList.length !== route.requiredChainAddresses.length) {
|
|
2260
|
+
addressList = userAddresses.map((x) => x.address);
|
|
2261
|
+
}
|
|
2262
|
+
const validLength = addressList.length === route.requiredChainAddresses.length || addressList.length === ((_a = route.chainIds) == null ? void 0 : _a.length);
|
|
2263
|
+
if (!validLength) {
|
|
2264
|
+
throw new Error("executeRoute error: invalid address list");
|
|
2265
|
+
}
|
|
2266
|
+
const isUserAddressesValid = yield validateUserAddresses(userAddresses);
|
|
2267
|
+
if (!isUserAddressesValid) {
|
|
2268
|
+
throw new Error("executeRoute error: invalid user addresses");
|
|
2269
|
+
}
|
|
2270
|
+
const response = yield chunkFVSSCQ6C_js.messages({
|
|
2271
|
+
timeoutSeconds,
|
|
2272
|
+
amountIn: route == null ? void 0 : route.amountIn,
|
|
2273
|
+
amountOut: route.estimatedAmountOut || "0",
|
|
2274
|
+
sourceAssetChainId: route == null ? void 0 : route.sourceAssetChainId,
|
|
2275
|
+
sourceAssetDenom: route == null ? void 0 : route.sourceAssetDenom,
|
|
2276
|
+
destAssetChainId: route == null ? void 0 : route.destAssetChainId,
|
|
2277
|
+
destAssetDenom: route == null ? void 0 : route.destAssetDenom,
|
|
2278
|
+
operations: route == null ? void 0 : route.operations,
|
|
2279
|
+
addressList,
|
|
2280
|
+
slippageTolerancePercent: options.slippageTolerancePercent || "1",
|
|
2281
|
+
chainIdsToAffiliates: chunkASPVKNJ7_js.ApiState.chainIdsToAffiliates
|
|
2282
|
+
});
|
|
2283
|
+
if (beforeMsg && ((_c = (_b = response == null ? void 0 : response.txs) == null ? void 0 : _b.length) != null ? _c : 0) > 0) {
|
|
2284
|
+
const firstTx = (_d = response == null ? void 0 : response.txs) == null ? void 0 : _d[0];
|
|
2285
|
+
if (firstTx && "cosmosTx" in firstTx) {
|
|
2286
|
+
(_f = (_e = firstTx.cosmosTx) == null ? void 0 : _e.msgs) == null ? void 0 : _f.unshift(beforeMsg);
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2289
|
+
if (afterMsg && ((_h = (_g = response == null ? void 0 : response.txs) == null ? void 0 : _g.length) != null ? _h : 0) > 0) {
|
|
2290
|
+
const lastTx = (_i = response == null ? void 0 : response.txs) == null ? void 0 : _i[response.txs.length - 1];
|
|
2291
|
+
if (lastTx && "cosmosTx" in lastTx) {
|
|
2292
|
+
(_k = (_j = lastTx.cosmosTx) == null ? void 0 : _j.msgs) == null ? void 0 : _k.push(afterMsg);
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
2295
|
+
yield executeTransactions(chunkASPVKNJ7_js.__spreadProps(chunkASPVKNJ7_js.__spreadValues({}, options), { txs: response == null ? void 0 : response.txs }));
|
|
2296
|
+
});
|
|
2297
|
+
var validateUserAddresses = (userAddresses) => chunkASPVKNJ7_js.__async(void 0, null, function* () {
|
|
2298
|
+
const chains2 = yield chunk6GJEXV5J_js.ClientState.getSkipChains();
|
|
2299
|
+
const validations = userAddresses.map((userAddress) => {
|
|
2300
|
+
var _a, _b;
|
|
2301
|
+
const chain = chains2.find((chain2) => chain2.chainId === userAddress.chainId);
|
|
2302
|
+
switch (chain == null ? void 0 : chain.chainType) {
|
|
2303
|
+
case "cosmos" /* Cosmos */:
|
|
2304
|
+
try {
|
|
2305
|
+
if ((_a = chain.chainId) == null ? void 0 : _a.includes("penumbra")) {
|
|
2306
|
+
try {
|
|
2307
|
+
return chain.bech32Prefix === ((_b = bech32.bech32m.decode(userAddress.address, 143)) == null ? void 0 : _b.prefix);
|
|
2308
|
+
} catch (e) {
|
|
2309
|
+
return ["penumbracompat1", "tpenumbra"].includes(
|
|
2310
|
+
bech32.bech32.decode(userAddress.address, 1023).prefix
|
|
2311
|
+
);
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
return chain.bech32Prefix === bech32.bech32.decode(userAddress.address, 1023).prefix;
|
|
2315
|
+
} catch (e) {
|
|
2316
|
+
return false;
|
|
2317
|
+
}
|
|
2318
|
+
case "evm" /* Evm */:
|
|
2319
|
+
try {
|
|
2320
|
+
return viem.isAddress(userAddress.address);
|
|
2321
|
+
} catch (_error) {
|
|
2322
|
+
return false;
|
|
2323
|
+
}
|
|
2324
|
+
case "svm" /* Svm */:
|
|
2325
|
+
try {
|
|
2326
|
+
const publicKey = new web3_js.PublicKey(userAddress.address);
|
|
2327
|
+
return web3_js.PublicKey.isOnCurve(publicKey);
|
|
2328
|
+
} catch (_error) {
|
|
2329
|
+
return false;
|
|
2330
|
+
}
|
|
2331
|
+
default:
|
|
2332
|
+
return false;
|
|
2333
|
+
}
|
|
2334
|
+
});
|
|
2335
|
+
return validations.every((validation) => validation);
|
|
2336
|
+
});
|
|
2337
|
+
|
|
2338
|
+
exports.Api = Api;
|
|
2339
|
+
exports.AutopilotAction = AutopilotAction;
|
|
2340
|
+
exports.AxelarTransferState = AxelarTransferState;
|
|
2341
|
+
exports.AxelarTransferType = AxelarTransferType;
|
|
2342
|
+
exports.BridgeType = BridgeType;
|
|
2343
|
+
exports.CCTPTransferState = CCTPTransferState;
|
|
2344
|
+
exports.ChainType = ChainType;
|
|
2345
|
+
exports.ContentType = ContentType;
|
|
2346
|
+
exports.ContractCallWithTokenErrorType = ContractCallWithTokenErrorType;
|
|
2347
|
+
exports.FeeType = FeeType;
|
|
2348
|
+
exports.GoFastTransferState = GoFastTransferState;
|
|
2349
|
+
exports.HttpClient = HttpClient;
|
|
2350
|
+
exports.HyperlaneTransferState = HyperlaneTransferState;
|
|
2351
|
+
exports.LayerZeroTransferState = LayerZeroTransferState;
|
|
2352
|
+
exports.OPInitTransferState = OPInitTransferState;
|
|
2353
|
+
exports.PacketErrorType = PacketErrorType;
|
|
2354
|
+
exports.Reason = Reason;
|
|
2355
|
+
exports.RoutePriceWarningType = RoutePriceWarningType;
|
|
2356
|
+
exports.SendTokenErrorType = SendTokenErrorType;
|
|
2357
|
+
exports.StargateTransferState = StargateTransferState;
|
|
2358
|
+
exports.StatusErrorType = StatusErrorType;
|
|
2359
|
+
exports.TransactionState = TransactionState;
|
|
2360
|
+
exports.TransferState = TransferState;
|
|
2361
|
+
exports.executeRoute = executeRoute;
|