Skip to content

Commit

Permalink
Fix getTransactionStatus rpc response
Browse files Browse the repository at this point in the history
  • Loading branch information
weiihann committed Jan 13, 2025
1 parent 0fb6380 commit 2008a1b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rpc/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ func (h *Handler) MethodsV0_7() ([]jsonrpc.Method, string) { //nolint: funlen
{
Name: "starknet_getTransactionStatus",
Params: []jsonrpc.Parameter{{Name: "transaction_hash"}},
Handler: h.TransactionStatus,
Handler: h.TransactionStatusV0_7,
},
{
Name: "starknet_call",
Expand Down
18 changes: 18 additions & 0 deletions rpc/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,24 @@ func (h *Handler) TransactionStatus(ctx context.Context, hash felt.Felt) (*Trans
return nil, txErr
}

// In 0.7.0, the failure reason is not returned in the TransactionStatus response.
type TransactionStatusV0_7 struct {
Finality TxnStatus `json:"finality_status"`
Execution TxnExecutionStatus `json:"execution_status,omitempty"`
}

func (h *Handler) TransactionStatusV0_7(ctx context.Context, hash felt.Felt) (*TransactionStatusV0_7, *jsonrpc.Error) {
res, err := h.TransactionStatus(ctx, hash)
if err != nil {
return nil, err
}

Check warning on line 659 in rpc/transaction.go

View check run for this annotation

Codecov / codecov/patch

rpc/transaction.go#L655-L659

Added lines #L655 - L659 were not covered by tests

return &TransactionStatusV0_7{
Finality: res.Finality,
Execution: res.Execution,
}, nil

Check warning on line 664 in rpc/transaction.go

View check run for this annotation

Codecov / codecov/patch

rpc/transaction.go#L661-L664

Added lines #L661 - L664 were not covered by tests
}

func makeJSONErrorFromGatewayError(err error) *jsonrpc.Error {
gatewayErr, ok := err.(*gateway.Error)
if !ok {
Expand Down

0 comments on commit 2008a1b

Please sign in to comment.