From 38c26e70bc61b5181fdf6f9c6907da6c20e8a953 Mon Sep 17 00:00:00 2001 From: kvhnuke <10602065+kvhnuke@users.noreply.github.com> Date: Mon, 19 Sep 2022 13:58:06 -0700 Subject: [PATCH 01/21] devop: create new package --- package.json | 3 +- packages/name-resolution/.editorconfig | 10 + packages/name-resolution/.eslintignore | 1 + packages/name-resolution/.eslintrc.json | 66 +++ packages/name-resolution/.gitignore | 107 +++++ packages/name-resolution/.nvmrc | 1 + packages/name-resolution/LICENSE | 21 + packages/name-resolution/README.md | 2 + packages/name-resolution/package.json | 47 ++ packages/name-resolution/src/index.ts | 7 + packages/name-resolution/src/types/types.d.ts | 4 + .../name-resolution/tests/example.test.ts | 6 + packages/name-resolution/tsconfig.json | 28 ++ packages/name-resolution/tsconfig.paths.json | 8 + yarn.lock | 403 +++++++++++++++++- 15 files changed, 705 insertions(+), 9 deletions(-) create mode 100644 packages/name-resolution/.editorconfig create mode 100644 packages/name-resolution/.eslintignore create mode 100644 packages/name-resolution/.eslintrc.json create mode 100644 packages/name-resolution/.gitignore create mode 100644 packages/name-resolution/.nvmrc create mode 100644 packages/name-resolution/LICENSE create mode 100644 packages/name-resolution/README.md create mode 100644 packages/name-resolution/package.json create mode 100644 packages/name-resolution/src/index.ts create mode 100644 packages/name-resolution/src/types/types.d.ts create mode 100644 packages/name-resolution/tests/example.test.ts create mode 100644 packages/name-resolution/tsconfig.json create mode 100644 packages/name-resolution/tsconfig.paths.json diff --git a/package.json b/package.json index 0dca0dc59..6b9b5cdc9 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "packages/extension", "packages/storage", "packages/request", - "packages/hw-wallets" + "packages/hw-wallets", + "packages/name-resolution" ], "scripts": { "test": "yarn workspaces foreach -pv run test", diff --git a/packages/name-resolution/.editorconfig b/packages/name-resolution/.editorconfig new file mode 100644 index 000000000..aa7d67e49 --- /dev/null +++ b/packages/name-resolution/.editorconfig @@ -0,0 +1,10 @@ +# Editor configuration, see http://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 + +[*.sh] +indent_size = 4 \ No newline at end of file diff --git a/packages/name-resolution/.eslintignore b/packages/name-resolution/.eslintignore new file mode 100644 index 000000000..4ebc8aea5 --- /dev/null +++ b/packages/name-resolution/.eslintignore @@ -0,0 +1 @@ +coverage diff --git a/packages/name-resolution/.eslintrc.json b/packages/name-resolution/.eslintrc.json new file mode 100644 index 000000000..d33f3e9e9 --- /dev/null +++ b/packages/name-resolution/.eslintrc.json @@ -0,0 +1,66 @@ +{ + "extends": [ + "airbnb-base", + "plugin:import/errors", + "plugin:import/warnings", + "plugin:import/typescript", + "plugin:@typescript-eslint/recommended", + "prettier" + ], + "plugins": ["@typescript-eslint"], + "root": true, + "globals": {}, + "rules": { + "@typescript-eslint/no-var-requires": "off", + "no-multi-assign": "off", + "no-param-reassign": "off", + "no-underscore-dangle": "off", + "no-continue": "off", + "@typescript-eslint/ban-ts-comment": "off", + "no-console": "off", + "no-plusplus": "off", + "import/extensions": [ + "error", + "ignorePackages", + { + "js": "never", + "jsx": "never", + "ts": "never", + "tsx": "never" + } + ], + "import/no-unresolved": [ + 2, + { + "commonjs": true, + "amd": true + } + ], + "import/prefer-default-export": "off", + "max-len": [ + "error", + { + "code": 150, + "ignoreComments": true, + "ignoreTrailingComments": true, + "ignoreUrls": true, + "ignoreStrings": true, + "ignoreTemplateLiterals": true + } + ] + }, + "parser": "@typescript-eslint/parser", + "env": {}, + "overrides": [], + "settings": { + "import/resolver": { + "alias": { + "map": [ + ["@src", "./src"], + ["@tests", "./tests"] + ], + "extensions": [".ts", ".js"] + } + } + } +} diff --git a/packages/name-resolution/.gitignore b/packages/name-resolution/.gitignore new file mode 100644 index 000000000..f512ba0ff --- /dev/null +++ b/packages/name-resolution/.gitignore @@ -0,0 +1,107 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# Next.js build output +.next + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and *not* Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +dist +*.log \ No newline at end of file diff --git a/packages/name-resolution/.nvmrc b/packages/name-resolution/.nvmrc new file mode 100644 index 000000000..7480d3c85 --- /dev/null +++ b/packages/name-resolution/.nvmrc @@ -0,0 +1 @@ +lts/fermium \ No newline at end of file diff --git a/packages/name-resolution/LICENSE b/packages/name-resolution/LICENSE new file mode 100644 index 000000000..0c437d9d2 --- /dev/null +++ b/packages/name-resolution/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2022 kvhnuke <10602065+kvhnuke@users.noreply.github.com> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/name-resolution/README.md b/packages/name-resolution/README.md new file mode 100644 index 000000000..5b0ee17c2 --- /dev/null +++ b/packages/name-resolution/README.md @@ -0,0 +1,2 @@ +# name resolution +## name resolution module for enkrypt \ No newline at end of file diff --git a/packages/name-resolution/package.json b/packages/name-resolution/package.json new file mode 100644 index 000000000..3eb015bfa --- /dev/null +++ b/packages/name-resolution/package.json @@ -0,0 +1,47 @@ +{ + "name": "name resolution", + "version": "0.1.3", + "description": "name resolution module for enkrypt", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "files": [ + "dist" + ], + "scripts": { + "build": "tsup src/index.ts --format esm,cjs --dts", + "lint": "eslint . --ext .js,.jsx,.ts,.tsx --fix", + "test": "ts-mocha -p tsconfig.json tests/**/*.test.ts" + }, + "engines": { + "node": ">=14.15.0" + }, + "devDependencies": { + "@types/chai": "^4.3.0", + "@types/mocha": "^9.1.0", + "@types/node": "^17.0.17", + "@typescript-eslint/eslint-plugin": "^5.11.0", + "@typescript-eslint/parser": "^5.11.0", + "chai": "^4.3.6", + "eslint": "^8.9.0", + "eslint-config-airbnb-base": "^15.0.0", + "eslint-config-prettier": "^8.3.0", + "eslint-import-resolver-alias": "^1.1.2", + "eslint-plugin-import": "^2.25.4", + "eslint-plugin-module-resolver": "^1.4.0", + "mocha": "^9.2.0", + "prettier": "^2.5.1", + "ts-mocha": "^9.0.2", + "ts-node": "^10.5.0", + "tsconfig-paths": "^3.12.0", + "tsup": "^5.11.13", + "typescript": "^4.5.5", + "typescript-eslint": "0.0.1-alpha.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/" + }, + "keywords": [], + "author": "kvhnuke", + "license": "MIT" +} diff --git a/packages/name-resolution/src/index.ts b/packages/name-resolution/src/index.ts new file mode 100644 index 000000000..a427d2b29 --- /dev/null +++ b/packages/name-resolution/src/index.ts @@ -0,0 +1,7 @@ +export function sayHello(name: string): string { + const abc: ExampleType = { + platform: "my-platform", + version: "my-version" + } + return `Hello ${name} ${JSON.stringify(abc)}`; +} \ No newline at end of file diff --git a/packages/name-resolution/src/types/types.d.ts b/packages/name-resolution/src/types/types.d.ts new file mode 100644 index 000000000..c26cf9b52 --- /dev/null +++ b/packages/name-resolution/src/types/types.d.ts @@ -0,0 +1,4 @@ +type ExampleType = { + platform: string; + version: string; +}; \ No newline at end of file diff --git a/packages/name-resolution/tests/example.test.ts b/packages/name-resolution/tests/example.test.ts new file mode 100644 index 000000000..71c28258c --- /dev/null +++ b/packages/name-resolution/tests/example.test.ts @@ -0,0 +1,6 @@ +import { expect } from 'chai'; +describe('Simple addition', () => { // the tests container + it('it should properly add', async () => { + expect(1 + 2).to.be.equals(3) + }); +}); \ No newline at end of file diff --git a/packages/name-resolution/tsconfig.json b/packages/name-resolution/tsconfig.json new file mode 100644 index 000000000..6da8e1f23 --- /dev/null +++ b/packages/name-resolution/tsconfig.json @@ -0,0 +1,28 @@ +{ + "extends": "./tsconfig.paths.json", + "compilerOptions": { + "lib": ["ESNext", "dom"], + "moduleResolution": "node", + "noUnusedLocals": true, + "noUnusedParameters": true, + "removeComments": true, + "sourceMap": true, + "target": "es5", + "module": "commonjs", + "outDir": "dist", + "resolveJsonModule": true, + "esModuleInterop": true, + "declaration": true + }, + "include": ["src/**/*.ts", "tests/**/*.ts"], + "exclude": [ + "node_modules/**/*", + "_warmup/**/*", + ".vscode/**/*", + "tests/**/*" + ], + "ts-node": { + "require": ["tsconfig-paths/register"], + "files": true + } +} diff --git a/packages/name-resolution/tsconfig.paths.json b/packages/name-resolution/tsconfig.paths.json new file mode 100644 index 000000000..6451834c2 --- /dev/null +++ b/packages/name-resolution/tsconfig.paths.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "paths": { + "@src/*": ["src/*"] + } + } +} diff --git a/yarn.lock b/yarn.lock index 774c8c17d..e6af41152 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2766,6 +2766,23 @@ __metadata: languageName: node linkType: hard +"@eslint/eslintrc@npm:^1.3.2": + version: 1.3.2 + resolution: "@eslint/eslintrc@npm:1.3.2" + dependencies: + ajv: ^6.12.4 + debug: ^4.3.2 + espree: ^9.4.0 + globals: ^13.15.0 + ignore: ^5.2.0 + import-fresh: ^3.2.1 + js-yaml: ^4.1.0 + minimatch: ^3.1.2 + strip-json-comments: ^3.1.1 + checksum: 2074dca47d7e1c5c6323ff353f690f4b25d3ab53fe7d27337e2592d37a894cf60ca0e85ca66b50ff2db0bc7e630cc1e9c7347d65bb185b61416565584c38999c + languageName: node + linkType: hard + "@ethereumjs/common@npm:^2.5.0, @ethereumjs/common@npm:^2.6.3, @ethereumjs/common@npm:^2.6.4": version: 2.6.4 resolution: "@ethereumjs/common@npm:2.6.4" @@ -3349,6 +3366,13 @@ __metadata: languageName: node linkType: hard +"@humanwhocodes/module-importer@npm:^1.0.1": + version: 1.0.1 + resolution: "@humanwhocodes/module-importer@npm:1.0.1" + checksum: 0fd22007db8034a2cdf2c764b140d37d9020bbfce8a49d3ec5c05290e77d4b0263b1b972b752df8c89e5eaa94073408f2b7d977aed131faf6cf396ebb5d7fb61 + languageName: node + linkType: hard + "@humanwhocodes/object-schema@npm:^1.2.1": version: 1.2.1 resolution: "@humanwhocodes/object-schema@npm:1.2.1" @@ -6019,7 +6043,7 @@ __metadata: languageName: node linkType: hard -"@types/chai@npm:^4.3.3": +"@types/chai@npm:^4.3.0, @types/chai@npm:^4.3.3": version: 4.3.3 resolution: "@types/chai@npm:4.3.3" checksum: 20cd094753e137cfc35939cae7f0ed78ecda7861e5c94704efab6979b9121a63807e9b631bdcf3a2792d6c6dba44050b13387262f9e63ebb040741c01c345f0a @@ -6371,7 +6395,7 @@ __metadata: languageName: node linkType: hard -"@types/mocha@npm:^9.1.1": +"@types/mocha@npm:^9.1.0, @types/mocha@npm:^9.1.1": version: 9.1.1 resolution: "@types/mocha@npm:9.1.1" checksum: 516077c0acd9806dc78317f88aaac0df5aaf0bdc2f63dfdadeabdf0b0137953b6ca65472e6ff7c30bc93ce4e0ae76eae70e8d46764b9a8eae4877a928b6ef49a @@ -6451,6 +6475,13 @@ __metadata: languageName: node linkType: hard +"@types/node@npm:^17.0.17": + version: 17.0.45 + resolution: "@types/node@npm:17.0.45" + checksum: aa04366b9103b7d6cfd6b2ef64182e0eaa7d4462c3f817618486ea0422984c51fc69fd0d436eae6c9e696ddfdbec9ccaa27a917f7c2e8c75c5d57827fe3d95e8 + languageName: node + linkType: hard + "@types/node@npm:^18.6.5": version: 18.6.5 resolution: "@types/node@npm:18.6.5" @@ -6720,6 +6751,28 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/eslint-plugin@npm:^5.11.0": + version: 5.38.0 + resolution: "@typescript-eslint/eslint-plugin@npm:5.38.0" + dependencies: + "@typescript-eslint/scope-manager": 5.38.0 + "@typescript-eslint/type-utils": 5.38.0 + "@typescript-eslint/utils": 5.38.0 + debug: ^4.3.4 + ignore: ^5.2.0 + regexpp: ^3.2.0 + semver: ^7.3.7 + tsutils: ^3.21.0 + peerDependencies: + "@typescript-eslint/parser": ^5.0.0 + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + peerDependenciesMeta: + typescript: + optional: true + checksum: e9cd1970c7c8a438aee912cf00aa27bdcde0a0fb57bbfe70eccda93eefa5b4fb4c7ebf5ba7a51744c1ec2b4df3a72b8dcd19dc17a9c3e4e3435f631ac6b10a6a + languageName: node + linkType: hard + "@typescript-eslint/parser@npm:^5.0.0, @typescript-eslint/parser@npm:^5.32.0, @typescript-eslint/parser@npm:^5.33.0": version: 5.33.0 resolution: "@typescript-eslint/parser@npm:5.33.0" @@ -6737,6 +6790,23 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/parser@npm:^5.11.0": + version: 5.38.0 + resolution: "@typescript-eslint/parser@npm:5.38.0" + dependencies: + "@typescript-eslint/scope-manager": 5.38.0 + "@typescript-eslint/types": 5.38.0 + "@typescript-eslint/typescript-estree": 5.38.0 + debug: ^4.3.4 + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + peerDependenciesMeta: + typescript: + optional: true + checksum: d5fb2d8f3a25cd6ff31326c665db4617f2d428247cad690f0404de440abbcfc7261528f54d642d2b121aae34aadecb55a24b72c8ef341cafdc7b2bbcbf7dae8d + languageName: node + linkType: hard + "@typescript-eslint/scope-manager@npm:5.33.0": version: 5.33.0 resolution: "@typescript-eslint/scope-manager@npm:5.33.0" @@ -6747,6 +6817,16 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/scope-manager@npm:5.38.0": + version: 5.38.0 + resolution: "@typescript-eslint/scope-manager@npm:5.38.0" + dependencies: + "@typescript-eslint/types": 5.38.0 + "@typescript-eslint/visitor-keys": 5.38.0 + checksum: a34d2976e9c755b853b6524e0b9fb1da237340ddff9f6839a51ba37998527c02d0f2f16ffc3d4baa47898f2bb7eb85a6749d6ca588c0461dbd654d8f9925dd0f + languageName: node + linkType: hard + "@typescript-eslint/type-utils@npm:5.33.0": version: 5.33.0 resolution: "@typescript-eslint/type-utils@npm:5.33.0" @@ -6763,6 +6843,23 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/type-utils@npm:5.38.0": + version: 5.38.0 + resolution: "@typescript-eslint/type-utils@npm:5.38.0" + dependencies: + "@typescript-eslint/typescript-estree": 5.38.0 + "@typescript-eslint/utils": 5.38.0 + debug: ^4.3.4 + tsutils: ^3.21.0 + peerDependencies: + eslint: "*" + peerDependenciesMeta: + typescript: + optional: true + checksum: 43f2f55329b2357bedf158a93a469d058a11c69f8f88ff891080b8cb5977bffe8d679923bce7048cbc076c083e0f5741c83b761355309d606cc4e217e1da4208 + languageName: node + linkType: hard + "@typescript-eslint/types@npm:5.33.0": version: 5.33.0 resolution: "@typescript-eslint/types@npm:5.33.0" @@ -6770,6 +6867,13 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/types@npm:5.38.0": + version: 5.38.0 + resolution: "@typescript-eslint/types@npm:5.38.0" + checksum: 03aec1de64417e60830c6d33bb4f1bf4402411080371013513f55c7a2fadb6f8745a89a7604cde03d89aa53307f94bc913060c5897ed93285247e4c39af43a00 + languageName: node + linkType: hard + "@typescript-eslint/typescript-estree@npm:5.33.0": version: 5.33.0 resolution: "@typescript-eslint/typescript-estree@npm:5.33.0" @@ -6788,6 +6892,24 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/typescript-estree@npm:5.38.0": + version: 5.38.0 + resolution: "@typescript-eslint/typescript-estree@npm:5.38.0" + dependencies: + "@typescript-eslint/types": 5.38.0 + "@typescript-eslint/visitor-keys": 5.38.0 + debug: ^4.3.4 + globby: ^11.1.0 + is-glob: ^4.0.3 + semver: ^7.3.7 + tsutils: ^3.21.0 + peerDependenciesMeta: + typescript: + optional: true + checksum: 174461c91e49a0340945da2d31e38ec175cd90b2b5068f3c925518cc9182100fe1435d3225908a52f62257e97bc2b995cbc6b6bd1b7143ff0a0e4b483bd70834 + languageName: node + linkType: hard + "@typescript-eslint/utils@npm:5.33.0, @typescript-eslint/utils@npm:^5.32.0": version: 5.33.0 resolution: "@typescript-eslint/utils@npm:5.33.0" @@ -6804,6 +6926,22 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/utils@npm:5.38.0": + version: 5.38.0 + resolution: "@typescript-eslint/utils@npm:5.38.0" + dependencies: + "@types/json-schema": ^7.0.9 + "@typescript-eslint/scope-manager": 5.38.0 + "@typescript-eslint/types": 5.38.0 + "@typescript-eslint/typescript-estree": 5.38.0 + eslint-scope: ^5.1.1 + eslint-utils: ^3.0.0 + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + checksum: c927a68d4ff5029ed3dbc7e6e87702f7cdfba26452ccf401b37cc68f6e5cca72eb884831dbc7957512998d59950b1852b2ecea19f174a20fe659d851b4afd4fd + languageName: node + linkType: hard + "@typescript-eslint/visitor-keys@npm:5.33.0": version: 5.33.0 resolution: "@typescript-eslint/visitor-keys@npm:5.33.0" @@ -6814,6 +6952,16 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/visitor-keys@npm:5.38.0": + version: 5.38.0 + resolution: "@typescript-eslint/visitor-keys@npm:5.38.0" + dependencies: + "@typescript-eslint/types": 5.38.0 + eslint-visitor-keys: ^3.3.0 + checksum: cc3d0c6eb0c9a20a25d66b640d759cb1b52f8df485f16d948218d63d798b5c0672ef298f5dae5e5327ec021c0f8369d1da5d26b9c16a245a20fa44a9365956bc + languageName: node + linkType: hard + "@ungap/promise-all-settled@npm:1.1.2": version: 1.1.2 resolution: "@ungap/promise-all-settled@npm:1.1.2" @@ -10666,6 +10814,18 @@ __metadata: languageName: node linkType: hard +"debug@npm:4.3.3": + version: 4.3.3 + resolution: "debug@npm:4.3.3" + dependencies: + ms: 2.1.2 + peerDependenciesMeta: + supports-color: + optional: true + checksum: 14472d56fe4a94dbcfaa6dbed2dd3849f1d72ba78104a1a328047bb564643ca49df0224c3a17fa63533fd11dd3d4c8636cd861191232a2c6735af00cc2d4de16 + languageName: node + linkType: hard + "debug@npm:^3.1.1, debug@npm:^3.2.6, debug@npm:^3.2.7": version: 3.2.7 resolution: "debug@npm:3.2.7" @@ -11749,7 +11909,7 @@ __metadata: languageName: node linkType: hard -"eslint-config-prettier@npm:^8.5.0": +"eslint-config-prettier@npm:^8.3.0, eslint-config-prettier@npm:^8.5.0": version: 8.5.0 resolution: "eslint-config-prettier@npm:8.5.0" peerDependencies: @@ -11831,7 +11991,7 @@ __metadata: languageName: node linkType: hard -"eslint-plugin-import@npm:^2.26.0": +"eslint-plugin-import@npm:^2.25.4, eslint-plugin-import@npm:^2.26.0": version: 2.26.0 resolution: "eslint-plugin-import@npm:2.26.0" dependencies: @@ -12148,6 +12308,55 @@ __metadata: languageName: node linkType: hard +"eslint@npm:^8.9.0": + version: 8.23.1 + resolution: "eslint@npm:8.23.1" + dependencies: + "@eslint/eslintrc": ^1.3.2 + "@humanwhocodes/config-array": ^0.10.4 + "@humanwhocodes/gitignore-to-minimatch": ^1.0.2 + "@humanwhocodes/module-importer": ^1.0.1 + ajv: ^6.10.0 + chalk: ^4.0.0 + cross-spawn: ^7.0.2 + debug: ^4.3.2 + doctrine: ^3.0.0 + escape-string-regexp: ^4.0.0 + eslint-scope: ^7.1.1 + eslint-utils: ^3.0.0 + eslint-visitor-keys: ^3.3.0 + espree: ^9.4.0 + esquery: ^1.4.0 + esutils: ^2.0.2 + fast-deep-equal: ^3.1.3 + file-entry-cache: ^6.0.1 + find-up: ^5.0.0 + glob-parent: ^6.0.1 + globals: ^13.15.0 + globby: ^11.1.0 + grapheme-splitter: ^1.0.4 + ignore: ^5.2.0 + import-fresh: ^3.0.0 + imurmurhash: ^0.1.4 + is-glob: ^4.0.0 + js-sdsl: ^4.1.4 + js-yaml: ^4.1.0 + json-stable-stringify-without-jsonify: ^1.0.1 + levn: ^0.4.1 + lodash.merge: ^4.6.2 + minimatch: ^3.1.2 + natural-compare: ^1.4.0 + optionator: ^0.9.1 + regexpp: ^3.2.0 + strip-ansi: ^6.0.1 + strip-json-comments: ^3.1.0 + text-table: ^0.2.0 + bin: + eslint: bin/eslint.js + checksum: a727e15492786a03b438bcf021db49f715680679846a7b8d79b98ad34576f2a570404ffe882d3c3e26f6359bff7277ef11fae5614bfe8629adb653f20d018c71 + languageName: node + linkType: hard + "espree@npm:^9.0.0, espree@npm:^9.3.1": version: 9.3.1 resolution: "espree@npm:9.3.1" @@ -12170,6 +12379,17 @@ __metadata: languageName: node linkType: hard +"espree@npm:^9.4.0": + version: 9.4.0 + resolution: "espree@npm:9.4.0" + dependencies: + acorn: ^8.8.0 + acorn-jsx: ^5.3.2 + eslint-visitor-keys: ^3.3.0 + checksum: 2e3020dde67892d2ba3632413b44d0dc31d92c29ce72267d7ec24216a562f0a6494d3696e2fa39a3ec8c0e0088d773947ab2925fbb716801a11eb8dd313ac89c + languageName: node + linkType: hard + "esprima@npm:^4.0.0": version: 4.0.1 resolution: "esprima@npm:4.0.1" @@ -14878,6 +15098,13 @@ __metadata: languageName: node linkType: hard +"js-sdsl@npm:^4.1.4": + version: 4.1.4 + resolution: "js-sdsl@npm:4.1.4" + checksum: 1977cea4ab18e0e03e28bdf0371d8b443fad65ca0988e0faa216406faf6bb943714fe8f7cc7a5bfe5f35ba3d94ddae399f4d10200f547f2c3320688b0670d726 + languageName: node + linkType: hard + "js-sha256@npm:^0.9.0": version: 0.9.0 resolution: "js-sha256@npm:0.9.0" @@ -16068,6 +16295,15 @@ __metadata: languageName: node linkType: hard +"minimatch@npm:4.2.1": + version: 4.2.1 + resolution: "minimatch@npm:4.2.1" + dependencies: + brace-expansion: ^1.1.7 + checksum: 2b1514e3d0f29a549912f0db7ae7b82c5cab4a8f2dd0369f1c6451a325b3f12b2cf473c95873b6157bb8df183d6cf6db82ff03614b6adaaf1d7e055beccdfd01 + languageName: node + linkType: hard + "minimatch@npm:5.0.1": version: 5.0.1 resolution: "minimatch@npm:5.0.1" @@ -16316,6 +16552,41 @@ __metadata: languageName: node linkType: hard +"mocha@npm:^9.2.0": + version: 9.2.2 + resolution: "mocha@npm:9.2.2" + dependencies: + "@ungap/promise-all-settled": 1.1.2 + ansi-colors: 4.1.1 + browser-stdout: 1.3.1 + chokidar: 3.5.3 + debug: 4.3.3 + diff: 5.0.0 + escape-string-regexp: 4.0.0 + find-up: 5.0.0 + glob: 7.2.0 + growl: 1.10.5 + he: 1.2.0 + js-yaml: 4.1.0 + log-symbols: 4.1.0 + minimatch: 4.2.1 + ms: 2.1.3 + nanoid: 3.3.1 + serialize-javascript: 6.0.0 + strip-json-comments: 3.1.1 + supports-color: 8.1.1 + which: 2.0.2 + workerpool: 6.2.0 + yargs: 16.2.0 + yargs-parser: 20.2.4 + yargs-unparser: 2.0.0 + bin: + _mocha: bin/_mocha + mocha: bin/mocha + checksum: 4d5ca4ce33fc66627e63acdf09a634e2358c9a00f61de7788b1091b6aad430da04f97f9ecb82d56dc034b623cb833b65576136fd010d77679c03fcea5bc1e12d + languageName: node + linkType: hard + "mock-fs@npm:^4.1.0": version: 4.14.0 resolution: "mock-fs@npm:4.14.0" @@ -16452,6 +16723,33 @@ __metadata: languageName: node linkType: hard +"name resolution@workspace:packages/name-resolution": + version: 0.0.0-use.local + resolution: "name resolution@workspace:packages/name-resolution" + dependencies: + "@types/chai": ^4.3.0 + "@types/mocha": ^9.1.0 + "@types/node": ^17.0.17 + "@typescript-eslint/eslint-plugin": ^5.11.0 + "@typescript-eslint/parser": ^5.11.0 + chai: ^4.3.6 + eslint: ^8.9.0 + eslint-config-airbnb-base: ^15.0.0 + eslint-config-prettier: ^8.3.0 + eslint-import-resolver-alias: ^1.1.2 + eslint-plugin-import: ^2.25.4 + eslint-plugin-module-resolver: ^1.4.0 + mocha: ^9.2.0 + prettier: ^2.5.1 + ts-mocha: ^9.0.2 + ts-node: ^10.5.0 + tsconfig-paths: ^3.12.0 + tsup: ^5.11.13 + typescript: ^4.5.5 + typescript-eslint: 0.0.1-alpha.0 + languageName: unknown + linkType: soft + "nan@npm:^2.13.2": version: 2.15.0 resolution: "nan@npm:2.15.0" @@ -16491,6 +16789,15 @@ __metadata: languageName: node linkType: hard +"nanoid@npm:3.3.1": + version: 3.3.1 + resolution: "nanoid@npm:3.3.1" + bin: + nanoid: bin/nanoid.cjs + checksum: 4ef0969e1bbe866fc223eb32276cbccb0961900bfe79104fa5abe34361979dead8d0e061410a5c03bc3d47455685adf32c09d6f27790f4a6898fb51f7df7ec86 + languageName: node + linkType: hard + "nanoid@npm:3.3.3": version: 3.3.3 resolution: "nanoid@npm:3.3.3" @@ -18029,7 +18336,7 @@ __metadata: languageName: node linkType: hard -"prettier@npm:^2.7.1": +"prettier@npm:^2.5.1, prettier@npm:^2.7.1": version: 2.7.1 resolution: "prettier@npm:2.7.1" bin: @@ -20685,6 +20992,23 @@ __metadata: languageName: node linkType: hard +"ts-mocha@npm:^9.0.2": + version: 9.0.2 + resolution: "ts-mocha@npm:9.0.2" + dependencies: + ts-node: 7.0.1 + tsconfig-paths: ^3.5.0 + peerDependencies: + mocha: ^3.X.X || ^4.X.X || ^5.X.X || ^6.X.X || ^7.X.X || ^8.X.X || ^9.X.X + dependenciesMeta: + tsconfig-paths: + optional: true + bin: + ts-mocha: bin/ts-mocha + checksum: 142a7fc2b7be156e2933b31ec0577d092789d4c55e5be0e42c038b92644983e970fdc3fd7b2fb12b007288e2be749d5897c064ecf7c48cb021f38401f5a95a67 + languageName: node + linkType: hard + "ts-node@npm:7.0.1": version: 7.0.1 resolution: "ts-node@npm:7.0.1" @@ -20703,7 +21027,7 @@ __metadata: languageName: node linkType: hard -"ts-node@npm:^10.8.1, ts-node@npm:^10.9.1": +"ts-node@npm:^10.5.0, ts-node@npm:^10.8.1, ts-node@npm:^10.9.1": version: 10.9.1 resolution: "ts-node@npm:10.9.1" dependencies: @@ -20761,7 +21085,7 @@ __metadata: languageName: node linkType: hard -"tsconfig-paths@npm:^3.14.1, tsconfig-paths@npm:^3.5.0": +"tsconfig-paths@npm:^3.12.0, tsconfig-paths@npm:^3.14.1, tsconfig-paths@npm:^3.5.0": version: 3.14.1 resolution: "tsconfig-paths@npm:3.14.1" dependencies: @@ -20805,6 +21129,42 @@ __metadata: languageName: node linkType: hard +"tsup@npm:^5.11.13": + version: 5.12.9 + resolution: "tsup@npm:5.12.9" + dependencies: + bundle-require: ^3.0.2 + cac: ^6.7.12 + chokidar: ^3.5.1 + debug: ^4.3.1 + esbuild: ^0.14.25 + execa: ^5.0.0 + globby: ^11.0.3 + joycon: ^3.0.1 + postcss-load-config: ^3.0.1 + resolve-from: ^5.0.0 + rollup: ^2.74.1 + source-map: 0.8.0-beta.0 + sucrase: ^3.20.3 + tree-kill: ^1.2.2 + peerDependencies: + "@swc/core": ^1 + postcss: ^8.4.12 + typescript: ^4.1.0 + peerDependenciesMeta: + "@swc/core": + optional: true + postcss: + optional: true + typescript: + optional: true + bin: + tsup: dist/cli-default.js + tsup-node: dist/cli-node.js + checksum: 872b7d1b523cb2feb6cdfaf9d0d45c1dee835b4b0a38d4f18dfd619ee5abc312421cf201edc8957cac8ba0d1061e697dd6ad1ccb2b45dc200a78ef7d0dd2569d + languageName: node + linkType: hard + "tsup@npm:^6.2.1": version: 6.2.1 resolution: "tsup@npm:6.2.1" @@ -21011,6 +21371,16 @@ __metadata: languageName: node linkType: hard +"typescript@npm:^4.5.5": + version: 4.8.3 + resolution: "typescript@npm:4.8.3" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 8286a5edcaf3d68e65c451aa1e7150ad1cf53ee0813c07ec35b7abdfdb10f355ecaa13c6a226a694ae7a67785fd7eeebf89f845da0b4f7e4a35561ddc459aba0 + languageName: node + linkType: hard + "typescript@npm:^4.6.4, typescript@npm:^4.7.4": version: 4.7.4 resolution: "typescript@npm:4.7.4" @@ -21031,6 +21401,16 @@ __metadata: languageName: node linkType: hard +"typescript@patch:typescript@^4.5.5#~builtin": + version: 4.8.3 + resolution: "typescript@patch:typescript@npm%3A4.8.3#~builtin::version=4.8.3&hash=f456af" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 0404a09c625df01934ef774b45ce1ca57ccae41cd625fcdbb82056715320d9329e70d9d75c2c732ec6ef947444ca978c189a332b71fa21f5c1437d5a83e24906 + languageName: node + linkType: hard + "typescript@patch:typescript@^4.6.4#~builtin, typescript@patch:typescript@^4.7.4#~builtin": version: 4.7.4 resolution: "typescript@patch:typescript@npm%3A4.7.4#~builtin::version=4.7.4&hash=f456af" @@ -22472,7 +22852,7 @@ __metadata: languageName: node linkType: hard -"which@npm:^2.0.1, which@npm:^2.0.2": +"which@npm:2.0.2, which@npm:^2.0.1, which@npm:^2.0.2": version: 2.0.2 resolution: "which@npm:2.0.2" dependencies: @@ -22553,6 +22933,13 @@ __metadata: languageName: node linkType: hard +"workerpool@npm:6.2.0": + version: 6.2.0 + resolution: "workerpool@npm:6.2.0" + checksum: 3493b4f0ef979a23d2c1583d7ef85f62fc9463cc02f82829d3e7e663b517f8ae9707da0249b382e46ac58986deb0ca2232ee1081713741211bda9254b429c9bb + languageName: node + linkType: hard + "workerpool@npm:6.2.1": version: 6.2.1 resolution: "workerpool@npm:6.2.1" From 6cf375245988ad8ceaff56391d73ee34f7480b5a Mon Sep 17 00:00:00 2001 From: kvhnuke <10602065+kvhnuke@users.noreply.github.com> Date: Mon, 19 Sep 2022 16:45:56 -0700 Subject: [PATCH 02/21] devop: add ens and ud support --- packages/name-resolution/package.json | 11 +- packages/name-resolution/src/ens/index.ts | 51 ++ packages/name-resolution/src/ens/types.ts | 3 + packages/name-resolution/src/index.ts | 54 +- packages/name-resolution/src/types.ts | 158 +++++ packages/name-resolution/src/types/types.d.ts | 138 ---- packages/name-resolution/src/ud/index.ts | 50 ++ packages/name-resolution/src/utils.ts | 5 + packages/name-resolution/tests/ens.test.ts | 40 ++ .../name-resolution/tests/example.test.ts | 6 - .../name-resolution/tests/resolver.test.ts | 29 + packages/name-resolution/tests/ud.test.ts | 37 ++ yarn.lock | 605 ++++++++++++++++-- 13 files changed, 994 insertions(+), 193 deletions(-) create mode 100644 packages/name-resolution/src/ens/index.ts create mode 100644 packages/name-resolution/src/ens/types.ts create mode 100644 packages/name-resolution/src/types.ts delete mode 100644 packages/name-resolution/src/types/types.d.ts create mode 100644 packages/name-resolution/src/ud/index.ts create mode 100644 packages/name-resolution/src/utils.ts create mode 100644 packages/name-resolution/tests/ens.test.ts delete mode 100644 packages/name-resolution/tests/example.test.ts create mode 100644 packages/name-resolution/tests/resolver.test.ts create mode 100644 packages/name-resolution/tests/ud.test.ts diff --git a/packages/name-resolution/package.json b/packages/name-resolution/package.json index 05f070723..fcf3fea2d 100644 --- a/packages/name-resolution/package.json +++ b/packages/name-resolution/package.json @@ -1,6 +1,6 @@ { - "name": "name resolution", - "version": "0.1.3", + "name": "@enkryptcom/name-resolution", + "version": "0.0.1", "description": "name resolution module for enkrypt", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -43,5 +43,10 @@ }, "keywords": [], "author": "kvhnuke", - "license": "MIT" + "license": "MIT", + "dependencies": { + "@ensdomains/address-encoder": "^0.2.18", + "@unstoppabledomains/resolution": "^8.3.3", + "ethers": "^5.7.1" + } } diff --git a/packages/name-resolution/src/ens/index.ts b/packages/name-resolution/src/ens/index.ts new file mode 100644 index 000000000..78e0b567f --- /dev/null +++ b/packages/name-resolution/src/ens/index.ts @@ -0,0 +1,51 @@ +import { ethers } from "ethers"; +import { formatsByName } from "@ensdomains/address-encoder"; +import { BaseResolver, CoinType } from "../types"; +import { ENSOptions } from "./types"; +import { getTLD } from "../utils"; + +class ENSResolver implements BaseResolver { + options: ENSOptions; + + name: string; + + ENSProvider: ethers.providers.JsonRpcProvider; + + constructor(options: ENSOptions) { + this.options = options; + this.name = "ens"; + } + + public async init(): Promise { + this.ENSProvider = new ethers.providers.JsonRpcProvider(this.options.node); + } + + public async resolveReverseName(address: string): Promise { + const nameAddress = await this.ENSProvider.lookupAddress(address); + if (nameAddress) return nameAddress; + return null; + } + + public async resolveAddress( + name: string, + coin: CoinType = "ETH" + ): Promise { + const resolver = await this.ENSProvider.getResolver(name); + if (resolver) { + return resolver + .getAddress(formatsByName[coin].coinType) + .then((address) => { + if (address) return address; + return null; + }); + } + return null; + } + + // eslint-disable-next-line class-methods-use-this + public isSupportedName(name: string): boolean { + return getTLD(name).length > 2; + } +} + +export default ENSResolver; diff --git a/packages/name-resolution/src/ens/types.ts b/packages/name-resolution/src/ens/types.ts new file mode 100644 index 000000000..5140f6db2 --- /dev/null +++ b/packages/name-resolution/src/ens/types.ts @@ -0,0 +1,3 @@ +export interface ENSOptions { + node: string; +} diff --git a/packages/name-resolution/src/index.ts b/packages/name-resolution/src/index.ts index a427d2b29..7b8ffdd89 100644 --- a/packages/name-resolution/src/index.ts +++ b/packages/name-resolution/src/index.ts @@ -1,7 +1,47 @@ -export function sayHello(name: string): string { - const abc: ExampleType = { - platform: "my-platform", - version: "my-version" - } - return `Hello ${name} ${JSON.stringify(abc)}`; -} \ No newline at end of file +import ENSResolver from "./ens"; +import { CoinType, NameResolverOptions } from "./types"; +import UDResolver from "./ud"; + +class NameResolver { + ens: ENSResolver; + + ud: UDResolver; + + initDone: Promise; + + constructor(options: NameResolverOptions) { + this.ens = new ENSResolver(options.ens); + this.ud = new UDResolver(); + this.initDone = Promise.all([this.ens.init(), this.ud.init()]); + } + + public async resolveReverseName(address: string): Promise { + return this.initDone.then(() => + Promise.all([ + this.ens.resolveReverseName(address), + this.ud.resolveReverseName(address), + ]).then((results) => { + // eslint-disable-next-line no-restricted-syntax + for (const name of results) { + if (name !== null) return name; + } + return null; + }) + ); + } + + public async resolveAddress( + name: string, + coin: CoinType = "ETH" + ): Promise { + return this.initDone.then(() => { + if (this.ud.isSupportedName(name)) + return this.ud.resolveAddress(name, coin); + if (this.ens.isSupportedName(name)) + return this.ens.resolveAddress(name, coin); + return null; + }); + } +} +export { ENSResolver, UDResolver }; +export default NameResolver; diff --git a/packages/name-resolution/src/types.ts b/packages/name-resolution/src/types.ts new file mode 100644 index 000000000..a5b8193fa --- /dev/null +++ b/packages/name-resolution/src/types.ts @@ -0,0 +1,158 @@ +import { ENSOptions } from "./ens/types"; + +export type CoinType = + | "BTC" + | "LTC" + | "DOGE" + | "RDD" + | "DASH" + | "PPC" + | "NMC" + | "VIA" + | "GRS" + | "DGB" + | "MONA" + | "DCR" + | "XEM" + | "AIB" + | "SYS" + | "ETH" + | "ETC_LEGACY" + | "ICX" + | "XVG" + | "STRAT" + | "ARK" + | "ATOM" + | "ZIL" + | "EGLD" + | "ZEN" + | "XMR" + | "ZEC" + | "LSK" + | "STEEM" + | "FIRO" + | "RSK" + | "KMD" + | "XRP" + | "BCH" + | "XLM" + | "BTM" + | "BTG" + | "NANO" + | "RVN" + | "POA_LEGACY" + | "LCC" + | "EOS" + | "TRX" + | "BCN" + | "FIO" + | "BSV" + | "NEO" + | "NIM" + | "EWT_LEGACY" + | "ALGO" + | "IOST" + | "DIVI" + | "IOTX" + | "BTS" + | "CKB" + | "MRX" + | "LUNA" + | "DOT" + | "VSYS" + | "ABBC" + | "NEAR" + | "ETN" + | "AION" + | "KSM" + | "AE" + | "KAVA" + | "FIL" + | "AR" + | "CCA" + | "THETA_LEGACY" + | "SOL" + | "XHV" + | "FLOW" + | "IRIS" + | "LRG" + | "SERO" + | "BDX" + | "CCXX" + | "SRM" + | "VLX" + | "BPS" + | "TFUEL" + | "GRIN" + | "XDAI_LEGACY" + | "VET" + | "BNB" + | "CLO_LEGACY" + | "HIVE" + | "TOMO_LEGACY" + | "HNT" + | "RUNE" + | "BCD" + | "TT_LEGACY" + | "FTM_LEGACY" + | "ONE" + | "ONT" + | "XTZ" + | "ADA" + | "SC" + | "QTUM" + | "GXC" + | "ELA" + | "NAS" + | "HBAR" + | "IOTA" + | "HNS" + | "STX" + | "GO_LEGACY" + | "XCH" + | "NULS" + | "AVAX" + | "NRG_LEGACY" + | "ARDR" + | "ZEL" + | "CELO_LEGACY" + | "WICC" + | "WAN" + | "WAVES" + | "OP" + | "CRO" + | "BSC" + | "GO" + | "ETC" + | "TOMO" + | "POA" + | "XDAI" + | "TT" + | "MATIC" + | "EWT" + | "FTM" + | "THETA" + | "CLO" + | "NRG" + | "ARB1" + | "CELO" + | "AVAXC"; + +export abstract class BaseResolver { + name: string; + + public abstract init(): Promise; + + public abstract resolveAddress( + name: string, + coint: CoinType + ): Promise; + + public abstract resolveReverseName(address: string): Promise; + + public abstract isSupportedName(name: string): boolean; +} + +export interface NameResolverOptions { + ens: ENSOptions; +} diff --git a/packages/name-resolution/src/types/types.d.ts b/packages/name-resolution/src/types/types.d.ts deleted file mode 100644 index 8be551591..000000000 --- a/packages/name-resolution/src/types/types.d.ts +++ /dev/null @@ -1,138 +0,0 @@ -export type CoinType = [ - "BTC", - "LTC", - "DOGE", - "RDD", - "DASH", - "PPC", - "NMC", - "VIA", - "GRS", - "DGB", - "MONA", - "DCR", - "XEM", - "AIB", - "SYS", - "ETH", - "ETC_LEGACY", - "ICX", - "XVG", - "STRAT", - "ARK", - "ATOM", - "ZIL", - "EGLD", - "ZEN", - "XMR", - "ZEC", - "LSK", - "STEEM", - "FIRO", - "RSK", - "KMD", - "XRP", - "BCH", - "XLM", - "BTM", - "BTG", - "NANO", - "RVN", - "POA_LEGACY", - "LCC", - "EOS", - "TRX", - "BCN", - "FIO", - "BSV", - "NEO", - "NIM", - "EWT_LEGACY", - "ALGO", - "IOST", - "DIVI", - "IOTX", - "BTS", - "CKB", - "MRX", - "LUNA", - "DOT", - "VSYS", - "ABBC", - "NEAR", - "ETN", - "AION", - "KSM", - "AE", - "KAVA", - "FIL", - "AR", - "CCA", - "THETA_LEGACY", - "SOL", - "XHV", - "FLOW", - "IRIS", - "LRG", - "SERO", - "BDX", - "CCXX", - "SRM", - "VLX", - "BPS", - "TFUEL", - "GRIN", - "XDAI_LEGACY", - "VET", - "BNB", - "CLO_LEGACY", - "HIVE", - "TOMO_LEGACY", - "HNT", - "RUNE", - "BCD", - "TT_LEGACY", - "FTM_LEGACY", - "ONE", - "ONT", - "XTZ", - "ADA", - "SC", - "QTUM", - "GXC", - "ELA", - "NAS", - "HBAR", - "IOTA", - "HNS", - "STX", - "GO_LEGACY", - "XCH", - "NULS", - "AVAX", - "NRG_LEGACY", - "ARDR", - "ZEL", - "CELO_LEGACY", - "WICC", - "WAN", - "WAVES", - "OP", - "CRO", - "BSC", - "GO", - "ETC", - "TOMO", - "POA", - "XDAI", - "TT", - "MATIC", - "EWT", - "FTM", - "THETA", - "CLO", - "NRG", - "ARB1", - "CELO", - "AVAXC" -]; diff --git a/packages/name-resolution/src/ud/index.ts b/packages/name-resolution/src/ud/index.ts new file mode 100644 index 000000000..93adfc123 --- /dev/null +++ b/packages/name-resolution/src/ud/index.ts @@ -0,0 +1,50 @@ +import { Resolution } from "@unstoppabledomains/resolution"; +import { BaseResolver, CoinType } from "../types"; +import { getTLD } from "../utils"; + +class UDResolver implements BaseResolver { + UDProvider: Resolution; + + name: string; + + supportedTLDs = [ + "blockchain", + "bitcoin", + "crypto", + "nft", + "wallet", + "x", + "dao", + "888", + "zil", + ]; + + constructor() { + this.UDProvider = new Resolution(); + this.name = "ud"; + } + + // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-empty-function + public async init(): Promise {} + + public async resolveReverseName(address: string): Promise { + return this.UDProvider.reverse(address) + .then((name) => name) + .catch(() => null); + } + + public async resolveAddress( + name: string, + coin: CoinType = "ETH" + ): Promise { + return this.UDProvider.addr(name, coin) + .then((address) => address) + .catch(() => null); + } + + public isSupportedName(name: string): boolean { + return this.supportedTLDs.includes(getTLD(name)); + } +} + +export default UDResolver; diff --git a/packages/name-resolution/src/utils.ts b/packages/name-resolution/src/utils.ts new file mode 100644 index 000000000..d8e433b06 --- /dev/null +++ b/packages/name-resolution/src/utils.ts @@ -0,0 +1,5 @@ +export const getTLD = (name: string): string => { + const labels = name.split("."); + if (labels.length < 2) return ""; + return labels[labels.length - 1]; +}; diff --git a/packages/name-resolution/tests/ens.test.ts b/packages/name-resolution/tests/ens.test.ts new file mode 100644 index 000000000..2911fcee3 --- /dev/null +++ b/packages/name-resolution/tests/ens.test.ts @@ -0,0 +1,40 @@ +import { expect } from "chai"; +import ENSResolver from "../src/ens"; + +describe("ENS Name resolving", () => { + // the tests container + it("it should properly resolve address", async () => { + const resolver = new ENSResolver({ + node: "https://nodes.mewapi.io/rpc/eth", + }); + await resolver.init(); + let address = await resolver.resolveAddress("test.eth", "ETH"); + expect(address).to.be.eq("0xeefB13C7D42eFCc655E528dA6d6F7bBcf9A2251d"); + address = await resolver.resolveAddress("1.offchainexample.eth", "ETH"); + expect(address).to.be.eq("0x41563129cDbbD0c5D3e1c86cf9563926b243834d"); + }).timeout(10000); + + it("it should properly reverse resolve", async () => { + const resolver = new ENSResolver({ + node: "https://nodes.mewapi.io/rpc/eth", + }); + await resolver.init(); + const name = await resolver.resolveReverseName( + "0xe5dc07bdcdb8c98850050c7f67de7e164b1ea391" + ); + expect(name).to.be.eq("kvhnuke.eth"); + }).timeout(10000); + + it("it should return null if not found", async () => { + const resolver = new ENSResolver({ + node: "https://nodes.mewapi.io/rpc/eth", + }); + await resolver.init(); + const name = await resolver.resolveReverseName( + "0xe5dc07bdcdb8c98850050c7f67de7e164b1ea392" + ); + expect(name).to.be.eq(null); + const address = await resolver.resolveAddress("sdfsfsdfsdfsdf.eth", "ETH"); + expect(address).to.be.eq(null); + }).timeout(10000); +}); diff --git a/packages/name-resolution/tests/example.test.ts b/packages/name-resolution/tests/example.test.ts deleted file mode 100644 index 71c28258c..000000000 --- a/packages/name-resolution/tests/example.test.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { expect } from 'chai'; -describe('Simple addition', () => { // the tests container - it('it should properly add', async () => { - expect(1 + 2).to.be.equals(3) - }); -}); \ No newline at end of file diff --git a/packages/name-resolution/tests/resolver.test.ts b/packages/name-resolution/tests/resolver.test.ts new file mode 100644 index 000000000..4d3c6056a --- /dev/null +++ b/packages/name-resolution/tests/resolver.test.ts @@ -0,0 +1,29 @@ +import { expect } from "chai"; +import NameResolver from "../src"; + +describe("Name Resolver resolving", () => { + // the tests container + it("it should properly resolve address", async () => { + const resolver = new NameResolver({ + ens: { + node: "https://nodes.mewapi.io/rpc/eth", + }, + }); + let address = await resolver.resolveAddress("test.eth", "ETH"); + expect(address).to.be.eq("0xeefB13C7D42eFCc655E528dA6d6F7bBcf9A2251d"); + address = await resolver.resolveAddress("brad.crypto", "ETH"); + expect(address).to.be.eq("0x8aaD44321A86b170879d7A244c1e8d360c99DdA8"); + }).timeout(10000); + + it("it should properly reverse resolve", async () => { + const resolver = new NameResolver({ + ens: { + node: "https://nodes.mewapi.io/rpc/eth", + }, + }); + const name = await resolver.resolveReverseName( + "0xe5dc07bdcdb8c98850050c7f67de7e164b1ea391" + ); + expect(name).to.be.eq("kvhnuke.eth"); + }).timeout(10000); +}); diff --git a/packages/name-resolution/tests/ud.test.ts b/packages/name-resolution/tests/ud.test.ts new file mode 100644 index 000000000..7926c594b --- /dev/null +++ b/packages/name-resolution/tests/ud.test.ts @@ -0,0 +1,37 @@ +import { expect } from "chai"; +import UDResolver from "../src/ud"; + +describe("UD Name resolving", () => { + // the tests container + it("it should properly resolve address", async () => { + const resolver = new UDResolver(); + await resolver.init(); + let address = await resolver.resolveAddress("brad.crypto", "ETH"); + expect(address).to.be.eq("0x8aaD44321A86b170879d7A244c1e8d360c99DdA8"); + address = await resolver.resolveAddress("brad.zil", "ETH"); + expect(address).to.be.eq("0x45b31e01AA6f42F0549aD482BE81635ED3149abb"); + }).timeout(10000); + + // it("it should properly reverse resolve", async () => { + // const resolver = new UDResolver(); + // await resolver.init(); + // const name = await resolver.resolveReverseName( + // "0xe5dc07bdcdb8c98850050c7f67de7e164b1ea391" + // ); + // expect(name).to.be.eq("kvhnuke.eth"); + // }).timeout(10000); + + it("it should return null if not found", async () => { + const resolver = new UDResolver(); + await resolver.init(); + const name = await resolver.resolveReverseName( + "0xe5dc07bdcdb8c98850050c7f67de7e164b1ea392" + ); + expect(name).to.be.eq(null); + const address = await resolver.resolveAddress( + "sdfsfsdfsdfsdf.crypto", + "ETH" + ); + expect(address).to.be.eq(null); + }).timeout(10000); +}); diff --git a/yarn.lock b/yarn.lock index a16b03265..07a89d06e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2558,6 +2558,36 @@ __metadata: languageName: unknown linkType: soft +"@enkryptcom/name-resolution@workspace:packages/name-resolution": + version: 0.0.0-use.local + resolution: "@enkryptcom/name-resolution@workspace:packages/name-resolution" + dependencies: + "@ensdomains/address-encoder": ^0.2.18 + "@types/chai": ^4.3.3 + "@types/mocha": ^9.1.1 + "@types/node": ^18.7.18 + "@typescript-eslint/eslint-plugin": ^5.38.0 + "@typescript-eslint/parser": ^5.38.0 + "@unstoppabledomains/resolution": ^8.3.3 + chai: ^4.3.6 + eslint: ^8.23.1 + eslint-config-airbnb-base: ^15.0.0 + eslint-config-prettier: ^8.5.0 + eslint-import-resolver-alias: ^1.1.2 + eslint-plugin-import: ^2.26.0 + eslint-plugin-module-resolver: ^1.5.0 + ethers: ^5.7.1 + mocha: ^10.0.0 + prettier: ^2.7.1 + ts-mocha: ^10.0.0 + ts-node: ^10.9.1 + tsconfig-paths: ^4.1.0 + tsup: ^6.2.3 + typescript: ^4.8.3 + typescript-eslint: 0.0.1-alpha.0 + languageName: unknown + linkType: soft + "@enkryptcom/request@^0.0.1, @enkryptcom/request@workspace:packages/request": version: 0.0.0-use.local resolution: "@enkryptcom/request@workspace:packages/request" @@ -2748,6 +2778,25 @@ __metadata: languageName: unknown linkType: soft +"@ensdomains/address-encoder@npm:^0.2.18": + version: 0.2.18 + resolution: "@ensdomains/address-encoder@npm:0.2.18" + dependencies: + bech32: ^2.0.0 + blakejs: ^1.1.0 + bn.js: ^4.11.8 + bs58: ^4.0.1 + crypto-addr-codec: ^0.1.7 + js-crc: ^0.2.0 + js-sha256: ^0.9.0 + js-sha512: ^0.8.0 + nano-base32: ^1.0.1 + ripemd160: ^2.0.2 + sha3: ^2.1.3 + checksum: 79f6962b40c8aadd262c21038b4b6b9fbf66e95438d1bf6eedbd99f6125aed1203bc00132382b25cb1a985e4e504971fbccd32e49096a41b8875ee4e906d6411 + languageName: node + linkType: hard + "@esbuild/linux-loong64@npm:0.15.7": version: 0.15.7 resolution: "@esbuild/linux-loong64@npm:0.15.7" @@ -2870,6 +2919,23 @@ __metadata: languageName: node linkType: hard +"@ethersproject/abi@npm:5.7.0, @ethersproject/abi@npm:^5.0.1, @ethersproject/abi@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/abi@npm:5.7.0" + dependencies: + "@ethersproject/address": ^5.7.0 + "@ethersproject/bignumber": ^5.7.0 + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/constants": ^5.7.0 + "@ethersproject/hash": ^5.7.0 + "@ethersproject/keccak256": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + "@ethersproject/properties": ^5.7.0 + "@ethersproject/strings": ^5.7.0 + checksum: bc6962bb6cb854e4d2a4d65b2c49c716477675b131b1363312234bdbb7e19badb7d9ce66f4ca2a70ae2ea84f7123dbc4e300a1bfe5d58864a7eafabc1466627e + languageName: node + linkType: hard + "@ethersproject/abi@npm:^5.5.0": version: 5.6.3 resolution: "@ethersproject/abi@npm:5.6.3" @@ -2904,6 +2970,21 @@ __metadata: languageName: node linkType: hard +"@ethersproject/abstract-provider@npm:5.7.0, @ethersproject/abstract-provider@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/abstract-provider@npm:5.7.0" + dependencies: + "@ethersproject/bignumber": ^5.7.0 + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + "@ethersproject/networks": ^5.7.0 + "@ethersproject/properties": ^5.7.0 + "@ethersproject/transactions": ^5.7.0 + "@ethersproject/web": ^5.7.0 + checksum: 74cf4696245cf03bb7cc5b6cbf7b4b89dd9a79a1c4688126d214153a938126d4972d42c93182198653ce1de35f2a2cad68be40337d4774b3698a39b28f0228a8 + languageName: node + linkType: hard + "@ethersproject/abstract-provider@npm:^5.6.0": version: 5.6.0 resolution: "@ethersproject/abstract-provider@npm:5.6.0" @@ -2934,6 +3015,19 @@ __metadata: languageName: node linkType: hard +"@ethersproject/abstract-signer@npm:5.7.0, @ethersproject/abstract-signer@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/abstract-signer@npm:5.7.0" + dependencies: + "@ethersproject/abstract-provider": ^5.7.0 + "@ethersproject/bignumber": ^5.7.0 + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + "@ethersproject/properties": ^5.7.0 + checksum: a823dac9cfb761e009851050ebebd5b229d1b1cc4a75b125c2da130ff37e8218208f7f9d1386f77407705b889b23d4a230ad67185f8872f083143e0073cbfbe3 + languageName: node + linkType: hard + "@ethersproject/abstract-signer@npm:^5.6.0": version: 5.6.0 resolution: "@ethersproject/abstract-signer@npm:5.6.0" @@ -2960,6 +3054,19 @@ __metadata: languageName: node linkType: hard +"@ethersproject/address@npm:5.7.0, @ethersproject/address@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/address@npm:5.7.0" + dependencies: + "@ethersproject/bignumber": ^5.7.0 + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/keccak256": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + "@ethersproject/rlp": ^5.7.0 + checksum: 64ea5ebea9cc0e845c413e6cb1e54e157dd9fc0dffb98e239d3a3efc8177f2ff798cd4e3206cf3660ee8faeb7bef1a47dc0ebef0d7b132c32e61e550c7d4c843 + languageName: node + linkType: hard + "@ethersproject/address@npm:^5.0.4, @ethersproject/address@npm:^5.6.0": version: 5.6.0 resolution: "@ethersproject/address@npm:5.6.0" @@ -2986,6 +3093,15 @@ __metadata: languageName: node linkType: hard +"@ethersproject/base64@npm:5.7.0, @ethersproject/base64@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/base64@npm:5.7.0" + dependencies: + "@ethersproject/bytes": ^5.7.0 + checksum: 7dd5d734d623582f08f665434f53685041a3d3b334a0e96c0c8afa8bbcaab934d50e5b6b980e826a8fde8d353e0b18f11e61faf17468177274b8e7c69cd9742b + languageName: node + linkType: hard + "@ethersproject/base64@npm:^5.6.0": version: 5.6.0 resolution: "@ethersproject/base64@npm:5.6.0" @@ -3004,6 +3120,27 @@ __metadata: languageName: node linkType: hard +"@ethersproject/basex@npm:5.7.0, @ethersproject/basex@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/basex@npm:5.7.0" + dependencies: + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/properties": ^5.7.0 + checksum: 326087b7e1f3787b5fe6cd1cf2b4b5abfafbc355a45e88e22e5e9d6c845b613ffc5301d629b28d5c4d5e2bfe9ec424e6782c804956dff79be05f0098cb5817de + languageName: node + linkType: hard + +"@ethersproject/bignumber@npm:5.7.0, @ethersproject/bignumber@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/bignumber@npm:5.7.0" + dependencies: + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + bn.js: ^5.2.1 + checksum: 8c9a134b76f3feb4ec26a5a27379efb4e156b8fb2de0678a67788a91c7f4e30abe9d948638458e4b20f2e42380da0adacc7c9389d05fce070692edc6ae9b4904 + languageName: node + linkType: hard + "@ethersproject/bignumber@npm:^5.0.7, @ethersproject/bignumber@npm:^5.6.0": version: 5.6.0 resolution: "@ethersproject/bignumber@npm:5.6.0" @@ -3026,6 +3163,15 @@ __metadata: languageName: node linkType: hard +"@ethersproject/bytes@npm:5.7.0, @ethersproject/bytes@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/bytes@npm:5.7.0" + dependencies: + "@ethersproject/logger": ^5.7.0 + checksum: 66ad365ceaab5da1b23b72225c71dce472cf37737af5118181fa8ab7447d696bea15ca22e3a0e8836fdd8cfac161afe321a7c67d0dde96f9f645ddd759676621 + languageName: node + linkType: hard + "@ethersproject/bytes@npm:^5.0.4, @ethersproject/bytes@npm:^5.6.0, @ethersproject/bytes@npm:^5.6.1": version: 5.6.1 resolution: "@ethersproject/bytes@npm:5.6.1" @@ -3035,6 +3181,15 @@ __metadata: languageName: node linkType: hard +"@ethersproject/constants@npm:5.7.0, @ethersproject/constants@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/constants@npm:5.7.0" + dependencies: + "@ethersproject/bignumber": ^5.7.0 + checksum: 6d4b1355747cce837b3e76ec3bde70e4732736f23b04f196f706ebfa5d4d9c2be50904a390d4d40ce77803b98d03d16a9b6898418e04ba63491933ce08c4ba8a + languageName: node + linkType: hard + "@ethersproject/constants@npm:^5.0.4, @ethersproject/constants@npm:^5.6.0": version: 5.6.0 resolution: "@ethersproject/constants@npm:5.6.0" @@ -3053,6 +3208,41 @@ __metadata: languageName: node linkType: hard +"@ethersproject/contracts@npm:5.7.0": + version: 5.7.0 + resolution: "@ethersproject/contracts@npm:5.7.0" + dependencies: + "@ethersproject/abi": ^5.7.0 + "@ethersproject/abstract-provider": ^5.7.0 + "@ethersproject/abstract-signer": ^5.7.0 + "@ethersproject/address": ^5.7.0 + "@ethersproject/bignumber": ^5.7.0 + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/constants": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + "@ethersproject/properties": ^5.7.0 + "@ethersproject/transactions": ^5.7.0 + checksum: 6ccf1121cba01b31e02f8c507cb971ab6bfed85706484a9ec09878ef1594a62215f43c4fdef8f4a4875b99c4a800bc95e3be69b1803f8ce479e07634b5a740c0 + languageName: node + linkType: hard + +"@ethersproject/hash@npm:5.7.0, @ethersproject/hash@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/hash@npm:5.7.0" + dependencies: + "@ethersproject/abstract-signer": ^5.7.0 + "@ethersproject/address": ^5.7.0 + "@ethersproject/base64": ^5.7.0 + "@ethersproject/bignumber": ^5.7.0 + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/keccak256": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + "@ethersproject/properties": ^5.7.0 + "@ethersproject/strings": ^5.7.0 + checksum: 6e9fa8d14eb08171cd32f17f98cc108ec2aeca74a427655f0d689c550fee0b22a83b3b400fad7fb3f41cf14d4111f87f170aa7905bcbcd1173a55f21b06262ef + languageName: node + linkType: hard + "@ethersproject/hash@npm:^5.0.4": version: 5.6.0 resolution: "@ethersproject/hash@npm:5.6.0" @@ -3085,6 +3275,57 @@ __metadata: languageName: node linkType: hard +"@ethersproject/hdnode@npm:5.7.0, @ethersproject/hdnode@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/hdnode@npm:5.7.0" + dependencies: + "@ethersproject/abstract-signer": ^5.7.0 + "@ethersproject/basex": ^5.7.0 + "@ethersproject/bignumber": ^5.7.0 + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + "@ethersproject/pbkdf2": ^5.7.0 + "@ethersproject/properties": ^5.7.0 + "@ethersproject/sha2": ^5.7.0 + "@ethersproject/signing-key": ^5.7.0 + "@ethersproject/strings": ^5.7.0 + "@ethersproject/transactions": ^5.7.0 + "@ethersproject/wordlists": ^5.7.0 + checksum: bfe5ca2d89a42de73655f853170ef4766b933c5f481cddad709b3aca18823275b096e572f92d1602a052f80b426edde44ad6b9d028799775a7dad4a5bbed2133 + languageName: node + linkType: hard + +"@ethersproject/json-wallets@npm:5.7.0, @ethersproject/json-wallets@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/json-wallets@npm:5.7.0" + dependencies: + "@ethersproject/abstract-signer": ^5.7.0 + "@ethersproject/address": ^5.7.0 + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/hdnode": ^5.7.0 + "@ethersproject/keccak256": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + "@ethersproject/pbkdf2": ^5.7.0 + "@ethersproject/properties": ^5.7.0 + "@ethersproject/random": ^5.7.0 + "@ethersproject/strings": ^5.7.0 + "@ethersproject/transactions": ^5.7.0 + aes-js: 3.0.0 + scrypt-js: 3.0.1 + checksum: f583458d22db62efaaf94d38dd243482776a45bf90f9f3882fbad5aa0b8fd288b41eb7c1ff8ec0b99c9b751088e43d6173530db64dd33c59f9d8daa8d7ad5aa2 + languageName: node + linkType: hard + +"@ethersproject/keccak256@npm:5.7.0, @ethersproject/keccak256@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/keccak256@npm:5.7.0" + dependencies: + "@ethersproject/bytes": ^5.7.0 + js-sha3: 0.8.0 + checksum: ff70950d82203aab29ccda2553422cbac2e7a0c15c986bd20a69b13606ed8bb6e4fdd7b67b8d3b27d4f841e8222cbaccd33ed34be29f866fec7308f96ed244c6 + languageName: node + linkType: hard + "@ethersproject/keccak256@npm:^5.0.3, @ethersproject/keccak256@npm:^5.6.0": version: 5.6.0 resolution: "@ethersproject/keccak256@npm:5.6.0" @@ -3105,6 +3346,13 @@ __metadata: languageName: node linkType: hard +"@ethersproject/logger@npm:5.7.0, @ethersproject/logger@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/logger@npm:5.7.0" + checksum: 075ab2f605f1fd0813f2e39c3308f77b44a67732b36e712d9bc085f22a84aac4da4f71b39bee50fe78da3e1c812673fadc41180c9970fe5e486e91ea17befe0d + languageName: node + linkType: hard + "@ethersproject/logger@npm:^5.0.5, @ethersproject/logger@npm:^5.6.0": version: 5.6.0 resolution: "@ethersproject/logger@npm:5.6.0" @@ -3112,6 +3360,15 @@ __metadata: languageName: node linkType: hard +"@ethersproject/networks@npm:5.7.1, @ethersproject/networks@npm:^5.7.0": + version: 5.7.1 + resolution: "@ethersproject/networks@npm:5.7.1" + dependencies: + "@ethersproject/logger": ^5.7.0 + checksum: 0339f312304c17d9a0adce550edb825d4d2c8c9468c1634c44172c67a9ed256f594da62c4cda5c3837a0f28b7fabc03aca9b492f68ff1fdad337ee861b27bd5d + languageName: node + linkType: hard + "@ethersproject/networks@npm:^5.6.0": version: 5.6.2 resolution: "@ethersproject/networks@npm:5.6.2" @@ -3130,6 +3387,25 @@ __metadata: languageName: node linkType: hard +"@ethersproject/pbkdf2@npm:5.7.0, @ethersproject/pbkdf2@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/pbkdf2@npm:5.7.0" + dependencies: + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/sha2": ^5.7.0 + checksum: b895adb9e35a8a127e794f7aadc31a2424ef355a70e51cde10d457e3e888bb8102373199a540cf61f2d6b9a32e47358f9c65b47d559f42bf8e596b5fd67901e9 + languageName: node + linkType: hard + +"@ethersproject/properties@npm:5.7.0, @ethersproject/properties@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/properties@npm:5.7.0" + dependencies: + "@ethersproject/logger": ^5.7.0 + checksum: 6ab0ccf0c3aadc9221e0cdc5306ce6cd0df7f89f77d77bccdd1277182c9ead0202cd7521329ba3acde130820bf8af299e17cf567d0d497c736ee918207bbf59f + languageName: node + linkType: hard + "@ethersproject/properties@npm:^5.0.3, @ethersproject/properties@npm:^5.6.0": version: 5.6.0 resolution: "@ethersproject/properties@npm:5.6.0" @@ -3139,6 +3415,54 @@ __metadata: languageName: node linkType: hard +"@ethersproject/providers@npm:5.7.1": + version: 5.7.1 + resolution: "@ethersproject/providers@npm:5.7.1" + dependencies: + "@ethersproject/abstract-provider": ^5.7.0 + "@ethersproject/abstract-signer": ^5.7.0 + "@ethersproject/address": ^5.7.0 + "@ethersproject/base64": ^5.7.0 + "@ethersproject/basex": ^5.7.0 + "@ethersproject/bignumber": ^5.7.0 + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/constants": ^5.7.0 + "@ethersproject/hash": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + "@ethersproject/networks": ^5.7.0 + "@ethersproject/properties": ^5.7.0 + "@ethersproject/random": ^5.7.0 + "@ethersproject/rlp": ^5.7.0 + "@ethersproject/sha2": ^5.7.0 + "@ethersproject/strings": ^5.7.0 + "@ethersproject/transactions": ^5.7.0 + "@ethersproject/web": ^5.7.0 + bech32: 1.1.4 + ws: 7.4.6 + checksum: 673745e967e7215b46b7d3024f5ee02be975d6cf66b605f87a0e5beaa349d6d30c987165f98eceddaf7996f64a1ec414f0715f25fc3458aead6eea4c4820c399 + languageName: node + linkType: hard + +"@ethersproject/random@npm:5.7.0, @ethersproject/random@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/random@npm:5.7.0" + dependencies: + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + checksum: 017829c91cff6c76470852855108115b0b52c611b6be817ed1948d56ba42d6677803ec2012aa5ae298a7660024156a64c11fcf544e235e239ab3f89f0fff7345 + languageName: node + linkType: hard + +"@ethersproject/rlp@npm:5.7.0, @ethersproject/rlp@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/rlp@npm:5.7.0" + dependencies: + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + checksum: bce165b0f7e68e4d091c9d3cf47b247cac33252df77a095ca4281d32d5eeaaa3695d9bc06b2b057c5015353a68df89f13a4a54a72e888e4beeabbe56b15dda6e + languageName: node + linkType: hard + "@ethersproject/rlp@npm:^5.5.0, @ethersproject/rlp@npm:^5.6.1": version: 5.6.1 resolution: "@ethersproject/rlp@npm:5.6.1" @@ -3159,6 +3483,17 @@ __metadata: languageName: node linkType: hard +"@ethersproject/sha2@npm:5.7.0, @ethersproject/sha2@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/sha2@npm:5.7.0" + dependencies: + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + hash.js: 1.1.7 + checksum: 09321057c022effbff4cc2d9b9558228690b5dd916329d75c4b1ffe32ba3d24b480a367a7cc92d0f0c0b1c896814d03351ae4630e2f1f7160be2bcfbde435dbc + languageName: node + linkType: hard + "@ethersproject/sha2@npm:^5.5.0": version: 5.6.1 resolution: "@ethersproject/sha2@npm:5.6.1" @@ -3170,6 +3505,20 @@ __metadata: languageName: node linkType: hard +"@ethersproject/signing-key@npm:5.7.0, @ethersproject/signing-key@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/signing-key@npm:5.7.0" + dependencies: + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + "@ethersproject/properties": ^5.7.0 + bn.js: ^5.2.1 + elliptic: 6.5.4 + hash.js: 1.1.7 + checksum: 8f8de09b0aac709683bbb49339bc0a4cd2f95598f3546436c65d6f3c3a847ffa98e06d35e9ed2b17d8030bd2f02db9b7bd2e11c5cf8a71aad4537487ab4cf03a + languageName: node + linkType: hard + "@ethersproject/signing-key@npm:^5.6.0": version: 5.6.0 resolution: "@ethersproject/signing-key@npm:5.6.0" @@ -3198,6 +3547,31 @@ __metadata: languageName: node linkType: hard +"@ethersproject/solidity@npm:5.7.0": + version: 5.7.0 + resolution: "@ethersproject/solidity@npm:5.7.0" + dependencies: + "@ethersproject/bignumber": ^5.7.0 + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/keccak256": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + "@ethersproject/sha2": ^5.7.0 + "@ethersproject/strings": ^5.7.0 + checksum: 9a02f37f801c96068c3e7721f83719d060175bc4e80439fe060e92bd7acfcb6ac1330c7e71c49f4c2535ca1308f2acdcb01e00133129aac00581724c2d6293f3 + languageName: node + linkType: hard + +"@ethersproject/strings@npm:5.7.0, @ethersproject/strings@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/strings@npm:5.7.0" + dependencies: + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/constants": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + checksum: 5ff78693ae3fdf3cf23e1f6dc047a61e44c8197d2408c42719fef8cb7b7b3613a4eec88ac0ed1f9f5558c74fe0de7ae3195a29ca91a239c74b9f444d8e8b50df + languageName: node + linkType: hard + "@ethersproject/strings@npm:^5.0.4, @ethersproject/strings@npm:^5.6.0": version: 5.6.0 resolution: "@ethersproject/strings@npm:5.6.0" @@ -3220,6 +3594,23 @@ __metadata: languageName: node linkType: hard +"@ethersproject/transactions@npm:5.7.0, @ethersproject/transactions@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/transactions@npm:5.7.0" + dependencies: + "@ethersproject/address": ^5.7.0 + "@ethersproject/bignumber": ^5.7.0 + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/constants": ^5.7.0 + "@ethersproject/keccak256": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + "@ethersproject/properties": ^5.7.0 + "@ethersproject/rlp": ^5.7.0 + "@ethersproject/signing-key": ^5.7.0 + checksum: a31b71996d2b283f68486241bff0d3ea3f1ba0e8f1322a8fffc239ccc4f4a7eb2ea9994b8fd2f093283fd75f87bae68171e01b6265261f821369aca319884a79 + languageName: node + linkType: hard + "@ethersproject/transactions@npm:^5.0.0-beta.135, @ethersproject/transactions@npm:^5.6.0": version: 5.6.0 resolution: "@ethersproject/transactions@npm:5.6.0" @@ -3254,6 +3645,53 @@ __metadata: languageName: node linkType: hard +"@ethersproject/units@npm:5.7.0": + version: 5.7.0 + resolution: "@ethersproject/units@npm:5.7.0" + dependencies: + "@ethersproject/bignumber": ^5.7.0 + "@ethersproject/constants": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + checksum: 304714f848cd32e57df31bf545f7ad35c2a72adae957198b28cbc62166daa929322a07bff6e9c9ac4577ab6aa0de0546b065ed1b2d20b19e25748b7d475cb0fc + languageName: node + linkType: hard + +"@ethersproject/wallet@npm:5.7.0": + version: 5.7.0 + resolution: "@ethersproject/wallet@npm:5.7.0" + dependencies: + "@ethersproject/abstract-provider": ^5.7.0 + "@ethersproject/abstract-signer": ^5.7.0 + "@ethersproject/address": ^5.7.0 + "@ethersproject/bignumber": ^5.7.0 + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/hash": ^5.7.0 + "@ethersproject/hdnode": ^5.7.0 + "@ethersproject/json-wallets": ^5.7.0 + "@ethersproject/keccak256": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + "@ethersproject/properties": ^5.7.0 + "@ethersproject/random": ^5.7.0 + "@ethersproject/signing-key": ^5.7.0 + "@ethersproject/transactions": ^5.7.0 + "@ethersproject/wordlists": ^5.7.0 + checksum: a4009bf7331eddab38e3015b5e9101ef92de7f705b00a6196b997db0e5635b6d83561674d46c90c6f77b87c0500fe4a6b0183ba13749efc22db59c99deb82fbd + languageName: node + linkType: hard + +"@ethersproject/web@npm:5.7.1, @ethersproject/web@npm:^5.7.0": + version: 5.7.1 + resolution: "@ethersproject/web@npm:5.7.1" + dependencies: + "@ethersproject/base64": ^5.7.0 + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + "@ethersproject/properties": ^5.7.0 + "@ethersproject/strings": ^5.7.0 + checksum: 7028c47103f82fd2e2c197ce0eecfacaa9180ffeec7de7845b1f4f9b19d84081b7a48227aaddde05a4aaa526af574a9a0ce01cc0fc75e3e371f84b38b5b16b2b + languageName: node + linkType: hard + "@ethersproject/web@npm:^5.6.0": version: 5.6.0 resolution: "@ethersproject/web@npm:5.6.0" @@ -3280,6 +3718,19 @@ __metadata: languageName: node linkType: hard +"@ethersproject/wordlists@npm:5.7.0, @ethersproject/wordlists@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/wordlists@npm:5.7.0" + dependencies: + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/hash": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + "@ethersproject/properties": ^5.7.0 + "@ethersproject/strings": ^5.7.0 + checksum: 30eb6eb0731f9ef5faa44bf9c0c6e950bcaaef61e4d2d9ce0ae6d341f4e2d6d1f4ab4f8880bfce03b7aac4b862fb740e1421170cfbf8e2aafc359277d49e6e97 + languageName: node + linkType: hard + "@gar/promisify@npm:^1.1.3": version: 1.1.3 resolution: "@gar/promisify@npm:1.1.3" @@ -7483,6 +7934,19 @@ __metadata: languageName: node linkType: hard +"@unstoppabledomains/resolution@npm:^8.3.3": + version: 8.3.3 + resolution: "@unstoppabledomains/resolution@npm:8.3.3" + dependencies: + "@ethersproject/abi": ^5.0.1 + bn.js: ^4.4.0 + cross-fetch: ^3.1.4 + crypto-js: ^4.1.1 + elliptic: ^6.5.4 + checksum: 5fdee68899d6c1da501923bdf09ee100676d5172895051d42fc15a6affcab488fbabaf9112e30a0b39194e7c27b6fb66c48b33d35f5408f4c6fadaefaaa522c5 + languageName: node + linkType: hard + "@vue/babel-helper-vue-jsx-merge-props@npm:^1.2.1": version: 1.2.1 resolution: "@vue/babel-helper-vue-jsx-merge-props@npm:1.2.1" @@ -8528,6 +8992,13 @@ __metadata: languageName: node linkType: hard +"aes-js@npm:3.0.0": + version: 3.0.0 + resolution: "aes-js@npm:3.0.0" + checksum: 251e26d533cd1a915b44896b17d5ed68c24a02484cfdd2e74ec700a309267db96651ea4eb657bf20aac32a3baa61f6e34edf8e2fec2de440a655da9942d334b8 + languageName: node + linkType: hard + "aes-js@npm:^3.1.2": version: 3.1.2 resolution: "aes-js@npm:3.1.2" @@ -9538,7 +10009,7 @@ __metadata: languageName: node linkType: hard -"bn.js@npm:^4.0.0, bn.js@npm:^4.1.0, bn.js@npm:^4.11.0, bn.js@npm:^4.11.6, bn.js@npm:^4.11.8, bn.js@npm:^4.11.9": +"bn.js@npm:^4.0.0, bn.js@npm:^4.1.0, bn.js@npm:^4.11.0, bn.js@npm:^4.11.6, bn.js@npm:^4.11.8, bn.js@npm:^4.11.9, bn.js@npm:^4.4.0": version: 4.12.0 resolution: "bn.js@npm:4.12.0" checksum: 39afb4f15f4ea537b55eaf1446c896af28ac948fdcf47171961475724d1bb65118cca49fa6e3d67706e4790955ec0e74de584e45c8f1ef89f46c812bee5b5a12 @@ -9865,23 +10336,23 @@ __metadata: languageName: node linkType: hard -"buffer@npm:^5.0.5, buffer@npm:^5.1.0, buffer@npm:^5.5.0, buffer@npm:^5.6.0": - version: 5.7.1 - resolution: "buffer@npm:5.7.1" +"buffer@npm:6.0.3, buffer@npm:^6.0.2, buffer@npm:^6.0.3, buffer@npm:~6.0.3": + version: 6.0.3 + resolution: "buffer@npm:6.0.3" dependencies: base64-js: ^1.3.1 - ieee754: ^1.1.13 - checksum: e2cf8429e1c4c7b8cbd30834ac09bd61da46ce35f5c22a78e6c2f04497d6d25541b16881e30a019c6fd3154150650ccee27a308eff3e26229d788bbdeb08ab84 + ieee754: ^1.2.1 + checksum: 5ad23293d9a731e4318e420025800b42bf0d264004c0286c8cc010af7a270c7a0f6522e84f54b9ad65cbd6db20b8badbfd8d2ebf4f80fa03dab093b89e68c3f9 languageName: node linkType: hard -"buffer@npm:^6.0.2, buffer@npm:^6.0.3, buffer@npm:~6.0.3": - version: 6.0.3 - resolution: "buffer@npm:6.0.3" +"buffer@npm:^5.0.5, buffer@npm:^5.1.0, buffer@npm:^5.5.0, buffer@npm:^5.6.0": + version: 5.7.1 + resolution: "buffer@npm:5.7.1" dependencies: base64-js: ^1.3.1 - ieee754: ^1.2.1 - checksum: 5ad23293d9a731e4318e420025800b42bf0d264004c0286c8cc010af7a270c7a0f6522e84f54b9ad65cbd6db20b8badbfd8d2ebf4f80fa03dab093b89e68c3f9 + ieee754: ^1.1.13 + checksum: e2cf8429e1c4c7b8cbd30834ac09bd61da46ce35f5c22a78e6c2f04497d6d25541b16881e30a019c6fd3154150650ccee27a308eff3e26229d788bbdeb08ab84 languageName: node linkType: hard @@ -11045,6 +11516,21 @@ __metadata: languageName: node linkType: hard +"crypto-addr-codec@npm:^0.1.7": + version: 0.1.7 + resolution: "crypto-addr-codec@npm:0.1.7" + dependencies: + base-x: ^3.0.8 + big-integer: 1.6.36 + blakejs: ^1.1.0 + bs58: ^4.0.1 + ripemd160-min: 0.0.6 + safe-buffer: ^5.2.0 + sha3: ^2.1.1 + checksum: 76a198dea3703b92ecb9329783d30a83257cf5bc8b3c2ed09c2f0a46bf93479fb9d04449bed7cd1702158b3f65060c5fd275300187a5e86feb3bc6acfcaf6fa3 + languageName: node + linkType: hard + "crypto-browserify@npm:3.12.0, crypto-browserify@npm:^3.12.0": version: 3.12.0 resolution: "crypto-browserify@npm:3.12.0" @@ -13078,6 +13564,44 @@ __metadata: languageName: node linkType: hard +"ethers@npm:^5.7.1": + version: 5.7.1 + resolution: "ethers@npm:5.7.1" + dependencies: + "@ethersproject/abi": 5.7.0 + "@ethersproject/abstract-provider": 5.7.0 + "@ethersproject/abstract-signer": 5.7.0 + "@ethersproject/address": 5.7.0 + "@ethersproject/base64": 5.7.0 + "@ethersproject/basex": 5.7.0 + "@ethersproject/bignumber": 5.7.0 + "@ethersproject/bytes": 5.7.0 + "@ethersproject/constants": 5.7.0 + "@ethersproject/contracts": 5.7.0 + "@ethersproject/hash": 5.7.0 + "@ethersproject/hdnode": 5.7.0 + "@ethersproject/json-wallets": 5.7.0 + "@ethersproject/keccak256": 5.7.0 + "@ethersproject/logger": 5.7.0 + "@ethersproject/networks": 5.7.1 + "@ethersproject/pbkdf2": 5.7.0 + "@ethersproject/properties": 5.7.0 + "@ethersproject/providers": 5.7.1 + "@ethersproject/random": 5.7.0 + "@ethersproject/rlp": 5.7.0 + "@ethersproject/sha2": 5.7.0 + "@ethersproject/signing-key": 5.7.0 + "@ethersproject/solidity": 5.7.0 + "@ethersproject/strings": 5.7.0 + "@ethersproject/transactions": 5.7.0 + "@ethersproject/units": 5.7.0 + "@ethersproject/wallet": 5.7.0 + "@ethersproject/web": 5.7.1 + "@ethersproject/wordlists": 5.7.0 + checksum: 7a61b7a105c41f9fec327887414f1950dc27bfa2d12fe29a068419eaaa3d415e6a12275685c87f700abd88c3b639ae79c09a2f90edea1e69edc8126cb0dce708 + languageName: node + linkType: hard + "ethjs-unit@npm:0.1.6": version: 0.1.6 resolution: "ethjs-unit@npm:0.1.6" @@ -15512,6 +16036,13 @@ __metadata: languageName: node linkType: hard +"js-crc@npm:^0.2.0": + version: 0.2.0 + resolution: "js-crc@npm:0.2.0" + checksum: 3e307ae64236b745658e0df50d56809a810e67f39e45b7c1302433f10560819bea1d457841b2bac0eb42b72c96d60ae4c3232613275ea6c482b3cdb98a8bab09 + languageName: node + linkType: hard + "js-logger@npm:^1.6.1": version: 1.6.1 resolution: "js-logger@npm:1.6.1" @@ -17134,33 +17665,6 @@ __metadata: languageName: node linkType: hard -"name resolution@workspace:packages/name-resolution": - version: 0.0.0-use.local - resolution: "name resolution@workspace:packages/name-resolution" - dependencies: - "@types/chai": ^4.3.3 - "@types/mocha": ^9.1.1 - "@types/node": ^18.7.18 - "@typescript-eslint/eslint-plugin": ^5.38.0 - "@typescript-eslint/parser": ^5.38.0 - chai: ^4.3.6 - eslint: ^8.23.1 - eslint-config-airbnb-base: ^15.0.0 - eslint-config-prettier: ^8.5.0 - eslint-import-resolver-alias: ^1.1.2 - eslint-plugin-import: ^2.26.0 - eslint-plugin-module-resolver: ^1.5.0 - mocha: ^10.0.0 - prettier: ^2.7.1 - ts-mocha: ^10.0.0 - ts-node: ^10.9.1 - tsconfig-paths: ^4.1.0 - tsup: ^6.2.3 - typescript: ^4.8.3 - typescript-eslint: 0.0.1-alpha.0 - languageName: unknown - linkType: soft - "nan@npm:^2.13.2": version: 2.15.0 resolution: "nan@npm:2.15.0" @@ -17179,6 +17683,13 @@ __metadata: languageName: node linkType: hard +"nano-base32@npm:^1.0.1": + version: 1.0.1 + resolution: "nano-base32@npm:1.0.1" + checksum: 1abe4229f7197ac35c91376b0a897c01d783dc0bbad35b45b70486bdca79c552d8cc7f3780ae9c815d865e3d52adacf1ca4d805ef0bfd4718f982ef5942a8285 + languageName: node + linkType: hard + "nano-json-stream-parser@npm:^0.1.2": version: 0.1.2 resolution: "nano-json-stream-parser@npm:0.1.2" @@ -19607,6 +20118,13 @@ __metadata: languageName: node linkType: hard +"ripemd160-min@npm:0.0.6": + version: 0.0.6 + resolution: "ripemd160-min@npm:0.0.6" + checksum: 3253fec273aee407e736df0baf69f90c65f56573d6fc537532041112e7c09a2f665ee2e618ef4a88eb494923d36614322eac26ddf35a504fcfedb422fd414c75 + languageName: node + linkType: hard + "ripemd160@npm:2, ripemd160@npm:^2.0.0, ripemd160@npm:^2.0.1, ripemd160@npm:^2.0.2": version: 2.0.2 resolution: "ripemd160@npm:2.0.2" @@ -19915,7 +20433,7 @@ __metadata: languageName: node linkType: hard -"scrypt-js@npm:^3.0.0, scrypt-js@npm:^3.0.1": +"scrypt-js@npm:3.0.1, scrypt-js@npm:^3.0.0, scrypt-js@npm:^3.0.1": version: 3.0.1 resolution: "scrypt-js@npm:3.0.1" checksum: b7c7d1a68d6ca946f2fbb0778e0c4ec63c65501b54023b2af7d7e9f48fdb6c6580d6f7675cd53bda5944c5ebc057560d5a6365079752546865defb3b79dea454 @@ -20126,6 +20644,15 @@ __metadata: languageName: node linkType: hard +"sha3@npm:^2.1.1, sha3@npm:^2.1.3": + version: 2.1.4 + resolution: "sha3@npm:2.1.4" + dependencies: + buffer: 6.0.3 + checksum: fb49c8e18143cc46babc0e5d83d5f5d0149e645f26633a0e6a9aa2514df2ef91f10b6ece20da229e7ead8b8002d8e9514dcc747ef96a25b749294d6385c6f29f + languageName: node + linkType: hard + "shallow-clone@npm:^3.0.0": version: 3.0.1 resolution: "shallow-clone@npm:3.0.1" From 1cb3858242954a55dfb0432b5efe94bcaed87df6 Mon Sep 17 00:00:00 2001 From: brettkolodny Date: Tue, 4 Oct 2022 12:08:50 -0400 Subject: [PATCH 03/21] feat: canto config --- .../providers/etherscan/configs.ts | 1 + .../src/providers/ethereum/networks/canto.ts | 25 +++++++++++++++++++ .../ethereum/networks/icons/canto.svg | 4 +++ .../src/providers/ethereum/networks/index.ts | 2 ++ packages/types/src/networks.ts | 2 ++ 5 files changed, 34 insertions(+) create mode 100644 packages/extension/src/providers/ethereum/networks/canto.ts create mode 100644 packages/extension/src/providers/ethereum/networks/icons/canto.svg diff --git a/packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts b/packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts index 73ed83c02..f1dace022 100644 --- a/packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts +++ b/packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts @@ -13,6 +13,7 @@ const NetworkEndpoints = { [NetworkNames.KaruraEVM]: "https://blockscout.karura.network/", [NetworkNames.AstarEVM]: "https://blockscout.com/astar/", [NetworkNames.ShidenEVM]: "https://blockscout.com/shiden/", + [NetworkNames.Canto]: "https://evm.explorer.canto.io/", }; export { NetworkEndpoints }; diff --git a/packages/extension/src/providers/ethereum/networks/canto.ts b/packages/extension/src/providers/ethereum/networks/canto.ts new file mode 100644 index 000000000..e922fd8d8 --- /dev/null +++ b/packages/extension/src/providers/ethereum/networks/canto.ts @@ -0,0 +1,25 @@ +import wrapActivityHandler from "@/libs/activity-state/wrap-activity-handler"; +import { CoingeckoPlatform, NetworkNames } from "@enkryptcom/types"; +import { EtherscanActivity } from "../libs/activity-handlers"; +import { EvmNetwork, EvmNetworkOptions } from "../types/evm-network"; + +const cantoOptions: EvmNetworkOptions = { + name: NetworkNames.Canto, + name_long: "Canto", + homePage: "https://canto.io/", + blockExplorerTX: "https://evm.explorer.canto.io/tx/[[txHash]]", + blockExplorerAddr: "https://evm.explorer.canto.io/address/[[address]]", + chainID: 7700, + isTestNetwork: false, + currencyName: "CANTO", + node: "https://canto.evm.chandrastation.com/", + icon: require("./icons/canto.svg"), + gradient: "linear-gradient(180deg, #C549FF 0%, #684CFF 100%)", + coingeckoID: "canto", + coingeckoPlatform: CoingeckoPlatform.Canto, + activityHandler: wrapActivityHandler(EtherscanActivity), +}; + +const canto = new EvmNetwork(cantoOptions); + +export default canto; diff --git a/packages/extension/src/providers/ethereum/networks/icons/canto.svg b/packages/extension/src/providers/ethereum/networks/icons/canto.svg new file mode 100644 index 000000000..029028234 --- /dev/null +++ b/packages/extension/src/providers/ethereum/networks/icons/canto.svg @@ -0,0 +1,4 @@ + + + + diff --git a/packages/extension/src/providers/ethereum/networks/index.ts b/packages/extension/src/providers/ethereum/networks/index.ts index 12f0cc00b..c623dd994 100644 --- a/packages/extension/src/providers/ethereum/networks/index.ts +++ b/packages/extension/src/providers/ethereum/networks/index.ts @@ -11,6 +11,7 @@ import moonriverNode from "./moonriver"; import karuraEvmNode from "./karura"; import shidenEvmNode from "./sdn"; import astarEvmNode from "./astr"; +import cantoNode from "./canto"; export default { goerli: goerliNode, @@ -26,4 +27,5 @@ export default { karuraEvm: karuraEvmNode, shidenEvm: shidenEvmNode, astarEvm: astarEvmNode, + canto: cantoNode, }; diff --git a/packages/types/src/networks.ts b/packages/types/src/networks.ts index d1d17bee2..52951dc05 100644 --- a/packages/types/src/networks.ts +++ b/packages/types/src/networks.ts @@ -19,6 +19,7 @@ export enum NetworkNames { Shiden = "SDN", ShidenEVM = "SDN EVM", AstarEVM = "ASTR EVM", + Canto = "CANTO", } export enum CoingeckoPlatform { @@ -35,4 +36,5 @@ export enum CoingeckoPlatform { Polkadot = "polkadot", Astar = "astar", Shiden = "shiden network", + Canto = "canto", } From 27a6648856fa7ed4c47a5e9dce9c3af720401e31 Mon Sep 17 00:00:00 2001 From: kvhnuke <10602065+kvhnuke@users.noreply.github.com> Date: Tue, 4 Oct 2022 11:54:54 -0700 Subject: [PATCH 04/21] fix: canto rpc --- packages/extension/src/providers/ethereum/index.ts | 3 ++- packages/extension/src/providers/polkadot/index.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/extension/src/providers/ethereum/index.ts b/packages/extension/src/providers/ethereum/index.ts index 2fb2d6536..89ab55b94 100644 --- a/packages/extension/src/providers/ethereum/index.ts +++ b/packages/extension/src/providers/ethereum/index.ts @@ -44,7 +44,8 @@ class EthereumProvider } setRequestProvider(network: BaseNetwork): void { this.network = network as EvmNetwork; - this.requestProvider.changeNetwork(network.node); + this.requestProvider.disconnect(); + this.requestProvider = getRequestProvider(network.node, this.middlewares); } async isPersistentEvent(request: ProviderRPCRequest): Promise { if (request.method === "eth_subscribe") return true; diff --git a/packages/extension/src/providers/polkadot/index.ts b/packages/extension/src/providers/polkadot/index.ts index 1b6d68661..88b537053 100644 --- a/packages/extension/src/providers/polkadot/index.ts +++ b/packages/extension/src/providers/polkadot/index.ts @@ -36,6 +36,7 @@ class PolkadotProvider this.middlewares = Middlewares.map((mw) => mw.bind(this)); } setRequestProvider(network: BaseNetwork): void { + this.requestProvider.disconnect(); this.requestProvider.changeNetwork(network.node); } request(request: ProviderRPCRequest): Promise { From b5e6f53e7465bd6719ef41f7dfbc48069d3a2eaf Mon Sep 17 00:00:00 2001 From: brettkolodny Date: Thu, 20 Oct 2022 17:11:49 -0400 Subject: [PATCH 05/21] feat: add ENS & UD support for EVM and Substrate networks --- .../ethereum/ui/send-transaction/index.vue | 29 +++++++++++++++++-- .../polkadot/ui/send-transaction/index.vue | 25 ++++++++++++++++ packages/name-resolution/src/index.ts | 2 +- 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue b/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue index 7206bf585..3317bedd0 100644 --- a/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue +++ b/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue @@ -164,6 +164,7 @@ import getUiPath from "@/libs/utils/get-ui-path"; import Browser from "webextension-polyfill"; import { ProviderName } from "@/types/provider"; import PublicKeyRing from "@/libs/keyring/public-keyring"; +import NameResolver, { CoinType } from "@enkryptcom/name-resolution"; const props = defineProps({ network: { @@ -185,9 +186,13 @@ const loadingAsset = new Erc20Token({ decimals: 18, }); -const addressInputTo = ref(); const route = useRoute(); const router = useRouter(); +const nameResolver = new NameResolver({ + ens: { node: "https://nodes.mewapi.io/rpc/eth" }, +}); + +const addressInputTo = ref(); const selected: string = route.params.id as string; const accountAssets = ref([]); const selectedAsset = ref>(loadingAsset); @@ -214,6 +219,8 @@ const addressFrom = ref( const addressTo = ref(""); const isLoadingAssets = ref(true); +const resolveTimeoutId = ref | null>(null); + const nativeBalance = computed(() => { const accountIndex = props.accountInfo.activeAccounts.findIndex( (acc) => acc.address === addressFrom.value @@ -440,7 +447,25 @@ const inputAddressFrom = (text: string) => { addressFrom.value = text; }; -const inputAddressTo = (text: string) => { +const inputAddressTo = async (text: string) => { + if (resolveTimeoutId.value) { + clearTimeout(resolveTimeoutId.value); + resolveTimeoutId.value = null; + } + + resolveTimeoutId.value = setTimeout(async () => { + // Get the resolved address for the current network, or default to ETH + const resolved = + (await nameResolver + .resolveAddress(text, props.network.name as CoinType) + .catch(() => null)) || + (await nameResolver.resolveAddress(text, "ETH").catch(() => null)); + + if (resolved) { + addressTo.value = resolved; + } + }, 500); + addressTo.value = text; }; diff --git a/packages/extension/src/providers/polkadot/ui/send-transaction/index.vue b/packages/extension/src/providers/polkadot/ui/send-transaction/index.vue index 16b4d0476..05d130fad 100644 --- a/packages/extension/src/providers/polkadot/ui/send-transaction/index.vue +++ b/packages/extension/src/providers/polkadot/ui/send-transaction/index.vue @@ -124,6 +124,7 @@ import getUiPath from "@/libs/utils/get-ui-path"; import { ProviderName } from "@/types/provider"; import PublicKeyRing from "@/libs/keyring/public-keyring"; import { polkadotEncodeAddress } from "@enkryptcom/utils"; +import NameResolver, { CoinType } from "@enkryptcom/name-resolution"; const props = defineProps({ network: { @@ -138,6 +139,9 @@ const props = defineProps({ const route = useRoute(); const router = useRouter(); +const nameResolver = new NameResolver({ + ens: { node: "https://nodes.mewapi.io/rpc/eth" }, +}); const addressInputTo = ref(); const addressInputFrom = ref(); @@ -165,6 +169,8 @@ const sendMax = ref(false); const selected: string = route.params.id as string; const isLoadingAssets = ref(true); +const resolveTimeoutId = ref | null>(null); + const edWarn = computed(() => { if (!fee.value) { return undefined; @@ -309,6 +315,25 @@ const inputAddressFrom = (text: string) => { }; const inputAddressTo = (text: string) => { + if (resolveTimeoutId.value) { + clearTimeout(resolveTimeoutId.value); + resolveTimeoutId.value = null; + } + + resolveTimeoutId.value = setTimeout(async () => { + // Get the resolved address for the current network, then try for DOT, then KSM + const resolved = + (await nameResolver + .resolveAddress(text, props.network.name as CoinType) + .catch(() => null)) || + (await nameResolver.resolveAddress(text, "DOT").catch(() => null)) || + (await nameResolver.resolveAddress(text, "KSM").catch(() => null)); + + if (resolved) { + addressTo.value = resolved; + } + }, 500); + addressTo.value = text; }; diff --git a/packages/name-resolution/src/index.ts b/packages/name-resolution/src/index.ts index 7b8ffdd89..ca643f288 100644 --- a/packages/name-resolution/src/index.ts +++ b/packages/name-resolution/src/index.ts @@ -43,5 +43,5 @@ class NameResolver { }); } } -export { ENSResolver, UDResolver }; +export { ENSResolver, UDResolver, CoinType }; export default NameResolver; From 05bc3427c2f28b8b5ba27cb2926d4b2da22e1483 Mon Sep 17 00:00:00 2001 From: kvhnuke <10602065+kvhnuke@users.noreply.github.com> Date: Mon, 24 Oct 2022 12:55:51 -0700 Subject: [PATCH 06/21] devop: cleanup name resolving --- .../extension/src/libs/name-resolver/index.ts | 21 +++++++++++ .../ethereum/ui/send-transaction/index.vue | 35 +++++++------------ .../polkadot/ui/send-transaction/index.vue | 34 +++++++----------- 3 files changed, 45 insertions(+), 45 deletions(-) create mode 100644 packages/extension/src/libs/name-resolver/index.ts diff --git a/packages/extension/src/libs/name-resolver/index.ts b/packages/extension/src/libs/name-resolver/index.ts new file mode 100644 index 000000000..d081cdfc3 --- /dev/null +++ b/packages/extension/src/libs/name-resolver/index.ts @@ -0,0 +1,21 @@ +import NameResolver, { CoinType } from "@enkryptcom/name-resolution"; +class GenericNameResolver { + nameResolver: NameResolver; + + constructor() { + this.nameResolver = new NameResolver({ + ens: { node: "https://nodes.mewapi.io/rpc/eth" }, + }); + } + + async resolveName(name: string, coins: CoinType[]): Promise { + let response: string | null = null; + for (const coin of coins) { + response = await this.nameResolver.resolveAddress(name, coin); + if (response) return response; + } + return response; + } +} + +export { CoinType, GenericNameResolver }; diff --git a/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue b/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue index 3317bedd0..0dc21331e 100644 --- a/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue +++ b/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue @@ -129,6 +129,7 @@