Bump common (#3099)
* Bump common * Undefined value * Test for undefined
This commit is contained in:
@@ -18,13 +18,13 @@
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@polkadot/metadata": "3.5.2-14",
|
||||
"@polkadot/util": "^5.3.2-8",
|
||||
"@polkadot/util-crypto": "^5.3.2-8",
|
||||
"@polkadot/x-rxjs": "3.5.2-1",
|
||||
"@polkadot/util": "^5.4.1",
|
||||
"@polkadot/util-crypto": "^5.4.1",
|
||||
"@polkadot/x-rxjs": "5.4.1",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^5.3.2-8"
|
||||
"@polkadot/keyring": "^5.4.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,10 +104,9 @@ function extractProperties (registry: Registry, metadata: Metadata): ChainProper
|
||||
return original;
|
||||
}
|
||||
|
||||
return registry.createType('ChainProperties', {
|
||||
...(original || {}),
|
||||
ss58Format
|
||||
});
|
||||
const { tokenDecimals, tokenSymbol } = original || {};
|
||||
|
||||
return registry.createType('ChainProperties', { ss58Format, tokenDecimals, tokenSymbol });
|
||||
}
|
||||
|
||||
export class TypeRegistry implements Registry {
|
||||
|
||||
@@ -22,12 +22,12 @@ describe('ChainProperties', (): void => {
|
||||
|
||||
it('decodes from an actual object (multiple tokens)', (): void => {
|
||||
const { ss58Format, tokenDecimals, tokenSymbol } = registry.createType('ChainProperties', {
|
||||
ss58Format: 27,
|
||||
ss58Format: undefined,
|
||||
tokenDecimals: [10, 12],
|
||||
tokenSymbol: ['pDOT', 'pKSM']
|
||||
});
|
||||
|
||||
expect(ss58Format.unwrap().eq(27)).toBe(true);
|
||||
expect(ss58Format.isNone).toBe(true);
|
||||
expect(tokenDecimals.unwrap().eq([10, 12])).toBe(true);
|
||||
expect(tokenSymbol.unwrap().eq(['pDOT', 'pKSM'])).toBe(true);
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import type { Codec, Registry } from '../types';
|
||||
|
||||
import { isFunction, isNull } from '@polkadot/util';
|
||||
import { isFunction, isNull, isUndefined } from '@polkadot/util';
|
||||
|
||||
import { Json } from '../codec/Json';
|
||||
import { Option } from '../codec/Option';
|
||||
@@ -13,14 +13,14 @@ import { u32 } from '../primitive/U32';
|
||||
|
||||
function createValue (registry: Registry, type: string, value: unknown, asArray = true): Option<Codec> {
|
||||
// We detect codec here as well - when found, generally this is constructed from itself
|
||||
if (isFunction((value as Option<Codec>).unwrapOrDefault)) {
|
||||
if (value && isFunction((value as Option<Codec>).unwrapOrDefault)) {
|
||||
return value as Option<Codec>;
|
||||
}
|
||||
|
||||
return registry.createType(
|
||||
type as 'Option<u32>',
|
||||
asArray
|
||||
? isNull(value)
|
||||
? isNull(value) || isUndefined(value)
|
||||
? null
|
||||
: Array.isArray(value)
|
||||
? value
|
||||
|
||||
Reference in New Issue
Block a user