From 0cf4b319ce4aa405c4b6b5d8f56471967d7b2f0a Mon Sep 17 00:00:00 2001 From: Abhinav Prakash <95116715+PsychoPunkSage@users.noreply.github.com> Date: Thu, 25 Jul 2024 13:10:04 +0530 Subject: [PATCH] Reverted changes in `BroadcastDeclareTxnV3` (#604) Correct BroadcastDeclareTxnV3 to follow the spec 0.7.1 Co-authored-by: Rian Hughes --- rpc/types_broadcast_transaction.go | 19 +++++++++++-- rpc/write_test.go | 44 ++++++++++++++---------------- 2 files changed, 38 insertions(+), 25 deletions(-) diff --git a/rpc/types_broadcast_transaction.go b/rpc/types_broadcast_transaction.go index 167d28a0..ded69f28 100644 --- a/rpc/types_broadcast_transaction.go +++ b/rpc/types_broadcast_transaction.go @@ -98,8 +98,23 @@ func (tx BroadcastDeclareTxnV2) GetContractClass() interface{} { } type BroadcastDeclareTxnV3 struct { - DeclareTxnV3 - ContractClass *ContractClass `json:"contract_class"` + Type TransactionType `json:"type"` + SenderAddress *felt.Felt `json:"sender_address"` + CompiledClassHash *felt.Felt `json:"compiled_class_hash"` + Version TransactionVersion `json:"version"` + Signature []*felt.Felt `json:"signature"` + Nonce *felt.Felt `json:"nonce"` + ContractClass *ContractClass `json:"contract_class"` + ResourceBounds ResourceBoundsMapping `json:"resource_bounds"` + Tip U64 `json:"tip"` + // The data needed to allow the paymaster to pay for the transaction in native tokens + PayMasterData []*felt.Felt `json:"paymaster_data"` + // The data needed to deploy the account contract from which this tx will be initiated + AccountDeploymentData []*felt.Felt `json:"account_deployment_data"` + // The storage domain of the account's nonce (an account has a nonce per DA mode) + NonceDataMode DataAvailabilityMode `json:"nonce_data_availability_mode"` + // The storage domain of the account's balance from which fee will be charged + FeeMode DataAvailabilityMode `json:"fee_data_availability_mode"` } func (tx BroadcastDeclareTxnV3) GetContractClass() interface{} { diff --git a/rpc/write_test.go b/rpc/write_test.go index 90e3038b..8354f5aa 100644 --- a/rpc/write_test.go +++ b/rpc/write_test.go @@ -33,30 +33,28 @@ func TestDeclareTransaction(t *testing.T) { }, { DeclareTx: BroadcastDeclareTxnV3{ - DeclareTxnV3: DeclareTxnV3{ - Type: TransactionType_Declare, - Version: TransactionV3, - Signature: []*felt.Felt{}, - Nonce: utils.TestHexToFelt(t, "0x0"), - NonceDataMode: DAModeL1, - FeeMode: DAModeL1, - ResourceBounds: ResourceBoundsMapping{ - L1Gas: ResourceBounds{ - MaxAmount: "0x0", - MaxPricePerUnit: "0x0", - }, - L2Gas: ResourceBounds{ - MaxAmount: "0x0", - MaxPricePerUnit: "0x0", - }, + Type: TransactionType_Declare, + Version: TransactionV3, + Signature: []*felt.Felt{}, + Nonce: utils.TestHexToFelt(t, "0x0"), + NonceDataMode: DAModeL1, + FeeMode: DAModeL1, + ResourceBounds: ResourceBoundsMapping{ + L1Gas: ResourceBounds{ + MaxAmount: "0x0", + MaxPricePerUnit: "0x0", }, - Tip: "", - PayMasterData: []*felt.Felt{}, - SenderAddress: utils.TestHexToFelt(t, "0x0"), - CompiledClassHash: utils.TestHexToFelt(t, "0x0"), - ClassHash: utils.TestHexToFelt(t, "0x0"), - AccountDeploymentData: []*felt.Felt{}, - }}, + L2Gas: ResourceBounds{ + MaxAmount: "0x0", + MaxPricePerUnit: "0x0", + }, + }, + Tip: "", + PayMasterData: []*felt.Felt{}, + SenderAddress: utils.TestHexToFelt(t, "0x0"), + CompiledClassHash: utils.TestHexToFelt(t, "0x0"), + AccountDeploymentData: []*felt.Felt{}, + }, ExpectedResp: AddDeclareTransactionResponse{ TransactionHash: utils.TestHexToFelt(t, "0x41d1f5206ef58a443e7d3d1ca073171ec25fa75313394318fc83a074a6631c3")}, ExpectedError: nil,