Bump common (#3099)

* Bump common

* Undefined value

* Test for undefined
This commit is contained in:
Jaco Greeff
2021-01-24 11:23:23 +01:00
committed by GitHub
parent d438814ad6
commit 9269d94677
13 changed files with 123 additions and 124 deletions
+4 -4
View File
@@ -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"
}
}
+3 -4
View File
@@ -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