Skip to content

Commit

Permalink
rpc05 Update pending types (#424)
Browse files Browse the repository at this point in the history
Co-authored-by: Carmen Irene Cabrera Rodríguez <[email protected]>
  • Loading branch information
rianhughes and cicr99 authored Oct 24, 2023
1 parent d5a5bf3 commit 2817c4f
Showing 1 changed file with 81 additions and 9 deletions.
90 changes: 81 additions & 9 deletions rpc/types_transaction_receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,59 @@ func (tr L1HandlerTransactionReceipt) GetExecutionStatus() TxnExecutionStatus {
return tr.ExecutionStatus
}

type PendingDeployTransactionReceipt struct {
CommonTransactionReceipt
type PendingL1HandlerTransactionReceipt struct {
Type TransactionType `json:"type"`
// The message hash as it appears on the L1 core contract
MsgHash NumAsHex `json:"message_hash"`
PendingCommonTransactionReceiptProperties
}

func (tr PendingL1HandlerTransactionReceipt) Hash() *felt.Felt {
return tr.TransactionHash
}

func (tr PendingL1HandlerTransactionReceipt) GetExecutionStatus() TxnExecutionStatus {
return tr.ExecutionStatus
}

type PendingDeclareTransactionReceipt struct {
Type TransactionType `json:"type"`
PendingCommonTransactionReceiptProperties
}

func (tr PendingDeclareTransactionReceipt) Hash() *felt.Felt {
return tr.TransactionHash
}

func (tr PendingDeclareTransactionReceipt) GetExecutionStatus() TxnExecutionStatus {
return tr.ExecutionStatus
}

type PendingDeployAccountTransactionReceipt struct {
Type TransactionType `json:"type"`
// The address of the deployed contract
ContractAddress *felt.Felt `json:"contract_address"`
PendingCommonTransactionReceiptProperties
}

func (tr PendingDeployAccountTransactionReceipt) Hash() *felt.Felt {
return tr.TransactionHash
}

func (tr PendingDeployAccountTransactionReceipt) GetExecutionStatus() TxnExecutionStatus {
return tr.ExecutionStatus
}

type PendingInvokeTransactionReceipt struct {
Type TransactionType `json:"type"`
PendingCommonTransactionReceiptProperties
}

func (tr PendingDeployTransactionReceipt) Hash() *felt.Felt {
func (tr PendingInvokeTransactionReceipt) Hash() *felt.Felt {
return tr.TransactionHash
}

func (tr PendingDeployTransactionReceipt) GetExecutionStatus() TxnExecutionStatus {
func (tr PendingInvokeTransactionReceipt) GetExecutionStatus() TxnExecutionStatus {
return tr.ExecutionStatus
}

Expand All @@ -160,7 +202,29 @@ type PendingCommonTransactionReceiptProperties struct {
FinalityStatus TxnFinalityStatus `json:"finality_status"`
RevertReason string `json:"revert_reason"`
// Events The events emitted as part of this transaction
Events []Event `json:"events"`
Events []Event `json:"events"`
ExecutionResources ExecutionResources `json:"execution_resources"`
}

type ExecutionResources struct {
// The number of Cairo steps used
Steps NumAsHex `json:"steps"`
// The number of unused memory cells (each cell is roughly equivalent to a step)
MemoryHoles NumAsHex `json:"memory_holes,omitempty"`
// The number of RANGE_CHECK builtin instances
RangeCheckApps NumAsHex `json:"range_check_builtin_applications"`
// The number of Pedersen builtin instances
PedersenApps NumAsHex `json:"pedersen_builtin_applications"`
// The number of Poseidon builtin instances
PoseidonApps NumAsHex `json:"poseidon_builtin_applications"`
// The number of EC_OP builtin instances
ECOPApps NumAsHex `json:"ec_op_builtin_applications"`
// The number of ECDSA builtin instances
ECDSAApps NumAsHex `json:"ecdsa_builtin_applications"`
// The number of BITWISE builtin instances
BitwiseApps NumAsHex `json:"bitwise_builtin_applications"`
// The number of KECCAK builtin instances
KeccakApps NumAsHex `json:"keccak_builtin_applications"`
}

func (tr PendingCommonTransactionReceiptProperties) Hash() *felt.Felt {
Expand Down Expand Up @@ -227,12 +291,20 @@ func unmarshalTransactionReceipt(t interface{}) (TransactionReceipt, error) {
// Pending doesn't have a block number
if casted["block_hash"] == nil {
switch TransactionType(typ.(string)) {
case TransactionType_Deploy:
var txn PendingDeployTransactionReceipt
case TransactionType_Invoke:
var txn PendingInvokeTransactionReceipt
remarshal(casted, &txn)
return txn, nil
case TransactionType_DeployAccount:
var txn PendingDeployAccountTransactionReceipt
remarshal(casted, &txn)
return txn, nil
case TransactionType_L1Handler:
var txn PendingL1HandlerTransactionReceipt
remarshal(casted, &txn)
return txn, nil
default:
var txn PendingCommonTransactionReceiptProperties
case TransactionType_Declare:
var txn PendingDeclareTransactionReceipt
remarshal(casted, &txn)
return txn, nil
}
Expand Down

0 comments on commit 2817c4f

Please sign in to comment.