carbon-js-sdk 0.11.64 → 0.11.65
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.
|
@@ -215,6 +215,9 @@ export declare class CarbonWallet {
|
|
|
215
215
|
isEvmWallet(): boolean;
|
|
216
216
|
isViewOnlyWallet(): boolean;
|
|
217
217
|
private estimateTxFee;
|
|
218
|
+
private getTotalGasCost;
|
|
219
|
+
private addAdditionalGasCost;
|
|
220
|
+
private getExecGasCost;
|
|
218
221
|
private isAccountNotFoundError;
|
|
219
222
|
private isTxHashNotFound;
|
|
220
223
|
private isNonceMismatchError;
|
|
@@ -783,11 +783,7 @@ class CarbonWallet {
|
|
|
783
783
|
estimateTxFee(messages, feeDenom = constant_1.DEFAULT_FEE_DENOM) {
|
|
784
784
|
var _a;
|
|
785
785
|
const denomGasPrice = (_a = this.gasFee) === null || _a === void 0 ? void 0 : _a.getGasPrice(feeDenom);
|
|
786
|
-
const totalGasCost =
|
|
787
|
-
var _a;
|
|
788
|
-
const gasCost = (_a = this.gasFee) === null || _a === void 0 ? void 0 : _a.getGasCost(message.typeUrl);
|
|
789
|
-
return result.plus(gasCost !== null && gasCost !== void 0 ? gasCost : number_1.BN_ZERO);
|
|
790
|
-
}, number_1.BN_ZERO);
|
|
786
|
+
const totalGasCost = this.getTotalGasCost(messages);
|
|
791
787
|
let totalFees = totalGasCost.times(denomGasPrice !== null && denomGasPrice !== void 0 ? denomGasPrice : number_1.BN_ZERO);
|
|
792
788
|
// override zero gas cost tx with some gas for tx execution
|
|
793
789
|
// set overall fee to zero, implying 0 gas price.
|
|
@@ -804,6 +800,26 @@ class CarbonWallet {
|
|
|
804
800
|
gas: constant_1.DEFAULT_GAS.toString(10),
|
|
805
801
|
};
|
|
806
802
|
}
|
|
803
|
+
getTotalGasCost(messages) {
|
|
804
|
+
var _a;
|
|
805
|
+
let totalGasCost = number_1.BN_ZERO;
|
|
806
|
+
for (const message of messages) {
|
|
807
|
+
const gasCost = (_a = this.gasFee) === null || _a === void 0 ? void 0 : _a.getGasCost(message.typeUrl);
|
|
808
|
+
const additionalGasCost = this.addAdditionalGasCost(message);
|
|
809
|
+
totalGasCost = totalGasCost.plus(gasCost !== null && gasCost !== void 0 ? gasCost : number_1.BN_ZERO).plus(additionalGasCost);
|
|
810
|
+
}
|
|
811
|
+
return totalGasCost;
|
|
812
|
+
}
|
|
813
|
+
addAdditionalGasCost(message) {
|
|
814
|
+
switch (message.typeUrl) {
|
|
815
|
+
case codec_1.TxTypes.MsgExec: return this.getExecGasCost(message.value);
|
|
816
|
+
}
|
|
817
|
+
return number_1.BN_ZERO;
|
|
818
|
+
}
|
|
819
|
+
getExecGasCost(message) {
|
|
820
|
+
const { msgs } = message;
|
|
821
|
+
return this.getTotalGasCost(msgs);
|
|
822
|
+
}
|
|
807
823
|
getQueryClient() {
|
|
808
824
|
if (!this.query)
|
|
809
825
|
throw new Error("wallet not initialized");
|