Skip to content

Commit

Permalink
Reverted changes in BroadcastDeclareTxnV3 (#604)
Browse files Browse the repository at this point in the history
Correct BroadcastDeclareTxnV3 to follow the spec 0.7.1

Co-authored-by: Rian Hughes <[email protected]>
  • Loading branch information
PsychoPunkSage and rianhughes authored Jul 25, 2024
1 parent e8a6688 commit 0cf4b31
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 25 deletions.
19 changes: 17 additions & 2 deletions rpc/types_broadcast_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{} {
Expand Down
44 changes: 21 additions & 23 deletions rpc/write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0cf4b31

Please sign in to comment.