mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 21:17:16 +00:00
393753af42
* fix starknet tx hashing to work with txpool v2 * fix test * fix starknet txs mining * lint fixup * fixup * fix 2
45 lines
933 B
Go
45 lines
933 B
Go
package vm
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/ledgerwatch/erigon/common"
|
|
"github.com/ledgerwatch/erigon/crypto"
|
|
)
|
|
|
|
func NewCVM(state IntraBlockState) *CVM {
|
|
cvm := &CVM{
|
|
intraBlockState: state,
|
|
}
|
|
|
|
return cvm
|
|
}
|
|
|
|
type CVM struct {
|
|
config Config
|
|
intraBlockState IntraBlockState
|
|
}
|
|
|
|
func (cvm *CVM) Create(caller ContractRef, code []byte) ([]byte, common.Address, error) {
|
|
address := crypto.CreateAddress(caller.Address(), cvm.intraBlockState.GetNonce(caller.Address()))
|
|
cvm.intraBlockState.SetCode(address, code)
|
|
fmt.Println(">>>> Create Starknet Contract", address.Hex())
|
|
return code, common.Address{}, nil
|
|
|
|
//TODO:: execute cairo construct
|
|
//ret, err := cvm.run(code)
|
|
}
|
|
|
|
func (cvm *CVM) Config() Config {
|
|
return cvm.config
|
|
}
|
|
|
|
func (cvm *CVM) IntraBlockState() IntraBlockState {
|
|
return cvm.intraBlockState
|
|
}
|
|
|
|
//func (cvm *CVM) run(code []byte) ([]byte, error) {
|
|
// // TODO:: call grpc cairo
|
|
// return code, nil
|
|
//}
|