Skip to content
This repository has been archived by the owner on Aug 31, 2024. It is now read-only.

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Lawliet-Chan committed Jan 31, 2024
1 parent 46eff13 commit 7fb38c7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions cairoVM/cairo.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func (c *Cairo) HandleDeclareTx(tx *core.DeclareTransaction, class core.Class) (
}

func (c *Cairo) HandleInvokeTx(tx *core.InvokeTransaction) (*vm.TransactionTrace, error) {
fmt.Println("---------- Invoke TX ----------")
tx.MaxFee = c.MaxFee
tx.SenderAddress = &felt.Zero
txnHash, err := core.TransactionHash(tx, c.cfg.Network)
Expand Down
18 changes: 11 additions & 7 deletions cairoVM/invoke.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cairoVM

import (
"fmt"
"github.com/NethermindEth/juno/core"
"github.com/NethermindEth/juno/core/felt"
"github.com/NethermindEth/starknet.go/account"
Expand All @@ -13,23 +14,25 @@ var (
)

func NewInvoke() (*core.InvokeTransaction, error) {
InvokeTx := rpc.InvokeTxnV1{
Version: rpc.TransactionV1,
Type: rpc.TransactionType_Invoke,
}
//InvokeTx := rpc.InvokeTxnV1{
// Version: rpc.TransactionV1,
// Type: rpc.TransactionType_Invoke,
//}

// Converting the contractAddress from hex to felt
contractAddress := new(felt.Felt).SetUint64(2)

randata := new(felt.Felt).SetUint64(2)
randata := new(felt.Felt).SetUint64(111)
// Building the functionCall struct, where :
FnCall := rpc.FunctionCall{
ContractAddress: contractAddress, //contractAddress is the contract that we want to call
EntryPointSelector: utils.GetSelectorFromNameFelt(contractMethod), //this is the function that we want to call
Calldata: []*felt.Felt{randata}, //this is the data that we want to pass to the function
}

InvokeTx.Calldata = account.FmtCalldataCairo2([]rpc.FunctionCall{FnCall})
txCallData := account.FmtCalldataCairo2([]rpc.FunctionCall{FnCall})

fmt.Println("invoke calldata = ", txCallData)

nonce := new(felt.Felt).SetUint64(1)
tx := core.InvokeTransaction{
Expand All @@ -38,7 +41,8 @@ func NewInvoke() (*core.InvokeTransaction, error) {
Version: new(core.TransactionVersion).SetUint64(1),
ContractAddress: contractAddress,
EntryPointSelector: utils.GetSelectorFromNameFelt(contractMethod),
CallData: []*felt.Felt{randata},
CallData: txCallData,
// CallData: []*felt.Felt{randata},
}

return &tx, nil
Expand Down

0 comments on commit 7fb38c7

Please sign in to comment.