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

rpc05 Update pending types #424

Merged
merged 2 commits into from
Oct 24, 2023
Merged
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
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