accountNextIndex on nonce = -1 (#2618)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user