Skip to content

Commit

Permalink
Dchan/dt 902 add ens resolution js (#254)
Browse files Browse the repository at this point in the history
* [DT-912] Revert: "Removes ENS support"

This reverts commit 0af264b.

* [DT-902] test: fixing tests to use alchemy's goerli as provider for ENS

* [DT-902] docs: updating changelog to include minor version for ENS support

* [DT-902] refactor: ENS constructor and fix ENS.test.ts

* [DT-902] test: Fixed Resolution.test.ts unit tests

* [DT-902] refactor: Added UdApi for ensConfig

* [DT-902] refactor: added ens.getAddress()

* [DT-902] fix: CI node version

* [DT-902] fix: test setup and timeout

* [DT-902] feature: Adding support for ENS tokenURI()

* [DT-902] feature: adding ENS support for unhash()

* [DT-902] feature: adding ENS support for locations()

* [DT-902] chore: removing unnecessary README.md info

* [DT-902] fix: fixing unit tests

* [DT-902] fix: Ens.fetchAddress() to support ud Api as the provider with apiKey

* [DT-902] Updating @unstoppabledomains/sizecheck dev dependency to latest version

* [DT-902] fix: Fixed @unstoppabledomains/sizecheck version to 4.0.4

* [DT-902] Fix: owner() & reverse()

* [DT-902] Fix: Resolution.addr()

* [DT-902] feature: adding ENS support for Resolution.email(), Resolution.httpUrl(), Resolution.ipfsHash()

* [DT-902] fix: Added final validation for Ens.reverseOf()

* [DT-902] fix: locations() & added better error handling

* [DT-902] refactor: reverseTokenId() to support ENS

* [DT-902] chore: added Ens.dns() todo

* [DT-902] fix: Unit testing and small updates

* [DT-902] chore: resolve PR comments & revise unit tests

* [DT-902] chore: Making sure to throw unsupported method for Ens multiChainAddr()

* [DT-902] chore: updating README.md to include ENS examples

* v9.2.0
  • Loading branch information
DChan0319 authored Oct 3, 2023
1 parent b9d3140 commit f19421a
Show file tree
Hide file tree
Showing 36 changed files with 6,594 additions and 1,343 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
L1_TEST_NET_RPC_URL=https://goerli.infura.io/v3/<your_key>
L1_TEST_NET_RPC_WSS_URL=wss://goerli.infura.io/ws/v3/<your_key>
L2_TEST_NET_RPC_URL=https://polygon-mumbai.infura.io/v3/<your_key>
L2_TEST_NET_RPC_WSS_URL=wss://polygon-mumbai.g.alchemy.com/v2/<your_key>
L2_TEST_NET_RPC_WSS_URL=wss://polygon-mumbai.g.alchemy.com/v2/<your_key>
4 changes: 2 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
node: [12, 14, 16]
node: [16]

name: ${{ matrix.os }} - Node ${{ matrix.node }}

Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 12
node-version: ${{ matrix.node }}

- name: Install Dependencies
run: yarn install
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 9.2.0

- Add ENS support

## 9.1.0

- Add new getAddress API
Expand Down
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ const resolution = new Resolution({
url: 'https://api.zilliqa.com',
network: 'mainnet',
},
ens: {
url: 'https://mainnet.infura.io/v3/<infura_api_key>',
network: 'mainnet',
},
},
});
```
Expand Down Expand Up @@ -163,6 +167,7 @@ function resolve(domain, currency) {

resolve('brad.crypto', 'ETH');
resolve('brad.zil', 'ZIL');
resolve('vitalik.eth', 'ETH');
```

### Find the IPFS hash for a decentralized website
Expand All @@ -182,13 +187,16 @@ function resolveIpfsHash(domain) {
}

resolveIpfsHash('homecakes.crypto');
resolveIpfsHash('vitalik.eth');
```

### Find a custom record

Create a new file in your project, `custom-resolution.js`.

```javascript
// Does not support ENS

