UNPKG

@syncswap/sdk

Version:

SyncSwap TypeScript SDK for building DeFi applications

40 lines 1.13 kB
/** * A library class for address */ export class Address { static nullAddress() { return this.NULL_ADDRESS; } static isNullAddress(address) { return address === this.nullAddress(); } static isAddress(s) { return (s !== null && s !== undefined && s !== "" && s.length == 42 && s.startsWith("0x")); } static isAddressValid(address) { return this.isAddress(address) && !this.isNullAddress(address); } static isValidAddressFormat(s) { return (s !== null && s !== undefined && s !== "" && s !== this.NULL_ADDRESS && (typeof s === "string" || s instanceof String) && s.length == 42 && s.startsWith("0x")); } static normalizeAddress(address) { if (this.isAddress(address)) { return address.toLowerCase(); } else { throw new Error(`Invalid address: ${address}`); } } } Address.NULL_ADDRESS = "0x0000000000000000000000000000000000000000"; //# sourceMappingURL=address.js.map