-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
7 changed files
with
73 additions
and
13 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
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,66 @@ | ||
import type {SigningKey, BytesLike, BigNumberish, Interface, Result, FunctionFragment} from 'ethers'; | ||
|
||
type HexString = string; | ||
|
||
export interface Record { | ||
addr?(type: bigint) : Promise<BytesLike | undefined>; | ||
text?(key: string) : Promise<string | undefined>; | ||
contenthash?(): Promise<BytesLike | undefined>; | ||
pubkey?(): Promise<{x: BigNumberish, y: BigNumberish} | BytesLike | undefined>; | ||
name?(): Promise<string | undefined>; | ||
ABI?(types: number): Promise<{type: number, data: BytesLike} | BytesLike | undefined>; | ||
} | ||
|
||
export type History = { | ||
level: number; | ||
next?: History; | ||
children: History[]; | ||
name?: string; | ||
error?: any; | ||
show?: any[]; | ||
enter(): History; | ||
then(): History; | ||
} | ||
|
||
type SigningProtocol = 'tor' | 'ens' | 'raw'; | ||
type CallContextExtra = {[key: string]: any}; | ||
type CallContext = { | ||
sender: HexString; | ||
calldata: HexString; | ||
protocol: SigningProtocol; | ||
resolver: HexString; | ||
history: History; | ||
} & CallContextExtra; | ||
type CCIPReadFunction = (args: Result, context: CallContext, history: History) => Promise<BytesLike | any[] | undefined>; | ||
type CCIPReadHandler = {abi: Interface, frag: FunctionFragment, fn: CCIPReadFunction}; | ||
type ENSIP10Function = (name: string, context: CallContext) => Promise<Record | undefined>; | ||
type EZCCIPConfig = { | ||
protocol?: SigningProtocol; | ||
signingKey?: SigningKey | HexString; | ||
ttlSec?: number; | ||
recursionLimit?: number; | ||
} & CallContextExtra; | ||
export class EZCCIP { | ||
enableENSIP10(get: ENSIP10Function, options?: {multicall?: boolean}): void; | ||
register(abi: string | string[] | Interface, impl: CCIPReadFunction | {[name: string]: CCIPReadFunction}): CCIPReadHandler[]; | ||
handleRead(sender: HexString, calldata: HexString, config: EZCCIPConfig & {resolver?: HexString}): Promise<{data: HexString, history: History}>; | ||
} | ||
export function processENSIP10(record: Record | undefined, calldata: HexString, multicall?: boolean, history?: History): HexString; | ||
|
||
export function serve(handler: ENSIP10Function | EZCCIP, options?: { | ||
log?: boolean | ((...a: any) => any); // default console.log w/date, falsy to disable | ||
port?: number; // default random open | ||
resolvers?: { [tag: string]: HexString }; // default: uses sender | ||
} & EZCCIPConfig): Promise<Readonly<{ | ||
http: { close(): void }; | ||
port: number; | ||
endpoint: string; | ||
signer: HexString; | ||
context: string; | ||
}>>; | ||
|
||
export function asciiize(s: string): string; | ||
export function labels_from_dns_encoded(v: Uint8Array): string[]; | ||
export function error_with(message: string, options: Object, cause?: any): Error; | ||
|
||
export const RESOLVE_ABI: Interface; |
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