Switch mortal default to 5mins (defaults) (#1112)
* Switch mortal default to 5mins (defaults) * Expose era on raw payload
This commit is contained in:
@@ -44,7 +44,7 @@ function sign (signerPair: IKeyringPair, u8a: Uint8Array): Uint8Array {
|
||||
export default class SignaturePayload extends Struct {
|
||||
protected _signature?: Uint8Array;
|
||||
|
||||
constructor (value?: SignaturePayloadValue | Uint8Array) {
|
||||
public constructor (value?: SignaturePayloadValue | Uint8Array) {
|
||||
super({
|
||||
nonce: Nonce,
|
||||
method: Method,
|
||||
@@ -56,42 +56,42 @@ export default class SignaturePayload extends Struct {
|
||||
/**
|
||||
* @description `true` if the payload refers to a valid signature
|
||||
*/
|
||||
get isSigned (): boolean {
|
||||
public get isSigned (): boolean {
|
||||
return !!(this._signature && this._signature.length === 64);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The block [[Hash]] the signature applies to (mortal/immortal)
|
||||
*/
|
||||
get blockHash (): Hash {
|
||||
public get blockHash (): Hash {
|
||||
return this.get('blockHash') as Hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Method]] contained in the payload
|
||||
*/
|
||||
get method (): Method {
|
||||
public get method (): Method {
|
||||
return this.get('method') as Method;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[ExtrinsicEra]]
|
||||
*/
|
||||
get era (): ExtrinsicEra {
|
||||
public get era (): ExtrinsicEra {
|
||||
return this.get('era') as ExtrinsicEra;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Nonce]]
|
||||
*/
|
||||
get nonce (): Nonce {
|
||||
public get nonce (): Nonce {
|
||||
return this.get('nonce') as Nonce;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The raw signature as a `Uint8Array`
|
||||
*/
|
||||
get signature (): Uint8Array {
|
||||
public get signature (): Uint8Array {
|
||||
if (!this.isSigned) {
|
||||
throw new Error('Transaction is not signed');
|
||||
}
|
||||
@@ -102,7 +102,7 @@ export default class SignaturePayload extends Struct {
|
||||
/**
|
||||
* @description Sign the payload with the keypair
|
||||
*/
|
||||
sign (signerPair: IKeyringPair, version?: RuntimeVersion): Uint8Array {
|
||||
public sign (signerPair: IKeyringPair, version?: RuntimeVersion): Uint8Array {
|
||||
this._signature = sign(signerPair, this.toU8a());
|
||||
|
||||
return this._signature;
|
||||
@@ -115,7 +115,7 @@ export default class SignaturePayload extends Struct {
|
||||
* A version of [[SignaturePayload]] where it does not rely on [[Method]] being initalized with metadata. When constructing, it treats the [[Method]] as a raw stream of bytes, so will always apply the signature over this without any additional checking. Unlike the [[SignaturePayload]], it assumed that you will only construct and sign, thereby providing no insigt into constructed values
|
||||
*/
|
||||
export class SignaturePayloadRaw extends Struct {
|
||||
constructor (value?: any) {
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
nonce: Nonce,
|
||||
method: U8a,
|
||||
@@ -124,10 +124,17 @@ export class SignaturePayloadRaw extends Struct {
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[ExtrinsicEra]]
|
||||
*/
|
||||
public get era (): ExtrinsicEra {
|
||||
return this.get('era') as ExtrinsicEra;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Sign the payload with the keypair
|
||||
*/
|
||||
sign (signerPair: IKeyringPair): Uint8Array {
|
||||
public sign (signerPair: IKeyringPair): Uint8Array {
|
||||
return sign(signerPair, this.toU8a());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user