accountId decoding
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
// Copyright 2017-2018 @polkadot/params authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
import { EncodingVersions, Param$Decoded } from '../../types';
|
||||
|
||||
// TODO Comment out when auto-convert of addresses is in place
|
||||
// import encodeAddress from '@polkadot/util-keyring/address/encode';
|
||||
|
||||
import u8a from './u8a';
|
||||
|
||||
export default function accountId (input: Uint8Array | null, version: EncodingVersions, isStorage: boolean): Param$Decoded {
|
||||
if (input === null) {
|
||||
return {
|
||||
length: 0
|
||||
} as Param$Decoded;
|
||||
}
|
||||
|
||||
const u8aDecoded = u8a(input, 256, (isStorage || version === 'poc-1') ? 0 : 1);
|
||||
|
||||
return {
|
||||
length: u8aDecoded.length,
|
||||
value: u8aDecoded.value // encodeAddress(u8aDecoded.value as Uint8Array)
|
||||
};
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import { Decoder } from '../types';
|
||||
import sizes from '@polkadot/primitives/sizes';
|
||||
import toU8a from '@polkadot/util/u8a/toU8a';
|
||||
|
||||
import accountId from './accountId';
|
||||
import bool from './bool';
|
||||
import bn from './bn';
|
||||
import byte from './byte';
|
||||
@@ -30,7 +31,7 @@ export default function decodeValue (decode: Decoder, type: Param$Type, _input:
|
||||
switch (type) {
|
||||
// TODO Pass back the actual address, not publicKey?
|
||||
case 'AccountId':
|
||||
return u8a(input, 256, (isStorage || version === 'poc-1') ? 0 : 1);
|
||||
return accountId(input, version, isStorage);
|
||||
|
||||
case 'Balance':
|
||||
return bn(input, sizes.Balance);
|
||||
|
||||
Reference in New Issue
Block a user