Add ss58Format to ChainProperties interface (#1335)

* Add ss58Format to ChainProperties

* Make ChaineProperties entries Option
This commit is contained in:
Jaco Greeff
2019-08-21 17:48:02 +02:00
committed by GitHub
parent 2d59e9790e
commit 67d6c5058f
4 changed files with 25 additions and 11 deletions
@@ -14,12 +14,22 @@ describe('ChainProperties', (): void => {
});
it('decodes from an actual object', (): void => {
const { tokenDecimals, tokenSymbol } = createType('ChainProperties', {
const { ss58Format, tokenDecimals, tokenSymbol } = createType('ChainProperties', {
ss58Format: 2,
tokenDecimals: 15,
tokenSymbol: 'BBQ'
tokenSymbol: 'KSM'
});
expect(tokenDecimals.eq(15)).toBe(true);
expect(tokenSymbol.eq('BBQ')).toBe(true);
expect(ss58Format.unwrap().eq(2)).toBe(true);
expect(tokenDecimals.unwrap().eq(15)).toBe(true);
expect(tokenSymbol.unwrap().eq('KSM')).toBe(true);
});
it('decodes from an object, flagged for non-existent ss58Format', (): void => {
const { ss58Format, tokenDecimals, tokenSymbol } = createType('ChainProperties', { tokenSymbol: 'DEV' });
expect(ss58Format.isNone).toBe(true);
expect(tokenDecimals.isNone).toBe(true);
expect(tokenSymbol.isSome).toBe(true);
});
});
@@ -6,8 +6,9 @@ export default {
types: {
ApiId: '[u8; 8]',
ChainProperties: {
tokenDecimals: 'u32',
tokenSymbol: 'Text'
ss58Format: 'Option<u8>',
tokenDecimals: 'Option<u32>',
tokenSymbol: 'Option<Text>'
},
ExtrinsicOrHash: {
_enum: {
+7 -5
View File
@@ -3,7 +3,7 @@
import { Codec } from '../../types';
import { Enum, Option, Struct, Vec } from '../../codec';
import { Bytes, StorageData, StorageKey, Text, bool, u32, u64 } from '../../primitive';
import { Bytes, StorageData, StorageKey, Text, bool, u32, u64, u8 } from '../../primitive';
import { BlockNumber, Hash } from '../runtime';
/** Uint8Array & Codec */
@@ -11,10 +11,12 @@ export type ApiId = Uint8Array & Codec;
/** Struct */
export interface ChainProperties extends Struct {
/** u32 */
readonly tokenDecimals: u32;
/** Text */
readonly tokenSymbol: Text;
/** Option<u8> */
readonly ss58Format: Option<u8>;
/** Option<u32> */
readonly tokenDecimals: Option<u32>;
/** Option<Text> */
readonly tokenSymbol: Option<Text>;
}
/** Enum */
@@ -14,6 +14,7 @@ describe('ExtrinsicPayload', (): void => {
genesisHash: '0xdcd1346701ca8396496e52aa2785b1748deb6db09551b72159dcb3e08991025b',
method: '0x0500ffd7568e5f0a7eda67a82691ff379ac4bba4f9c9b859fe779b5d46363b61ad2db9e56c',
nonce: '0x00001234',
specVersion: 123,
tip: '0x00000000000000000000000000005678'
};