Skip to content

Commit

Permalink
update wellknown key (#525)
Browse files Browse the repository at this point in the history
  • Loading branch information
xlc authored Nov 8, 2023
1 parent c3c56ec commit 140c8ac
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/core/src/utils/well-known-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,18 @@ const wellKnownKeys = [
},
type: '(u32, u32)',
},
{
name: 'relay_dispatch_queue_size',
prefixHex: '0xf5207f03cfdce586301014700e2c2593fad157e461d71fd4c1f936839a5f1f3e',
decodeKey: (registry: Registry, key: HexString) => {
// get last 4 bytes
const last4Bytes = '0x' + key.slice(-8)
return [registry.createType('u32', hexToU8a(last4Bytes)).toJSON()]
},
type: '(u32, u32)',
},
].map((def) => {
const prefix = stringToHex(def.prefix || def.key)
const prefix = def.prefixHex ?? stringToHex(def.prefix || def.key)
return {
name: def.name,
prefix,
Expand Down
14 changes: 14 additions & 0 deletions packages/e2e/src/__snapshots__/decoder.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,20 @@ exports[`decoder > with acala > works with well known keys 4`] = `
}
`;

exports[`decoder > with acala > works with well known keys 5`] = `
{
"key": [
2000,
],
"method": "relay_dispatch_queue_size",
"section": "substrate",
"value": [
1,
67,
],
}
`;

exports[`decoder > works with multiple chains 1`] = `
{
"key": [
Expand Down
8 changes: 8 additions & 0 deletions packages/e2e/src/decoder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ describe('decoder', async () => {
).toMatchSnapshot()
expect(decodeKeyValue(meta, chain.head, '0x3a7472616e73616374696f6e5f6c6576656c3a')).toMatchSnapshot()
expect(decodeKeyValue(meta, chain.head, '0x3a65787472696e7369635f696e646578', '0x02000000')).toMatchSnapshot()
expect(
decodeKeyValue(
meta,
chain.head,
'0xf5207f03cfdce586301014700e2c2593fad157e461d71fd4c1f936839a5f1f3e63f5a4efb16ffa83d0070000',
'0x0100000043000000',
),
).toMatchSnapshot()
})
})

Expand Down

0 comments on commit 140c8ac

Please sign in to comment.