Skip to content

Commit

Permalink
storage-node: handle new typename for dispatch error
Browse files Browse the repository at this point in the history
  • Loading branch information
mnaamani committed Sep 15, 2023
1 parent e089a28 commit 21d7177
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 2 additions & 1 deletion storage-node/src/services/runtime/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import stringify from 'fast-safe-stringify'
import sleep from 'sleep-promise'
import ExitCodes from '../../command-base/ExitCodes'
import logger from '../../services/logger'
import { SpRuntimeDispatchError } from '@polkadot/types/lookup'

/**
* Dedicated error for the failed extrinsics.
Expand Down Expand Up @@ -171,7 +172,7 @@ async function lockAndGetNonce(api: ApiPromise, account: KeyringPair): Promise<I
* @param error - DispatchError instance
* @returns error string.
*/
export function formatDispatchError(api: ApiPromise, error: DispatchError): string {
export function formatDispatchError(api: ApiPromise, error: DispatchError | SpRuntimeDispatchError): string {
// Need to assert that registry is of TypeRegistry type, since Registry intefrace
// seems outdated and doesn't include DispatchErrorModule as possible argument for "findMetaError"
const typeRegistry = api.registry as TypeRegistry
Expand Down
3 changes: 1 addition & 2 deletions storage-node/src/services/runtime/extrinsics.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ApiPromise } from '@polkadot/api'
import { KeyringPair } from '@polkadot/keyring/types'
import { DispatchError } from '@polkadot/types/interfaces/system'
import { PalletStorageBagIdType as BagId, PalletStorageDynamicBagType as DynamicBagType } from '@polkadot/types/lookup'
import BN from 'bn.js'
import { timeout } from 'promise-timeout'
Expand Down Expand Up @@ -118,7 +117,7 @@ export async function updateStorageBucketsForBags(
if (e.method === 'ItemFailed') {
return {
args: txs[i].args.toString(),
error: formatDispatchError(api, e.data[0] as DispatchError),
error: formatDispatchError(api, e.data[0]),
}
}
})
Expand Down

0 comments on commit 21d7177

Please sign in to comment.