2021-02-04 19:15:23 +01:00
|
|
|
import EthJsEns from 'ethjs-ens';
|
|
|
|
import ensNetworkMap from 'ethereum-ens-network-map';
|
2019-11-01 18:54:00 +01:00
|
|
|
|
2020-05-06 00:19:38 +02:00
|
|
|
export default class Ens {
|
2020-11-03 00:41:28 +01:00
|
|
|
static getNetworkEnsSupport(network) {
|
2021-02-04 19:15:23 +01:00
|
|
|
return Boolean(ensNetworkMap[network]);
|
2019-11-01 18:54:00 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
constructor({ network, provider } = {}) {
|
2019-11-01 18:54:00 +01:00
|
|
|
this._ethJsEns = new EthJsEns({
|
|
|
|
network,
|
|
|
|
provider,
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2019-11-01 18:54:00 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
lookup(ensName) {
|
2021-02-04 19:15:23 +01:00
|
|
|
return this._ethJsEns.lookup(ensName);
|
2019-11-01 18:54:00 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
reverse(address) {
|
2021-02-04 19:15:23 +01:00
|
|
|
return this._ethJsEns.reverse(address);
|
2019-11-01 18:54:00 +01:00
|
|
|
}
|
|
|
|
}
|