Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change assetId type in SignerPayloadJSON to HexString #5967

Merged
merged 4 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/types/src/extrinsic/SignerPayload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('SignerPayload', (): void => {
const TEST = {
address: '5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFabHE',
// eslint-disable-next-line sort-keys
assetId: { parents: 0, interior: { x2: [{ palletInstance: 50 }, { generalIndex: 123 }] } },
assetId: '0x0002043205ed01',
blockHash: '0xde8f69eeb5e065e18c6950ff708d7e551f68dc9bf59a07c52367c0280f805ec7',
blockNumber: '0x00231d30',
era: '0x0703',
Expand Down Expand Up @@ -57,7 +57,7 @@ describe('SignerPayload', (): void => {
).toEqual({
address: '5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFabHE',
// eslint-disable-next-line sort-keys
assetId: { parents: 0, interior: { x2: [{ palletInstance: 50 }, { generalIndex: 123 }] } },
assetId: '0x0002043205ed01',
blockHash: '0xde8f69eeb5e065e18c6950ff708d7e551f68dc9bf59a07c52367c0280f805ec7',
blockNumber: '0x00231d30',
era: '0x0703',
Expand Down Expand Up @@ -88,12 +88,12 @@ describe('SignerPayload', (): void => {
expect(
test.toPayload().assetId
// eslint-disable-next-line sort-keys
).toEqual({ parents: 0, interior: { x2: [{ palletInstance: 50 }, { generalIndex: 123 }] } });
).toEqual('0x0002043205ed01');

expect(
new SignerPayload(registry, { assetId: 0 }).toPayload().assetId
// eslint-disable-next-line sort-keys
).toEqual({ parents: 0, interior: { here: null } });
).toEqual('0x0000');
});

it('re-constructs from JSON', (): void => {
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/extrinsic/SignerPayload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export class GenericSignerPayload extends Struct implements ISignerPayload, Sign
// the known defaults as managed explicitly and has different
// formatting in cases, e.g. we mostly expose a hex format here
address: this.address.toString(),
assetId: this.assetId ? this.assetId.toJSON() : null,
assetId: this.assetId && this.assetId.isSome ? this.assetId.unwrap().toHex() : null,
blockHash: this.blockHash.toHex(),
blockNumber: this.blockNumber.toHex(),
era: this.era.toHex(),
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/types/extrinsic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export interface SignerPayloadJSON {
/**
* @description The id of the asset used to pay fees, in hex
*/
assetId?: number | object;
assetId?: HexString;

/**
* @description The checkpoint hash of the block, in hex
Expand Down