Files
pezkuwi-api/packages/bizinikiwi-bindings/dist/esm/codecs/scale/AccountId.mjs
T
pezkuwichain 31467f90d4 feat: add PAPI rebrand packages
- @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.
2026-01-22 15:40:12 +03:00

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