@injectivelabs/wallet-core 1.19.27 → 1.19.28
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 +112 -50
- package/dist/cjs/index.d.cts +6 -6
- package/dist/esm/index.d.ts +6 -6
- package/dist/esm/index.js +112 -50
- package/package.json +7 -7
package/dist/cjs/index.cjs
CHANGED
|
@@ -396,9 +396,10 @@ var MsgBroadcaster = class {
|
|
|
396
396
|
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationEnd);
|
|
397
397
|
txRaw.signatures = [takerSig, feePayerSig.startsWith("0x") ? (0, __injectivelabs_sdk_ts_utils.hexToUint8Array)(feePayerSig.slice(2)) : (0, __injectivelabs_sdk_ts_utils.base64ToUint8Array)(feePayerSig)];
|
|
398
398
|
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastStart);
|
|
399
|
+
const txInclusionOptions = this.resolveTxInclusionOptions({ txInclusion });
|
|
399
400
|
const txResponse = await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).broadcast(txRaw, {
|
|
400
401
|
txTimeout: txTimeoutInBlocks,
|
|
401
|
-
...
|
|
402
|
+
...txInclusionOptions,
|
|
402
403
|
onBroadcast: () => {
|
|
403
404
|
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastSynced);
|
|
404
405
|
}
|
|
@@ -417,40 +418,6 @@ var MsgBroadcaster = class {
|
|
|
417
418
|
throw new __injectivelabs_exceptions.TransactionException(new Error(error));
|
|
418
419
|
}
|
|
419
420
|
}
|
|
420
|
-
resolveTimeoutInBlocks(override) {
|
|
421
|
-
return typeof override === "number" && Number.isInteger(override) && override > 0 ? override : this.txTimeout;
|
|
422
|
-
}
|
|
423
|
-
resolveTxInclusionOptions(tx) {
|
|
424
|
-
var _txInclusion$eventInc;
|
|
425
|
-
const txInclusion = (tx === null || tx === void 0 ? void 0 : tx.txInclusion) || this.txInclusion;
|
|
426
|
-
if (!txInclusion) return;
|
|
427
|
-
return {
|
|
428
|
-
...txInclusion,
|
|
429
|
-
eventInclusion: {
|
|
430
|
-
...txInclusion.eventInclusion,
|
|
431
|
-
rpcEndpoint: ((_txInclusion$eventInc = txInclusion.eventInclusion) === null || _txInclusion$eventInc === void 0 ? void 0 : _txInclusion$eventInc.rpcEndpoint) || this.endpoints.rpc
|
|
432
|
-
}
|
|
433
|
-
};
|
|
434
|
-
}
|
|
435
|
-
createTxGrpcApi() {
|
|
436
|
-
const client = new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(this.endpoints.grpc);
|
|
437
|
-
if (this.httpHeaders) client.setMetadata(this.httpHeaders);
|
|
438
|
-
return client;
|
|
439
|
-
}
|
|
440
|
-
async waitForTxInclusion(txHash, timeout, tx) {
|
|
441
|
-
return this.createTxGrpcApi().waitForTxInclusion(txHash, timeout, this.resolveTxInclusionOptions(tx));
|
|
442
|
-
}
|
|
443
|
-
async prepareTxInclusionWaiter(txRawOrSignResponse, timeout, tx) {
|
|
444
|
-
const txRaw = (0, __injectivelabs_sdk_ts_core_tx.createTxRawFromSigResponse)(txRawOrSignResponse);
|
|
445
|
-
const txHash = __injectivelabs_sdk_ts_core_tx.TxClient.hash(txRaw);
|
|
446
|
-
return this.createTxGrpcApi().prepareTxInclusionWait(txHash, timeout, this.resolveTxInclusionOptions(tx));
|
|
447
|
-
}
|
|
448
|
-
async waitForPreparedTxInclusion(responseTxHash, timeout, tx, inclusionWaiter) {
|
|
449
|
-
if (!inclusionWaiter) return this.waitForTxInclusion(responseTxHash, timeout, tx);
|
|
450
|
-
const confirmedTx = await inclusionWaiter.wait(responseTxHash);
|
|
451
|
-
if (!confirmedTx) throw new __injectivelabs_exceptions.TransactionException(/* @__PURE__ */ new Error(`The transaction with ${responseTxHash} is not found`));
|
|
452
|
-
return confirmedTx;
|
|
453
|
-
}
|
|
454
421
|
/**
|
|
455
422
|
* Prepare/sign/broadcast transaction using
|
|
456
423
|
* Ethereum native wallets on the client side.
|
|
@@ -532,7 +499,11 @@ var MsgBroadcaster = class {
|
|
|
532
499
|
const txRawEip712 = (0, __injectivelabs_sdk_ts_core_tx.createTxRawEIP712)(txRaw, (0, __injectivelabs_sdk_ts_core_tx.createWeb3Extension)({ evmChainId }));
|
|
533
500
|
/** Append Signatures */
|
|
534
501
|
txRawEip712.signatures = [(0, __injectivelabs_sdk_ts_utils.hexToBuff)(signature)];
|
|
535
|
-
const inclusionWaiter = await this.prepareTxInclusionWaiter(
|
|
502
|
+
const inclusionWaiter = await this.prepareTxInclusionWaiter({
|
|
503
|
+
tx,
|
|
504
|
+
txRawOrSignResponse: txRawEip712,
|
|
505
|
+
timeout: txTimeoutTimeInMilliSeconds
|
|
506
|
+
});
|
|
536
507
|
let response;
|
|
537
508
|
try {
|
|
538
509
|
response = await walletStrategy.sendTransaction(txRawEip712, {
|
|
@@ -546,7 +517,12 @@ var MsgBroadcaster = class {
|
|
|
546
517
|
throw e;
|
|
547
518
|
}
|
|
548
519
|
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastSynced);
|
|
549
|
-
const confirmedTx = await this.waitForPreparedTxInclusion(
|
|
520
|
+
const confirmedTx = await this.waitForPreparedTxInclusion({
|
|
521
|
+
tx,
|
|
522
|
+
inclusionWaiter,
|
|
523
|
+
responseTxHash: response.txHash,
|
|
524
|
+
timeout: txTimeoutTimeInMilliSeconds
|
|
525
|
+
});
|
|
550
526
|
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
|
|
551
527
|
return confirmedTx;
|
|
552
528
|
}
|
|
@@ -633,7 +609,11 @@ var MsgBroadcaster = class {
|
|
|
633
609
|
const txRawEip712 = (0, __injectivelabs_sdk_ts_core_tx.createTxRawEIP712)(txRaw, (0, __injectivelabs_sdk_ts_core_tx.createWeb3Extension)({ evmChainId }));
|
|
634
610
|
/** Append Signatures */
|
|
635
611
|
txRawEip712.signatures = [(0, __injectivelabs_sdk_ts_utils.hexToBuff)(signature)];
|
|
636
|
-
const inclusionWaiter = await this.prepareTxInclusionWaiter(
|
|
612
|
+
const inclusionWaiter = await this.prepareTxInclusionWaiter({
|
|
613
|
+
tx,
|
|
614
|
+
timeout: txTimeoutTimeInMilliSeconds,
|
|
615
|
+
txRawOrSignResponse: txRawEip712
|
|
616
|
+
});
|
|
637
617
|
let response;
|
|
638
618
|
try {
|
|
639
619
|
response = await walletStrategy.sendTransaction(txRawEip712, {
|
|
@@ -647,7 +627,12 @@ var MsgBroadcaster = class {
|
|
|
647
627
|
throw e;
|
|
648
628
|
}
|
|
649
629
|
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastSynced);
|
|
650
|
-
const confirmedTx = await this.waitForPreparedTxInclusion(
|
|
630
|
+
const confirmedTx = await this.waitForPreparedTxInclusion({
|
|
631
|
+
tx,
|
|
632
|
+
inclusionWaiter,
|
|
633
|
+
responseTxHash: response.txHash,
|
|
634
|
+
timeout: txTimeoutTimeInMilliSeconds
|
|
635
|
+
});
|
|
651
636
|
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
|
|
652
637
|
return confirmedTx;
|
|
653
638
|
}
|
|
@@ -693,7 +678,11 @@ var MsgBroadcaster = class {
|
|
|
693
678
|
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastStart);
|
|
694
679
|
const response = await broadcast();
|
|
695
680
|
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastSynced);
|
|
696
|
-
const confirmedTx = await this.waitForTxInclusion(
|
|
681
|
+
const confirmedTx = await this.waitForTxInclusion({
|
|
682
|
+
tx,
|
|
683
|
+
txHash: response.txHash,
|
|
684
|
+
timeout: txTimeoutTimeInMilliSeconds
|
|
685
|
+
});
|
|
697
686
|
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
|
|
698
687
|
return confirmedTx;
|
|
699
688
|
} catch (e) {
|
|
@@ -775,7 +764,11 @@ var MsgBroadcaster = class {
|
|
|
775
764
|
address: tx.injectiveAddress
|
|
776
765
|
})).signature.signature)];
|
|
777
766
|
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastStart);
|
|
778
|
-
const inclusionWaiter$1 = await this.prepareTxInclusionWaiter(
|
|
767
|
+
const inclusionWaiter$1 = await this.prepareTxInclusionWaiter({
|
|
768
|
+
tx,
|
|
769
|
+
txRawOrSignResponse: txRaw,
|
|
770
|
+
timeout: txTimeoutTimeInMilliSeconds
|
|
771
|
+
});
|
|
779
772
|
let response$1;
|
|
780
773
|
try {
|
|
781
774
|
response$1 = await walletStrategy.sendTransaction(txRaw, {
|
|
@@ -789,7 +782,12 @@ var MsgBroadcaster = class {
|
|
|
789
782
|
throw e;
|
|
790
783
|
}
|
|
791
784
|
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastSynced);
|
|
792
|
-
const confirmedTx$1 = await this.waitForPreparedTxInclusion(
|
|
785
|
+
const confirmedTx$1 = await this.waitForPreparedTxInclusion({
|
|
786
|
+
tx,
|
|
787
|
+
inclusionWaiter: inclusionWaiter$1,
|
|
788
|
+
timeout: txTimeoutTimeInMilliSeconds,
|
|
789
|
+
responseTxHash: response$1.txHash
|
|
790
|
+
});
|
|
793
791
|
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
|
|
794
792
|
return confirmedTx$1;
|
|
795
793
|
}
|
|
@@ -800,7 +798,11 @@ var MsgBroadcaster = class {
|
|
|
800
798
|
accountNumber: baseAccount.accountNumber
|
|
801
799
|
});
|
|
802
800
|
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastStart);
|
|
803
|
-
const inclusionWaiter = await this.prepareTxInclusionWaiter(
|
|
801
|
+
const inclusionWaiter = await this.prepareTxInclusionWaiter({
|
|
802
|
+
tx,
|
|
803
|
+
timeout: txTimeoutTimeInMilliSeconds,
|
|
804
|
+
txRawOrSignResponse: directSignResponse
|
|
805
|
+
});
|
|
804
806
|
let response;
|
|
805
807
|
try {
|
|
806
808
|
response = await walletStrategy.sendTransaction(directSignResponse, {
|
|
@@ -814,7 +816,12 @@ var MsgBroadcaster = class {
|
|
|
814
816
|
throw e;
|
|
815
817
|
}
|
|
816
818
|
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastSynced);
|
|
817
|
-
const confirmedTx = await this.waitForPreparedTxInclusion(
|
|
819
|
+
const confirmedTx = await this.waitForPreparedTxInclusion({
|
|
820
|
+
tx,
|
|
821
|
+
inclusionWaiter,
|
|
822
|
+
responseTxHash: response.txHash,
|
|
823
|
+
timeout: txTimeoutTimeInMilliSeconds
|
|
824
|
+
});
|
|
818
825
|
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
|
|
819
826
|
return confirmedTx;
|
|
820
827
|
}
|
|
@@ -875,14 +882,14 @@ var MsgBroadcaster = class {
|
|
|
875
882
|
*/
|
|
876
883
|
const { txRaw } = (0, __injectivelabs_sdk_ts_core_tx.createTransaction)({
|
|
877
884
|
pubKey,
|
|
885
|
+
chainId,
|
|
878
886
|
message: msgs,
|
|
879
|
-
memo: aminoSignResponse.signed.memo,
|
|
880
887
|
signMode: __injectivelabs_sdk_ts_core_tx.SIGN_EIP712,
|
|
888
|
+
memo: aminoSignResponse.signed.memo,
|
|
881
889
|
fee: aminoSignResponse.signed.fee,
|
|
882
890
|
sequence: parseInt(aminoSignResponse.signed.sequence, 10),
|
|
883
|
-
timeoutHeight: parseInt(aminoSignResponse.signed.timeout_height, 10),
|
|
884
891
|
accountNumber: parseInt(aminoSignResponse.signed.account_number, 10),
|
|
885
|
-
|
|
892
|
+
timeoutHeight: parseInt(aminoSignResponse.signed.timeout_height, 10)
|
|
886
893
|
});
|
|
887
894
|
const txRawEip712 = (0, __injectivelabs_sdk_ts_core_tx.createTxRawEIP712)(txRaw, (0, __injectivelabs_sdk_ts_core_tx.createWeb3Extension)({ evmChainId }));
|
|
888
895
|
if (simulateTx) await this.simulateTxRaw(txRawEip712);
|
|
@@ -995,8 +1002,8 @@ var MsgBroadcaster = class {
|
|
|
995
1002
|
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationEnd);
|
|
996
1003
|
const signedTxRaw = (0, __injectivelabs_sdk_ts_core_tx.createTxRawFromSigResponse)(directSignResponse);
|
|
997
1004
|
const broadcast = async () => await transactionApi.broadcastCosmosTxRequest({
|
|
998
|
-
address: tx.injectiveAddress,
|
|
999
1005
|
txRaw: signedTxRaw,
|
|
1006
|
+
address: tx.injectiveAddress,
|
|
1000
1007
|
signature: directSignResponse.signature.signature,
|
|
1001
1008
|
pubKey: directSignResponse.signature.pub_key || {
|
|
1002
1009
|
value: pubKey,
|
|
@@ -1005,7 +1012,11 @@ var MsgBroadcaster = class {
|
|
|
1005
1012
|
});
|
|
1006
1013
|
try {
|
|
1007
1014
|
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastStart);
|
|
1008
|
-
const inclusionWaiter = await this.prepareTxInclusionWaiter(
|
|
1015
|
+
const inclusionWaiter = await this.prepareTxInclusionWaiter({
|
|
1016
|
+
tx,
|
|
1017
|
+
txRawOrSignResponse: signedTxRaw,
|
|
1018
|
+
timeout: txTimeoutTimeInMilliSeconds
|
|
1019
|
+
});
|
|
1009
1020
|
let response;
|
|
1010
1021
|
try {
|
|
1011
1022
|
response = await broadcast();
|
|
@@ -1015,7 +1026,12 @@ var MsgBroadcaster = class {
|
|
|
1015
1026
|
}
|
|
1016
1027
|
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastSynced);
|
|
1017
1028
|
if (canDisableCosmosGasCheck && cosmosWallet.enableGasCheck) cosmosWallet.enableGasCheck(chainId);
|
|
1018
|
-
const confirmedTx = await this.waitForPreparedTxInclusion(
|
|
1029
|
+
const confirmedTx = await this.waitForPreparedTxInclusion({
|
|
1030
|
+
tx,
|
|
1031
|
+
inclusionWaiter,
|
|
1032
|
+
responseTxHash: response.txHash,
|
|
1033
|
+
timeout: txTimeoutTimeInMilliSeconds
|
|
1034
|
+
});
|
|
1019
1035
|
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
|
|
1020
1036
|
return confirmedTx;
|
|
1021
1037
|
} catch (e) {
|
|
@@ -1148,6 +1164,52 @@ var MsgBroadcaster = class {
|
|
|
1148
1164
|
latestHeight: latestBlock.header.height.toString()
|
|
1149
1165
|
};
|
|
1150
1166
|
}
|
|
1167
|
+
resolveTimeoutInBlocks(override) {
|
|
1168
|
+
return typeof override === "number" && Number.isInteger(override) && override > 0 ? override : this.txTimeout;
|
|
1169
|
+
}
|
|
1170
|
+
resolveTxInclusionOptions(tx) {
|
|
1171
|
+
var _txInclusion$eventInc;
|
|
1172
|
+
const txInclusion = (tx === null || tx === void 0 ? void 0 : tx.txInclusion) || this.txInclusion;
|
|
1173
|
+
if (!txInclusion) return;
|
|
1174
|
+
return {
|
|
1175
|
+
...txInclusion,
|
|
1176
|
+
eventInclusion: {
|
|
1177
|
+
...txInclusion.eventInclusion,
|
|
1178
|
+
rpcEndpoint: ((_txInclusion$eventInc = txInclusion.eventInclusion) === null || _txInclusion$eventInc === void 0 ? void 0 : _txInclusion$eventInc.rpcEndpoint) || this.endpoints.rpc
|
|
1179
|
+
}
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
createTxGrpcApi() {
|
|
1183
|
+
const client = new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(this.endpoints.grpc);
|
|
1184
|
+
if (this.httpHeaders) client.setMetadata(this.httpHeaders);
|
|
1185
|
+
return client;
|
|
1186
|
+
}
|
|
1187
|
+
async waitForTxInclusion({ tx, txHash, timeout }) {
|
|
1188
|
+
return this.createTxGrpcApi().waitForTxInclusion({
|
|
1189
|
+
txHash,
|
|
1190
|
+
timeout,
|
|
1191
|
+
options: this.resolveTxInclusionOptions(tx)
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
async prepareTxInclusionWaiter({ tx, timeout, txRawOrSignResponse }) {
|
|
1195
|
+
const txRaw = (0, __injectivelabs_sdk_ts_core_tx.createTxRawFromSigResponse)(txRawOrSignResponse);
|
|
1196
|
+
const txHash = __injectivelabs_sdk_ts_core_tx.TxClient.hash(txRaw);
|
|
1197
|
+
return this.createTxGrpcApi().prepareTxInclusionWait({
|
|
1198
|
+
txHash,
|
|
1199
|
+
timeout,
|
|
1200
|
+
options: this.resolveTxInclusionOptions(tx)
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
async waitForPreparedTxInclusion({ tx, timeout, responseTxHash, inclusionWaiter }) {
|
|
1204
|
+
if (!inclusionWaiter) return this.waitForTxInclusion({
|
|
1205
|
+
tx,
|
|
1206
|
+
timeout,
|
|
1207
|
+
txHash: responseTxHash
|
|
1208
|
+
});
|
|
1209
|
+
const confirmedTx = await inclusionWaiter.wait(responseTxHash);
|
|
1210
|
+
if (!confirmedTx) throw new __injectivelabs_exceptions.TransactionException(/* @__PURE__ */ new Error(`The transaction with ${responseTxHash} is not found`));
|
|
1211
|
+
return confirmedTx;
|
|
1212
|
+
}
|
|
1151
1213
|
};
|
|
1152
1214
|
|
|
1153
1215
|
//#endregion
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -195,12 +195,6 @@ declare class MsgBroadcaster {
|
|
|
195
195
|
txInclusion?: TxClientInclusionOptions;
|
|
196
196
|
txTimeoutInBlocks?: number;
|
|
197
197
|
}): Promise<TxResponse>;
|
|
198
|
-
private resolveTimeoutInBlocks;
|
|
199
|
-
private resolveTxInclusionOptions;
|
|
200
|
-
private createTxGrpcApi;
|
|
201
|
-
private waitForTxInclusion;
|
|
202
|
-
private prepareTxInclusionWaiter;
|
|
203
|
-
private waitForPreparedTxInclusion;
|
|
204
198
|
/**
|
|
205
199
|
* Prepare/sign/broadcast transaction using
|
|
206
200
|
* Ethereum native wallets on the client side.
|
|
@@ -278,6 +272,12 @@ declare class MsgBroadcaster {
|
|
|
278
272
|
private simulateTxWithSigners;
|
|
279
273
|
private retryOnException;
|
|
280
274
|
private fetchAccountAndBlockDetails;
|
|
275
|
+
private resolveTimeoutInBlocks;
|
|
276
|
+
private resolveTxInclusionOptions;
|
|
277
|
+
private createTxGrpcApi;
|
|
278
|
+
private waitForTxInclusion;
|
|
279
|
+
private prepareTxInclusionWaiter;
|
|
280
|
+
private waitForPreparedTxInclusion;
|
|
281
281
|
}
|
|
282
282
|
//#endregion
|
|
283
283
|
//#region src/broadcaster/Web3Broadcaster.d.ts
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -195,12 +195,6 @@ declare class MsgBroadcaster {
|
|
|
195
195
|
txInclusion?: TxClientInclusionOptions;
|
|
196
196
|
txTimeoutInBlocks?: number;
|
|
197
197
|
}): Promise<TxResponse>;
|
|
198
|
-
private resolveTimeoutInBlocks;
|
|
199
|
-
private resolveTxInclusionOptions;
|
|
200
|
-
private createTxGrpcApi;
|
|
201
|
-
private waitForTxInclusion;
|
|
202
|
-
private prepareTxInclusionWaiter;
|
|
203
|
-
private waitForPreparedTxInclusion;
|
|
204
198
|
/**
|
|
205
199
|
* Prepare/sign/broadcast transaction using
|
|
206
200
|
* Ethereum native wallets on the client side.
|
|
@@ -278,6 +272,12 @@ declare class MsgBroadcaster {
|
|
|
278
272
|
private simulateTxWithSigners;
|
|
279
273
|
private retryOnException;
|
|
280
274
|
private fetchAccountAndBlockDetails;
|
|
275
|
+
private resolveTimeoutInBlocks;
|
|
276
|
+
private resolveTxInclusionOptions;
|
|
277
|
+
private createTxGrpcApi;
|
|
278
|
+
private waitForTxInclusion;
|
|
279
|
+
private prepareTxInclusionWaiter;
|
|
280
|
+
private waitForPreparedTxInclusion;
|
|
281
281
|
}
|
|
282
282
|
//#endregion
|
|
283
283
|
//#region src/broadcaster/Web3Broadcaster.d.ts
|
package/dist/esm/index.js
CHANGED
|
@@ -396,9 +396,10 @@ var MsgBroadcaster = class {
|
|
|
396
396
|
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationEnd);
|
|
397
397
|
txRaw.signatures = [takerSig, feePayerSig.startsWith("0x") ? hexToUint8Array(feePayerSig.slice(2)) : base64ToUint8Array(feePayerSig)];
|
|
398
398
|
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastStart);
|
|
399
|
+
const txInclusionOptions = this.resolveTxInclusionOptions({ txInclusion });
|
|
399
400
|
const txResponse = await new TxGrpcApi(endpoints.grpc).broadcast(txRaw, {
|
|
400
401
|
txTimeout: txTimeoutInBlocks,
|
|
401
|
-
...
|
|
402
|
+
...txInclusionOptions,
|
|
402
403
|
onBroadcast: () => {
|
|
403
404
|
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastSynced);
|
|
404
405
|
}
|
|
@@ -417,40 +418,6 @@ var MsgBroadcaster = class {
|
|
|
417
418
|
throw new TransactionException(new Error(error));
|
|
418
419
|
}
|
|
419
420
|
}
|
|
420
|
-
resolveTimeoutInBlocks(override) {
|
|
421
|
-
return typeof override === "number" && Number.isInteger(override) && override > 0 ? override : this.txTimeout;
|
|
422
|
-
}
|
|
423
|
-
resolveTxInclusionOptions(tx) {
|
|
424
|
-
var _txInclusion$eventInc;
|
|
425
|
-
const txInclusion = (tx === null || tx === void 0 ? void 0 : tx.txInclusion) || this.txInclusion;
|
|
426
|
-
if (!txInclusion) return;
|
|
427
|
-
return {
|
|
428
|
-
...txInclusion,
|
|
429
|
-
eventInclusion: {
|
|
430
|
-
...txInclusion.eventInclusion,
|
|
431
|
-
rpcEndpoint: ((_txInclusion$eventInc = txInclusion.eventInclusion) === null || _txInclusion$eventInc === void 0 ? void 0 : _txInclusion$eventInc.rpcEndpoint) || this.endpoints.rpc
|
|
432
|
-
}
|
|
433
|
-
};
|
|
434
|
-
}
|
|
435
|
-
createTxGrpcApi() {
|
|
436
|
-
const client = new TxGrpcApi(this.endpoints.grpc);
|
|
437
|
-
if (this.httpHeaders) client.setMetadata(this.httpHeaders);
|
|
438
|
-
return client;
|
|
439
|
-
}
|
|
440
|
-
async waitForTxInclusion(txHash, timeout, tx) {
|
|
441
|
-
return this.createTxGrpcApi().waitForTxInclusion(txHash, timeout, this.resolveTxInclusionOptions(tx));
|
|
442
|
-
}
|
|
443
|
-
async prepareTxInclusionWaiter(txRawOrSignResponse, timeout, tx) {
|
|
444
|
-
const txRaw = createTxRawFromSigResponse(txRawOrSignResponse);
|
|
445
|
-
const txHash = TxClient.hash(txRaw);
|
|
446
|
-
return this.createTxGrpcApi().prepareTxInclusionWait(txHash, timeout, this.resolveTxInclusionOptions(tx));
|
|
447
|
-
}
|
|
448
|
-
async waitForPreparedTxInclusion(responseTxHash, timeout, tx, inclusionWaiter) {
|
|
449
|
-
if (!inclusionWaiter) return this.waitForTxInclusion(responseTxHash, timeout, tx);
|
|
450
|
-
const confirmedTx = await inclusionWaiter.wait(responseTxHash);
|
|
451
|
-
if (!confirmedTx) throw new TransactionException(/* @__PURE__ */ new Error(`The transaction with ${responseTxHash} is not found`));
|
|
452
|
-
return confirmedTx;
|
|
453
|
-
}
|
|
454
421
|
/**
|
|
455
422
|
* Prepare/sign/broadcast transaction using
|
|
456
423
|
* Ethereum native wallets on the client side.
|
|
@@ -532,7 +499,11 @@ var MsgBroadcaster = class {
|
|
|
532
499
|
const txRawEip712 = createTxRawEIP712(txRaw, createWeb3Extension({ evmChainId }));
|
|
533
500
|
/** Append Signatures */
|
|
534
501
|
txRawEip712.signatures = [hexToBuff(signature)];
|
|
535
|
-
const inclusionWaiter = await this.prepareTxInclusionWaiter(
|
|
502
|
+
const inclusionWaiter = await this.prepareTxInclusionWaiter({
|
|
503
|
+
tx,
|
|
504
|
+
txRawOrSignResponse: txRawEip712,
|
|
505
|
+
timeout: txTimeoutTimeInMilliSeconds
|
|
506
|
+
});
|
|
536
507
|
let response;
|
|
537
508
|
try {
|
|
538
509
|
response = await walletStrategy.sendTransaction(txRawEip712, {
|
|
@@ -546,7 +517,12 @@ var MsgBroadcaster = class {
|
|
|
546
517
|
throw e;
|
|
547
518
|
}
|
|
548
519
|
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastSynced);
|
|
549
|
-
const confirmedTx = await this.waitForPreparedTxInclusion(
|
|
520
|
+
const confirmedTx = await this.waitForPreparedTxInclusion({
|
|
521
|
+
tx,
|
|
522
|
+
inclusionWaiter,
|
|
523
|
+
responseTxHash: response.txHash,
|
|
524
|
+
timeout: txTimeoutTimeInMilliSeconds
|
|
525
|
+
});
|
|
550
526
|
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
|
|
551
527
|
return confirmedTx;
|
|
552
528
|
}
|
|
@@ -633,7 +609,11 @@ var MsgBroadcaster = class {
|
|
|
633
609
|
const txRawEip712 = createTxRawEIP712(txRaw, createWeb3Extension({ evmChainId }));
|
|
634
610
|
/** Append Signatures */
|
|
635
611
|
txRawEip712.signatures = [hexToBuff(signature)];
|
|
636
|
-
const inclusionWaiter = await this.prepareTxInclusionWaiter(
|
|
612
|
+
const inclusionWaiter = await this.prepareTxInclusionWaiter({
|
|
613
|
+
tx,
|
|
614
|
+
timeout: txTimeoutTimeInMilliSeconds,
|
|
615
|
+
txRawOrSignResponse: txRawEip712
|
|
616
|
+
});
|
|
637
617
|
let response;
|
|
638
618
|
try {
|
|
639
619
|
response = await walletStrategy.sendTransaction(txRawEip712, {
|
|
@@ -647,7 +627,12 @@ var MsgBroadcaster = class {
|
|
|
647
627
|
throw e;
|
|
648
628
|
}
|
|
649
629
|
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastSynced);
|
|
650
|
-
const confirmedTx = await this.waitForPreparedTxInclusion(
|
|
630
|
+
const confirmedTx = await this.waitForPreparedTxInclusion({
|
|
631
|
+
tx,
|
|
632
|
+
inclusionWaiter,
|
|
633
|
+
responseTxHash: response.txHash,
|
|
634
|
+
timeout: txTimeoutTimeInMilliSeconds
|
|
635
|
+
});
|
|
651
636
|
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
|
|
652
637
|
return confirmedTx;
|
|
653
638
|
}
|
|
@@ -693,7 +678,11 @@ var MsgBroadcaster = class {
|
|
|
693
678
|
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastStart);
|
|
694
679
|
const response = await broadcast();
|
|
695
680
|
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastSynced);
|
|
696
|
-
const confirmedTx = await this.waitForTxInclusion(
|
|
681
|
+
const confirmedTx = await this.waitForTxInclusion({
|
|
682
|
+
tx,
|
|
683
|
+
txHash: response.txHash,
|
|
684
|
+
timeout: txTimeoutTimeInMilliSeconds
|
|
685
|
+
});
|
|
697
686
|
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
|
|
698
687
|
return confirmedTx;
|
|
699
688
|
} catch (e) {
|
|
@@ -775,7 +764,11 @@ var MsgBroadcaster = class {
|
|
|
775
764
|
address: tx.injectiveAddress
|
|
776
765
|
})).signature.signature)];
|
|
777
766
|
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastStart);
|
|
778
|
-
const inclusionWaiter$1 = await this.prepareTxInclusionWaiter(
|
|
767
|
+
const inclusionWaiter$1 = await this.prepareTxInclusionWaiter({
|
|
768
|
+
tx,
|
|
769
|
+
txRawOrSignResponse: txRaw,
|
|
770
|
+
timeout: txTimeoutTimeInMilliSeconds
|
|
771
|
+
});
|
|
779
772
|
let response$1;
|
|
780
773
|
try {
|
|
781
774
|
response$1 = await walletStrategy.sendTransaction(txRaw, {
|
|
@@ -789,7 +782,12 @@ var MsgBroadcaster = class {
|
|
|
789
782
|
throw e;
|
|
790
783
|
}
|
|
791
784
|
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastSynced);
|
|
792
|
-
const confirmedTx$1 = await this.waitForPreparedTxInclusion(
|
|
785
|
+
const confirmedTx$1 = await this.waitForPreparedTxInclusion({
|
|
786
|
+
tx,
|
|
787
|
+
inclusionWaiter: inclusionWaiter$1,
|
|
788
|
+
timeout: txTimeoutTimeInMilliSeconds,
|
|
789
|
+
responseTxHash: response$1.txHash
|
|
790
|
+
});
|
|
793
791
|
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
|
|
794
792
|
return confirmedTx$1;
|
|
795
793
|
}
|
|
@@ -800,7 +798,11 @@ var MsgBroadcaster = class {
|
|
|
800
798
|
accountNumber: baseAccount.accountNumber
|
|
801
799
|
});
|
|
802
800
|
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastStart);
|
|
803
|
-
const inclusionWaiter = await this.prepareTxInclusionWaiter(
|
|
801
|
+
const inclusionWaiter = await this.prepareTxInclusionWaiter({
|
|
802
|
+
tx,
|
|
803
|
+
timeout: txTimeoutTimeInMilliSeconds,
|
|
804
|
+
txRawOrSignResponse: directSignResponse
|
|
805
|
+
});
|
|
804
806
|
let response;
|
|
805
807
|
try {
|
|
806
808
|
response = await walletStrategy.sendTransaction(directSignResponse, {
|
|
@@ -814,7 +816,12 @@ var MsgBroadcaster = class {
|
|
|
814
816
|
throw e;
|
|
815
817
|
}
|
|
816
818
|
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastSynced);
|
|
817
|
-
const confirmedTx = await this.waitForPreparedTxInclusion(
|
|
819
|
+
const confirmedTx = await this.waitForPreparedTxInclusion({
|
|
820
|
+
tx,
|
|
821
|
+
inclusionWaiter,
|
|
822
|
+
responseTxHash: response.txHash,
|
|
823
|
+
timeout: txTimeoutTimeInMilliSeconds
|
|
824
|
+
});
|
|
818
825
|
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
|
|
819
826
|
return confirmedTx;
|
|
820
827
|
}
|
|
@@ -875,14 +882,14 @@ var MsgBroadcaster = class {
|
|
|
875
882
|
*/
|
|
876
883
|
const { txRaw } = createTransaction({
|
|
877
884
|
pubKey,
|
|
885
|
+
chainId,
|
|
878
886
|
message: msgs,
|
|
879
|
-
memo: aminoSignResponse.signed.memo,
|
|
880
887
|
signMode: SIGN_EIP712,
|
|
888
|
+
memo: aminoSignResponse.signed.memo,
|
|
881
889
|
fee: aminoSignResponse.signed.fee,
|
|
882
890
|
sequence: parseInt(aminoSignResponse.signed.sequence, 10),
|
|
883
|
-
timeoutHeight: parseInt(aminoSignResponse.signed.timeout_height, 10),
|
|
884
891
|
accountNumber: parseInt(aminoSignResponse.signed.account_number, 10),
|
|
885
|
-
|
|
892
|
+
timeoutHeight: parseInt(aminoSignResponse.signed.timeout_height, 10)
|
|
886
893
|
});
|
|
887
894
|
const txRawEip712 = createTxRawEIP712(txRaw, createWeb3Extension({ evmChainId }));
|
|
888
895
|
if (simulateTx) await this.simulateTxRaw(txRawEip712);
|
|
@@ -995,8 +1002,8 @@ var MsgBroadcaster = class {
|
|
|
995
1002
|
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationEnd);
|
|
996
1003
|
const signedTxRaw = createTxRawFromSigResponse(directSignResponse);
|
|
997
1004
|
const broadcast = async () => await transactionApi.broadcastCosmosTxRequest({
|
|
998
|
-
address: tx.injectiveAddress,
|
|
999
1005
|
txRaw: signedTxRaw,
|
|
1006
|
+
address: tx.injectiveAddress,
|
|
1000
1007
|
signature: directSignResponse.signature.signature,
|
|
1001
1008
|
pubKey: directSignResponse.signature.pub_key || {
|
|
1002
1009
|
value: pubKey,
|
|
@@ -1005,7 +1012,11 @@ var MsgBroadcaster = class {
|
|
|
1005
1012
|
});
|
|
1006
1013
|
try {
|
|
1007
1014
|
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastStart);
|
|
1008
|
-
const inclusionWaiter = await this.prepareTxInclusionWaiter(
|
|
1015
|
+
const inclusionWaiter = await this.prepareTxInclusionWaiter({
|
|
1016
|
+
tx,
|
|
1017
|
+
txRawOrSignResponse: signedTxRaw,
|
|
1018
|
+
timeout: txTimeoutTimeInMilliSeconds
|
|
1019
|
+
});
|
|
1009
1020
|
let response;
|
|
1010
1021
|
try {
|
|
1011
1022
|
response = await broadcast();
|
|
@@ -1015,7 +1026,12 @@ var MsgBroadcaster = class {
|
|
|
1015
1026
|
}
|
|
1016
1027
|
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastSynced);
|
|
1017
1028
|
if (canDisableCosmosGasCheck && cosmosWallet.enableGasCheck) cosmosWallet.enableGasCheck(chainId);
|
|
1018
|
-
const confirmedTx = await this.waitForPreparedTxInclusion(
|
|
1029
|
+
const confirmedTx = await this.waitForPreparedTxInclusion({
|
|
1030
|
+
tx,
|
|
1031
|
+
inclusionWaiter,
|
|
1032
|
+
responseTxHash: response.txHash,
|
|
1033
|
+
timeout: txTimeoutTimeInMilliSeconds
|
|
1034
|
+
});
|
|
1019
1035
|
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
|
|
1020
1036
|
return confirmedTx;
|
|
1021
1037
|
} catch (e) {
|
|
@@ -1148,6 +1164,52 @@ var MsgBroadcaster = class {
|
|
|
1148
1164
|
latestHeight: latestBlock.header.height.toString()
|
|
1149
1165
|
};
|
|
1150
1166
|
}
|
|
1167
|
+
resolveTimeoutInBlocks(override) {
|
|
1168
|
+
return typeof override === "number" && Number.isInteger(override) && override > 0 ? override : this.txTimeout;
|
|
1169
|
+
}
|
|
1170
|
+
resolveTxInclusionOptions(tx) {
|
|
1171
|
+
var _txInclusion$eventInc;
|
|
1172
|
+
const txInclusion = (tx === null || tx === void 0 ? void 0 : tx.txInclusion) || this.txInclusion;
|
|
1173
|
+
if (!txInclusion) return;
|
|
1174
|
+
return {
|
|
1175
|
+
...txInclusion,
|
|
1176
|
+
eventInclusion: {
|
|
1177
|
+
...txInclusion.eventInclusion,
|
|
1178
|
+
rpcEndpoint: ((_txInclusion$eventInc = txInclusion.eventInclusion) === null || _txInclusion$eventInc === void 0 ? void 0 : _txInclusion$eventInc.rpcEndpoint) || this.endpoints.rpc
|
|
1179
|
+
}
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
createTxGrpcApi() {
|
|
1183
|
+
const client = new TxGrpcApi(this.endpoints.grpc);
|
|
1184
|
+
if (this.httpHeaders) client.setMetadata(this.httpHeaders);
|
|
1185
|
+
return client;
|
|
1186
|
+
}
|
|
1187
|
+
async waitForTxInclusion({ tx, txHash, timeout }) {
|
|
1188
|
+
return this.createTxGrpcApi().waitForTxInclusion({
|
|
1189
|
+
txHash,
|
|
1190
|
+
timeout,
|
|
1191
|
+
options: this.resolveTxInclusionOptions(tx)
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
async prepareTxInclusionWaiter({ tx, timeout, txRawOrSignResponse }) {
|
|
1195
|
+
const txRaw = createTxRawFromSigResponse(txRawOrSignResponse);
|
|
1196
|
+
const txHash = TxClient.hash(txRaw);
|
|
1197
|
+
return this.createTxGrpcApi().prepareTxInclusionWait({
|
|
1198
|
+
txHash,
|
|
1199
|
+
timeout,
|
|
1200
|
+
options: this.resolveTxInclusionOptions(tx)
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
async waitForPreparedTxInclusion({ tx, timeout, responseTxHash, inclusionWaiter }) {
|
|
1204
|
+
if (!inclusionWaiter) return this.waitForTxInclusion({
|
|
1205
|
+
tx,
|
|
1206
|
+
timeout,
|
|
1207
|
+
txHash: responseTxHash
|
|
1208
|
+
});
|
|
1209
|
+
const confirmedTx = await inclusionWaiter.wait(responseTxHash);
|
|
1210
|
+
if (!confirmedTx) throw new TransactionException(/* @__PURE__ */ new Error(`The transaction with ${responseTxHash} is not found`));
|
|
1211
|
+
return confirmedTx;
|
|
1212
|
+
}
|
|
1151
1213
|
};
|
|
1152
1214
|
|
|
1153
1215
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@injectivelabs/wallet-core",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.28",
|
|
4
4
|
"description": "Core wallet strategy",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -44,12 +44,12 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@keplr-wallet/types": "^0.12.296",
|
|
46
46
|
"eventemitter3": "^5.0.1",
|
|
47
|
-
"@injectivelabs/
|
|
48
|
-
"@injectivelabs/
|
|
49
|
-
"@injectivelabs/
|
|
50
|
-
"@injectivelabs/
|
|
51
|
-
"@injectivelabs/
|
|
52
|
-
"@injectivelabs/
|
|
47
|
+
"@injectivelabs/ts-types": "1.19.28",
|
|
48
|
+
"@injectivelabs/sdk-ts": "1.19.28",
|
|
49
|
+
"@injectivelabs/networks": "1.19.28",
|
|
50
|
+
"@injectivelabs/wallet-base": "1.19.28",
|
|
51
|
+
"@injectivelabs/exceptions": "1.19.28",
|
|
52
|
+
"@injectivelabs/utils": "1.19.28"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|