Skip to content

Commit

Permalink
fix(client): uncaught storage exception with incompatible runtime (po…
Browse files Browse the repository at this point in the history
  • Loading branch information
voliva authored Apr 16, 2024
1 parent 74da2b4 commit 4628891
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Fixed

- client: uncaught storage exception with incompatible runtime.

## 0.2.3 - 2024-04-15

### Fixed
Expand Down
5 changes: 3 additions & 2 deletions packages/client/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ export const createStorageEntry = (
at,
"value",
(ctx) => {
if (!isCompatible(ctx)) throw checksumError()
const codecs = ctx.dynamicBuilder.buildStorage(pallet, name)
const actualArgs = args.length === codecs.len ? args : args.slice(0, -1)
if (args !== actualArgs && !isLastArgOptional) throw invalidArgs(args)
if (!isCompatible(ctx)) throw checksumError()
return codecs.enc(...actualArgs)
},
null,
Expand All @@ -132,13 +132,14 @@ export const createStorageEntry = (
at,
"descendantsValues",
(ctx) => {
if (!isCompatible(ctx)) throw checksumError()

const codecs = ctx.dynamicBuilder.buildStorage(pallet, name)
if (args.length > codecs.len) throw invalidArgs(args)
const actualArgs =
args.length > 0 && isLastArgOptional ? args.slice(0, -1) : args
if (args.length === codecs.len && actualArgs === args)
throw invalidArgs(args)
if (!isCompatible(ctx)) throw checksumError()
return codecs.enc(...actualArgs)
},
null,
Expand Down

0 comments on commit 4628891

Please sign in to comment.