Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "feat: Add ENS lookup methods" #145

Merged
merged 1 commit into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ jobs:
path-to-signatures: 'signatures/version1/cla.json'
path-to-cla-document: 'https://gnosis-safe.io/cla/'
branch: 'cla-signatures'
allowlist: germartinez,mikheevm,rmeissner,Uxio0,dasanra,davidalbela,luarx,giacomolicari,lukasschor,tschubotz,gnosis-info,bot*,katspaugh,usame-algan
allowlist: germartinez,mikheevm,rmeissner,Uxio0,dasanra,davidalbela,luarx,giacomolicari,lukasschor,tschubotz,gnosis-info,bot*,katspaugh
empty-commit-flag: false
blockchain-storage-flag: false
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,3 @@ deployments
typechain

openapi/
.idea
2 changes: 0 additions & 2 deletions packages/safe-core-sdk/src/ethereumLibs/EthAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ interface EthAdapter {
signMessage(message: string, signerAddress: string): Promise<string>
estimateGas(transaction: EthAdapterTransaction, options?: string): Promise<number>
call(transaction: EthAdapterTransaction): Promise<string>
ensLookup(name: string): Promise<string>
ensReverseLookup(address: string): Promise<string>
}

export default EthAdapter
34 changes: 0 additions & 34 deletions packages/safe-core-sdk/src/ethereumLibs/EthersAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
} from '../contracts/safeDeploymentContracts'
import { AbiItem } from '../types'
import EthAdapter, { EthAdapterTransaction, GetSafeContractProps } from './EthAdapter'
import ErrorCodes from './exceptions'

export interface EthersAdapterConfig {
/** ethers - Ethers v5 library */
Expand Down Expand Up @@ -152,39 +151,6 @@ class EthersAdapter implements EthAdapter {
call(transaction: EthAdapterTransaction): Promise<string> {
return this.#provider.call(transaction)
}

async ensLookup(name: string): Promise<string> {
let address: string | null

try {
address = await this.#provider.resolveName(name)
} catch (error) {
address = null
}

if (!address) {
throw new Error(ErrorCodes._100)
}

return address

}

async ensReverseLookup(address: string): Promise<string> {
let name: string | null

try {
name = await this.#provider.lookupAddress(address);
} catch (error) {
name = null
}

if (!name) {
throw new Error(ErrorCodes._101)
}

return name
}
}

export default EthersAdapter
26 changes: 2 additions & 24 deletions packages/safe-core-sdk/src/ethereumLibs/Web3Adapter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { BigNumber } from '@ethersproject/bignumber'
import { namehash } from '@ethersproject/hash'
import { SafeVersion } from '../contracts/config'
import {
getGnosisSafeProxyFactoryContractInstance,
Expand All @@ -16,7 +15,6 @@ import {
} from '../contracts/safeDeploymentContracts'
import { AbiItem } from '../types'
import EthAdapter, { EthAdapterTransaction, GetSafeContractProps } from './EthAdapter'
import ErrorCodes from './exceptions'

export interface Web3AdapterConfig {
/** web3 - Web3 library */
Expand Down Expand Up @@ -107,7 +105,7 @@ class Web3Adapter implements EthAdapter {
return getGnosisSafeProxyFactoryContractInstance(safeVersion, proxyFactoryContract)
}

getContract(address: string, abi: any): any {
getContract(address: string, abi: AbiItem[]): any {
return new this.#web3.eth.Contract(abi, address)
}

Expand All @@ -127,33 +125,13 @@ class Web3Adapter implements EthAdapter {
return this.#web3.eth.sign(message, this.#signerAddress)
}

estimateGas(transaction: EthAdapterTransaction, options?: any): Promise<number> {
estimateGas(transaction: EthAdapterTransaction, options?: string): Promise<number> {
return this.#web3.eth.estimateGas(transaction, options)
}

call(transaction: EthAdapterTransaction): Promise<string> {
return this.#web3.eth.call(transaction)
}

async ensLookup(name: string): Promise<string> {
try {
return await this.#web3.eth.ens.getAddress(name)
} catch (error) {
throw new Error(ErrorCodes._100)
}
}

async ensReverseLookup(address: string): Promise<string> {
const lookup = address.slice(2) + '.addr.reverse'
const node = namehash(lookup)

try {
const ResolverContract = await this.#web3.eth.ens.getResolver(lookup);
return await ResolverContract.methods.name(node).call()
} catch (error) {
throw new Error(ErrorCodes._101)
}
}
}

export default Web3Adapter
6 changes: 0 additions & 6 deletions packages/safe-core-sdk/src/ethereumLibs/exceptions.ts

This file was deleted.

87 changes: 0 additions & 87 deletions packages/safe-core-sdk/tests/ens.test.ts

This file was deleted.