Bump metadata (#1108)
* Bump metadata * Add Phantom type (grrr... don't like this in meta, but it is what it is) * yarn test:one Metadata passes * Update with new section indexes
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
"postinstall": "polkadot-dev-yarn-only",
|
||||
"test": "jest --coverage --testPathIgnorePatterns e2e",
|
||||
"test:all": "jest",
|
||||
"test:one": "jest",
|
||||
"test:watch": "jest --coverage --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -30,7 +30,7 @@ describe('fromMetadata', () => {
|
||||
// version, no signature
|
||||
1,
|
||||
// index
|
||||
1, 0,
|
||||
2, 0,
|
||||
// values, Compact<Moment>
|
||||
116
|
||||
])
|
||||
|
||||
@@ -22,7 +22,7 @@ describe('extrinsics', () => {
|
||||
}
|
||||
).toU8a(true)
|
||||
).toEqual(new Uint8Array([
|
||||
129, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 73, 19, 0, 1, 0, 213, 157
|
||||
129, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 73, 19, 0, 2, 0, 213, 157
|
||||
]));
|
||||
});
|
||||
|
||||
@@ -39,10 +39,10 @@ describe('extrinsics', () => {
|
||||
'2502' + // length
|
||||
'81' + // signed flag
|
||||
'ffd172a74cda4c865912c32ba0a80a57ae69abae410e5ccb59dee84e2f4432db4f' + // who
|
||||
'02f1b1aa2b3008731473caa5f28aad423543bffbb2828a8413185b3e1c1b787a' + // sig1
|
||||
'c4400f4a5dd61e3858e195ab92e39cc25155043a8505d9d6657a9c597a73a00e' + // sig2
|
||||
'fa4c192f6960a3bcdbdee5bcd9c26a3f971b131081912abcc31eab6a0b7589ab' + // sig1
|
||||
'7f99b81a01738cb5e2a911a19d5daa5c0b654d4b8dbc521a6b29090c6d205903' + // sig2
|
||||
'0000' + // nonce
|
||||
'0400' + // balances.transfer
|
||||
'0500' + // balances.transfer
|
||||
'ffd7568e5f0a7eda67a82691ff379ac4bba4f9c9b859fe779b5d46363b61ad2db9' + // to
|
||||
'e56c' // value
|
||||
);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
{"jsonrpc":"2.0","result":{"block":{"extrinsics":["0x20010100033822245d","0x14010a002534","0x250281ff90b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe2290b20be8c5929d7d4dfe3f8124bad55217fa0dc53210399448a7bddefade7a7e64489c1acbfe65eb42d235e6d54279cd88e4d6d6147862a4e5c6ba2ed44594006c000400ffe659a7a1628cdd93febc04a4e0646ea20e9f5f0ce097d9a05290d4a9e054df4ee5c0"],"header":{"digest":{"logs":["0x0661757261208e08491700000000","0x05617572610101039584bca9a9dd88d4bede8787ce022ddea809cef8ebdbf0d7b17c918e49921c86e6d6aedebc991630f7634b3f3306b6c134e87325f34301de5745df0da0240e"]},"extrinsicsRoot":"0xe52df22c1a9deb8ed460e5d80a3dd8e1090bfd51631f53eca465915089703b92","number":"0xd0a","parentHash":"0xcf5fa8ef2fe76c0d6288535231d21989829933b986d32a3ba452173c5a2074f1","stateRoot":"0x3fe7723fdb1a60938e45b72f1d84f414434b9df4ece367dbb39912ebe1a85e9f"}},"justification":null},"id":7}
|
||||
{"jsonrpc":"2.0","result":{"block":{"extrinsics":["0x20010100033822245d","0x14010a002534","0x250281ff90b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe2290b20be8c5929d7d4dfe3f8124bad55217fa0dc53210399448a7bddefade7a7e64489c1acbfe65eb42d235e6d54279cd88e4d6d6147862a4e5c6ba2ed44594006c000500ffe659a7a1628cdd93febc04a4e0646ea20e9f5f0ce097d9a05290d4a9e054df4ee5c0"],"header":{"digest":{"logs":["0x0661757261208e08491700000000","0x05617572610101039584bca9a9dd88d4bede8787ce022ddea809cef8ebdbf0d7b17c918e49921c86e6d6aedebc991630f7634b3f3306b6c134e87325f34301de5745df0da0240e"]},"extrinsicsRoot":"0xe52df22c1a9deb8ed460e5d80a3dd8e1090bfd51631f53eca465915089703b92","number":"0xd0a","parentHash":"0xcf5fa8ef2fe76c0d6288535231d21989829933b986d32a3ba452173c5a2074f1","stateRoot":"0x3fe7723fdb1a60938e45b72f1d84f414434b9df4ece367dbb39912ebe1a85e9f"}},"justification":null},"id":7}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"jsonrpc":"2.0","result":{"block":{"extrinsics":["0x20010100036022245d","0x14010a004d34","0x290281ff90b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe22f2040bbcf048e6bfb68c0722fe379c93afbc8f885ee21fc5b5679d4ade606a7d46cf151a2b8ad5bbce6ee198a41e3251302f5e9c64f457dbeacacf3e43b448087033000400ffe659a7a1628cdd93febc04a4e0646ea20e9f5f0ce097d9a05290d4a9e054df4ee5c0"],"header":{"digest":{"logs":["0x0661757261209808491700000000","0x0561757261010195888c7f16b54cf99117933d503faea1a7a8bdab4b6a8144c078b6c3d9e55d3a1114af92b2360a0694a057df016e1ad2bd750d43411464b9e7414e921cfdc00b"]},"extrinsicsRoot":"0x751fc4dfad59fefd3c4f730596f1a742b56c9936b4e3d4801015472261a0ce48","number":"0xd14","parentHash":"0x497b3b929ae079f6f0d280ba85744b87559eaab8969619be5cc7596c5a974cb9","stateRoot":"0x011c352e0f97cad72578f9e1e8ec759096365b891928d6b094d0d8d329f9bbab"}},"justification":null},"id":8}
|
||||
{"jsonrpc":"2.0","result":{"block":{"extrinsics":["0x20010100036022245d","0x14010a004d34","0x290281ff90b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe22f2040bbcf048e6bfb68c0722fe379c93afbc8f885ee21fc5b5679d4ade606a7d46cf151a2b8ad5bbce6ee198a41e3251302f5e9c64f457dbeacacf3e43b448087033000500ffe659a7a1628cdd93febc04a4e0646ea20e9f5f0ce097d9a05290d4a9e054df4ee5c0"],"header":{"digest":{"logs":["0x0661757261209808491700000000","0x0561757261010195888c7f16b54cf99117933d503faea1a7a8bdab4b6a8144c078b6c3d9e55d3a1114af92b2360a0694a057df016e1ad2bd750d43411464b9e7414e921cfdc00b"]},"extrinsicsRoot":"0x751fc4dfad59fefd3c4f730596f1a742b56c9936b4e3d4801015472261a0ce48","number":"0xd14","parentHash":"0x497b3b929ae079f6f0d280ba85744b87559eaab8969619be5cc7596c5a974cb9","stateRoot":"0x011c352e0f97cad72578f9e1e8ec759096365b891928d6b094d0d8d329f9bbab"}},"justification":null},"id":8}
|
||||
|
||||
@@ -11,21 +11,19 @@ describe('Method', () => {
|
||||
Method.injectMethods(extrinsics);
|
||||
});
|
||||
|
||||
// FIXME susbtrate master does not currently expose the new system module calls in meta,
|
||||
// once it does the index here will change, so a different method would be refrerred to
|
||||
it('handles decoding correctly (bare)', () => {
|
||||
expect(
|
||||
new Method({
|
||||
args: [],
|
||||
callIndex: [4, 1] // balances.setBalance
|
||||
callIndex: [5, 1] // balances.setBalance
|
||||
}).toU8a()
|
||||
).toEqual(new Uint8Array([4, 1, 0, 0, 0]));
|
||||
).toEqual(new Uint8Array([5, 1, 0, 0, 0]));
|
||||
});
|
||||
|
||||
it('handles creation from a hex value properly', () => {
|
||||
expect(
|
||||
new Method('0x0401').toU8a()
|
||||
).toEqual(new Uint8Array([4, 1, 0, 0, 0])); // balances.setBalance
|
||||
new Method('0x0501').toU8a()
|
||||
).toEqual(new Uint8Array([5, 1, 0, 0, 0])); // balances.setBalance
|
||||
});
|
||||
|
||||
describe('hasOrigin', () => {
|
||||
|
||||
@@ -68,3 +68,14 @@ export default class Null implements Codec {
|
||||
return new Uint8Array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Phantom
|
||||
* @description
|
||||
* Implements a type that does not contain anything (apart from `null`)
|
||||
*/
|
||||
export class Phantom extends Null {
|
||||
toRawType (): string {
|
||||
return 'Phantom';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,9 @@ export default class Type extends Text {
|
||||
// HACK duplication between contracts & primitives, however contracts prefixed with exec
|
||||
Type._alias('exec::StorageKey', 'ContractStorageKey'),
|
||||
// flattens tuples with one value, `(AccountId)` -> `AccountId`
|
||||
Type._flattenSingleTuple()
|
||||
Type._flattenSingleTuple(),
|
||||
// converts ::Type to Type, <T as Trait<I>>::Proposal -> ::Proposal
|
||||
Type._removeColonPrefix()
|
||||
];
|
||||
|
||||
return mappings.reduce((result, fn) => {
|
||||
@@ -148,6 +150,12 @@ export default class Type extends Text {
|
||||
};
|
||||
}
|
||||
|
||||
private static _removeColonPrefix (): Mapper {
|
||||
return (value: string): string => {
|
||||
return value.replace(/^::/, '');
|
||||
};
|
||||
}
|
||||
|
||||
private static _removeGenerics (): Mapper {
|
||||
return (value: string): string => {
|
||||
for (let index = 0; index < value.length; index++) {
|
||||
|
||||
@@ -34,7 +34,7 @@ export { default as I128, default as i128 } from './I128';
|
||||
export { default as I256, default as i256 } from './I256';
|
||||
export { default as Method } from './Method';
|
||||
export { default as Moment, MomentOf } from './Moment';
|
||||
export { default as Null } from './Null';
|
||||
export { default as Null, Phantom } from './Null';
|
||||
export { default as Origin } from './Origin';
|
||||
export { default as Signature, Ed25519Signature, Sr25519Signature } from './Signature';
|
||||
export { default as StorageData } from './StorageData';
|
||||
|
||||
@@ -13,16 +13,16 @@ describe('Extrinsic', () => {
|
||||
});
|
||||
|
||||
it.skip('decodes a non-signed properly via JSON', () => {
|
||||
const extrinsic = new Extrinsic('0x010200ea51b75b00000000');
|
||||
const extrinsic = new Extrinsic('0x010300ea51b75b00000000');
|
||||
|
||||
expect(extrinsic.isSigned).toEqual(false);
|
||||
expect(extrinsic.callIndex).toEqual(new Uint8Array([2, 0]));
|
||||
expect(extrinsic.callIndex).toEqual(new Uint8Array([3, 0]));
|
||||
expect(extrinsic.data).toEqual(new Uint8Array([234, 81, 183, 91, 0, 0, 0, 0]));
|
||||
});
|
||||
|
||||
it('decodes an actual transaction (new format)', () => {
|
||||
const extrinsic = new Extrinsic('0x250281ffbfc823aa75c30058eeec21abe2c2d6b7247418a4af89d67a2084c2ac864da080c0aa4df3b4926c3cd78bbdced31d8bdccb8604b779b71b90e58b2848df4a9ad6b0aa1aae6be7a05c9413a172b0325e4d214e5ff2b25098028b30f1a50be9c90e0c00' +
|
||||
'0400' + // balances.transfer
|
||||
'0500' + // balances.transfer
|
||||
'ff4a83f1c09be797bc3d9adce29818368b276a84e6b545ced492c25c948978d7f8e5c0');
|
||||
|
||||
expect(extrinsic.isSigned).toEqual(true);
|
||||
@@ -30,7 +30,7 @@ describe('Extrinsic', () => {
|
||||
expect(extrinsic.signature.signature.toHex()).toEqual('0xc0aa4df3b4926c3cd78bbdced31d8bdccb8604b779b71b90e58b2848df4a9ad6b0aa1aae6be7a05c9413a172b0325e4d214e5ff2b25098028b30f1a50be9c90e');
|
||||
expect(extrinsic.signature.nonce.toNumber()).toEqual(3);
|
||||
expect(extrinsic.signature.era.toU8a()).toEqual(new Uint8Array([0]));
|
||||
expect(extrinsic.callIndex).toEqual(new Uint8Array([4, 0]));
|
||||
expect(extrinsic.callIndex).toEqual(new Uint8Array([5, 0]));
|
||||
expect(`${extrinsic.method.sectionName}.${extrinsic.method.methodName}`).toEqual('balances.transfer');
|
||||
expect(extrinsic.args[0].toString()).toEqual('5DkQbYAExs3M2sZgT1Ec3mKfZnAQCL4Dt9beTCknkCUn5jzo');
|
||||
});
|
||||
@@ -38,7 +38,7 @@ describe('Extrinsic', () => {
|
||||
it('decodes an actual transaction (old format)', () => {
|
||||
const extrinsic = new Extrinsic(
|
||||
'0x81ffbfc823aa75c30058eeec21abe2c2d6b7247418a4af89d67a2084c2ac864da080c0aa4df3b4926c3cd78bbdced31d8bdccb8604b779b71b90e58b2848df4a9ad6b0aa1aae6be7a05c9413a172b0325e4d214e5ff2b25098028b30f1a50be9c90e0c00' +
|
||||
'0400' + // balances.transfer
|
||||
'0500' + // balances.transfer
|
||||
'ff4a83f1c09be797bc3d9adce29818368b276a84e6b545ced492c25c948978d7f8e5c0'
|
||||
);
|
||||
|
||||
@@ -47,7 +47,7 @@ describe('Extrinsic', () => {
|
||||
expect(extrinsic.signature.signature.toHex()).toEqual('0xc0aa4df3b4926c3cd78bbdced31d8bdccb8604b779b71b90e58b2848df4a9ad6b0aa1aae6be7a05c9413a172b0325e4d214e5ff2b25098028b30f1a50be9c90e');
|
||||
expect(extrinsic.signature.nonce.toNumber()).toEqual(3);
|
||||
expect(extrinsic.signature.era.toU8a()).toEqual(new Uint8Array([0]));
|
||||
expect(extrinsic.callIndex).toEqual(new Uint8Array([4, 0]));
|
||||
expect(extrinsic.callIndex).toEqual(new Uint8Array([5, 0]));
|
||||
expect(`${extrinsic.method.sectionName}.${extrinsic.method.methodName}`).toEqual('balances.transfer');
|
||||
expect(extrinsic.args[0].toString()).toEqual('5DkQbYAExs3M2sZgT1Ec3mKfZnAQCL4Dt9beTCknkCUn5jzo');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user