Add signedTransaction to SignerResult for injected Signers in signAndSend (#5914)

* Start work on payload feature

* Change naming and type

* Add validation and whitelisting

* Update comments

* Fix some properties and commetns

* Switch logic over to signedTransaction

* Add mode to output of extrinsic signature

* Add validation

* Update comments

* Update comments

* Reduce validation

* Update internal docs

* Make comments clearer

* comments

* one more inline doc :)

* Fix nasty little bug for signAsync, and when signedTransaction is not used

* remove uncessecary ?

* Add undefined typing
This commit is contained in:
Tarik Gul
2024-06-24 19:00:28 -04:00
committed by GitHub
parent 5ca873b501
commit 586f02f831
5 changed files with 85 additions and 8 deletions
@@ -206,6 +206,13 @@ abstract class ExtrinsicBase<A extends AnyTuple> extends AbstractBase<ExtrinsicV
return this.inner.signature.metadataHash;
}
/**
* @description Forward compat
*/
public get mode (): INumber {
return this.inner.signature.mode;
}
/**
* @description Returns the raw transaction version (not flagged with signing information)
*/
@@ -334,6 +341,7 @@ export class GenericExtrinsic<A extends AnyTuple = AnyTuple> extends ExtrinsicBa
assetId: this.assetId ? this.assetId.toHuman(isExpanded, disableAscii) : null,
era: this.era.toHuman(isExpanded, disableAscii),
metadataHash: this.metadataHash ? this.metadataHash.toHex() : null,
mode: this.mode.toHuman(),
nonce: this.nonce.toHuman(isExpanded, disableAscii),
signature: this.signature.toHex(),
signer: this.signer.toHuman(isExpanded, disableAscii),
@@ -126,6 +126,13 @@ export class GenericExtrinsicSignatureV4 extends Struct implements IExtrinsicSig
return this.getT('assetId');
}
/**
* @description the [[u32]] mode
*/
public get mode (): INumber {
return this.getT('mode');
}
/**
* @description The [[Hash]] for the metadata
*/
+10
View File
@@ -145,6 +145,16 @@ export interface SignerResult {
* @description The resulting signature in hex
*/
signature: HexString;
/**
* @description The payload constructed by the signer. This allows the
* inputted signed transaction to bypass `signAndSend` from adding the signature to the payload,
* and instead broadcasting the transaction directly. There is a small validation layer. Please refer
* to the implementation for more information. If the inputted signed transaction is not actually signed, it will fail with an error.
*
* NOTE: This is only implemented for `signPayload`.
*/
signedTransaction?: HexString | Uint8Array;
}
export interface Signer {