Skip to content

Commit

Permalink
Fix stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
rianhughes committed Sep 22, 2023
1 parent 58330af commit 99a5b77
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion account/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (account *Account) TransactionHashInvoke(tx rpc.InvokeTxnType) (*felt.Felt,
)

case rpc.InvokeTxnV1:
if len(txn.Calldata) == 0 || txn.Nonce == nil || txn.MaxFee == nil || txn.SenderAddress == nil {
if txn.Version == "" || len(txn.Calldata) == 0 || txn.Nonce == nil || txn.MaxFee == nil || txn.SenderAddress == nil {
return nil, ErrNotAllParametersSet
}

Expand Down
20 changes: 9 additions & 11 deletions account/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package account_test

import (
"context"
"encoding/json"
"flag"
"fmt"
"math/big"
Expand Down Expand Up @@ -397,13 +398,7 @@ func TestAddInvoke(t *testing.T) {

require.NoError(t, acnt.BuildInvokeTx(context.Background(), &test.InvokeTx, &[]rpc.FunctionCall{test.FnCall}), "Error building Invoke")

invokeTxn := rpc.InvokeTxnV1{
Calldata: test.FnCall.Calldata,
Nonce: test.TxDetails.Nonce,
MaxFee: test.TxDetails.MaxFee,
SenderAddress: acnt.AccountAddress,
}
txHash, err := acnt.TransactionHashInvoke(invokeTxn)
txHash, err := acnt.TransactionHashInvoke(test.InvokeTx)
require.NoError(t, err)
require.Equal(t, txHash.String(), test.ExpectedHash.String())

Expand Down Expand Up @@ -525,7 +520,7 @@ func TestTransactionHashDeclare(t *testing.T) {
Nonce: utils.TestHexToFelt(t, "0xb"),
MaxFee: utils.TestHexToFelt(t, "0x50c8f3053db"),
Type: rpc.TransactionType_Declare,
Version: "0x2", //todo update when rpcv04 merged
Version: rpc.TransactionV2,
Signature: []*felt.Felt{},
SenderAddress: utils.TestHexToFelt(t, "0x36437dffa1b0bf630f04690a3b302adbabb942deb488ea430660c895ff25acf"),
CompiledClassHash: utils.TestHexToFelt(t, "0x615a5260d3d47d79fba87898da95cb5394b181c7d5097bc8ced4ed06ac24ac5"),
Expand Down Expand Up @@ -565,7 +560,7 @@ func TestAddDeclareTransaction(t *testing.T) {
Nonce: utils.TestHexToFelt(t, "0xb"),
MaxFee: utils.TestHexToFelt(t, "0x50c8f3053db"),
Type: rpc.TransactionType_Declare,
Version: "0x2", //todo update when rpcv04 merged
Version: rpc.TransactionV2,
Signature: []*felt.Felt{},
SenderAddress: utils.TestHexToFelt(t, "0x36437dffa1b0bf630f04690a3b302adbabb942deb488ea430660c895ff25acf"),
CompiledClassHash: utils.TestHexToFelt(t, "0x615a5260d3d47d79fba87898da95cb5394b181c7d5097bc8ced4ed06ac24ac5"),
Expand All @@ -577,10 +572,13 @@ func TestAddDeclareTransaction(t *testing.T) {
require.Equal(t, expectedTransactionHash.String(), hash.String(), "TransactionHashDeclare not what expected")

err = acnt.SignDeclareTransaction(context.Background(), &tx)
require.NoError(t, err)
require.NoError(t, err, "Error in SignDeclareTransaction()")

qwe, _ := json.MarshalIndent(tx, "", "")
fmt.Println(string(qwe))

resp, err := acnt.AddDeclareTransaction(context.Background(), tx)
require.NoError(t, err)
require.NoError(t, err, "Error in AddDeclareTransaction()")
require.Equal(t, resp.TransactionHash.String(), expectedTransactionHash.String(), "AddDeclareTransaction TransactionHash mismatch")
require.Equal(t, resp.ClassHash.String(), expectedClassHash.String(), "AddDeclareTransaction ClassHash mismatch")
}
Expand Down

0 comments on commit 99a5b77

Please sign in to comment.