Type casting and function signature alterations needed to comply with plugeth-utils

This commit is contained in:
philip-morlier 2024-01-24 11:13:39 -08:00
parent 48be241dbf
commit 8722e19c77
3 changed files with 11 additions and 5 deletions

View File

@ -129,7 +129,7 @@ func (b *Backend) SendTx(ctx context.Context, signedTx []byte) error {
return b.b.SendTx(ctx, tx) return b.b.SendTx(ctx, tx)
} }
func (b *Backend) GetTransaction(ctx context.Context, txHash core.Hash) ([]byte, core.Hash, uint64, uint64, error) { // RLP Encoded transaction { func (b *Backend) GetTransaction(ctx context.Context, txHash core.Hash) ([]byte, core.Hash, uint64, uint64, error) { // RLP Encoded transaction {
tx, blockHash, blockNumber, index, err := b.b.GetTransaction(ctx, common.Hash(txHash)) _, tx, blockHash, blockNumber, index, err := b.b.GetTransaction(ctx, common.Hash(txHash))
if err != nil { if err != nil {
return nil, core.Hash(blockHash), blockNumber, index, err return nil, core.Hash(blockHash), blockNumber, index, err
} }

View File

@ -1,6 +1,8 @@
package backendwrapper package backendwrapper
import ( import (
"math/big"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
@ -28,7 +30,7 @@ func (t *WrappedTrie) GetAccount(address core.Address) (*core.StateAccount, erro
} }
return &core.StateAccount{ return &core.StateAccount{
Nonce: act.Nonce, Nonce: act.Nonce,
Balance: act.Balance, Balance: new(big.Int).SetBytes(act.Balance.Bytes()),
Root: core.Hash(act.Root), Root: core.Hash(act.Root),
CodeHash: act.CodeHash, CodeHash: act.CodeHash,
}, nil }, nil

View File

@ -4,6 +4,8 @@ import (
"math/big" "math/big"
"encoding/json" "encoding/json"
"github.com/holiman/uint256"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/core/vm"
@ -57,7 +59,7 @@ func (w *WrappedContract) Address() core.Address {
} }
func (w *WrappedContract) Value() *big.Int { func (w *WrappedContract) Value() *big.Int {
return w.c.Value() return new(big.Int).SetBytes(w.c.Value().Bytes())
} }
func (w *WrappedContract) Input() []byte { func (w *WrappedContract) Input() []byte {
@ -128,7 +130,8 @@ func NewWrappedStateDB(d *state.StateDB) *WrappedStateDB {
// GetBalance(Address) *big.Int // GetBalance(Address) *big.Int
func (w *WrappedStateDB) GetBalance(addr core.Address) *big.Int { func (w *WrappedStateDB) GetBalance(addr core.Address) *big.Int {
return w.s.GetBalance(common.Address(addr)) return new(big.Int).SetBytes(w.s.GetBalance(common.Address(addr)).Bytes())
} }
// GetNonce(Address) uint64 // GetNonce(Address) uint64
@ -201,7 +204,8 @@ func (w *WrappedStateDB) IntermediateRoot(deleteEmptyObjects bool) core.Hash {
} }
func (w *WrappedStateDB) AddBalance(addr core.Address, amount *big.Int) { func (w *WrappedStateDB) AddBalance(addr core.Address, amount *big.Int) {
w.s.AddBalance(common.Address(addr), amount) castAmount := new(uint256.Int)
w.s.AddBalance(common.Address(addr), castAmount.SetBytes(amount.Bytes()))
} }
type Node struct { type Node struct {