-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add name service infrastructure and ENS (#567)
* feat: add name service infrastructrure and ENS * feat: resolveName and lookupAddress * chore: naming & declaration Co-authored-by: Krasimir Raykov <raykov@weichain.tech>
- Loading branch information
1 parent
1a0d1d7
commit c82ec04
Showing
8 changed files
with
79 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { AddressType, NamingProvider } from '@chainify/types'; | ||
import { StaticJsonRpcProvider } from '@ethersproject/providers'; | ||
|
||
export class EnsProvider implements NamingProvider { | ||
private _provider: StaticJsonRpcProvider; | ||
|
||
constructor(provider: StaticJsonRpcProvider) { | ||
this._provider = provider; | ||
} | ||
|
||
/** | ||
* @param address - resolve name to address | ||
* @returns - address | ||
*/ | ||
public async resolveName(name: string): Promise<AddressType> { | ||
return this._provider.resolveName(name); | ||
} | ||
|
||
/** | ||
* @param address - look up address | ||
* @returns - ens | ||
*/ | ||
public async lookupAddress(address: AddressType): Promise<string> { | ||
return this._provider.lookupAddress(address.toString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { AddressType } from './Address'; | ||
|
||
export interface NamingProvider { | ||
/** | ||
* @param address - resolve name to address | ||
* @returns - address | ||
*/ | ||
resolveName(name: string): Promise<AddressType>; | ||
|
||
/** | ||
* @param address - look up address | ||
* @returns - ens | ||
*/ | ||
lookupAddress(address: AddressType): Promise<string>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters