@metamask/name-controller 1.0.0
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/CHANGELOG.md +14 -0
- package/LICENSE +20 -0
- package/README.md +15 -0
- package/dist/NameController.d.ts +91 -0
- package/dist/NameController.d.ts.map +1 -0
- package/dist/NameController.js +293 -0
- package/dist/NameController.js.map +1 -0
- package/dist/constants.d.ts +100 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +106 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/ens.d.ts +11 -0
- package/dist/providers/ens.d.ts.map +1 -0
- package/dist/providers/ens.js +53 -0
- package/dist/providers/ens.js.map +1 -0
- package/dist/providers/etherscan.d.ts +10 -0
- package/dist/providers/etherscan.d.ts.map +1 -0
- package/dist/providers/etherscan.js +81 -0
- package/dist/providers/etherscan.js.map +1 -0
- package/dist/providers/lens.d.ts +6 -0
- package/dist/providers/lens.d.ts.map +1 -0
- package/dist/providers/lens.js +53 -0
- package/dist/providers/lens.js.map +1 -0
- package/dist/providers/token.d.ts +6 -0
- package/dist/providers/token.d.ts.map +1 -0
- package/dist/providers/token.js +41 -0
- package/dist/providers/token.js.map +1 -0
- package/dist/types.d.ts +69 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/dist/util.d.ts +25 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +70 -0
- package/dist/util.js.map +1 -0
- package/package.json +52 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
All notable changes to this project will be documented in this file.
|
|
3
|
+
|
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [1.0.0]
|
|
10
|
+
### Added
|
|
11
|
+
- Initial Release ([#1647](https://github.com/MetaMask/core/pull/1647))
|
|
12
|
+
|
|
13
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/name-controller@1.0.0...HEAD
|
|
14
|
+
[1.0.0]: https://github.com/MetaMask/core/releases/tag/@metamask/name-controller@1.0.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 MetaMask
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# `@metamask/name-controller`
|
|
2
|
+
|
|
3
|
+
Stores and suggests names for values such as Ethereum addresses.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
`yarn add @metamask/name-controller`
|
|
8
|
+
|
|
9
|
+
or
|
|
10
|
+
|
|
11
|
+
`npm install @metamask/name-controller`
|
|
12
|
+
|
|
13
|
+
## Contributing
|
|
14
|
+
|
|
15
|
+
This package is part of a monorepo. Instructions for contributing can be found in the [monorepo README](https://github.com/MetaMask/core#readme).
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { RestrictedControllerMessenger } from '@metamask/base-controller';
|
|
2
|
+
import { BaseControllerV2 } from '@metamask/base-controller';
|
|
3
|
+
import type { Patch } from 'immer';
|
|
4
|
+
import type { NameProvider } from './types';
|
|
5
|
+
import { NameType } from './types';
|
|
6
|
+
declare const controllerName = "NameController";
|
|
7
|
+
export declare type NameEntry = {
|
|
8
|
+
name: string | null;
|
|
9
|
+
sourceId: string | null;
|
|
10
|
+
proposedNames: Record<string, string[] | null>;
|
|
11
|
+
proposedNamesLastUpdated: number | null;
|
|
12
|
+
};
|
|
13
|
+
export declare type SourceEntry = {
|
|
14
|
+
label: string;
|
|
15
|
+
};
|
|
16
|
+
export declare type NameControllerState = {
|
|
17
|
+
names: Record<NameType, Record<string, Record<string, NameEntry>>>;
|
|
18
|
+
nameSources: Record<string, SourceEntry>;
|
|
19
|
+
};
|
|
20
|
+
export declare type GetNameState = {
|
|
21
|
+
type: `${typeof controllerName}:getState`;
|
|
22
|
+
handler: () => NameControllerState;
|
|
23
|
+
};
|
|
24
|
+
export declare type NameStateChange = {
|
|
25
|
+
type: `${typeof controllerName}:stateChange`;
|
|
26
|
+
payload: [NameControllerState, Patch[]];
|
|
27
|
+
};
|
|
28
|
+
export declare type NameControllerActions = GetNameState;
|
|
29
|
+
export declare type NameControllerEvents = NameStateChange;
|
|
30
|
+
export declare type NameControllerMessenger = RestrictedControllerMessenger<typeof controllerName, NameControllerActions, NameControllerEvents, never, never>;
|
|
31
|
+
export declare type NameControllerOptions = {
|
|
32
|
+
getChainId: () => string;
|
|
33
|
+
messenger: NameControllerMessenger;
|
|
34
|
+
providers: NameProvider[];
|
|
35
|
+
state?: Partial<NameControllerState>;
|
|
36
|
+
};
|
|
37
|
+
export declare type UpdateProposedNamesRequest = {
|
|
38
|
+
value: string;
|
|
39
|
+
type: NameType;
|
|
40
|
+
sourceIds?: string[];
|
|
41
|
+
};
|
|
42
|
+
export declare type UpdateProposedNamesResult = {
|
|
43
|
+
results: Record<string, {
|
|
44
|
+
proposedNames?: string[];
|
|
45
|
+
error?: unknown;
|
|
46
|
+
}>;
|
|
47
|
+
};
|
|
48
|
+
export declare type SetNameRequest = {
|
|
49
|
+
value: string;
|
|
50
|
+
type: NameType;
|
|
51
|
+
name: string;
|
|
52
|
+
sourceId?: string;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Controller for storing and deriving names for values such as Ethereum addresses.
|
|
56
|
+
*/
|
|
57
|
+
export declare class NameController extends BaseControllerV2<typeof controllerName, NameControllerState, NameControllerMessenger> {
|
|
58
|
+
#private;
|
|
59
|
+
/**
|
|
60
|
+
* Construct a Name controller.
|
|
61
|
+
*
|
|
62
|
+
* @param options - Controller options.
|
|
63
|
+
* @param options.getChainId - Callback that returns the chain ID of the current network.
|
|
64
|
+
* @param options.messenger - Restricted controller messenger for the name controller.
|
|
65
|
+
* @param options.providers - Array of name provider instances to propose names.
|
|
66
|
+
* @param options.state - Initial state to set on the controller.
|
|
67
|
+
*/
|
|
68
|
+
constructor({ getChainId, messenger, providers, state, }: NameControllerOptions);
|
|
69
|
+
/**
|
|
70
|
+
* Set the user specified name for a value.
|
|
71
|
+
*
|
|
72
|
+
* @param request - Request object.
|
|
73
|
+
* @param request.name - Name to set.
|
|
74
|
+
* @param request.sourceId - Optional ID of the source of the proposed name.
|
|
75
|
+
* @param request.type - Type of value to set the name for.
|
|
76
|
+
* @param request.value - Value to set the name for.
|
|
77
|
+
*/
|
|
78
|
+
setName(request: SetNameRequest): void;
|
|
79
|
+
/**
|
|
80
|
+
* Generate the proposed names for a value using the name providers and store them in the state.
|
|
81
|
+
*
|
|
82
|
+
* @param request - Request object.
|
|
83
|
+
* @param request.value - Value to update the proposed names for.
|
|
84
|
+
* @param request.type - Type of value to update the proposed names for.
|
|
85
|
+
* @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.
|
|
86
|
+
* @returns The updated proposed names for the value.
|
|
87
|
+
*/
|
|
88
|
+
updateProposedNames(request: UpdateProposedNamesRequest): Promise<UpdateProposedNamesResult>;
|
|
89
|
+
}
|
|
90
|
+
export {};
|
|
91
|
+
//# sourceMappingURL=NameController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NameController.d.ts","sourceRoot":"","sources":["../src/NameController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,KAAK,EACV,YAAY,EAGb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,QAAA,MAAM,cAAc,mBAAmB,CAAC;AAcxC,oBAAY,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;IAC/C,wBAAwB,EAAE,MAAM,GAAG,IAAI,CAAC;CACzC,CAAC;AAEF,oBAAY,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,oBAAY,mBAAmB,GAAG;IAEhC,KAAK,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C;IACd,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,qBAAa,cAAe,SAAQ,gBAAgB,CAClD,OAAO,cAAc,EACrB,mBAAmB,EACnB,uBAAuB,CACxB;;IAKC;;;;;;;;OAQG;gBACS,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,KAAK,GACN,EAAE,qBAAqB;IAYxB;;;;;;;;OAQG;IACH,OAAO,CAAC,OAAO,EAAE,cAAc;IAQ/B;;;;;;;;OAQG;IACG,mBAAmB,CACvB,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,yBAAyB,CAAC;CAgVtC"}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
+
};
|
|
17
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
20
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
+
};
|
|
22
|
+
var _NameController_instances, _NameController_getChainId, _NameController_providers, _NameController_updateProposedNameState, _NameController_updateSourceState, _NameController_getUpdateProposedNamesResult, _NameController_getProviderResponse, _NameController_updateEntry, _NameController_getTypeVariationKey, _NameController_getCurrentTimeSeconds, _NameController_validateSetNameRequest, _NameController_validateUpdateProposedNamesRequest, _NameController_validateValue, _NameController_validateType, _NameController_validateName, _NameController_validateSourceIds, _NameController_validateSourceId, _NameController_validateDuplicateSourceIds, _NameController_getAllSourceIds, _NameController_getSourceIds;
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.NameController = void 0;
|
|
25
|
+
const base_controller_1 = require("@metamask/base-controller");
|
|
26
|
+
const types_1 = require("./types");
|
|
27
|
+
const controllerName = 'NameController';
|
|
28
|
+
const stateMetadata = {
|
|
29
|
+
names: { persist: true, anonymous: false },
|
|
30
|
+
nameSources: { persist: true, anonymous: false },
|
|
31
|
+
};
|
|
32
|
+
const getDefaultState = () => ({
|
|
33
|
+
names: {
|
|
34
|
+
[types_1.NameType.ETHEREUM_ADDRESS]: {},
|
|
35
|
+
},
|
|
36
|
+
nameSources: {},
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Controller for storing and deriving names for values such as Ethereum addresses.
|
|
40
|
+
*/
|
|
41
|
+
class NameController extends base_controller_1.BaseControllerV2 {
|
|
42
|
+
/**
|
|
43
|
+
* Construct a Name controller.
|
|
44
|
+
*
|
|
45
|
+
* @param options - Controller options.
|
|
46
|
+
* @param options.getChainId - Callback that returns the chain ID of the current network.
|
|
47
|
+
* @param options.messenger - Restricted controller messenger for the name controller.
|
|
48
|
+
* @param options.providers - Array of name provider instances to propose names.
|
|
49
|
+
* @param options.state - Initial state to set on the controller.
|
|
50
|
+
*/
|
|
51
|
+
constructor({ getChainId, messenger, providers, state, }) {
|
|
52
|
+
super({
|
|
53
|
+
name: controllerName,
|
|
54
|
+
metadata: stateMetadata,
|
|
55
|
+
messenger,
|
|
56
|
+
state: Object.assign(Object.assign({}, getDefaultState()), state),
|
|
57
|
+
});
|
|
58
|
+
_NameController_instances.add(this);
|
|
59
|
+
_NameController_getChainId.set(this, void 0);
|
|
60
|
+
_NameController_providers.set(this, void 0);
|
|
61
|
+
__classPrivateFieldSet(this, _NameController_getChainId, getChainId, "f");
|
|
62
|
+
__classPrivateFieldSet(this, _NameController_providers, providers, "f");
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Set the user specified name for a value.
|
|
66
|
+
*
|
|
67
|
+
* @param request - Request object.
|
|
68
|
+
* @param request.name - Name to set.
|
|
69
|
+
* @param request.sourceId - Optional ID of the source of the proposed name.
|
|
70
|
+
* @param request.type - Type of value to set the name for.
|
|
71
|
+
* @param request.value - Value to set the name for.
|
|
72
|
+
*/
|
|
73
|
+
setName(request) {
|
|
74
|
+
__classPrivateFieldGet(this, _NameController_instances, "m", _NameController_validateSetNameRequest).call(this, request);
|
|
75
|
+
const { value, type, name, sourceId } = request;
|
|
76
|
+
__classPrivateFieldGet(this, _NameController_instances, "m", _NameController_updateEntry).call(this, value, type, { name, sourceId: sourceId !== null && sourceId !== void 0 ? sourceId : null });
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Generate the proposed names for a value using the name providers and store them in the state.
|
|
80
|
+
*
|
|
81
|
+
* @param request - Request object.
|
|
82
|
+
* @param request.value - Value to update the proposed names for.
|
|
83
|
+
* @param request.type - Type of value to update the proposed names for.
|
|
84
|
+
* @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.
|
|
85
|
+
* @returns The updated proposed names for the value.
|
|
86
|
+
*/
|
|
87
|
+
updateProposedNames(request) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
__classPrivateFieldGet(this, _NameController_instances, "m", _NameController_validateUpdateProposedNamesRequest).call(this, request);
|
|
90
|
+
const chainId = __classPrivateFieldGet(this, _NameController_getChainId, "f").call(this);
|
|
91
|
+
const providerResponses = (yield Promise.all(__classPrivateFieldGet(this, _NameController_providers, "f").map((provider) => __classPrivateFieldGet(this, _NameController_instances, "m", _NameController_getProviderResponse).call(this, request, chainId, provider)))).filter((response) => Boolean(response));
|
|
92
|
+
__classPrivateFieldGet(this, _NameController_instances, "m", _NameController_updateProposedNameState).call(this, request, providerResponses);
|
|
93
|
+
__classPrivateFieldGet(this, _NameController_instances, "m", _NameController_updateSourceState).call(this, __classPrivateFieldGet(this, _NameController_providers, "f"));
|
|
94
|
+
return __classPrivateFieldGet(this, _NameController_instances, "m", _NameController_getUpdateProposedNamesResult).call(this, providerResponses);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.NameController = NameController;
|
|
99
|
+
_NameController_getChainId = new WeakMap(), _NameController_providers = new WeakMap(), _NameController_instances = new WeakSet(), _NameController_updateProposedNameState = function _NameController_updateProposedNameState(request, providerResponses) {
|
|
100
|
+
var _a, _b, _c;
|
|
101
|
+
const { value, type } = request;
|
|
102
|
+
const newProposedNames = {};
|
|
103
|
+
for (const providerResponse of providerResponses) {
|
|
104
|
+
const { results, error: responseError } = providerResponse;
|
|
105
|
+
if (responseError) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
for (const sourceId of Object.keys(providerResponse.results)) {
|
|
109
|
+
const result = results[sourceId];
|
|
110
|
+
const { proposedNames } = result;
|
|
111
|
+
let finalProposedNames = result.error ? null : proposedNames !== null && proposedNames !== void 0 ? proposedNames : [];
|
|
112
|
+
if (finalProposedNames) {
|
|
113
|
+
finalProposedNames = finalProposedNames.filter((proposedName) => proposedName === null || proposedName === void 0 ? void 0 : proposedName.length);
|
|
114
|
+
}
|
|
115
|
+
newProposedNames[sourceId] = finalProposedNames;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const variationKey = __classPrivateFieldGet(this, _NameController_instances, "m", _NameController_getTypeVariationKey).call(this, type);
|
|
119
|
+
const existingProposedNames = (_c = (_b = (_a = this.state.names[type]) === null || _a === void 0 ? void 0 : _a[value]) === null || _b === void 0 ? void 0 : _b[variationKey]) === null || _c === void 0 ? void 0 : _c.proposedNames;
|
|
120
|
+
const proposedNames = Object.assign(Object.assign({}, existingProposedNames), newProposedNames);
|
|
121
|
+
const proposedNamesLastUpdated = __classPrivateFieldGet(this, _NameController_instances, "m", _NameController_getCurrentTimeSeconds).call(this);
|
|
122
|
+
__classPrivateFieldGet(this, _NameController_instances, "m", _NameController_updateEntry).call(this, value, type, { proposedNames, proposedNamesLastUpdated });
|
|
123
|
+
}, _NameController_updateSourceState = function _NameController_updateSourceState(providers) {
|
|
124
|
+
const newNameSources = Object.assign({}, this.state.nameSources);
|
|
125
|
+
for (const provider of providers) {
|
|
126
|
+
const { sourceLabels } = provider.getMetadata();
|
|
127
|
+
for (const sourceId of Object.keys(sourceLabels)) {
|
|
128
|
+
newNameSources[sourceId] = {
|
|
129
|
+
label: sourceLabels[sourceId],
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
this.update((state) => {
|
|
134
|
+
state.nameSources = newNameSources;
|
|
135
|
+
});
|
|
136
|
+
}, _NameController_getUpdateProposedNamesResult = function _NameController_getUpdateProposedNamesResult(providerResponses) {
|
|
137
|
+
return providerResponses.reduce((acc, providerResponse) => {
|
|
138
|
+
const { results } = providerResponse;
|
|
139
|
+
for (const sourceId of Object.keys(results)) {
|
|
140
|
+
const { proposedNames: resultProposedNames, error: resultError } = results[sourceId];
|
|
141
|
+
let proposedNames = resultError
|
|
142
|
+
? undefined
|
|
143
|
+
: resultProposedNames !== null && resultProposedNames !== void 0 ? resultProposedNames : [];
|
|
144
|
+
if (proposedNames) {
|
|
145
|
+
proposedNames = proposedNames.filter((proposedName) => proposedName === null || proposedName === void 0 ? void 0 : proposedName.length);
|
|
146
|
+
}
|
|
147
|
+
acc.results[sourceId] = {
|
|
148
|
+
proposedNames,
|
|
149
|
+
error: resultError,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
return acc;
|
|
153
|
+
}, { results: {} });
|
|
154
|
+
}, _NameController_getProviderResponse = function _NameController_getProviderResponse(request, chainId, provider) {
|
|
155
|
+
var _a;
|
|
156
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
157
|
+
const { value, type, sourceIds: requestedSourceIds } = request;
|
|
158
|
+
const supportedSourceIds = __classPrivateFieldGet(this, _NameController_instances, "m", _NameController_getSourceIds).call(this, provider, type);
|
|
159
|
+
const matchingSourceIds = (_a = requestedSourceIds === null || requestedSourceIds === void 0 ? void 0 : requestedSourceIds.filter((sourceId) => supportedSourceIds.includes(sourceId))) !== null && _a !== void 0 ? _a : supportedSourceIds;
|
|
160
|
+
if (requestedSourceIds && !matchingSourceIds.length) {
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
163
|
+
const providerRequest = {
|
|
164
|
+
chainId,
|
|
165
|
+
value,
|
|
166
|
+
type,
|
|
167
|
+
sourceIds: requestedSourceIds ? matchingSourceIds : undefined,
|
|
168
|
+
};
|
|
169
|
+
let responseError;
|
|
170
|
+
let response;
|
|
171
|
+
try {
|
|
172
|
+
response = yield provider.getProposedNames(providerRequest);
|
|
173
|
+
responseError = response.error;
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
responseError = error;
|
|
177
|
+
}
|
|
178
|
+
let results = {};
|
|
179
|
+
if (response === null || response === void 0 ? void 0 : response.results) {
|
|
180
|
+
results = Object.keys(response.results).reduce((acc, sourceId) => {
|
|
181
|
+
if (!requestedSourceIds || requestedSourceIds.includes(sourceId)) {
|
|
182
|
+
acc[sourceId] = response.results[sourceId];
|
|
183
|
+
}
|
|
184
|
+
return acc;
|
|
185
|
+
}, {});
|
|
186
|
+
}
|
|
187
|
+
if (responseError) {
|
|
188
|
+
results = supportedSourceIds.reduce((acc, sourceId) => {
|
|
189
|
+
acc[sourceId] = { proposedNames: [], error: responseError };
|
|
190
|
+
return acc;
|
|
191
|
+
}, {});
|
|
192
|
+
}
|
|
193
|
+
return { results, error: responseError };
|
|
194
|
+
});
|
|
195
|
+
}, _NameController_updateEntry = function _NameController_updateEntry(value, type, data) {
|
|
196
|
+
const variationKey = __classPrivateFieldGet(this, _NameController_instances, "m", _NameController_getTypeVariationKey).call(this, type);
|
|
197
|
+
this.update((state) => {
|
|
198
|
+
var _a;
|
|
199
|
+
const typeEntries = state.names[type] || {};
|
|
200
|
+
state.names[type] = typeEntries;
|
|
201
|
+
const variationEntries = typeEntries[value] || {};
|
|
202
|
+
typeEntries[value] = variationEntries;
|
|
203
|
+
const currentEntry = (_a = variationEntries[variationKey]) !== null && _a !== void 0 ? _a : {
|
|
204
|
+
proposedNames: {},
|
|
205
|
+
proposedNamesLastUpdated: null,
|
|
206
|
+
name: null,
|
|
207
|
+
sourceId: null,
|
|
208
|
+
};
|
|
209
|
+
const updatedEntry = Object.assign(Object.assign({}, currentEntry), data);
|
|
210
|
+
variationEntries[variationKey] = updatedEntry;
|
|
211
|
+
});
|
|
212
|
+
}, _NameController_getTypeVariationKey = function _NameController_getTypeVariationKey(type) {
|
|
213
|
+
switch (type) {
|
|
214
|
+
default: {
|
|
215
|
+
return __classPrivateFieldGet(this, _NameController_getChainId, "f").call(this);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}, _NameController_getCurrentTimeSeconds = function _NameController_getCurrentTimeSeconds() {
|
|
219
|
+
return Math.round(Date.now() / 1000);
|
|
220
|
+
}, _NameController_validateSetNameRequest = function _NameController_validateSetNameRequest(request) {
|
|
221
|
+
const { name, value, type, sourceId } = request;
|
|
222
|
+
const errorMessages = [];
|
|
223
|
+
__classPrivateFieldGet(this, _NameController_instances, "m", _NameController_validateValue).call(this, value, errorMessages);
|
|
224
|
+
__classPrivateFieldGet(this, _NameController_instances, "m", _NameController_validateType).call(this, type, errorMessages);
|
|
225
|
+
__classPrivateFieldGet(this, _NameController_instances, "m", _NameController_validateName).call(this, name, errorMessages);
|
|
226
|
+
__classPrivateFieldGet(this, _NameController_instances, "m", _NameController_validateSourceId).call(this, sourceId, type, errorMessages);
|
|
227
|
+
if (errorMessages.length) {
|
|
228
|
+
throw new Error(errorMessages.join(' '));
|
|
229
|
+
}
|
|
230
|
+
}, _NameController_validateUpdateProposedNamesRequest = function _NameController_validateUpdateProposedNamesRequest(request) {
|
|
231
|
+
const { value, type, sourceIds } = request;
|
|
232
|
+
const errorMessages = [];
|
|
233
|
+
__classPrivateFieldGet(this, _NameController_instances, "m", _NameController_validateValue).call(this, value, errorMessages);
|
|
234
|
+
__classPrivateFieldGet(this, _NameController_instances, "m", _NameController_validateType).call(this, type, errorMessages);
|
|
235
|
+
__classPrivateFieldGet(this, _NameController_instances, "m", _NameController_validateSourceIds).call(this, sourceIds, type, errorMessages);
|
|
236
|
+
__classPrivateFieldGet(this, _NameController_instances, "m", _NameController_validateDuplicateSourceIds).call(this, type, errorMessages);
|
|
237
|
+
if (errorMessages.length) {
|
|
238
|
+
throw new Error(errorMessages.join(' '));
|
|
239
|
+
}
|
|
240
|
+
}, _NameController_validateValue = function _NameController_validateValue(value, errorMessages) {
|
|
241
|
+
if (!(value === null || value === void 0 ? void 0 : value.length) || typeof value !== 'string') {
|
|
242
|
+
errorMessages.push('Must specify a non-empty string for value.');
|
|
243
|
+
}
|
|
244
|
+
}, _NameController_validateType = function _NameController_validateType(type, errorMessages) {
|
|
245
|
+
if (!Object.values(types_1.NameType).includes(type)) {
|
|
246
|
+
errorMessages.push(`Must specify one of the following types: ${Object.values(types_1.NameType).join(', ')}`);
|
|
247
|
+
}
|
|
248
|
+
}, _NameController_validateName = function _NameController_validateName(name, errorMessages) {
|
|
249
|
+
if (!(name === null || name === void 0 ? void 0 : name.length) || typeof name !== 'string') {
|
|
250
|
+
errorMessages.push('Must specify a non-empty string for name.');
|
|
251
|
+
}
|
|
252
|
+
}, _NameController_validateSourceIds = function _NameController_validateSourceIds(sourceIds, type, errorMessages) {
|
|
253
|
+
if (!sourceIds) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
const allSourceIds = __classPrivateFieldGet(this, _NameController_instances, "m", _NameController_getAllSourceIds).call(this, type);
|
|
257
|
+
const missingSourceIds = [];
|
|
258
|
+
for (const sourceId of sourceIds) {
|
|
259
|
+
if (!allSourceIds.includes(sourceId)) {
|
|
260
|
+
missingSourceIds.push(sourceId);
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
if (missingSourceIds.length) {
|
|
265
|
+
errorMessages.push(`Unknown source IDs for type '${type}': ${missingSourceIds.join(', ')}`);
|
|
266
|
+
}
|
|
267
|
+
}, _NameController_validateSourceId = function _NameController_validateSourceId(sourceId, type, errorMessages) {
|
|
268
|
+
if (sourceId === null || sourceId === undefined) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
const allSourceIds = __classPrivateFieldGet(this, _NameController_instances, "m", _NameController_getAllSourceIds).call(this, type);
|
|
272
|
+
if (!sourceId.length || typeof sourceId !== 'string') {
|
|
273
|
+
errorMessages.push('Must specify a non-empty string for sourceId.');
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
if (!allSourceIds.includes(sourceId)) {
|
|
277
|
+
errorMessages.push(`Unknown source ID for type '${type}': ${sourceId}`);
|
|
278
|
+
}
|
|
279
|
+
}, _NameController_validateDuplicateSourceIds = function _NameController_validateDuplicateSourceIds(type, errorMessages) {
|
|
280
|
+
const allSourceIds = __classPrivateFieldGet(this, _NameController_instances, "m", _NameController_getAllSourceIds).call(this, type);
|
|
281
|
+
const duplicateSourceIds = allSourceIds.filter((sourceId, index) => allSourceIds.indexOf(sourceId) !== index);
|
|
282
|
+
if (duplicateSourceIds.length) {
|
|
283
|
+
errorMessages.push(`Duplicate source IDs found for type '${type}': ${duplicateSourceIds.join(', ')}`);
|
|
284
|
+
}
|
|
285
|
+
}, _NameController_getAllSourceIds = function _NameController_getAllSourceIds(type) {
|
|
286
|
+
return (__classPrivateFieldGet(this, _NameController_providers, "f")
|
|
287
|
+
/* istanbul ignore next */
|
|
288
|
+
.map((provider) => __classPrivateFieldGet(this, _NameController_instances, "m", _NameController_getSourceIds).call(this, provider, type))
|
|
289
|
+
.flat());
|
|
290
|
+
}, _NameController_getSourceIds = function _NameController_getSourceIds(provider, type) {
|
|
291
|
+
return provider.getMetadata().sourceIds[type];
|
|
292
|
+
};
|
|
293
|
+
//# sourceMappingURL=NameController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NameController.js","sourceRoot":"","sources":["../src/NameController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,+DAA6D;AAQ7D,mCAAmC;AAEnC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAExC,MAAM,aAAa,GAAG;IACpB,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE;IAC1C,WAAW,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE;CACjD,CAAC;AAEF,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,CAAC;IAC7B,KAAK,EAAE;QACL,CAAC,gBAAQ,CAAC,gBAAgB,CAAC,EAAE,EAAE;KAChC;IACD,WAAW,EAAE,EAAE;CAChB,CAAC,CAAC;AAiEH;;GAEG;AACH,MAAa,cAAe,SAAQ,kCAInC;IAKC;;;;;;;;OAQG;IACH,YAAY,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,KAAK,GACiB;QACtB,KAAK,CAAC;YACJ,IAA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AAE,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,KAAK,CAC9D,CAAC;IAEF,IAAI,kBAAkB,CAAC,MAAM,EAAE;QAC7B,aAAa,CAAC,IAAI,CAChB,wCAAwC,IAAI,MAAM,kBAAkB,CAAC,IAAI,CACvE,IAAI,CACL,EAAE,CACJ,CAAC;KACH;AACH,CAAC,6EAEgB,IAAc;IAC7B,OAAO,CACL,uBAAA,IAAI,iCAAW;QACb,0BAA0B;SACzB,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,uBAAA,IAAI,+DAAc,MAAlB,IAAI,EAAe,QAAQ,EAAE,IAAI,CAAC,CAAC;SACrD,IAAI,EAAE,CACV,CAAC;AACJ,CAAC,uEAEa,QAAsB,EAAE,IAAc;IAClD,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import type { RestrictedControllerMessenger } from '@metamask/base-controller';\nimport { BaseControllerV2 } from '@metamask/base-controller';\nimport type { Patch } from 'immer';\n\nimport type {\n NameProvider,\n NameProviderRequest,\n NameProviderResult,\n} from './types';\nimport { NameType } from './types';\n\nconst controllerName = 'NameController';\n\nconst stateMetadata = {\n names: { persist: true, anonymous: false },\n nameSources: { persist: true, anonymous: false },\n};\n\nconst getDefaultState = () => ({\n names: {\n [NameType.ETHEREUM_ADDRESS]: {},\n },\n nameSources: {},\n});\n\nexport type NameEntry = {\n name: string | null;\n sourceId: string | null;\n proposedNames: Record<string, string[] | null>;\n proposedNamesLastUpdated: number | null;\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 = {\n type: `${typeof controllerName}:getState`;\n handler: () => NameControllerState;\n};\n\nexport type NameStateChange = {\n type: `${typeof controllerName}:stateChange`;\n payload: [NameControllerState, Patch[]];\n};\n\nexport type NameControllerActions = GetNameState;\n\nexport type NameControllerEvents = NameStateChange;\n\nexport type NameControllerMessenger = RestrictedControllerMessenger<\n typeof controllerName,\n NameControllerActions,\n NameControllerEvents,\n never,\n never\n>;\n\nexport type NameControllerOptions = {\n getChainId: () => string;\n messenger: NameControllerMessenger;\n providers: NameProvider[];\n state?: Partial<NameControllerState>;\n};\n\nexport type UpdateProposedNamesRequest = {\n value: string;\n type: NameType;\n sourceIds?: 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;\n sourceId?: string;\n};\n\n/**\n * Controller for storing and deriving names for values such as Ethereum addresses.\n */\nexport class NameController extends BaseControllerV2<\n typeof controllerName,\n NameControllerState,\n NameControllerMessenger\n> {\n #getChainId: () => string;\n\n #providers: NameProvider[];\n\n /**\n * Construct a Name controller.\n *\n * @param options - Controller options.\n * @param options.getChainId - Callback that returns the chain ID of the current network.\n * @param options.messenger - Restricted controller 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 */\n constructor({\n getChainId,\n messenger,\n providers,\n state,\n }: NameControllerOptions) {\n super({\n name: controllerName,\n metadata: stateMetadata,\n messenger,\n state: { ...getDefaultState(), ...state },\n });\n\n this.#getChainId = getChainId;\n this.#providers = providers;\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 */\n setName(request: SetNameRequest) {\n this.#validateSetNameRequest(request);\n\n const { value, type, name, sourceId } = request;\n\n this.#updateEntry(value, type, { name, sourceId: sourceId ?? null });\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 * @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 chainId = this.#getChainId();\n\n const providerResponses = (\n await Promise.all(\n this.#providers.map((provider) =>\n this.#getProviderResponse(request, chainId, provider),\n ),\n )\n ).filter((response) => Boolean(response)) as NameProviderResult[];\n\n this.#updateProposedNameState(request, providerResponses);\n this.#updateSourceState(this.#providers);\n\n return this.#getUpdateProposedNamesResult(providerResponses);\n }\n\n #updateProposedNameState(\n request: UpdateProposedNamesRequest,\n providerResponses: NameProviderResult[],\n ) {\n const { value, type } = request;\n const newProposedNames: { [sourceId: string]: string[] | null } = {};\n\n for (const providerResponse of providerResponses) {\n const { results, error: responseError } = providerResponse;\n\n if (responseError) {\n continue;\n }\n\n for (const sourceId of Object.keys(providerResponse.results)) {\n const result = results[sourceId];\n const { proposedNames } = result;\n let finalProposedNames = result.error ? null : proposedNames ?? [];\n\n if (finalProposedNames) {\n finalProposedNames = finalProposedNames.filter(\n (proposedName) => proposedName?.length,\n );\n }\n\n newProposedNames[sourceId] = finalProposedNames;\n }\n }\n\n const variationKey = this.#getTypeVariationKey(type);\n\n const existingProposedNames =\n this.state.names[type]?.[value]?.[variationKey]?.proposedNames;\n\n const proposedNames = {\n ...existingProposedNames,\n ...newProposedNames,\n };\n\n const proposedNamesLastUpdated = this.#getCurrentTimeSeconds();\n\n this.#updateEntry(value, type, { proposedNames, proposedNamesLastUpdated });\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: resultProposedNames, error: resultError } =\n results[sourceId];\n\n let proposedNames = resultError\n ? undefined\n : resultProposedNames ?? [];\n\n if (proposedNames) {\n proposedNames = proposedNames.filter(\n (proposedName) => proposedName?.length,\n );\n }\n\n acc.results[sourceId] = {\n proposedNames,\n error: resultError,\n };\n }\n\n return acc;\n },\n { results: {} },\n );\n }\n\n async #getProviderResponse(\n request: UpdateProposedNamesRequest,\n chainId: string,\n provider: NameProvider,\n ): Promise<NameProviderResult | undefined> {\n const { value, type, sourceIds: requestedSourceIds } = request;\n const supportedSourceIds = this.#getSourceIds(provider, type);\n\n const matchingSourceIds =\n requestedSourceIds?.filter((sourceId) =>\n supportedSourceIds.includes(sourceId),\n ) ?? supportedSourceIds;\n\n if (requestedSourceIds && !matchingSourceIds.length) {\n return undefined;\n }\n\n const providerRequest: NameProviderRequest = {\n chainId,\n value,\n type,\n sourceIds: requestedSourceIds ? matchingSourceIds : undefined,\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 let results = {};\n\n if (response?.results) {\n results = Object.keys(response.results).reduce(\n (acc: NameProviderResult['results'], sourceId) => {\n if (!requestedSourceIds || requestedSourceIds.includes(sourceId)) {\n acc[sourceId] = (response as NameProviderResult).results[sourceId];\n }\n\n return acc;\n },\n {},\n );\n }\n\n if (responseError) {\n results = supportedSourceIds.reduce(\n (acc: NameProviderResult['results'], sourceId) => {\n acc[sourceId] = { proposedNames: [], error: responseError };\n return acc;\n },\n {},\n );\n }\n\n return { results, error: responseError };\n }\n\n #updateEntry(value: string, type: NameType, data: Partial<NameEntry>) {\n const variationKey = this.#getTypeVariationKey(type);\n\n this.update((state) => {\n const typeEntries = state.names[type] || {};\n state.names[type] = typeEntries;\n\n const variationEntries = typeEntries[value] || {};\n typeEntries[value] = variationEntries;\n\n const currentEntry = variationEntries[variationKey] ?? {\n proposedNames: {},\n proposedNamesLastUpdated: null,\n name: null,\n sourceId: null,\n };\n\n const updatedEntry = { ...currentEntry, ...data };\n\n variationEntries[variationKey] = updatedEntry;\n });\n }\n\n #getTypeVariationKey(type: NameType): string {\n switch (type) {\n default: {\n return this.#getChainId();\n }\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 } = 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, errorMessages);\n\n if (errorMessages.length) {\n throw new Error(errorMessages.join(' '));\n }\n }\n\n #validateUpdateProposedNamesRequest(request: UpdateProposedNamesRequest) {\n const { value, type, sourceIds } = 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\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, errorMessages: string[]) {\n if (!name?.length || typeof name !== 'string') {\n errorMessages.push('Must specify a non-empty string 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 errorMessages: string[],\n ) {\n if (sourceId === null || sourceId === undefined) {\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 #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"]}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export declare const CHAIN_IDS: {
|
|
2
|
+
readonly MAINNET: "0x1";
|
|
3
|
+
readonly GOERLI: "0x5";
|
|
4
|
+
readonly BSC: "0x38";
|
|
5
|
+
readonly BSC_TESTNET: "0x61";
|
|
6
|
+
readonly OPTIMISM: "0xa";
|
|
7
|
+
readonly OPTIMISM_TESTNET: "0x1a4";
|
|
8
|
+
readonly POLYGON: "0x89";
|
|
9
|
+
readonly POLYGON_TESTNET: "0x13881";
|
|
10
|
+
readonly AVALANCHE: "0xa86a";
|
|
11
|
+
readonly AVALANCHE_TESTNET: "0xa869";
|
|
12
|
+
readonly FANTOM: "0xfa";
|
|
13
|
+
readonly FANTOM_TESTNET: "0xfa2";
|
|
14
|
+
readonly SEPOLIA: "0xaa36a7";
|
|
15
|
+
readonly LINEA_GOERLI: "0xe704";
|
|
16
|
+
readonly LINEA_MAINNET: "0xe708";
|
|
17
|
+
readonly MOONBEAM: "0x504";
|
|
18
|
+
readonly MOONBEAM_TESTNET: "0x507";
|
|
19
|
+
readonly MOONRIVER: "0x505";
|
|
20
|
+
readonly GNOSIS: "0x64";
|
|
21
|
+
};
|
|
22
|
+
export declare const ETHERSCAN_SUPPORTED_NETWORKS: {
|
|
23
|
+
"0x5": {
|
|
24
|
+
domain: string;
|
|
25
|
+
subdomain: string;
|
|
26
|
+
};
|
|
27
|
+
"0x1": {
|
|
28
|
+
domain: string;
|
|
29
|
+
subdomain: string;
|
|
30
|
+
};
|
|
31
|
+
"0xaa36a7": {
|
|
32
|
+
domain: string;
|
|
33
|
+
subdomain: string;
|
|
34
|
+
};
|
|
35
|
+
"0xe704": {
|
|
36
|
+
domain: string;
|
|
37
|
+
subdomain: string;
|
|
38
|
+
};
|
|
39
|
+
"0xe708": {
|
|
40
|
+
domain: string;
|
|
41
|
+
subdomain: string;
|
|
42
|
+
};
|
|
43
|
+
"0x38": {
|
|
44
|
+
domain: string;
|
|
45
|
+
subdomain: string;
|
|
46
|
+
};
|
|
47
|
+
"0x61": {
|
|
48
|
+
domain: string;
|
|
49
|
+
subdomain: string;
|
|
50
|
+
};
|
|
51
|
+
"0xa": {
|
|
52
|
+
domain: string;
|
|
53
|
+
subdomain: string;
|
|
54
|
+
};
|
|
55
|
+
"0x1a4": {
|
|
56
|
+
domain: string;
|
|
57
|
+
subdomain: string;
|
|
58
|
+
};
|
|
59
|
+
"0x89": {
|
|
60
|
+
domain: string;
|
|
61
|
+
subdomain: string;
|
|
62
|
+
};
|
|
63
|
+
"0x13881": {
|
|
64
|
+
domain: string;
|
|
65
|
+
subdomain: string;
|
|
66
|
+
};
|
|
67
|
+
"0xa86a": {
|
|
68
|
+
domain: string;
|
|
69
|
+
subdomain: string;
|
|
70
|
+
};
|
|
71
|
+
"0xa869": {
|
|
72
|
+
domain: string;
|
|
73
|
+
subdomain: string;
|
|
74
|
+
};
|
|
75
|
+
"0xfa": {
|
|
76
|
+
domain: string;
|
|
77
|
+
subdomain: string;
|
|
78
|
+
};
|
|
79
|
+
"0xfa2": {
|
|
80
|
+
domain: string;
|
|
81
|
+
subdomain: string;
|
|
82
|
+
};
|
|
83
|
+
"0x504": {
|
|
84
|
+
domain: string;
|
|
85
|
+
subdomain: string;
|
|
86
|
+
};
|
|
87
|
+
"0x507": {
|
|
88
|
+
domain: string;
|
|
89
|
+
subdomain: string;
|
|
90
|
+
};
|
|
91
|
+
"0x505": {
|
|
92
|
+
domain: string;
|
|
93
|
+
subdomain: string;
|
|
94
|
+
};
|
|
95
|
+
"0x64": {
|
|
96
|
+
domain: string;
|
|
97
|
+
subdomain: string;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;CAoBZ,CAAC;AAKX,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6ExC,CAAC"}
|