Converts payloads to use BlockHash types (#5358)
This commit is contained in:
@@ -3,11 +3,11 @@
|
||||
|
||||
import type { AnyJson, BareOpts, Registry } from '@polkadot/types-codec/types';
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { BlockHash } from '../interfaces/chain';
|
||||
import type { ExtrinsicPayloadV4 } from '../interfaces/extrinsics';
|
||||
import type { Hash } from '../interfaces/runtime';
|
||||
import type { ExtrinsicPayloadValue, ICompact, IKeyringPair, INumber } from '../types';
|
||||
|
||||
import { AbstractBase, Raw } from '@polkadot/types-codec';
|
||||
import { AbstractBase, Bytes } from '@polkadot/types-codec';
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { DEFAULT_VERSION } from './constants';
|
||||
@@ -49,9 +49,9 @@ export class GenericExtrinsicPayload extends AbstractBase<ExtrinsicPayloadVx> {
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The block [[Hash]] the signature applies to (mortal/immortal)
|
||||
* @description The block [[BlockHash]] the signature applies to (mortal/immortal)
|
||||
*/
|
||||
public get blockHash (): Hash {
|
||||
public get blockHash (): BlockHash {
|
||||
return this.inner.blockHash;
|
||||
}
|
||||
|
||||
@@ -63,17 +63,17 @@ export class GenericExtrinsicPayload extends AbstractBase<ExtrinsicPayloadVx> {
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The genesis block [[Hash]] the signature applies to
|
||||
* @description The genesis block [[BlockHash]] the signature applies to
|
||||
*/
|
||||
public get genesisHash (): Hash {
|
||||
public get genesisHash (): BlockHash {
|
||||
// NOTE only v3+
|
||||
return this.inner.genesisHash || this.registry.createTypeUnsafe('Hash', []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Raw]] contained in the payload
|
||||
* @description The [[Bytes]] contained in the payload
|
||||
*/
|
||||
public get method (): Raw {
|
||||
public get method (): Bytes {
|
||||
return this.inner.method;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import type { Registry } from '@polkadot/types-codec/types';
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { Address, Call, ExtrinsicEra, Hash } from '../interfaces';
|
||||
import type { Address, BlockHash, Call, ExtrinsicEra, Hash } from '../interfaces';
|
||||
import type { Codec, ICompact, INumber, IRuntimeVersion, ISignerPayload, SignerPayloadJSON, SignerPayloadRaw } from '../types';
|
||||
|
||||
import { Option, Struct, Text, Vec } from '@polkadot/types-codec';
|
||||
@@ -67,7 +67,7 @@ export class GenericSignerPayload extends Struct implements ISignerPayload, Sign
|
||||
return this.getT('address');
|
||||
}
|
||||
|
||||
get blockHash (): Hash {
|
||||
get blockHash (): BlockHash {
|
||||
return this.getT('blockHash');
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ export class GenericSignerPayload extends Struct implements ISignerPayload, Sign
|
||||
return this.getT('era');
|
||||
}
|
||||
|
||||
get genesisHash (): Hash {
|
||||
get genesisHash (): BlockHash {
|
||||
return this.getT('genesisHash');
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
import type { SignOptions } from '@polkadot/keyring/types';
|
||||
import type { Inspect, Registry } from '@polkadot/types-codec/types';
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { BlockHash } from '../../interfaces/chain';
|
||||
import type { ExtrinsicEra } from '../../interfaces/extrinsics';
|
||||
import type { Hash } from '../../interfaces/runtime';
|
||||
import type { ExtrinsicPayloadValue, ICompact, IKeyringPair, INumber, IOption } from '../../types';
|
||||
|
||||
import { Bytes, Enum, Struct } from '@polkadot/types-codec';
|
||||
@@ -45,9 +45,9 @@ export class GenericExtrinsicPayloadV4 extends Struct {
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The block [[Hash]] the signature applies to (mortal/immortal)
|
||||
* @description The block [[BlockHash]] the signature applies to (mortal/immortal)
|
||||
*/
|
||||
public get blockHash (): Hash {
|
||||
public get blockHash (): BlockHash {
|
||||
return this.getT('blockHash');
|
||||
}
|
||||
|
||||
@@ -59,9 +59,9 @@ export class GenericExtrinsicPayloadV4 extends Struct {
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The genesis [[Hash]] the signature applies to (mortal/immortal)
|
||||
* @description The genesis [[BlockHash]] the signature applies to (mortal/immortal)
|
||||
*/
|
||||
public get genesisHash (): Hash {
|
||||
public get genesisHash (): BlockHash {
|
||||
return this.getT('genesisHash');
|
||||
}
|
||||
|
||||
@@ -101,8 +101,7 @@ export class GenericExtrinsicPayloadV4 extends Struct {
|
||||
}
|
||||
|
||||
/**
|
||||
* @description
|
||||
* The (optional) asset id for this signature for chains that support transaction fees in assets
|
||||
* @description The (optional) asset id for this signature for chains that support transaction fees in assets
|
||||
*/
|
||||
public get assetId (): IOption<INumber> {
|
||||
return this.getT('assetId');
|
||||
@@ -116,7 +115,7 @@ export class GenericExtrinsicPayloadV4 extends Struct {
|
||||
// don't want the method (Bytes) to have the length prefix included. This
|
||||
// means that the data-as-signed is un-decodable, but is also doesn't need
|
||||
// the extra information, only the pure data (and is not decoded) ...
|
||||
// The same applies to V1..V3, if we have a V5, carrythis comment
|
||||
// The same applies to V1..V3, if we have a V5, carry this comment
|
||||
return sign(this.registry, signerPair, this.toU8a({ method: true }), this.#signOptions);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user