From 2817c4f71e4122b8338881dd3c95670172bdc861 Mon Sep 17 00:00:00 2001 From: Rian Hughes Date: Tue, 24 Oct 2023 14:53:21 +0100 Subject: [PATCH] rpc05 Update pending types (#424) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Carmen Irene Cabrera Rodríguez <49727740+cicr99@users.noreply.github.com> --- rpc/types_transaction_receipt.go | 90 ++++++++++++++++++++++++++++---- 1 file changed, 81 insertions(+), 9 deletions(-) diff --git a/rpc/types_transaction_receipt.go b/rpc/types_transaction_receipt.go index cffe7ea6..85a9d198 100644 --- a/rpc/types_transaction_receipt.go +++ b/rpc/types_transaction_receipt.go @@ -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 } @@ -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 { @@ -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 }