choosing AccountId20 type if the address is 20 bytes (#5991)

This commit is contained in:
Daria
2024-10-01 20:27:19 +08:00
committed by GitHub
parent 87b4cecc1b
commit d3c16b5cb4
2 changed files with 2 additions and 2 deletions
@@ -24,7 +24,7 @@ export function accountId (instanceId: string, api: DeriveApi): (address?: Addre
: decodeAddress((address || '').toString());
if (decoded.length > 8) {
return of(api.registry.createType('AccountId', decoded));
return of(api.registry.createType(decoded.length === 20 ? 'AccountId20' : 'AccountId', decoded));
}
const accountIndex = api.registry.createType('AccountIndex', decoded);
@@ -34,7 +34,7 @@ export function idAndIndex (instanceId: string, api: DeriveApi): (address?: Addr
: decodeAddress((address || '').toString());
if (decoded.length > 8) {
const accountId = api.registry.createType('AccountId', decoded);
const accountId = api.registry.createType(decoded.length === 20 ? 'AccountId20' : 'AccountId', decoded);
return api.derive.accounts.idToIndex(accountId).pipe(
map((accountIndex): AccountIdAndIndex => [accountId, accountIndex])