Skip to content

Commit

Permalink
Added test for decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
TarikGul committed Sep 24, 2024
1 parent 072f69a commit 4667ebd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/types/src/extrinsic/Extrinsic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,18 @@ describe('Extrinsic', (): void => {
expect(extrinsic.toPrimitive()).toEqual({ method: { args: { dest: { id: '5DiuK2zR4asj2CEh77SKtUgTswTLkD8eiAKrByg5G3wL5w9b' }, value: 104560923320000 }, callIndex: '0x0600' }, signature: { era: { mortalEra: [1024, 186] }, nonce: 68, signature: { ed25519: '0xd99ffe3e610ad234e1414bda5831395a6df9098bf80b01561ce89a5065ae89d5c10e1619c6c99131b0bea4fb73ef04d07c07770e2ae9df5c325c331769ccb300' }, signer: { id: '5Hn8KKEp8qruCGWaN9MEsjTs4FXB4wv9xn7g1RWkNeKKNXCr' }, tip: 30000000000 } });
});
});

describe('V5', () => {
it('Signed Extrinsic', () => {
registry.setSignedExtensions(fallbackExtensions);

const extrinsic = new Extrinsic(
registry,
'0x51028500d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d01fe54549be20bf992bc41433b698e2efd2196d54d1192ce851592369811c023079e6e1c334d546549e7cc0e71f5e3982a42ea832727ffdaca62af7f1a20fc428a00a500000000000603008eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a480b00a0724e1809',
{ preamble: 'signed', version: 5 }
);

expect(extrinsic.signer.toHuman()).toEqual('HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F');
});
});
});
4 changes: 4 additions & 0 deletions packages/types/src/extrinsic/Extrinsic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ function decodeU8a (registry: Registry, value: Uint8Array, version: number, prea

const data = value.subarray(offset, total);

if (version === 5) {
return newFromValue(registry, data.subarray(2), data[0], preamble);
}

return newFromValue(registry, data.subarray(1), data[0], preamble);
}

Expand Down

0 comments on commit 4667ebd

Please sign in to comment.