From 8722e19c774fff506e8b22b3a4db1176b863ce5b Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Wed, 24 Jan 2024 11:13:39 -0800 Subject: [PATCH] Type casting and function signature alterations needed to comply with plugeth-utils --- plugins/wrappers/backendwrapper/backendwrapper.go | 2 +- plugins/wrappers/backendwrapper/triewrapper.go | 4 +++- plugins/wrappers/wrappers.go | 10 +++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/wrappers/backendwrapper/backendwrapper.go b/plugins/wrappers/backendwrapper/backendwrapper.go index a2f681ed9..603d8b598 100644 --- a/plugins/wrappers/backendwrapper/backendwrapper.go +++ b/plugins/wrappers/backendwrapper/backendwrapper.go @@ -129,7 +129,7 @@ func (b *Backend) SendTx(ctx context.Context, signedTx []byte) error { 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 { - 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 { return nil, core.Hash(blockHash), blockNumber, index, err } diff --git a/plugins/wrappers/backendwrapper/triewrapper.go b/plugins/wrappers/backendwrapper/triewrapper.go index d4e3b3c1d..6171b9c79 100644 --- a/plugins/wrappers/backendwrapper/triewrapper.go +++ b/plugins/wrappers/backendwrapper/triewrapper.go @@ -1,6 +1,8 @@ package backendwrapper import ( + "math/big" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/log" @@ -28,7 +30,7 @@ func (t *WrappedTrie) GetAccount(address core.Address) (*core.StateAccount, erro } return &core.StateAccount{ Nonce: act.Nonce, - Balance: act.Balance, + Balance: new(big.Int).SetBytes(act.Balance.Bytes()), Root: core.Hash(act.Root), CodeHash: act.CodeHash, }, nil diff --git a/plugins/wrappers/wrappers.go b/plugins/wrappers/wrappers.go index 98bfd93d0..f75940cdc 100644 --- a/plugins/wrappers/wrappers.go +++ b/plugins/wrappers/wrappers.go @@ -4,6 +4,8 @@ import ( "math/big" "encoding/json" + "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/vm" @@ -57,7 +59,7 @@ func (w *WrappedContract) Address() core.Address { } func (w *WrappedContract) Value() *big.Int { - return w.c.Value() + return new(big.Int).SetBytes(w.c.Value().Bytes()) } func (w *WrappedContract) Input() []byte { @@ -128,7 +130,8 @@ func NewWrappedStateDB(d *state.StateDB) *WrappedStateDB { // GetBalance(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 @@ -201,7 +204,8 @@ func (w *WrappedStateDB) IntermediateRoot(deleteEmptyObjects bool) core.Hash { } 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 {