Bump common (#5095)
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
"@polkadot/types": "8.13.2-8-x",
|
||||
"@polkadot/types-augment": "8.13.2-8-x",
|
||||
"@polkadot/types-codec": "8.13.2-8-x",
|
||||
"@polkadot/util": "^10.0.2"
|
||||
"@polkadot/util": "^10.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/types-support": "8.13.2-8-x"
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
"@babel/runtime": "^7.18.9",
|
||||
"@polkadot/rpc-core": "8.13.2-8-x",
|
||||
"@polkadot/types": "8.13.2-8-x",
|
||||
"@polkadot/util": "^10.0.2",
|
||||
"@polkadot/util": "^10.1.1",
|
||||
"rxjs": "^7.5.6"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,12 +28,12 @@
|
||||
"@polkadot/types": "8.13.2-8-x",
|
||||
"@polkadot/types-codec": "8.13.2-8-x",
|
||||
"@polkadot/types-create": "8.13.2-8-x",
|
||||
"@polkadot/util": "^10.0.2",
|
||||
"@polkadot/util-crypto": "^10.0.2",
|
||||
"@polkadot/util": "^10.1.1",
|
||||
"@polkadot/util-crypto": "^10.1.1",
|
||||
"rxjs": "^7.5.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/api-augment": "8.13.2-8-x",
|
||||
"@polkadot/keyring": "^10.0.2"
|
||||
"@polkadot/keyring": "^10.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
"@polkadot/rpc-core": "8.13.2-8-x",
|
||||
"@polkadot/types": "8.13.2-8-x",
|
||||
"@polkadot/types-codec": "8.13.2-8-x",
|
||||
"@polkadot/util": "^10.0.2",
|
||||
"@polkadot/util-crypto": "^10.0.2",
|
||||
"@polkadot/util": "^10.1.1",
|
||||
"@polkadot/util-crypto": "^10.1.1",
|
||||
"rxjs": "^7.5.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
"@polkadot/api-augment": "8.13.2-8-x",
|
||||
"@polkadot/api-base": "8.13.2-8-x",
|
||||
"@polkadot/api-derive": "8.13.2-8-x",
|
||||
"@polkadot/keyring": "^10.0.2",
|
||||
"@polkadot/keyring": "^10.1.1",
|
||||
"@polkadot/rpc-augment": "8.13.2-8-x",
|
||||
"@polkadot/rpc-core": "8.13.2-8-x",
|
||||
"@polkadot/rpc-provider": "8.13.2-8-x",
|
||||
@@ -36,8 +36,8 @@
|
||||
"@polkadot/types-codec": "8.13.2-8-x",
|
||||
"@polkadot/types-create": "8.13.2-8-x",
|
||||
"@polkadot/types-known": "8.13.2-8-x",
|
||||
"@polkadot/util": "^10.0.2",
|
||||
"@polkadot/util-crypto": "^10.0.2",
|
||||
"@polkadot/util": "^10.1.1",
|
||||
"@polkadot/util-crypto": "^10.1.1",
|
||||
"eventemitter3": "^4.0.7",
|
||||
"rxjs": "^7.5.6"
|
||||
},
|
||||
|
||||
@@ -27,6 +27,6 @@
|
||||
"@polkadot/rpc-core": "8.13.2-8-x",
|
||||
"@polkadot/types": "8.13.2-8-x",
|
||||
"@polkadot/types-codec": "8.13.2-8-x",
|
||||
"@polkadot/util": "^10.0.2"
|
||||
"@polkadot/util": "^10.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,11 +27,11 @@
|
||||
"@polkadot/rpc-augment": "8.13.2-8-x",
|
||||
"@polkadot/rpc-provider": "8.13.2-8-x",
|
||||
"@polkadot/types": "8.13.2-8-x",
|
||||
"@polkadot/util": "^10.0.2",
|
||||
"@polkadot/util": "^10.1.1",
|
||||
"rxjs": "^7.5.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^10.0.2",
|
||||
"@polkadot/keyring": "^10.1.1",
|
||||
"@polkadot/rpc-augment": "8.13.2-8-x"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,14 +24,14 @@
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.9",
|
||||
"@polkadot/keyring": "^10.0.2",
|
||||
"@polkadot/keyring": "^10.1.1",
|
||||
"@polkadot/types": "8.13.2-8-x",
|
||||
"@polkadot/types-support": "8.13.2-8-x",
|
||||
"@polkadot/util": "^10.0.2",
|
||||
"@polkadot/util-crypto": "^10.0.2",
|
||||
"@polkadot/x-fetch": "^10.0.2",
|
||||
"@polkadot/x-global": "^10.0.2",
|
||||
"@polkadot/x-ws": "^10.0.2",
|
||||
"@polkadot/util": "^10.1.1",
|
||||
"@polkadot/util-crypto": "^10.1.1",
|
||||
"@polkadot/x-fetch": "^10.1.1",
|
||||
"@polkadot/x-global": "^10.1.1",
|
||||
"@polkadot/x-ws": "^10.1.1",
|
||||
"@substrate/connect": "0.7.9",
|
||||
"eventemitter3": "^4.0.7",
|
||||
"mock-socket": "^9.1.5",
|
||||
|
||||
@@ -42,9 +42,9 @@
|
||||
"@polkadot/types-codec": "8.13.2-8-x",
|
||||
"@polkadot/types-create": "8.13.2-8-x",
|
||||
"@polkadot/types-support": "8.13.2-8-x",
|
||||
"@polkadot/util": "^10.0.2",
|
||||
"@polkadot/util-crypto": "^10.0.2",
|
||||
"@polkadot/x-ws": "^10.0.2",
|
||||
"@polkadot/util": "^10.1.1",
|
||||
"@polkadot/util-crypto": "^10.1.1",
|
||||
"@polkadot/x-ws": "^10.1.1",
|
||||
"handlebars": "^4.7.7",
|
||||
"websocket": "^1.0.34",
|
||||
"yargs": "^17.5.1"
|
||||
|
||||
@@ -26,6 +26,6 @@
|
||||
"@babel/runtime": "^7.18.9",
|
||||
"@polkadot/types": "8.13.2-8-x",
|
||||
"@polkadot/types-codec": "8.13.2-8-x",
|
||||
"@polkadot/util": "^10.0.2"
|
||||
"@polkadot/util": "^10.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,13 +24,13 @@
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.9",
|
||||
"@polkadot/util": "^10.0.2",
|
||||
"@polkadot/x-bigint": "^10.0.2"
|
||||
"@polkadot/util": "^10.1.1",
|
||||
"@polkadot/x-bigint": "^10.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/types": "8.13.2-8-x",
|
||||
"@polkadot/types-augment": "8.13.2-8-x",
|
||||
"@polkadot/types-support": "8.13.2-8-x",
|
||||
"@polkadot/util-crypto": "^10.0.2"
|
||||
"@polkadot/util-crypto": "^10.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,116 @@ describe('Struct', (): void => {
|
||||
testDecode('hex', '0x1c62617a7a696e6745000000');
|
||||
testDecode('object', { foo: 'bazzing', bar: 69 });
|
||||
testDecode('Uint8Array', Uint8Array.from([28, 98, 97, 122, 122, 105, 110, 103, 69, 0, 0, 0]));
|
||||
|
||||
it('decodes null/undefined/empty correctly (& equivalent)', (): void => {
|
||||
const Clazz = Struct.with({
|
||||
txt: Text,
|
||||
u32: U32
|
||||
});
|
||||
const expected = { txt: '', u32: '0' };
|
||||
|
||||
expect(new Clazz(registry, {}).toHuman()).toEqual(expected);
|
||||
expect(new Clazz(registry, null).toHuman()).toEqual(expected);
|
||||
expect(new Clazz(registry, undefined).toHuman()).toEqual(expected);
|
||||
});
|
||||
|
||||
it('decodes with Optionals', (): void => {
|
||||
const Clazz = Struct.with({
|
||||
a: 'Option<Bool>',
|
||||
b: 'Option<Bool>'
|
||||
});
|
||||
|
||||
const c = new Clazz(registry, { a: false }) as unknown as { a: Option<Bool>, b: Option<Bool> };
|
||||
|
||||
expect(c.a.isSome).toEqual(true);
|
||||
expect(c.a.unwrap().isTrue).toEqual(false);
|
||||
expect(c.b.isSome).toEqual(false);
|
||||
});
|
||||
|
||||
it('decodes reusing instantiated inputs', (): void => {
|
||||
const foo = new Text(registry, 'bar');
|
||||
|
||||
expect(
|
||||
(new Struct(
|
||||
registry,
|
||||
{ foo: Text },
|
||||
{ foo }
|
||||
)).get('foo')
|
||||
).toBe(foo);
|
||||
});
|
||||
|
||||
it('decodes a more complicated type', (): void => {
|
||||
const s = new Struct(registry, {
|
||||
foo: Vec.with(Struct.with({
|
||||
bar: Text
|
||||
}))
|
||||
}, { foo: [{ bar: 1 }, { bar: 2 }] });
|
||||
|
||||
expect(s.toString()).toBe('{"foo":[{"bar":"1"},{"bar":"2"}]}');
|
||||
});
|
||||
|
||||
it('decodes a previously problematic input', (): void => {
|
||||
let data;
|
||||
|
||||
try {
|
||||
data = new Struct(registry, {
|
||||
a: 'u32',
|
||||
b: 'H256',
|
||||
c: 'H256',
|
||||
swap: Enum.with({
|
||||
A: 'u256',
|
||||
B: 'u256'
|
||||
}),
|
||||
d: Vec.with('u8'),
|
||||
e: 'u8'
|
||||
}, TEST_A);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
expect(data.get('d')).toHaveLength(50000);
|
||||
});
|
||||
|
||||
it('decodes from a Map input', (): void => {
|
||||
const s = new Struct(registry, {
|
||||
txt: Text,
|
||||
foo: U32,
|
||||
bar: U32
|
||||
}, new Map<string, unknown>([['a', 42], ['txt', 'fubar']]));
|
||||
|
||||
expect(s.toString()).toEqual('{"txt":"fubar","foo":0,"bar":0}');
|
||||
});
|
||||
|
||||
it('decodes from a snake_case input', (): void => {
|
||||
const input = new Struct(registry, {
|
||||
snakeCaseA: U32,
|
||||
snakeCaseB: Text,
|
||||
other: U32
|
||||
}, { snake_case_a: 42, snake_case_b: 'fubar', other: 69 } as any);
|
||||
|
||||
expect(input.toString()).toEqual('{"snakeCaseA":42,"snakeCaseB":"fubar","other":69}');
|
||||
});
|
||||
|
||||
it('throws when it cannot decode', (): void => {
|
||||
expect(
|
||||
(): Struct<any> => new (
|
||||
Struct.with({
|
||||
txt: Text,
|
||||
u32: U32
|
||||
})
|
||||
)(registry, 'ABC')
|
||||
).toThrowError(/Cannot decode value/);
|
||||
});
|
||||
|
||||
it('throws a sensical error on incorrect array values passed to structs', (): void => {
|
||||
expect(
|
||||
() => new Struct(registry, {
|
||||
_: 'Vec<u32>'
|
||||
}, [123, 456])
|
||||
).toThrow(/array to object with known keys/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('encoding', (): void => {
|
||||
@@ -52,116 +162,6 @@ describe('Struct', (): void => {
|
||||
testEncode('toString', '{"foo":"bazzing","bar":69}');
|
||||
});
|
||||
|
||||
it('decodes null/undefined/empty correctly (& equivalently)', (): void => {
|
||||
const Clazz = Struct.with({
|
||||
txt: Text,
|
||||
u32: U32
|
||||
});
|
||||
const expected = { txt: '', u32: '0' };
|
||||
|
||||
expect(new Clazz(registry, {}).toHuman()).toEqual(expected);
|
||||
expect(new Clazz(registry, null).toHuman()).toEqual(expected);
|
||||
expect(new Clazz(registry, undefined).toHuman()).toEqual(expected);
|
||||
});
|
||||
|
||||
it('decodes with Optionals', (): void => {
|
||||
const Clazz = Struct.with({
|
||||
a: 'Option<Bool>',
|
||||
b: 'Option<Bool>'
|
||||
});
|
||||
|
||||
const c = new Clazz(registry, { a: false }) as unknown as { a: Option<Bool>, b: Option<Bool> };
|
||||
|
||||
expect(c.a.isSome).toEqual(true);
|
||||
expect(c.a.unwrap().isTrue).toEqual(false);
|
||||
expect(c.b.isSome).toEqual(false);
|
||||
});
|
||||
|
||||
it('decodes reusing instantiated inputs', (): void => {
|
||||
const foo = new Text(registry, 'bar');
|
||||
|
||||
expect(
|
||||
(new Struct(
|
||||
registry,
|
||||
{ foo: Text },
|
||||
{ foo }
|
||||
)).get('foo')
|
||||
).toBe(foo);
|
||||
});
|
||||
|
||||
it('decodes a more complicated type', (): void => {
|
||||
const s = new Struct(registry, {
|
||||
foo: Vec.with(Struct.with({
|
||||
bar: Text
|
||||
}))
|
||||
}, { foo: [{ bar: 1 }, { bar: 2 }] });
|
||||
|
||||
expect(s.toString()).toBe('{"foo":[{"bar":"1"},{"bar":"2"}]}');
|
||||
});
|
||||
|
||||
it('decodes a previously problematic input', (): void => {
|
||||
let data;
|
||||
|
||||
try {
|
||||
data = new Struct(registry, {
|
||||
a: 'u32',
|
||||
b: 'H256',
|
||||
c: 'H256',
|
||||
swap: Enum.with({
|
||||
A: 'u256',
|
||||
B: 'u256'
|
||||
}),
|
||||
d: Vec.with('u8'),
|
||||
e: 'u8'
|
||||
}, TEST_A);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
expect(data.get('d')).toHaveLength(50000);
|
||||
});
|
||||
|
||||
it('decodes from a Map input', (): void => {
|
||||
const s = new Struct(registry, {
|
||||
txt: Text,
|
||||
foo: U32,
|
||||
bar: U32
|
||||
}, new Map<string, unknown>([['a', 42], ['txt', 'fubar']]));
|
||||
|
||||
expect(s.toString()).toEqual('{"txt":"fubar","foo":0,"bar":0}');
|
||||
});
|
||||
|
||||
it('decodes from a snake_case input', (): void => {
|
||||
const input = new Struct(registry, {
|
||||
snakeCaseA: U32,
|
||||
snakeCaseB: Text,
|
||||
other: U32
|
||||
}, { snake_case_a: 42, snake_case_b: 'fubar', other: 69 } as any);
|
||||
|
||||
expect(input.toString()).toEqual('{"snakeCaseA":42,"snakeCaseB":"fubar","other":69}');
|
||||
});
|
||||
|
||||
it('throws when it cannot decode', (): void => {
|
||||
expect(
|
||||
(): Struct<any> => new (
|
||||
Struct.with({
|
||||
txt: Text,
|
||||
u32: U32
|
||||
})
|
||||
)(registry, 'ABC')
|
||||
).toThrowError(/Cannot decode value/);
|
||||
});
|
||||
|
||||
it('throws a sensical error on incorrect array values passed to structs', (): void => {
|
||||
expect(
|
||||
() => new Struct(registry, {
|
||||
_: 'Vec<u32>'
|
||||
}, [123, 456])
|
||||
).toThrow(/array to object with known keys/);
|
||||
});
|
||||
|
||||
it('provides a clean toString()', (): void => {
|
||||
expect(
|
||||
new (
|
||||
@@ -257,6 +257,83 @@ describe('Struct', (): void => {
|
||||
}, test).eq(test)
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('has a sane toPrimitive', (): void => {
|
||||
const S = Struct.with({
|
||||
name: 'Text',
|
||||
description: 'Vec<Text>',
|
||||
fooA: 'Bytes',
|
||||
fooB: 'Bytes',
|
||||
fooC: Struct.with({
|
||||
a: 'u32',
|
||||
b: 'u128',
|
||||
c: 'Compact<u128>',
|
||||
d: 'bool'
|
||||
})
|
||||
});
|
||||
|
||||
expect(
|
||||
new S(registry, {
|
||||
name: 'Something',
|
||||
description: ['One line', 'Another line'],
|
||||
fooA: 'hello world!',
|
||||
fooB: '0x123456',
|
||||
fooC: {
|
||||
a: 1234,
|
||||
b: BigInt('1234567890111213141516'),
|
||||
c: 123456,
|
||||
d: true
|
||||
}
|
||||
}).toPrimitive()
|
||||
).toEqual({
|
||||
name: 'Something',
|
||||
description: ['One line', 'Another line'],
|
||||
fooA: 'hello world!',
|
||||
fooB: '0x123456',
|
||||
fooC: {
|
||||
a: 1234,
|
||||
b: '1234567890111213141516',
|
||||
c: 123456,
|
||||
d: true
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('generates sane toRawType', (): void => {
|
||||
expect(
|
||||
new Struct(registry, {
|
||||
accountId: 'AccountId',
|
||||
balanceCompact: registry.createClass('Compact<Balance>'),
|
||||
blockNumber: registry.createClass('BlockNumber'),
|
||||
compactNumber: registry.createClass('Compact<BlockNumber>'),
|
||||
optionNumber: registry.createClass('Option<BlockNumber>'),
|
||||
counter: U32,
|
||||
vector: Vec.with('AccountId')
|
||||
}).toRawType()
|
||||
).toEqual(JSON.stringify({
|
||||
accountId: 'AccountId',
|
||||
balanceCompact: 'Compact<Balance>', // Override in Uint
|
||||
blockNumber: 'BlockNumber',
|
||||
compactNumber: 'Compact<BlockNumber>',
|
||||
optionNumber: 'Option<BlockNumber>',
|
||||
counter: 'u32',
|
||||
vector: 'Vec<AccountId>'
|
||||
}));
|
||||
});
|
||||
|
||||
it('generates sane toRawType (via with)', (): void => {
|
||||
const Type = Struct.with({
|
||||
accountId: 'AccountId',
|
||||
balance: registry.createClass('Balance')
|
||||
});
|
||||
|
||||
expect(
|
||||
new Type(registry).toRawType()
|
||||
).toEqual(JSON.stringify({
|
||||
accountId: 'AccountId',
|
||||
balance: 'Balance' // Override in Uint
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
it('allows toString with large numbers', (): void => {
|
||||
@@ -268,42 +345,6 @@ describe('Struct', (): void => {
|
||||
).toEqual('{"blockNumber":279694831}');
|
||||
});
|
||||
|
||||
it('generates sane toRawType', (): void => {
|
||||
expect(
|
||||
new Struct(registry, {
|
||||
accountId: 'AccountId',
|
||||
balanceCompact: registry.createClass('Compact<Balance>'),
|
||||
blockNumber: registry.createClass('BlockNumber'),
|
||||
compactNumber: registry.createClass('Compact<BlockNumber>'),
|
||||
optionNumber: registry.createClass('Option<BlockNumber>'),
|
||||
counter: U32,
|
||||
vector: Vec.with('AccountId')
|
||||
}).toRawType()
|
||||
).toEqual(JSON.stringify({
|
||||
accountId: 'AccountId',
|
||||
balanceCompact: 'Compact<Balance>', // Override in Uint
|
||||
blockNumber: 'BlockNumber',
|
||||
compactNumber: 'Compact<BlockNumber>',
|
||||
optionNumber: 'Option<BlockNumber>',
|
||||
counter: 'u32',
|
||||
vector: 'Vec<AccountId>'
|
||||
}));
|
||||
});
|
||||
|
||||
it('generates sane toRawType (via with)', (): void => {
|
||||
const Type = Struct.with({
|
||||
accountId: 'AccountId',
|
||||
balance: registry.createClass('Balance')
|
||||
});
|
||||
|
||||
expect(
|
||||
new Type(registry).toRawType()
|
||||
).toEqual(JSON.stringify({
|
||||
accountId: 'AccountId',
|
||||
balance: 'Balance' // Override in Uint
|
||||
}));
|
||||
});
|
||||
|
||||
describe('toU8a', (): void => {
|
||||
const def: Record<string, any> = {
|
||||
foo: 'Bytes',
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.9",
|
||||
"@polkadot/types-codec": "8.13.2-8-x",
|
||||
"@polkadot/util": "^10.0.2"
|
||||
"@polkadot/util": "^10.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/types": "8.13.2-8-x"
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.9",
|
||||
"@polkadot/networks": "^10.0.2",
|
||||
"@polkadot/networks": "^10.1.1",
|
||||
"@polkadot/types": "8.13.2-8-x",
|
||||
"@polkadot/types-codec": "8.13.2-8-x",
|
||||
"@polkadot/types-create": "8.13.2-8-x",
|
||||
"@polkadot/util": "^10.0.2"
|
||||
"@polkadot/util": "^10.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,6 @@
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.9",
|
||||
"@polkadot/util": "^10.0.2"
|
||||
"@polkadot/util": "^10.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,16 +24,16 @@
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.9",
|
||||
"@polkadot/keyring": "^10.0.2",
|
||||
"@polkadot/keyring": "^10.1.1",
|
||||
"@polkadot/types-augment": "8.13.2-8-x",
|
||||
"@polkadot/types-codec": "8.13.2-8-x",
|
||||
"@polkadot/types-create": "8.13.2-8-x",
|
||||
"@polkadot/util": "^10.0.2",
|
||||
"@polkadot/util-crypto": "^10.0.2",
|
||||
"@polkadot/util": "^10.1.1",
|
||||
"@polkadot/util-crypto": "^10.1.1",
|
||||
"rxjs": "^7.5.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^10.0.2",
|
||||
"@polkadot/keyring": "^10.1.1",
|
||||
"@polkadot/types-support": "8.13.2-8-x"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user