@metamask-previews/name-controller 9.1.2-preview-064aea96d → 9.1.2-preview-ec4680201
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/NameController-method-action-types.cjs.map +1 -1
- package/dist/NameController-method-action-types.d.cts.map +1 -1
- package/dist/NameController-method-action-types.d.mts.map +1 -1
- package/dist/NameController-method-action-types.mjs.map +1 -1
- package/dist/NameController.cjs +7 -7
- package/dist/NameController.cjs.map +1 -1
- package/dist/NameController.d.cts.map +1 -1
- package/dist/NameController.d.mts.map +1 -1
- package/dist/NameController.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/providers/ens.cjs +4 -4
- package/dist/providers/ens.cjs.map +1 -1
- package/dist/providers/ens.d.cts.map +1 -1
- package/dist/providers/ens.d.mts.map +1 -1
- package/dist/providers/ens.mjs.map +1 -1
- package/dist/providers/etherscan.cjs +9 -9
- package/dist/providers/etherscan.cjs.map +1 -1
- package/dist/providers/etherscan.d.cts.map +1 -1
- package/dist/providers/etherscan.d.mts.map +1 -1
- package/dist/providers/etherscan.mjs.map +1 -1
- package/dist/providers/lens.cjs +6 -6
- package/dist/providers/lens.cjs.map +1 -1
- package/dist/providers/lens.d.cts.map +1 -1
- package/dist/providers/lens.d.mts.map +1 -1
- package/dist/providers/lens.mjs.map +1 -1
- package/dist/providers/token.cjs +6 -6
- package/dist/providers/token.cjs.map +1 -1
- package/dist/providers/token.d.cts.map +1 -1
- package/dist/providers/token.d.mts.map +1 -1
- package/dist/providers/token.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NameController-method-action-types.cjs","sourceRoot":"","sources":["../src/NameController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { NameController } from './NameController';\n\n/**\n * Set the user specified name for a value.\n *\n * @param request - Request object.\n * @param request.name - Name to set.\n * @param request.sourceId - Optional ID of the source of the proposed name.\n * @param request.type - Type of value to set the name for.\n * @param request.value - Value to set the name for.\n * @param request.variation - Variation of the raw value to set the name for. The chain ID if the type is Ethereum address.\n */\nexport type NameControllerSetNameAction = {\n type: `NameController:setName`;\n handler: NameController['setName'];\n};\n\n/**\n * Generate the proposed names for a value using the name providers and store them in the state.\n *\n * @param request - Request object.\n * @param request.value - Value to update the proposed names for.\n * @param request.type - Type of value to update the proposed names for.\n * @param request.sourceIds - Optional array of source IDs to limit which sources are used by the providers. If not provided, all sources in all providers will be used.\n * @param request.variation - Variation of the raw value to update proposed names for. The chain ID if the type is Ethereum address.\n * @returns The updated proposed names for the value.\n */\nexport type NameControllerUpdateProposedNamesAction = {\n type: `NameController:updateProposedNames`;\n handler: NameController['updateProposedNames'];\n};\n\n/**\n * Union of all NameController action types.\n */\nexport type NameControllerMethodActions =\n | NameControllerSetNameAction\n | NameControllerUpdateProposedNamesAction;\n"]}
|
|
1
|
+
{"version":3,"file":"NameController-method-action-types.cjs","sourceRoot":"","sources":["../src/NameController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { NameController } from './NameController.js';\n\n/**\n * Set the user specified name for a value.\n *\n * @param request - Request object.\n * @param request.name - Name to set.\n * @param request.sourceId - Optional ID of the source of the proposed name.\n * @param request.type - Type of value to set the name for.\n * @param request.value - Value to set the name for.\n * @param request.variation - Variation of the raw value to set the name for. The chain ID if the type is Ethereum address.\n */\nexport type NameControllerSetNameAction = {\n type: `NameController:setName`;\n handler: NameController['setName'];\n};\n\n/**\n * Generate the proposed names for a value using the name providers and store them in the state.\n *\n * @param request - Request object.\n * @param request.value - Value to update the proposed names for.\n * @param request.type - Type of value to update the proposed names for.\n * @param request.sourceIds - Optional array of source IDs to limit which sources are used by the providers. If not provided, all sources in all providers will be used.\n * @param request.variation - Variation of the raw value to update proposed names for. The chain ID if the type is Ethereum address.\n * @returns The updated proposed names for the value.\n */\nexport type NameControllerUpdateProposedNamesAction = {\n type: `NameController:updateProposedNames`;\n handler: NameController['updateProposedNames'];\n};\n\n/**\n * Union of all NameController action types.\n */\nexport type NameControllerMethodActions =\n | NameControllerSetNameAction\n | NameControllerUpdateProposedNamesAction;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NameController-method-action-types.d.cts","sourceRoot":"","sources":["../src/NameController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"NameController-method-action-types.d.cts","sourceRoot":"","sources":["../src/NameController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,6BAA4B;AAE1D;;;;;;;;;GASG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;CACpC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,cAAc,CAAC,qBAAqB,CAAC,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,2BAA2B,GACnC,2BAA2B,GAC3B,uCAAuC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NameController-method-action-types.d.mts","sourceRoot":"","sources":["../src/NameController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"NameController-method-action-types.d.mts","sourceRoot":"","sources":["../src/NameController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,6BAA4B;AAE1D;;;;;;;;;GASG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;CACpC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,cAAc,CAAC,qBAAqB,CAAC,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,2BAA2B,GACnC,2BAA2B,GAC3B,uCAAuC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NameController-method-action-types.mjs","sourceRoot":"","sources":["../src/NameController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { NameController } from './NameController';\n\n/**\n * Set the user specified name for a value.\n *\n * @param request - Request object.\n * @param request.name - Name to set.\n * @param request.sourceId - Optional ID of the source of the proposed name.\n * @param request.type - Type of value to set the name for.\n * @param request.value - Value to set the name for.\n * @param request.variation - Variation of the raw value to set the name for. The chain ID if the type is Ethereum address.\n */\nexport type NameControllerSetNameAction = {\n type: `NameController:setName`;\n handler: NameController['setName'];\n};\n\n/**\n * Generate the proposed names for a value using the name providers and store them in the state.\n *\n * @param request - Request object.\n * @param request.value - Value to update the proposed names for.\n * @param request.type - Type of value to update the proposed names for.\n * @param request.sourceIds - Optional array of source IDs to limit which sources are used by the providers. If not provided, all sources in all providers will be used.\n * @param request.variation - Variation of the raw value to update proposed names for. The chain ID if the type is Ethereum address.\n * @returns The updated proposed names for the value.\n */\nexport type NameControllerUpdateProposedNamesAction = {\n type: `NameController:updateProposedNames`;\n handler: NameController['updateProposedNames'];\n};\n\n/**\n * Union of all NameController action types.\n */\nexport type NameControllerMethodActions =\n | NameControllerSetNameAction\n | NameControllerUpdateProposedNamesAction;\n"]}
|
|
1
|
+
{"version":3,"file":"NameController-method-action-types.mjs","sourceRoot":"","sources":["../src/NameController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { NameController } from './NameController.js';\n\n/**\n * Set the user specified name for a value.\n *\n * @param request - Request object.\n * @param request.name - Name to set.\n * @param request.sourceId - Optional ID of the source of the proposed name.\n * @param request.type - Type of value to set the name for.\n * @param request.value - Value to set the name for.\n * @param request.variation - Variation of the raw value to set the name for. The chain ID if the type is Ethereum address.\n */\nexport type NameControllerSetNameAction = {\n type: `NameController:setName`;\n handler: NameController['setName'];\n};\n\n/**\n * Generate the proposed names for a value using the name providers and store them in the state.\n *\n * @param request - Request object.\n * @param request.value - Value to update the proposed names for.\n * @param request.type - Type of value to update the proposed names for.\n * @param request.sourceIds - Optional array of source IDs to limit which sources are used by the providers. If not provided, all sources in all providers will be used.\n * @param request.variation - Variation of the raw value to update proposed names for. The chain ID if the type is Ethereum address.\n * @returns The updated proposed names for the value.\n */\nexport type NameControllerUpdateProposedNamesAction = {\n type: `NameController:updateProposedNames`;\n handler: NameController['updateProposedNames'];\n};\n\n/**\n * Union of all NameController action types.\n */\nexport type NameControllerMethodActions =\n | NameControllerSetNameAction\n | NameControllerUpdateProposedNamesAction;\n"]}
|
package/dist/NameController.cjs
CHANGED
|
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.NameController = exports.NameOrigin = exports.PROPOSED_NAME_EXPIRE_DURATION = exports.FALLBACK_VARIATION = void 0;
|
|
16
16
|
const base_controller_1 = require("@metamask/base-controller");
|
|
17
17
|
const controller_utils_1 = require("@metamask/controller-utils");
|
|
18
|
-
const
|
|
18
|
+
const types_js_1 = require("./types.cjs");
|
|
19
19
|
exports.FALLBACK_VARIATION = '*';
|
|
20
20
|
exports.PROPOSED_NAME_EXPIRE_DURATION = 60 * 60 * 24; // 24 hours
|
|
21
21
|
/**
|
|
@@ -52,7 +52,7 @@ const stateMetadata = {
|
|
|
52
52
|
};
|
|
53
53
|
const getDefaultState = () => ({
|
|
54
54
|
names: {
|
|
55
|
-
[
|
|
55
|
+
[types_js_1.NameType.ETHEREUM_ADDRESS]: {},
|
|
56
56
|
},
|
|
57
57
|
nameSources: {},
|
|
58
58
|
});
|
|
@@ -244,7 +244,7 @@ _NameController_providers = new WeakMap(), _NameController_updateDelay = new Wea
|
|
|
244
244
|
}, _NameController_normalizeValue = function _NameController_normalizeValue(value, type) {
|
|
245
245
|
/* istanbul ignore next */
|
|
246
246
|
switch (type) {
|
|
247
|
-
case
|
|
247
|
+
case types_js_1.NameType.ETHEREUM_ADDRESS:
|
|
248
248
|
return value.toLowerCase();
|
|
249
249
|
default:
|
|
250
250
|
return value;
|
|
@@ -252,7 +252,7 @@ _NameController_providers = new WeakMap(), _NameController_updateDelay = new Wea
|
|
|
252
252
|
}, _NameController_normalizeVariation = function _NameController_normalizeVariation(variation, type) {
|
|
253
253
|
/* istanbul ignore next */
|
|
254
254
|
switch (type) {
|
|
255
|
-
case
|
|
255
|
+
case types_js_1.NameType.ETHEREUM_ADDRESS:
|
|
256
256
|
return variation.toLowerCase();
|
|
257
257
|
default:
|
|
258
258
|
return variation;
|
|
@@ -309,8 +309,8 @@ _NameController_providers = new WeakMap(), _NameController_updateDelay = new Wea
|
|
|
309
309
|
errorMessages.push('Must specify a non-empty string for value.');
|
|
310
310
|
}
|
|
311
311
|
}, _NameController_validateType = function _NameController_validateType(type, errorMessages) {
|
|
312
|
-
if (!Object.values(
|
|
313
|
-
errorMessages.push(`Must specify one of the following types: ${Object.values(
|
|
312
|
+
if (!Object.values(types_js_1.NameType).includes(type)) {
|
|
313
|
+
errorMessages.push(`Must specify one of the following types: ${Object.values(types_js_1.NameType).join(', ')}`);
|
|
314
314
|
}
|
|
315
315
|
}, _NameController_validateName = function _NameController_validateName(name, errorMessages) {
|
|
316
316
|
if (name === null) {
|
|
@@ -357,7 +357,7 @@ _NameController_providers = new WeakMap(), _NameController_updateDelay = new Wea
|
|
|
357
357
|
errorMessages.push(`Duplicate source IDs found for type '${type}': ${duplicateSourceIds.join(', ')}`);
|
|
358
358
|
}
|
|
359
359
|
}, _NameController_validateVariation = function _NameController_validateVariation(variation, type, errorMessages) {
|
|
360
|
-
if (type !==
|
|
360
|
+
if (type !== types_js_1.NameType.ETHEREUM_ADDRESS) {
|
|
361
361
|
return;
|
|
362
362
|
}
|
|
363
363
|
if (!variation?.length ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NameController.cjs","sourceRoot":"","sources":["../src/NameController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAIA,+DAA2D;AAC3D,iEAA8D;AAU9D,uCAAmC;AAEtB,QAAA,kBAAkB,GAAG,GAAG,CAAC;AACzB,QAAA,6BAA6B,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,WAAW;AAEtE;;GAEG;AACH,IAAY,UASX;AATD,WAAY,UAAU;IACpB,uCAAuC;IACvC,mDAAqC,CAAA;IACrC,yCAAyC;IACzC,2CAA6B,CAAA;IAC7B,yEAAyE;IACzE,yBAAW,CAAA;IACX,oDAAoD;IACpD,uBAAS,CAAA;AACX,CAAC,EATW,UAAU,0BAAV,UAAU,QASrB;AAED,MAAM,oBAAoB,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,YAAY;AACjD,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAExC,MAAM,yBAAyB,GAAG,CAAC,SAAS,EAAE,qBAAqB,CAAU,CAAC;AAE9E,MAAM,aAAa,GAAG;IACpB,KAAK,EAAE;QACL,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,IAAI;KACf;IACD,WAAW,EAAE;QACX,kBAAkB,EAAE,IAAI;QACxB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":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport { isSafeDynamicKey } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\n\nimport type { NameControllerMethodActions } from './NameController-method-action-types';\nimport type {\n NameProvider,\n NameProviderRequest,\n NameProviderResult,\n NameProviderSourceResult,\n} from './types';\nimport { NameType } from './types';\n\nexport const FALLBACK_VARIATION = '*';\nexport const PROPOSED_NAME_EXPIRE_DURATION = 60 * 60 * 24; // 24 hours\n\n/**\n * Enumerates the possible origins responsible for setting a petname.\n */\nexport enum NameOrigin {\n // Originated from an account identity.\n ACCOUNT_IDENTITY = 'account-identity',\n // Originated from an address book entry.\n ADDRESS_BOOK = 'address-book',\n // Originated from the API (NameController.setName). This is the default.\n API = 'api',\n // Originated from the user taking action in the UI.\n UI = 'ui',\n}\n\nconst DEFAULT_UPDATE_DELAY = 60 * 2; // 2 Minutes\nconst DEFAULT_VARIATION = '';\n\nconst controllerName = 'NameController';\n\nconst MESSENGER_EXPOSED_METHODS = ['setName', 'updateProposedNames'] as const;\n\nconst stateMetadata = {\n names: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n nameSources: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n};\n\nconst getDefaultState = () => ({\n names: {\n [NameType.ETHEREUM_ADDRESS]: {},\n },\n nameSources: {},\n});\n\nexport type ProposedNamesEntry = {\n proposedNames: string[];\n lastRequestTime: number | null;\n updateDelay: number | null;\n};\n\nexport type NameEntry = {\n name: string | null;\n sourceId: string | null;\n origin: NameOrigin | null;\n proposedNames: Record<string, ProposedNamesEntry>;\n};\n\nexport type SourceEntry = {\n label: string;\n};\n\nexport type NameControllerState = {\n // Type > Value > Variation > Entry\n names: Record<NameType, Record<string, Record<string, NameEntry>>>;\n nameSources: Record<string, SourceEntry>;\n};\n\nexport type GetNameState = ControllerGetStateAction<\n typeof controllerName,\n NameControllerState\n>;\n\nexport type NameStateChange = ControllerStateChangeEvent<\n typeof controllerName,\n NameControllerState\n>;\n\nexport type NameControllerActions = GetNameState | NameControllerMethodActions;\n\nexport type NameControllerEvents = NameStateChange;\n\nexport type NameControllerMessenger = Messenger<\n typeof controllerName,\n NameControllerActions,\n NameControllerEvents\n>;\n\nexport type NameControllerOptions = {\n messenger: NameControllerMessenger;\n providers: NameProvider[];\n state?: Partial<NameControllerState>;\n updateDelay?: number;\n};\n\nexport type UpdateProposedNamesRequest = {\n value: string;\n type: NameType;\n sourceIds?: string[];\n onlyUpdateAfterDelay?: boolean;\n variation?: string;\n};\n\nexport type UpdateProposedNamesResult = {\n results: Record<string, { proposedNames?: string[]; error?: unknown }>;\n};\n\nexport type SetNameRequest = {\n value: string;\n type: NameType;\n name: string | null;\n sourceId?: string;\n variation?: string;\n origin?: NameOrigin;\n};\n\n/**\n * Controller for storing and deriving names for values such as Ethereum addresses.\n */\nexport class NameController extends BaseController<\n typeof controllerName,\n NameControllerState,\n NameControllerMessenger\n> {\n readonly #providers: NameProvider[];\n\n readonly #updateDelay: number;\n\n /**\n * Construct a Name controller.\n *\n * @param options - Controller options.\n * @param options.messenger - Restricted messenger for the name controller.\n * @param options.providers - Array of name provider instances to propose names.\n * @param options.state - Initial state to set on the controller.\n * @param options.updateDelay - The delay in seconds before a new request to a source should be made.\n */\n constructor({\n messenger,\n providers,\n state,\n updateDelay,\n }: NameControllerOptions) {\n super({\n name: controllerName,\n metadata: stateMetadata,\n messenger,\n state: { ...getDefaultState(), ...state },\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n\n this.#providers = providers;\n this.#updateDelay = updateDelay ?? DEFAULT_UPDATE_DELAY;\n }\n\n /**\n * Set the user specified name for a value.\n *\n * @param request - Request object.\n * @param request.name - Name to set.\n * @param request.sourceId - Optional ID of the source of the proposed name.\n * @param request.type - Type of value to set the name for.\n * @param request.value - Value to set the name for.\n * @param request.variation - Variation of the raw value to set the name for. The chain ID if the type is Ethereum address.\n */\n setName(request: SetNameRequest) {\n this.#validateSetNameRequest(request);\n\n const {\n value,\n type,\n name,\n sourceId: requestSourceId,\n origin: requestOrigin,\n variation,\n } = request;\n const sourceId = requestSourceId ?? null;\n // If the name is being cleared, the fallback origin should be cleared as well.\n const fallbackOrigin = name === null ? null : NameOrigin.API;\n const origin = requestOrigin ?? fallbackOrigin;\n\n this.#updateEntry(value, type, variation, (entry: NameEntry) => {\n entry.name = name;\n entry.sourceId = sourceId;\n entry.origin = origin;\n });\n }\n\n /**\n * Generate the proposed names for a value using the name providers and store them in the state.\n *\n * @param request - Request object.\n * @param request.value - Value to update the proposed names for.\n * @param request.type - Type of value to update the proposed names for.\n * @param request.sourceIds - Optional array of source IDs to limit which sources are used by the providers. If not provided, all sources in all providers will be used.\n * @param request.variation - Variation of the raw value to update proposed names for. The chain ID if the type is Ethereum address.\n * @returns The updated proposed names for the value.\n */\n async updateProposedNames(\n request: UpdateProposedNamesRequest,\n ): Promise<UpdateProposedNamesResult> {\n this.#validateUpdateProposedNamesRequest(request);\n\n const providerResponses = (\n await Promise.all(\n this.#providers.map((provider) =>\n this.#getProviderResponse(request, provider),\n ),\n )\n ).filter((response) => Boolean(response)) as NameProviderResult[];\n\n this.#updateProposedNameState(request, providerResponses);\n this.#updateSourceState(this.#providers);\n this.#removeExpiredEntries();\n\n return this.#getUpdateProposedNamesResult(providerResponses);\n }\n\n #updateProposedNameState(\n request: UpdateProposedNamesRequest,\n providerResponses: NameProviderResult[],\n ) {\n const { value, type, variation } = request;\n const currentTime = this.#getCurrentTimeSeconds();\n\n this.#updateEntry(value, type, variation, (entry: NameEntry) => {\n this.#removeDormantProposedNames(entry.proposedNames, type);\n\n for (const providerResponse of providerResponses) {\n const { results } = providerResponse;\n\n for (const sourceId of Object.keys(providerResponse.results)) {\n const result = results[sourceId];\n const { proposedNames, updateDelay } = result;\n\n const proposedNameEntry = entry.proposedNames[sourceId] ?? {\n proposedNames: [],\n lastRequestTime: null,\n updateDelay: null,\n };\n\n entry.proposedNames[sourceId] = proposedNameEntry;\n\n if (proposedNames) {\n proposedNameEntry.proposedNames = proposedNames;\n }\n\n proposedNameEntry.lastRequestTime = currentTime;\n proposedNameEntry.updateDelay = updateDelay ?? null;\n }\n }\n });\n }\n\n #updateSourceState(providers: NameProvider[]) {\n const newNameSources = { ...this.state.nameSources };\n\n for (const provider of providers) {\n const { sourceLabels } = provider.getMetadata();\n\n for (const sourceId of Object.keys(sourceLabels)) {\n newNameSources[sourceId] = {\n label: sourceLabels[sourceId],\n };\n }\n }\n\n this.update((state) => {\n state.nameSources = newNameSources;\n });\n }\n\n #getUpdateProposedNamesResult(\n providerResponses: NameProviderResult[],\n ): UpdateProposedNamesResult {\n return providerResponses.reduce(\n (acc: UpdateProposedNamesResult, providerResponse) => {\n const { results } = providerResponse;\n\n for (const sourceId of Object.keys(results)) {\n const { proposedNames, error } = results[sourceId];\n\n acc.results[sourceId] = {\n proposedNames,\n error,\n };\n }\n\n return acc;\n },\n { results: {} },\n );\n }\n\n async #getProviderResponse(\n request: UpdateProposedNamesRequest,\n provider: NameProvider,\n ): Promise<NameProviderResult | undefined> {\n const {\n value,\n type,\n sourceIds: requestedSourceIds,\n onlyUpdateAfterDelay,\n variation,\n } = request;\n\n /* istanbul ignore next */\n const variationKey = variation ?? DEFAULT_VARIATION;\n const supportedSourceIds = this.#getSourceIds(provider, type);\n const currentTime = this.#getCurrentTimeSeconds();\n const normalizedValue = this.#normalizeValue(value, type);\n\n const matchingSourceIds = supportedSourceIds.filter((sourceId) => {\n if (requestedSourceIds && !requestedSourceIds.includes(sourceId)) {\n return false;\n }\n\n if (onlyUpdateAfterDelay) {\n const entry =\n this.state.names[type]?.[normalizedValue]?.[variationKey] ?? {};\n const proposedNamesEntry = entry.proposedNames?.[sourceId] ?? {};\n const lastRequestTime = proposedNamesEntry.lastRequestTime ?? 0;\n const updateDelay = proposedNamesEntry.updateDelay ?? this.#updateDelay;\n\n if (currentTime - lastRequestTime < updateDelay) {\n return false;\n }\n }\n\n return true;\n });\n\n if (!matchingSourceIds.length) {\n return undefined;\n }\n\n const providerRequest: NameProviderRequest = {\n value: this.#normalizeValue(value, type),\n type,\n sourceIds: requestedSourceIds ? matchingSourceIds : undefined,\n variation: this.#normalizeVariation(variationKey, type),\n };\n\n let responseError: unknown | undefined;\n let response: NameProviderResult | undefined;\n\n try {\n response = await provider.getProposedNames(providerRequest);\n responseError = response.error;\n } catch (error) {\n responseError = error;\n }\n\n return this.#normalizeProviderResult(\n response,\n responseError,\n matchingSourceIds,\n );\n }\n\n #normalizeProviderResult(\n result: NameProviderResult | undefined,\n responseError: unknown,\n matchingSourceIds: string[],\n ): NameProviderResult {\n const error = responseError ?? undefined;\n\n const results = matchingSourceIds.reduce((acc, sourceId) => {\n const sourceResult = result?.results?.[sourceId];\n\n const normalizedSourceResult = this.#normalizeProviderSourceResult(\n sourceResult,\n responseError,\n );\n\n return {\n ...acc,\n [sourceId]: normalizedSourceResult,\n };\n }, {});\n\n return { results, error };\n }\n\n #normalizeProviderSourceResult(\n result: NameProviderSourceResult | undefined,\n responseError: unknown,\n ): NameProviderSourceResult | undefined {\n const error = result?.error ?? responseError ?? undefined;\n const updateDelay = result?.updateDelay ?? undefined;\n let proposedNames = error\n ? undefined\n : (result?.proposedNames ?? undefined);\n\n if (proposedNames) {\n proposedNames = proposedNames.filter(\n (proposedName) => proposedName?.length,\n );\n }\n\n return {\n proposedNames,\n error,\n updateDelay,\n };\n }\n\n #normalizeValue(value: string, type: NameType): string {\n /* istanbul ignore next */\n switch (type) {\n case NameType.ETHEREUM_ADDRESS:\n return value.toLowerCase();\n\n default:\n return value;\n }\n }\n\n #normalizeVariation(variation: string, type: NameType): string {\n /* istanbul ignore next */\n switch (type) {\n case NameType.ETHEREUM_ADDRESS:\n return variation.toLowerCase();\n\n default:\n return variation;\n }\n }\n\n #updateEntry(\n value: string,\n type: NameType,\n variation: string | undefined,\n callback: (entry: NameEntry) => void,\n ) {\n /* istanbul ignore next */\n const variationKey = variation ?? DEFAULT_VARIATION;\n const normalizedValue = this.#normalizeValue(value, type);\n const normalizedVariation = this.#normalizeVariation(variationKey, type);\n\n if (\n [normalizedValue, normalizedVariation].some(\n (key) => !isSafeDynamicKey(key),\n )\n ) {\n return;\n }\n\n this.update((state) => {\n const typeEntries = state.names[type] || {};\n state.names[type] = typeEntries;\n\n const variationEntries = typeEntries[normalizedValue] || {};\n typeEntries[normalizedValue] = variationEntries;\n\n const entry = variationEntries[normalizedVariation] ?? {\n proposedNames: {},\n name: null,\n sourceId: null,\n origin: null,\n };\n variationEntries[normalizedVariation] = entry;\n\n callback(entry);\n });\n }\n\n #getCurrentTimeSeconds(): number {\n return Math.round(Date.now() / 1000);\n }\n\n #validateSetNameRequest(request: SetNameRequest) {\n const { name, value, type, sourceId, variation, origin } = request;\n const errorMessages: string[] = [];\n\n this.#validateValue(value, errorMessages);\n this.#validateType(type, errorMessages);\n this.#validateName(name, errorMessages);\n this.#validateSourceId(sourceId, type, name, errorMessages);\n this.#validateVariation(variation, type, errorMessages);\n this.#validateOrigin(origin, name, errorMessages);\n\n if (errorMessages.length) {\n throw new Error(errorMessages.join(' '));\n }\n }\n\n #validateUpdateProposedNamesRequest(request: UpdateProposedNamesRequest) {\n const { value, type, sourceIds, variation } = request;\n const errorMessages: string[] = [];\n\n this.#validateValue(value, errorMessages);\n this.#validateType(type, errorMessages);\n this.#validateSourceIds(sourceIds, type, errorMessages);\n this.#validateDuplicateSourceIds(type, errorMessages);\n this.#validateVariation(variation, type, errorMessages);\n\n if (errorMessages.length) {\n throw new Error(errorMessages.join(' '));\n }\n }\n\n #validateValue(value: string, errorMessages: string[]) {\n if (!value?.length || typeof value !== 'string') {\n errorMessages.push('Must specify a non-empty string for value.');\n }\n }\n\n #validateType(type: NameType, errorMessages: string[]) {\n if (!Object.values(NameType).includes(type)) {\n errorMessages.push(\n `Must specify one of the following types: ${Object.values(\n NameType,\n ).join(', ')}`,\n );\n }\n }\n\n #validateName(name: string | null, errorMessages: string[]) {\n if (name === null) {\n return;\n }\n\n if (!name?.length || typeof name !== 'string') {\n errorMessages.push('Must specify a non-empty string or null for name.');\n }\n }\n\n #validateSourceIds(\n sourceIds: string[] | undefined,\n type: NameType,\n errorMessages: string[],\n ) {\n if (!sourceIds) {\n return;\n }\n\n const allSourceIds = this.#getAllSourceIds(type);\n const missingSourceIds = [];\n\n for (const sourceId of sourceIds) {\n if (!allSourceIds.includes(sourceId)) {\n missingSourceIds.push(sourceId);\n continue;\n }\n }\n\n if (missingSourceIds.length) {\n errorMessages.push(\n `Unknown source IDs for type '${type}': ${missingSourceIds.join(', ')}`,\n );\n }\n }\n\n #validateSourceId(\n sourceId: string | undefined,\n type: NameType,\n name: string | null,\n errorMessages: string[],\n ) {\n if (sourceId === null || sourceId === undefined) {\n return;\n }\n\n if (name === null) {\n errorMessages.push(\n `Cannot specify a source ID when clearing the saved name: ${sourceId}`,\n );\n return;\n }\n\n const allSourceIds = this.#getAllSourceIds(type);\n\n if (!sourceId.length || typeof sourceId !== 'string') {\n errorMessages.push('Must specify a non-empty string for sourceId.');\n return;\n }\n\n if (!allSourceIds.includes(sourceId)) {\n errorMessages.push(`Unknown source ID for type '${type}': ${sourceId}`);\n }\n }\n\n #validateDuplicateSourceIds(type: NameType, errorMessages: string[]) {\n const allSourceIds = this.#getAllSourceIds(type);\n\n const duplicateSourceIds = allSourceIds.filter(\n (sourceId, index) => allSourceIds.indexOf(sourceId) !== index,\n );\n\n if (duplicateSourceIds.length) {\n errorMessages.push(\n `Duplicate source IDs found for type '${type}': ${duplicateSourceIds.join(\n ', ',\n )}`,\n );\n }\n }\n\n #validateVariation(\n variation: string | undefined,\n type: string,\n errorMessages: string[],\n ) {\n if (type !== NameType.ETHEREUM_ADDRESS) {\n return;\n }\n\n if (\n !variation?.length ||\n typeof variation !== 'string' ||\n (!variation.match(/^0x[0-9A-Fa-f]+$/u) &&\n variation !== FALLBACK_VARIATION)\n ) {\n errorMessages.push(\n `Must specify a chain ID in hexadecimal format or the fallback, \"${FALLBACK_VARIATION}\", for variation when using '${type}' type.`,\n );\n }\n }\n\n #validateOrigin(\n origin: NameOrigin | null | undefined,\n name: string | null,\n errorMessages: string[],\n ) {\n if (!origin) {\n return;\n }\n\n if (name === null) {\n errorMessages.push(\n `Cannot specify an origin when clearing the saved name: ${origin}`,\n );\n return;\n }\n\n if (!Object.values(NameOrigin).includes(origin)) {\n errorMessages.push(\n `Must specify one of the following origins: ${Object.values(\n NameOrigin,\n ).join(', ')}`,\n );\n }\n }\n\n #getAllSourceIds(type: NameType): string[] {\n return (\n this.#providers\n /* istanbul ignore next */\n .map((provider) => this.#getSourceIds(provider, type))\n .flat()\n );\n }\n\n #getSourceIds(provider: NameProvider, type: NameType): string[] {\n return provider.getMetadata().sourceIds[type];\n }\n\n #removeDormantProposedNames(\n proposedNames: Record<string, ProposedNamesEntry>,\n type: NameType,\n ) {\n if (Object.keys(proposedNames).length === 0) {\n return;\n }\n\n const typeSourceIds = this.#getAllSourceIds(type);\n\n const dormantSourceIds = Object.keys(proposedNames).filter(\n (sourceId) => !typeSourceIds.includes(sourceId),\n );\n\n for (const dormantSourceId of dormantSourceIds) {\n delete proposedNames[dormantSourceId];\n }\n }\n\n #removeExpiredEntries(): void {\n const currentTime = this.#getCurrentTimeSeconds();\n\n this.update((state: NameControllerState) => {\n const entries = this.#getEntriesList(state);\n for (const { nameType, value, variation, entry } of entries) {\n if (entry.name !== null) {\n continue;\n }\n\n const proposedNames = Object.values(entry.proposedNames);\n const allProposedNamesExpired = proposedNames.every(\n (proposedName: ProposedNamesEntry) =>\n currentTime - (proposedName.lastRequestTime ?? 0) >=\n PROPOSED_NAME_EXPIRE_DURATION,\n );\n\n if (allProposedNamesExpired) {\n delete state.names[nameType][value][variation];\n }\n }\n });\n }\n\n #getEntriesList(state: NameControllerState): {\n nameType: NameType;\n value: string;\n variation: string;\n entry: NameEntry;\n }[] {\n return Object.entries(state.names).flatMap(([type, typeEntries]) =>\n Object.entries(typeEntries).flatMap(([value, variationEntries]) =>\n Object.entries(variationEntries).map(([variation, entry]) => ({\n entry,\n nameType: type as NameType,\n value,\n variation,\n })),\n ),\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"NameController.cjs","sourceRoot":"","sources":["../src/NameController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAIA,+DAA2D;AAC3D,iEAA8D;AAU9D,0CAAsC;AAEzB,QAAA,kBAAkB,GAAG,GAAG,CAAC;AACzB,QAAA,6BAA6B,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,WAAW;AAEtE;;GAEG;AACH,IAAY,UASX;AATD,WAAY,UAAU;IACpB,uCAAuC;IACvC,mDAAqC,CAAA;IACrC,yCAAyC;IACzC,2CAA6B,CAAA;IAC7B,yEAAyE;IACzE,yBAAW,CAAA;IACX,oDAAoD;IACpD,uBAAS,CAAA;AACX,CAAC,EATW,UAAU,0BAAV,UAAU,QASrB;AAED,MAAM,oBAAoB,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,YAAY;AACjD,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAExC,MAAM,yBAAyB,GAAG,CAAC,SAAS,EAAE,qBAAqB,CAAU,CAAC;AAE9E,MAAM,aAAa,GAAG;IACpB,KAAK,EAAE;QACL,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,IAAI;KACf;IACD,WAAW,EAAE;QACX,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,IAAI;KACf;CACF,CAAC;AAEF,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,CAAC;IAC7B,KAAK,EAAE;QACL,CAAC,mBAAQ,CAAC,gBA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,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,OAAO,EAAE,CAAC;YAC5D,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;gBACxB,SAAS;YACX,CAAC;YAED,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;YACzD,MAAM,uBAAuB,GAAG,aAAa,CAAC,KAAK,CACjD,CAAC,YAAgC,EAAE,EAAE,CACnC,WAAW,GAAG,CAAC,YAAY,CAAC,eAAe,IAAI,CAAC,CAAC;gBACjD,qCAA6B,CAChC,CAAC;YAEF,IAAI,uBAAuB,EAAE,CAAC;gBAC5B,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,2EAEe,KAA0B;IAMxC,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,EAAE,CACjE,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,gBAAgB,CAAC,EAAE,EAAE,CAChE,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;QAC5D,KAAK;QACL,QAAQ,EAAE,IAAgB;QAC1B,KAAK;QACL,SAAS;KACV,CAAC,CAAC,CACJ,CACF,CAAC;AACJ,CAAC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport { isSafeDynamicKey } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\n\nimport type { NameControllerMethodActions } from './NameController-method-action-types.js';\nimport type {\n NameProvider,\n NameProviderRequest,\n NameProviderResult,\n NameProviderSourceResult,\n} from './types.js';\nimport { NameType } from './types.js';\n\nexport const FALLBACK_VARIATION = '*';\nexport const PROPOSED_NAME_EXPIRE_DURATION = 60 * 60 * 24; // 24 hours\n\n/**\n * Enumerates the possible origins responsible for setting a petname.\n */\nexport enum NameOrigin {\n // Originated from an account identity.\n ACCOUNT_IDENTITY = 'account-identity',\n // Originated from an address book entry.\n ADDRESS_BOOK = 'address-book',\n // Originated from the API (NameController.setName). This is the default.\n API = 'api',\n // Originated from the user taking action in the UI.\n UI = 'ui',\n}\n\nconst DEFAULT_UPDATE_DELAY = 60 * 2; // 2 Minutes\nconst DEFAULT_VARIATION = '';\n\nconst controllerName = 'NameController';\n\nconst MESSENGER_EXPOSED_METHODS = ['setName', 'updateProposedNames'] as const;\n\nconst stateMetadata = {\n names: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n nameSources: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n};\n\nconst getDefaultState = () => ({\n names: {\n [NameType.ETHEREUM_ADDRESS]: {},\n },\n nameSources: {},\n});\n\nexport type ProposedNamesEntry = {\n proposedNames: string[];\n lastRequestTime: number | null;\n updateDelay: number | null;\n};\n\nexport type NameEntry = {\n name: string | null;\n sourceId: string | null;\n origin: NameOrigin | null;\n proposedNames: Record<string, ProposedNamesEntry>;\n};\n\nexport type SourceEntry = {\n label: string;\n};\n\nexport type NameControllerState = {\n // Type > Value > Variation > Entry\n names: Record<NameType, Record<string, Record<string, NameEntry>>>;\n nameSources: Record<string, SourceEntry>;\n};\n\nexport type GetNameState = ControllerGetStateAction<\n typeof controllerName,\n NameControllerState\n>;\n\nexport type NameStateChange = ControllerStateChangeEvent<\n typeof controllerName,\n NameControllerState\n>;\n\nexport type NameControllerActions = GetNameState | NameControllerMethodActions;\n\nexport type NameControllerEvents = NameStateChange;\n\nexport type NameControllerMessenger = Messenger<\n typeof controllerName,\n NameControllerActions,\n NameControllerEvents\n>;\n\nexport type NameControllerOptions = {\n messenger: NameControllerMessenger;\n providers: NameProvider[];\n state?: Partial<NameControllerState>;\n updateDelay?: number;\n};\n\nexport type UpdateProposedNamesRequest = {\n value: string;\n type: NameType;\n sourceIds?: string[];\n onlyUpdateAfterDelay?: boolean;\n variation?: string;\n};\n\nexport type UpdateProposedNamesResult = {\n results: Record<string, { proposedNames?: string[]; error?: unknown }>;\n};\n\nexport type SetNameRequest = {\n value: string;\n type: NameType;\n name: string | null;\n sourceId?: string;\n variation?: string;\n origin?: NameOrigin;\n};\n\n/**\n * Controller for storing and deriving names for values such as Ethereum addresses.\n */\nexport class NameController extends BaseController<\n typeof controllerName,\n NameControllerState,\n NameControllerMessenger\n> {\n readonly #providers: NameProvider[];\n\n readonly #updateDelay: number;\n\n /**\n * Construct a Name controller.\n *\n * @param options - Controller options.\n * @param options.messenger - Restricted messenger for the name controller.\n * @param options.providers - Array of name provider instances to propose names.\n * @param options.state - Initial state to set on the controller.\n * @param options.updateDelay - The delay in seconds before a new request to a source should be made.\n */\n constructor({\n messenger,\n providers,\n state,\n updateDelay,\n }: NameControllerOptions) {\n super({\n name: controllerName,\n metadata: stateMetadata,\n messenger,\n state: { ...getDefaultState(), ...state },\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n\n this.#providers = providers;\n this.#updateDelay = updateDelay ?? DEFAULT_UPDATE_DELAY;\n }\n\n /**\n * Set the user specified name for a value.\n *\n * @param request - Request object.\n * @param request.name - Name to set.\n * @param request.sourceId - Optional ID of the source of the proposed name.\n * @param request.type - Type of value to set the name for.\n * @param request.value - Value to set the name for.\n * @param request.variation - Variation of the raw value to set the name for. The chain ID if the type is Ethereum address.\n */\n setName(request: SetNameRequest) {\n this.#validateSetNameRequest(request);\n\n const {\n value,\n type,\n name,\n sourceId: requestSourceId,\n origin: requestOrigin,\n variation,\n } = request;\n const sourceId = requestSourceId ?? null;\n // If the name is being cleared, the fallback origin should be cleared as well.\n const fallbackOrigin = name === null ? null : NameOrigin.API;\n const origin = requestOrigin ?? fallbackOrigin;\n\n this.#updateEntry(value, type, variation, (entry: NameEntry) => {\n entry.name = name;\n entry.sourceId = sourceId;\n entry.origin = origin;\n });\n }\n\n /**\n * Generate the proposed names for a value using the name providers and store them in the state.\n *\n * @param request - Request object.\n * @param request.value - Value to update the proposed names for.\n * @param request.type - Type of value to update the proposed names for.\n * @param request.sourceIds - Optional array of source IDs to limit which sources are used by the providers. If not provided, all sources in all providers will be used.\n * @param request.variation - Variation of the raw value to update proposed names for. The chain ID if the type is Ethereum address.\n * @returns The updated proposed names for the value.\n */\n async updateProposedNames(\n request: UpdateProposedNamesRequest,\n ): Promise<UpdateProposedNamesResult> {\n this.#validateUpdateProposedNamesRequest(request);\n\n const providerResponses = (\n await Promise.all(\n this.#providers.map((provider) =>\n this.#getProviderResponse(request, provider),\n ),\n )\n ).filter((response) => Boolean(response)) as NameProviderResult[];\n\n this.#updateProposedNameState(request, providerResponses);\n this.#updateSourceState(this.#providers);\n this.#removeExpiredEntries();\n\n return this.#getUpdateProposedNamesResult(providerResponses);\n }\n\n #updateProposedNameState(\n request: UpdateProposedNamesRequest,\n providerResponses: NameProviderResult[],\n ) {\n const { value, type, variation } = request;\n const currentTime = this.#getCurrentTimeSeconds();\n\n this.#updateEntry(value, type, variation, (entry: NameEntry) => {\n this.#removeDormantProposedNames(entry.proposedNames, type);\n\n for (const providerResponse of providerResponses) {\n const { results } = providerResponse;\n\n for (const sourceId of Object.keys(providerResponse.results)) {\n const result = results[sourceId];\n const { proposedNames, updateDelay } = result;\n\n const proposedNameEntry = entry.proposedNames[sourceId] ?? {\n proposedNames: [],\n lastRequestTime: null,\n updateDelay: null,\n };\n\n entry.proposedNames[sourceId] = proposedNameEntry;\n\n if (proposedNames) {\n proposedNameEntry.proposedNames = proposedNames;\n }\n\n proposedNameEntry.lastRequestTime = currentTime;\n proposedNameEntry.updateDelay = updateDelay ?? null;\n }\n }\n });\n }\n\n #updateSourceState(providers: NameProvider[]) {\n const newNameSources = { ...this.state.nameSources };\n\n for (const provider of providers) {\n const { sourceLabels } = provider.getMetadata();\n\n for (const sourceId of Object.keys(sourceLabels)) {\n newNameSources[sourceId] = {\n label: sourceLabels[sourceId],\n };\n }\n }\n\n this.update((state) => {\n state.nameSources = newNameSources;\n });\n }\n\n #getUpdateProposedNamesResult(\n providerResponses: NameProviderResult[],\n ): UpdateProposedNamesResult {\n return providerResponses.reduce(\n (acc: UpdateProposedNamesResult, providerResponse) => {\n const { results } = providerResponse;\n\n for (const sourceId of Object.keys(results)) {\n const { proposedNames, error } = results[sourceId];\n\n acc.results[sourceId] = {\n proposedNames,\n error,\n };\n }\n\n return acc;\n },\n { results: {} },\n );\n }\n\n async #getProviderResponse(\n request: UpdateProposedNamesRequest,\n provider: NameProvider,\n ): Promise<NameProviderResult | undefined> {\n const {\n value,\n type,\n sourceIds: requestedSourceIds,\n onlyUpdateAfterDelay,\n variation,\n } = request;\n\n /* istanbul ignore next */\n const variationKey = variation ?? DEFAULT_VARIATION;\n const supportedSourceIds = this.#getSourceIds(provider, type);\n const currentTime = this.#getCurrentTimeSeconds();\n const normalizedValue = this.#normalizeValue(value, type);\n\n const matchingSourceIds = supportedSourceIds.filter((sourceId) => {\n if (requestedSourceIds && !requestedSourceIds.includes(sourceId)) {\n return false;\n }\n\n if (onlyUpdateAfterDelay) {\n const entry =\n this.state.names[type]?.[normalizedValue]?.[variationKey] ?? {};\n const proposedNamesEntry = entry.proposedNames?.[sourceId] ?? {};\n const lastRequestTime = proposedNamesEntry.lastRequestTime ?? 0;\n const updateDelay = proposedNamesEntry.updateDelay ?? this.#updateDelay;\n\n if (currentTime - lastRequestTime < updateDelay) {\n return false;\n }\n }\n\n return true;\n });\n\n if (!matchingSourceIds.length) {\n return undefined;\n }\n\n const providerRequest: NameProviderRequest = {\n value: this.#normalizeValue(value, type),\n type,\n sourceIds: requestedSourceIds ? matchingSourceIds : undefined,\n variation: this.#normalizeVariation(variationKey, type),\n };\n\n let responseError: unknown | undefined;\n let response: NameProviderResult | undefined;\n\n try {\n response = await provider.getProposedNames(providerRequest);\n responseError = response.error;\n } catch (error) {\n responseError = error;\n }\n\n return this.#normalizeProviderResult(\n response,\n responseError,\n matchingSourceIds,\n );\n }\n\n #normalizeProviderResult(\n result: NameProviderResult | undefined,\n responseError: unknown,\n matchingSourceIds: string[],\n ): NameProviderResult {\n const error = responseError ?? undefined;\n\n const results = matchingSourceIds.reduce((acc, sourceId) => {\n const sourceResult = result?.results?.[sourceId];\n\n const normalizedSourceResult = this.#normalizeProviderSourceResult(\n sourceResult,\n responseError,\n );\n\n return {\n ...acc,\n [sourceId]: normalizedSourceResult,\n };\n }, {});\n\n return { results, error };\n }\n\n #normalizeProviderSourceResult(\n result: NameProviderSourceResult | undefined,\n responseError: unknown,\n ): NameProviderSourceResult | undefined {\n const error = result?.error ?? responseError ?? undefined;\n const updateDelay = result?.updateDelay ?? undefined;\n let proposedNames = error\n ? undefined\n : (result?.proposedNames ?? undefined);\n\n if (proposedNames) {\n proposedNames = proposedNames.filter(\n (proposedName) => proposedName?.length,\n );\n }\n\n return {\n proposedNames,\n error,\n updateDelay,\n };\n }\n\n #normalizeValue(value: string, type: NameType): string {\n /* istanbul ignore next */\n switch (type) {\n case NameType.ETHEREUM_ADDRESS:\n return value.toLowerCase();\n\n default:\n return value;\n }\n }\n\n #normalizeVariation(variation: string, type: NameType): string {\n /* istanbul ignore next */\n switch (type) {\n case NameType.ETHEREUM_ADDRESS:\n return variation.toLowerCase();\n\n default:\n return variation;\n }\n }\n\n #updateEntry(\n value: string,\n type: NameType,\n variation: string | undefined,\n callback: (entry: NameEntry) => void,\n ) {\n /* istanbul ignore next */\n const variationKey = variation ?? DEFAULT_VARIATION;\n const normalizedValue = this.#normalizeValue(value, type);\n const normalizedVariation = this.#normalizeVariation(variationKey, type);\n\n if (\n [normalizedValue, normalizedVariation].some(\n (key) => !isSafeDynamicKey(key),\n )\n ) {\n return;\n }\n\n this.update((state) => {\n const typeEntries = state.names[type] || {};\n state.names[type] = typeEntries;\n\n const variationEntries = typeEntries[normalizedValue] || {};\n typeEntries[normalizedValue] = variationEntries;\n\n const entry = variationEntries[normalizedVariation] ?? {\n proposedNames: {},\n name: null,\n sourceId: null,\n origin: null,\n };\n variationEntries[normalizedVariation] = entry;\n\n callback(entry);\n });\n }\n\n #getCurrentTimeSeconds(): number {\n return Math.round(Date.now() / 1000);\n }\n\n #validateSetNameRequest(request: SetNameRequest) {\n const { name, value, type, sourceId, variation, origin } = request;\n const errorMessages: string[] = [];\n\n this.#validateValue(value, errorMessages);\n this.#validateType(type, errorMessages);\n this.#validateName(name, errorMessages);\n this.#validateSourceId(sourceId, type, name, errorMessages);\n this.#validateVariation(variation, type, errorMessages);\n this.#validateOrigin(origin, name, errorMessages);\n\n if (errorMessages.length) {\n throw new Error(errorMessages.join(' '));\n }\n }\n\n #validateUpdateProposedNamesRequest(request: UpdateProposedNamesRequest) {\n const { value, type, sourceIds, variation } = request;\n const errorMessages: string[] = [];\n\n this.#validateValue(value, errorMessages);\n this.#validateType(type, errorMessages);\n this.#validateSourceIds(sourceIds, type, errorMessages);\n this.#validateDuplicateSourceIds(type, errorMessages);\n this.#validateVariation(variation, type, errorMessages);\n\n if (errorMessages.length) {\n throw new Error(errorMessages.join(' '));\n }\n }\n\n #validateValue(value: string, errorMessages: string[]) {\n if (!value?.length || typeof value !== 'string') {\n errorMessages.push('Must specify a non-empty string for value.');\n }\n }\n\n #validateType(type: NameType, errorMessages: string[]) {\n if (!Object.values(NameType).includes(type)) {\n errorMessages.push(\n `Must specify one of the following types: ${Object.values(\n NameType,\n ).join(', ')}`,\n );\n }\n }\n\n #validateName(name: string | null, errorMessages: string[]) {\n if (name === null) {\n return;\n }\n\n if (!name?.length || typeof name !== 'string') {\n errorMessages.push('Must specify a non-empty string or null for name.');\n }\n }\n\n #validateSourceIds(\n sourceIds: string[] | undefined,\n type: NameType,\n errorMessages: string[],\n ) {\n if (!sourceIds) {\n return;\n }\n\n const allSourceIds = this.#getAllSourceIds(type);\n const missingSourceIds = [];\n\n for (const sourceId of sourceIds) {\n if (!allSourceIds.includes(sourceId)) {\n missingSourceIds.push(sourceId);\n continue;\n }\n }\n\n if (missingSourceIds.length) {\n errorMessages.push(\n `Unknown source IDs for type '${type}': ${missingSourceIds.join(', ')}`,\n );\n }\n }\n\n #validateSourceId(\n sourceId: string | undefined,\n type: NameType,\n name: string | null,\n errorMessages: string[],\n ) {\n if (sourceId === null || sourceId === undefined) {\n return;\n }\n\n if (name === null) {\n errorMessages.push(\n `Cannot specify a source ID when clearing the saved name: ${sourceId}`,\n );\n return;\n }\n\n const allSourceIds = this.#getAllSourceIds(type);\n\n if (!sourceId.length || typeof sourceId !== 'string') {\n errorMessages.push('Must specify a non-empty string for sourceId.');\n return;\n }\n\n if (!allSourceIds.includes(sourceId)) {\n errorMessages.push(`Unknown source ID for type '${type}': ${sourceId}`);\n }\n }\n\n #validateDuplicateSourceIds(type: NameType, errorMessages: string[]) {\n const allSourceIds = this.#getAllSourceIds(type);\n\n const duplicateSourceIds = allSourceIds.filter(\n (sourceId, index) => allSourceIds.indexOf(sourceId) !== index,\n );\n\n if (duplicateSourceIds.length) {\n errorMessages.push(\n `Duplicate source IDs found for type '${type}': ${duplicateSourceIds.join(\n ', ',\n )}`,\n );\n }\n }\n\n #validateVariation(\n variation: string | undefined,\n type: string,\n errorMessages: string[],\n ) {\n if (type !== NameType.ETHEREUM_ADDRESS) {\n return;\n }\n\n if (\n !variation?.length ||\n typeof variation !== 'string' ||\n (!variation.match(/^0x[0-9A-Fa-f]+$/u) &&\n variation !== FALLBACK_VARIATION)\n ) {\n errorMessages.push(\n `Must specify a chain ID in hexadecimal format or the fallback, \"${FALLBACK_VARIATION}\", for variation when using '${type}' type.`,\n );\n }\n }\n\n #validateOrigin(\n origin: NameOrigin | null | undefined,\n name: string | null,\n errorMessages: string[],\n ) {\n if (!origin) {\n return;\n }\n\n if (name === null) {\n errorMessages.push(\n `Cannot specify an origin when clearing the saved name: ${origin}`,\n );\n return;\n }\n\n if (!Object.values(NameOrigin).includes(origin)) {\n errorMessages.push(\n `Must specify one of the following origins: ${Object.values(\n NameOrigin,\n ).join(', ')}`,\n );\n }\n }\n\n #getAllSourceIds(type: NameType): string[] {\n return (\n this.#providers\n /* istanbul ignore next */\n .map((provider) => this.#getSourceIds(provider, type))\n .flat()\n );\n }\n\n #getSourceIds(provider: NameProvider, type: NameType): string[] {\n return provider.getMetadata().sourceIds[type];\n }\n\n #removeDormantProposedNames(\n proposedNames: Record<string, ProposedNamesEntry>,\n type: NameType,\n ) {\n if (Object.keys(proposedNames).length === 0) {\n return;\n }\n\n const typeSourceIds = this.#getAllSourceIds(type);\n\n const dormantSourceIds = Object.keys(proposedNames).filter(\n (sourceId) => !typeSourceIds.includes(sourceId),\n );\n\n for (const dormantSourceId of dormantSourceIds) {\n delete proposedNames[dormantSourceId];\n }\n }\n\n #removeExpiredEntries(): void {\n const currentTime = this.#getCurrentTimeSeconds();\n\n this.update((state: NameControllerState) => {\n const entries = this.#getEntriesList(state);\n for (const { nameType, value, variation, entry } of entries) {\n if (entry.name !== null) {\n continue;\n }\n\n const proposedNames = Object.values(entry.proposedNames);\n const allProposedNamesExpired = proposedNames.every(\n (proposedName: ProposedNamesEntry) =>\n currentTime - (proposedName.lastRequestTime ?? 0) >=\n PROPOSED_NAME_EXPIRE_DURATION,\n );\n\n if (allProposedNamesExpired) {\n delete state.names[nameType][value][variation];\n }\n }\n });\n }\n\n #getEntriesList(state: NameControllerState): {\n nameType: NameType;\n value: string;\n variation: string;\n entry: NameEntry;\n }[] {\n return Object.entries(state.names).flatMap(([type, typeEntries]) =>\n Object.entries(typeEntries).flatMap(([value, variationEntries]) =>\n Object.entries(variationEntries).map(([variation, entry]) => ({\n entry,\n nameType: type as NameType,\n value,\n variation,\n })),\n ),\n );\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NameController.d.cts","sourceRoot":"","sources":["../src/NameController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD,OAAO,KAAK,EAAE,2BAA2B,EAAE,
|
|
1
|
+
{"version":3,"file":"NameController.d.cts","sourceRoot":"","sources":["../src/NameController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD,OAAO,KAAK,EAAE,2BAA2B,EAAE,iDAAgD;AAC3F,OAAO,KAAK,EACV,YAAY,EAIb,oBAAmB;AACpB,OAAO,EAAE,QAAQ,EAAE,oBAAmB;AAEtC,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,eAAO,MAAM,6BAA6B,QAAe,CAAC;AAE1D;;GAEG;AACH,oBAAY,UAAU;IAEpB,gBAAgB,qBAAqB;IAErC,YAAY,iBAAiB;IAE7B,GAAG,QAAQ;IAEX,EAAE,OAAO;CACV;AAKD,QAAA,MAAM,cAAc,mBAAmB,CAAC;AA0BxC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC,MA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,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACxE,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,qBAAa,cAAe,SAAQ,cAAc,CAChD,OAAO,cAAc,EACrB,mBAAmB,EACnB,uBAAuB,CACxB;;IAKC;;;;;;;;OAQG;gBACS,EACV,SAAS,EACT,SAAS,EACT,KAAK,EACL,WAAW,GACZ,EAAE,qBAAqB;IAiBxB;;;;;;;;;OASG;IACH,OAAO,CAAC,OAAO,EAAE,cAAc;IAuB/B;;;;;;;;;OASG;IACG,mBAAmB,CACvB,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,yBAAyB,CAAC;CAsgBtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NameController.d.mts","sourceRoot":"","sources":["../src/NameController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD,OAAO,KAAK,EAAE,2BAA2B,EAAE,
|
|
1
|
+
{"version":3,"file":"NameController.d.mts","sourceRoot":"","sources":["../src/NameController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD,OAAO,KAAK,EAAE,2B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uBAAA,IAAI,iEAAgB,MAApB,IAAI,EAAiB,KAAK,CAAC,CAAC;QAC5C,KAAK,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,OAAO,EAAE,CAAC;YAC5D,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;gBACxB,SAAS;YACX,CAAC;YAED,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;YACzD,MAAM,uBAAuB,GAAG,aAAa,CAAC,KAAK,CACjD,CAAC,YAAgC,EAAE,EAAE,CACnC,WAAW,GAAG,CAAC,YAAY,CAAC,eAAe,IAAI,CAAC,CAAC;gBACjD,6BAA6B,CAChC,CAAC;YAEF,IAAI,uBAAuB,EAAE,CAAC;gBAC5B,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,2EAEe,KAA0B;IAMxC,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,EAAE,CACjE,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,gBAAgB,CAAC,EAAE,EAAE,CAChE,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;QAC5D,KAAK;QACL,QAAQ,EAAE,IAAgB;QAC1B,KAAK;QACL,SAAS;KACV,CAAC,CAAC,CACJ,CACF,CAAC;AACJ,CAAC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport { isSafeDynamicKey } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\n\nimport type { NameControllerMethodActions } from './NameController-method-action-types';\nimport type {\n NameProvider,\n NameProviderRequest,\n NameProviderResult,\n NameProviderSourceResult,\n} from './types';\nimport { NameType } from './types';\n\nexport const FALLBACK_VARIATION = '*';\nexport const PROPOSED_NAME_EXPIRE_DURATION = 60 * 60 * 24; // 24 hours\n\n/**\n * Enumerates the possible origins responsible for setting a petname.\n */\nexport enum NameOrigin {\n // Originated from an account identity.\n ACCOUNT_IDENTITY = 'account-identity',\n // Originated from an address book entry.\n ADDRESS_BOOK = 'address-book',\n // Originated from the API (NameController.setName). This is the default.\n API = 'api',\n // Originated from the user taking action in the UI.\n UI = 'ui',\n}\n\nconst DEFAULT_UPDATE_DELAY = 60 * 2; // 2 Minutes\nconst DEFAULT_VARIATION = '';\n\nconst controllerName = 'NameController';\n\nconst MESSENGER_EXPOSED_METHODS = ['setName', 'updateProposedNames'] as const;\n\nconst stateMetadata = {\n names: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n nameSources: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n};\n\nconst getDefaultState = () => ({\n names: {\n [NameType.ETHEREUM_ADDRESS]: {},\n },\n nameSources: {},\n});\n\nexport type ProposedNamesEntry = {\n proposedNames: string[];\n lastRequestTime: number | null;\n updateDelay: number | null;\n};\n\nexport type NameEntry = {\n name: string | null;\n sourceId: string | null;\n origin: NameOrigin | null;\n proposedNames: Record<string, ProposedNamesEntry>;\n};\n\nexport type SourceEntry = {\n label: string;\n};\n\nexport type NameControllerState = {\n // Type > Value > Variation > Entry\n names: Record<NameType, Record<string, Record<string, NameEntry>>>;\n nameSources: Record<string, SourceEntry>;\n};\n\nexport type GetNameState = ControllerGetStateAction<\n typeof controllerName,\n NameControllerState\n>;\n\nexport type NameStateChange = ControllerStateChangeEvent<\n typeof controllerName,\n NameControllerState\n>;\n\nexport type NameControllerActions = GetNameState | NameControllerMethodActions;\n\nexport type NameControllerEvents = NameStateChange;\n\nexport type NameControllerMessenger = Messenger<\n typeof controllerName,\n NameControllerActions,\n NameControllerEvents\n>;\n\nexport type NameControllerOptions = {\n messenger: NameControllerMessenger;\n providers: NameProvider[];\n state?: Partial<NameControllerState>;\n updateDelay?: number;\n};\n\nexport type UpdateProposedNamesRequest = {\n value: string;\n type: NameType;\n sourceIds?: string[];\n onlyUpdateAfterDelay?: boolean;\n variation?: string;\n};\n\nexport type UpdateProposedNamesResult = {\n results: Record<string, { proposedNames?: string[]; error?: unknown }>;\n};\n\nexport type SetNameRequest = {\n value: string;\n type: NameType;\n name: string | null;\n sourceId?: string;\n variation?: string;\n origin?: NameOrigin;\n};\n\n/**\n * Controller for storing and deriving names for values such as Ethereum addresses.\n */\nexport class NameController extends BaseController<\n typeof controllerName,\n NameControllerState,\n NameControllerMessenger\n> {\n readonly #providers: NameProvider[];\n\n readonly #updateDelay: number;\n\n /**\n * Construct a Name controller.\n *\n * @param options - Controller options.\n * @param options.messenger - Restricted messenger for the name controller.\n * @param options.providers - Array of name provider instances to propose names.\n * @param options.state - Initial state to set on the controller.\n * @param options.updateDelay - The delay in seconds before a new request to a source should be made.\n */\n constructor({\n messenger,\n providers,\n state,\n updateDelay,\n }: NameControllerOptions) {\n super({\n name: controllerName,\n metadata: stateMetadata,\n messenger,\n state: { ...getDefaultState(), ...state },\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n\n this.#providers = providers;\n this.#updateDelay = updateDelay ?? DEFAULT_UPDATE_DELAY;\n }\n\n /**\n * Set the user specified name for a value.\n *\n * @param request - Request object.\n * @param request.name - Name to set.\n * @param request.sourceId - Optional ID of the source of the proposed name.\n * @param request.type - Type of value to set the name for.\n * @param request.value - Value to set the name for.\n * @param request.variation - Variation of the raw value to set the name for. The chain ID if the type is Ethereum address.\n */\n setName(request: SetNameRequest) {\n this.#validateSetNameRequest(request);\n\n const {\n value,\n type,\n name,\n sourceId: requestSourceId,\n origin: requestOrigin,\n variation,\n } = request;\n const sourceId = requestSourceId ?? null;\n // If the name is being cleared, the fallback origin should be cleared as well.\n const fallbackOrigin = name === null ? null : NameOrigin.API;\n const origin = requestOrigin ?? fallbackOrigin;\n\n this.#updateEntry(value, type, variation, (entry: NameEntry) => {\n entry.name = name;\n entry.sourceId = sourceId;\n entry.origin = origin;\n });\n }\n\n /**\n * Generate the proposed names for a value using the name providers and store them in the state.\n *\n * @param request - Request object.\n * @param request.value - Value to update the proposed names for.\n * @param request.type - Type of value to update the proposed names for.\n * @param request.sourceIds - Optional array of source IDs to limit which sources are used by the providers. If not provided, all sources in all providers will be used.\n * @param request.variation - Variation of the raw value to update proposed names for. The chain ID if the type is Ethereum address.\n * @returns The updated proposed names for the value.\n */\n async updateProposedNames(\n request: UpdateProposedNamesRequest,\n ): Promise<UpdateProposedNamesResult> {\n this.#validateUpdateProposedNamesRequest(request);\n\n const providerResponses = (\n await Promise.all(\n this.#providers.map((provider) =>\n this.#getProviderResponse(request, provider),\n ),\n )\n ).filter((response) => Boolean(response)) as NameProviderResult[];\n\n this.#updateProposedNameState(request, providerResponses);\n this.#updateSourceState(this.#providers);\n this.#removeExpiredEntries();\n\n return this.#getUpdateProposedNamesResult(providerResponses);\n }\n\n #updateProposedNameState(\n request: UpdateProposedNamesRequest,\n providerResponses: NameProviderResult[],\n ) {\n const { value, type, variation } = request;\n const currentTime = this.#getCurrentTimeSeconds();\n\n this.#updateEntry(value, type, variation, (entry: NameEntry) => {\n this.#removeDormantProposedNames(entry.proposedNames, type);\n\n for (const providerResponse of providerResponses) {\n const { results } = providerResponse;\n\n for (const sourceId of Object.keys(providerResponse.results)) {\n const result = results[sourceId];\n const { proposedNames, updateDelay } = result;\n\n const proposedNameEntry = entry.proposedNames[sourceId] ?? {\n proposedNames: [],\n lastRequestTime: null,\n updateDelay: null,\n };\n\n entry.proposedNames[sourceId] = proposedNameEntry;\n\n if (proposedNames) {\n proposedNameEntry.proposedNames = proposedNames;\n }\n\n proposedNameEntry.lastRequestTime = currentTime;\n proposedNameEntry.updateDelay = updateDelay ?? null;\n }\n }\n });\n }\n\n #updateSourceState(providers: NameProvider[]) {\n const newNameSources = { ...this.state.nameSources };\n\n for (const provider of providers) {\n const { sourceLabels } = provider.getMetadata();\n\n for (const sourceId of Object.keys(sourceLabels)) {\n newNameSources[sourceId] = {\n label: sourceLabels[sourceId],\n };\n }\n }\n\n this.update((state) => {\n state.nameSources = newNameSources;\n });\n }\n\n #getUpdateProposedNamesResult(\n providerResponses: NameProviderResult[],\n ): UpdateProposedNamesResult {\n return providerResponses.reduce(\n (acc: UpdateProposedNamesResult, providerResponse) => {\n const { results } = providerResponse;\n\n for (const sourceId of Object.keys(results)) {\n const { proposedNames, error } = results[sourceId];\n\n acc.results[sourceId] = {\n proposedNames,\n error,\n };\n }\n\n return acc;\n },\n { results: {} },\n );\n }\n\n async #getProviderResponse(\n request: UpdateProposedNamesRequest,\n provider: NameProvider,\n ): Promise<NameProviderResult | undefined> {\n const {\n value,\n type,\n sourceIds: requestedSourceIds,\n onlyUpdateAfterDelay,\n variation,\n } = request;\n\n /* istanbul ignore next */\n const variationKey = variation ?? DEFAULT_VARIATION;\n const supportedSourceIds = this.#getSourceIds(provider, type);\n const currentTime = this.#getCurrentTimeSeconds();\n const normalizedValue = this.#normalizeValue(value, type);\n\n const matchingSourceIds = supportedSourceIds.filter((sourceId) => {\n if (requestedSourceIds && !requestedSourceIds.includes(sourceId)) {\n return false;\n }\n\n if (onlyUpdateAfterDelay) {\n const entry =\n this.state.names[type]?.[normalizedValue]?.[variationKey] ?? {};\n const proposedNamesEntry = entry.proposedNames?.[sourceId] ?? {};\n const lastRequestTime = proposedNamesEntry.lastRequestTime ?? 0;\n const updateDelay = proposedNamesEntry.updateDelay ?? this.#updateDelay;\n\n if (currentTime - lastRequestTime < updateDelay) {\n return false;\n }\n }\n\n return true;\n });\n\n if (!matchingSourceIds.length) {\n return undefined;\n }\n\n const providerRequest: NameProviderRequest = {\n value: this.#normalizeValue(value, type),\n type,\n sourceIds: requestedSourceIds ? matchingSourceIds : undefined,\n variation: this.#normalizeVariation(variationKey, type),\n };\n\n let responseError: unknown | undefined;\n let response: NameProviderResult | undefined;\n\n try {\n response = await provider.getProposedNames(providerRequest);\n responseError = response.error;\n } catch (error) {\n responseError = error;\n }\n\n return this.#normalizeProviderResult(\n response,\n responseError,\n matchingSourceIds,\n );\n }\n\n #normalizeProviderResult(\n result: NameProviderResult | undefined,\n responseError: unknown,\n matchingSourceIds: string[],\n ): NameProviderResult {\n const error = responseError ?? undefined;\n\n const results = matchingSourceIds.reduce((acc, sourceId) => {\n const sourceResult = result?.results?.[sourceId];\n\n const normalizedSourceResult = this.#normalizeProviderSourceResult(\n sourceResult,\n responseError,\n );\n\n return {\n ...acc,\n [sourceId]: normalizedSourceResult,\n };\n }, {});\n\n return { results, error };\n }\n\n #normalizeProviderSourceResult(\n result: NameProviderSourceResult | undefined,\n responseError: unknown,\n ): NameProviderSourceResult | undefined {\n const error = result?.error ?? responseError ?? undefined;\n const updateDelay = result?.updateDelay ?? undefined;\n let proposedNames = error\n ? undefined\n : (result?.proposedNames ?? undefined);\n\n if (proposedNames) {\n proposedNames = proposedNames.filter(\n (proposedName) => proposedName?.length,\n );\n }\n\n return {\n proposedNames,\n error,\n updateDelay,\n };\n }\n\n #normalizeValue(value: string, type: NameType): string {\n /* istanbul ignore next */\n switch (type) {\n case NameType.ETHEREUM_ADDRESS:\n return value.toLowerCase();\n\n default:\n return value;\n }\n }\n\n #normalizeVariation(variation: string, type: NameType): string {\n /* istanbul ignore next */\n switch (type) {\n case NameType.ETHEREUM_ADDRESS:\n return variation.toLowerCase();\n\n default:\n return variation;\n }\n }\n\n #updateEntry(\n value: string,\n type: NameType,\n variation: string | undefined,\n callback: (entry: NameEntry) => void,\n ) {\n /* istanbul ignore next */\n const variationKey = variation ?? DEFAULT_VARIATION;\n const normalizedValue = this.#normalizeValue(value, type);\n const normalizedVariation = this.#normalizeVariation(variationKey, type);\n\n if (\n [normalizedValue, normalizedVariation].some(\n (key) => !isSafeDynamicKey(key),\n )\n ) {\n return;\n }\n\n this.update((state) => {\n const typeEntries = state.names[type] || {};\n state.names[type] = typeEntries;\n\n const variationEntries = typeEntries[normalizedValue] || {};\n typeEntries[normalizedValue] = variationEntries;\n\n const entry = variationEntries[normalizedVariation] ?? {\n proposedNames: {},\n name: null,\n sourceId: null,\n origin: null,\n };\n variationEntries[normalizedVariation] = entry;\n\n callback(entry);\n });\n }\n\n #getCurrentTimeSeconds(): number {\n return Math.round(Date.now() / 1000);\n }\n\n #validateSetNameRequest(request: SetNameRequest) {\n const { name, value, type, sourceId, variation, origin } = request;\n const errorMessages: string[] = [];\n\n this.#validateValue(value, errorMessages);\n this.#validateType(type, errorMessages);\n this.#validateName(name, errorMessages);\n this.#validateSourceId(sourceId, type, name, errorMessages);\n this.#validateVariation(variation, type, errorMessages);\n this.#validateOrigin(origin, name, errorMessages);\n\n if (errorMessages.length) {\n throw new Error(errorMessages.join(' '));\n }\n }\n\n #validateUpdateProposedNamesRequest(request: UpdateProposedNamesRequest) {\n const { value, type, sourceIds, variation } = request;\n const errorMessages: string[] = [];\n\n this.#validateValue(value, errorMessages);\n this.#validateType(type, errorMessages);\n this.#validateSourceIds(sourceIds, type, errorMessages);\n this.#validateDuplicateSourceIds(type, errorMessages);\n this.#validateVariation(variation, type, errorMessages);\n\n if (errorMessages.length) {\n throw new Error(errorMessages.join(' '));\n }\n }\n\n #validateValue(value: string, errorMessages: string[]) {\n if (!value?.length || typeof value !== 'string') {\n errorMessages.push('Must specify a non-empty string for value.');\n }\n }\n\n #validateType(type: NameType, errorMessages: string[]) {\n if (!Object.values(NameType).includes(type)) {\n errorMessages.push(\n `Must specify one of the following types: ${Object.values(\n NameType,\n ).join(', ')}`,\n );\n }\n }\n\n #validateName(name: string | null, errorMessages: string[]) {\n if (name === null) {\n return;\n }\n\n if (!name?.length || typeof name !== 'string') {\n errorMessages.push('Must specify a non-empty string or null for name.');\n }\n }\n\n #validateSourceIds(\n sourceIds: string[] | undefined,\n type: NameType,\n errorMessages: string[],\n ) {\n if (!sourceIds) {\n return;\n }\n\n const allSourceIds = this.#getAllSourceIds(type);\n const missingSourceIds = [];\n\n for (const sourceId of sourceIds) {\n if (!allSourceIds.includes(sourceId)) {\n missingSourceIds.push(sourceId);\n continue;\n }\n }\n\n if (missingSourceIds.length) {\n errorMessages.push(\n `Unknown source IDs for type '${type}': ${missingSourceIds.join(', ')}`,\n );\n }\n }\n\n #validateSourceId(\n sourceId: string | undefined,\n type: NameType,\n name: string | null,\n errorMessages: string[],\n ) {\n if (sourceId === null || sourceId === undefined) {\n return;\n }\n\n if (name === null) {\n errorMessages.push(\n `Cannot specify a source ID when clearing the saved name: ${sourceId}`,\n );\n return;\n }\n\n const allSourceIds = this.#getAllSourceIds(type);\n\n if (!sourceId.length || typeof sourceId !== 'string') {\n errorMessages.push('Must specify a non-empty string for sourceId.');\n return;\n }\n\n if (!allSourceIds.includes(sourceId)) {\n errorMessages.push(`Unknown source ID for type '${type}': ${sourceId}`);\n }\n }\n\n #validateDuplicateSourceIds(type: NameType, errorMessages: string[]) {\n const allSourceIds = this.#getAllSourceIds(type);\n\n const duplicateSourceIds = allSourceIds.filter(\n (sourceId, index) => allSourceIds.indexOf(sourceId) !== index,\n );\n\n if (duplicateSourceIds.length) {\n errorMessages.push(\n `Duplicate source IDs found for type '${type}': ${duplicateSourceIds.join(\n ', ',\n )}`,\n );\n }\n }\n\n #validateVariation(\n variation: string | undefined,\n type: string,\n errorMessages: string[],\n ) {\n if (type !== NameType.ETHEREUM_ADDRESS) {\n return;\n }\n\n if (\n !variation?.length ||\n typeof variation !== 'string' ||\n (!variation.match(/^0x[0-9A-Fa-f]+$/u) &&\n variation !== FALLBACK_VARIATION)\n ) {\n errorMessages.push(\n `Must specify a chain ID in hexadecimal format or the fallback, \"${FALLBACK_VARIATION}\", for variation when using '${type}' type.`,\n );\n }\n }\n\n #validateOrigin(\n origin: NameOrigin | null | undefined,\n name: string | null,\n errorMessages: string[],\n ) {\n if (!origin) {\n return;\n }\n\n if (name === null) {\n errorMessages.push(\n `Cannot specify an origin when clearing the saved name: ${origin}`,\n );\n return;\n }\n\n if (!Object.values(NameOrigin).includes(origin)) {\n errorMessages.push(\n `Must specify one of the following origins: ${Object.values(\n NameOrigin,\n ).join(', ')}`,\n );\n }\n }\n\n #getAllSourceIds(type: NameType): string[] {\n return (\n this.#providers\n /* istanbul ignore next */\n .map((provider) => this.#getSourceIds(provider, type))\n .flat()\n );\n }\n\n #getSourceIds(provider: NameProvider, type: NameType): string[] {\n return provider.getMetadata().sourceIds[type];\n }\n\n #removeDormantProposedNames(\n proposedNames: Record<string, ProposedNamesEntry>,\n type: NameType,\n ) {\n if (Object.keys(proposedNames).length === 0) {\n return;\n }\n\n const typeSourceIds = this.#getAllSourceIds(type);\n\n const dormantSourceIds = Object.keys(proposedNames).filter(\n (sourceId) => !typeSourceIds.includes(sourceId),\n );\n\n for (const dormantSourceId of dormantSourceIds) {\n delete proposedNames[dormantSourceId];\n }\n }\n\n #removeExpiredEntries(): void {\n const currentTime = this.#getCurrentTimeSeconds();\n\n this.update((state: NameControllerState) => {\n const entries = this.#getEntriesList(state);\n for (const { nameType, value, variation, entry } of entries) {\n if (entry.name !== null) {\n continue;\n }\n\n const proposedNames = Object.values(entry.proposedNames);\n const allProposedNamesExpired = proposedNames.every(\n (proposedName: ProposedNamesEntry) =>\n currentTime - (proposedName.lastRequestTime ?? 0) >=\n PROPOSED_NAME_EXPIRE_DURATION,\n );\n\n if (allProposedNamesExpired) {\n delete state.names[nameType][value][variation];\n }\n }\n });\n }\n\n #getEntriesList(state: NameControllerState): {\n nameType: NameType;\n value: string;\n variation: string;\n entry: NameEntry;\n }[] {\n return Object.entries(state.names).flatMap(([type, typeEntries]) =>\n Object.entries(typeEntries).flatMap(([value, variationEntries]) =>\n Object.entries(variationEntries).map(([variation, entry]) => ({\n entry,\n nameType: type as NameType,\n value,\n variation,\n })),\n ),\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"NameController.mjs","sourceRoot":"","sources":["../src/NameController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,mCAAmC;AAU9D,OAAO,EAAE,QAAQ,EAAE,oBAAmB;AAEtC,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AACtC,MAAM,CAAC,MAAM,6BAA6B,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,WAAW;AAEtE;;GAEG;AACH,MAAM,CAAN,IAAY,UASX;AATD,WAAY,UAAU;IACpB,uCAAuC;IACvC,mDAAqC,CAAA;IACrC,yCAAyC;IACzC,2CAA6B,CAAA;IAC7B,yEAAyE;IACzE,yBAAW,CAAA;IACX,oDAAoD;IACpD,uBAAS,CAAA;AACX,CAAC,EATW,UAAU,KAAV,UAAU,QASrB;AAED,MAAM,oBAAoB,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,YAAY;AACjD,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAExC,MAAM,yBAAyB,GAAG,CAAC,SAAS,EAAE,qBAAqB,CAAU,CAAC;AAE9E,MAAM,aAAa,GAAG;IACpB,KAAK,EAAE;QACL,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,IAAI;KACf;IACD,WAAW,EAAE;QACX,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,IAAI;KACf;CACF,CAAC;AAEF,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,CAAC;IAC7B,KAAK,EAAE;QAC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,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,OAAO,EAAE,CAAC;YAC5D,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;gBACxB,SAAS;YACX,CAAC;YAED,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;YACzD,MAAM,uBAAuB,GAAG,aAAa,CAAC,KAAK,CACjD,CAAC,YAAgC,EAAE,EAAE,CACnC,WAAW,GAAG,CAAC,YAAY,CAAC,eAAe,IAAI,CAAC,CAAC;gBACjD,6BAA6B,CAChC,CAAC;YAEF,IAAI,uBAAuB,EAAE,CAAC;gBAC5B,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,2EAEe,KAA0B;IAMxC,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,EAAE,CACjE,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,gBAAgB,CAAC,EAAE,EAAE,CAChE,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;QAC5D,KAAK;QACL,QAAQ,EAAE,IAAgB;QAC1B,KAAK;QACL,SAAS;KACV,CAAC,CAAC,CACJ,CACF,CAAC;AACJ,CAAC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport { isSafeDynamicKey } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\n\nimport type { NameControllerMethodActions } from './NameController-method-action-types.js';\nimport type {\n NameProvider,\n NameProviderRequest,\n NameProviderResult,\n NameProviderSourceResult,\n} from './types.js';\nimport { NameType } from './types.js';\n\nexport const FALLBACK_VARIATION = '*';\nexport const PROPOSED_NAME_EXPIRE_DURATION = 60 * 60 * 24; // 24 hours\n\n/**\n * Enumerates the possible origins responsible for setting a petname.\n */\nexport enum NameOrigin {\n // Originated from an account identity.\n ACCOUNT_IDENTITY = 'account-identity',\n // Originated from an address book entry.\n ADDRESS_BOOK = 'address-book',\n // Originated from the API (NameController.setName). This is the default.\n API = 'api',\n // Originated from the user taking action in the UI.\n UI = 'ui',\n}\n\nconst DEFAULT_UPDATE_DELAY = 60 * 2; // 2 Minutes\nconst DEFAULT_VARIATION = '';\n\nconst controllerName = 'NameController';\n\nconst MESSENGER_EXPOSED_METHODS = ['setName', 'updateProposedNames'] as const;\n\nconst stateMetadata = {\n names: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n nameSources: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n};\n\nconst getDefaultState = () => ({\n names: {\n [NameType.ETHEREUM_ADDRESS]: {},\n },\n nameSources: {},\n});\n\nexport type ProposedNamesEntry = {\n proposedNames: string[];\n lastRequestTime: number | null;\n updateDelay: number | null;\n};\n\nexport type NameEntry = {\n name: string | null;\n sourceId: string | null;\n origin: NameOrigin | null;\n proposedNames: Record<string, ProposedNamesEntry>;\n};\n\nexport type SourceEntry = {\n label: string;\n};\n\nexport type NameControllerState = {\n // Type > Value > Variation > Entry\n names: Record<NameType, Record<string, Record<string, NameEntry>>>;\n nameSources: Record<string, SourceEntry>;\n};\n\nexport type GetNameState = ControllerGetStateAction<\n typeof controllerName,\n NameControllerState\n>;\n\nexport type NameStateChange = ControllerStateChangeEvent<\n typeof controllerName,\n NameControllerState\n>;\n\nexport type NameControllerActions = GetNameState | NameControllerMethodActions;\n\nexport type NameControllerEvents = NameStateChange;\n\nexport type NameControllerMessenger = Messenger<\n typeof controllerName,\n NameControllerActions,\n NameControllerEvents\n>;\n\nexport type NameControllerOptions = {\n messenger: NameControllerMessenger;\n providers: NameProvider[];\n state?: Partial<NameControllerState>;\n updateDelay?: number;\n};\n\nexport type UpdateProposedNamesRequest = {\n value: string;\n type: NameType;\n sourceIds?: string[];\n onlyUpdateAfterDelay?: boolean;\n variation?: string;\n};\n\nexport type UpdateProposedNamesResult = {\n results: Record<string, { proposedNames?: string[]; error?: unknown }>;\n};\n\nexport type SetNameRequest = {\n value: string;\n type: NameType;\n name: string | null;\n sourceId?: string;\n variation?: string;\n origin?: NameOrigin;\n};\n\n/**\n * Controller for storing and deriving names for values such as Ethereum addresses.\n */\nexport class NameController extends BaseController<\n typeof controllerName,\n NameControllerState,\n NameControllerMessenger\n> {\n readonly #providers: NameProvider[];\n\n readonly #updateDelay: number;\n\n /**\n * Construct a Name controller.\n *\n * @param options - Controller options.\n * @param options.messenger - Restricted messenger for the name controller.\n * @param options.providers - Array of name provider instances to propose names.\n * @param options.state - Initial state to set on the controller.\n * @param options.updateDelay - The delay in seconds before a new request to a source should be made.\n */\n constructor({\n messenger,\n providers,\n state,\n updateDelay,\n }: NameControllerOptions) {\n super({\n name: controllerName,\n metadata: stateMetadata,\n messenger,\n state: { ...getDefaultState(), ...state },\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n\n this.#providers = providers;\n this.#updateDelay = updateDelay ?? DEFAULT_UPDATE_DELAY;\n }\n\n /**\n * Set the user specified name for a value.\n *\n * @param request - Request object.\n * @param request.name - Name to set.\n * @param request.sourceId - Optional ID of the source of the proposed name.\n * @param request.type - Type of value to set the name for.\n * @param request.value - Value to set the name for.\n * @param request.variation - Variation of the raw value to set the name for. The chain ID if the type is Ethereum address.\n */\n setName(request: SetNameRequest) {\n this.#validateSetNameRequest(request);\n\n const {\n value,\n type,\n name,\n sourceId: requestSourceId,\n origin: requestOrigin,\n variation,\n } = request;\n const sourceId = requestSourceId ?? null;\n // If the name is being cleared, the fallback origin should be cleared as well.\n const fallbackOrigin = name === null ? null : NameOrigin.API;\n const origin = requestOrigin ?? fallbackOrigin;\n\n this.#updateEntry(value, type, variation, (entry: NameEntry) => {\n entry.name = name;\n entry.sourceId = sourceId;\n entry.origin = origin;\n });\n }\n\n /**\n * Generate the proposed names for a value using the name providers and store them in the state.\n *\n * @param request - Request object.\n * @param request.value - Value to update the proposed names for.\n * @param request.type - Type of value to update the proposed names for.\n * @param request.sourceIds - Optional array of source IDs to limit which sources are used by the providers. If not provided, all sources in all providers will be used.\n * @param request.variation - Variation of the raw value to update proposed names for. The chain ID if the type is Ethereum address.\n * @returns The updated proposed names for the value.\n */\n async updateProposedNames(\n request: UpdateProposedNamesRequest,\n ): Promise<UpdateProposedNamesResult> {\n this.#validateUpdateProposedNamesRequest(request);\n\n const providerResponses = (\n await Promise.all(\n this.#providers.map((provider) =>\n this.#getProviderResponse(request, provider),\n ),\n )\n ).filter((response) => Boolean(response)) as NameProviderResult[];\n\n this.#updateProposedNameState(request, providerResponses);\n this.#updateSourceState(this.#providers);\n this.#removeExpiredEntries();\n\n return this.#getUpdateProposedNamesResult(providerResponses);\n }\n\n #updateProposedNameState(\n request: UpdateProposedNamesRequest,\n providerResponses: NameProviderResult[],\n ) {\n const { value, type, variation } = request;\n const currentTime = this.#getCurrentTimeSeconds();\n\n this.#updateEntry(value, type, variation, (entry: NameEntry) => {\n this.#removeDormantProposedNames(entry.proposedNames, type);\n\n for (const providerResponse of providerResponses) {\n const { results } = providerResponse;\n\n for (const sourceId of Object.keys(providerResponse.results)) {\n const result = results[sourceId];\n const { proposedNames, updateDelay } = result;\n\n const proposedNameEntry = entry.proposedNames[sourceId] ?? {\n proposedNames: [],\n lastRequestTime: null,\n updateDelay: null,\n };\n\n entry.proposedNames[sourceId] = proposedNameEntry;\n\n if (proposedNames) {\n proposedNameEntry.proposedNames = proposedNames;\n }\n\n proposedNameEntry.lastRequestTime = currentTime;\n proposedNameEntry.updateDelay = updateDelay ?? null;\n }\n }\n });\n }\n\n #updateSourceState(providers: NameProvider[]) {\n const newNameSources = { ...this.state.nameSources };\n\n for (const provider of providers) {\n const { sourceLabels } = provider.getMetadata();\n\n for (const sourceId of Object.keys(sourceLabels)) {\n newNameSources[sourceId] = {\n label: sourceLabels[sourceId],\n };\n }\n }\n\n this.update((state) => {\n state.nameSources = newNameSources;\n });\n }\n\n #getUpdateProposedNamesResult(\n providerResponses: NameProviderResult[],\n ): UpdateProposedNamesResult {\n return providerResponses.reduce(\n (acc: UpdateProposedNamesResult, providerResponse) => {\n const { results } = providerResponse;\n\n for (const sourceId of Object.keys(results)) {\n const { proposedNames, error } = results[sourceId];\n\n acc.results[sourceId] = {\n proposedNames,\n error,\n };\n }\n\n return acc;\n },\n { results: {} },\n );\n }\n\n async #getProviderResponse(\n request: UpdateProposedNamesRequest,\n provider: NameProvider,\n ): Promise<NameProviderResult | undefined> {\n const {\n value,\n type,\n sourceIds: requestedSourceIds,\n onlyUpdateAfterDelay,\n variation,\n } = request;\n\n /* istanbul ignore next */\n const variationKey = variation ?? DEFAULT_VARIATION;\n const supportedSourceIds = this.#getSourceIds(provider, type);\n const currentTime = this.#getCurrentTimeSeconds();\n const normalizedValue = this.#normalizeValue(value, type);\n\n const matchingSourceIds = supportedSourceIds.filter((sourceId) => {\n if (requestedSourceIds && !requestedSourceIds.includes(sourceId)) {\n return false;\n }\n\n if (onlyUpdateAfterDelay) {\n const entry =\n this.state.names[type]?.[normalizedValue]?.[variationKey] ?? {};\n const proposedNamesEntry = entry.proposedNames?.[sourceId] ?? {};\n const lastRequestTime = proposedNamesEntry.lastRequestTime ?? 0;\n const updateDelay = proposedNamesEntry.updateDelay ?? this.#updateDelay;\n\n if (currentTime - lastRequestTime < updateDelay) {\n return false;\n }\n }\n\n return true;\n });\n\n if (!matchingSourceIds.length) {\n return undefined;\n }\n\n const providerRequest: NameProviderRequest = {\n value: this.#normalizeValue(value, type),\n type,\n sourceIds: requestedSourceIds ? matchingSourceIds : undefined,\n variation: this.#normalizeVariation(variationKey, type),\n };\n\n let responseError: unknown | undefined;\n let response: NameProviderResult | undefined;\n\n try {\n response = await provider.getProposedNames(providerRequest);\n responseError = response.error;\n } catch (error) {\n responseError = error;\n }\n\n return this.#normalizeProviderResult(\n response,\n responseError,\n matchingSourceIds,\n );\n }\n\n #normalizeProviderResult(\n result: NameProviderResult | undefined,\n responseError: unknown,\n matchingSourceIds: string[],\n ): NameProviderResult {\n const error = responseError ?? undefined;\n\n const results = matchingSourceIds.reduce((acc, sourceId) => {\n const sourceResult = result?.results?.[sourceId];\n\n const normalizedSourceResult = this.#normalizeProviderSourceResult(\n sourceResult,\n responseError,\n );\n\n return {\n ...acc,\n [sourceId]: normalizedSourceResult,\n };\n }, {});\n\n return { results, error };\n }\n\n #normalizeProviderSourceResult(\n result: NameProviderSourceResult | undefined,\n responseError: unknown,\n ): NameProviderSourceResult | undefined {\n const error = result?.error ?? responseError ?? undefined;\n const updateDelay = result?.updateDelay ?? undefined;\n let proposedNames = error\n ? undefined\n : (result?.proposedNames ?? undefined);\n\n if (proposedNames) {\n proposedNames = proposedNames.filter(\n (proposedName) => proposedName?.length,\n );\n }\n\n return {\n proposedNames,\n error,\n updateDelay,\n };\n }\n\n #normalizeValue(value: string, type: NameType): string {\n /* istanbul ignore next */\n switch (type) {\n case NameType.ETHEREUM_ADDRESS:\n return value.toLowerCase();\n\n default:\n return value;\n }\n }\n\n #normalizeVariation(variation: string, type: NameType): string {\n /* istanbul ignore next */\n switch (type) {\n case NameType.ETHEREUM_ADDRESS:\n return variation.toLowerCase();\n\n default:\n return variation;\n }\n }\n\n #updateEntry(\n value: string,\n type: NameType,\n variation: string | undefined,\n callback: (entry: NameEntry) => void,\n ) {\n /* istanbul ignore next */\n const variationKey = variation ?? DEFAULT_VARIATION;\n const normalizedValue = this.#normalizeValue(value, type);\n const normalizedVariation = this.#normalizeVariation(variationKey, type);\n\n if (\n [normalizedValue, normalizedVariation].some(\n (key) => !isSafeDynamicKey(key),\n )\n ) {\n return;\n }\n\n this.update((state) => {\n const typeEntries = state.names[type] || {};\n state.names[type] = typeEntries;\n\n const variationEntries = typeEntries[normalizedValue] || {};\n typeEntries[normalizedValue] = variationEntries;\n\n const entry = variationEntries[normalizedVariation] ?? {\n proposedNames: {},\n name: null,\n sourceId: null,\n origin: null,\n };\n variationEntries[normalizedVariation] = entry;\n\n callback(entry);\n });\n }\n\n #getCurrentTimeSeconds(): number {\n return Math.round(Date.now() / 1000);\n }\n\n #validateSetNameRequest(request: SetNameRequest) {\n const { name, value, type, sourceId, variation, origin } = request;\n const errorMessages: string[] = [];\n\n this.#validateValue(value, errorMessages);\n this.#validateType(type, errorMessages);\n this.#validateName(name, errorMessages);\n this.#validateSourceId(sourceId, type, name, errorMessages);\n this.#validateVariation(variation, type, errorMessages);\n this.#validateOrigin(origin, name, errorMessages);\n\n if (errorMessages.length) {\n throw new Error(errorMessages.join(' '));\n }\n }\n\n #validateUpdateProposedNamesRequest(request: UpdateProposedNamesRequest) {\n const { value, type, sourceIds, variation } = request;\n const errorMessages: string[] = [];\n\n this.#validateValue(value, errorMessages);\n this.#validateType(type, errorMessages);\n this.#validateSourceIds(sourceIds, type, errorMessages);\n this.#validateDuplicateSourceIds(type, errorMessages);\n this.#validateVariation(variation, type, errorMessages);\n\n if (errorMessages.length) {\n throw new Error(errorMessages.join(' '));\n }\n }\n\n #validateValue(value: string, errorMessages: string[]) {\n if (!value?.length || typeof value !== 'string') {\n errorMessages.push('Must specify a non-empty string for value.');\n }\n }\n\n #validateType(type: NameType, errorMessages: string[]) {\n if (!Object.values(NameType).includes(type)) {\n errorMessages.push(\n `Must specify one of the following types: ${Object.values(\n NameType,\n ).join(', ')}`,\n );\n }\n }\n\n #validateName(name: string | null, errorMessages: string[]) {\n if (name === null) {\n return;\n }\n\n if (!name?.length || typeof name !== 'string') {\n errorMessages.push('Must specify a non-empty string or null for name.');\n }\n }\n\n #validateSourceIds(\n sourceIds: string[] | undefined,\n type: NameType,\n errorMessages: string[],\n ) {\n if (!sourceIds) {\n return;\n }\n\n const allSourceIds = this.#getAllSourceIds(type);\n const missingSourceIds = [];\n\n for (const sourceId of sourceIds) {\n if (!allSourceIds.includes(sourceId)) {\n missingSourceIds.push(sourceId);\n continue;\n }\n }\n\n if (missingSourceIds.length) {\n errorMessages.push(\n `Unknown source IDs for type '${type}': ${missingSourceIds.join(', ')}`,\n );\n }\n }\n\n #validateSourceId(\n sourceId: string | undefined,\n type: NameType,\n name: string | null,\n errorMessages: string[],\n ) {\n if (sourceId === null || sourceId === undefined) {\n return;\n }\n\n if (name === null) {\n errorMessages.push(\n `Cannot specify a source ID when clearing the saved name: ${sourceId}`,\n );\n return;\n }\n\n const allSourceIds = this.#getAllSourceIds(type);\n\n if (!sourceId.length || typeof sourceId !== 'string') {\n errorMessages.push('Must specify a non-empty string for sourceId.');\n return;\n }\n\n if (!allSourceIds.includes(sourceId)) {\n errorMessages.push(`Unknown source ID for type '${type}': ${sourceId}`);\n }\n }\n\n #validateDuplicateSourceIds(type: NameType, errorMessages: string[]) {\n const allSourceIds = this.#getAllSourceIds(type);\n\n const duplicateSourceIds = allSourceIds.filter(\n (sourceId, index) => allSourceIds.indexOf(sourceId) !== index,\n );\n\n if (duplicateSourceIds.length) {\n errorMessages.push(\n `Duplicate source IDs found for type '${type}': ${duplicateSourceIds.join(\n ', ',\n )}`,\n );\n }\n }\n\n #validateVariation(\n variation: string | undefined,\n type: string,\n errorMessages: string[],\n ) {\n if (type !== NameType.ETHEREUM_ADDRESS) {\n return;\n }\n\n if (\n !variation?.length ||\n typeof variation !== 'string' ||\n (!variation.match(/^0x[0-9A-Fa-f]+$/u) &&\n variation !== FALLBACK_VARIATION)\n ) {\n errorMessages.push(\n `Must specify a chain ID in hexadecimal format or the fallback, \"${FALLBACK_VARIATION}\", for variation when using '${type}' type.`,\n );\n }\n }\n\n #validateOrigin(\n origin: NameOrigin | null | undefined,\n name: string | null,\n errorMessages: string[],\n ) {\n if (!origin) {\n return;\n }\n\n if (name === null) {\n errorMessages.push(\n `Cannot specify an origin when clearing the saved name: ${origin}`,\n );\n return;\n }\n\n if (!Object.values(NameOrigin).includes(origin)) {\n errorMessages.push(\n `Must specify one of the following origins: ${Object.values(\n NameOrigin,\n ).join(', ')}`,\n );\n }\n }\n\n #getAllSourceIds(type: NameType): string[] {\n return (\n this.#providers\n /* istanbul ignore next */\n .map((provider) => this.#getSourceIds(provider, type))\n .flat()\n );\n }\n\n #getSourceIds(provider: NameProvider, type: NameType): string[] {\n return provider.getMetadata().sourceIds[type];\n }\n\n #removeDormantProposedNames(\n proposedNames: Record<string, ProposedNamesEntry>,\n type: NameType,\n ) {\n if (Object.keys(proposedNames).length === 0) {\n return;\n }\n\n const typeSourceIds = this.#getAllSourceIds(type);\n\n const dormantSourceIds = Object.keys(proposedNames).filter(\n (sourceId) => !typeSourceIds.includes(sourceId),\n );\n\n for (const dormantSourceId of dormantSourceIds) {\n delete proposedNames[dormantSourceId];\n }\n }\n\n #removeExpiredEntries(): void {\n const currentTime = this.#getCurrentTimeSeconds();\n\n this.update((state: NameControllerState) => {\n const entries = this.#getEntriesList(state);\n for (const { nameType, value, variation, entry } of entries) {\n if (entry.name !== null) {\n continue;\n }\n\n const proposedNames = Object.values(entry.proposedNames);\n const allProposedNamesExpired = proposedNames.every(\n (proposedName: ProposedNamesEntry) =>\n currentTime - (proposedName.lastRequestTime ?? 0) >=\n PROPOSED_NAME_EXPIRE_DURATION,\n );\n\n if (allProposedNamesExpired) {\n delete state.names[nameType][value][variation];\n }\n }\n });\n }\n\n #getEntriesList(state: NameControllerState): {\n nameType: NameType;\n value: string;\n variation: string;\n entry: NameEntry;\n }[] {\n return Object.entries(state.names).flatMap(([type, typeEntries]) =>\n Object.entries(typeEntries).flatMap(([value, variationEntries]) =>\n Object.entries(variationEntries).map(([variation, entry]) => ({\n entry,\n nameType: type as NameType,\n value,\n variation,\n })),\n ),\n );\n }\n}\n"]}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAoC;AAKpC,8CAA2B;AAC3B,sDAAmC;AACnC,4DAAyC;AACzC,wDAAqC;AACrC,uDAAoC","sourcesContent":["export * from './NameController.js';\nexport type {\n NameControllerSetNameAction,\n NameControllerUpdateProposedNamesAction,\n} from './NameController-method-action-types.js';\nexport * from './types.js';\nexport * from './providers/ens.js';\nexport * from './providers/etherscan.js';\nexport * from './providers/token.js';\nexport * from './providers/lens.js';\n"]}
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qCAAoC;AACpC,YAAY,EACV,2BAA2B,EAC3B,uCAAuC,GACxC,iDAAgD;AACjD,4BAA2B;AAC3B,oCAAmC;AACnC,0CAAyC;AACzC,sCAAqC;AACrC,qCAAoC"}
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qCAAoC;AACpC,YAAY,EACV,2BAA2B,EAC3B,uCAAuC,GACxC,iDAAgD;AACjD,4BAA2B;AAC3B,oCAAmC;AACnC,0CAAyC;AACzC,sCAAqC;AACrC,qCAAoC"}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qCAAoC;AAKpC,4BAA2B;AAC3B,oCAAmC;AACnC,0CAAyC;AACzC,sCAAqC;AACrC,qCAAoC","sourcesContent":["export * from './NameController.js';\nexport type {\n NameControllerSetNameAction,\n NameControllerUpdateProposedNamesAction,\n} from './NameController-method-action-types.js';\nexport * from './types.js';\nexport * from './providers/ens.js';\nexport * from './providers/etherscan.js';\nexport * from './providers/token.js';\nexport * from './providers/lens.js';\n"]}
|
package/dist/providers/ens.cjs
CHANGED
|
@@ -13,11 +13,11 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var _ENSNameProvider_isEnabled, _ENSNameProvider_reverseLookup;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.ENSNameProvider = void 0;
|
|
16
|
-
const
|
|
17
|
-
const
|
|
16
|
+
const logger_js_1 = require("../logger.cjs");
|
|
17
|
+
const types_js_1 = require("../types.cjs");
|
|
18
18
|
const ID = 'ens';
|
|
19
19
|
const LABEL = 'Ethereum Name Service (ENS)';
|
|
20
|
-
const log = (0,
|
|
20
|
+
const log = (0, logger_js_1.createModuleLogger)(logger_js_1.projectLogger, 'ens');
|
|
21
21
|
class ENSNameProvider {
|
|
22
22
|
constructor({ isEnabled, reverseLookup, }) {
|
|
23
23
|
_ENSNameProvider_isEnabled.set(this, void 0);
|
|
@@ -27,7 +27,7 @@ class ENSNameProvider {
|
|
|
27
27
|
}
|
|
28
28
|
getMetadata() {
|
|
29
29
|
return {
|
|
30
|
-
sourceIds: { [
|
|
30
|
+
sourceIds: { [types_js_1.NameType.ETHEREUM_ADDRESS]: [ID] },
|
|
31
31
|
sourceLabels: { [ID]: LABEL },
|
|
32
32
|
};
|
|
33
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ens.cjs","sourceRoot":"","sources":["../../src/providers/ens.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"ens.cjs","sourceRoot":"","sources":["../../src/providers/ens.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAAiE;AAOjE,2CAAuC;AAOvC,MAAM,EAAE,GAAG,KAAK,CAAC;AACjB,MAAM,KAAK,GAAG,6BAA6B,CAAC;AAE5C,MAAM,GAAG,GAAG,IAAA,8BAAkB,EAAC,yBAAa,EAAE,KAAK,CAAC,CAAC;AAErD,MAAa,eAAe;IAK1B,YAAY,EACV,SAAS,EACT,aAAa,GAId;QAVQ,6CAA0B;QAE1B,iDAAsC;QAS7C,uBAAA,IAAI,8BAAc,SAAS,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAA,CAAC;QAC5C,uBAAA,IAAI,kCAAkB,aAAa,MAAA,CAAC;IACtC,CAAC;IAED,WAAW;QACT,OAAO;YACL,SAAS,EAAE,EAAE,CAAC,mBAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;YAChD,YAAY,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE;SAC9B,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,gBAAgB,CACpB,OAA4B;QAE5B,IAAI,CAAC,uBAAA,IAAI,kCAAW,MAAf,IAAI,CAAa,EAAE,CAAC;YACvB,GAAG,CAAC,8BAA8B,CAAC,CAAC;YAEpC,OAAO;gBACL,OAAO,EAAE;oBACP,CAAC,EAAE,CAAC,EAAE;wBACJ,aAAa,EAAE,EAAE;qBAClB;iBACF;aACF,CAAC;QACJ,CAAC;QAED,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QAE9C,GAAG,CAAC,mBAAmB,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QAE7C,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,MAAM,uBAAA,IAAI,sCAAe,MAAnB,IAAI,EAAgB,KAAK,EAAE,OAAO,CAAC,CAAC;YAC/D,MAAM,aAAa,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAEzD,GAAG,CAAC,oBAAoB,EAAE,aAAa,CAAC,CAAC;YAEzC,OAAO;gBACL,OAAO,EAAE;oBACP,CAAC,EAAE,CAAC,EAAE,EAAE,aAAa,EAAE;iBACxB;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;YAC7B,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AA1DD,0CA0DC","sourcesContent":["import { projectLogger, createModuleLogger } from '../logger.js';\nimport type {\n NameProvider,\n NameProviderMetadata,\n NameProviderRequest,\n NameProviderResult,\n} from '../types.js';\nimport { NameType } from '../types.js';\n\nexport type ReverseLookupCallback = (\n address: string,\n chainId: string,\n) => Promise<string>;\n\nconst ID = 'ens';\nconst LABEL = 'Ethereum Name Service (ENS)';\n\nconst log = createModuleLogger(projectLogger, 'ens');\n\nexport class ENSNameProvider implements NameProvider {\n readonly #isEnabled: () => boolean;\n\n readonly #reverseLookup: ReverseLookupCallback;\n\n constructor({\n isEnabled,\n reverseLookup,\n }: {\n isEnabled?: () => boolean;\n reverseLookup: ReverseLookupCallback;\n }) {\n this.#isEnabled = isEnabled || (() => true);\n this.#reverseLookup = reverseLookup;\n }\n\n getMetadata(): NameProviderMetadata {\n return {\n sourceIds: { [NameType.ETHEREUM_ADDRESS]: [ID] },\n sourceLabels: { [ID]: LABEL },\n };\n }\n\n async getProposedNames(\n request: NameProviderRequest,\n ): Promise<NameProviderResult> {\n if (!this.#isEnabled()) {\n log('Skipping request as disabled');\n\n return {\n results: {\n [ID]: {\n proposedNames: [],\n },\n },\n };\n }\n\n const { value, variation: chainId } = request;\n\n log('Invoking callback', { value, chainId });\n\n try {\n const proposedName = await this.#reverseLookup(value, chainId);\n const proposedNames = proposedName ? [proposedName] : [];\n\n log('New proposed names', proposedNames);\n\n return {\n results: {\n [ID]: { proposedNames },\n },\n };\n } catch (error) {\n log('Request failed', error);\n throw error;\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ens.d.cts","sourceRoot":"","sources":["../../src/providers/ens.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,
|
|
1
|
+
{"version":3,"file":"ens.d.cts","sourceRoot":"","sources":["../../src/providers/ens.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,qBAAoB;AAGrB,MAAM,MAAM,qBAAqB,GAAG,CAClC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,KACZ,OAAO,CAAC,MAAM,CAAC,CAAC;AAOrB,qBAAa,eAAgB,YAAW,YAAY;;gBAKtC,EACV,SAAS,EACT,aAAa,GACd,EAAE;QACD,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC;QAC1B,aAAa,EAAE,qBAAqB,CAAC;KACtC;IAKD,WAAW,IAAI,oBAAoB;IAO7B,gBAAgB,CACpB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,kBAAkB,CAAC;CAiC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ens.d.mts","sourceRoot":"","sources":["../../src/providers/ens.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,
|
|
1
|
+
{"version":3,"file":"ens.d.mts","sourceRoot":"","sources":["../../src/providers/ens.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,qBAAoB;AAGrB,MAAM,MAAM,qBAAqB,GAAG,CAClC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,KACZ,OAAO,CAAC,MAAM,CAAC,CAAC;AAOrB,qBAAa,eAAgB,YAAW,YAAY;;gBAKtC,EACV,SAAS,EACT,aAAa,GACd,EAAE;QACD,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC;QAC1B,aAAa,EAAE,qBAAqB,CAAC;KACtC;IAKD,WAAW,IAAI,oBAAoB;IAO7B,gBAAgB,CACpB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,kBAAkB,CAAC;CAiC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ens.mjs","sourceRoot":"","sources":["../../src/providers/ens.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"ens.mjs","sourceRoot":"","sources":["../../src/providers/ens.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,sBAAqB;AAOjE,OAAO,EAAE,QAAQ,EAAE,qBAAoB;AAOvC,MAAM,EAAE,GAAG,KAAK,CAAC;AACjB,MAAM,KAAK,GAAG,6BAA6B,CAAC;AAE5C,MAAM,GAAG,GAAG,kBAAkB,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;AAErD,MAAM,OAAO,eAAe;IAK1B,YAAY,EACV,SAAS,EACT,aAAa,GAId;QAVQ,6CAA0B;QAE1B,iDAAsC;QAS7C,uBAAA,IAAI,8BAAc,SAAS,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAA,CAAC;QAC5C,uBAAA,IAAI,kCAAkB,aAAa,MAAA,CAAC;IACtC,CAAC;IAED,WAAW;QACT,OAAO;YACL,SAAS,EAAE,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;YAChD,YAAY,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE;SAC9B,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,gBAAgB,CACpB,OAA4B;QAE5B,IAAI,CAAC,uBAAA,IAAI,kCAAW,MAAf,IAAI,CAAa,EAAE,CAAC;YACvB,GAAG,CAAC,8BAA8B,CAAC,CAAC;YAEpC,OAAO;gBACL,OAAO,EAAE;oBACP,CAAC,EAAE,CAAC,EAAE;wBACJ,aAAa,EAAE,EAAE;qBAClB;iBACF;aACF,CAAC;QACJ,CAAC;QAED,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QAE9C,GAAG,CAAC,mBAAmB,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QAE7C,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,MAAM,uBAAA,IAAI,sCAAe,MAAnB,IAAI,EAAgB,KAAK,EAAE,OAAO,CAAC,CAAC;YAC/D,MAAM,aAAa,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAEzD,GAAG,CAAC,oBAAoB,EAAE,aAAa,CAAC,CAAC;YAEzC,OAAO;gBACL,OAAO,EAAE;oBACP,CAAC,EAAE,CAAC,EAAE,EAAE,aAAa,EAAE;iBACxB;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;YAC7B,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF","sourcesContent":["import { projectLogger, createModuleLogger } from '../logger.js';\nimport type {\n NameProvider,\n NameProviderMetadata,\n NameProviderRequest,\n NameProviderResult,\n} from '../types.js';\nimport { NameType } from '../types.js';\n\nexport type ReverseLookupCallback = (\n address: string,\n chainId: string,\n) => Promise<string>;\n\nconst ID = 'ens';\nconst LABEL = 'Ethereum Name Service (ENS)';\n\nconst log = createModuleLogger(projectLogger, 'ens');\n\nexport class ENSNameProvider implements NameProvider {\n readonly #isEnabled: () => boolean;\n\n readonly #reverseLookup: ReverseLookupCallback;\n\n constructor({\n isEnabled,\n reverseLookup,\n }: {\n isEnabled?: () => boolean;\n reverseLookup: ReverseLookupCallback;\n }) {\n this.#isEnabled = isEnabled || (() => true);\n this.#reverseLookup = reverseLookup;\n }\n\n getMetadata(): NameProviderMetadata {\n return {\n sourceIds: { [NameType.ETHEREUM_ADDRESS]: [ID] },\n sourceLabels: { [ID]: LABEL },\n };\n }\n\n async getProposedNames(\n request: NameProviderRequest,\n ): Promise<NameProviderResult> {\n if (!this.#isEnabled()) {\n log('Skipping request as disabled');\n\n return {\n results: {\n [ID]: {\n proposedNames: [],\n },\n },\n };\n }\n\n const { value, variation: chainId } = request;\n\n log('Invoking callback', { value, chainId });\n\n try {\n const proposedName = await this.#reverseLookup(value, chainId);\n const proposedNames = proposedName ? [proposedName] : [];\n\n log('New proposed names', proposedNames);\n\n return {\n results: {\n [ID]: { proposedNames },\n },\n };\n } catch (error) {\n log('Request failed', error);\n throw error;\n }\n }\n}\n"]}
|
|
@@ -14,15 +14,15 @@ var _EtherscanNameProvider_instances, _EtherscanNameProvider_isEnabled, _Ethersc
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.EtherscanNameProvider = void 0;
|
|
16
16
|
const async_mutex_1 = require("async-mutex");
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
17
|
+
const constants_js_1 = require("../constants.cjs");
|
|
18
|
+
const logger_js_1 = require("../logger.cjs");
|
|
19
|
+
const types_js_1 = require("../types.cjs");
|
|
20
|
+
const util_js_1 = require("../util.cjs");
|
|
21
21
|
const ID = 'etherscan';
|
|
22
22
|
const LABEL = 'Etherscan (Verified Contract Name)';
|
|
23
23
|
const RATE_LIMIT_UPDATE_DELAY = 5; // 5 Seconds
|
|
24
24
|
const RATE_LIMIT_INTERVAL = RATE_LIMIT_UPDATE_DELAY * 1000;
|
|
25
|
-
const log = (0,
|
|
25
|
+
const log = (0, logger_js_1.createModuleLogger)(logger_js_1.projectLogger, 'etherscan');
|
|
26
26
|
class EtherscanNameProvider {
|
|
27
27
|
constructor({ isEnabled } = {}) {
|
|
28
28
|
_EtherscanNameProvider_instances.add(this);
|
|
@@ -33,7 +33,7 @@ class EtherscanNameProvider {
|
|
|
33
33
|
}
|
|
34
34
|
getMetadata() {
|
|
35
35
|
return {
|
|
36
|
-
sourceIds: { [
|
|
36
|
+
sourceIds: { [types_js_1.NameType.ETHEREUM_ADDRESS]: [ID] },
|
|
37
37
|
sourceLabels: { [ID]: LABEL },
|
|
38
38
|
};
|
|
39
39
|
}
|
|
@@ -103,18 +103,18 @@ exports.EtherscanNameProvider = EtherscanNameProvider;
|
|
|
103
103
|
_EtherscanNameProvider_isEnabled = new WeakMap(), _EtherscanNameProvider_lastRequestTime = new WeakMap(), _EtherscanNameProvider_mutex = new WeakMap(), _EtherscanNameProvider_instances = new WeakSet(), _EtherscanNameProvider_sendRequest = async function _EtherscanNameProvider_sendRequest(url) {
|
|
104
104
|
try {
|
|
105
105
|
log('Sending request', url);
|
|
106
|
-
const responseData = (await (0,
|
|
106
|
+
const responseData = (await (0, util_js_1.handleFetch)(url));
|
|
107
107
|
return { responseData };
|
|
108
108
|
}
|
|
109
109
|
catch (error) {
|
|
110
|
-
(0,
|
|
110
|
+
(0, util_js_1.assertIsError)(error);
|
|
111
111
|
return { error };
|
|
112
112
|
}
|
|
113
113
|
finally {
|
|
114
114
|
__classPrivateFieldSet(this, _EtherscanNameProvider_lastRequestTime, Date.now(), "f");
|
|
115
115
|
}
|
|
116
116
|
}, _EtherscanNameProvider_getUrl = function _EtherscanNameProvider_getUrl(chainId, params) {
|
|
117
|
-
const networkInfo =
|
|
117
|
+
const networkInfo = constants_js_1.ETHERSCAN_SUPPORTED_NETWORKS[chainId];
|
|
118
118
|
if (!networkInfo) {
|
|
119
119
|
throw new Error(`Etherscan does not support chain with ID: ${chainId}`);
|
|
120
120
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"etherscan.cjs","sourceRoot":"","sources":["../../src/providers/etherscan.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAAoC;AAEpC,
|
|
1
|
+
{"version":3,"file":"etherscan.cjs","sourceRoot":"","sources":["../../src/providers/etherscan.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAAoC;AAEpC,mDAA+D;AAC/D,6CAAiE;AAOjE,2CAAuC;AACvC,yCAAwD;AAExD,MAAM,EAAE,GAAG,WAAW,CAAC;AACvB,MAAM,KAAK,GAAG,oCAAoC,CAAC;AACnD,MAAM,uBAAuB,GAAG,CAAC,CAAC,CAAC,YAAY;AAC/C,MAAM,mBAAmB,GAAG,uBAAuB,GAAG,IAAI,CAAC;AAE3D,MAAM,GAAG,GAAG,IAAA,8BAAkB,EAAC,yBAAa,EAAE,WAAW,CAAC,CAAC;AAuB3D,MAAa,qBAAqB;IAOhC,YAAY,EAAE,SAAS,KAAoC,EAAE;;QANpD,mDAA0B;QAEnC,iDAAmB,CAAC,EAAC;QAEZ,uCAAS,IAAI,mBAAK,EAAE,EAAC;QAG5B,uBAAA,IAAI,oCAAc,SAAS,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAA,CAAC;IAC9C,CAAC;IAED,WAAW;QACT,OAAO;YACL,SAAS,EAAE,EAAE,CAAC,mBAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;YAChD,YAAY,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE;SAC9B,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,gBAAgB,CACpB,OAA4B;QAE5B,IAAI,CAAC,uBAAA,IA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,MAAM,MAAM,CAAC;IAEvE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QACzC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1B,GAAG,IAAI,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { Mutex } from 'async-mutex';\n\nimport { ETHERSCAN_SUPPORTED_NETWORKS } from '../constants.js';\nimport { createModuleLogger, projectLogger } from '../logger.js';\nimport type {\n NameProvider,\n NameProviderMetadata,\n NameProviderRequest,\n NameProviderResult,\n} from '../types.js';\nimport { NameType } from '../types.js';\nimport { handleFetch, assertIsError } from '../util.js';\n\nconst ID = 'etherscan';\nconst LABEL = 'Etherscan (Verified Contract Name)';\nconst RATE_LIMIT_UPDATE_DELAY = 5; // 5 Seconds\nconst RATE_LIMIT_INTERVAL = RATE_LIMIT_UPDATE_DELAY * 1000;\n\nconst log = createModuleLogger(projectLogger, 'etherscan');\n\ntype EtherscanGetSourceCodeResponse = {\n status: '1' | '0';\n message: string;\n result: [\n {\n SourceCode: string;\n ABI: string;\n ContractName: string;\n CompilerVersion: string;\n OptimizationUsed: string;\n Runs: string;\n ConstructorArguments: string;\n Library: string;\n LicenseType: string;\n Proxy: string;\n Implementation: string;\n SwarmSource: string;\n },\n ];\n};\n\nexport class EtherscanNameProvider implements NameProvider {\n readonly #isEnabled: () => boolean;\n\n #lastRequestTime = 0;\n\n readonly #mutex = new Mutex();\n\n constructor({ isEnabled }: { isEnabled?: () => boolean } = {}) {\n this.#isEnabled = isEnabled || (() => true);\n }\n\n getMetadata(): NameProviderMetadata {\n return {\n sourceIds: { [NameType.ETHEREUM_ADDRESS]: [ID] },\n sourceLabels: { [ID]: LABEL },\n };\n }\n\n async getProposedNames(\n request: NameProviderRequest,\n ): Promise<NameProviderResult> {\n if (!this.#isEnabled()) {\n log('Skipping request as disabled');\n\n return {\n results: {\n [ID]: {\n proposedNames: [],\n },\n },\n };\n }\n\n const releaseLock = await this.#mutex.acquire();\n\n try {\n const { value, variation: chainId } = request;\n\n const time = Date.now();\n const timeSinceLastRequest = time - this.#lastRequestTime;\n\n if (timeSinceLastRequest < RATE_LIMIT_INTERVAL) {\n log('Skipping request to avoid rate limit');\n\n return {\n results: {\n [ID]: {\n updateDelay: RATE_LIMIT_UPDATE_DELAY,\n },\n },\n };\n }\n\n const url = this.#getUrl(chainId, {\n module: 'contract',\n action: 'getsourcecode',\n address: value,\n });\n\n const { responseData, error } = await this.#sendRequest(url);\n\n if (error) {\n log('Request failed', error);\n throw error;\n }\n\n if (responseData?.message === 'NOTOK') {\n log('Request warning', responseData.result);\n\n return {\n results: {\n [ID]: {\n updateDelay: RATE_LIMIT_UPDATE_DELAY,\n },\n },\n };\n }\n\n const results = responseData?.result ?? [];\n const proposedNames = results.map((result) => result.ContractName);\n\n log('New proposed names', proposedNames);\n\n return {\n results: {\n [ID]: {\n proposedNames,\n },\n },\n };\n } finally {\n releaseLock();\n }\n }\n\n async #sendRequest(url: string): Promise<{\n responseData?: EtherscanGetSourceCodeResponse;\n error?: Error;\n }> {\n try {\n log('Sending request', url);\n\n const responseData = (await handleFetch(\n url,\n )) as EtherscanGetSourceCodeResponse;\n\n return { responseData };\n } catch (error) {\n assertIsError(error);\n return { error };\n } finally {\n this.#lastRequestTime = Date.now();\n }\n }\n\n #getUrl(chainId: string, params: Record<string, string | undefined>): string {\n type SupportedChainId = keyof typeof ETHERSCAN_SUPPORTED_NETWORKS;\n\n const networkInfo =\n ETHERSCAN_SUPPORTED_NETWORKS[chainId as SupportedChainId];\n\n if (!networkInfo) {\n throw new Error(`Etherscan does not support chain with ID: ${chainId}`);\n }\n\n let url = `https://${networkInfo.subdomain}.${networkInfo.domain}/api`;\n\n Object.keys(params).forEach((key, index) => {\n const value = params[key];\n url += `${index === 0 ? '?' : '&'}${key}=${value}`;\n });\n\n return url;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"etherscan.d.cts","sourceRoot":"","sources":["../../src/providers/etherscan.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,
|
|
1
|
+
{"version":3,"file":"etherscan.d.cts","sourceRoot":"","sources":["../../src/providers/etherscan.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,qBAAoB;AAgCrB,qBAAa,qBAAsB,YAAW,YAAY;;gBAO5C,EAAE,SAAS,EAAE,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,OAAO,CAAA;KAAO;IAI7D,WAAW,IAAI,oBAAoB;IAO7B,gBAAgB,CACpB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,kBAAkB,CAAC;CAkH/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"etherscan.d.mts","sourceRoot":"","sources":["../../src/providers/etherscan.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,
|
|
1
|
+
{"version":3,"file":"etherscan.d.mts","sourceRoot":"","sources":["../../src/providers/etherscan.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,qBAAoB;AAgCrB,qBAAa,qBAAsB,YAAW,YAAY;;gBAO5C,EAAE,SAAS,EAAE,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,OAAO,CAAA;KAAO;IAI7D,WAAW,IAAI,oBAAoB;IAO7B,gBAAgB,CACpB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,kBAAkB,CAAC;CAkH/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"etherscan.mjs","sourceRoot":"","sources":["../../src/providers/etherscan.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,oBAAoB;AAEpC,OAAO,EAAE,4BAA4B,EAAE,
|
|
1
|
+
{"version":3,"file":"etherscan.mjs","sourceRoot":"","sources":["../../src/providers/etherscan.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,oBAAoB;AAEpC,OAAO,EAAE,4BAA4B,EAAE,yBAAwB;AAC/D,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,sBAAqB;AAOjE,OAAO,EAAE,QAAQ,EAAE,qBAAoB;AACvC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,oBAAmB;AAExD,MAAM,EAAE,GAAG,WAAW,CAAC;AACvB,MAAM,KAAK,GAAG,oCAAoC,CAAC;AACnD,MAAM,uBAAuB,GAAG,CAAC,CAAC,CAAC,YAAY;AAC/C,MAAM,mBAAmB,GAAG,uBAAuB,GAAG,IAAI,CAAC;AAE3D,MAAM,GAAG,GAAG,kBAAkB,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;AAuB3D,MAAM,OAAO,qBAAqB;IAOhC,YAAY,EAAE,SAAS,KAAoC,EAAE;;QANpD,mDAA0B;QAEnC,iDAAmB,CAAC,EAAC;QAEZ,uCAAS,IAAI,KAAK,EAAE,EAAC;QAG5B,uBAAA,IAAI,oCAAc,SAAS,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAA,CAAC;IAC9C,CAAC;IAED,WAAW;QACT,OAAO;YACL,SAAS,EAAE,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;YAChD,YAAY,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE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;IAED,IAAI,GAAG,GAAG,WAAW,WAAW,CAAC,SAAS,IAAI,WAAW,CAAC,MAAM,MAAM,CAAC;IAEvE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QACzC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1B,GAAG,IAAI,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { Mutex } from 'async-mutex';\n\nimport { ETHERSCAN_SUPPORTED_NETWORKS } from '../constants.js';\nimport { createModuleLogger, projectLogger } from '../logger.js';\nimport type {\n NameProvider,\n NameProviderMetadata,\n NameProviderRequest,\n NameProviderResult,\n} from '../types.js';\nimport { NameType } from '../types.js';\nimport { handleFetch, assertIsError } from '../util.js';\n\nconst ID = 'etherscan';\nconst LABEL = 'Etherscan (Verified Contract Name)';\nconst RATE_LIMIT_UPDATE_DELAY = 5; // 5 Seconds\nconst RATE_LIMIT_INTERVAL = RATE_LIMIT_UPDATE_DELAY * 1000;\n\nconst log = createModuleLogger(projectLogger, 'etherscan');\n\ntype EtherscanGetSourceCodeResponse = {\n status: '1' | '0';\n message: string;\n result: [\n {\n SourceCode: string;\n ABI: string;\n ContractName: string;\n CompilerVersion: string;\n OptimizationUsed: string;\n Runs: string;\n ConstructorArguments: string;\n Library: string;\n LicenseType: string;\n Proxy: string;\n Implementation: string;\n SwarmSource: string;\n },\n ];\n};\n\nexport class EtherscanNameProvider implements NameProvider {\n readonly #isEnabled: () => boolean;\n\n #lastRequestTime = 0;\n\n readonly #mutex = new Mutex();\n\n constructor({ isEnabled }: { isEnabled?: () => boolean } = {}) {\n this.#isEnabled = isEnabled || (() => true);\n }\n\n getMetadata(): NameProviderMetadata {\n return {\n sourceIds: { [NameType.ETHEREUM_ADDRESS]: [ID] },\n sourceLabels: { [ID]: LABEL },\n };\n }\n\n async getProposedNames(\n request: NameProviderRequest,\n ): Promise<NameProviderResult> {\n if (!this.#isEnabled()) {\n log('Skipping request as disabled');\n\n return {\n results: {\n [ID]: {\n proposedNames: [],\n },\n },\n };\n }\n\n const releaseLock = await this.#mutex.acquire();\n\n try {\n const { value, variation: chainId } = request;\n\n const time = Date.now();\n const timeSinceLastRequest = time - this.#lastRequestTime;\n\n if (timeSinceLastRequest < RATE_LIMIT_INTERVAL) {\n log('Skipping request to avoid rate limit');\n\n return {\n results: {\n [ID]: {\n updateDelay: RATE_LIMIT_UPDATE_DELAY,\n },\n },\n };\n }\n\n const url = this.#getUrl(chainId, {\n module: 'contract',\n action: 'getsourcecode',\n address: value,\n });\n\n const { responseData, error } = await this.#sendRequest(url);\n\n if (error) {\n log('Request failed', error);\n throw error;\n }\n\n if (responseData?.message === 'NOTOK') {\n log('Request warning', responseData.result);\n\n return {\n results: {\n [ID]: {\n updateDelay: RATE_LIMIT_UPDATE_DELAY,\n },\n },\n };\n }\n\n const results = responseData?.result ?? [];\n const proposedNames = results.map((result) => result.ContractName);\n\n log('New proposed names', proposedNames);\n\n return {\n results: {\n [ID]: {\n proposedNames,\n },\n },\n };\n } finally {\n releaseLock();\n }\n }\n\n async #sendRequest(url: string): Promise<{\n responseData?: EtherscanGetSourceCodeResponse;\n error?: Error;\n }> {\n try {\n log('Sending request', url);\n\n const responseData = (await handleFetch(\n url,\n )) as EtherscanGetSourceCodeResponse;\n\n return { responseData };\n } catch (error) {\n assertIsError(error);\n return { error };\n } finally {\n this.#lastRequestTime = Date.now();\n }\n }\n\n #getUrl(chainId: string, params: Record<string, string | undefined>): string {\n type SupportedChainId = keyof typeof ETHERSCAN_SUPPORTED_NETWORKS;\n\n const networkInfo =\n ETHERSCAN_SUPPORTED_NETWORKS[chainId as SupportedChainId];\n\n if (!networkInfo) {\n throw new Error(`Etherscan does not support chain with ID: ${chainId}`);\n }\n\n let url = `https://${networkInfo.subdomain}.${networkInfo.domain}/api`;\n\n Object.keys(params).forEach((key, index) => {\n const value = params[key];\n url += `${index === 0 ? '?' : '&'}${key}=${value}`;\n });\n\n return url;\n }\n}\n"]}
|
package/dist/providers/lens.cjs
CHANGED
|
@@ -13,9 +13,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var _LensNameProvider_isEnabled;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.LensNameProvider = void 0;
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
16
|
+
const logger_js_1 = require("../logger.cjs");
|
|
17
|
+
const types_js_1 = require("../types.cjs");
|
|
18
|
+
const util_js_1 = require("../util.cjs");
|
|
19
19
|
const ID = 'lens';
|
|
20
20
|
const LABEL = 'Lens Protocol';
|
|
21
21
|
const LENS_URL = `https://api.lens.dev`;
|
|
@@ -27,7 +27,7 @@ query HandlesForAddress($address: EthereumAddress!) {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
}`;
|
|
30
|
-
const log = (0,
|
|
30
|
+
const log = (0, logger_js_1.createModuleLogger)(logger_js_1.projectLogger, 'lens');
|
|
31
31
|
class LensNameProvider {
|
|
32
32
|
constructor({ isEnabled } = {}) {
|
|
33
33
|
_LensNameProvider_isEnabled.set(this, void 0);
|
|
@@ -35,7 +35,7 @@ class LensNameProvider {
|
|
|
35
35
|
}
|
|
36
36
|
getMetadata() {
|
|
37
37
|
return {
|
|
38
|
-
sourceIds: { [
|
|
38
|
+
sourceIds: { [types_js_1.NameType.ETHEREUM_ADDRESS]: [ID] },
|
|
39
39
|
sourceLabels: { [ID]: LABEL },
|
|
40
40
|
};
|
|
41
41
|
}
|
|
@@ -54,7 +54,7 @@ class LensNameProvider {
|
|
|
54
54
|
const variables = { address: value };
|
|
55
55
|
log('Sending request', { variables });
|
|
56
56
|
try {
|
|
57
|
-
const responseData = await (0,
|
|
57
|
+
const responseData = await (0, util_js_1.graphQL)(LENS_URL, QUERY, variables);
|
|
58
58
|
const profiles = responseData?.profiles?.items ?? [];
|
|
59
59
|
const proposedNames = profiles.map((profile) => profile.handle);
|
|
60
60
|
log('New proposed names', proposedNames);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lens.cjs","sourceRoot":"","sources":["../../src/providers/lens.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"lens.cjs","sourceRoot":"","sources":["../../src/providers/lens.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAAiE;AAOjE,2CAAuC;AACvC,yCAAqC;AAErC,MAAM,EAAE,GAAG,MAAM,CAAC;AAClB,MAAM,KAAK,GAAG,eAAe,CAAC;AAC9B,MAAM,QAAQ,GAAG,sBAAsB,CAAC;AAExC,MAAM,KAAK,GAAG;;;;;;;EAOZ,CAAC;AAEH,MAAM,GAAG,GAAG,IAAA,8BAAkB,EAAC,yBAAa,EAAE,MAAM,CAAC,CAAC;AAYtD,MAAa,gBAAgB;IAG3B,YAAY,EAAE,SAAS,KAAoC,EAAE;QAFpD,8CAA0B;QAGjC,uBAAA,IAAI,+BAAc,SAAS,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAA,CAAC;IAC9C,CAAC;IAED,WAAW;QACT,OAAO;YACL,SAAS,EAAE,EAAE,CAAC,mBAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;YAChD,YAAY,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE;SAC9B,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,gBAAgB,CACpB,OAA4B;QAE5B,IAAI,CAAC,uBAAA,IAAI,mCAAW,MAAf,IAAI,CAAa,EAAE,CAAC;YACvB,GAAG,CAAC,8BAA8B,CAAC,CAAC;YAEpC,OAAO;gBACL,OAAO,EAAE;oBACP,CAAC,EAAE,CAAC,EAAE;wBACJ,aAAa,EAAE,EAAE;qBAClB;iBACF;aACF,CAAC;QACJ,CAAC;QAED,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;QAC1B,MAAM,SAAS,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAErC,GAAG,CAAC,iBAAiB,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;QAEtC,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,MAAM,IAAA,iBAAO,EAChC,QAAQ,EACR,KAAK,EACL,SAAS,CACV,CAAC;YAEF,MAAM,QAAQ,GAAG,YAAY,EAAE,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC;YACrD,MAAM,aAAa,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAEhE,GAAG,CAAC,oBAAoB,EAAE,aAAa,CAAC,CAAC;YAEzC,OAAO;gBACL,OAAO,EAAE;oBACP,CAAC,EAAE,CAAC,EAAE;wBACJ,aAAa;qBACd;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;YAC7B,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AA1DD,4CA0DC","sourcesContent":["import { createModuleLogger, projectLogger } from '../logger.js';\nimport type {\n NameProvider,\n NameProviderMetadata,\n NameProviderRequest,\n NameProviderResult,\n} from '../types.js';\nimport { NameType } from '../types.js';\nimport { graphQL } from '../util.js';\n\nconst ID = 'lens';\nconst LABEL = 'Lens Protocol';\nconst LENS_URL = `https://api.lens.dev`;\n\nconst QUERY = `\nquery HandlesForAddress($address: EthereumAddress!) {\n profiles(request: { ownedBy: [$address] }) {\n items {\n handle\n }\n }\n}`;\n\nconst log = createModuleLogger(projectLogger, 'lens');\n\ntype LensResponse = {\n profiles: {\n items: [\n {\n handle: string;\n },\n ];\n };\n};\n\nexport class LensNameProvider implements NameProvider {\n readonly #isEnabled: () => boolean;\n\n constructor({ isEnabled }: { isEnabled?: () => boolean } = {}) {\n this.#isEnabled = isEnabled || (() => true);\n }\n\n getMetadata(): NameProviderMetadata {\n return {\n sourceIds: { [NameType.ETHEREUM_ADDRESS]: [ID] },\n sourceLabels: { [ID]: LABEL },\n };\n }\n\n async getProposedNames(\n request: NameProviderRequest,\n ): Promise<NameProviderResult> {\n if (!this.#isEnabled()) {\n log('Skipping request as disabled');\n\n return {\n results: {\n [ID]: {\n proposedNames: [],\n },\n },\n };\n }\n\n const { value } = request;\n const variables = { address: value };\n\n log('Sending request', { variables });\n\n try {\n const responseData = await graphQL<LensResponse>(\n LENS_URL,\n QUERY,\n variables,\n );\n\n const profiles = responseData?.profiles?.items ?? [];\n const proposedNames = profiles.map((profile) => profile.handle);\n\n log('New proposed names', proposedNames);\n\n return {\n results: {\n [ID]: {\n proposedNames,\n },\n },\n };\n } catch (error) {\n log('Request failed', error);\n throw error;\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lens.d.cts","sourceRoot":"","sources":["../../src/providers/lens.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,
|
|
1
|
+
{"version":3,"file":"lens.d.cts","sourceRoot":"","sources":["../../src/providers/lens.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,qBAAoB;AA6BrB,qBAAa,gBAAiB,YAAW,YAAY;;gBAGvC,EAAE,SAAS,EAAE,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,OAAO,CAAA;KAAO;IAI7D,WAAW,IAAI,oBAAoB;IAO7B,gBAAgB,CACpB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,kBAAkB,CAAC;CA0C/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lens.d.mts","sourceRoot":"","sources":["../../src/providers/lens.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,
|
|
1
|
+
{"version":3,"file":"lens.d.mts","sourceRoot":"","sources":["../../src/providers/lens.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,qBAAoB;AA6BrB,qBAAa,gBAAiB,YAAW,YAAY;;gBAGvC,EAAE,SAAS,EAAE,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,OAAO,CAAA;KAAO;IAI7D,WAAW,IAAI,oBAAoB;IAO7B,gBAAgB,CACpB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,kBAAkB,CAAC;CA0C/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lens.mjs","sourceRoot":"","sources":["../../src/providers/lens.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"lens.mjs","sourceRoot":"","sources":["../../src/providers/lens.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,sBAAqB;AAOjE,OAAO,EAAE,QAAQ,EAAE,qBAAoB;AACvC,OAAO,EAAE,OAAO,EAAE,oBAAmB;AAErC,MAAM,EAAE,GAAG,MAAM,CAAC;AAClB,MAAM,KAAK,GAAG,eAAe,CAAC;AAC9B,MAAM,QAAQ,GAAG,sBAAsB,CAAC;AAExC,MAAM,KAAK,GAAG;;;;;;;EAOZ,CAAC;AAEH,MAAM,GAAG,GAAG,kBAAkB,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;AAYtD,MAAM,OAAO,gBAAgB;IAG3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AC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;YAC7B,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF","sourcesContent":["import { createModuleLogger, projectLogger } from '../logger.js';\nimport type {\n NameProvider,\n NameProviderMetadata,\n NameProviderRequest,\n NameProviderResult,\n} from '../types.js';\nimport { NameType } from '../types.js';\nimport { graphQL } from '../util.js';\n\nconst ID = 'lens';\nconst LABEL = 'Lens Protocol';\nconst LENS_URL = `https://api.lens.dev`;\n\nconst QUERY = `\nquery HandlesForAddress($address: EthereumAddress!) {\n profiles(request: { ownedBy: [$address] }) {\n items {\n handle\n }\n }\n}`;\n\nconst log = createModuleLogger(projectLogger, 'lens');\n\ntype LensResponse = {\n profiles: {\n items: [\n {\n handle: string;\n },\n ];\n };\n};\n\nexport class LensNameProvider implements NameProvider {\n readonly #isEnabled: () => boolean;\n\n constructor({ isEnabled }: { isEnabled?: () => boolean } = {}) {\n this.#isEnabled = isEnabled || (() => true);\n }\n\n getMetadata(): NameProviderMetadata {\n return {\n sourceIds: { [NameType.ETHEREUM_ADDRESS]: [ID] },\n sourceLabels: { [ID]: LABEL },\n };\n }\n\n async getProposedNames(\n request: NameProviderRequest,\n ): Promise<NameProviderResult> {\n if (!this.#isEnabled()) {\n log('Skipping request as disabled');\n\n return {\n results: {\n [ID]: {\n proposedNames: [],\n },\n },\n };\n }\n\n const { value } = request;\n const variables = { address: value };\n\n log('Sending request', { variables });\n\n try {\n const responseData = await graphQL<LensResponse>(\n LENS_URL,\n QUERY,\n variables,\n );\n\n const profiles = responseData?.profiles?.items ?? [];\n const proposedNames = profiles.map((profile) => profile.handle);\n\n log('New proposed names', proposedNames);\n\n return {\n results: {\n [ID]: {\n proposedNames,\n },\n },\n };\n } catch (error) {\n log('Request failed', error);\n throw error;\n }\n }\n}\n"]}
|
package/dist/providers/token.cjs
CHANGED
|
@@ -13,12 +13,12 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var _TokenNameProvider_isEnabled;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.TokenNameProvider = void 0;
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
16
|
+
const logger_js_1 = require("../logger.cjs");
|
|
17
|
+
const types_js_1 = require("../types.cjs");
|
|
18
|
+
const util_js_1 = require("../util.cjs");
|
|
19
19
|
const ID = 'token';
|
|
20
20
|
const LABEL = 'Blockchain (Token Name)';
|
|
21
|
-
const log = (0,
|
|
21
|
+
const log = (0, logger_js_1.createModuleLogger)(logger_js_1.projectLogger, 'token');
|
|
22
22
|
class TokenNameProvider {
|
|
23
23
|
constructor({ isEnabled } = {}) {
|
|
24
24
|
_TokenNameProvider_isEnabled.set(this, void 0);
|
|
@@ -26,7 +26,7 @@ class TokenNameProvider {
|
|
|
26
26
|
}
|
|
27
27
|
getMetadata() {
|
|
28
28
|
return {
|
|
29
|
-
sourceIds: { [
|
|
29
|
+
sourceIds: { [types_js_1.NameType.ETHEREUM_ADDRESS]: [ID] },
|
|
30
30
|
sourceLabels: { [ID]: LABEL },
|
|
31
31
|
};
|
|
32
32
|
}
|
|
@@ -45,7 +45,7 @@ class TokenNameProvider {
|
|
|
45
45
|
const url = `https://token.api.cx.metamask.io/token/${chainId}?address=${value}`;
|
|
46
46
|
log('Sending request', url);
|
|
47
47
|
try {
|
|
48
|
-
const responseData = await (0,
|
|
48
|
+
const responseData = await (0, util_js_1.handleFetch)(url);
|
|
49
49
|
const proposedName = responseData.name;
|
|
50
50
|
const proposedNames = proposedName ? [proposedName] : [];
|
|
51
51
|
log('New proposed names', proposedNames);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.cjs","sourceRoot":"","sources":["../../src/providers/token.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"token.cjs","sourceRoot":"","sources":["../../src/providers/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CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAEzD,GAAG,CAAC,oBAAoB,EAAE,aAAa,CAAC,CAAC;YAEzC,OAAO;gBACL,OAAO,EAAE;oBACP,CAAC,EAAE,CAAC,EAAE;wBACJ,aAAa;qBACd;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;YAC7B,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AArDD,8CAqDC","sourcesContent":["import { createModuleLogger, projectLogger } from '../logger.js';\nimport type {\n NameProvider,\n NameProviderMetadata,\n NameProviderRequest,\n NameProviderResult,\n} from '../types.js';\nimport { NameType } from '../types.js';\nimport { handleFetch } from '../util.js';\n\nconst ID = 'token';\nconst LABEL = 'Blockchain (Token Name)';\n\nconst log = createModuleLogger(projectLogger, 'token');\n\nexport class TokenNameProvider implements NameProvider {\n readonly #isEnabled: () => boolean;\n\n constructor({ isEnabled }: { isEnabled?: () => boolean } = {}) {\n this.#isEnabled = isEnabled || (() => true);\n }\n\n getMetadata(): NameProviderMetadata {\n return {\n sourceIds: { [NameType.ETHEREUM_ADDRESS]: [ID] },\n sourceLabels: { [ID]: LABEL },\n };\n }\n\n async getProposedNames(\n request: NameProviderRequest,\n ): Promise<NameProviderResult> {\n if (!this.#isEnabled()) {\n log('Skipping request as disabled');\n\n return {\n results: {\n [ID]: {\n proposedNames: [],\n },\n },\n };\n }\n\n const { value, variation: chainId } = request;\n const url = `https://token.api.cx.metamask.io/token/${chainId}?address=${value}`;\n\n log('Sending request', url);\n\n try {\n const responseData = await handleFetch(url);\n const proposedName = responseData.name;\n const proposedNames = proposedName ? [proposedName] : [];\n\n log('New proposed names', proposedNames);\n\n return {\n results: {\n [ID]: {\n proposedNames,\n },\n },\n };\n } catch (error) {\n log('Request failed', error);\n throw error;\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.d.cts","sourceRoot":"","sources":["../../src/providers/token.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,
|
|
1
|
+
{"version":3,"file":"token.d.cts","sourceRoot":"","sources":["../../src/providers/token.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,qBAAoB;AASrB,qBAAa,iBAAkB,YAAW,YAAY;;gBAGxC,EAAE,SAAS,EAAE,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,OAAO,CAAA;KAAO;IAI7D,WAAW,IAAI,oBAAoB;IAO7B,gBAAgB,CACpB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,kBAAkB,CAAC;CAqC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.d.mts","sourceRoot":"","sources":["../../src/providers/token.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,
|
|
1
|
+
{"version":3,"file":"token.d.mts","sourceRoot":"","sources":["../../src/providers/token.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,qBAAoB;AASrB,qBAAa,iBAAkB,YAAW,YAAY;;gBAGxC,EAAE,SAAS,EAAE,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,OAAO,CAAA;KAAO;IAI7D,WAAW,IAAI,oBAAoB;IAO7B,gBAAgB,CACpB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,kBAAkB,CAAC;CAqC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.mjs","sourceRoot":"","sources":["../../src/providers/token.ts"],"names":[],"mappings":";;;;;;;;;;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G,CAAC,CAAC;QAE5B,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC,CAAC;YAC5C,MAAM,YAAY,GAAG,YAAY,CAAC,IAAI,CAAC;YACvC,MAAM,aAAa,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAEzD,GAAG,CAAC,oBAAoB,EAAE,aAAa,CAAC,CAAC;YAEzC,OAAO;gBACL,OAAO,EAAE;oBACP,CAAC,EAAE,CAAC,EAAE;wBACJ,aAAa;qBACd;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;YAC7B,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF","sourcesContent":["import { createModuleLogger, projectLogger } from '../logger.js';\nimport type {\n NameProvider,\n NameProviderMetadata,\n NameProviderRequest,\n NameProviderResult,\n} from '../types.js';\nimport { NameType } from '../types.js';\nimport { handleFetch } from '../util.js';\n\nconst ID = 'token';\nconst LABEL = 'Blockchain (Token Name)';\n\nconst log = createModuleLogger(projectLogger, 'token');\n\nexport class TokenNameProvider implements NameProvider {\n readonly #isEnabled: () => boolean;\n\n constructor({ isEnabled }: { isEnabled?: () => boolean } = {}) {\n this.#isEnabled = isEnabled || (() => true);\n }\n\n getMetadata(): NameProviderMetadata {\n return {\n sourceIds: { [NameType.ETHEREUM_ADDRESS]: [ID] },\n sourceLabels: { [ID]: LABEL },\n };\n }\n\n async getProposedNames(\n request: NameProviderRequest,\n ): Promise<NameProviderResult> {\n if (!this.#isEnabled()) {\n log('Skipping request as disabled');\n\n return {\n results: {\n [ID]: {\n proposedNames: [],\n },\n },\n };\n }\n\n const { value, variation: chainId } = request;\n const url = `https://token.api.cx.metamask.io/token/${chainId}?address=${value}`;\n\n log('Sending request', url);\n\n try {\n const responseData = await handleFetch(url);\n const proposedName = responseData.name;\n const proposedNames = proposedName ? [proposedName] : [];\n\n log('New proposed names', proposedNames);\n\n return {\n results: {\n [ID]: {\n proposedNames,\n },\n },\n };\n } catch (error) {\n log('Request failed', error);\n throw error;\n }\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/name-controller",
|
|
3
|
-
"version": "9.1.2-preview-
|
|
3
|
+
"version": "9.1.2-preview-ec4680201",
|
|
4
4
|
"description": "Stores and suggests names for values such as Ethereum addresses",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ethereum",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/name-controller",
|
|
47
47
|
"lint:tsconfigs": "tsx ../../scripts/lint-tsconfigs/lint-tsconfigs.mts",
|
|
48
48
|
"lint:tsconfigs:fix": "tsx ../../scripts/lint-tsconfigs/lint-tsconfigs.mts --fix",
|
|
49
|
-
"messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --check",
|
|
50
|
-
"messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --generate",
|
|
49
|
+
"messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --esm --check",
|
|
50
|
+
"messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --esm --generate",
|
|
51
51
|
"prepare-manifest:preview": "../../scripts/prepare-preview-manifest.sh",
|
|
52
52
|
"since-latest-release": "../../scripts/since-latest-release.sh",
|
|
53
53
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
|