Change assetId type in SignerPayloadJSON to HexString (#5967)
* Change assetId type in SignerPayloadJSON to HexString * fix encoding * Fix tests * also fix createClass
This commit is contained in:
@@ -348,7 +348,7 @@ export function createClass <ApiType extends ApiTypes> ({ api, apiType, blockHas
|
|||||||
const ext = this.registry.createTypeUnsafe<Extrinsic>('Extrinsic', [result.signedTransaction]);
|
const ext = this.registry.createTypeUnsafe<Extrinsic>('Extrinsic', [result.signedTransaction]);
|
||||||
const newSignerPayload = this.registry.createTypeUnsafe<SignerPayload>('SignerPayload', [objectSpread({}, {
|
const newSignerPayload = this.registry.createTypeUnsafe<SignerPayload>('SignerPayload', [objectSpread({}, {
|
||||||
address,
|
address,
|
||||||
assetId: ext.assetId ? ext.assetId.toHex() : null,
|
assetId: ext.assetId && ext.assetId.isSome ? ext.assetId.unwrap().toHex() : null,
|
||||||
blockHash: payload.blockHash,
|
blockHash: payload.blockHash,
|
||||||
blockNumber: header ? header.number : 0,
|
blockNumber: header ? header.number : 0,
|
||||||
era: ext.era.toHex(),
|
era: ext.era.toHex(),
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ describe('SignerPayload', (): void => {
|
|||||||
const TEST = {
|
const TEST = {
|
||||||
address: '5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFabHE',
|
address: '5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFabHE',
|
||||||
// eslint-disable-next-line sort-keys
|
// eslint-disable-next-line sort-keys
|
||||||
assetId: { parents: 0, interior: { x2: [{ palletInstance: 50 }, { generalIndex: 123 }] } },
|
assetId: '0x0002043205ed01',
|
||||||
blockHash: '0xde8f69eeb5e065e18c6950ff708d7e551f68dc9bf59a07c52367c0280f805ec7',
|
blockHash: '0xde8f69eeb5e065e18c6950ff708d7e551f68dc9bf59a07c52367c0280f805ec7',
|
||||||
blockNumber: '0x00231d30',
|
blockNumber: '0x00231d30',
|
||||||
era: '0x0703',
|
era: '0x0703',
|
||||||
@@ -57,7 +57,7 @@ describe('SignerPayload', (): void => {
|
|||||||
).toEqual({
|
).toEqual({
|
||||||
address: '5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFabHE',
|
address: '5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFabHE',
|
||||||
// eslint-disable-next-line sort-keys
|
// eslint-disable-next-line sort-keys
|
||||||
assetId: { parents: 0, interior: { x2: [{ palletInstance: 50 }, { generalIndex: 123 }] } },
|
assetId: '0x0002043205ed01',
|
||||||
blockHash: '0xde8f69eeb5e065e18c6950ff708d7e551f68dc9bf59a07c52367c0280f805ec7',
|
blockHash: '0xde8f69eeb5e065e18c6950ff708d7e551f68dc9bf59a07c52367c0280f805ec7',
|
||||||
blockNumber: '0x00231d30',
|
blockNumber: '0x00231d30',
|
||||||
era: '0x0703',
|
era: '0x0703',
|
||||||
@@ -88,12 +88,12 @@ describe('SignerPayload', (): void => {
|
|||||||
expect(
|
expect(
|
||||||
test.toPayload().assetId
|
test.toPayload().assetId
|
||||||
// eslint-disable-next-line sort-keys
|
// eslint-disable-next-line sort-keys
|
||||||
).toEqual({ parents: 0, interior: { x2: [{ palletInstance: 50 }, { generalIndex: 123 }] } });
|
).toEqual('0x0002043205ed01');
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
new SignerPayload(registry, { assetId: 0 }).toPayload().assetId
|
new SignerPayload(registry, { assetId: 0 }).toPayload().assetId
|
||||||
// eslint-disable-next-line sort-keys
|
// eslint-disable-next-line sort-keys
|
||||||
).toEqual({ parents: 0, interior: { here: null } });
|
).toEqual('0x0000');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('re-constructs from JSON', (): void => {
|
it('re-constructs from JSON', (): void => {
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ export class GenericSignerPayload extends Struct implements ISignerPayload, Sign
|
|||||||
// the known defaults as managed explicitly and has different
|
// the known defaults as managed explicitly and has different
|
||||||
// formatting in cases, e.g. we mostly expose a hex format here
|
// formatting in cases, e.g. we mostly expose a hex format here
|
||||||
address: this.address.toString(),
|
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(),
|
blockHash: this.blockHash.toHex(),
|
||||||
blockNumber: this.blockNumber.toHex(),
|
blockNumber: this.blockNumber.toHex(),
|
||||||
era: this.era.toHex(),
|
era: this.era.toHex(),
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export interface SignerPayloadJSON {
|
|||||||
/**
|
/**
|
||||||
* @description The id of the asset used to pay fees, in hex
|
* @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
|
* @description The checkpoint hash of the block, in hex
|
||||||
|
|||||||
Reference in New Issue
Block a user