Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds GetMessagesStatus method #634

Merged
merged 3 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions mocks/mock_rpc_provider.go

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

3 changes: 2 additions & 1 deletion rpc/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type RpcProvider interface {
BlockHashAndNumber(ctx context.Context) (*BlockHashAndNumberOutput, error)
BlockNumber(ctx context.Context) (uint64, error)
BlockTransactionCount(ctx context.Context, blockID BlockID) (uint64, error)
BlockWithReceipts(ctx context.Context, blockID BlockID) (interface{}, error)
BlockWithTxHashes(ctx context.Context, blockID BlockID) (interface{}, error)
BlockWithTxs(ctx context.Context, blockID BlockID) (interface{}, error)
Call(ctx context.Context, call FunctionCall, block BlockID) ([]*felt.Felt, error)
Expand All @@ -58,9 +59,9 @@ type RpcProvider interface {
EstimateFee(ctx context.Context, requests []BroadcastTxn, simulationFlags []SimulationFlag, blockID BlockID) ([]FeeEstimation, error)
EstimateMessageFee(ctx context.Context, msg MsgFromL1, blockID BlockID) (*FeeEstimation, error)
Events(ctx context.Context, input EventsInput) (*EventChunk, error)
BlockWithReceipts(ctx context.Context, blockID BlockID) (interface{}, error)
GetStorageProof(ctx context.Context, storageProofInput StorageProofInput) (*StorageProofResult, error)
GetTransactionStatus(ctx context.Context, transactionHash *felt.Felt) (*TxnStatusResp, error)
GetMessagesStatus(ctx context.Context, transactionHash NumAsHex) ([]MessageStatusResp, error)
Nonce(ctx context.Context, blockID BlockID, contractAddress *felt.Felt) (*felt.Felt, error)
SimulateTransactions(ctx context.Context, blockID BlockID, txns []BroadcastTxn, simulationFlags []SimulationFlag) ([]SimulatedTransaction, error)
StateUpdate(ctx context.Context, blockID BlockID) (*StateUpdateOutput, error)
Expand Down
17 changes: 17 additions & 0 deletions rpc/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,20 @@ func (provider *Provider) GetTransactionStatus(ctx context.Context, transactionH
}
return &receipt, nil
}

// Given an L1 tx hash, returns the associated l1_handler tx hashes and statuses for all L1 -> L2 messages sent by the l1 transaction, ordered by the L1 tx sending order
//
// Parameters:
// - ctx: the context.Context object for cancellation and timeouts.
// - transactionHash: The hash of the L1 transaction that sent L1->L2 messages
// Returns:
// - [] MessageStatusResp: An array containing the status of the messages sent by the L1 transaction
// - error, if one arose.
func (provider *Provider) GetMessagesStatus(ctx context.Context, transactionHash NumAsHex) ([]MessageStatusResp, error) {
thiagodeev marked this conversation as resolved.
Show resolved Hide resolved
var response []MessageStatusResp
err := do(ctx, provider.c, "starknet_getMessagesStatus", &response, transactionHash)
if err != nil {
return nil, tryUnwrapToRPCErr(err, ErrHashNotFound)
}
return response, nil
}
4 changes: 4 additions & 0 deletions rpc/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,7 @@ func TestGetTransactionStatus(t *testing.T) {
require.Equal(t, *resp, test.ExpectedResp)
}
}

func TestGetMessagesStatus(t *testing.T) {
t.Skip("TODO: create a test before merge")
}
9 changes: 9 additions & 0 deletions rpc/types_transaction_receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ type MsgFromL1 struct {
Payload []*felt.Felt `json:"payload"`
}

type MessageStatusResp struct {
// The hash of a L1 handler transaction
TransactionHash *felt.Felt `json:"transaction_hash"`
// The finality status of the transaction, including the case the txn is still in the mempool or failed validation during the block construction phase
FinalityStatus TxnStatus `json:"finality_status"`
// The failure reason, only appears if finality_status is REJECTED
FailureReason string `json:"failure_reason,omitempty"`
}

type OrderedMsg struct {
// The order of the message within the transaction
Order int `json:"order"`
Expand Down
Loading