@apibara/evm 2.1.0-beta.23 → 2.1.0-beta.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +386 -475
- package/dist/index.d.cts +1068 -2054
- package/dist/index.d.mts +1068 -2054
- package/dist/index.d.ts +1068 -2054
- package/dist/index.mjs +388 -466
- package/package.json +2 -4
- package/src/block.ts +312 -308
- package/src/common.ts +64 -101
- package/src/filter.ts +128 -138
- package/src/common.test.ts +0 -79
- package/src/filter.test.ts +0 -187
- package/src/helpers.ts +0 -8
package/src/block.ts
CHANGED
|
@@ -1,361 +1,365 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { BytesFromUint8Array } from "@apibara/protocol";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ArrayCodec,
|
|
5
|
+
BigIntCodec,
|
|
6
|
+
BooleanCodec,
|
|
7
|
+
type Codec,
|
|
8
|
+
type CodecType,
|
|
9
|
+
DateCodec,
|
|
10
|
+
MessageCodec,
|
|
11
|
+
NumberCodec,
|
|
12
|
+
OneOfCodec,
|
|
13
|
+
OptionalCodec,
|
|
14
|
+
StringCodec,
|
|
15
|
+
} from "@apibara/protocol/codec";
|
|
16
|
+
import { RequiredCodec } from "@apibara/protocol/codec";
|
|
4
17
|
import { Address, B256, U128, U256 } from "./common";
|
|
5
|
-
import { tag } from "./helpers";
|
|
6
18
|
import * as proto from "./proto";
|
|
7
19
|
|
|
8
|
-
export const Bloom
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
decode({ value }) {
|
|
19
|
-
return value;
|
|
20
|
-
},
|
|
20
|
+
export const Bloom: Codec<
|
|
21
|
+
`0x${string}` | undefined,
|
|
22
|
+
{ value?: Uint8Array | undefined }
|
|
23
|
+
> = {
|
|
24
|
+
encode(x) {
|
|
25
|
+
return { value: BytesFromUint8Array.encode(x) };
|
|
26
|
+
},
|
|
27
|
+
decode({ value }) {
|
|
28
|
+
return BytesFromUint8Array.decode(value);
|
|
21
29
|
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export type Bloom = typeof Bloom
|
|
25
|
-
|
|
26
|
-
export const TransactionStatus
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return enumMap[value] ?? "unknown";
|
|
39
|
-
},
|
|
40
|
-
encode(value) {
|
|
41
|
-
throw new Error("encode: not implemented");
|
|
42
|
-
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type Bloom = CodecType<typeof Bloom>;
|
|
33
|
+
|
|
34
|
+
export const TransactionStatus: Codec<
|
|
35
|
+
"unknown" | "succeeded" | "reverted",
|
|
36
|
+
proto.data.TransactionStatus
|
|
37
|
+
> = {
|
|
38
|
+
encode(x) {
|
|
39
|
+
const enumMap = {
|
|
40
|
+
unknown: proto.data.TransactionStatus.UNSPECIFIED,
|
|
41
|
+
succeeded: proto.data.TransactionStatus.SUCCEEDED,
|
|
42
|
+
reverted: proto.data.TransactionStatus.REVERTED,
|
|
43
|
+
} as const;
|
|
44
|
+
|
|
45
|
+
return enumMap[x] ?? proto.data.TransactionStatus.UNSPECIFIED;
|
|
43
46
|
},
|
|
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
|
-
|
|
47
|
+
decode(p) {
|
|
48
|
+
const enumMap = {
|
|
49
|
+
[proto.data.TransactionStatus.SUCCEEDED]: "succeeded",
|
|
50
|
+
[proto.data.TransactionStatus.REVERTED]: "reverted",
|
|
51
|
+
[proto.data.TransactionStatus.UNSPECIFIED]: "unknown",
|
|
52
|
+
[proto.data.TransactionStatus.UNRECOGNIZED]: "unknown",
|
|
53
|
+
} as const;
|
|
54
|
+
|
|
55
|
+
return enumMap[p] ?? "unknown";
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export type TransactionStatus = CodecType<typeof TransactionStatus>;
|
|
60
|
+
|
|
61
|
+
export const BlockHeader = MessageCodec({
|
|
62
|
+
blockNumber: RequiredCodec(BigIntCodec),
|
|
63
|
+
blockHash: RequiredCodec(B256),
|
|
64
|
+
parentBlockHash: RequiredCodec(B256),
|
|
65
|
+
unclesHash: RequiredCodec(B256),
|
|
66
|
+
miner: RequiredCodec(Address),
|
|
67
|
+
stateRoot: RequiredCodec(B256),
|
|
68
|
+
transactionsRoot: RequiredCodec(B256),
|
|
69
|
+
receiptsRoot: RequiredCodec(B256),
|
|
70
|
+
logsBloom: RequiredCodec(Bloom),
|
|
71
|
+
difficulty: RequiredCodec(U256),
|
|
72
|
+
gasLimit: RequiredCodec(U128),
|
|
73
|
+
gasUsed: RequiredCodec(U128),
|
|
74
|
+
timestamp: RequiredCodec(DateCodec),
|
|
75
|
+
extraData: RequiredCodec(BytesFromUint8Array),
|
|
76
|
+
mixHash: OptionalCodec(B256),
|
|
77
|
+
nonce: OptionalCodec(BigIntCodec),
|
|
78
|
+
baseFeePerGas: OptionalCodec(U128),
|
|
79
|
+
withdrawalsRoot: OptionalCodec(B256),
|
|
80
|
+
totalDifficulty: OptionalCodec(U256),
|
|
81
|
+
blobGasUsed: OptionalCodec(U128),
|
|
82
|
+
excessBlobGas: OptionalCodec(U128),
|
|
83
|
+
parentBeaconBlockRoot: OptionalCodec(B256),
|
|
84
|
+
requestsHash: OptionalCodec(B256),
|
|
72
85
|
});
|
|
73
86
|
|
|
74
|
-
export type BlockHeader = typeof BlockHeader
|
|
87
|
+
export type BlockHeader = CodecType<typeof BlockHeader>;
|
|
75
88
|
|
|
76
|
-
export const Withdrawal =
|
|
77
|
-
filterIds:
|
|
78
|
-
withdrawalIndex:
|
|
79
|
-
index:
|
|
80
|
-
validatorIndex:
|
|
81
|
-
address: Address,
|
|
82
|
-
amount:
|
|
89
|
+
export const Withdrawal = MessageCodec({
|
|
90
|
+
filterIds: ArrayCodec(NumberCodec),
|
|
91
|
+
withdrawalIndex: RequiredCodec(NumberCodec),
|
|
92
|
+
index: RequiredCodec(BigIntCodec),
|
|
93
|
+
validatorIndex: RequiredCodec(NumberCodec),
|
|
94
|
+
address: RequiredCodec(Address),
|
|
95
|
+
amount: RequiredCodec(BigIntCodec),
|
|
83
96
|
});
|
|
84
97
|
|
|
85
|
-
export type Withdrawal = typeof Withdrawal
|
|
98
|
+
export type Withdrawal = CodecType<typeof Withdrawal>;
|
|
86
99
|
|
|
87
|
-
export const AccessListItem =
|
|
88
|
-
address: Address,
|
|
89
|
-
storageKeys:
|
|
100
|
+
export const AccessListItem = MessageCodec({
|
|
101
|
+
address: RequiredCodec(Address),
|
|
102
|
+
storageKeys: ArrayCodec(B256),
|
|
90
103
|
});
|
|
91
104
|
|
|
92
|
-
export type AccessListItem = typeof AccessListItem
|
|
105
|
+
export type AccessListItem = CodecType<typeof AccessListItem>;
|
|
93
106
|
|
|
94
|
-
export const Signature =
|
|
95
|
-
r: U256,
|
|
96
|
-
s: U256,
|
|
97
|
-
v:
|
|
98
|
-
YParity:
|
|
107
|
+
export const Signature = MessageCodec({
|
|
108
|
+
r: RequiredCodec(U256),
|
|
109
|
+
s: RequiredCodec(U256),
|
|
110
|
+
v: OptionalCodec(U256),
|
|
111
|
+
YParity: OptionalCodec(BooleanCodec),
|
|
99
112
|
});
|
|
100
113
|
|
|
101
|
-
export type Signature = typeof Signature
|
|
102
|
-
|
|
103
|
-
export const Transaction =
|
|
104
|
-
filterIds:
|
|
105
|
-
transactionIndex:
|
|
106
|
-
transactionHash: B256,
|
|
107
|
-
nonce:
|
|
108
|
-
from: Address,
|
|
109
|
-
to:
|
|
110
|
-
value: U256,
|
|
111
|
-
gasPrice:
|
|
112
|
-
gas: U128,
|
|
113
|
-
maxFeePerGas:
|
|
114
|
-
maxPriorityFeePerGas:
|
|
115
|
-
input: BytesFromUint8Array,
|
|
116
|
-
signature:
|
|
117
|
-
chainId:
|
|
118
|
-
accessList:
|
|
119
|
-
transactionType:
|
|
120
|
-
maxFeePerBlobGas:
|
|
121
|
-
blobVersionedHashes:
|
|
122
|
-
transactionStatus: TransactionStatus,
|
|
114
|
+
export type Signature = CodecType<typeof Signature>;
|
|
115
|
+
|
|
116
|
+
export const Transaction = MessageCodec({
|
|
117
|
+
filterIds: ArrayCodec(NumberCodec),
|
|
118
|
+
transactionIndex: RequiredCodec(NumberCodec),
|
|
119
|
+
transactionHash: RequiredCodec(B256),
|
|
120
|
+
nonce: RequiredCodec(BigIntCodec),
|
|
121
|
+
from: RequiredCodec(Address),
|
|
122
|
+
to: OptionalCodec(Address),
|
|
123
|
+
value: RequiredCodec(U256),
|
|
124
|
+
gasPrice: OptionalCodec(U128),
|
|
125
|
+
gas: RequiredCodec(U128),
|
|
126
|
+
maxFeePerGas: OptionalCodec(U128),
|
|
127
|
+
maxPriorityFeePerGas: OptionalCodec(U128),
|
|
128
|
+
input: RequiredCodec(BytesFromUint8Array),
|
|
129
|
+
signature: OptionalCodec(Signature),
|
|
130
|
+
chainId: OptionalCodec(BigIntCodec),
|
|
131
|
+
accessList: ArrayCodec(AccessListItem),
|
|
132
|
+
transactionType: RequiredCodec(BigIntCodec),
|
|
133
|
+
maxFeePerBlobGas: OptionalCodec(U128),
|
|
134
|
+
blobVersionedHashes: ArrayCodec(B256),
|
|
135
|
+
transactionStatus: RequiredCodec(TransactionStatus),
|
|
123
136
|
});
|
|
124
137
|
|
|
125
|
-
export type Transaction = typeof Transaction
|
|
126
|
-
|
|
127
|
-
export const TransactionReceipt =
|
|
128
|
-
filterIds:
|
|
129
|
-
transactionIndex:
|
|
130
|
-
transactionHash: B256,
|
|
131
|
-
cumulativeGasUsed: U128,
|
|
132
|
-
gasUsed: U128,
|
|
133
|
-
effectiveGasPrice: U128,
|
|
134
|
-
from: Address,
|
|
135
|
-
to:
|
|
136
|
-
contractAddress:
|
|
137
|
-
logsBloom: Bloom,
|
|
138
|
-
transactionType:
|
|
139
|
-
blobGasUsed:
|
|
140
|
-
blobGasPrice:
|
|
141
|
-
transactionStatus: TransactionStatus,
|
|
138
|
+
export type Transaction = CodecType<typeof Transaction>;
|
|
139
|
+
|
|
140
|
+
export const TransactionReceipt = MessageCodec({
|
|
141
|
+
filterIds: ArrayCodec(NumberCodec),
|
|
142
|
+
transactionIndex: RequiredCodec(NumberCodec),
|
|
143
|
+
transactionHash: RequiredCodec(B256),
|
|
144
|
+
cumulativeGasUsed: RequiredCodec(U128),
|
|
145
|
+
gasUsed: RequiredCodec(U128),
|
|
146
|
+
effectiveGasPrice: RequiredCodec(U128),
|
|
147
|
+
from: RequiredCodec(Address),
|
|
148
|
+
to: OptionalCodec(Address),
|
|
149
|
+
contractAddress: OptionalCodec(Address),
|
|
150
|
+
logsBloom: RequiredCodec(Bloom),
|
|
151
|
+
transactionType: RequiredCodec(BigIntCodec),
|
|
152
|
+
blobGasUsed: OptionalCodec(U128),
|
|
153
|
+
blobGasPrice: OptionalCodec(U128),
|
|
154
|
+
transactionStatus: RequiredCodec(TransactionStatus),
|
|
142
155
|
});
|
|
143
156
|
|
|
144
|
-
export type TransactionReceipt = typeof TransactionReceipt
|
|
145
|
-
|
|
146
|
-
export const Log =
|
|
147
|
-
filterIds:
|
|
148
|
-
address: Address,
|
|
149
|
-
topics:
|
|
150
|
-
data: BytesFromUint8Array,
|
|
151
|
-
logIndex:
|
|
152
|
-
logIndexInTransaction:
|
|
153
|
-
transactionIndex:
|
|
154
|
-
transactionHash: B256,
|
|
155
|
-
transactionStatus: TransactionStatus,
|
|
157
|
+
export type TransactionReceipt = CodecType<typeof TransactionReceipt>;
|
|
158
|
+
|
|
159
|
+
export const Log = MessageCodec({
|
|
160
|
+
filterIds: ArrayCodec(NumberCodec),
|
|
161
|
+
address: RequiredCodec(Address),
|
|
162
|
+
topics: ArrayCodec(B256),
|
|
163
|
+
data: RequiredCodec(BytesFromUint8Array),
|
|
164
|
+
logIndex: RequiredCodec(NumberCodec),
|
|
165
|
+
logIndexInTransaction: RequiredCodec(NumberCodec),
|
|
166
|
+
transactionIndex: RequiredCodec(NumberCodec),
|
|
167
|
+
transactionHash: RequiredCodec(B256),
|
|
168
|
+
transactionStatus: RequiredCodec(TransactionStatus),
|
|
156
169
|
});
|
|
157
170
|
|
|
158
|
-
export type Log = typeof Log
|
|
159
|
-
|
|
160
|
-
export const CallType
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
[proto.data.CallType.CALL_CODE]: "callCode",
|
|
176
|
-
[proto.data.CallType.DELEGATE_CALL]: "delegateCall",
|
|
177
|
-
[proto.data.CallType.STATIC_CALL]: "staticCall",
|
|
178
|
-
[proto.data.CallType.AUTH_CALL]: "authCall",
|
|
179
|
-
[proto.data.CallType.UNSPECIFIED]: "unknown",
|
|
180
|
-
[proto.data.CallType.UNRECOGNIZED]: "unknown",
|
|
181
|
-
} as const;
|
|
182
|
-
|
|
183
|
-
return enumMap[value] ?? "unknown";
|
|
184
|
-
},
|
|
185
|
-
encode(value) {
|
|
186
|
-
throw new Error("encode: not implemented");
|
|
187
|
-
},
|
|
171
|
+
export type Log = CodecType<typeof Log>;
|
|
172
|
+
|
|
173
|
+
export const CallType: Codec<
|
|
174
|
+
"unknown" | "call" | "delegateCall" | "callCode" | "staticCall" | "authCall",
|
|
175
|
+
proto.data.CallType
|
|
176
|
+
> = {
|
|
177
|
+
encode(x) {
|
|
178
|
+
const enumMap = {
|
|
179
|
+
unknown: proto.data.CallType.UNSPECIFIED,
|
|
180
|
+
call: proto.data.CallType.CALL,
|
|
181
|
+
callCode: proto.data.CallType.CALL_CODE,
|
|
182
|
+
delegateCall: proto.data.CallType.DELEGATE_CALL,
|
|
183
|
+
staticCall: proto.data.CallType.STATIC_CALL,
|
|
184
|
+
authCall: proto.data.CallType.AUTH_CALL,
|
|
185
|
+
} as const;
|
|
186
|
+
|
|
187
|
+
return enumMap[x] ?? proto.data.CallType.UNSPECIFIED;
|
|
188
188
|
},
|
|
189
|
-
)
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
[proto.data.CreationMethod.EOF_CREATE]: "eofCreate",
|
|
202
|
-
[proto.data.CallType.UNSPECIFIED]: "unknown",
|
|
203
|
-
[proto.data.CallType.UNRECOGNIZED]: "unknown",
|
|
204
|
-
} as const;
|
|
205
|
-
|
|
206
|
-
return enumMap[value] ?? "unknown";
|
|
207
|
-
},
|
|
208
|
-
encode(value) {
|
|
209
|
-
throw new Error("encode: not implemented");
|
|
210
|
-
},
|
|
189
|
+
decode(p) {
|
|
190
|
+
const enumMap = {
|
|
191
|
+
[proto.data.CallType.CALL]: "call",
|
|
192
|
+
[proto.data.CallType.CALL_CODE]: "callCode",
|
|
193
|
+
[proto.data.CallType.DELEGATE_CALL]: "delegateCall",
|
|
194
|
+
[proto.data.CallType.STATIC_CALL]: "staticCall",
|
|
195
|
+
[proto.data.CallType.AUTH_CALL]: "authCall",
|
|
196
|
+
[proto.data.CallType.UNSPECIFIED]: "unknown",
|
|
197
|
+
[proto.data.CallType.UNRECOGNIZED]: "unknown",
|
|
198
|
+
} as const;
|
|
199
|
+
|
|
200
|
+
return enumMap[p] ?? "unknown";
|
|
211
201
|
},
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
export type
|
|
215
|
-
|
|
216
|
-
export const
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
export type CallType = CodecType<typeof CallType>;
|
|
205
|
+
|
|
206
|
+
export const CreationMethod: Codec<
|
|
207
|
+
"unknown" | "create" | "create2" | "eofCreate",
|
|
208
|
+
proto.data.CreationMethod
|
|
209
|
+
> = {
|
|
210
|
+
encode(x) {
|
|
211
|
+
const enumMap = {
|
|
212
|
+
unknown: proto.data.CreationMethod.UNSPECIFIED,
|
|
213
|
+
create: proto.data.CreationMethod.CREATE,
|
|
214
|
+
create2: proto.data.CreationMethod.CREATE2,
|
|
215
|
+
eofCreate: proto.data.CreationMethod.EOF_CREATE,
|
|
216
|
+
} as const;
|
|
217
|
+
|
|
218
|
+
return enumMap[x] ?? proto.data.CreationMethod.UNSPECIFIED;
|
|
219
|
+
},
|
|
220
|
+
decode(p) {
|
|
221
|
+
const enumMap = {
|
|
222
|
+
[proto.data.CreationMethod.CREATE]: "create",
|
|
223
|
+
[proto.data.CreationMethod.CREATE2]: "create2",
|
|
224
|
+
[proto.data.CreationMethod.EOF_CREATE]: "eofCreate",
|
|
225
|
+
[proto.data.CreationMethod.UNSPECIFIED]: "unknown",
|
|
226
|
+
[proto.data.CreationMethod.UNRECOGNIZED]: "unknown",
|
|
227
|
+
} as const;
|
|
228
|
+
|
|
229
|
+
return enumMap[p] ?? "unknown";
|
|
230
|
+
},
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
export type CreationMethod = CodecType<typeof CreationMethod>;
|
|
234
|
+
|
|
235
|
+
export const CallAction = MessageCodec({
|
|
236
|
+
fromAddress: RequiredCodec(Address),
|
|
237
|
+
type: RequiredCodec(CallType),
|
|
238
|
+
gas: RequiredCodec(BigIntCodec),
|
|
239
|
+
input: RequiredCodec(BytesFromUint8Array),
|
|
240
|
+
toAddress: RequiredCodec(Address),
|
|
241
|
+
value: RequiredCodec(U256),
|
|
226
242
|
});
|
|
227
243
|
|
|
228
|
-
export type CallAction = typeof CallAction
|
|
229
|
-
|
|
230
|
-
export const CreateAction =
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
value: U256,
|
|
237
|
-
creationMethod: CreationMethod,
|
|
238
|
-
}),
|
|
244
|
+
export type CallAction = CodecType<typeof CallAction>;
|
|
245
|
+
|
|
246
|
+
export const CreateAction = MessageCodec({
|
|
247
|
+
fromAddress: RequiredCodec(Address),
|
|
248
|
+
gas: RequiredCodec(BigIntCodec),
|
|
249
|
+
init: RequiredCodec(BytesFromUint8Array),
|
|
250
|
+
value: RequiredCodec(U256),
|
|
251
|
+
creationMethod: RequiredCodec(CreationMethod),
|
|
239
252
|
});
|
|
240
253
|
|
|
241
|
-
export type CreateAction = typeof CreateAction
|
|
254
|
+
export type CreateAction = CodecType<typeof CreateAction>;
|
|
242
255
|
|
|
243
|
-
export const SelfDestructAction =
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
balance: U256,
|
|
248
|
-
refundAddress: Address,
|
|
249
|
-
}),
|
|
256
|
+
export const SelfDestructAction = MessageCodec({
|
|
257
|
+
address: RequiredCodec(Address),
|
|
258
|
+
balance: RequiredCodec(U256),
|
|
259
|
+
refundAddress: RequiredCodec(Address),
|
|
250
260
|
});
|
|
251
261
|
|
|
252
|
-
export type SelfDestructAction = typeof SelfDestructAction
|
|
253
|
-
|
|
254
|
-
export const RewardType
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
262
|
+
export type SelfDestructAction = CodecType<typeof SelfDestructAction>;
|
|
263
|
+
|
|
264
|
+
export const RewardType: Codec<
|
|
265
|
+
"unknown" | "block" | "uncle",
|
|
266
|
+
proto.data.RewardType
|
|
267
|
+
> = {
|
|
268
|
+
encode(x) {
|
|
269
|
+
const enumMap = {
|
|
270
|
+
unknown: proto.data.RewardType.UNSPECIFIED,
|
|
271
|
+
block: proto.data.RewardType.BLOCK,
|
|
272
|
+
uncle: proto.data.RewardType.UNCLE,
|
|
273
|
+
} as const;
|
|
274
|
+
|
|
275
|
+
return enumMap[x] ?? proto.data.RewardType.UNSPECIFIED;
|
|
276
|
+
},
|
|
277
|
+
decode(p) {
|
|
278
|
+
const enumMap = {
|
|
279
|
+
[proto.data.RewardType.BLOCK]: "block",
|
|
280
|
+
[proto.data.RewardType.UNCLE]: "uncle",
|
|
281
|
+
[proto.data.RewardType.UNSPECIFIED]: "unknown",
|
|
282
|
+
[proto.data.RewardType.UNRECOGNIZED]: "unknown",
|
|
283
|
+
} as const;
|
|
284
|
+
|
|
285
|
+
return enumMap[p] ?? "unknown";
|
|
271
286
|
},
|
|
272
|
-
|
|
287
|
+
};
|
|
273
288
|
|
|
274
|
-
export type RewardType = typeof RewardType
|
|
289
|
+
export type RewardType = CodecType<typeof RewardType>;
|
|
275
290
|
|
|
276
|
-
export const RewardAction =
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
type: RewardType,
|
|
281
|
-
value: U256,
|
|
282
|
-
}),
|
|
291
|
+
export const RewardAction = MessageCodec({
|
|
292
|
+
author: RequiredCodec(Address),
|
|
293
|
+
type: RequiredCodec(RewardType),
|
|
294
|
+
value: RequiredCodec(U256),
|
|
283
295
|
});
|
|
284
296
|
|
|
285
|
-
export type RewardAction = typeof RewardAction
|
|
297
|
+
export type RewardAction = CodecType<typeof RewardAction>;
|
|
286
298
|
|
|
287
|
-
export const CallOutput =
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
gasUsed: Schema.BigIntFromSelf,
|
|
291
|
-
output: BytesFromUint8Array,
|
|
292
|
-
}),
|
|
299
|
+
export const CallOutput = MessageCodec({
|
|
300
|
+
gasUsed: RequiredCodec(BigIntCodec),
|
|
301
|
+
output: RequiredCodec(BytesFromUint8Array),
|
|
293
302
|
});
|
|
294
303
|
|
|
295
|
-
export type CallOutput = typeof CallOutput
|
|
304
|
+
export type CallOutput = CodecType<typeof CallOutput>;
|
|
296
305
|
|
|
297
|
-
export const CreateOutput =
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
code: BytesFromUint8Array,
|
|
302
|
-
gasUsed: Schema.BigIntFromSelf,
|
|
303
|
-
}),
|
|
306
|
+
export const CreateOutput = MessageCodec({
|
|
307
|
+
address: RequiredCodec(Address),
|
|
308
|
+
code: RequiredCodec(BytesFromUint8Array),
|
|
309
|
+
gasUsed: RequiredCodec(BigIntCodec),
|
|
304
310
|
});
|
|
305
311
|
|
|
306
|
-
export type CreateOutput = typeof CreateOutput
|
|
312
|
+
export type CreateOutput = CodecType<typeof CreateOutput>;
|
|
307
313
|
|
|
308
|
-
export const Trace =
|
|
309
|
-
action:
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
+
export const Trace = MessageCodec({
|
|
315
|
+
action: RequiredCodec(
|
|
316
|
+
OneOfCodec({
|
|
317
|
+
call: CallAction,
|
|
318
|
+
create: CreateAction,
|
|
319
|
+
selfDestruct: SelfDestructAction,
|
|
320
|
+
reward: RewardAction,
|
|
321
|
+
}),
|
|
314
322
|
),
|
|
315
|
-
error:
|
|
316
|
-
output:
|
|
317
|
-
|
|
318
|
-
|
|
323
|
+
error: OptionalCodec(StringCodec),
|
|
324
|
+
output: OptionalCodec(
|
|
325
|
+
OneOfCodec({
|
|
326
|
+
callOutput: CallOutput,
|
|
327
|
+
createOutput: CreateOutput,
|
|
328
|
+
}),
|
|
329
|
+
),
|
|
330
|
+
subtraces: RequiredCodec(NumberCodec),
|
|
331
|
+
traceAddress: ArrayCodec(NumberCodec),
|
|
319
332
|
});
|
|
320
333
|
|
|
321
|
-
export type Trace = typeof Trace
|
|
334
|
+
export type Trace = CodecType<typeof Trace>;
|
|
322
335
|
|
|
323
|
-
export const TransactionTrace =
|
|
324
|
-
filterIds:
|
|
325
|
-
transactionIndex:
|
|
326
|
-
transactionHash: B256,
|
|
327
|
-
traces:
|
|
336
|
+
export const TransactionTrace = MessageCodec({
|
|
337
|
+
filterIds: ArrayCodec(NumberCodec),
|
|
338
|
+
transactionIndex: RequiredCodec(NumberCodec),
|
|
339
|
+
transactionHash: RequiredCodec(B256),
|
|
340
|
+
traces: ArrayCodec(Trace),
|
|
328
341
|
});
|
|
329
342
|
|
|
330
|
-
export type TransactionTrace = typeof TransactionTrace
|
|
343
|
+
export type TransactionTrace = CodecType<typeof TransactionTrace>;
|
|
331
344
|
|
|
332
|
-
export const Block =
|
|
333
|
-
header: BlockHeader,
|
|
334
|
-
withdrawals:
|
|
335
|
-
transactions:
|
|
336
|
-
receipts:
|
|
337
|
-
logs:
|
|
338
|
-
traces:
|
|
345
|
+
export const Block = MessageCodec({
|
|
346
|
+
header: RequiredCodec(BlockHeader),
|
|
347
|
+
withdrawals: ArrayCodec(Withdrawal),
|
|
348
|
+
transactions: ArrayCodec(Transaction),
|
|
349
|
+
receipts: ArrayCodec(TransactionReceipt),
|
|
350
|
+
logs: ArrayCodec(Log),
|
|
351
|
+
traces: ArrayCodec(TransactionTrace),
|
|
339
352
|
});
|
|
340
353
|
|
|
341
|
-
export type Block = typeof Block
|
|
342
|
-
|
|
343
|
-
export const BlockFromBytes =
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}
|
|
352
|
-
return proto.data.Block.decode(value);
|
|
353
|
-
},
|
|
354
|
-
encode(value) {
|
|
355
|
-
if (value === null) {
|
|
356
|
-
return new Uint8Array();
|
|
357
|
-
}
|
|
358
|
-
return proto.data.Block.encode(value).finish();
|
|
359
|
-
},
|
|
354
|
+
export type Block = CodecType<typeof Block>;
|
|
355
|
+
|
|
356
|
+
export const BlockFromBytes: Codec<Block, Uint8Array> = {
|
|
357
|
+
encode(x) {
|
|
358
|
+
const block = Block.encode(x);
|
|
359
|
+
return proto.data.Block.encode(block).finish();
|
|
360
|
+
},
|
|
361
|
+
decode(p) {
|
|
362
|
+
const block = proto.data.Block.decode(p);
|
|
363
|
+
return Block.decode(block);
|
|
360
364
|
},
|
|
361
|
-
|
|
365
|
+
};
|