Skip to content

Commit 67d6c50

Browse files
authored
Add ss58Format to ChainProperties interface (#1335)
* Add ss58Format to ChainProperties * Make ChaineProperties entries Option
1 parent 2d59e97 commit 67d6c50

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

packages/types/src/interfaces/rpc/ChainProperties.spec.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,22 @@ describe('ChainProperties', (): void => {
1414
});
1515

1616
it('decodes from an actual object', (): void => {
17-
const { tokenDecimals, tokenSymbol } = createType('ChainProperties', {
17+
const { ss58Format, tokenDecimals, tokenSymbol } = createType('ChainProperties', {
18+
ss58Format: 2,
1819
tokenDecimals: 15,
19-
tokenSymbol: 'BBQ'
20+
tokenSymbol: 'KSM'
2021
});
2122

22-
expect(tokenDecimals.eq(15)).toBe(true);
23-
expect(tokenSymbol.eq('BBQ')).toBe(true);
23+
expect(ss58Format.unwrap().eq(2)).toBe(true);
24+
expect(tokenDecimals.unwrap().eq(15)).toBe(true);
25+
expect(tokenSymbol.unwrap().eq('KSM')).toBe(true);
26+
});
27+
28+
it('decodes from an object, flagged for non-existent ss58Format', (): void => {
29+
const { ss58Format, tokenDecimals, tokenSymbol } = createType('ChainProperties', { tokenSymbol: 'DEV' });
30+
31+
expect(ss58Format.isNone).toBe(true);
32+
expect(tokenDecimals.isNone).toBe(true);
33+
expect(tokenSymbol.isSome).toBe(true);
2434
});
2535
});

packages/types/src/interfaces/rpc/definitions.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ export default {
66
types: {
77
ApiId: '[u8; 8]',
88
ChainProperties: {
9-
tokenDecimals: 'u32',
10-
tokenSymbol: 'Text'
9+
ss58Format: 'Option<u8>',
10+
tokenDecimals: 'Option<u32>',
11+
tokenSymbol: 'Option<Text>'
1112
},
1213
ExtrinsicOrHash: {
1314
_enum: {

packages/types/src/interfaces/rpc/types.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@
33

44
import { Codec } from '../../types';
55
import { Enum, Option, Struct, Vec } from '../../codec';
6-
import { Bytes, StorageData, StorageKey, Text, bool, u32, u64 } from '../../primitive';
6+
import { Bytes, StorageData, StorageKey, Text, bool, u32, u64, u8 } from '../../primitive';
77
import { BlockNumber, Hash } from '../runtime';
88

99
/** Uint8Array & Codec */
1010
export type ApiId = Uint8Array & Codec;
1111

1212
/** Struct */
1313
export interface ChainProperties extends Struct {
14-
/** u32 */
15-
readonly tokenDecimals: u32;
16-
/** Text */
17-
readonly tokenSymbol: Text;
14+
/** Option<u8> */
15+
readonly ss58Format: Option<u8>;
16+
/** Option<u32> */
17+
readonly tokenDecimals: Option<u32>;
18+
/** Option<Text> */
19+
readonly tokenSymbol: Option<Text>;
1820
}
1921

2022
/** Enum */

packages/types/src/primitive/Extrinsic/ExtrinsicPayload.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ describe('ExtrinsicPayload', (): void => {
1414
genesisHash: '0xdcd1346701ca8396496e52aa2785b1748deb6db09551b72159dcb3e08991025b',
1515
method: '0x0500ffd7568e5f0a7eda67a82691ff379ac4bba4f9c9b859fe779b5d46363b61ad2db9e56c',
1616
nonce: '0x00001234',
17+
specVersion: 123,
1718
tip: '0x00000000000000000000000000005678'
1819
};
1920

0 commit comments

Comments
 (0)