UNPKG

@rarible/types

Version:

`@rarible/types` is a TypeScript library that provides type definitions and interfaces for the Rarible ecosystem. This package is designed to facilitate seamless integration with Rarible's APIs and services, ensuring type safety and improved developer exp

34 lines (33 loc) 914 B
import { randomBinary } from "./common/binary/index.js"; /** * @deprecated will be replaced in 0.11.0. * Please use `import { toEVMAddress } from "@rarible/types"` */ export function toAddress(value) { let hex; if (value.startsWith("0x")) { hex = value.substring(2).toLowerCase(); } else { hex = value.toLowerCase(); } const re = /[0-9a-f]{40}/g; if (re.test(hex)) { return `0x${hex}`; } else { throw new Error(`not an address: ${value}`); } } /** * @deprecated will be replaced in 0.11.0. * Please use `import { EVM_ZERO_ADDRESS } from "@rarible/types"` */ export const ZERO_ADDRESS = toAddress("0x0000000000000000000000000000000000000000"); /** * @deprecated will be replaced in 0.11.0. * Please use `import { randomEVMAddress } from "@rarible/types"` */ export function randomAddress() { return toAddress(randomBinary(20)); }