Skip to content

Commit

Permalink
derive fee type from runtime api instead of hardcoding value
Browse files Browse the repository at this point in the history
  • Loading branch information
ERussel committed Nov 24, 2024
1 parent e3cfa5e commit 0e84042
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import Foundation

enum StateCallRpc {
static var method: String { "state_call" }
static var feeBuiltInModule: String { "TransactionPaymentApi" }
static var feeBuiltInMethod: String { "query_info" }
static var feeBuiltIn: String { "TransactionPaymentApi_query_info" }
static var feeResultType: String { "RuntimeDispatchInfo" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,20 @@ final class ExtrinsicNativeFeeEstimator {
connection: JSONRPCEngine
) -> CompoundOperationWrapper<RuntimeDispatchInfo> {
if chain.feeViaRuntimeCall {
createStateCallFeeWrapper(
let feeApi = coderFactory.metadata.getRuntimeApiMethod(
for: StateCallRpc.feeBuiltInModule, methodName: StateCallRpc.feeBuiltInMethod
)

let feeTypeName = feeApi.map { String($0.method.output) } ?? StateCallRpc.feeResultType

return createStateCallFeeWrapper(
for: coderFactory,
type: StateCallRpc.feeResultType,
type: feeTypeName,
extrinsic: extrinsic,
connection: connection
)
} else {
createApiFeeWrapper(
return createApiFeeWrapper(
extrinsic: extrinsic,
connection: connection
)
Expand Down

0 comments on commit 0e84042

Please sign in to comment.