Allow as-signed paymentInfo on any extrinsic (#2593)

* Allow as-signed paymentInfo on any extrinsic

* Bumps
This commit is contained in:
Jaco Greeff
2020-09-09 10:43:59 +02:00
committed by GitHub
parent d0bf8b8d82
commit 0a8d2e5ac1
11 changed files with 112 additions and 109 deletions
+1 -1
View File
@@ -32,6 +32,6 @@
"@polkadot/types": "1.33.0-beta.0",
"@polkadot/util": "^3.4.1",
"bn.js": "^5.1.3",
"rxjs": "^6.6.2"
"rxjs": "^6.6.3"
}
}
+1 -1
View File
@@ -36,7 +36,7 @@
"@polkadot/util-crypto": "^3.4.1",
"bn.js": "^5.1.3",
"memoizee": "^0.4.14",
"rxjs": "^6.6.2"
"rxjs": "^6.6.3"
},
"devDependencies": {
"@polkadot/keyring": "^3.4.1"
+1 -1
View File
@@ -38,7 +38,7 @@
"@polkadot/util-crypto": "^3.4.1",
"bn.js": "^5.1.3",
"eventemitter3": "^4.0.7",
"rxjs": "^6.6.2"
"rxjs": "^6.6.3"
},
"devDependencies": {
"@polkadot/keyring": "^3.4.1"
+13 -11
View File
@@ -44,19 +44,21 @@ export default function createClass <ApiType extends ApiTypes> ({ api, apiType,
// eslint-disable-next-line @typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-call
return decorateMethod(
(): Observable<RuntimeDispatchInfo> =>
api.derive.tx.signingInfo(address, allOptions.nonce, allOptions.era).pipe(
first(),
switchMap((signingInfo): Observable<RuntimeDispatchInfo> => {
// setup our options (same way as in signAndSend)
const eraOptions = this.#makeEraOptions(allOptions, signingInfo);
const signOptions = this.#makeSignOptions(eraOptions, {});
this.isSigned
? api.rpc.payment.queryInfo(this.toHex(), options?.blockHash)
: api.derive.tx.signingInfo(address, allOptions.nonce, allOptions.era).pipe(
first(),
switchMap((signingInfo): Observable<RuntimeDispatchInfo> => {
// setup our options (same way as in signAndSend)
const eraOptions = this.#makeEraOptions(allOptions, signingInfo);
const signOptions = this.#makeSignOptions(eraOptions, {});
// add a fake signature to the extrinsic
this.signFake(address, signOptions);
// add a fake signature to the extrinsic
this.signFake(address, signOptions);
return api.rpc.payment.queryInfo(this.toHex());
})
)
return api.rpc.payment.queryInfo(this.toHex());
})
)
)();
}
+2 -2
View File
@@ -3,7 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, Address, Extrinsic, ExtrinsicStatus, EventRecord, Hash, RuntimeDispatchInfo } from '@polkadot/types/interfaces';
import { AnyNumber, AnyU8a, Callback, Codec, IExtrinsicEra, IKeyringPair, Signer, ISubmittableResult } from '@polkadot/types/types';
import { AnyNumber, Callback, Codec, IExtrinsicEra, IKeyringPair, Signer, ISubmittableResult } from '@polkadot/types/types';
import { ApiTypes } from '../types';
import { Observable } from 'rxjs';
@@ -34,7 +34,7 @@ export type SubmittableThis<ApiType extends ApiTypes, THIS> =
: Promise<THIS>;
export interface SignerOptions {
blockHash: AnyU8a;
blockHash: Uint8Array | string;
era?: IExtrinsicEra | number;
nonce: AnyNumber | Codec;
signer?: Signer;
+1 -1
View File
@@ -32,7 +32,7 @@
"@polkadot/types": "1.33.0-beta.0",
"@polkadot/util": "^3.4.1",
"memoizee": "^0.4.14",
"rxjs": "^6.6.2"
"rxjs": "^6.6.3"
},
"devDependencies": {
"@polkadot/keyring": "^3.4.1"
+1 -1
View File
@@ -33,7 +33,7 @@
"@types/bn.js": "^4.11.6",
"bn.js": "^5.1.3",
"memoizee": "^0.4.14",
"rxjs": "^6.6.2"
"rxjs": "^6.6.3"
},
"devDependencies": {
"@polkadot/keyring": "^3.4.1",
+2 -2
View File
@@ -150,9 +150,9 @@ export interface IExtrinsicEra extends Codec {
}
export interface SignatureOptions {
blockHash: AnyU8a;
blockHash: Uint8Array | string;
era?: IExtrinsicEra;
genesisHash: AnyU8a;
genesisHash: Uint8Array | string;
nonce: AnyNumber;
runtimeVersion: IRuntimeVersion;
signedExtensions?: string[];