@injectivelabs/wallet-core 1.17.2-alpha.0 → 1.17.2-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +44 -49
- package/dist/cjs/index.d.cts +38 -56
- package/dist/esm/index.d.ts +38 -56
- package/dist/esm/index.js +15 -19
- package/package.json +11 -7
package/dist/cjs/index.cjs
CHANGED
|
@@ -2,8 +2,8 @@ let __injectivelabs_exceptions = require("@injectivelabs/exceptions");
|
|
|
2
2
|
let eventemitter3 = require("eventemitter3");
|
|
3
3
|
let __injectivelabs_wallet_base = require("@injectivelabs/wallet-base");
|
|
4
4
|
let __injectivelabs_ts_types = require("@injectivelabs/ts-types");
|
|
5
|
-
let __injectivelabs_sdk_ts_utils = require("@injectivelabs/sdk-ts/utils");
|
|
6
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
7
|
let __injectivelabs_sdk_ts_client_indexer = require("@injectivelabs/sdk-ts/client/indexer");
|
|
8
8
|
let __injectivelabs_networks = require("@injectivelabs/networks");
|
|
9
9
|
let __injectivelabs_sdk_ts_client_chain = require("@injectivelabs/sdk-ts/client/chain");
|
|
@@ -15,19 +15,6 @@ const checkIfTxRunOutOfGas = (e) => {
|
|
|
15
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
16
|
};
|
|
17
17
|
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/broadcaster/types.ts
|
|
20
|
-
const WalletStrategyEmitterEventType = {
|
|
21
|
-
TransactionFail: "transaction-fail",
|
|
22
|
-
TransactionSigned: "transaction-signed",
|
|
23
|
-
TransactionSignStart: "transaction-sign-start",
|
|
24
|
-
TransactionBroadcastEnd: "transaction-broadcast-end",
|
|
25
|
-
WalletStrategyDisconnect: "wallet-strategy-disconnect",
|
|
26
|
-
TransactionBroadcastStart: "transaction-broadcast-start",
|
|
27
|
-
TransactionPreparationEnd: "transaction-preparation-end",
|
|
28
|
-
TransactionPreparationStart: "transaction-preparation-start"
|
|
29
|
-
};
|
|
30
|
-
|
|
31
18
|
//#endregion
|
|
32
19
|
//#region \0@oxc-project+runtime@0.98.0/helpers/typeof.js
|
|
33
20
|
function _typeof(o) {
|
|
@@ -100,12 +87,21 @@ var BaseWalletStrategy = class {
|
|
|
100
87
|
this.off = this.emitter.off.bind(this.emitter);
|
|
101
88
|
this.emit = this.emitter.emit.bind(this.emitter);
|
|
102
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
|
+
}
|
|
103
97
|
getWallet() {
|
|
104
98
|
return this.wallet;
|
|
105
99
|
}
|
|
106
100
|
async setWallet(wallet) {
|
|
101
|
+
var _strategy$initStrateg;
|
|
107
102
|
this.wallet = wallet;
|
|
108
|
-
this.getStrategy();
|
|
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));
|
|
109
105
|
}
|
|
110
106
|
setMetadata(metadata) {
|
|
111
107
|
var _this$getStrategy$set, _this$getStrategy;
|
|
@@ -163,30 +159,30 @@ var BaseWalletStrategy = class {
|
|
|
163
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}`));
|
|
164
160
|
/** Phantom wallet needs enabling before signing */
|
|
165
161
|
if (this.wallet === __injectivelabs_wallet_base.Wallet.Phantom) await this.enable();
|
|
166
|
-
this.emit(WalletStrategyEmitterEventType.TransactionSignStart);
|
|
162
|
+
this.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionSignStart);
|
|
167
163
|
const response = await this.getStrategy().signEip712TypedData(eip712TypedData, address, options);
|
|
168
|
-
this.emit(WalletStrategyEmitterEventType.TransactionSigned);
|
|
164
|
+
this.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionSigned);
|
|
169
165
|
return response;
|
|
170
166
|
}
|
|
171
167
|
async signAminoCosmosTransaction(transaction) {
|
|
172
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}`));
|
|
173
|
-
this.emit(WalletStrategyEmitterEventType.TransactionSignStart);
|
|
169
|
+
this.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionSignStart);
|
|
174
170
|
const response = await this.getStrategy().signAminoCosmosTransaction(transaction);
|
|
175
|
-
this.emit(WalletStrategyEmitterEventType.TransactionSigned);
|
|
171
|
+
this.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionSigned);
|
|
176
172
|
return response;
|
|
177
173
|
}
|
|
178
174
|
async signCosmosTransaction(transaction) {
|
|
179
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}`));
|
|
180
|
-
this.emit(WalletStrategyEmitterEventType.TransactionSignStart);
|
|
176
|
+
this.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionSignStart);
|
|
181
177
|
const response = await this.getStrategy().signCosmosTransaction(transaction);
|
|
182
|
-
this.emit(WalletStrategyEmitterEventType.TransactionSigned);
|
|
178
|
+
this.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionSigned);
|
|
183
179
|
return response;
|
|
184
180
|
}
|
|
185
181
|
async signArbitrary(signer, data) {
|
|
186
182
|
if (this.getStrategy().signArbitrary) {
|
|
187
|
-
this.emit(WalletStrategyEmitterEventType.TransactionSignStart);
|
|
183
|
+
this.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionSignStart);
|
|
188
184
|
const response = await this.getStrategy().signArbitrary(signer, data);
|
|
189
|
-
this.emit(WalletStrategyEmitterEventType.TransactionSigned);
|
|
185
|
+
this.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionSigned);
|
|
190
186
|
return response;
|
|
191
187
|
}
|
|
192
188
|
}
|
|
@@ -199,7 +195,7 @@ var BaseWalletStrategy = class {
|
|
|
199
195
|
async disconnect() {
|
|
200
196
|
if (this.getStrategy().disconnect) {
|
|
201
197
|
await this.getStrategy().disconnect();
|
|
202
|
-
this.emit(WalletStrategyEmitterEventType.WalletStrategyDisconnect);
|
|
198
|
+
this.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.WalletStrategyDisconnect);
|
|
203
199
|
}
|
|
204
200
|
}
|
|
205
201
|
getCosmosWallet(chainId) {
|
|
@@ -306,7 +302,7 @@ var MsgBroadcaster = class {
|
|
|
306
302
|
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);
|
|
307
303
|
} catch (e) {
|
|
308
304
|
const error = e;
|
|
309
|
-
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionFail);
|
|
305
|
+
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionFail);
|
|
310
306
|
if ((0, __injectivelabs_exceptions.isThrownException)(error)) throw error;
|
|
311
307
|
throw new __injectivelabs_exceptions.TransactionException(new Error(error));
|
|
312
308
|
}
|
|
@@ -331,7 +327,7 @@ var MsgBroadcaster = class {
|
|
|
331
327
|
return (0, __injectivelabs_wallet_base.isCosmosWallet)(walletStrategy.wallet) ? await this.broadcastDirectSign(txWithAddresses) : await this.broadcastEip712V2(txWithAddresses);
|
|
332
328
|
} catch (e) {
|
|
333
329
|
const error = e;
|
|
334
|
-
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionFail);
|
|
330
|
+
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionFail);
|
|
335
331
|
if ((0, __injectivelabs_exceptions.isThrownException)(error)) throw error;
|
|
336
332
|
throw new __injectivelabs_exceptions.TransactionException(new Error(error));
|
|
337
333
|
}
|
|
@@ -355,7 +351,7 @@ var MsgBroadcaster = class {
|
|
|
355
351
|
return (0, __injectivelabs_wallet_base.isCosmosWallet)(walletStrategy.wallet) ? await this.broadcastDirectSignWithFeeDelegation(txWithAddresses) : await this.broadcastEip712WithFeeDelegation(txWithAddresses);
|
|
356
352
|
} catch (e) {
|
|
357
353
|
const error = e;
|
|
358
|
-
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionFail);
|
|
354
|
+
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionFail);
|
|
359
355
|
if ((0, __injectivelabs_exceptions.isThrownException)(error)) throw error;
|
|
360
356
|
throw new __injectivelabs_exceptions.TransactionException(new Error(error));
|
|
361
357
|
}
|
|
@@ -421,7 +417,7 @@ var MsgBroadcaster = class {
|
|
|
421
417
|
evmChainId
|
|
422
418
|
});
|
|
423
419
|
/** Signing on Ethereum */
|
|
424
|
-
const signature = await walletStrategy.signEip712TypedData(
|
|
420
|
+
const signature = await walletStrategy.signEip712TypedData((0, __injectivelabs_sdk_ts_utils.safeBigIntStringify)(eip712TypedData), tx.ethereumAddress, { txTimeout: txTimeoutTimeInSeconds });
|
|
425
421
|
const pubKeyOrSignatureDerivedPubKey = await getEthereumWalletPubKey({
|
|
426
422
|
pubKey: (_baseAccount$pubKey = baseAccount.pubKey) === null || _baseAccount$pubKey === void 0 ? void 0 : _baseAccount$pubKey.key,
|
|
427
423
|
eip712TypedData,
|
|
@@ -448,7 +444,7 @@ var MsgBroadcaster = class {
|
|
|
448
444
|
txTimeout: txTimeoutInBlocks,
|
|
449
445
|
address: tx.injectiveAddress
|
|
450
446
|
});
|
|
451
|
-
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
|
|
447
|
+
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
|
|
452
448
|
return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
|
|
453
449
|
}
|
|
454
450
|
/**
|
|
@@ -498,7 +494,7 @@ var MsgBroadcaster = class {
|
|
|
498
494
|
});
|
|
499
495
|
stdFee = simulatedStdFee;
|
|
500
496
|
}
|
|
501
|
-
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationStart);
|
|
497
|
+
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationStart);
|
|
502
498
|
/** EIP712 for signing on Ethereum wallets */
|
|
503
499
|
const eip712TypedData = (0, __injectivelabs_sdk_ts_core_tx.getEip712TypedDataV2)({
|
|
504
500
|
msgs,
|
|
@@ -512,15 +508,15 @@ var MsgBroadcaster = class {
|
|
|
512
508
|
},
|
|
513
509
|
evmChainId
|
|
514
510
|
});
|
|
515
|
-
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationEnd);
|
|
511
|
+
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationEnd);
|
|
516
512
|
/** Signing on Ethereum */
|
|
517
|
-
const signature = await walletStrategy.signEip712TypedData(
|
|
513
|
+
const signature = await walletStrategy.signEip712TypedData((0, __injectivelabs_sdk_ts_utils.safeBigIntStringify)(eip712TypedData), tx.ethereumAddress, { txTimeout: txTimeoutTimeInSeconds });
|
|
518
514
|
const pubKeyOrSignatureDerivedPubKey = await getEthereumWalletPubKey({
|
|
519
515
|
pubKey: (_baseAccount$pubKey2 = baseAccount.pubKey) === null || _baseAccount$pubKey2 === void 0 ? void 0 : _baseAccount$pubKey2.key,
|
|
520
516
|
eip712TypedData,
|
|
521
517
|
signature
|
|
522
518
|
});
|
|
523
|
-
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastStart);
|
|
519
|
+
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastStart);
|
|
524
520
|
const { txRaw } = (0, __injectivelabs_sdk_ts_core_tx.createTransaction)({
|
|
525
521
|
message: msgs,
|
|
526
522
|
memo: tx.memo,
|
|
@@ -541,7 +537,7 @@ var MsgBroadcaster = class {
|
|
|
541
537
|
txTimeout: txTimeoutInBlocks,
|
|
542
538
|
address: tx.injectiveAddress
|
|
543
539
|
});
|
|
544
|
-
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
|
|
540
|
+
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
|
|
545
541
|
return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
|
|
546
542
|
}
|
|
547
543
|
/**
|
|
@@ -563,7 +559,7 @@ var MsgBroadcaster = class {
|
|
|
563
559
|
const txTimeoutTimeInMilliSeconds = txTimeoutTimeInSeconds * 1e3;
|
|
564
560
|
let timeoutHeight = void 0;
|
|
565
561
|
if (txTimeoutOnFeeDelegation) timeoutHeight = (0, __injectivelabs_utils.toBigNumber)((await new __injectivelabs_sdk_ts_client_chain.ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock()).header.height.toString()).plus(txTimeoutInBlocks).toNumber();
|
|
566
|
-
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationStart);
|
|
562
|
+
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationStart);
|
|
567
563
|
const prepareTxResponse = await transactionApi.prepareTxRequest({
|
|
568
564
|
timeoutHeight,
|
|
569
565
|
memo: tx.memo,
|
|
@@ -573,7 +569,7 @@ var MsgBroadcaster = class {
|
|
|
573
569
|
gasLimit: (0, __injectivelabs_sdk_ts_utils.getGasPriceBasedOnMessage)(msgs),
|
|
574
570
|
estimateGas: simulateTx
|
|
575
571
|
});
|
|
576
|
-
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationEnd);
|
|
572
|
+
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationEnd);
|
|
577
573
|
const signature = await walletStrategy.signEip712TypedData(prepareTxResponse.data, tx.ethereumAddress, { txTimeout: txTimeoutTimeInSeconds });
|
|
578
574
|
const broadcast = async () => await transactionApi.broadcastTxRequest({
|
|
579
575
|
signature,
|
|
@@ -582,9 +578,9 @@ var MsgBroadcaster = class {
|
|
|
582
578
|
chainId: evmChainId
|
|
583
579
|
});
|
|
584
580
|
try {
|
|
585
|
-
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastStart);
|
|
581
|
+
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastStart);
|
|
586
582
|
const response = await broadcast();
|
|
587
|
-
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
|
|
583
|
+
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
|
|
588
584
|
return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
|
|
589
585
|
} catch (e) {
|
|
590
586
|
const error = e;
|
|
@@ -630,7 +626,7 @@ var MsgBroadcaster = class {
|
|
|
630
626
|
const signMode = (0, __injectivelabs_wallet_base.isCosmosAminoOnlyWallet)(walletStrategy.wallet) ? __injectivelabs_sdk_ts_core_tx.SIGN_EIP712 : __injectivelabs_sdk_ts_core_tx.SIGN_DIRECT;
|
|
631
627
|
const pubKey = await walletStrategy.getPubKey(tx.injectiveAddress);
|
|
632
628
|
const gas = (((_tx$gas3 = tx.gas) === null || _tx$gas3 === void 0 ? void 0 : _tx$gas3.gas) || (0, __injectivelabs_sdk_ts_utils.getGasPriceBasedOnMessage)(msgs)).toString();
|
|
633
|
-
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationStart);
|
|
629
|
+
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationStart);
|
|
634
630
|
/** Prepare the Transaction * */
|
|
635
631
|
const { txRaw } = await this.getTxWithSignersAndStdFee({
|
|
636
632
|
chainId,
|
|
@@ -648,7 +644,7 @@ var MsgBroadcaster = class {
|
|
|
648
644
|
gas
|
|
649
645
|
})
|
|
650
646
|
});
|
|
651
|
-
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationEnd);
|
|
647
|
+
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationEnd);
|
|
652
648
|
/** Ledger using Cosmos app only allows signing amino docs */
|
|
653
649
|
if ((0, __injectivelabs_wallet_base.isCosmosAminoOnlyWallet)(walletStrategy.wallet)) {
|
|
654
650
|
var _tx$gas4;
|
|
@@ -664,14 +660,14 @@ var MsgBroadcaster = class {
|
|
|
664
660
|
signDoc: aminoSignDoc,
|
|
665
661
|
address: tx.injectiveAddress
|
|
666
662
|
})).signature.signature)];
|
|
667
|
-
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastStart);
|
|
663
|
+
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastStart);
|
|
668
664
|
const response$1 = await walletStrategy.sendTransaction(txRaw, {
|
|
669
665
|
chainId,
|
|
670
666
|
endpoints,
|
|
671
667
|
address: tx.injectiveAddress,
|
|
672
668
|
txTimeout: txTimeoutInBlocks
|
|
673
669
|
});
|
|
674
|
-
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
|
|
670
|
+
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
|
|
675
671
|
return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response$1.txHash, txTimeoutTimeInMilliSeconds);
|
|
676
672
|
}
|
|
677
673
|
const directSignResponse = await walletStrategy.signCosmosTransaction({
|
|
@@ -680,14 +676,14 @@ var MsgBroadcaster = class {
|
|
|
680
676
|
address: tx.injectiveAddress,
|
|
681
677
|
accountNumber: baseAccount.accountNumber
|
|
682
678
|
});
|
|
683
|
-
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastStart);
|
|
679
|
+
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastStart);
|
|
684
680
|
const response = await walletStrategy.sendTransaction(directSignResponse, {
|
|
685
681
|
chainId,
|
|
686
682
|
endpoints,
|
|
687
683
|
txTimeout: txTimeoutInBlocks,
|
|
688
684
|
address: tx.injectiveAddress
|
|
689
685
|
});
|
|
690
|
-
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
|
|
686
|
+
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
|
|
691
687
|
return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
|
|
692
688
|
}
|
|
693
689
|
/**
|
|
@@ -822,14 +818,14 @@ var MsgBroadcaster = class {
|
|
|
822
818
|
})
|
|
823
819
|
});
|
|
824
820
|
if (canDisableCosmosGasCheck && cosmosWallet.disableGasCheck) cosmosWallet.disableGasCheck(chainId);
|
|
825
|
-
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationStart);
|
|
821
|
+
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationStart);
|
|
826
822
|
const directSignResponse = await walletStrategy.signCosmosTransaction({
|
|
827
823
|
txRaw,
|
|
828
824
|
chainId,
|
|
829
825
|
address: tx.injectiveAddress,
|
|
830
826
|
accountNumber: baseAccount.accountNumber
|
|
831
827
|
});
|
|
832
|
-
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationEnd);
|
|
828
|
+
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationEnd);
|
|
833
829
|
const transactionApi = new __injectivelabs_sdk_ts_client_indexer.IndexerGrpcWeb3GwApi(endpoints.web3gw || endpoints.indexer);
|
|
834
830
|
if (httpHeaders) transactionApi.setMetadata(httpHeaders);
|
|
835
831
|
const broadcast = async () => await transactionApi.broadcastCosmosTxRequest({
|
|
@@ -842,9 +838,9 @@ var MsgBroadcaster = class {
|
|
|
842
838
|
}
|
|
843
839
|
});
|
|
844
840
|
try {
|
|
845
|
-
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastStart);
|
|
841
|
+
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastStart);
|
|
846
842
|
const response = await broadcast();
|
|
847
|
-
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
|
|
843
|
+
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
|
|
848
844
|
if (canDisableCosmosGasCheck && cosmosWallet.enableGasCheck) cosmosWallet.enableGasCheck(chainId);
|
|
849
845
|
return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
|
|
850
846
|
} catch (e) {
|
|
@@ -1010,6 +1006,5 @@ var Web3Broadcaster = class {
|
|
|
1010
1006
|
//#endregion
|
|
1011
1007
|
exports.BaseWalletStrategy = BaseWalletStrategy;
|
|
1012
1008
|
exports.MsgBroadcaster = MsgBroadcaster;
|
|
1013
|
-
exports.WalletStrategyEmitterEventType = WalletStrategyEmitterEventType;
|
|
1014
1009
|
exports.Web3Broadcaster = Web3Broadcaster;
|
|
1015
1010
|
exports.checkIfTxRunOutOfGas = checkIfTxRunOutOfGas;
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,69 +1,15 @@
|
|
|
1
|
-
import { ConcreteStrategiesArg, ConcreteWalletStrategy, CosmosWalletAbstraction, Eip1193Provider, SendTransactionOptions, Wallet, WalletDeviceType, WalletMetadata, WalletStrategy, WalletStrategyArguments, onAccountChangeCallback, onChainIdChangeCallback } from "@injectivelabs/wallet-base";
|
|
1
|
+
import { ConcreteStrategiesArg, ConcreteWalletStrategy, CosmosWalletAbstraction, Eip1193Provider, SendTransactionOptions, Wallet, WalletDeviceType, WalletMetadata, WalletStrategy, WalletStrategyArguments, WalletStrategyEmitter, onAccountChangeCallback, onChainIdChangeCallback } from "@injectivelabs/wallet-base";
|
|
2
2
|
import { StdSignDoc } from "@keplr-wallet/types";
|
|
3
3
|
import { OfflineSigner } from "@cosmjs/proto-signing";
|
|
4
4
|
import { AccountAddress, ChainId, EvmChainId } from "@injectivelabs/ts-types";
|
|
5
5
|
import { TxResponse } from "@injectivelabs/sdk-ts/core/tx";
|
|
6
6
|
import { AminoSignResponse, DirectSignResponse, TxRaw } from "@injectivelabs/sdk-ts/types";
|
|
7
|
-
import { EventEmitter } from "eventemitter3";
|
|
8
7
|
import { Msgs } from "@injectivelabs/sdk-ts/core/modules";
|
|
9
8
|
import { Network, NetworkEndpoints } from "@injectivelabs/networks";
|
|
10
9
|
|
|
11
10
|
//#region src/utils/tx.d.ts
|
|
12
11
|
declare const checkIfTxRunOutOfGas: (e: unknown) => boolean;
|
|
13
12
|
//#endregion
|
|
14
|
-
//#region src/broadcaster/types.d.ts
|
|
15
|
-
interface MsgBroadcasterTxOptions {
|
|
16
|
-
memo?: string;
|
|
17
|
-
ethereumAddress?: string;
|
|
18
|
-
injectiveAddress?: string;
|
|
19
|
-
msgs: Msgs | Msgs[];
|
|
20
|
-
gas?: {
|
|
21
|
-
gasPrice?: string;
|
|
22
|
-
gas?: number; /** gas limit */
|
|
23
|
-
feePayer?: string;
|
|
24
|
-
granter?: string;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
interface MsgBroadcasterTxOptionsWithAddresses extends MsgBroadcasterTxOptions {
|
|
28
|
-
ethereumAddress: string;
|
|
29
|
-
injectiveAddress: string;
|
|
30
|
-
}
|
|
31
|
-
interface MsgBroadcasterOptions {
|
|
32
|
-
network: Network;
|
|
33
|
-
endpoints?: NetworkEndpoints;
|
|
34
|
-
chainId?: ChainId;
|
|
35
|
-
evmChainId?: EvmChainId;
|
|
36
|
-
feePayerPubKey?: string;
|
|
37
|
-
simulateTx?: boolean;
|
|
38
|
-
txTimeoutOnFeeDelegation?: boolean;
|
|
39
|
-
txTimeout?: number;
|
|
40
|
-
walletStrategy: BaseWalletStrategy;
|
|
41
|
-
gasBufferCoefficient?: number;
|
|
42
|
-
httpHeaders?: Record<string, string>;
|
|
43
|
-
}
|
|
44
|
-
declare const WalletStrategyEmitterEventType: {
|
|
45
|
-
readonly TransactionFail: "transaction-fail";
|
|
46
|
-
readonly TransactionSigned: "transaction-signed";
|
|
47
|
-
readonly TransactionSignStart: "transaction-sign-start";
|
|
48
|
-
readonly TransactionBroadcastEnd: "transaction-broadcast-end";
|
|
49
|
-
readonly WalletStrategyDisconnect: "wallet-strategy-disconnect";
|
|
50
|
-
readonly TransactionBroadcastStart: "transaction-broadcast-start";
|
|
51
|
-
readonly TransactionPreparationEnd: "transaction-preparation-end";
|
|
52
|
-
readonly TransactionPreparationStart: "transaction-preparation-start";
|
|
53
|
-
};
|
|
54
|
-
type WalletStrategyEmitterEventType = (typeof WalletStrategyEmitterEventType)[keyof typeof WalletStrategyEmitterEventType];
|
|
55
|
-
type WalletStrategyEmitterEvents = {
|
|
56
|
-
[WalletStrategyEmitterEventType.TransactionFail]: Record<string, any>;
|
|
57
|
-
[WalletStrategyEmitterEventType.TransactionSigned]: Record<string, any>;
|
|
58
|
-
[WalletStrategyEmitterEventType.TransactionSignStart]: Record<string, any>;
|
|
59
|
-
[WalletStrategyEmitterEventType.TransactionBroadcastEnd]: Record<string, any>;
|
|
60
|
-
[WalletStrategyEmitterEventType.WalletStrategyDisconnect]: Record<string, any>;
|
|
61
|
-
[WalletStrategyEmitterEventType.TransactionBroadcastStart]: Record<string, any>;
|
|
62
|
-
[WalletStrategyEmitterEventType.TransactionPreparationEnd]: Record<string, any>;
|
|
63
|
-
[WalletStrategyEmitterEventType.TransactionPreparationStart]: Record<string, any>;
|
|
64
|
-
};
|
|
65
|
-
type WalletStrategyEmitter = EventEmitter<WalletStrategyEmitterEvents>;
|
|
66
|
-
//#endregion
|
|
67
13
|
//#region src/strategy/BaseWalletStrategy.d.ts
|
|
68
14
|
declare class BaseWalletStrategy implements WalletStrategy {
|
|
69
15
|
strategies: ConcreteStrategiesArg;
|
|
@@ -76,6 +22,11 @@ declare class BaseWalletStrategy implements WalletStrategy {
|
|
|
76
22
|
off: WalletStrategyEmitter['off'];
|
|
77
23
|
emit: WalletStrategyEmitter['emit'];
|
|
78
24
|
constructor(args: WalletStrategyArguments);
|
|
25
|
+
/**
|
|
26
|
+
* Get the emitter instance.
|
|
27
|
+
* Used to pass to strategies so they can emit events directly.
|
|
28
|
+
*/
|
|
29
|
+
getEmitter(): WalletStrategyEmitter;
|
|
79
30
|
getWallet(): Wallet;
|
|
80
31
|
setWallet(wallet: Wallet): Promise<void>;
|
|
81
32
|
setMetadata(metadata?: WalletMetadata): void;
|
|
@@ -121,6 +72,37 @@ declare class BaseWalletStrategy implements WalletStrategy {
|
|
|
121
72
|
getOfflineSigner(chainId: string): Promise<OfflineSigner>;
|
|
122
73
|
}
|
|
123
74
|
//#endregion
|
|
75
|
+
//#region src/broadcaster/types.d.ts
|
|
76
|
+
interface MsgBroadcasterTxOptions {
|
|
77
|
+
memo?: string;
|
|
78
|
+
ethereumAddress?: string;
|
|
79
|
+
injectiveAddress?: string;
|
|
80
|
+
msgs: Msgs | Msgs[];
|
|
81
|
+
gas?: {
|
|
82
|
+
gasPrice?: string;
|
|
83
|
+
gas?: number; /** gas limit */
|
|
84
|
+
feePayer?: string;
|
|
85
|
+
granter?: string;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
interface MsgBroadcasterTxOptionsWithAddresses extends MsgBroadcasterTxOptions {
|
|
89
|
+
ethereumAddress: string;
|
|
90
|
+
injectiveAddress: string;
|
|
91
|
+
}
|
|
92
|
+
interface MsgBroadcasterOptions {
|
|
93
|
+
network: Network;
|
|
94
|
+
endpoints?: NetworkEndpoints;
|
|
95
|
+
chainId?: ChainId;
|
|
96
|
+
evmChainId?: EvmChainId;
|
|
97
|
+
feePayerPubKey?: string;
|
|
98
|
+
simulateTx?: boolean;
|
|
99
|
+
txTimeoutOnFeeDelegation?: boolean;
|
|
100
|
+
txTimeout?: number;
|
|
101
|
+
walletStrategy: BaseWalletStrategy;
|
|
102
|
+
gasBufferCoefficient?: number;
|
|
103
|
+
httpHeaders?: Record<string, string>;
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
124
106
|
//#region src/broadcaster/MsgBroadcaster.d.ts
|
|
125
107
|
/**
|
|
126
108
|
* This class is used to broadcast transactions
|
|
@@ -285,4 +267,4 @@ declare class Web3Broadcaster {
|
|
|
285
267
|
sendTransaction(args: SendTransactionOptions$1): Promise<string>;
|
|
286
268
|
}
|
|
287
269
|
//#endregion
|
|
288
|
-
export { BaseWalletStrategy, MsgBroadcaster, MsgBroadcasterOptions, MsgBroadcasterTxOptions, MsgBroadcasterTxOptionsWithAddresses,
|
|
270
|
+
export { BaseWalletStrategy, MsgBroadcaster, MsgBroadcasterOptions, MsgBroadcasterTxOptions, MsgBroadcasterTxOptionsWithAddresses, Web3Broadcaster, checkIfTxRunOutOfGas };
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ConcreteStrategiesArg, ConcreteWalletStrategy, CosmosWalletAbstraction, Eip1193Provider, SendTransactionOptions, Wallet, WalletDeviceType, WalletMetadata, WalletStrategy, WalletStrategyArguments, onAccountChangeCallback, onChainIdChangeCallback } from "@injectivelabs/wallet-base";
|
|
1
|
+
import { ConcreteStrategiesArg, ConcreteWalletStrategy, CosmosWalletAbstraction, Eip1193Provider, SendTransactionOptions, Wallet, WalletDeviceType, WalletMetadata, WalletStrategy, WalletStrategyArguments, WalletStrategyEmitter, onAccountChangeCallback, onChainIdChangeCallback } from "@injectivelabs/wallet-base";
|
|
3
2
|
import { AccountAddress, ChainId, EvmChainId } from "@injectivelabs/ts-types";
|
|
4
3
|
import { Network, NetworkEndpoints } from "@injectivelabs/networks";
|
|
5
4
|
import { TxResponse } from "@injectivelabs/sdk-ts/core/tx";
|
|
@@ -11,59 +10,6 @@ import { Msgs } from "@injectivelabs/sdk-ts/core/modules";
|
|
|
11
10
|
//#region src/utils/tx.d.ts
|
|
12
11
|
declare const checkIfTxRunOutOfGas: (e: unknown) => boolean;
|
|
13
12
|
//#endregion
|
|
14
|
-
//#region src/broadcaster/types.d.ts
|
|
15
|
-
interface MsgBroadcasterTxOptions {
|
|
16
|
-
memo?: string;
|
|
17
|
-
ethereumAddress?: string;
|
|
18
|
-
injectiveAddress?: string;
|
|
19
|
-
msgs: Msgs | Msgs[];
|
|
20
|
-
gas?: {
|
|
21
|
-
gasPrice?: string;
|
|
22
|
-
gas?: number; /** gas limit */
|
|
23
|
-
feePayer?: string;
|
|
24
|
-
granter?: string;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
interface MsgBroadcasterTxOptionsWithAddresses extends MsgBroadcasterTxOptions {
|
|
28
|
-
ethereumAddress: string;
|
|
29
|
-
injectiveAddress: string;
|
|
30
|
-
}
|
|
31
|
-
interface MsgBroadcasterOptions {
|
|
32
|
-
network: Network;
|
|
33
|
-
endpoints?: NetworkEndpoints;
|
|
34
|
-
chainId?: ChainId;
|
|
35
|
-
evmChainId?: EvmChainId;
|
|
36
|
-
feePayerPubKey?: string;
|
|
37
|
-
simulateTx?: boolean;
|
|
38
|
-
txTimeoutOnFeeDelegation?: boolean;
|
|
39
|
-
txTimeout?: number;
|
|
40
|
-
walletStrategy: BaseWalletStrategy;
|
|
41
|
-
gasBufferCoefficient?: number;
|
|
42
|
-
httpHeaders?: Record<string, string>;
|
|
43
|
-
}
|
|
44
|
-
declare const WalletStrategyEmitterEventType: {
|
|
45
|
-
readonly TransactionFail: "transaction-fail";
|
|
46
|
-
readonly TransactionSigned: "transaction-signed";
|
|
47
|
-
readonly TransactionSignStart: "transaction-sign-start";
|
|
48
|
-
readonly TransactionBroadcastEnd: "transaction-broadcast-end";
|
|
49
|
-
readonly WalletStrategyDisconnect: "wallet-strategy-disconnect";
|
|
50
|
-
readonly TransactionBroadcastStart: "transaction-broadcast-start";
|
|
51
|
-
readonly TransactionPreparationEnd: "transaction-preparation-end";
|
|
52
|
-
readonly TransactionPreparationStart: "transaction-preparation-start";
|
|
53
|
-
};
|
|
54
|
-
type WalletStrategyEmitterEventType = (typeof WalletStrategyEmitterEventType)[keyof typeof WalletStrategyEmitterEventType];
|
|
55
|
-
type WalletStrategyEmitterEvents = {
|
|
56
|
-
[WalletStrategyEmitterEventType.TransactionFail]: Record<string, any>;
|
|
57
|
-
[WalletStrategyEmitterEventType.TransactionSigned]: Record<string, any>;
|
|
58
|
-
[WalletStrategyEmitterEventType.TransactionSignStart]: Record<string, any>;
|
|
59
|
-
[WalletStrategyEmitterEventType.TransactionBroadcastEnd]: Record<string, any>;
|
|
60
|
-
[WalletStrategyEmitterEventType.WalletStrategyDisconnect]: Record<string, any>;
|
|
61
|
-
[WalletStrategyEmitterEventType.TransactionBroadcastStart]: Record<string, any>;
|
|
62
|
-
[WalletStrategyEmitterEventType.TransactionPreparationEnd]: Record<string, any>;
|
|
63
|
-
[WalletStrategyEmitterEventType.TransactionPreparationStart]: Record<string, any>;
|
|
64
|
-
};
|
|
65
|
-
type WalletStrategyEmitter = EventEmitter<WalletStrategyEmitterEvents>;
|
|
66
|
-
//#endregion
|
|
67
13
|
//#region src/strategy/BaseWalletStrategy.d.ts
|
|
68
14
|
declare class BaseWalletStrategy implements WalletStrategy {
|
|
69
15
|
strategies: ConcreteStrategiesArg;
|
|
@@ -76,6 +22,11 @@ declare class BaseWalletStrategy implements WalletStrategy {
|
|
|
76
22
|
off: WalletStrategyEmitter['off'];
|
|
77
23
|
emit: WalletStrategyEmitter['emit'];
|
|
78
24
|
constructor(args: WalletStrategyArguments);
|
|
25
|
+
/**
|
|
26
|
+
* Get the emitter instance.
|
|
27
|
+
* Used to pass to strategies so they can emit events directly.
|
|
28
|
+
*/
|
|
29
|
+
getEmitter(): WalletStrategyEmitter;
|
|
79
30
|
getWallet(): Wallet;
|
|
80
31
|
setWallet(wallet: Wallet): Promise<void>;
|
|
81
32
|
setMetadata(metadata?: WalletMetadata): void;
|
|
@@ -121,6 +72,37 @@ declare class BaseWalletStrategy implements WalletStrategy {
|
|
|
121
72
|
getOfflineSigner(chainId: string): Promise<OfflineSigner>;
|
|
122
73
|
}
|
|
123
74
|
//#endregion
|
|
75
|
+
//#region src/broadcaster/types.d.ts
|
|
76
|
+
interface MsgBroadcasterTxOptions {
|
|
77
|
+
memo?: string;
|
|
78
|
+
ethereumAddress?: string;
|
|
79
|
+
injectiveAddress?: string;
|
|
80
|
+
msgs: Msgs | Msgs[];
|
|
81
|
+
gas?: {
|
|
82
|
+
gasPrice?: string;
|
|
83
|
+
gas?: number; /** gas limit */
|
|
84
|
+
feePayer?: string;
|
|
85
|
+
granter?: string;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
interface MsgBroadcasterTxOptionsWithAddresses extends MsgBroadcasterTxOptions {
|
|
89
|
+
ethereumAddress: string;
|
|
90
|
+
injectiveAddress: string;
|
|
91
|
+
}
|
|
92
|
+
interface MsgBroadcasterOptions {
|
|
93
|
+
network: Network;
|
|
94
|
+
endpoints?: NetworkEndpoints;
|
|
95
|
+
chainId?: ChainId;
|
|
96
|
+
evmChainId?: EvmChainId;
|
|
97
|
+
feePayerPubKey?: string;
|
|
98
|
+
simulateTx?: boolean;
|
|
99
|
+
txTimeoutOnFeeDelegation?: boolean;
|
|
100
|
+
txTimeout?: number;
|
|
101
|
+
walletStrategy: BaseWalletStrategy;
|
|
102
|
+
gasBufferCoefficient?: number;
|
|
103
|
+
httpHeaders?: Record<string, string>;
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
124
106
|
//#region src/broadcaster/MsgBroadcaster.d.ts
|
|
125
107
|
/**
|
|
126
108
|
* This class is used to broadcast transactions
|
|
@@ -285,4 +267,4 @@ declare class Web3Broadcaster {
|
|
|
285
267
|
sendTransaction(args: SendTransactionOptions$1): Promise<string>;
|
|
286
268
|
}
|
|
287
269
|
//#endregion
|
|
288
|
-
export { BaseWalletStrategy, MsgBroadcaster, MsgBroadcasterOptions, MsgBroadcasterTxOptions, MsgBroadcasterTxOptionsWithAddresses,
|
|
270
|
+
export { BaseWalletStrategy, MsgBroadcaster, MsgBroadcasterOptions, MsgBroadcasterTxOptions, MsgBroadcasterTxOptionsWithAddresses, Web3Broadcaster, checkIfTxRunOutOfGas };
|
package/dist/esm/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ChainCosmosErrorCode, GeneralException, TransactionChainErrorModule, TransactionException, UnspecifiedErrorCode, WalletException, Web3Exception, isThrownException } from "@injectivelabs/exceptions";
|
|
2
2
|
import { EventEmitter } from "eventemitter3";
|
|
3
|
-
import { Wallet, WalletDeviceType, createEip712StdSignDoc, getEthereumSignerAddress, getInjectiveSignerAddress, isCosmosAminoOnlyWallet, isCosmosWallet, isEip712V2OnlyWallet, isEvmBrowserWallet, isEvmWallet } from "@injectivelabs/wallet-base";
|
|
3
|
+
import { Wallet, WalletDeviceType, WalletStrategyEmitterEventType, createEip712StdSignDoc, getEthereumSignerAddress, getInjectiveSignerAddress, isCosmosAminoOnlyWallet, isCosmosWallet, isEip712V2OnlyWallet, isEvmBrowserWallet, isEvmWallet } from "@injectivelabs/wallet-base";
|
|
4
4
|
import { EvmChainId } from "@injectivelabs/ts-types";
|
|
5
|
-
import { base64ToUint8Array, getGasPriceBasedOnMessage, hexToBase64, hexToBuff, hexToUint8Array, ofacList, recoverTypedSignaturePubKey, uint8ArrayToBase64 } from "@injectivelabs/sdk-ts/utils";
|
|
6
5
|
import { PublicKey } from "@injectivelabs/sdk-ts/core/accounts";
|
|
6
|
+
import { base64ToUint8Array, getGasPriceBasedOnMessage, hexToBase64, hexToBuff, hexToUint8Array, ofacList, recoverTypedSignaturePubKey, safeBigIntStringify, uint8ArrayToBase64 } from "@injectivelabs/sdk-ts/utils";
|
|
7
7
|
import { IndexerGrpcWeb3GwApi } from "@injectivelabs/sdk-ts/client/indexer";
|
|
8
8
|
import { getNetworkEndpoints, getNetworkInfo, isMainnet, isTestnet } from "@injectivelabs/networks";
|
|
9
9
|
import { ChainGrpcAuthApi, ChainGrpcTendermintApi, ChainGrpcTxFeesApi } from "@injectivelabs/sdk-ts/client/chain";
|
|
@@ -15,19 +15,6 @@ const checkIfTxRunOutOfGas = (e) => {
|
|
|
15
15
|
return e instanceof TransactionException && e.contextCode === ChainCosmosErrorCode.ErrOutOfGas && e.contextModule === TransactionChainErrorModule.CosmosSdk && e.originalMessage.includes("out of gas");
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/broadcaster/types.ts
|
|
20
|
-
const WalletStrategyEmitterEventType = {
|
|
21
|
-
TransactionFail: "transaction-fail",
|
|
22
|
-
TransactionSigned: "transaction-signed",
|
|
23
|
-
TransactionSignStart: "transaction-sign-start",
|
|
24
|
-
TransactionBroadcastEnd: "transaction-broadcast-end",
|
|
25
|
-
WalletStrategyDisconnect: "wallet-strategy-disconnect",
|
|
26
|
-
TransactionBroadcastStart: "transaction-broadcast-start",
|
|
27
|
-
TransactionPreparationEnd: "transaction-preparation-end",
|
|
28
|
-
TransactionPreparationStart: "transaction-preparation-start"
|
|
29
|
-
};
|
|
30
|
-
|
|
31
18
|
//#endregion
|
|
32
19
|
//#region \0@oxc-project+runtime@0.98.0/helpers/typeof.js
|
|
33
20
|
function _typeof(o) {
|
|
@@ -100,12 +87,21 @@ var BaseWalletStrategy = class {
|
|
|
100
87
|
this.off = this.emitter.off.bind(this.emitter);
|
|
101
88
|
this.emit = this.emitter.emit.bind(this.emitter);
|
|
102
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
|
+
}
|
|
103
97
|
getWallet() {
|
|
104
98
|
return this.wallet;
|
|
105
99
|
}
|
|
106
100
|
async setWallet(wallet) {
|
|
101
|
+
var _strategy$initStrateg;
|
|
107
102
|
this.wallet = wallet;
|
|
108
|
-
this.getStrategy();
|
|
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));
|
|
109
105
|
}
|
|
110
106
|
setMetadata(metadata) {
|
|
111
107
|
var _this$getStrategy$set, _this$getStrategy;
|
|
@@ -421,7 +417,7 @@ var MsgBroadcaster = class {
|
|
|
421
417
|
evmChainId
|
|
422
418
|
});
|
|
423
419
|
/** Signing on Ethereum */
|
|
424
|
-
const signature = await walletStrategy.signEip712TypedData(
|
|
420
|
+
const signature = await walletStrategy.signEip712TypedData(safeBigIntStringify(eip712TypedData), tx.ethereumAddress, { txTimeout: txTimeoutTimeInSeconds });
|
|
425
421
|
const pubKeyOrSignatureDerivedPubKey = await getEthereumWalletPubKey({
|
|
426
422
|
pubKey: (_baseAccount$pubKey = baseAccount.pubKey) === null || _baseAccount$pubKey === void 0 ? void 0 : _baseAccount$pubKey.key,
|
|
427
423
|
eip712TypedData,
|
|
@@ -514,7 +510,7 @@ var MsgBroadcaster = class {
|
|
|
514
510
|
});
|
|
515
511
|
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationEnd);
|
|
516
512
|
/** Signing on Ethereum */
|
|
517
|
-
const signature = await walletStrategy.signEip712TypedData(
|
|
513
|
+
const signature = await walletStrategy.signEip712TypedData(safeBigIntStringify(eip712TypedData), tx.ethereumAddress, { txTimeout: txTimeoutTimeInSeconds });
|
|
518
514
|
const pubKeyOrSignatureDerivedPubKey = await getEthereumWalletPubKey({
|
|
519
515
|
pubKey: (_baseAccount$pubKey2 = baseAccount.pubKey) === null || _baseAccount$pubKey2 === void 0 ? void 0 : _baseAccount$pubKey2.key,
|
|
520
516
|
eip712TypedData,
|
|
@@ -1008,4 +1004,4 @@ var Web3Broadcaster = class {
|
|
|
1008
1004
|
};
|
|
1009
1005
|
|
|
1010
1006
|
//#endregion
|
|
1011
|
-
export { BaseWalletStrategy, MsgBroadcaster,
|
|
1007
|
+
export { BaseWalletStrategy, MsgBroadcaster, Web3Broadcaster, checkIfTxRunOutOfGas };
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@injectivelabs/wallet-core",
|
|
3
|
-
"version": "1.17.2-alpha.
|
|
3
|
+
"version": "1.17.2-alpha.10",
|
|
4
4
|
"description": "Core wallet strategy",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "InjectiveLabs",
|
|
8
8
|
"email": "admin@injectivelabs.org"
|
|
9
9
|
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/InjectiveLabs/injective-ts"
|
|
13
|
+
},
|
|
10
14
|
"type": "module",
|
|
11
15
|
"sideEffects": false,
|
|
12
16
|
"exports": {
|
|
@@ -40,12 +44,12 @@
|
|
|
40
44
|
"dependencies": {
|
|
41
45
|
"@keplr-wallet/types": "^0.12.296",
|
|
42
46
|
"eventemitter3": "^5.0.1",
|
|
43
|
-
"@injectivelabs/exceptions": "1.17.2-alpha.
|
|
44
|
-
"@injectivelabs/sdk-ts": "1.17.2-alpha.
|
|
45
|
-
"@injectivelabs/
|
|
46
|
-
"@injectivelabs/
|
|
47
|
-
"@injectivelabs/
|
|
48
|
-
"@injectivelabs/
|
|
47
|
+
"@injectivelabs/exceptions": "1.17.2-alpha.10",
|
|
48
|
+
"@injectivelabs/sdk-ts": "1.17.2-alpha.10",
|
|
49
|
+
"@injectivelabs/utils": "1.17.2-alpha.10",
|
|
50
|
+
"@injectivelabs/ts-types": "1.17.2-alpha.10",
|
|
51
|
+
"@injectivelabs/wallet-base": "1.17.2-alpha.10",
|
|
52
|
+
"@injectivelabs/networks": "1.17.2-alpha.10"
|
|
49
53
|
},
|
|
50
54
|
"publishConfig": {
|
|
51
55
|
"access": "public"
|