accountNextIndex on nonce = -1 (#2618)

This commit is contained in:
Jaco Greeff
2020-09-17 14:54:06 +02:00
committed by GitHub
parent 6c00a5a408
commit 4596e434dd
3 changed files with 11 additions and 2 deletions
+9 -1
View File
@@ -24,6 +24,12 @@ function latestNonce (api: ApiInterfaceRx, address: string): Observable<Index> {
);
}
function nextNonce (api: ApiInterfaceRx, address: string): Observable<Index> {
return api.rpc.system?.accountNextIndex
? api.rpc.system.accountNextIndex(address)
: latestNonce(api, address);
}
function signingHeader (api: ApiInterfaceRx): Observable<Header> {
return combineLatest([
api.rpc.chain.getHeader(),
@@ -47,7 +53,9 @@ export function signingInfo (_instanceId: string, api: ApiInterfaceRx): (address
// retrieve nonce if none was specified
isUndefined(nonce)
? latestNonce(api, address)
: of(api.registry.createType('Index', nonce)),
: nonce === -1
? nextNonce(api, address)
: of(api.registry.createType('Index', nonce)),
// if no era (create) or era > 0 (mortal), do block retrieval
(isUndefined(era) || (isNumber(era) && era > 0))
? signingHeader(api)