function resolveCustomRecord(domain, record) {
resolution
.records(domain, [record])
Expand Down Expand Up @@ -218,6 +226,8 @@ function getWalletAddr(domain, ticker) {
}
getWalletAddr('homecakes.crypto', 'ETH');
// Domain homecakes.crypto has address for ETH: 0xe7474D07fD2FA286e7e0aa23cd107F8379085037
getWalletAddr('vitalik.eth', 'ETH');
// Domain homecakes.crypto has address for ETH: 0xe7474D07fD2FA286e7e0aa23cd107F8379085037
```

### Resolve multi-chain address format using `multiChainAddr`
Expand All @@ -229,6 +239,8 @@ This API is used to retrieve wallet address for multi-chain address records.
With `aaron.x` has `crypto.AAVE.version.ERC20.address` on-chain:

```javascript
// Does not support ENS

function getMultiChainWalletAddr(domain, ticker, network) {
resolution
.multiChainAddr(domain, ticker, network)
Expand Down Expand Up @@ -335,6 +347,7 @@ token.EVM.ETH.address
```

`getAddress(domain, 'ETH', 'USDC')` will lookup records in the following order:
// Not supported with ENS

```
1. token.EVM.ETH.USDC.address
Expand All @@ -344,15 +357,6 @@ token.EVM.ETH.address
5. token.EVM.address
```

> **Warning** please use the API with caution as it's still in beta. Please
> submit an issue if you find a bug.
### Command Line Interface

CLI support was removed from the Resolution library starting from version 6.0.
Please use the
[standalone CLI tool](https://github.com/unstoppabledomains/resolution-cli).

## Error Handling

When resolution encounters an error it returns the error code instead of
Expand Down Expand Up @@ -389,7 +393,6 @@ or **Linux shell**).
### Internal config

#### To update:

- Network config: `$ yarn network-config:pull`
- Resolver keys: `$ yarn resolver-keys:pull`
- Both configs: `$ yarn config:pull`
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
diagnostics: false,
},
},
testTimeout: 40000,
testTimeout: 50000,
coveragePathIgnorePatterns: ['/node_modules/', '/src/tests/'],
setupFilesAfterEnv: ['<rootDir>/src/tests/jestSetup.ts'],
};
15 changes: 11 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@unstoppabledomains/resolution",
"version": "9.1.0",
"version": "9.2.0",
"description": "Domain Resolution for blockchain domains",
"main": "./build/index.js",
"directories": {
Expand Down Expand Up @@ -45,6 +45,7 @@
"keywords": [
".crypto",
"zns",
"ens",
"ethereum",
"zilliqa",
"blockchain",
Expand All @@ -59,6 +60,7 @@
},
"homepage": "https://github.com/unstoppabledomains/resolution.git#readme",
"devDependencies": {
"@ensdomains/address-encoder": "0.2.18",
"@ethersproject/providers": "^5.4.5",
"@types/bn.js": "^4.11.6",
"@types/crypto-js": "^4.1.1",
Expand All @@ -68,9 +70,11 @@
"@types/node": "11.15.3",
"@typescript-eslint/eslint-plugin": "^3.9.0",
"@typescript-eslint/parser": "^3.9.0",
"@unstoppabledomains/sizecheck": "^4.0.0",
"@unstoppabledomains/sizecheck": "^4.0.4",
"@zilliqa-js/core": "^3.3.4",
"audit-ci": "^3.1.1",
"bip44-constants": "^8.0.103",
"content-hash": "^2.5.2",
"dotenv": "^8.2.0",
"eslint": "^7.7.0",
"eslint-config-prettier": "^8.3.0",
Expand All @@ -97,9 +101,12 @@
"dependencies": {
"@ethersproject/abi": "^5.0.1",
"bn.js": "^4.4.0",
"cross-fetch": "^3.1.4",
"cross-fetch": "4.0.0",
"crypto-js": "^4.1.1",
"elliptic": "^6.5.4"
"elliptic": "^6.5.4",
"ethereum-ens-network-map": "^1.0.2",
"js-sha256": "^0.9.0",
"js-sha3": "^0.8.0"
},
"lint-staged": {
"src/**/*.ts": "eslint --fix",
Expand Down
Loading

0 comments on commit f19421a

Please sign in to comment.