@skip-go/client 1.0.0-alpha-4 → 1.0.0

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