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

39 lines (38 loc) 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.randomAddress = exports.ZERO_ADDRESS = exports.toAddress = void 0; const index_js_1 = require("./common/binary/index.js"); /** * @deprecated will be replaced in 0.11.0. * Please use `import { toEVMAddress } from "@rarible/types"` */ 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}`); } } exports.toAddress = toAddress; /** * @deprecated will be replaced in 0.11.0. * Please use `import { EVM_ZERO_ADDRESS } from "@rarible/types"` */ exports.ZERO_ADDRESS = toAddress("0x0000000000000000000000000000000000000000"); /** * @deprecated will be replaced in 0.11.0. * Please use `import { randomEVMAddress } from "@rarible/types"` */ function randomAddress() { return toAddress((0, index_js_1.randomBinary)(20)); } exports.randomAddress = randomAddress;