@@ -159,9 +159,9 @@ function convertDeposit (deposit?: [AccountId, u128] | null): PreimageDeposit |
159
159
}
160
160
161
161
/** @internal Returns the parameters required for a call to bytes */
162
- function getBytesParams ( interimResult : PreimageStatus , optStatus : Option < PalletPreimageRequestStatus > ) : BytesParams {
162
+ function getBytesParams ( interimResult : PreimageStatus , someOptStatus : Option < PalletPreimageRequestStatus > ) : BytesParams {
163
163
const result = objectSpread < PreimageStatus > ( { } , interimResult , {
164
- status : optStatus . unwrapOr ( null )
164
+ status : someOptStatus . unwrapOr ( null )
165
165
} ) ;
166
166
167
167
if ( result . status ) {
@@ -218,14 +218,18 @@ function usePreimageImpl (hashOrBounded?: Hash | HexString | FrameSupportPreimag
218
218
[ api , hashOrBounded ]
219
219
) ;
220
220
221
+ // api.query.preimage.statusFor has been deprecated in favor of api.query.preimage.requestStatusFor.
222
+ // To ensure we get all preimages correctly we query both storages. see: https://github.com/polkadot-js/apps/pull/10310
221
223
const optStatus = useCall < Option < PalletPreimageRequestStatus > > ( ! inlineData && paramsStatus && api . query . preimage ?. statusFor , paramsStatus ) ;
224
+ const optRequstStatus = useCall < Option < PalletPreimageRequestStatus > > ( ! inlineData && paramsStatus && api . query . preimage ?. requestStatusFor , paramsStatus ) ;
225
+ const someOptStatus = optStatus ?. isSome ? optStatus : optRequstStatus ;
222
226
223
227
// from the retrieved status (if any), get the on-chain stored bytes
224
228
const { paramsBytes, resultPreimageFor } = useMemo (
225
- ( ) => resultPreimageHash && optStatus
226
- ? getBytesParams ( resultPreimageHash , optStatus )
229
+ ( ) => resultPreimageHash && someOptStatus
230
+ ? getBytesParams ( resultPreimageHash , someOptStatus )
227
231
: { } ,
228
- [ optStatus , resultPreimageHash ]
232
+ [ someOptStatus , resultPreimageHash ]
229
233
) ;
230
234
231
235
const optBytes = useCall < Option < Bytes > > ( paramsBytes && api . query . preimage ?. preimageFor , paramsBytes ) ;
0 commit comments