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

little refine #24

Merged
merged 3 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
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
21 changes: 9 additions & 12 deletions cairoVM/cairo.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,6 @@ func NewCairoVM(cfg *Config) (*Cairo, error) {
if err != nil {
return nil, err
}
//db, err := pebble.NewMem()
//if err != nil {
// return nil, err
//}
//txn, err := db.NewTransaction(true)
//if err != nil {
// return nil, err
//}
//state := core.NewState(txn)
//cairoFiles := make(map[string]string)
//cairoFiles["data/genesis/NoValidateAccount.sierra.json"] = "data/genesis/NoValidateAccount.casm.json"
//cairoFiles["data/genesis/erc20.sierra.json"] = "data/genesis/erc20.casm.json"

state, err := BuildGenesis(
[]string{
Expand Down Expand Up @@ -131,10 +119,19 @@ func (c *Cairo) HandleInvokeTx(tx *core.InvokeTransaction) (*vm.TransactionTrace
fmt.Println("---------- Invoke TX ----------")
tx.MaxFee = c.MaxFee
tx.SenderAddress = &felt.Zero

nonce, err := c.state.ContractNonce(tx.SenderAddress)
if err != nil {
return nil, err
}

tx.Nonce = nonce

txnHash, err := core.TransactionHash(tx, c.cfg.Network)
if err != nil {
return nil, err
}

tx.TransactionHash = txnHash

sig, err := c.acc.Sign(context.Background(), txnHash)
Expand Down
1 change: 0 additions & 1 deletion cairoVM/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/davecgh/go-spew/spew"

"github.com/NethermindEth/juno/core/felt"
// "github.com/NethermindEth/juno/core"
)

func main() {
Expand Down
31 changes: 0 additions & 31 deletions cairoVM/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ func NewDeployCool() (*core.InvokeTransaction, error) {
}

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

// Converting the contractAddress from hex to felt
// contractAddress := new(felt.Felt).SetUint64(2)
contractAddress, _ := new(felt.Felt).SetString("0x7f2f788bcd85c25ece505a4fe359c577be77841c5afb971648af03391e5e834")

params := new(felt.Felt).SetUint64(9099)
Expand All @@ -79,10 +72,7 @@ func NewDeployInvokeTest() (*core.InvokeTransaction, error) {

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

nonce := new(felt.Felt).SetUint64(3)
tx := core.InvokeTransaction{
Nonce: nonce,
MaxFee: &felt.Zero,
Version: new(core.TransactionVersion).SetUint64(1),
ContractAddress: contractAddress,
EntryPointSelector: utils.GetSelectorFromNameFelt(contractMethod),
Expand All @@ -95,12 +85,6 @@ func NewDeployInvokeTest() (*core.InvokeTransaction, error) {
}

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

// using UniversalDeploy address
contractAddress := new(felt.Felt).SetUint64(1)

classHash, _ := new(felt.Felt).SetString("0x47f93257c3a6e42fc71162a646b3223dfad27c2d994f97f333492c66e31b8c8")
Expand All @@ -125,29 +109,18 @@ func NewDeployCoolOld() (*core.InvokeTransaction, error) {

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

nonce := new(felt.Felt).SetUint64(4)
tx := core.InvokeTransaction{
Nonce: nonce,
MaxFee: &felt.Zero,
Version: new(core.TransactionVersion).SetUint64(1),
ContractAddress: contractAddress,
EntryPointSelector: utils.GetSelectorFromNameFelt(deployContractMethod),
CallData: txCallData,
// CallData: []*felt.Felt{randata},
}

return &tx, nil

}

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

// Converting the contractAddress from hex to felt
// contractAddress := new(felt.Felt).SetUint64(2)
contractAddress, _ := new(felt.Felt).SetString("0x77fcc62a59a2160f099493fcd0466c526120320c164a62a72c6ac9931db34d9")

params := new(felt.Felt).SetUint64(1111)
Expand All @@ -162,15 +135,11 @@ func NewDeployInvokeTestCoolOld() (*core.InvokeTransaction, error) {

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

nonce := new(felt.Felt).SetUint64(5)
tx := core.InvokeTransaction{
Nonce: nonce,
MaxFee: &felt.Zero,
Version: new(core.TransactionVersion).SetUint64(1),
ContractAddress: contractAddress,
EntryPointSelector: utils.GetSelectorFromNameFelt(contractMethod),
CallData: txCallData,
// CallData: []*felt.Felt{randata},
}

return &tx, nil
Expand Down
3 changes: 0 additions & 3 deletions cairoVM/invoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ func NewInvoke() (*core.InvokeTransaction, error) {

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

nonce := new(felt.Felt).SetUint64(1)
tx := core.InvokeTransaction{
Nonce: nonce,
MaxFee: &felt.Zero,
Version: new(core.TransactionVersion).SetUint64(1),
ContractAddress: contractAddress,
EntryPointSelector: utils.GetSelectorFromNameFelt(contractMethod),
Expand Down
Loading