Skip to content

Commit

Permalink
Update protocol with index in transaction fields (#136)
Browse files Browse the repository at this point in the history
This PR adds the `{event,message,log}IndexInTransaction` fields to track
the index inside a transaction.
  • Loading branch information
fracek authored Jan 18, 2025
2 parents 9ef9de3 + 666e5c9 commit 207bd64
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 3 deletions.
7 changes: 7 additions & 0 deletions change/@apibara-evm-f1bb6555-a641-4402-82e4-692be980ad21.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "starknet: add event and message index in transaction",
"packageName": "@apibara/evm",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "evm: add log index in transaction field",
"packageName": "@apibara/starknet",
"email": "[email protected]",
"dependentChangeType": "patch"
}
2 changes: 2 additions & 0 deletions packages/evm/proto/data.proto
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ message Log {
B256 transaction_hash = 7;
// The transaction status.
TransactionStatus transaction_status = 8;
// Index of the log in the transaction.
uint32 log_index_in_transaction = 9;
}

message Signature {
Expand Down
1 change: 1 addition & 0 deletions packages/evm/src/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export const Log = Schema.Struct({
topics: Schema.Array(B256),
data: BytesFromUint8Array,
logIndex: Schema.Number,
logIndexInTransaction: Schema.Number,
transactionIndex: Schema.Number,
transactionHash: Schema.optional(B256),
transactionStatus: Schema.optional(TransactionStatus),
Expand Down
22 changes: 21 additions & 1 deletion packages/evm/src/proto/data.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/starknet/proto/data.proto
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ message Event {
FieldElement transaction_hash = 7;
// Transaction status.
TransactionStatus transaction_status = 8;
// Event index in the transaction.
uint32 event_index_in_transaction = 9;
}

message MessageToL1 {
Expand All @@ -275,6 +277,8 @@ message MessageToL1 {
FieldElement transaction_hash = 7;
// Transaction status.
TransactionStatus transaction_status = 8;
// Message index in the transaction.
uint32 message_index_in_transaction = 9;
}

enum L1DataAvailabilityMode {
Expand Down
4 changes: 4 additions & 0 deletions packages/starknet/src/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ export type TransactionReceipt = typeof TransactionReceipt.Type;
* @prop transactionIndex The transaction index in the block.
* @prop transactionHash The transaction hash.
* @prop transactionStatus The transaction status.
* @prop eventIndexInTransaction The event index in the transaction.
*/
export const Event = Schema.Struct({
filterIds: Schema.optional(Schema.Array(Schema.Number)),
Expand All @@ -452,6 +453,7 @@ export const Event = Schema.Struct({
transactionIndex: Schema.optional(Schema.Number),
transactionHash: Schema.optional(FieldElement),
transactionStatus: Schema.optional(TransactionStatus),
eventIndexInTransaction: Schema.optional(Schema.Number),
});

export type Event = typeof Event.Type;
Expand All @@ -465,6 +467,7 @@ export type Event = typeof Event.Type;
* @prop transactionIndex The transaction index in the block.
* @prop transactionHash The transaction hash.
* @prop transactionStatus The transaction status.
* @prop messageIndexInTransaction The message index in the transaction.
*/
export const MessageToL1 = Schema.Struct({
filterIds: Schema.optional(Schema.Array(Schema.Number)),
Expand All @@ -475,6 +478,7 @@ export const MessageToL1 = Schema.Struct({
transactionIndex: Schema.optional(Schema.Number),
transactionHash: Schema.optional(FieldElement),
transactionStatus: Schema.optional(TransactionStatus),
messageIndexInTransaction: Schema.optional(Schema.Number),
});

export type MessageToL1 = typeof MessageToL1.Type;
Expand Down
48 changes: 46 additions & 2 deletions packages/starknet/src/proto/data.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 207bd64

Please sign in to comment.