-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a99117a
commit 6644ab2
Showing
12 changed files
with
1,818 additions
and
1,762 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,40 @@ | ||
import { BrowserProvider } from 'ethers/providers'; | ||
import log from 'loglevel'; | ||
|
||
import { ResolutionUtilsV2 } from './ResolutionUtilsV2/ResolutionUtilsV2'; | ||
import { ResolutionUtilsV2__factory } from './ResolutionUtilsV2/ResolutionUtilsV2__factory'; | ||
|
||
const resolutionUtilsV2Address = '0x1ea4e7A798557001b99D88D6b4ba7F7fc79406A9'; | ||
|
||
export class AvvyAPI { | ||
private static _instance: AvvyAPI | null = null; | ||
private resolutionUtilsV2: ResolutionUtilsV2; | ||
|
||
private constructor(provider: BrowserProvider) { | ||
this.resolutionUtilsV2 = ResolutionUtilsV2__factory.connect( | ||
resolutionUtilsV2Address, | ||
provider | ||
); | ||
} | ||
|
||
public static getInstance(provider: BrowserProvider): AvvyAPI { | ||
if (this._instance === null) { | ||
log.debug('AvvyAPI init'); | ||
this._instance = new AvvyAPI(provider); | ||
} | ||
return this._instance; | ||
} | ||
|
||
public addressToDomain = async (address: string) => { | ||
const domain = | ||
await this.resolutionUtilsV2.reverseResolveEVMToName(address); | ||
log.debug(domain); | ||
return domain; | ||
}; | ||
|
||
public domainToAddress = async (domain: string) => { | ||
const address = await this.resolutionUtilsV2.resolveStandard(domain, 3); | ||
log.debug(address); | ||
return address; | ||
}; | ||
} |
115 changes: 115 additions & 0 deletions
115
src/services/ethersV6/avvy/ResolutionUtilsV2/ResolutionUtilsV2.ts
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,115 @@ | ||
/* Autogenerated file. Do not edit manually. */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
import type { | ||
BaseContract, | ||
BigNumberish, | ||
BytesLike, | ||
FunctionFragment, | ||
Result, | ||
Interface, | ||
AddressLike, | ||
ContractRunner, | ||
ContractMethod, | ||
Listener, | ||
} from 'ethers'; | ||
import type { | ||
TypedContractEvent, | ||
TypedDeferredTopicFilter, | ||
TypedEventLog, | ||
TypedListener, | ||
TypedContractMethod, | ||
} from '../../types/common'; | ||
|
||
export interface ResolutionUtilsV2Interface extends Interface { | ||
getFunction( | ||
nameOrSignature: 'resolveStandard' | 'reverseResolveEVMToName' | ||
): FunctionFragment; | ||
|
||
encodeFunctionData( | ||
functionFragment: 'resolveStandard', | ||
values: [string, BigNumberish] | ||
): string; | ||
encodeFunctionData( | ||
functionFragment: 'reverseResolveEVMToName', | ||
values: [AddressLike] | ||
): string; | ||
|
||
decodeFunctionResult( | ||
functionFragment: 'resolveStandard', | ||
data: BytesLike | ||
): Result; | ||
decodeFunctionResult( | ||
functionFragment: 'reverseResolveEVMToName', | ||
data: BytesLike | ||
): Result; | ||
} | ||
|
||
export interface ResolutionUtilsV2 extends BaseContract { | ||
connect(runner?: ContractRunner | null): ResolutionUtilsV2; | ||
waitForDeployment(): Promise<this>; | ||
|
||
interface: ResolutionUtilsV2Interface; | ||
|
||
queryFilter<TCEvent extends TypedContractEvent>( | ||
event: TCEvent, | ||
fromBlockOrBlockhash?: string | number | undefined, | ||
toBlock?: string | number | undefined | ||
): Promise<Array<TypedEventLog<TCEvent>>>; | ||
queryFilter<TCEvent extends TypedContractEvent>( | ||
filter: TypedDeferredTopicFilter<TCEvent>, | ||
fromBlockOrBlockhash?: string | number | undefined, | ||
toBlock?: string | number | undefined | ||
): Promise<Array<TypedEventLog<TCEvent>>>; | ||
|
||
on<TCEvent extends TypedContractEvent>( | ||
event: TCEvent, | ||
listener: TypedListener<TCEvent> | ||
): Promise<this>; | ||
on<TCEvent extends TypedContractEvent>( | ||
filter: TypedDeferredTopicFilter<TCEvent>, | ||
listener: TypedListener<TCEvent> | ||
): Promise<this>; | ||
|
||
once<TCEvent extends TypedContractEvent>( | ||
event: TCEvent, | ||
listener: TypedListener<TCEvent> | ||
): Promise<this>; | ||
once<TCEvent extends TypedContractEvent>( | ||
filter: TypedDeferredTopicFilter<TCEvent>, | ||
listener: TypedListener<TCEvent> | ||
): Promise<this>; | ||
|
||
listeners<TCEvent extends TypedContractEvent>( | ||
event: TCEvent | ||
): Promise<Array<TypedListener<TCEvent>>>; | ||
listeners(eventName?: string): Promise<Array<Listener>>; | ||
removeAllListeners<TCEvent extends TypedContractEvent>( | ||
event?: TCEvent | ||
): Promise<this>; | ||
|
||
resolveStandard: TypedContractMethod< | ||
[name: string, key: BigNumberish], | ||
[string], | ||
'view' | ||
>; | ||
|
||
reverseResolveEVMToName: TypedContractMethod< | ||
[addy: AddressLike], | ||
[string], | ||
'view' | ||
>; | ||
|
||
getFunction<T extends ContractMethod = ContractMethod>( | ||
key: string | FunctionFragment | ||
): T; | ||
|
||
getFunction( | ||
nameOrSignature: 'resolveStandard' | ||
): TypedContractMethod<[name: string, key: BigNumberish], [string], 'view'>; | ||
getFunction( | ||
nameOrSignature: 'reverseResolveEVMToName' | ||
): TypedContractMethod<[addy: AddressLike], [string], 'view'>; | ||
|
||
filters: {}; | ||
} |
68 changes: 68 additions & 0 deletions
68
src/services/ethersV6/avvy/ResolutionUtilsV2/ResolutionUtilsV2__factory.ts
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,68 @@ | ||
/* Autogenerated file. Do not edit manually. */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
|
||
import { Contract, Interface, type ContractRunner } from 'ethers'; | ||
import type { | ||
ResolutionUtilsV2, | ||
ResolutionUtilsV2Interface, | ||
} from './ResolutionUtilsV2'; | ||
|
||
const _abi = [ | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: 'string', | ||
name: 'name', | ||
type: 'string', | ||
}, | ||
{ | ||
internalType: 'uint256', | ||
name: 'key', | ||
type: 'uint256', | ||
}, | ||
], | ||
name: 'resolveStandard', | ||
outputs: [ | ||
{ | ||
internalType: 'string', | ||
name: 'value', | ||
type: 'string', | ||
}, | ||
], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: 'address', | ||
name: 'addy', | ||
type: 'address', | ||
}, | ||
], | ||
name: 'reverseResolveEVMToName', | ||
outputs: [ | ||
{ | ||
internalType: 'string', | ||
name: 'preimage', | ||
type: 'string', | ||
}, | ||
], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
] as const; | ||
|
||
export class ResolutionUtilsV2__factory { | ||
static readonly abi = _abi; | ||
static createInterface(): ResolutionUtilsV2Interface { | ||
return new Interface(_abi) as ResolutionUtilsV2Interface; | ||
} | ||
static connect( | ||
address: string, | ||
runner?: ContractRunner | null | ||
): ResolutionUtilsV2 { | ||
return new Contract(address, _abi, runner) as unknown as ResolutionUtilsV2; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/services/ethersV6/interfaces/IWalletEthersV6ProviderApi.ts
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,9 @@ | ||
import { BrowserProvider } from 'ethers/providers'; | ||
|
||
import { IWalletAPI } from '../../interfaces/IWalletAPI'; | ||
|
||
export interface IWalletEthersV6ProviderApi extends IWalletAPI { | ||
// following methods are needed for using provider and signer in contract services | ||
getProvider(): BrowserProvider | null; | ||
getSignerAddress(): string | null; | ||
} |
Oops, something went wrong.