Skip to content

Commit 278c94c

Browse files
committed
fix
1 parent d5a0678 commit 278c94c

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

packages/eth-providers/src/base-provider.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -960,18 +960,27 @@ export abstract class BaseProvider extends AbstractProvider {
960960

961961
const lenIncreaseAfterSignature = 100; // approximate length increase after signature
962962
let feeDetails = null;
963-
if (!apiAt.call.transactionPaymentCallApi) {
964-
// for old api
965-
feeDetails = await apiAt.call.transactionPaymentApi.queryFeeDetails(
966-
extrinsic.toU8a(),
967-
extrinsic.toU8a().length + lenIncreaseAfterSignature,
968-
);
969-
} else {
963+
if (apiAt.call.transactionPaymentCallApi) {
970964
// for new api with runtime 2310
971965
feeDetails = await apiAt.call.transactionPaymentCallApi.queryCallFeeDetails(
972966
extrinsic,
973967
extrinsic.toU8a().length + lenIncreaseAfterSignature,
974968
);
969+
} else if (this.api.call.transactionPaymentCallApi && blockHash === this.bestBlockHash) {
970+
// for chopsticks test
971+
feeDetails = await this.api.call.transactionPaymentCallApi.queryCallFeeDetails(
972+
extrinsic,
973+
extrinsic.toU8a().length + lenIncreaseAfterSignature,
974+
);
975+
} else {
976+
// for old api
977+
feeDetails = await apiAt.call.transactionPaymentApi.queryFeeDetails(
978+
extrinsic.toU8a(),
979+
extrinsic.toU8a().length + lenIncreaseAfterSignature,
980+
);
981+
}
982+
if (feeDetails.isEmpty || feeDetails.inclusionFee.isEmpty) {
983+
return logger.throwError('failed to estimate gas', Logger.errors.CALL_EXCEPTION);
975984
}
976985
const { baseFee, lenFee, adjustedWeightFee } = feeDetails.inclusionFee.unwrap();
977986

0 commit comments

Comments
 (0)