UNPKG

@unstoppabledomains/resolution

Version:
44 lines (43 loc) 2.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.hasProvider = exports.ZnsSupportedNetwork = exports.EnsSupportedNetwork = exports.UnsSupportedNetwork = exports.EthCoinIndex = exports.NullAddresses = exports.NullAddress = void 0; exports.NullAddress = '0x0000000000000000000000000000000000000000'; var NullAddresses; (function (NullAddresses) { NullAddresses[NullAddresses["0x"] = 0] = "0x"; NullAddresses[NullAddresses["0x0000000000000000000000000000000000000000"] = 1] = "0x0000000000000000000000000000000000000000"; NullAddresses[NullAddresses["0x0000000000000000000000000000000000000000000000000000000000000000"] = 2] = "0x0000000000000000000000000000000000000000000000000000000000000000"; })(NullAddresses = exports.NullAddresses || (exports.NullAddresses = {})); exports.EthCoinIndex = '60'; // TypeScript will infer a string union type from the literal values passed to // this function. Without `extends string`, it would instead generalize them // to the common string type. // @see https://stackoverflow.com/questions/36836011/checking-validity-of-string-literal-union-type-at-runtime var StringUnion = function () { var values = []; for (var _i = 0; _i < arguments.length; _i++) { values[_i] = arguments[_i]; } Object.freeze(values); var valueSet = new Set(values); var guard = function (value) { return valueSet.has(value); }; var check = function (value) { if (!guard(value)) { var actual = JSON.stringify(value); var expected = values.map(function (s) { return JSON.stringify(s); }).join(' | '); throw new TypeError("Value '".concat(actual, "' is not assignable to type '").concat(expected, "'.")); } return value; }; var unionNamespace = { guard: guard, check: check, values: values }; return Object.freeze(unionNamespace); }; exports.UnsSupportedNetwork = StringUnion('mainnet', 'sepolia', 'polygon-mainnet', 'polygon-amoy', 'base-mainnet', 'base-sepolia'); exports.EnsSupportedNetwork = StringUnion('mainnet', 'sepolia'); exports.ZnsSupportedNetwork = StringUnion('mainnet', 'testnet'); function hasProvider(obj) { return obj && !!obj.provider; } exports.hasProvider = hasProvider;