@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/dist/util.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.successfulFetch = exports.handleFetch = exports.graphQL = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* Execute a GraphQL query.
|
|
15
|
+
*
|
|
16
|
+
* @param url - GraphQL endpoint URL.
|
|
17
|
+
* @param query - GraphQL query.
|
|
18
|
+
* @param variables - GraphQL variables.
|
|
19
|
+
*/
|
|
20
|
+
function graphQL(url, query, variables) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const body = JSON.stringify({
|
|
23
|
+
query,
|
|
24
|
+
variables,
|
|
25
|
+
});
|
|
26
|
+
const response = yield handleFetch(url, {
|
|
27
|
+
body,
|
|
28
|
+
method: 'POST',
|
|
29
|
+
headers: {
|
|
30
|
+
'Content-Type': 'application/json',
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
return response === null || response === void 0 ? void 0 : response.data;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
exports.graphQL = graphQL;
|
|
37
|
+
// Below functions are intentionally copied from controller-utils to avoid a package dependency
|
|
38
|
+
/**
|
|
39
|
+
* Execute fetch and return object response.
|
|
40
|
+
*
|
|
41
|
+
* @param request - The request information.
|
|
42
|
+
* @param options - The fetch options.
|
|
43
|
+
* @returns The fetch response JSON data.
|
|
44
|
+
*/
|
|
45
|
+
function handleFetch(request, options) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const response = yield successfulFetch(request, options);
|
|
48
|
+
const object = yield response.json();
|
|
49
|
+
return object;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
exports.handleFetch = handleFetch;
|
|
53
|
+
/**
|
|
54
|
+
* Execute fetch and verify that the response was successful.
|
|
55
|
+
*
|
|
56
|
+
* @param request - Request information.
|
|
57
|
+
* @param options - Fetch options.
|
|
58
|
+
* @returns The fetch response.
|
|
59
|
+
*/
|
|
60
|
+
function successfulFetch(request, options) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
const response = yield fetch(request, options);
|
|
63
|
+
if (!response.ok) {
|
|
64
|
+
throw new Error(`Fetch failed with status '${response.status}' for request '${request}'`);
|
|
65
|
+
}
|
|
66
|
+
return response;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
exports.successfulFetch = successfulFetch;
|
|
70
|
+
//# sourceMappingURL=util.js.map
|
package/dist/util.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;GAMG;AACH,SAAsB,OAAO,CAC3B,GAAW,EACX,KAAa,EACb,SAA8B;;QAE9B,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC;YAC1B,KAAK;YACL,SAAS;SACV,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,GAAG,EAAE;YACtC,IAAI;YACJ,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;QAEH,OAAO,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,CAAC;IACxB,CAAC;CAAA;AAnBD,0BAmBC;AAED,+FAA+F;AAE/F;;;;;;GAMG;AACH,SAAsB,WAAW,CAAC,OAAe,EAAE,OAAqB;;QACtE,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACzD,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACrC,OAAO,MAAM,CAAC;IAChB,CAAC;CAAA;AAJD,kCAIC;AAED;;;;;;GAMG;AACH,SAAsB,eAAe,CAAC,OAAe,EAAE,OAAqB;;QAC1E,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC/C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;YAChB,MAAM,IAAI,KAAK,CACb,6BAA6B,QAAQ,CAAC,MAAM,kBAAkB,OAAO,GAAG,CACzE,CAAC;SACH;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CAAA;AARD,0CAQC","sourcesContent":["/**\n * Execute a GraphQL query.\n *\n * @param url - GraphQL endpoint URL.\n * @param query - GraphQL query.\n * @param variables - GraphQL variables.\n */\nexport async function graphQL<T>(\n url: string,\n query: string,\n variables: Record<string, any>,\n): Promise<T> {\n const body = JSON.stringify({\n query,\n variables,\n });\n\n const response = await handleFetch(url, {\n body,\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n return response?.data;\n}\n\n// Below functions are intentionally copied from controller-utils to avoid a package dependency\n\n/**\n * Execute fetch and return object response.\n *\n * @param request - The request information.\n * @param options - The fetch options.\n * @returns The fetch response JSON data.\n */\nexport async function handleFetch(request: string, options?: RequestInit) {\n const response = await successfulFetch(request, options);\n const object = await response.json();\n return object;\n}\n\n/**\n * Execute fetch and verify that the response was successful.\n *\n * @param request - Request information.\n * @param options - Fetch options.\n * @returns The fetch response.\n */\nexport async function successfulFetch(request: string, options?: RequestInit) {\n const response = await fetch(request, options);\n if (!response.ok) {\n throw new Error(\n `Fetch failed with status '${response.status}' for request '${request}'`,\n );\n }\n return response;\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@metamask/name-controller",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Stores and suggests names for values such as Ethereum addresses",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"MetaMask",
|
|
7
|
+
"Ethereum"
|
|
8
|
+
],
|
|
9
|
+
"homepage": "https://github.com/MetaMask/core/tree/main/packages/name-controller#readme",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/MetaMask/core/issues"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/MetaMask/core.git"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"main": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"files": [
|
|
21
|
+
"dist/"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build:docs": "typedoc",
|
|
25
|
+
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/name-controller",
|
|
26
|
+
"prepare-manifest:preview": "../../scripts/prepare-preview-manifest.sh",
|
|
27
|
+
"publish:preview": "yarn npm publish --tag preview",
|
|
28
|
+
"test": "jest",
|
|
29
|
+
"test:watch": "jest --watch"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@metamask/base-controller": "^3.2.1",
|
|
33
|
+
"immer": "^9.0.6"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@metamask/auto-changelog": "^3.1.0",
|
|
37
|
+
"@types/jest": "^27.4.1",
|
|
38
|
+
"deepmerge": "^4.2.2",
|
|
39
|
+
"jest": "^27.5.1",
|
|
40
|
+
"ts-jest": "^27.1.4",
|
|
41
|
+
"typedoc": "^0.22.15",
|
|
42
|
+
"typedoc-plugin-missing-exports": "^0.22.6",
|
|
43
|
+
"typescript": "~4.6.3"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=16.0.0"
|
|
47
|
+
},
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public",
|
|
50
|
+
"registry": "https://registry.npmjs.org/"
|
|
51
|
+
}
|
|
52
|
+
}
|