Add fallbacks for paymentInfo (non-fixed) results (#5382)

This commit is contained in:
Jaco
2022-12-25 17:22:40 +02:00
committed by GitHub
parent 7b5b8745a2
commit 9fe8e3ace1
2 changed files with 15 additions and 8 deletions
@@ -29,6 +29,13 @@ export default {
partialFee: 'Balance'
},
RuntimeDispatchInfoV1: {
// NOTE: Generally we always point high -> low, however in this case we do have some _potential_
// discrepancies where some nodes may not return the correct RPC responses. Basically any node that
// is on WeightV2 and does not yet include https://github.com/paritytech/substrate/pull/12633 would
// have unparsable results. So effectively this makes the API not fail in those cases, however it
// will create "some" chaos on the side of the users who does expect the correct response.
// TL:DR Somebody _will_ still break since in cases where the RPCs are "between fixes"
__fallback: 'RuntimeDispatchInfoV2',
weight: 'WeightV1',
class: 'DispatchClass',
partialFee: 'Balance'
@@ -74,10 +74,11 @@ export const runtime: DefinitionsCall = {
type: 'u32'
}
],
// NOTE: _Should_ be V1 (as per current Substrate), however the interface was changed mid-flight between
// versions. So we have some of each depending on runtime. (We do detect the weight type, so correct)
// type: 'RuntimeDispatchInfoV1'
type: 'RuntimeDispatchInfo'
// NOTE: For some versions of the runtime which have not been corrected, there _could_ be a
// wrong reponse returned, i.e. RuntimeDispatchInfoV2. (See the comment applying to both
// RPC and state_call in definitions -> RuntimeDispatchInfoV1 for the fallbacks)
// TL;DR This is correct based on Substrate, but _may_ yield fallbacks on certain runtimes
type: 'RuntimeDispatchInfoV1'
}
}, V1_V2_SHARED_PAY),
version: 1
@@ -117,10 +118,9 @@ export const runtime: DefinitionsCall = {
type: 'u32'
}
],
// NOTE: _Should_ be V1 (as per current Substrate), however the interface was changed mid-flight between
// versions. So we have some of each depending on runtime. (We do detect the weight type, so correct)
// type: 'RuntimeDispatchInfoV1'
type: 'RuntimeDispatchInfo'
// NOTE: As per the above comment, the below is correct according to Substrate, but
// _may_ yield fallback decoding on some versions of the runtime
type: 'RuntimeDispatchInfoV1'
}
}, V1_V2_SHARED_CALL),
version: 1