@unique-nft/utils
Version:
A tiny library to work with Substrate and Ethereum addresses and do some more
40 lines (38 loc) • 1.25 kB
text/typescript
type SubAddressObj = {
Substrate: string;
};
type SubAddressObjUncapitalized = {
substrate: string;
};
type EthAddressObj = {
Ethereum: string;
};
type EthAddressObjUncapitalized = {
ethereum: string;
};
type CrossAccountId = SubAddressObj & {
Ethereum?: never;
} | EthAddressObj & {
Substrate?: never;
};
type AddressType = 'Ethereum' | 'Substrate';
type EnhancedCrossAccountId = CrossAccountId & {
address: string;
addressSS58: string;
type: AddressType;
isEthereum: boolean;
isSubstrate: boolean;
substratePublicKey: string;
};
type CrossAccountIdUncapitalized = SubAddressObjUncapitalized & {
ethereum?: never;
} | EthAddressObjUncapitalized & {
substrate?: never;
};
type CrossAccountIdOrString = CrossAccountId | string;
type CrossAccountIdUncapitalizedOrString = CrossAccountIdUncapitalized | string;
type EthCrossAccountId = {
eth: string;
sub: string;
};
export type { AddressType as A, CrossAccountId as C, EthAddressObj as E, SubAddressObj as S, SubAddressObjUncapitalized as a, EthAddressObjUncapitalized as b, EnhancedCrossAccountId as c, CrossAccountIdUncapitalized as d, CrossAccountIdOrString as e, CrossAccountIdUncapitalizedOrString as f, EthCrossAccountId as g };