Skip to content

Commit

Permalink
choosing AccountId20 type if the address is 20 bytes (#5991)
Browse files Browse the repository at this point in the history
  • Loading branch information
piggydoughnut authored Oct 1, 2024
1 parent 87b4cec commit d3c16b5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/api-derive/src/accounts/accountId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/api-derive/src/accounts/idAndIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit d3c16b5

Please sign in to comment.