Skip to content

Commit

Permalink
Layer two (#188)
Browse files Browse the repository at this point in the history
Release of Polygon Layer 2 support!
  • Loading branch information
DeRain authored Nov 4, 2021
1 parent ca79ec5 commit bf8a211
Show file tree
Hide file tree
Showing 32 changed files with 3,265 additions and 1,588 deletions.
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
## 6.0.0
### Breaking changes
- CLI tool was removed. Please use new binary CLI tool instead: [Github repo](https://github.com/unstoppabledomains/resolution-cli/releases).
- Constructor has changed. If you used `uns` configuration you have to specify parameters for L1 and L2 locations (Ethereum and Polygon mainnets).
- ENS support is deprecated and will be removed in future.
- Factory methods has changed. All of them requires provide L1 and L2 locations configuration for UNS. For example: `uns: {locations: {L1: ..., L2...}}`.
- The list of affected methods:
- `Resolution#infura`
- `Resolution#fromResolutionProvider`
- `Resolution#fromEthereumEip1193Provider`
- `Resolution#fromWeb3Version0Provider`
- `Resolution#fromWeb3Version1Provider`
- `Resolution#fromEthersProvider`
- `Resolution#location` method is replaced by `Resolution#locations`.

### New methods and features
- 🎉 🎉 🎉 Add Polygon Layer 2 support!
- Add `Resolution#locations` method which will help to determine domains location (blockhain, networkId) and useful metadata like owner, resolver, registry addresses, provider url if possible.
- Method returns:
- Domain blockhain (ETH or MATIC)
- Blockchain network id (numeric)
- Owner address
- Resolver address
- Registry address
- Provider URL if possible
- Infura URL by default

## 5.0.2
- Replaces `node-fetch` with `cross-fetch` package

Expand Down
18 changes: 6 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
{
"name": "@unstoppabledomains/resolution",
"version": "5.0.2",
"version": "6.0.0",
"description": "Domain Resolution for blockchain domains",
"main": "./build/index.js",
"directories": {
"doc": "docs"
},
"types": "./build/index.d.ts",
"bin": {
"resolution": "./build/cli/cli.js"
},
"scripts": {
"release": "RELEASE=patch yarn release:run",
"release:minor": "RELEASE=minor yarn release:run",
Expand All @@ -24,9 +21,7 @@
"test:live": "LIVE=1 yarn test",
"test:live:win": "set LIVE=1&& yarn test",
"start": "npm run build:live",
"dev": "yarn build && ./build/cli/cli.js -d brad.crypto",
"build": "rm -rf build && tsc -p . && chmod +x ./build/cli/cli.js",
"build:symlink": "yarn build && ln -sf $PWD/build/cli/cli.js /usr/local/bin/resolution",
"build": "rm -rf build && tsc -p .",
"build:live": "nodemon --watch 'src/**/*.ts' --exec yarn build",
"docs": "yarn docs:clone && yarn docs:generate && yarn docs:readme",
"docs:clone": "([ -d ./docs ] || git clone --branch gh-pages git@github.com:unstoppabledomains/resolution.git docs) && git -C ./docs pull",
Expand Down Expand Up @@ -68,10 +63,10 @@
"homepage": "https://github.com/unstoppabledomains/resolution.git#readme",
"devDependencies": {
"@ensdomains/address-encoder": "0.2.6",
"@ethersproject/providers": "^5.0.2",
"@ethersproject/providers": "^5.4.5",
"@types/bn.js": "^4.11.6",
"@types/elliptic": "^6.4.13",
"@types/jest": "24.0.23",
"@types/jest": "27.0.2",
"@types/lodash": "^4.14.158",
"@types/node": "11.15.3",
"@typescript-eslint/eslint-plugin": "^3.9.0",
Expand All @@ -87,7 +82,7 @@
"eslint-plugin-jest": "^24.1.0",
"husky": "^6.0.0",
"jest": "^27.0.4",
"lint-staged": "^11.0.0",
"lint-staged": "11.0.0",
"lodash": "^4.17.19",
"nock": "10.0.6",
"nodemon": "^2.0.7",
Expand All @@ -96,7 +91,7 @@
"ts-jest": "^27.0.3",
"ts-loader": "6.2.1",
"ts-node": "^8.6.2",
"typedoc": "0.17.8",
"typedoc": "0.18.0",
"typescript": "3.8.3",
"web3-0.20.7": "npm:web3@0.20.7",
"web3-providers-http": "^1.3.6",
Expand All @@ -108,7 +103,6 @@
"dependencies": {
"@ethersproject/abi": "^5.0.1",
"bn.js": "^4.4.0",
"commander": "^4.1.1",
"cross-fetch": "^3.1.4",
"elliptic": "^6.5.4",
"ethereum-ens-network-map": "^1.0.2",
Expand Down
26 changes: 8 additions & 18 deletions src/Ens.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {default as ensInterface} from './contracts/ens/ens';
import {default as resolverInterface} from './contracts/ens/resolver';
import {
BlockhanNetworkUrlMap,
BlockhainNetworkUrlMap,
EnsSupportedNetwork,
EthCoinIndex,
hasProvider,
Expand All @@ -10,9 +10,8 @@ import {ResolutionError, ResolutionErrorCode} from './errors/resolutionError';
import EthereumContract from './contracts/EthereumContract';
import EnsNetworkMap from 'ethereum-ens-network-map';
import {
BlockchainType,
DomainLocation,
EnsSource,
Locations,
NamingServiceName,
Provider,
} from './types/publicTypes';
Expand All @@ -34,7 +33,7 @@ import {requireOrFail} from './utils/requireOrFail';
* @internal
*/
export default class Ens extends NamingService {
static readonly UrlMap: BlockhanNetworkUrlMap = {
static readonly UrlMap: BlockhainNetworkUrlMap = {
1: 'https://mainnet.infura.io/v3/d423cf2499584d7fbe171e33b42cfbee',
3: 'https://ropsten.infura.io/v3/d423cf2499584d7fbe171e33b42cfbee',
4: 'https://rinkeby.infura.io/v3/d423cf2499584d7fbe171e33b42cfbee',
Expand Down Expand Up @@ -228,20 +227,11 @@ export default class Ens extends NamingService {
});
}

async location(domain: string): Promise<DomainLocation> {
const [registry, resolver, owner] = await Promise.all([
this.registryAddress(domain),
this.resolver(domain),
this.owner(domain),
]);

return {
registry,
resolver,
networkId: this.network,
blockchain: BlockchainType.ETH,
owner,
};
locations(domains: string[]): Promise<Locations> {
throw new ResolutionError(ResolutionErrorCode.UnsupportedMethod, {
method: NamingServiceName.ENS,
methodName: 'locations',
});
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/FetchProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class FetchProvider implements Provider {
});
if (response.status !== 200) {
throw new ResolutionError(ResolutionErrorCode.ServiceProviderError, {
providerMessage: `Request to ${this.url} failed with responce status ${response.status}`,
providerMessage: `Request to ${this.url} failed with response status ${response.status}`,
});
}
return response.json();
Expand Down
4 changes: 2 additions & 2 deletions src/NamingService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {DomainLocation, ResolutionMethod} from './types/publicTypes';
import {Locations, ResolutionMethod} from './types/publicTypes';

/**
* @internal
Expand Down Expand Up @@ -28,5 +28,5 @@ export abstract class NamingService {

abstract isAvailable(domain: string): Promise<boolean>;
abstract registryAddress(domain: string): Promise<string>;
abstract location(domain: string): Promise<DomainLocation>;
abstract locations(domains: string[]): Promise<Locations>;
}
Loading

0 comments on commit bf8a211

Please sign in to comment.