@apibara/evm 2.1.0-beta.22 → 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 +403 -476
- package/dist/index.d.cts +1073 -2035
- package/dist/index.d.mts +1073 -2035
- package/dist/index.d.ts +1073 -2035
- package/dist/index.mjs +405 -467
- package/package.json +2 -4
- package/src/block.ts +312 -307
- package/src/common.ts +64 -101
- package/src/filter.ts +128 -138
- package/src/proto/data.ts +26 -1
- 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,360 +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
|
-
|
|
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),
|
|
71
85
|
});
|
|
72
86
|
|
|
73
|
-
export type BlockHeader = typeof BlockHeader
|
|
87
|
+
export type BlockHeader = CodecType<typeof BlockHeader>;
|
|
74
88
|
|
|
75
|
-
export const Withdrawal =
|
|
76
|
-
filterIds:
|
|
77
|
-
withdrawalIndex:
|
|
78
|
-
index:
|
|
79
|
-
validatorIndex:
|
|
80
|
-
address: Address,
|
|
81
|
-
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),
|
|
82
96
|
});
|
|
83
97
|
|
|
84
|
-
export type Withdrawal = typeof Withdrawal
|
|
98
|
+
export type Withdrawal = CodecType<typeof Withdrawal>;
|
|
85
99
|
|
|
86
|
-
export const AccessListItem =
|
|
87
|
-
address: Address,
|
|
88
|
-
storageKeys:
|
|
100
|
+
export const AccessListItem = MessageCodec({
|
|
101
|
+
address: RequiredCodec(Address),
|
|
102
|
+
storageKeys: ArrayCodec(B256),
|
|
89
103
|
});
|
|
90
104
|
|
|
91
|
-
export type AccessListItem = typeof AccessListItem
|
|
105
|
+
export type AccessListItem = CodecType<typeof AccessListItem>;
|
|
92
106
|
|
|
93
|
-
export const Signature =
|
|
94
|
-
r: U256,
|
|
95
|
-
s: U256,
|
|
96
|
-
v: U256,
|
|
97
|
-
YParity:
|
|
107
|
+
export const Signature = MessageCodec({
|
|
108
|
+
r: RequiredCodec(U256),
|
|
109
|
+
s: RequiredCodec(U256),
|
|
110
|
+
v: OptionalCodec(U256),
|
|
111
|
+
YParity: OptionalCodec(BooleanCodec),
|
|
98
112
|
});
|
|
99
113
|
|
|
100
|
-
export type Signature = typeof Signature
|
|
101
|
-
|
|
102
|
-
export const Transaction =
|
|
103
|
-
filterIds:
|
|
104
|
-
transactionIndex:
|
|
105
|
-
transactionHash: B256,
|
|
106
|
-
nonce:
|
|
107
|
-
from: Address,
|
|
108
|
-
to:
|
|
109
|
-
value: U256,
|
|
110
|
-
gasPrice:
|
|
111
|
-
gas: U128,
|
|
112
|
-
maxFeePerGas:
|
|
113
|
-
maxPriorityFeePerGas:
|
|
114
|
-
input: BytesFromUint8Array,
|
|
115
|
-
signature:
|
|
116
|
-
chainId:
|
|
117
|
-
accessList:
|
|
118
|
-
transactionType:
|
|
119
|
-
maxFeePerBlobGas:
|
|
120
|
-
blobVersionedHashes:
|
|
121
|
-
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),
|
|
122
136
|
});
|
|
123
137
|
|
|
124
|
-
export type Transaction = typeof Transaction
|
|
125
|
-
|
|
126
|
-
export const TransactionReceipt =
|
|
127
|
-
filterIds:
|
|
128
|
-
transactionIndex:
|
|
129
|
-
transactionHash: B256,
|
|
130
|
-
cumulativeGasUsed: U128,
|
|
131
|
-
gasUsed: U128,
|
|
132
|
-
effectiveGasPrice: U128,
|
|
133
|
-
from: Address,
|
|
134
|
-
to:
|
|
135
|
-
contractAddress:
|
|
136
|
-
logsBloom: Bloom,
|
|
137
|
-
transactionType:
|
|
138
|
-
blobGasUsed:
|
|
139
|
-
blobGasPrice:
|
|
140
|
-
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),
|
|
141
155
|
});
|
|
142
156
|
|
|
143
|
-
export type TransactionReceipt = typeof TransactionReceipt
|
|
144
|
-
|
|
145
|
-
export const Log =
|
|
146
|
-
filterIds:
|
|
147
|
-
address: Address,
|
|
148
|
-
topics:
|
|
149
|
-
data: BytesFromUint8Array,
|
|
150
|
-
logIndex:
|
|
151
|
-
logIndexInTransaction:
|
|
152
|
-
transactionIndex:
|
|
153
|
-
transactionHash: B256,
|
|
154
|
-
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),
|
|
155
169
|
});
|
|
156
170
|
|
|
157
|
-
export type Log = typeof Log
|
|
158
|
-
|
|
159
|
-
export const CallType
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
[proto.data.CallType.CALL_CODE]: "callCode",
|
|
175
|
-
[proto.data.CallType.DELEGATE_CALL]: "delegateCall",
|
|
176
|
-
[proto.data.CallType.STATIC_CALL]: "staticCall",
|
|
177
|
-
[proto.data.CallType.AUTH_CALL]: "authCall",
|
|
178
|
-
[proto.data.CallType.UNSPECIFIED]: "unknown",
|
|
179
|
-
[proto.data.CallType.UNRECOGNIZED]: "unknown",
|
|
180
|
-
} as const;
|
|
181
|
-
|
|
182
|
-
return enumMap[value] ?? "unknown";
|
|
183
|
-
},
|
|
184
|
-
encode(value) {
|
|
185
|
-
throw new Error("encode: not implemented");
|
|
186
|
-
},
|
|
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;
|
|
187
188
|
},
|
|
188
|
-
)
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
[proto.data.CreationMethod.EOF_CREATE]: "eofCreate",
|
|
201
|
-
[proto.data.CallType.UNSPECIFIED]: "unknown",
|
|
202
|
-
[proto.data.CallType.UNRECOGNIZED]: "unknown",
|
|
203
|
-
} as const;
|
|
204
|
-
|
|
205
|
-
return enumMap[value] ?? "unknown";
|
|
206
|
-
},
|
|
207
|
-
encode(value) {
|
|
208
|
-
throw new Error("encode: not implemented");
|
|
209
|
-
},
|
|
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";
|
|
210
201
|
},
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
export type
|
|
214
|
-
|
|
215
|
-
export const
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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),
|
|
225
242
|
});
|
|
226
243
|
|
|
227
|
-
export type CallAction = typeof CallAction
|
|
228
|
-
|
|
229
|
-
export const CreateAction =
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
value: U256,
|
|
236
|
-
creationMethod: CreationMethod,
|
|
237
|
-
}),
|
|
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),
|
|
238
252
|
});
|
|
239
253
|
|
|
240
|
-
export type CreateAction = typeof CreateAction
|
|
254
|
+
export type CreateAction = CodecType<typeof CreateAction>;
|
|
241
255
|
|
|
242
|
-
export const SelfDestructAction =
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
balance: U256,
|
|
247
|
-
refundAddress: Address,
|
|
248
|
-
}),
|
|
256
|
+
export const SelfDestructAction = MessageCodec({
|
|
257
|
+
address: RequiredCodec(Address),
|
|
258
|
+
balance: RequiredCodec(U256),
|
|
259
|
+
refundAddress: RequiredCodec(Address),
|
|
249
260
|
});
|
|
250
261
|
|
|
251
|
-
export type SelfDestructAction = typeof SelfDestructAction
|
|
252
|
-
|
|
253
|
-
export const RewardType
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
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";
|
|
270
286
|
},
|
|
271
|
-
|
|
287
|
+
};
|
|
272
288
|
|
|
273
|
-
export type RewardType = typeof RewardType
|
|
289
|
+
export type RewardType = CodecType<typeof RewardType>;
|
|
274
290
|
|
|
275
|
-
export const RewardAction =
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
type: RewardType,
|
|
280
|
-
value: U256,
|
|
281
|
-
}),
|
|
291
|
+
export const RewardAction = MessageCodec({
|
|
292
|
+
author: RequiredCodec(Address),
|
|
293
|
+
type: RequiredCodec(RewardType),
|
|
294
|
+
value: RequiredCodec(U256),
|
|
282
295
|
});
|
|
283
296
|
|
|
284
|
-
export type RewardAction = typeof RewardAction
|
|
297
|
+
export type RewardAction = CodecType<typeof RewardAction>;
|
|
285
298
|
|
|
286
|
-
export const CallOutput =
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
gasUsed: Schema.BigIntFromSelf,
|
|
290
|
-
output: BytesFromUint8Array,
|
|
291
|
-
}),
|
|
299
|
+
export const CallOutput = MessageCodec({
|
|
300
|
+
gasUsed: RequiredCodec(BigIntCodec),
|
|
301
|
+
output: RequiredCodec(BytesFromUint8Array),
|
|
292
302
|
});
|
|
293
303
|
|
|
294
|
-
export type CallOutput = typeof CallOutput
|
|
304
|
+
export type CallOutput = CodecType<typeof CallOutput>;
|
|
295
305
|
|
|
296
|
-
export const CreateOutput =
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
code: BytesFromUint8Array,
|
|
301
|
-
gasUsed: Schema.BigIntFromSelf,
|
|
302
|
-
}),
|
|
306
|
+
export const CreateOutput = MessageCodec({
|
|
307
|
+
address: RequiredCodec(Address),
|
|
308
|
+
code: RequiredCodec(BytesFromUint8Array),
|
|
309
|
+
gasUsed: RequiredCodec(BigIntCodec),
|
|
303
310
|
});
|
|
304
311
|
|
|
305
|
-
export type CreateOutput = typeof CreateOutput
|
|
312
|
+
export type CreateOutput = CodecType<typeof CreateOutput>;
|
|
306
313
|
|
|
307
|
-
export const Trace =
|
|
308
|
-
action:
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
314
|
+
export const Trace = MessageCodec({
|
|
315
|
+
action: RequiredCodec(
|
|
316
|
+
OneOfCodec({
|
|
317
|
+
call: CallAction,
|
|
318
|
+
create: CreateAction,
|
|
319
|
+
selfDestruct: SelfDestructAction,
|
|
320
|
+
reward: RewardAction,
|
|
321
|
+
}),
|
|
313
322
|
),
|
|
314
|
-
error:
|
|
315
|
-
output:
|
|
316
|
-
|
|
317
|
-
|
|
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),
|
|
318
332
|
});
|
|
319
333
|
|
|
320
|
-
export type Trace = typeof Trace
|
|
334
|
+
export type Trace = CodecType<typeof Trace>;
|
|
321
335
|
|
|
322
|
-
export const TransactionTrace =
|
|
323
|
-
filterIds:
|
|
324
|
-
transactionIndex:
|
|
325
|
-
transactionHash: B256,
|
|
326
|
-
traces:
|
|
336
|
+
export const TransactionTrace = MessageCodec({
|
|
337
|
+
filterIds: ArrayCodec(NumberCodec),
|
|
338
|
+
transactionIndex: RequiredCodec(NumberCodec),
|
|
339
|
+
transactionHash: RequiredCodec(B256),
|
|
340
|
+
traces: ArrayCodec(Trace),
|
|
327
341
|
});
|
|
328
342
|
|
|
329
|
-
export type TransactionTrace = typeof TransactionTrace
|
|
343
|
+
export type TransactionTrace = CodecType<typeof TransactionTrace>;
|
|
330
344
|
|
|
331
|
-
export const Block =
|
|
332
|
-
header: BlockHeader,
|
|
333
|
-
withdrawals:
|
|
334
|
-
transactions:
|
|
335
|
-
receipts:
|
|
336
|
-
logs:
|
|
337
|
-
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),
|
|
338
352
|
});
|
|
339
353
|
|
|
340
|
-
export type Block = typeof Block
|
|
341
|
-
|
|
342
|
-
export const BlockFromBytes =
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
return proto.data.Block.decode(value);
|
|
352
|
-
},
|
|
353
|
-
encode(value) {
|
|
354
|
-
if (value === null) {
|
|
355
|
-
return new Uint8Array();
|
|
356
|
-
}
|
|
357
|
-
return proto.data.Block.encode(value).finish();
|
|
358
|
-
},
|
|
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);
|
|
359
364
|
},
|
|
360
|
-
|
|
365
|
+
};
|