From 410aa91020ec50276d2b3070580f73d93b521d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ti=E1=BA=BFn=20Nguy=E1=BB=85n=20Kh=E1=BA=AFc?= Date: Wed, 31 Jul 2024 23:35:18 +1200 Subject: [PATCH] fix(substrate-bindings): bytes to skip (#607) --- packages/substrate-bindings/CHANGELOG.md | 4 ++++ packages/substrate-bindings/src/storage.ts | 16 +++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/substrate-bindings/CHANGELOG.md b/packages/substrate-bindings/CHANGELOG.md index efc314b1b..921f293cb 100644 --- a/packages/substrate-bindings/CHANGELOG.md +++ b/packages/substrate-bindings/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Fixed + +- Incorrect bytes to skip when decoding storage key + ## 0.6.2 - 2024-07-25 ### Fixed diff --git a/packages/substrate-bindings/src/storage.ts b/packages/substrate-bindings/src/storage.ts index 9b5c071fc..9cdb7387a 100644 --- a/packages/substrate-bindings/src/storage.ts +++ b/packages/substrate-bindings/src/storage.ts @@ -32,12 +32,18 @@ export const Storage = (pallet: string) => { const bytesToSkip = encoders .map((e) => e[1]) .map((x) => { - if (x === Identity) return 0 - if (x === Twox64Concat) return 8 - if (x === Blake2128Concat) return 16 - return null + switch (x) { + case Identity: + return 0 + case Twox64Concat: + return 8 + case Blake2128Concat: + return 16 + default: + return null + } }) - .filter(Boolean) as Array + .filter((x) => x !== null) const keyDecoder = ( key: string,