mirror of
https://github.com/pezkuwichain/pezkuwi-api.git
synced 2026-04-22 03:17:56 +00:00
31467f90d4
- @pezkuwi/papi-utils (rebrand of @polkadot-api/utils) - @pezkuwi/bizinikiwi-bindings (rebrand of @polkadot-api/substrate-bindings) - @pezkuwi/metadata-builders (rebrand of @polkadot-api/metadata-builders) - @pezkuwi/merkleize-metadata (rebrand of @polkadot-api/merkleize-metadata) All @polkadot-api references replaced with @pezkuwi equivalents.
22 lines
675 B
JavaScript
22 lines
675 B
JavaScript
import { enhanceCodec, Bytes } from 'scale-ts';
|
|
import { fromBufferToBase58, getSs58AddressInfo } from '../../utils/ss58-util.mjs';
|
|
|
|
function fromBase58ToBuffer(nBytes, _ss58Format) {
|
|
return (address) => {
|
|
const info = getSs58AddressInfo(address);
|
|
if (!info.isValid) throw new Error("Invalid checksum");
|
|
const { publicKey } = info;
|
|
if (publicKey.length !== nBytes)
|
|
throw new Error("Invalid public key length");
|
|
return publicKey;
|
|
};
|
|
}
|
|
const AccountId = (ss58Format = 42, nBytes = 32) => enhanceCodec(
|
|
Bytes(nBytes),
|
|
fromBase58ToBuffer(nBytes),
|
|
fromBufferToBase58(ss58Format)
|
|
);
|
|
|
|
export { AccountId };
|
|
//# sourceMappingURL=AccountId.mjs.map
|