Skip to content

Commit

Permalink
Merge pull request #1198 from novasamatech/fix/fee-estimation
Browse files Browse the repository at this point in the history
fee estimation hot fixes
  • Loading branch information
svojsu authored Aug 26, 2024
2 parents 094c696 + 8e1f2cd commit 1682baf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ extension ExtrinsicFeeEstimationRegistry: ExtrinsicFeeEstimationRegistring {
chainAssetId: ChainAssetId,
extrinsicCreatingResultClosure: @escaping () throws -> ExtrinsicsCreationResult
) -> CompoundOperationWrapper<ExtrinsicFeeEstimationResultProtocol> {
switch AssetType(rawType: asset.type) {
guard !asset.isUtility else {
return estimatingWrapperFactory.createNativeFeeEstimatingWrapper(
extrinsicCreatingResultClosure: extrinsicCreatingResultClosure
)
}

return switch AssetType(rawType: asset.type) {
case .none:
estimatingWrapperFactory.createNativeFeeEstimatingWrapper(
extrinsicCreatingResultClosure: extrinsicCreatingResultClosure
Expand Down Expand Up @@ -141,7 +147,11 @@ extension ExtrinsicFeeEstimationRegistry: ExtrinsicFeeEstimationRegistring {
accountClosure: @escaping () throws -> ChainAccountResponse,
chainAsset: ChainAsset
) -> CompoundOperationWrapper<ExtrinsicFeeInstalling> {
switch AssetType(rawType: chainAsset.asset.type) {
guard !chainAsset.isUtilityAsset else {
return CompoundOperationWrapper.createWithResult(ExtrinsicNativeFeeInstaller())
}

return switch AssetType(rawType: chainAsset.asset.type) {
case .none:
CompoundOperationWrapper.createWithResult(ExtrinsicNativeFeeInstaller())
case .statemine where chain.hasAssetHubTransferFees:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,14 @@ final class OnChainTransferSetupPresenter: OnChainTransferPresenter, OnChainTran
private func switchFeeChainAssetIfNecessary() {
guard
let fee,
feeAssetChangeAvailable,
!isManualFeeSet,
!chainAsset.isUtilityAsset,
feeAsset.isUtilityAsset,
let utilityAssetMinBalance,
let senderUtilityAssetBalance
let senderUtilityAssetBalance,
let senderSendingAssetBalance,
senderSendingAssetBalance.transferable > 0
else {
return
}
Expand Down Expand Up @@ -271,6 +274,13 @@ final class OnChainTransferSetupPresenter: OnChainTransferPresenter, OnChainTran
super.didReceiveSendingAssetSenderBalance(balance)

updateTransferableBalance()
switchFeeChainAssetIfNecessary()
}

override func didReceiveUtilityAssetSenderBalance(_ balance: AssetBalance) {
super.didReceiveUtilityAssetSenderBalance(balance)

switchFeeChainAssetIfNecessary()
}

override func didReceiveFee(result: Result<FeeOutputModel, Error>) {
Expand Down

0 comments on commit 1682baf

Please sign in to comment.