-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrequest-model.ts
More file actions
83 lines (73 loc) · 1.83 KB
/
request-model.ts
File metadata and controls
83 lines (73 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { Data, Effect, RateLimiter } from 'effect'
export interface FetchABIParams {
readonly chainID: number
readonly address: string
readonly event?: string | undefined
readonly signature?: string | undefined
}
export class ResolveStrategyABIError extends Data.TaggedError('ResolveStrategyABIError')<{
resolver: string
address: string
chainID: number
message: string
}> {
constructor(resolver: string, address: string, chainID: number, message: string) {
super({ resolver, address, chainID, message })
}
}
export class MissingABIStrategyError extends Data.TaggedError('MissingABIStrategyError')<{
address: string
chainId: number
strategyId: string
event?: string
signature?: string
message: string
}> {
constructor(
address: string,
chainId: number,
strategyId: string,
event?: string,
signature?: string,
message = 'Missing contract ABI',
) {
super({ address, chainId, strategyId, event, signature, message })
}
}
interface FunctionFragmentABI {
type: 'func'
abi: string
address: string
chainID: number
signature: string
}
interface EventFragmentABI {
type: 'event'
abi: string
address: string
chainID: number
event: string
}
interface AddressABI {
type: 'address'
abi: string
address: string
chainID: number
}
export type ContractABI = FunctionFragmentABI | EventFragmentABI | AddressABI
export type RateLimiterOptions = RateLimiter.RateLimiter.Options
export interface ContractAbiResolverStrategy {
type: 'address' | 'fragment'
id: string
rateLimit?: RateLimiterOptions
resolver: (
_: GetContractABIStrategyParams,
) => Effect.Effect<ContractABI[], ResolveStrategyABIError | MissingABIStrategyError>
}
export interface GetContractABIStrategyParams {
chainId: number
address: string
strategyId: string
event?: string
signature?: string
}