Skip to content

Commit

Permalink
rpcv06 update receipts
Browse files Browse the repository at this point in the history
  • Loading branch information
rianhughes committed Nov 10, 2023
1 parent 96944d9 commit f0f71fa
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 28 deletions.
16 changes: 10 additions & 6 deletions rpc/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ func TestTransactionByHash(t *testing.T) {
// Parameters:
// - t: the testing object for running the test cases
// Returns:
// none
//
// none
func TestTransactionByBlockIdAndIndex(t *testing.T) {
testConfig := beforeEach(t)

Expand Down Expand Up @@ -169,7 +170,8 @@ func TestTransactionByBlockIdAndIndex(t *testing.T) {
// Parameters:
// - t: the testing object for running the test cases
// Returns:
// none
//
// none
func TestTransactionReceipt_MatchesCapturedTransaction(t *testing.T) {
testConfig := beforeEach(t)

Expand All @@ -179,7 +181,7 @@ func TestTransactionReceipt_MatchesCapturedTransaction(t *testing.T) {
}
var receiptTxn310370_0 = InvokeTransactionReceipt(CommonTransactionReceipt{
TransactionHash: utils.TestHexToFelt(t, "0x40c82f79dd2bc1953fc9b347a3e7ab40fe218ed5740bf4e120f74e8a3c9ac99"),
ActualFee: utils.TestHexToFelt(t, "0x1709a2f3a2"),
ActualFee: FeePayment{Amount: utils.TestHexToFelt(t, "0x1709a2f3a2")},
Type: "INVOKE",
ExecutionStatus: TxnExecutionStatusSUCCEEDED,
FinalityStatus: TxnFinalityStatusAcceptedOnL1,
Expand Down Expand Up @@ -252,7 +254,8 @@ func TestTransactionReceipt_MatchesCapturedTransaction(t *testing.T) {
// Parameters:
// - t: the testing object for running the test cases
// Returns:
// none
//
// none
func TestTransactionReceipt_MatchesStatus(t *testing.T) {
testConfig := beforeEach(t)

Expand Down Expand Up @@ -302,7 +305,8 @@ func TestTransactionReceipt_MatchesStatus(t *testing.T) {
// Parameters:
// - t: the testing object for running the test cases
// Returns:
// none
//
// none
func TestDeployOrDeclareReceipt(t *testing.T) {
testConfig := beforeEach(t)

Expand All @@ -314,7 +318,7 @@ func TestDeployOrDeclareReceipt(t *testing.T) {
var receiptTxn300114_3 = DeclareTransactionReceipt(
CommonTransactionReceipt{
TransactionHash: utils.TestHexToFelt(t, "0x46a9f52a96b2d226407929e04cb02507e531f7c78b9196fc8c910351d8c33f3"),
ActualFee: utils.TestHexToFelt(t, "0x0"),
ActualFee: FeePayment{Amount: utils.TestHexToFelt(t, "0x0")},
FinalityStatus: TxnFinalityStatusAcceptedOnL1,
ExecutionStatus: TxnExecutionStatusSUCCEEDED,
BlockHash: utils.TestHexToFelt(t, "0x184268bfbce24766fa53b65c9c8b30b295e145e8281d543a015b46308e27fdf"),
Expand Down
96 changes: 74 additions & 22 deletions rpc/types_transaction_receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,24 @@ import (
"github.com/NethermindEth/juno/core/felt"
)

type FeePayment struct {
Amount *felt.Felt `json:"amount"`
Unit FeePaymentUnit `json:"unit"`
}

type FeePaymentUnit string

const (
_ FeePaymentUnit = "WEI"
_ FeePaymentUnit = "STRK"
)

// CommonTransactionReceipt Common properties for a transaction receipt
type CommonTransactionReceipt struct {
// TransactionHash The hash identifying the transaction
TransactionHash *felt.Felt `json:"transaction_hash"`
// ActualFee The fee that was charged by the sequencer
ActualFee *felt.Felt `json:"actual_fee"`
ActualFee FeePayment `json:"actual_fee"`
ExecutionStatus TxnExecutionStatus `json:"execution_status"`
FinalityStatus TxnFinalityStatus `json:"finality_status"`
BlockHash *felt.Felt `json:"block_hash"`
Expand All @@ -28,7 +40,9 @@ type CommonTransactionReceipt struct {
// Hash returns the transaction hash associated with the CommonTransactionReceipt.
//
// Parameters:
// none
//
// none
//
// Returns:
// - *felt.Felt: the transaction hash
func (tr CommonTransactionReceipt) Hash() *felt.Felt {
Expand All @@ -38,7 +52,9 @@ func (tr CommonTransactionReceipt) Hash() *felt.Felt {
// GetExecutionStatus returns the execution status of the CommonTransactionReceipt.
//
// Parameters:
// none
//
// none
//
// Returns:
// - TxnExecutionStatus: the execution status
func (tr CommonTransactionReceipt) GetExecutionStatus() TxnExecutionStatus {
Expand All @@ -65,8 +81,10 @@ const (
// - "DEPLOY" maps to TransactionType_Deploy
// - "INVOKE" maps to TransactionType_Invoke
// - "L1_HANDLER" maps to TransactionType_L1Handler
//
// If none of the supported values match the input data, the function returns an error.
// nil if the unmarshaling is successful.
//
// nil if the unmarshaling is successful.
//
// Parameters:
// - data: It takes a byte slice as input representing the JSON data to be unmarshaled
Expand Down Expand Up @@ -99,7 +117,9 @@ func (tt *TransactionType) UnmarshalJSON(data []byte) error {
// MarshalJSON marshals the TransactionType to JSON.
//
// Parameters:
// none
//
// none
//
// Returns:
// - []byte: a byte slice
// - error: an error if any
Expand All @@ -113,7 +133,9 @@ type InvokeTransactionReceipt CommonTransactionReceipt
// Hash returns the hash of the invoke transaction receipt.
//
// Parameters:
// none
//
// none
//
// Returns:
// - *felt.Felt: the transaction hash
func (tr InvokeTransactionReceipt) Hash() *felt.Felt {
Expand All @@ -123,7 +145,9 @@ func (tr InvokeTransactionReceipt) Hash() *felt.Felt {
// GetExecutionStatus returns the execution status of the InvokeTransactionReceipt.
//
// Parameters:
// none
//
// none
//
// Returns:
// - TxnExecutionStatus: the execution status
func (tr InvokeTransactionReceipt) GetExecutionStatus() TxnExecutionStatus {
Expand All @@ -136,7 +160,9 @@ type DeclareTransactionReceipt CommonTransactionReceipt
// Hash returns the transaction hash.
//
// Parameters:
// none
//
// none
//
// Returns:
// - *felt.Felt: the transaction hash
func (tr DeclareTransactionReceipt) Hash() *felt.Felt {
Expand All @@ -146,7 +172,9 @@ func (tr DeclareTransactionReceipt) Hash() *felt.Felt {
// GetExecutionStatus returns the execution status of the DeclareTransactionReceipt function.
//
// Parameters:
// none
//
// none
//
// Returns:
// - TxnExecutionStatus: the execution status
func (tr DeclareTransactionReceipt) GetExecutionStatus() TxnExecutionStatus {
Expand All @@ -163,7 +191,9 @@ type DeployTransactionReceipt struct {
// Hash returns the transaction hash of the DeployTransactionReceipt.
//
// Parameters:
// none
//
// none
//
// Returns:
// - *felt.Felt: the transaction hash
func (tr DeployTransactionReceipt) Hash() *felt.Felt {
Expand All @@ -173,7 +203,9 @@ func (tr DeployTransactionReceipt) Hash() *felt.Felt {
// GetExecutionStatus returns the execution status of the DeployTransactionReceipt.
//
// Parameters:
// none
//
// none
//
// Returns:
// - TxnExecutionStatus: the execution status
func (tr DeployTransactionReceipt) GetExecutionStatus() TxnExecutionStatus {
Expand All @@ -190,7 +222,9 @@ type DeployAccountTransactionReceipt struct {
// Hash returns the transaction hash for the given DeployAccountTransactionReceipt.
//
// Parameters:
// none
//
// none
//
// Returns:
// - *felt.Felt: the transaction hash
func (tr DeployAccountTransactionReceipt) Hash() *felt.Felt {
Expand All @@ -200,7 +234,9 @@ func (tr DeployAccountTransactionReceipt) Hash() *felt.Felt {
// GetExecutionStatus returns the execution status of the DeployAccountTransactionReceipt.
//
// Parameters:
// none
//
// none
//
// Returns:
// - *TxnExecutionStatus: the execution status
func (tr DeployAccountTransactionReceipt) GetExecutionStatus() TxnExecutionStatus {
Expand All @@ -213,7 +249,9 @@ type L1HandlerTransactionReceipt CommonTransactionReceipt
// Hash returns the transaction hash.
//
// Parameters:
// none
//
// none
//
// Returns:
// - *felt.Felt: the transaction hash
func (tr L1HandlerTransactionReceipt) Hash() *felt.Felt {
Expand All @@ -223,7 +261,9 @@ func (tr L1HandlerTransactionReceipt) Hash() *felt.Felt {
// GetExecutionStatus returns the execution status of the L1HandlerTransactionReceipt.
//
// Parameters:
// none
//
// none
//
// Returns:
// - TxnExecutionStatus: the execution status
func (tr L1HandlerTransactionReceipt) GetExecutionStatus() TxnExecutionStatus {
Expand Down Expand Up @@ -268,7 +308,9 @@ type PendingDeployAccountTransactionReceipt struct {
// Hash returns the transaction hash of the pending deploy transaction receipt.
//
// Parameters:
// none
//
// none
//
// Returns:
// - *felt.Felt: the transaction hash
func (tr PendingDeployAccountTransactionReceipt) Hash() *felt.Felt {
Expand All @@ -278,7 +320,9 @@ func (tr PendingDeployAccountTransactionReceipt) Hash() *felt.Felt {
// GetExecutionStatus returns the execution status of the pending deploy transaction receipt.
//
// Parameters:
// none
//
// none
//
// Returns:
// - TxnExecutionStatus: the execution status
func (tr PendingDeployAccountTransactionReceipt) GetExecutionStatus() TxnExecutionStatus {
Expand All @@ -293,7 +337,9 @@ type PendingInvokeTransactionReceipt struct {
// Hash returns the transaction hash of the pending deploy transaction receipt.
//
// Parameters:
// none
//
// none
//
// Returns:
// - *felt.Felt: the transaction hash
func (tr PendingInvokeTransactionReceipt) Hash() *felt.Felt {
Expand All @@ -303,7 +349,9 @@ func (tr PendingInvokeTransactionReceipt) Hash() *felt.Felt {
// GetExecutionStatus returns the execution status of the pending deploy transaction receipt.
//
// Parameters:
// none
//
// none
//
// Returns:
// - TxnExecutionStatus: the execution status
func (tr PendingInvokeTransactionReceipt) GetExecutionStatus() TxnExecutionStatus {
Expand All @@ -314,7 +362,7 @@ type PendingCommonTransactionReceiptProperties struct {
// TransactionHash The hash identifying the transaction
TransactionHash *felt.Felt `json:"transaction_hash"`
// ActualFee The fee that was charged by the sequencer
ActualFee *felt.Felt `json:"actual_fee"`
ActualFee FeePayment `json:"actual_fee"`
Type TransactionType `json:"type,omitempty"`
MessagesSent []MsgToL1 `json:"messages_sent"`
ExecutionStatus TxnExecutionStatus `json:"execution_status"`
Expand Down Expand Up @@ -349,7 +397,9 @@ type ExecutionResources struct {
// Hash returns the transaction hash of the PendingCommonTransactionReceiptProperties.
//
// Parameters:
// none
//
// none
//
// Returns:
// - *felt.Felt: the transaction hash
func (tr PendingCommonTransactionReceiptProperties) Hash() *felt.Felt {
Expand All @@ -359,7 +409,9 @@ func (tr PendingCommonTransactionReceiptProperties) Hash() *felt.Felt {
// GetExecutionStatus returns the execution status of the pending common transaction receipt properties.
//
// Parameters:
// none
//
// none
//
// Returns:
// - TxnExecutionStatus: the execution status
func (tr PendingCommonTransactionReceiptProperties) GetExecutionStatus() TxnExecutionStatus {
Expand Down

0 comments on commit f0f71fa

Please sign in to comment.