Decode code correctly (length-prefixed) (#168)

This commit is contained in:
Jaco Greeff
2018-07-12 13:20:14 +02:00
committed by GitHub
parent b673e52f8a
commit 086fb8d90b
3 changed files with 131 additions and 68 deletions
@@ -4,9 +4,14 @@
import { Param$Decoded } from '../../types';
import u8aToBn from '@polkadot/util/u8a/toBn';
export default function code (input: Uint8Array): Param$Decoded {
const length = u8aToBn(input.subarray(0, 4), true).toNumber() + 4;
const value = input.subarray(4, length);
return {
length: input.length,
value: input
length,
value
};
}