@injectivelabs/wallet-core 1.20.8 → 1.20.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1260 +1,8 @@
1
- let __injectivelabs_exceptions = require("@injectivelabs/exceptions");
2
- let eventemitter3 = require("eventemitter3");
3
- let __injectivelabs_wallet_base = require("@injectivelabs/wallet-base");
4
- let __injectivelabs_ts_types = require("@injectivelabs/ts-types");
5
- let __injectivelabs_sdk_ts_core_accounts = require("@injectivelabs/sdk-ts/core/accounts");
6
- let __injectivelabs_sdk_ts_utils = require("@injectivelabs/sdk-ts/utils");
7
- let __injectivelabs_sdk_ts_client_indexer = require("@injectivelabs/sdk-ts/client/indexer");
8
- let __injectivelabs_networks = require("@injectivelabs/networks");
9
- let __injectivelabs_sdk_ts_client_chain = require("@injectivelabs/sdk-ts/client/chain");
10
- let __injectivelabs_utils = require("@injectivelabs/utils");
11
- let __injectivelabs_sdk_ts_core_tx = require("@injectivelabs/sdk-ts/core/tx");
12
-
13
- //#region src/utils/tx.ts
14
- const checkIfTxRunOutOfGas = (e) => {
15
- return e instanceof __injectivelabs_exceptions.TransactionException && e.contextCode === __injectivelabs_exceptions.ChainCosmosErrorCode.ErrOutOfGas && e.contextModule === __injectivelabs_exceptions.TransactionChainErrorModule.CosmosSdk && e.originalMessage.includes("out of gas");
16
- };
17
-
18
- //#endregion
19
- //#region \0@oxc-project+runtime@0.99.0/helpers/typeof.js
20
- function _typeof(o) {
21
- "@babel/helpers - typeof";
22
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
23
- return typeof o$1;
24
- } : function(o$1) {
25
- return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
26
- }, _typeof(o);
27
- }
28
-
29
- //#endregion
30
- //#region \0@oxc-project+runtime@0.99.0/helpers/toPrimitive.js
31
- function toPrimitive(t, r) {
32
- if ("object" != _typeof(t) || !t) return t;
33
- var e = t[Symbol.toPrimitive];
34
- if (void 0 !== e) {
35
- var i = e.call(t, r || "default");
36
- if ("object" != _typeof(i)) return i;
37
- throw new TypeError("@@toPrimitive must return a primitive value.");
38
- }
39
- return ("string" === r ? String : Number)(t);
40
- }
41
-
42
- //#endregion
43
- //#region \0@oxc-project+runtime@0.99.0/helpers/toPropertyKey.js
44
- function toPropertyKey(t) {
45
- var i = toPrimitive(t, "string");
46
- return "symbol" == _typeof(i) ? i : i + "";
47
- }
48
-
49
- //#endregion
50
- //#region \0@oxc-project+runtime@0.99.0/helpers/defineProperty.js
51
- function _defineProperty(e, r, t) {
52
- return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
53
- value: t,
54
- enumerable: !0,
55
- configurable: !0,
56
- writable: !0
57
- }) : e[r] = t, e;
58
- }
59
-
60
- //#endregion
61
- //#region src/strategy/BaseWalletStrategy.ts
62
- const getInitialWallet = (args) => {
63
- if (args.wallet) return args.wallet;
64
- const keys = Object.keys(args.strategies || {});
65
- if (keys.length === 0) return __injectivelabs_wallet_base.Wallet.Metamask;
66
- if (keys.includes(__injectivelabs_wallet_base.Wallet.Metamask) && args.evmOptions) return __injectivelabs_wallet_base.Wallet.Metamask;
67
- if (keys.includes(__injectivelabs_wallet_base.Wallet.Keplr) && !args.evmOptions) return __injectivelabs_wallet_base.Wallet.Keplr;
68
- return keys[0];
69
- };
70
- var BaseWalletStrategy = class {
71
- constructor(args) {
72
- _defineProperty(this, "strategies", void 0);
73
- _defineProperty(this, "wallet", void 0);
74
- _defineProperty(this, "args", void 0);
75
- _defineProperty(this, "metadata", void 0);
76
- _defineProperty(this, "wallets", void 0);
77
- _defineProperty(this, "emitter", void 0);
78
- _defineProperty(this, "on", void 0);
79
- _defineProperty(this, "off", void 0);
80
- _defineProperty(this, "emit", void 0);
81
- this.args = args;
82
- this.strategies = args.strategies;
83
- this.wallet = getInitialWallet(args);
84
- this.metadata = args.metadata;
85
- this.emitter = new eventemitter3.EventEmitter();
86
- this.on = this.emitter.on.bind(this.emitter);
87
- this.off = this.emitter.off.bind(this.emitter);
88
- this.emit = this.emitter.emit.bind(this.emitter);
89
- }
90
- /**
91
- * Get the emitter instance.
92
- * Used to pass to strategies so they can emit events directly.
93
- */
94
- getEmitter() {
95
- return this.emitter;
96
- }
97
- getWallet() {
98
- return this.wallet;
99
- }
100
- async setWallet(wallet) {
101
- var _strategy$initStrateg;
102
- this.wallet = wallet;
103
- const strategy = this.getStrategy();
104
- await (strategy === null || strategy === void 0 || (_strategy$initStrateg = strategy.initStrategy) === null || _strategy$initStrateg === void 0 ? void 0 : _strategy$initStrateg.call(strategy));
105
- }
106
- setMetadata(metadata) {
107
- var _this$getStrategy$set, _this$getStrategy;
108
- this.metadata = metadata;
109
- (_this$getStrategy$set = (_this$getStrategy = this.getStrategy()).setMetadata) === null || _this$getStrategy$set === void 0 || _this$getStrategy$set.call(_this$getStrategy, metadata);
110
- }
111
- getStrategy() {
112
- if (!this.strategies[this.wallet]) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error(`Wallet ${this.wallet} is not enabled/available!`));
113
- return this.strategies[this.wallet];
114
- }
115
- getAddresses(args) {
116
- return this.getStrategy().getAddresses(args);
117
- }
118
- getAddressesInfo(args) {
119
- return this.getStrategy().getAddressesInfo(args);
120
- }
121
- getWalletDeviceType() {
122
- return this.getStrategy().getWalletDeviceType();
123
- }
124
- getPubKey(address) {
125
- return this.getStrategy().getPubKey(address);
126
- }
127
- enable(args) {
128
- return this.getStrategy().enable(args);
129
- }
130
- async enableAndGetAddresses(args) {
131
- await this.getStrategy().enable(args);
132
- return this.getStrategy().getAddresses(args);
133
- }
134
- getEthereumChainId() {
135
- return this.getStrategy().getEthereumChainId();
136
- }
137
- async getEvmTransactionReceipt(txHash, evmChainId) {
138
- return this.getStrategy().getEvmTransactionReceipt(txHash, evmChainId);
139
- }
140
- async getSessionOrConfirm(address) {
141
- return this.getStrategy().getSessionOrConfirm(address);
142
- }
143
- async getWalletClient() {
144
- var _this$getStrategy2;
145
- if ((_this$getStrategy2 = this.getStrategy()) === null || _this$getStrategy2 === void 0 ? void 0 : _this$getStrategy2.getWalletClient) {
146
- var _this$getStrategy3, _this$getStrategy3$ge;
147
- const result = (_this$getStrategy3 = this.getStrategy()) === null || _this$getStrategy3 === void 0 || (_this$getStrategy3$ge = _this$getStrategy3.getWalletClient) === null || _this$getStrategy3$ge === void 0 ? void 0 : _this$getStrategy3$ge.call(_this$getStrategy3);
148
- if (result) return result;
149
- }
150
- throw new __injectivelabs_exceptions.WalletException(/* @__PURE__ */ new Error("Wallet client not found. Please check your wallet strategy."));
151
- }
152
- async sendTransaction(tx, options) {
153
- return this.getStrategy().sendTransaction(tx, options);
154
- }
155
- async sendEvmTransaction(tx, options) {
156
- return this.getStrategy().sendEvmTransaction(tx, options);
157
- }
158
- async signEip712TypedData(eip712TypedData, address, options = {}) {
159
- if ((0, __injectivelabs_wallet_base.isCosmosWallet)(this.wallet)) throw new __injectivelabs_exceptions.WalletException(/* @__PURE__ */ new Error(`You can't sign Ethereum Transaction using ${this.wallet}`));
160
- /** Phantom wallet needs enabling before signing */
161
- if (this.wallet === __injectivelabs_wallet_base.Wallet.Phantom) await this.enable();
162
- this.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionSignStart);
163
- const response = await this.getStrategy().signEip712TypedData(eip712TypedData, address, options);
164
- this.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionSigned);
165
- return response;
166
- }
167
- async signAminoCosmosTransaction(transaction) {
168
- if ((0, __injectivelabs_wallet_base.isEvmWallet)(this.wallet)) throw new __injectivelabs_exceptions.WalletException(/* @__PURE__ */ new Error(`You can't sign Cosmos Transaction using ${this.wallet}`));
169
- this.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionSignStart);
170
- const response = await this.getStrategy().signAminoCosmosTransaction(transaction);
171
- this.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionSigned);
172
- return response;
173
- }
174
- async signCosmosTransaction(transaction) {
175
- if ((0, __injectivelabs_wallet_base.isEvmWallet)(this.wallet)) throw new __injectivelabs_exceptions.WalletException(/* @__PURE__ */ new Error(`You can't sign Cosmos Transaction using ${this.wallet}`));
176
- this.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionSignStart);
177
- const response = await this.getStrategy().signCosmosTransaction(transaction);
178
- this.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionSigned);
179
- return response;
180
- }
181
- async signArbitrary(signer, data) {
182
- if (this.getStrategy().signArbitrary) {
183
- this.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionSignStart);
184
- const response = await this.getStrategy().signArbitrary(signer, data);
185
- this.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionSigned);
186
- return response;
187
- }
188
- }
189
- async onAccountChange(callback) {
190
- if (this.getStrategy().onAccountChange) return this.getStrategy().onAccountChange(callback);
191
- }
192
- async onChainIdChange(callback) {
193
- if (this.getStrategy().onChainIdChange) return this.getStrategy().onChainIdChange(callback);
194
- }
195
- async disconnect() {
196
- if (this.getStrategy().disconnect) {
197
- await this.getStrategy().disconnect();
198
- this.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.WalletStrategyDisconnect);
199
- }
200
- }
201
- getCosmosWallet(chainId) {
202
- const strategy = this.getStrategy();
203
- if (strategy.getCosmosWallet == void 0) throw new __injectivelabs_exceptions.WalletException(/* @__PURE__ */ new Error(`This method is not available for ${this.getWallet()} wallet`));
204
- return strategy.getCosmosWallet(chainId);
205
- }
206
- async getEip1193Provider() {
207
- if (this.getStrategy().getEip1193Provider) return this.getStrategy().getEip1193Provider();
208
- throw new __injectivelabs_exceptions.WalletException(/* @__PURE__ */ new Error("EIP1193 provider not found. Please check your wallet strategy."));
209
- }
210
- async getOfflineSigner(chainId) {
211
- if (this.getStrategy().getOfflineSigner) return this.getStrategy().getOfflineSigner(chainId);
212
- throw new __injectivelabs_exceptions.WalletException(/* @__PURE__ */ new Error("Offline signer not found. Please check your wallet strategy."));
213
- }
214
- };
215
-
216
- //#endregion
217
- //#region src/broadcaster/MsgBroadcaster.ts
218
- const getEthereumWalletPubKey = async ({ pubKey, eip712TypedData, signature }) => {
219
- if (pubKey) return pubKey;
220
- return (0, __injectivelabs_sdk_ts_utils.hexToBase64)(await (0, __injectivelabs_sdk_ts_utils.recoverTypedSignaturePubKey)(eip712TypedData, signature));
221
- };
222
- const defaultRetriesConfig = () => ({ [`${__injectivelabs_exceptions.TransactionChainErrorModule.CosmosSdk}-${__injectivelabs_exceptions.ChainCosmosErrorCode.ErrMempoolIsFull}`]: {
223
- retries: 0,
224
- maxRetries: 10,
225
- timeout: 1e3
226
- } });
227
- /**
228
- * This class is used to broadcast transactions
229
- * using the WalletStrategy as a handler
230
- * for the sign/broadcast flow of the transactions
231
- *
232
- * Mainly used for building UI products
233
- */
234
- var MsgBroadcaster = class {
235
- constructor(options) {
236
- _defineProperty(this, "options", void 0);
237
- _defineProperty(this, "walletStrategy", void 0);
238
- _defineProperty(this, "endpoints", void 0);
239
- _defineProperty(this, "chainId", void 0);
240
- _defineProperty(this, "txTimeout", __injectivelabs_utils.DEFAULT_BLOCK_TIMEOUT_HEIGHT);
241
- _defineProperty(this, "simulateTx", true);
242
- _defineProperty(this, "txTimeoutOnFeeDelegation", false);
243
- _defineProperty(this, "evmChainId", void 0);
244
- _defineProperty(this, "gasBufferCoefficient", 1.2);
245
- _defineProperty(this, "retriesOnError", defaultRetriesConfig());
246
- _defineProperty(this, "httpHeaders", void 0);
247
- _defineProperty(this, "txInclusion", void 0);
248
- const networkInfo = (0, __injectivelabs_networks.getNetworkInfo)(options.network);
249
- this.options = options;
250
- this.simulateTx = options.simulateTx !== void 0 ? options.simulateTx : true;
251
- this.txTimeout = options.txTimeout || __injectivelabs_utils.DEFAULT_BLOCK_TIMEOUT_HEIGHT;
252
- this.txTimeoutOnFeeDelegation = options.txTimeoutOnFeeDelegation !== void 0 ? options.txTimeoutOnFeeDelegation : true;
253
- this.gasBufferCoefficient = options.gasBufferCoefficient || 1.2;
254
- this.chainId = options.chainId || networkInfo.chainId;
255
- this.evmChainId = options.evmChainId || networkInfo.evmChainId;
256
- this.endpoints = options.endpoints || (0, __injectivelabs_networks.getNetworkEndpoints)(options.network);
257
- this.walletStrategy = options.walletStrategy;
258
- this.httpHeaders = options.httpHeaders;
259
- this.txInclusion = options.txInclusion;
260
- }
261
- setOptions(options) {
262
- this.simulateTx = options.simulateTx || this.simulateTx;
263
- this.txTimeout = options.txTimeout || this.txTimeout;
264
- this.txTimeoutOnFeeDelegation = options.txTimeoutOnFeeDelegation || this.txTimeoutOnFeeDelegation;
265
- this.txInclusion = options.txInclusion || this.txInclusion;
266
- }
267
- async getEvmChainId() {
268
- const { walletStrategy } = this;
269
- if (!(0, __injectivelabs_wallet_base.isEvmBrowserWallet)(walletStrategy.wallet)) return this.evmChainId;
270
- const mainnetEvmIds = [__injectivelabs_ts_types.EvmChainId.Mainnet, __injectivelabs_ts_types.EvmChainId.MainnetEvm];
271
- const testnetEvmIds = [__injectivelabs_ts_types.EvmChainId.Sepolia, __injectivelabs_ts_types.EvmChainId.TestnetEvm];
272
- const devnetEvmIds = [
273
- __injectivelabs_ts_types.EvmChainId.Sepolia,
274
- __injectivelabs_ts_types.EvmChainId.DevnetEvm,
275
- __injectivelabs_ts_types.EvmChainId.MainnetEvm,
276
- __injectivelabs_ts_types.EvmChainId.TestnetEvm
277
- ];
278
- try {
279
- const chainId = await walletStrategy.getEthereumChainId();
280
- if (!chainId) return this.evmChainId;
281
- const evmChainId = parseInt(chainId, 16);
282
- if (isNaN(evmChainId)) return this.evmChainId;
283
- if ((0, __injectivelabs_networks.isMainnet)(this.options.network) && !mainnetEvmIds.includes(evmChainId) || (0, __injectivelabs_networks.isTestnet)(this.options.network) && !testnetEvmIds.includes(evmChainId) || !(0, __injectivelabs_networks.isMainnet)(this.options.network) && !(0, __injectivelabs_networks.isTestnet)(this.options.network) && !devnetEvmIds.includes(evmChainId)) throw new __injectivelabs_exceptions.WalletException(/* @__PURE__ */ new Error("Your selected network is incorrect"));
284
- return evmChainId;
285
- } catch (e) {
286
- throw new __injectivelabs_exceptions.WalletException(e);
287
- }
288
- }
289
- /**
290
- * Broadcasting the transaction using the client
291
- * side approach for both cosmos and ethereum native wallets
292
- *
293
- * @param tx
294
- * @returns {string} transaction hash
295
- */
296
- async broadcast(tx) {
297
- const { walletStrategy } = this;
298
- const txWithAddresses = {
299
- ...tx,
300
- ethereumAddress: (0, __injectivelabs_wallet_base.getEthereumSignerAddress)(tx.injectiveAddress),
301
- injectiveAddress: (0, __injectivelabs_wallet_base.getInjectiveSignerAddress)(tx.injectiveAddress)
302
- };
303
- if (__injectivelabs_sdk_ts_utils.ofacList.includes(txWithAddresses.ethereumAddress)) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("You cannot execute this transaction"));
304
- try {
305
- return (0, __injectivelabs_wallet_base.isCosmosWallet)(walletStrategy.wallet) ? await this.broadcastDirectSign(txWithAddresses) : (0, __injectivelabs_wallet_base.isEip712V2OnlyWallet)(walletStrategy.wallet) ? await this.broadcastEip712V2(txWithAddresses) : await this.broadcastEip712(txWithAddresses);
306
- } catch (e) {
307
- const error = e;
308
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionFail);
309
- if ((0, __injectivelabs_exceptions.isThrownException)(error)) throw error;
310
- throw new __injectivelabs_exceptions.TransactionException(new Error(error));
311
- }
312
- }
313
- /**
314
- * Broadcasting the transaction using the client
315
- * side approach for both cosmos and ethereum native wallets
316
- * Note: using EIP712_V2 for Ethereum wallets
317
- *
318
- * @param tx
319
- * @returns {string} transaction hash
320
- */
321
- async broadcastV2(tx) {
322
- const { walletStrategy } = this;
323
- const txWithAddresses = {
324
- ...tx,
325
- ethereumAddress: (0, __injectivelabs_wallet_base.getEthereumSignerAddress)(tx.injectiveAddress),
326
- injectiveAddress: (0, __injectivelabs_wallet_base.getInjectiveSignerAddress)(tx.injectiveAddress)
327
- };
328
- if (__injectivelabs_sdk_ts_utils.ofacList.includes(txWithAddresses.ethereumAddress)) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("You cannot execute this transaction"));
329
- try {
330
- return (0, __injectivelabs_wallet_base.isCosmosWallet)(walletStrategy.wallet) ? await this.broadcastDirectSign(txWithAddresses) : await this.broadcastEip712V2(txWithAddresses);
331
- } catch (e) {
332
- const error = e;
333
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionFail);
334
- if ((0, __injectivelabs_exceptions.isThrownException)(error)) throw error;
335
- throw new __injectivelabs_exceptions.TransactionException(new Error(error));
336
- }
337
- }
338
- /**
339
- * Broadcasting the transaction using the feeDelegation
340
- * support approach for both cosmos and ethereum native wallets
341
- *
342
- * @param tx
343
- * @returns {string} transaction hash
344
- */
345
- async broadcastWithFeeDelegation(tx) {
346
- const { walletStrategy } = this;
347
- const txWithAddresses = {
348
- ...tx,
349
- ethereumAddress: (0, __injectivelabs_wallet_base.getEthereumSignerAddress)(tx.injectiveAddress),
350
- injectiveAddress: (0, __injectivelabs_wallet_base.getInjectiveSignerAddress)(tx.injectiveAddress)
351
- };
352
- if (__injectivelabs_sdk_ts_utils.ofacList.includes(txWithAddresses.ethereumAddress)) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("You cannot execute this transaction"));
353
- try {
354
- return (0, __injectivelabs_wallet_base.isCosmosWallet)(walletStrategy.wallet) ? await this.broadcastDirectSignWithFeeDelegation(txWithAddresses) : await this.broadcastEip712WithFeeDelegation(txWithAddresses);
355
- } catch (e) {
356
- const error = e;
357
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionFail);
358
- if ((0, __injectivelabs_exceptions.isThrownException)(error)) throw error;
359
- throw new __injectivelabs_exceptions.TransactionException(new Error(error));
360
- }
361
- }
362
- /**
363
- * Sign and broadcast a pre-built transaction whose fee payer signature
364
- * is already provided (e.g. from the RFQ executor / web3-gw `prepare`
365
- * endpoint). The taker is signed locally with the supplied private key.
366
- *
367
- * Autosign-only: the caller passes the autosign private key directly
368
- * (e.g. `sharedWalletStore.autoSign.privateKey`). We don't go through
369
- * `walletStrategy.signCosmosTransaction` because the PK strategy stubs
370
- * that out — and going through the wallet strategy would defeat the
371
- * point of autosign (no popups).
372
- *
373
- * @param tx Base64-encoded or raw `TxRaw` bytes returned by the prepare endpoint
374
- * @param feePayerSig Hex (`0x...`) or base64 fee payer signature
375
- * @param accountNumber Account number of the taker
376
- * @param privateKey Taker (autosign) private key — hex, with or without `0x`
377
- * @returns transaction response with txHash
378
- */
379
- async broadcastWithFeePayerSig({ tx, privateKey, feePayerSig, accountNumber, txInclusion, txTimeoutInBlocks: txTimeoutInBlocksParam }) {
380
- const { chainId, endpoints, walletStrategy } = this;
381
- const txTimeoutInBlocks = this.resolveTimeoutInBlocks(txTimeoutInBlocksParam);
382
- const pk = __injectivelabs_sdk_ts_core_accounts.PrivateKey.fromHex(privateKey);
383
- if (__injectivelabs_sdk_ts_utils.ofacList.includes(pk.toHex().toLowerCase())) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("You cannot execute this transaction"));
384
- const txBytes = typeof tx === "string" ? (0, __injectivelabs_sdk_ts_utils.base64ToUint8Array)(tx) : tx;
385
- const txRaw = __injectivelabs_sdk_ts_core_tx.CosmosTxV1Beta1TxPb.TxRaw.fromBinary(txBytes);
386
- try {
387
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationStart);
388
- const signDoc = __injectivelabs_sdk_ts_core_tx.CosmosTxV1Beta1TxPb.SignDoc.create({
389
- chainId,
390
- bodyBytes: txRaw.bodyBytes,
391
- authInfoBytes: txRaw.authInfoBytes,
392
- accountNumber: BigInt(accountNumber)
393
- });
394
- const signDocBytes = __injectivelabs_sdk_ts_core_tx.CosmosTxV1Beta1TxPb.SignDoc.toBinary(signDoc);
395
- const takerSig = await pk.sign(signDocBytes);
396
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationEnd);
397
- txRaw.signatures = [takerSig, feePayerSig.startsWith("0x") ? (0, __injectivelabs_sdk_ts_utils.hexToUint8Array)(feePayerSig.slice(2)) : (0, __injectivelabs_sdk_ts_utils.base64ToUint8Array)(feePayerSig)];
398
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastStart);
399
- const txInclusionOptions = this.resolveTxInclusionOptions({ txInclusion });
400
- const txResponse = await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).broadcast(txRaw, {
401
- txTimeout: txTimeoutInBlocks,
402
- ...txInclusionOptions,
403
- onBroadcast: () => {
404
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastSynced);
405
- }
406
- });
407
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
408
- if (txResponse.code !== 0) throw new __injectivelabs_exceptions.TransactionException(/* @__PURE__ */ new Error(`Transaction failed - ${txResponse.rawLog} - ${txResponse.txHash}`), {
409
- code: __injectivelabs_exceptions.UnspecifiedErrorCode,
410
- contextCode: txResponse.code,
411
- contextModule: txResponse.codespace
412
- });
413
- return txResponse;
414
- } catch (e) {
415
- const error = e;
416
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionFail);
417
- if ((0, __injectivelabs_exceptions.isThrownException)(error)) throw error;
418
- throw new __injectivelabs_exceptions.TransactionException(new Error(error));
419
- }
420
- }
421
- /**
422
- * Prepare/sign/broadcast transaction using
423
- * Ethereum native wallets on the client side.
424
- *
425
- * Note: Gas estimation not available
426
- *
427
- * @param tx The transaction that needs to be broadcasted
428
- * @returns transaction hash
429
- */
430
- async broadcastEip712(tx) {
431
- var _tx$gas, _baseAccount$pubKey;
432
- const { chainId, endpoints, walletStrategy } = this;
433
- const txTimeoutInBlocks = this.resolveTimeoutInBlocks(tx.txTimeoutInBlocks);
434
- const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
435
- const [evmChainId, { baseAccount, latestHeight }] = await Promise.all([this.getEvmChainId(), this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails)]);
436
- if (!evmChainId) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
437
- const timeoutHeight = (0, __injectivelabs_utils.toBigNumber)(latestHeight.toString()).plus(txTimeoutInBlocks);
438
- const txTimeoutTimeInSeconds = txTimeoutInBlocks * __injectivelabs_utils.DEFAULT_BLOCK_TIME_IN_SECONDS;
439
- const txTimeoutTimeInMilliSeconds = txTimeoutTimeInSeconds * 1e3;
440
- const gas = (((_tx$gas = tx.gas) === null || _tx$gas === void 0 ? void 0 : _tx$gas.gas) || (0, __injectivelabs_sdk_ts_utils.getGasPriceBasedOnMessage)(msgs)).toString();
441
- let stdFee = (0, __injectivelabs_utils.getStdFee)({
442
- ...tx.gas,
443
- gas
444
- });
445
- /**
446
- * Account has not been created on chain
447
- * and we cannot simulate the transaction
448
- * to estimate the gas
449
- **/
450
- if (!baseAccount.pubKey) stdFee = await this.getStdFeeWithDynamicBaseFee(stdFee);
451
- else {
452
- const { stdFee: simulatedStdFee } = await this.getTxWithSignersAndStdFee({
453
- chainId,
454
- signMode: __injectivelabs_sdk_ts_core_tx.SIGN_EIP712,
455
- memo: tx.memo,
456
- message: msgs,
457
- timeoutHeight: timeoutHeight.toNumber(),
458
- signers: {
459
- pubKey: baseAccount.pubKey.key,
460
- accountNumber: baseAccount.accountNumber,
461
- sequence: baseAccount.sequence
462
- },
463
- fee: stdFee
464
- });
465
- stdFee = simulatedStdFee;
466
- }
467
- /** EIP712 for signing on Ethereum wallets */
468
- const eip712TypedData = (0, __injectivelabs_sdk_ts_core_tx.getEip712TypedData)({
469
- msgs,
470
- fee: stdFee,
471
- tx: {
472
- memo: tx.memo,
473
- accountNumber: baseAccount.accountNumber.toString(),
474
- sequence: baseAccount.sequence.toString(),
475
- timeoutHeight: timeoutHeight.toFixed(),
476
- chainId
477
- },
478
- evmChainId
479
- });
480
- /** Signing on Ethereum */
481
- const signature = await walletStrategy.signEip712TypedData((0, __injectivelabs_sdk_ts_utils.safeBigIntStringify)(eip712TypedData), tx.ethereumAddress, { txTimeout: txTimeoutTimeInSeconds });
482
- const pubKeyOrSignatureDerivedPubKey = await getEthereumWalletPubKey({
483
- pubKey: (_baseAccount$pubKey = baseAccount.pubKey) === null || _baseAccount$pubKey === void 0 ? void 0 : _baseAccount$pubKey.key,
484
- eip712TypedData,
485
- signature
486
- });
487
- /** Preparing the transaction for client broadcasting */
488
- const { txRaw } = (0, __injectivelabs_sdk_ts_core_tx.createTransaction)({
489
- message: msgs,
490
- memo: tx.memo,
491
- signMode: __injectivelabs_sdk_ts_core_tx.SIGN_EIP712,
492
- fee: stdFee,
493
- pubKey: pubKeyOrSignatureDerivedPubKey,
494
- sequence: baseAccount.sequence,
495
- timeoutHeight: timeoutHeight.toNumber(),
496
- accountNumber: baseAccount.accountNumber,
497
- chainId
498
- });
499
- const txRawEip712 = (0, __injectivelabs_sdk_ts_core_tx.createTxRawEIP712)(txRaw, (0, __injectivelabs_sdk_ts_core_tx.createWeb3Extension)({ evmChainId }));
500
- /** Append Signatures */
501
- txRawEip712.signatures = [(0, __injectivelabs_sdk_ts_utils.hexToBuff)(signature)];
502
- const inclusionWaiter = await this.prepareTxInclusionWaiter({
503
- tx,
504
- txRawOrSignResponse: txRawEip712,
505
- timeout: txTimeoutTimeInMilliSeconds
506
- });
507
- let response;
508
- try {
509
- response = await walletStrategy.sendTransaction(txRawEip712, {
510
- chainId,
511
- endpoints,
512
- txTimeout: txTimeoutInBlocks,
513
- txInclusion: this.resolveTxInclusionOptions(tx),
514
- address: tx.injectiveAddress,
515
- onBroadcast: () => {
516
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastSynced);
517
- }
518
- });
519
- } catch (e) {
520
- inclusionWaiter.close();
521
- throw e;
522
- }
523
- const confirmedTx = await this.waitForPreparedTxInclusion({
524
- tx,
525
- inclusionWaiter,
526
- responseTxHash: response.txHash,
527
- timeout: txTimeoutTimeInMilliSeconds
528
- });
529
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
530
- return confirmedTx;
531
- }
532
- /**
533
- * Prepare/sign/broadcast transaction using
534
- * Ethereum native wallets on the client side.
535
- *
536
- * Note: Gas estimation not available
537
- *
538
- * @param tx The transaction that needs to be broadcasted
539
- * @returns transaction hash
540
- */
541
- async broadcastEip712V2(tx) {
542
- var _tx$gas2, _baseAccount$pubKey2;
543
- const { chainId, endpoints, walletStrategy } = this;
544
- const txTimeoutInBlocks = this.resolveTimeoutInBlocks(tx.txTimeoutInBlocks);
545
- const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
546
- const [evmChainId, { baseAccount, latestHeight }] = await Promise.all([this.getEvmChainId(), this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails)]);
547
- if (!evmChainId) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
548
- const timeoutHeight = (0, __injectivelabs_utils.toBigNumber)(latestHeight).plus(txTimeoutInBlocks);
549
- const txTimeoutTimeInSeconds = txTimeoutInBlocks * __injectivelabs_utils.DEFAULT_BLOCK_TIME_IN_SECONDS;
550
- const txTimeoutTimeInMilliSeconds = txTimeoutTimeInSeconds * 1e3;
551
- const gas = (((_tx$gas2 = tx.gas) === null || _tx$gas2 === void 0 ? void 0 : _tx$gas2.gas) || (0, __injectivelabs_sdk_ts_utils.getGasPriceBasedOnMessage)(msgs)).toString();
552
- let stdFee = (0, __injectivelabs_utils.getStdFee)({
553
- ...tx.gas,
554
- gas
555
- });
556
- /**
557
- * Account has not been created on chain
558
- * and we cannot simulate the transaction
559
- * to estimate the gas
560
- **/
561
- if (!baseAccount.pubKey) stdFee = await this.getStdFeeWithDynamicBaseFee(stdFee);
562
- else {
563
- const { stdFee: simulatedStdFee } = await this.getTxWithSignersAndStdFee({
564
- chainId,
565
- signMode: __injectivelabs_sdk_ts_core_tx.SIGN_EIP712_V2,
566
- memo: tx.memo,
567
- message: msgs,
568
- timeoutHeight: timeoutHeight.toNumber(),
569
- signers: {
570
- pubKey: baseAccount.pubKey.key,
571
- sequence: baseAccount.sequence,
572
- accountNumber: baseAccount.accountNumber
573
- },
574
- fee: stdFee
575
- });
576
- stdFee = simulatedStdFee;
577
- }
578
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationStart);
579
- /** EIP712 for signing on Ethereum wallets */
580
- const eip712TypedData = (0, __injectivelabs_sdk_ts_core_tx.getEip712TypedDataV2)({
581
- msgs,
582
- fee: stdFee,
583
- tx: {
584
- memo: tx.memo,
585
- accountNumber: baseAccount.accountNumber.toString(),
586
- sequence: baseAccount.sequence.toString(),
587
- timeoutHeight: timeoutHeight.toFixed(),
588
- chainId
589
- },
590
- evmChainId
591
- });
592
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationEnd);
593
- /** Signing on Ethereum */
594
- const signature = await walletStrategy.signEip712TypedData((0, __injectivelabs_sdk_ts_utils.safeBigIntStringify)(eip712TypedData), tx.ethereumAddress, { txTimeout: txTimeoutTimeInSeconds });
595
- const pubKeyOrSignatureDerivedPubKey = await getEthereumWalletPubKey({
596
- pubKey: (_baseAccount$pubKey2 = baseAccount.pubKey) === null || _baseAccount$pubKey2 === void 0 ? void 0 : _baseAccount$pubKey2.key,
597
- eip712TypedData,
598
- signature
599
- });
600
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastStart);
601
- const { txRaw } = (0, __injectivelabs_sdk_ts_core_tx.createTransaction)({
602
- message: msgs,
603
- memo: tx.memo,
604
- signMode: __injectivelabs_sdk_ts_core_tx.SIGN_EIP712_V2,
605
- fee: stdFee,
606
- pubKey: pubKeyOrSignatureDerivedPubKey,
607
- sequence: baseAccount.sequence,
608
- timeoutHeight: timeoutHeight.toNumber(),
609
- accountNumber: baseAccount.accountNumber,
610
- chainId
611
- });
612
- const txRawEip712 = (0, __injectivelabs_sdk_ts_core_tx.createTxRawEIP712)(txRaw, (0, __injectivelabs_sdk_ts_core_tx.createWeb3Extension)({ evmChainId }));
613
- /** Append Signatures */
614
- txRawEip712.signatures = [(0, __injectivelabs_sdk_ts_utils.hexToBuff)(signature)];
615
- const inclusionWaiter = await this.prepareTxInclusionWaiter({
616
- tx,
617
- timeout: txTimeoutTimeInMilliSeconds,
618
- txRawOrSignResponse: txRawEip712
619
- });
620
- let response;
621
- try {
622
- response = await walletStrategy.sendTransaction(txRawEip712, {
623
- chainId,
624
- endpoints,
625
- txTimeout: txTimeoutInBlocks,
626
- txInclusion: this.resolveTxInclusionOptions(tx),
627
- address: tx.injectiveAddress,
628
- onBroadcast: () => {
629
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastSynced);
630
- }
631
- });
632
- } catch (e) {
633
- inclusionWaiter.close();
634
- throw e;
635
- }
636
- const confirmedTx = await this.waitForPreparedTxInclusion({
637
- tx,
638
- inclusionWaiter,
639
- responseTxHash: response.txHash,
640
- timeout: txTimeoutTimeInMilliSeconds
641
- });
642
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
643
- return confirmedTx;
644
- }
645
- /**
646
- * Prepare/sign/broadcast transaction using
647
- * Ethereum native wallets using the Web3Gateway.
648
- *
649
- * @param tx The transaction that needs to be broadcasted
650
- * @returns transaction hash
651
- */
652
- async broadcastEip712WithFeeDelegation(tx) {
653
- const { endpoints, simulateTx, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation } = this;
654
- const txTimeoutInBlocks = this.resolveTimeoutInBlocks(tx.txTimeoutInBlocks);
655
- const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
656
- const web3Msgs = msgs.map((msg) => msg.toWeb3());
657
- const evmChainId = await this.getEvmChainId();
658
- if (!evmChainId) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
659
- const transactionApi = new __injectivelabs_sdk_ts_client_indexer.IndexerGrpcWeb3GwApi(endpoints.web3gw || endpoints.indexer);
660
- if (httpHeaders) transactionApi.setMetadata(httpHeaders);
661
- const txTimeoutTimeInSeconds = txTimeoutInBlocks * __injectivelabs_utils.DEFAULT_BLOCK_TIME_IN_SECONDS;
662
- const txTimeoutTimeInMilliSeconds = txTimeoutTimeInSeconds * 1e3;
663
- let timeoutHeight = void 0;
664
- if (txTimeoutOnFeeDelegation) timeoutHeight = (0, __injectivelabs_utils.toBigNumber)((await new __injectivelabs_sdk_ts_client_chain.ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock()).header.height.toString()).plus(txTimeoutInBlocks).toNumber();
665
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationStart);
666
- const prepareTxResponse = await transactionApi.prepareTxRequest({
667
- timeoutHeight,
668
- memo: tx.memo,
669
- message: web3Msgs,
670
- address: tx.ethereumAddress,
671
- chainId: evmChainId,
672
- gasLimit: (0, __injectivelabs_sdk_ts_utils.getGasPriceBasedOnMessage)(msgs),
673
- estimateGas: simulateTx
674
- });
675
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationEnd);
676
- const signature = await walletStrategy.signEip712TypedData(prepareTxResponse.data, tx.ethereumAddress, { txTimeout: txTimeoutTimeInSeconds });
677
- const broadcast = async () => await transactionApi.broadcastTxRequest({
678
- signature,
679
- message: web3Msgs,
680
- txResponse: prepareTxResponse,
681
- chainId: evmChainId
682
- });
683
- try {
684
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastStart);
685
- const response = await broadcast();
686
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastSynced);
687
- const confirmedTx = await this.waitForTxInclusion({
688
- tx,
689
- txHash: response.txHash,
690
- timeout: txTimeoutTimeInMilliSeconds
691
- });
692
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
693
- return confirmedTx;
694
- } catch (e) {
695
- const error = e;
696
- if ((0, __injectivelabs_exceptions.isThrownException)(error)) {
697
- const exception = error;
698
- /**
699
- * First MsgExec transaction with a PrivateKey wallet
700
- * always runs out of gas for some reason, temporary solution
701
- * to just broadcast the transaction twice
702
- **/
703
- if (walletStrategy.wallet === __injectivelabs_wallet_base.Wallet.PrivateKey && checkIfTxRunOutOfGas(exception)) {
704
- const { baseAccount } = await new __injectivelabs_sdk_ts_client_chain.ChainGrpcAuthApi(endpoints.grpc).fetchAccount(tx.injectiveAddress);
705
- /** We only do it on the first account tx fail */
706
- if (baseAccount.sequence > 1) throw e;
707
- return await this.broadcastEip712WithFeeDelegation(tx);
708
- }
709
- return await this.retryOnException(exception, broadcast);
710
- }
711
- throw e;
712
- }
713
- }
714
- /**
715
- * Prepare/sign/broadcast transaction using
716
- * Cosmos native wallets on the client side.
717
- *
718
- * @param tx The transaction that needs to be broadcasted
719
- * @returns transaction hash
720
- */
721
- async broadcastDirectSign(tx) {
722
- var _tx$gas3;
723
- const { chainId, endpoints, walletStrategy } = this;
724
- const txTimeoutInBlocks = this.resolveTimeoutInBlocks(tx.txTimeoutInBlocks);
725
- const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
726
- /**
727
- * When using Ledger with Keplr/Leap we have
728
- * to send EIP712 to sign on Keplr/Leap
729
- */
730
- if ([__injectivelabs_wallet_base.Wallet.Keplr, __injectivelabs_wallet_base.Wallet.Leap].includes(walletStrategy.getWallet())) {
731
- if (await walletStrategy.getWalletDeviceType() === __injectivelabs_wallet_base.WalletDeviceType.Hardware) return this.experimentalBroadcastWalletThroughLedger(tx);
732
- }
733
- const [{ baseAccount, latestHeight }, pubKey] = await Promise.all([this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails), walletStrategy.getPubKey(tx.injectiveAddress)]);
734
- const timeoutHeight = (0, __injectivelabs_utils.toBigNumber)(latestHeight).plus(txTimeoutInBlocks);
735
- const txTimeoutTimeInMilliSeconds = txTimeoutInBlocks * __injectivelabs_utils.DEFAULT_BLOCK_TIME_IN_SECONDS * 1e3;
736
- const signMode = (0, __injectivelabs_wallet_base.isCosmosAminoOnlyWallet)(walletStrategy.wallet) ? __injectivelabs_sdk_ts_core_tx.SIGN_EIP712 : __injectivelabs_sdk_ts_core_tx.SIGN_DIRECT;
737
- const gas = (((_tx$gas3 = tx.gas) === null || _tx$gas3 === void 0 ? void 0 : _tx$gas3.gas) || (0, __injectivelabs_sdk_ts_utils.getGasPriceBasedOnMessage)(msgs)).toString();
738
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationStart);
739
- /** Prepare the Transaction * */
740
- const { txRaw } = await this.getTxWithSignersAndStdFee({
741
- chainId,
742
- signMode,
743
- memo: tx.memo,
744
- message: msgs,
745
- timeoutHeight: timeoutHeight.toNumber(),
746
- signers: {
747
- pubKey,
748
- accountNumber: baseAccount.accountNumber,
749
- sequence: baseAccount.sequence
750
- },
751
- fee: (0, __injectivelabs_utils.getStdFee)({
752
- ...tx.gas,
753
- gas
754
- })
755
- });
756
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationEnd);
757
- /** Ledger using Cosmos app only allows signing amino docs */
758
- if ((0, __injectivelabs_wallet_base.isCosmosAminoOnlyWallet)(walletStrategy.wallet)) {
759
- var _tx$gas4;
760
- const aminoSignDoc = (0, __injectivelabs_sdk_ts_core_tx.getAminoStdSignDoc)({
761
- ...tx,
762
- ...baseAccount,
763
- msgs,
764
- chainId,
765
- gas: gas || ((_tx$gas4 = tx.gas) === null || _tx$gas4 === void 0 || (_tx$gas4 = _tx$gas4.gas) === null || _tx$gas4 === void 0 ? void 0 : _tx$gas4.toString()),
766
- timeoutHeight: timeoutHeight.toFixed()
767
- });
768
- txRaw.signatures = [(0, __injectivelabs_sdk_ts_utils.base64ToUint8Array)((await walletStrategy.signAminoCosmosTransaction({
769
- signDoc: aminoSignDoc,
770
- address: tx.injectiveAddress
771
- })).signature.signature)];
772
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastStart);
773
- const inclusionWaiter$1 = await this.prepareTxInclusionWaiter({
774
- tx,
775
- txRawOrSignResponse: txRaw,
776
- timeout: txTimeoutTimeInMilliSeconds
777
- });
778
- let response$1;
779
- try {
780
- response$1 = await walletStrategy.sendTransaction(txRaw, {
781
- chainId,
782
- endpoints,
783
- address: tx.injectiveAddress,
784
- txTimeout: txTimeoutInBlocks,
785
- txInclusion: this.resolveTxInclusionOptions(tx),
786
- onBroadcast: () => {
787
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastSynced);
788
- }
789
- });
790
- } catch (e) {
791
- inclusionWaiter$1.close();
792
- throw e;
793
- }
794
- const confirmedTx$1 = await this.waitForPreparedTxInclusion({
795
- tx,
796
- inclusionWaiter: inclusionWaiter$1,
797
- timeout: txTimeoutTimeInMilliSeconds,
798
- responseTxHash: response$1.txHash
799
- });
800
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
801
- return confirmedTx$1;
802
- }
803
- const directSignResponse = await walletStrategy.signCosmosTransaction({
804
- txRaw,
805
- chainId,
806
- address: tx.injectiveAddress,
807
- accountNumber: baseAccount.accountNumber
808
- });
809
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastStart);
810
- const inclusionWaiter = await this.prepareTxInclusionWaiter({
811
- tx,
812
- timeout: txTimeoutTimeInMilliSeconds,
813
- txRawOrSignResponse: directSignResponse
814
- });
815
- let response;
816
- try {
817
- response = await walletStrategy.sendTransaction(directSignResponse, {
818
- chainId,
819
- endpoints,
820
- txTimeout: txTimeoutInBlocks,
821
- txInclusion: this.resolveTxInclusionOptions(tx),
822
- address: tx.injectiveAddress,
823
- onBroadcast: () => {
824
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastSynced);
825
- }
826
- });
827
- } catch (e) {
828
- inclusionWaiter.close();
829
- throw e;
830
- }
831
- const confirmedTx = await this.waitForPreparedTxInclusion({
832
- tx,
833
- inclusionWaiter,
834
- responseTxHash: response.txHash,
835
- timeout: txTimeoutTimeInMilliSeconds
836
- });
837
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
838
- return confirmedTx;
839
- }
840
- /**
841
- * We use this method only when we want to broadcast a transaction using Ledger on Keplr/Leap for Injective
842
- *
843
- * Note: Gas estimation not available
844
- * @param tx the transaction that needs to be broadcasted
845
- */
846
- async experimentalBroadcastWalletThroughLedger(tx) {
847
- var _tx$gas5, _tx$gas6;
848
- const { chainId, endpoints, evmChainId, simulateTx, walletStrategy } = this;
849
- const txTimeoutInBlocks = this.resolveTimeoutInBlocks(tx.txTimeoutInBlocks);
850
- const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
851
- /**
852
- * We can only use this method
853
- * when Ledger is connected through Keplr
854
- */
855
- if ([__injectivelabs_wallet_base.Wallet.Keplr, __injectivelabs_wallet_base.Wallet.Leap].includes(walletStrategy.getWallet())) {
856
- if (!(await walletStrategy.getWalletDeviceType() === __injectivelabs_wallet_base.WalletDeviceType.Hardware)) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error(`This method can only be used when Ledger is connected through ${walletStrategy.getWallet()}`));
857
- }
858
- if (!evmChainId) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
859
- const cosmosWallet = walletStrategy.getCosmosWallet(chainId);
860
- const [{ baseAccount, latestHeight }, pubKey] = await Promise.all([this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails), walletStrategy.getPubKey()]);
861
- const timeoutHeight = (0, __injectivelabs_utils.toBigNumber)(latestHeight).plus(txTimeoutInBlocks);
862
- const gas = (((_tx$gas5 = tx.gas) === null || _tx$gas5 === void 0 ? void 0 : _tx$gas5.gas) || (0, __injectivelabs_sdk_ts_utils.getGasPriceBasedOnMessage)(msgs)).toString();
863
- /** EIP712 for signing on Ethereum wallets */
864
- const eip712TypedData = (0, __injectivelabs_sdk_ts_core_tx.getEip712TypedData)({
865
- msgs,
866
- fee: await this.getStdFeeWithDynamicBaseFee({
867
- ...tx.gas,
868
- gas
869
- }),
870
- tx: {
871
- chainId,
872
- memo: tx.memo,
873
- timeoutHeight: timeoutHeight.toFixed(),
874
- sequence: baseAccount.sequence.toString(),
875
- accountNumber: baseAccount.accountNumber.toString()
876
- },
877
- evmChainId
878
- });
879
- const aminoSignResponse = await cosmosWallet.signEIP712CosmosTx({
880
- eip712: eip712TypedData,
881
- signDoc: (0, __injectivelabs_wallet_base.createEip712StdSignDoc)({
882
- ...tx,
883
- ...baseAccount,
884
- msgs,
885
- chainId,
886
- gas: gas || ((_tx$gas6 = tx.gas) === null || _tx$gas6 === void 0 || (_tx$gas6 = _tx$gas6.gas) === null || _tx$gas6 === void 0 ? void 0 : _tx$gas6.toString()),
887
- timeoutHeight: timeoutHeight.toFixed()
888
- })
889
- });
890
- /**
891
- * Create TxRaw from the signed tx that we
892
- * get as a response in case the user changed the fee/memo
893
- * on the Keplr popup
894
- */
895
- const { txRaw } = (0, __injectivelabs_sdk_ts_core_tx.createTransaction)({
896
- pubKey,
897
- chainId,
898
- message: msgs,
899
- signMode: __injectivelabs_sdk_ts_core_tx.SIGN_EIP712,
900
- memo: aminoSignResponse.signed.memo,
901
- fee: aminoSignResponse.signed.fee,
902
- sequence: parseInt(aminoSignResponse.signed.sequence, 10),
903
- accountNumber: parseInt(aminoSignResponse.signed.account_number, 10),
904
- timeoutHeight: parseInt(aminoSignResponse.signed.timeout_height, 10)
905
- });
906
- const txRawEip712 = (0, __injectivelabs_sdk_ts_core_tx.createTxRawEIP712)(txRaw, (0, __injectivelabs_sdk_ts_core_tx.createWeb3Extension)({ evmChainId }));
907
- if (simulateTx) await this.simulateTxRaw(txRawEip712);
908
- txRawEip712.signatures = [(0, __injectivelabs_sdk_ts_utils.base64ToUint8Array)(aminoSignResponse.signature.signature)];
909
- /** Broadcast the transaction */
910
- const response = await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).broadcast(txRawEip712, {
911
- txTimeout: txTimeoutInBlocks,
912
- ...this.resolveTxInclusionOptions(tx),
913
- onBroadcast: () => {
914
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastSynced);
915
- }
916
- });
917
- if (response.code !== 0) throw new __injectivelabs_exceptions.TransactionException(new Error(response.rawLog), {
918
- code: __injectivelabs_exceptions.UnspecifiedErrorCode,
919
- contextCode: response.code,
920
- contextModule: response.codespace
921
- });
922
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
923
- return response;
924
- }
925
- /**
926
- * Prepare/sign/broadcast transaction using
927
- * Cosmos native wallets using the Web3Gateway.
928
- *
929
- * @param tx The transaction that needs to be broadcasted
930
- * @returns transaction hash
931
- */
932
- async broadcastDirectSignWithFeeDelegation(tx) {
933
- var _tx$gas7;
934
- const { options, chainId, endpoints, simulateTx, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation } = this;
935
- const txTimeoutInBlocks = this.resolveTimeoutInBlocks(tx.txTimeoutInBlocks);
936
- const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
937
- /**
938
- * We can only use this method when Keplr is connected
939
- * with ledger
940
- */
941
- if (walletStrategy.getWallet() === __injectivelabs_wallet_base.Wallet.Keplr) {
942
- if (await walletStrategy.getWalletDeviceType() === __injectivelabs_wallet_base.WalletDeviceType.Hardware) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("Keplr + Ledger is not available with fee delegation. Connect with Ledger directly."));
943
- }
944
- const cosmosWallet = walletStrategy.getCosmosWallet(chainId);
945
- const canDisableCosmosGasCheck = [__injectivelabs_wallet_base.Wallet.Keplr, __injectivelabs_wallet_base.Wallet.OWallet].includes(walletStrategy.wallet);
946
- const feePayerPubKey = await this.fetchFeePayerPubKey(options.feePayerPubKey);
947
- const feePayerPublicKey = __injectivelabs_sdk_ts_core_accounts.PublicKey.fromBase64(feePayerPubKey);
948
- const feePayer = feePayerPublicKey.toAddress().address;
949
- const transactionApi = new __injectivelabs_sdk_ts_client_indexer.IndexerGrpcWeb3GwApi(endpoints.web3gw || endpoints.indexer);
950
- if (httpHeaders) transactionApi.setMetadata(httpHeaders);
951
- const fetchAccountBlockDetails = async () => {
952
- try {
953
- const { baseAccount: baseAccount$1, latestHeight: latestHeight$1 } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails);
954
- return {
955
- baseAccount: baseAccount$1,
956
- latestHeight: latestHeight$1
957
- };
958
- } catch (e) {
959
- const error = e;
960
- if ((0, __injectivelabs_exceptions.isThrownException)(error) && error.message.toLowerCase().includes(`account ${tx.injectiveAddress} not found`)) {
961
- await transactionApi.prepareCosmosTxRequest({
962
- address: tx.injectiveAddress,
963
- message: msgs.map((msg) => msg.toWeb3Gw()),
964
- memo: tx.memo,
965
- estimateGas: simulateTx
966
- });
967
- const { baseAccount: baseAccount$1, latestHeight: latestHeight$1 } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
968
- return {
969
- baseAccount: baseAccount$1,
970
- latestHeight: latestHeight$1
971
- };
972
- }
973
- throw e;
974
- }
975
- };
976
- /** Account Details * */
977
- const { baseAccount, latestHeight } = await fetchAccountBlockDetails();
978
- const chainGrpcAuthApi = new __injectivelabs_sdk_ts_client_chain.ChainGrpcAuthApi(endpoints.grpc);
979
- if (httpHeaders) chainGrpcAuthApi.setMetadata(httpHeaders);
980
- const { baseAccount: feePayerBaseAccount } = await chainGrpcAuthApi.fetchAccount(feePayer);
981
- const timeoutHeight = (0, __injectivelabs_utils.toBigNumber)(latestHeight).plus(txTimeoutOnFeeDelegation ? txTimeoutInBlocks : __injectivelabs_utils.DEFAULT_BLOCK_TIMEOUT_HEIGHT);
982
- const txTimeoutTimeInMilliSeconds = txTimeoutInBlocks * __injectivelabs_utils.DEFAULT_BLOCK_TIME_IN_SECONDS * 1e3;
983
- const pubKey = await walletStrategy.getPubKey();
984
- const gas = (((_tx$gas7 = tx.gas) === null || _tx$gas7 === void 0 ? void 0 : _tx$gas7.gas) || (0, __injectivelabs_sdk_ts_utils.getGasPriceBasedOnMessage)(msgs)).toString();
985
- /** Prepare the Transaction * */
986
- const { txRaw } = await this.getTxWithSignersAndStdFee({
987
- chainId,
988
- memo: tx.memo,
989
- message: msgs,
990
- timeoutHeight: timeoutHeight.toNumber(),
991
- signers: [{
992
- pubKey,
993
- accountNumber: baseAccount.accountNumber,
994
- sequence: baseAccount.sequence
995
- }, {
996
- pubKey: feePayerPublicKey.toBase64(),
997
- accountNumber: feePayerBaseAccount.accountNumber,
998
- sequence: feePayerBaseAccount.sequence
999
- }],
1000
- fee: (0, __injectivelabs_utils.getStdFee)({
1001
- ...tx.gas,
1002
- gas,
1003
- payer: feePayer
1004
- })
1005
- });
1006
- if (canDisableCosmosGasCheck && cosmosWallet.disableGasCheck) cosmosWallet.disableGasCheck(chainId);
1007
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationStart);
1008
- const directSignResponse = await walletStrategy.signCosmosTransaction({
1009
- txRaw,
1010
- chainId,
1011
- address: tx.injectiveAddress,
1012
- accountNumber: baseAccount.accountNumber
1013
- });
1014
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationEnd);
1015
- const signedTxRaw = (0, __injectivelabs_sdk_ts_core_tx.createTxRawFromSigResponse)(directSignResponse);
1016
- const broadcast = async () => await transactionApi.broadcastCosmosTxRequest({
1017
- txRaw: signedTxRaw,
1018
- address: tx.injectiveAddress,
1019
- signature: directSignResponse.signature.signature,
1020
- pubKey: directSignResponse.signature.pub_key || {
1021
- value: pubKey,
1022
- type: "/injective.crypto.v1beta1.ethsecp256k1.PubKey"
1023
- }
1024
- });
1025
- try {
1026
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastStart);
1027
- const inclusionWaiter = await this.prepareTxInclusionWaiter({
1028
- tx,
1029
- txRawOrSignResponse: signedTxRaw,
1030
- timeout: txTimeoutTimeInMilliSeconds
1031
- });
1032
- let response;
1033
- try {
1034
- response = await broadcast();
1035
- } catch (e) {
1036
- inclusionWaiter.close();
1037
- throw e;
1038
- }
1039
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastSynced);
1040
- if (canDisableCosmosGasCheck && cosmosWallet.enableGasCheck) cosmosWallet.enableGasCheck(chainId);
1041
- const confirmedTx = await this.waitForPreparedTxInclusion({
1042
- tx,
1043
- inclusionWaiter,
1044
- responseTxHash: response.txHash,
1045
- timeout: txTimeoutTimeInMilliSeconds
1046
- });
1047
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
1048
- return confirmedTx;
1049
- } catch (e) {
1050
- const error = e;
1051
- if ((0, __injectivelabs_exceptions.isThrownException)(error)) {
1052
- const exception = error;
1053
- return await this.retryOnException(exception, broadcast);
1054
- }
1055
- throw e;
1056
- }
1057
- }
1058
- /**
1059
- * Fetch the fee payer's pub key from the web3 gateway
1060
- *
1061
- * Returns a base64 version of it
1062
- */
1063
- async fetchFeePayerPubKey(existingFeePayerPubKey) {
1064
- if (existingFeePayerPubKey) return existingFeePayerPubKey;
1065
- const { endpoints, httpHeaders } = this;
1066
- const transactionApi = new __injectivelabs_sdk_ts_client_indexer.IndexerGrpcWeb3GwApi(endpoints.web3gw || endpoints.indexer);
1067
- if (httpHeaders) transactionApi.setMetadata(httpHeaders);
1068
- const response = await transactionApi.fetchFeePayer();
1069
- if (!response.feePayerPubKey) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("Please provide a feePayerPubKey"));
1070
- if (response.feePayerPubKey.key.startsWith("0x") || response.feePayerPubKey.key.length === 66) return (0, __injectivelabs_sdk_ts_utils.uint8ArrayToBase64)((0, __injectivelabs_sdk_ts_utils.hexToUint8Array)(response.feePayerPubKey.key));
1071
- return response.feePayerPubKey.key;
1072
- }
1073
- async getStdFeeWithDynamicBaseFee(args) {
1074
- const client = new __injectivelabs_sdk_ts_client_chain.ChainGrpcTxFeesApi(this.endpoints.grpc);
1075
- let baseFee = __injectivelabs_utils.DEFAULT_GAS_PRICE;
1076
- try {
1077
- const response = await client.fetchEipBaseFee();
1078
- baseFee = Number((response === null || response === void 0 ? void 0 : response.baseFee) || __injectivelabs_utils.DEFAULT_GAS_PRICE);
1079
- } catch (_unused) {}
1080
- if (!args) return (0, __injectivelabs_utils.getStdFee)(baseFee ? { gasPrice: baseFee } : {});
1081
- if (typeof args === "string") return (0, __injectivelabs_utils.getStdFee)({
1082
- ...baseFee && { gasPrice: (0, __injectivelabs_utils.toBigNumber)(baseFee).toFixed() },
1083
- gas: args
1084
- });
1085
- return (0, __injectivelabs_utils.getStdFee)({
1086
- ...args,
1087
- ...baseFee && { gasPrice: (0, __injectivelabs_utils.toBigNumber)(baseFee).toFixed() }
1088
- });
1089
- }
1090
- /**
1091
- * In case we don't want to simulate the transaction
1092
- * we get the gas limit based on the message type.
1093
- *
1094
- * If we want to simulate the transaction we set the
1095
- * gas limit based on the simulation and add a small multiplier
1096
- * to be safe (factor of 1.2 as default)
1097
- */
1098
- async getTxWithSignersAndStdFee(args) {
1099
- var _result$gasInfo;
1100
- const { simulateTx } = this;
1101
- if (!simulateTx) return {
1102
- ...(0, __injectivelabs_sdk_ts_core_tx.createTransactionWithSigners)(args),
1103
- stdFee: await this.getStdFeeWithDynamicBaseFee(args.fee)
1104
- };
1105
- const result = await this.simulateTxWithSigners(args);
1106
- if (!((_result$gasInfo = result.gasInfo) === null || _result$gasInfo === void 0 ? void 0 : _result$gasInfo.gasUsed)) return {
1107
- ...(0, __injectivelabs_sdk_ts_core_tx.createTransactionWithSigners)(args),
1108
- stdFee: await this.getStdFeeWithDynamicBaseFee(args.fee)
1109
- };
1110
- const stdGasFee = { ...await this.getStdFeeWithDynamicBaseFee({
1111
- ...(0, __injectivelabs_utils.getStdFee)(args.fee),
1112
- gas: (0, __injectivelabs_utils.toBigNumber)(result.gasInfo.gasUsed).times(this.gasBufferCoefficient).toFixed()
1113
- }) };
1114
- return {
1115
- ...(0, __injectivelabs_sdk_ts_core_tx.createTransactionWithSigners)({
1116
- ...args,
1117
- fee: stdGasFee
1118
- }),
1119
- stdFee: stdGasFee
1120
- };
1121
- }
1122
- /**
1123
- * Create TxRaw and simulate it
1124
- */
1125
- async simulateTxRaw(txRaw) {
1126
- const { endpoints, httpHeaders } = this;
1127
- txRaw.signatures = [new Uint8Array(0)];
1128
- const client = new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc);
1129
- if (httpHeaders) client.setMetadata(httpHeaders);
1130
- return await client.simulate(txRaw);
1131
- }
1132
- /**
1133
- * Create TxRaw and simulate it
1134
- */
1135
- async simulateTxWithSigners(args) {
1136
- const { endpoints, httpHeaders } = this;
1137
- const { txRaw } = (0, __injectivelabs_sdk_ts_core_tx.createTransactionWithSigners)(args);
1138
- txRaw.signatures = Array(Array.isArray(args.signers) ? args.signers.length : 1).fill(new Uint8Array(0));
1139
- const client = new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc);
1140
- if (httpHeaders) client.setMetadata(httpHeaders);
1141
- return await client.simulate(txRaw);
1142
- }
1143
- async retryOnException(exception, retryLogic) {
1144
- const errorsToRetry = Object.keys(this.retriesOnError);
1145
- const errorKey = `${exception.contextModule}-${exception.contextCode}`;
1146
- if (!errorsToRetry.includes(errorKey)) throw exception;
1147
- const retryConfig = this.retriesOnError[errorKey];
1148
- if (retryConfig.retries >= retryConfig.maxRetries) {
1149
- this.retriesOnError = defaultRetriesConfig();
1150
- throw exception;
1151
- }
1152
- await (0, __injectivelabs_utils.sleep)(retryConfig.timeout);
1153
- try {
1154
- retryConfig.retries += 1;
1155
- return await retryLogic();
1156
- } catch (e) {
1157
- const error = e;
1158
- if ((0, __injectivelabs_exceptions.isThrownException)(error)) return this.retryOnException(error, retryLogic);
1159
- throw e;
1160
- }
1161
- }
1162
- async fetchAccountAndBlockDetails(address, existingAccountDetails) {
1163
- const { endpoints, httpHeaders } = this;
1164
- const tendermintClient = new __injectivelabs_sdk_ts_client_chain.ChainGrpcTendermintApi(endpoints.grpc);
1165
- if (httpHeaders) tendermintClient.setMetadata(httpHeaders);
1166
- if (existingAccountDetails) return {
1167
- baseAccount: existingAccountDetails,
1168
- latestHeight: (await tendermintClient.fetchLatestBlock()).header.height.toString()
1169
- };
1170
- const chainClient = new __injectivelabs_sdk_ts_client_chain.ChainGrpcAuthApi(endpoints.grpc);
1171
- if (httpHeaders) chainClient.setMetadata(httpHeaders);
1172
- const [accountDetails, latestBlock] = await Promise.all([chainClient.fetchAccount(address), tendermintClient.fetchLatestBlock()]);
1173
- const { baseAccount } = accountDetails;
1174
- return {
1175
- baseAccount,
1176
- latestHeight: latestBlock.header.height.toString()
1177
- };
1178
- }
1179
- resolveTimeoutInBlocks(override) {
1180
- return typeof override === "number" && Number.isInteger(override) && override > 0 ? override : this.txTimeout;
1181
- }
1182
- resolveTxInclusionOptions(tx) {
1183
- var _txInclusion$eventInc;
1184
- const txInclusion = (tx === null || tx === void 0 ? void 0 : tx.txInclusion) || this.txInclusion;
1185
- if (!txInclusion) return;
1186
- return {
1187
- ...txInclusion,
1188
- eventInclusion: {
1189
- ...txInclusion.eventInclusion,
1190
- rpcEndpoint: ((_txInclusion$eventInc = txInclusion.eventInclusion) === null || _txInclusion$eventInc === void 0 ? void 0 : _txInclusion$eventInc.rpcEndpoint) || this.endpoints.rpc
1191
- }
1192
- };
1193
- }
1194
- createTxGrpcApi() {
1195
- const client = new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(this.endpoints.grpc);
1196
- if (this.httpHeaders) client.setMetadata(this.httpHeaders);
1197
- return client;
1198
- }
1199
- async waitForTxInclusion({ tx, txHash, timeout }) {
1200
- return this.createTxGrpcApi().waitForTxInclusion({
1201
- txHash,
1202
- timeout,
1203
- options: this.resolveTxInclusionOptions(tx)
1204
- });
1205
- }
1206
- async prepareTxInclusionWaiter({ tx, timeout, txRawOrSignResponse }) {
1207
- const txRaw = (0, __injectivelabs_sdk_ts_core_tx.createTxRawFromSigResponse)(txRawOrSignResponse);
1208
- const txHash = __injectivelabs_sdk_ts_core_tx.TxClient.hash(txRaw);
1209
- return this.createTxGrpcApi().prepareTxInclusionWait({
1210
- txHash,
1211
- timeout,
1212
- options: this.resolveTxInclusionOptions(tx)
1213
- });
1214
- }
1215
- async waitForPreparedTxInclusion({ tx, timeout, responseTxHash, inclusionWaiter }) {
1216
- if (!inclusionWaiter) return this.waitForTxInclusion({
1217
- tx,
1218
- timeout,
1219
- txHash: responseTxHash
1220
- });
1221
- const confirmedTx = await inclusionWaiter.wait(responseTxHash);
1222
- if (!confirmedTx) throw new __injectivelabs_exceptions.TransactionException(/* @__PURE__ */ new Error(`The transaction with ${responseTxHash} is not found`));
1223
- return confirmedTx;
1224
- }
1225
- };
1226
-
1227
- //#endregion
1228
- //#region src/broadcaster/Web3Broadcaster.ts
1229
- /**
1230
- * Preparing and broadcasting
1231
- * Ethereum transactions
1232
- */
1233
- var Web3Broadcaster = class {
1234
- constructor({ walletStrategy, evmChainId }) {
1235
- _defineProperty(this, "walletStrategy", void 0);
1236
- _defineProperty(this, "evmChainId", void 0);
1237
- this.evmChainId = evmChainId;
1238
- this.walletStrategy = walletStrategy;
1239
- }
1240
- async sendTransaction(args) {
1241
- const { evmChainId, walletStrategy } = this;
1242
- try {
1243
- const chainId = args.evmChainId || evmChainId;
1244
- const txHash = await walletStrategy.sendEvmTransaction(args.tx, {
1245
- evmChainId: chainId,
1246
- address: args.address
1247
- });
1248
- await walletStrategy.getEvmTransactionReceipt(txHash, chainId);
1249
- return txHash;
1250
- } catch (e) {
1251
- throw new __injectivelabs_exceptions.Web3Exception(new Error(e.message));
1252
- }
1253
- }
1254
- };
1255
-
1256
- //#endregion
1257
- exports.BaseWalletStrategy = BaseWalletStrategy;
1258
- exports.MsgBroadcaster = MsgBroadcaster;
1259
- exports.Web3Broadcaster = Web3Broadcaster;
1260
- exports.checkIfTxRunOutOfGas = checkIfTxRunOutOfGas;
1
+ const require_broadcaster = require('./broadcaster-CPCJe4Al.cjs');
2
+ require('./defineProperty-CImP5zIM.cjs');
3
+ const require_strategy = require('./strategy-D8mmr647.cjs');
4
+
5
+ exports.BaseWalletStrategy = require_strategy.BaseWalletStrategy;
6
+ exports.MsgBroadcaster = require_broadcaster.MsgBroadcaster;
7
+ exports.Web3Broadcaster = require_broadcaster.Web3Broadcaster;
8
+ exports.checkIfTxRunOutOfGas = require_broadcaster.checkIfTxRunOutOfGas;