-
Notifications
You must be signed in to change notification settings - Fork 6
/
decoder.types.ts
107 lines (96 loc) · 2.24 KB
/
decoder.types.ts
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import {
type DECODED_ACTION,
type DECODED_EVENT_CATEGORY,
} from "./decoder.constants";
import {
type Chain,
type ChainName,
type GoldRushClient,
type LogEvent,
type Nullable,
type Transaction,
} from "@covalenthq/client-sdk";
export type Configs = {
protocol_name: string;
chain_name: ChainName | `${ChainName}`;
address: string;
is_factory: boolean;
}[];
export type EventDetails = Nullable<{
heading: string;
value: string;
type: "address" | "text";
}>[];
export type EventNFTs = Nullable<{
heading: string;
collection_name: string;
token_identifier: string;
collection_address: string;
images: Nullable<{
default: string;
256: string;
512: string;
1024: string;
}>;
}>[];
export type EventTokens = Nullable<{
heading: string;
value: string;
decimals: number;
ticker_symbol: string;
ticker_logo: string;
pretty_quote: string;
}>[];
export type EventType = Nullable<{
category: DECODED_EVENT_CATEGORY;
action: DECODED_ACTION;
name: string;
protocol?: Nullable<{
name: string;
logo: string;
}>;
tokens?: EventTokens;
nfts?: EventNFTs;
details?: EventDetails;
raw_log?: LogEvent;
}>;
export interface QueryOptions {
raw_logs?: boolean;
min_usd?: number;
}
export type DecodingFunction = (
log_event: LogEvent,
tx: Transaction,
chain_name: Chain,
goldrush_client: GoldRushClient,
options: QueryOptions
) => Promise<EventType | null>;
export type NativeDecodingFunction = (
tx: Transaction,
options: QueryOptions
) => EventType | null;
export type DecoderConfig =
| {
[chain_name in ChainName]: {
[protocol_name: string]: {
[address: string]: {
is_factory: boolean;
};
};
};
}
| Record<string, never>;
export type Decoders =
| {
[chain_name in ChainName]: {
[address: string]: {
[topic0_hash: string]: number;
};
};
}
| Record<string, never>;
export type Fallbacks =
| {
[topic0_hash: string]: number;
}
| Record<string, never>;