SignedExtension injection into payload (#1778)

* Make a start ... V11 definitions

* V11 conversion

* Fix ErrorMetadataV11

* Extension point for signed extensions

* Add V11 to mapped

* Expand toLatest comments

* Make a start at signer extension defs

* exports

* Extract extension definitions

* Add extension registration

* Remove old override

* Get definition on extrinsic creation

* Add missing V4 base

* Optional extrinsic

* Pull extrinsic version from metadata (if available)

* asLatest.extrinsic should now be available

* Don't export non-types for Extrinsic

* Setup registry with default extensions

* Async test really runs async

* Trace test failures (V1 orig, V4 now)

* CHANGELOG

* Add extension data to actual signature

* Cleanups

* Return cleanups

* Mark all type deocde static internal

* Apply extensions fully to payload

* Cleanup duplication

* ExtrinsicSignature* via createType
This commit is contained in:
Jaco Greeff
2020-02-01 14:17:17 +01:00
committed by GitHub
parent 5f8c623179
commit b24a1ff350
59 changed files with 359 additions and 153 deletions
+4 -1
View File
@@ -128,9 +128,12 @@ export default abstract class Init<ApiType extends ApiTypes> extends Decorate<Ap
this.registerTypes(getMetadataTypes(metadata.version));
const decoratedMeta = new DecoratedMeta(this.registry, metadata);
const metaExtrinsic = metadata.asLatest.extrinsic;
// only inject if we are not a clone (global init)
if (!this._options.source) {
if (metaExtrinsic.version.gtn(0)) {
this._extrinsicType = metaExtrinsic.version.toNumber();
} else if (!this._options.source) {
// detect the extrinsic version in-use based on the last block
const { block: { extrinsics: [firstTx] } }: SignedBlock = await this._rpcCore.chain.getBlock().toPromise();
+5 -2
View File
@@ -122,10 +122,13 @@ describe('ApiPromise', (): void => {
const api = await ApiPromise.create({ provider, registry, signer });
const transfer = api.tx.balances.transfer(keyring.getPair('0xe659a7a1628cdd93febc04a4e0646ea20e9f5f0ce097d9a05290d4a9e054df4e').address, 12345);
await transfer.signAsync(aliceEd, {});
await transfer.signAsync(aliceEd.address, {});
expect(transfer.signature.toHex()).toEqual(
'0x6b9ccc95afbd4e916d30c65c720f4f7b70a77db545735b48a763844aa5210e695aa346686bad1224af77d00bcfbf6fc8d2c216a60731027835d5a414186a2607'
// v1 extrinsic
// '0x6b9ccc95afbd4e916d30c65c720f4f7b70a77db545735b48a763844aa5210e695aa346686bad1224af77d00bcfbf6fc8d2c216a60731027835d5a414186a2607'
// v4 extrinsic
'0x0716cbdc3b649dad8741238bcc8e4336f859c518cf2b17a3427b2f5d0b8a79cf518da71b9ac71d92c517342e0978f297f5e05362babf5987d3f1c5ba3314af08'
);
});
});