Move EthTxReceipt to api
This commit is contained in:
parent
855c35cb88
commit
96bb03e1e0
@ -776,7 +776,7 @@ type FullNode interface {
|
|||||||
EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (eth.EthBlock, error) //perm:read
|
EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (eth.EthBlock, error) //perm:read
|
||||||
EthGetTransactionByHash(ctx context.Context, txHash *eth.EthHash) (*eth.EthTx, error) //perm:read
|
EthGetTransactionByHash(ctx context.Context, txHash *eth.EthHash) (*eth.EthTx, error) //perm:read
|
||||||
EthGetTransactionCount(ctx context.Context, sender eth.EthAddress, blkOpt string) (eth.EthUint64, error) //perm:read
|
EthGetTransactionCount(ctx context.Context, sender eth.EthAddress, blkOpt string) (eth.EthUint64, error) //perm:read
|
||||||
EthGetTransactionReceipt(ctx context.Context, txHash eth.EthHash) (*eth.EthTxReceipt, error) //perm:read
|
EthGetTransactionReceipt(ctx context.Context, txHash eth.EthHash) (*EthTxReceipt, error) //perm:read
|
||||||
EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash eth.EthHash, txIndex eth.EthUint64) (eth.EthTx, error) //perm:read
|
EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash eth.EthHash, txIndex eth.EthUint64) (eth.EthTx, error) //perm:read
|
||||||
EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum eth.EthUint64, txIndex eth.EthUint64) (eth.EthTx, error) //perm:read
|
EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum eth.EthUint64, txIndex eth.EthUint64) (eth.EthTx, error) //perm:read
|
||||||
|
|
||||||
@ -1289,3 +1289,22 @@ type PruneOpts struct {
|
|||||||
MovingGC bool
|
MovingGC bool
|
||||||
RetainState int64
|
RetainState int64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type EthTxReceipt struct {
|
||||||
|
TransactionHash eth.EthHash `json:"transactionHash"`
|
||||||
|
TransactionIndex eth.EthUint64 `json:"transactionIndex"`
|
||||||
|
BlockHash eth.EthHash `json:"blockHash"`
|
||||||
|
BlockNumber eth.EthUint64 `json:"blockNumber"`
|
||||||
|
From eth.EthAddress `json:"from"`
|
||||||
|
To *eth.EthAddress `json:"to"`
|
||||||
|
// Logs
|
||||||
|
// LogsBloom
|
||||||
|
StateRoot eth.EthHash `json:"root"`
|
||||||
|
Status eth.EthUint64 `json:"status"`
|
||||||
|
ContractAddress *eth.EthAddress `json:"contractAddress"`
|
||||||
|
CumulativeGasUsed eth.EthUint64 `json:"cumulativeGasUsed"`
|
||||||
|
GasUsed eth.EthUint64 `json:"gasUsed"`
|
||||||
|
EffectiveGasPrice eth.EthBigInt `json:"effectiveGasPrice"`
|
||||||
|
LogsBloom eth.EthBytes `json:"logsBloom"`
|
||||||
|
Logs []string `json:"logs"`
|
||||||
|
}
|
||||||
|
@ -1193,10 +1193,10 @@ func (mr *MockFullNodeMockRecorder) EthGetTransactionCount(arg0, arg1, arg2 inte
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EthGetTransactionReceipt mocks base method.
|
// EthGetTransactionReceipt mocks base method.
|
||||||
func (m *MockFullNode) EthGetTransactionReceipt(arg0 context.Context, arg1 eth.EthHash) (*eth.EthTxReceipt, error) {
|
func (m *MockFullNode) EthGetTransactionReceipt(arg0 context.Context, arg1 eth.EthHash) (*api.EthTxReceipt, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "EthGetTransactionReceipt", arg0, arg1)
|
ret := m.ctrl.Call(m, "EthGetTransactionReceipt", arg0, arg1)
|
||||||
ret0, _ := ret[0].(*eth.EthTxReceipt)
|
ret0, _ := ret[0].(*api.EthTxReceipt)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,7 @@ type FullNodeStruct struct {
|
|||||||
|
|
||||||
EthGetTransactionCount func(p0 context.Context, p1 eth.EthAddress, p2 string) (eth.EthUint64, error) `perm:"read"`
|
EthGetTransactionCount func(p0 context.Context, p1 eth.EthAddress, p2 string) (eth.EthUint64, error) `perm:"read"`
|
||||||
|
|
||||||
EthGetTransactionReceipt func(p0 context.Context, p1 eth.EthHash) (*eth.EthTxReceipt, error) `perm:"read"`
|
EthGetTransactionReceipt func(p0 context.Context, p1 eth.EthHash) (*EthTxReceipt, error) `perm:"read"`
|
||||||
|
|
||||||
EthMaxPriorityFeePerGas func(p0 context.Context) (eth.EthBigInt, error) `perm:"read"`
|
EthMaxPriorityFeePerGas func(p0 context.Context) (eth.EthBigInt, error) `perm:"read"`
|
||||||
|
|
||||||
@ -2042,14 +2042,14 @@ func (s *FullNodeStub) EthGetTransactionCount(p0 context.Context, p1 eth.EthAddr
|
|||||||
return *new(eth.EthUint64), ErrNotSupported
|
return *new(eth.EthUint64), ErrNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FullNodeStruct) EthGetTransactionReceipt(p0 context.Context, p1 eth.EthHash) (*eth.EthTxReceipt, error) {
|
func (s *FullNodeStruct) EthGetTransactionReceipt(p0 context.Context, p1 eth.EthHash) (*EthTxReceipt, error) {
|
||||||
if s.Internal.EthGetTransactionReceipt == nil {
|
if s.Internal.EthGetTransactionReceipt == nil {
|
||||||
return nil, ErrNotSupported
|
return nil, ErrNotSupported
|
||||||
}
|
}
|
||||||
return s.Internal.EthGetTransactionReceipt(p0, p1)
|
return s.Internal.EthGetTransactionReceipt(p0, p1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FullNodeStub) EthGetTransactionReceipt(p0 context.Context, p1 eth.EthHash) (*eth.EthTxReceipt, error) {
|
func (s *FullNodeStub) EthGetTransactionReceipt(p0 context.Context, p1 eth.EthHash) (*EthTxReceipt, error) {
|
||||||
return nil, ErrNotSupported
|
return nil, ErrNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
@ -178,25 +178,6 @@ func (c *EthCall) UnmarshalJSON(b []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type EthTxReceipt struct {
|
|
||||||
TransactionHash EthHash `json:"transactionHash"`
|
|
||||||
TransactionIndex EthUint64 `json:"transactionIndex"`
|
|
||||||
BlockHash EthHash `json:"blockHash"`
|
|
||||||
BlockNumber EthUint64 `json:"blockNumber"`
|
|
||||||
From EthAddress `json:"from"`
|
|
||||||
To *EthAddress `json:"to"`
|
|
||||||
// Logs
|
|
||||||
// LogsBloom
|
|
||||||
StateRoot EthHash `json:"root"`
|
|
||||||
Status EthUint64 `json:"status"`
|
|
||||||
ContractAddress *EthAddress `json:"contractAddress"`
|
|
||||||
CumulativeGasUsed EthUint64 `json:"cumulativeGasUsed"`
|
|
||||||
GasUsed EthUint64 `json:"gasUsed"`
|
|
||||||
EffectiveGasPrice EthBigInt `json:"effectiveGasPrice"`
|
|
||||||
LogsBloom EthBytes `json:"logsBloom"`
|
|
||||||
Logs []string `json:"logs"`
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
EthAddressLength = 20
|
EthAddressLength = 20
|
||||||
EthHashLength = 32
|
EthHashLength = 32
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/chain/eth"
|
"github.com/filecoin-project/lotus/chain/eth"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -43,7 +44,7 @@ func (e *EthModuleDummy) EthGetTransactionCount(ctx context.Context, sender eth.
|
|||||||
return 0, ErrImplementMe
|
return 0, ErrImplementMe
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *EthModuleDummy) EthGetTransactionReceipt(ctx context.Context, txHash eth.EthHash) (*eth.EthTxReceipt, error) {
|
func (e *EthModuleDummy) EthGetTransactionReceipt(ctx context.Context, txHash eth.EthHash) (*api.EthTxReceipt, error) {
|
||||||
return nil, ErrImplementMe
|
return nil, ErrImplementMe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ type EthModuleAPI interface {
|
|||||||
EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (eth.EthBlock, error)
|
EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (eth.EthBlock, error)
|
||||||
EthGetTransactionByHash(ctx context.Context, txHash *eth.EthHash) (*eth.EthTx, error)
|
EthGetTransactionByHash(ctx context.Context, txHash *eth.EthHash) (*eth.EthTx, error)
|
||||||
EthGetTransactionCount(ctx context.Context, sender eth.EthAddress, blkOpt string) (eth.EthUint64, error)
|
EthGetTransactionCount(ctx context.Context, sender eth.EthAddress, blkOpt string) (eth.EthUint64, error)
|
||||||
EthGetTransactionReceipt(ctx context.Context, txHash eth.EthHash) (*eth.EthTxReceipt, error)
|
EthGetTransactionReceipt(ctx context.Context, txHash eth.EthHash) (*api.EthTxReceipt, error)
|
||||||
EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash eth.EthHash, txIndex eth.EthUint64) (eth.EthTx, error)
|
EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash eth.EthHash, txIndex eth.EthUint64) (eth.EthTx, error)
|
||||||
EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum eth.EthUint64, txIndex eth.EthUint64) (eth.EthTx, error)
|
EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum eth.EthUint64, txIndex eth.EthUint64) (eth.EthTx, error)
|
||||||
EthGetCode(ctx context.Context, address eth.EthAddress, blkOpt string) (eth.EthBytes, error)
|
EthGetCode(ctx context.Context, address eth.EthAddress, blkOpt string) (eth.EthBytes, error)
|
||||||
@ -191,7 +191,7 @@ func (a *EthModule) EthGetTransactionCount(ctx context.Context, sender eth.EthAd
|
|||||||
return eth.EthUint64(nonce), nil
|
return eth.EthUint64(nonce), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *EthModule) EthGetTransactionReceipt(ctx context.Context, txHash eth.EthHash) (*eth.EthTxReceipt, error) {
|
func (a *EthModule) EthGetTransactionReceipt(ctx context.Context, txHash eth.EthHash) (*api.EthTxReceipt, error) {
|
||||||
cid := txHash.ToCid()
|
cid := txHash.ToCid()
|
||||||
|
|
||||||
msgLookup, err := a.StateAPI.StateSearchMsg(ctx, types.EmptyTSK, cid, api.LookbackNoLimit, true)
|
msgLookup, err := a.StateAPI.StateSearchMsg(ctx, types.EmptyTSK, cid, api.LookbackNoLimit, true)
|
||||||
@ -866,8 +866,8 @@ func (a *EthModule) newEthTxFromFilecoinMessageLookup(ctx context.Context, msgLo
|
|||||||
return tx, nil
|
return tx, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEthTxReceipt(tx eth.EthTx, lookup *api.MsgLookup, replay *api.InvocResult) (eth.EthTxReceipt, error) {
|
func NewEthTxReceipt(tx eth.EthTx, lookup *api.MsgLookup, replay *api.InvocResult) (api.EthTxReceipt, error) {
|
||||||
receipt := eth.EthTxReceipt{
|
receipt := api.EthTxReceipt{
|
||||||
TransactionHash: tx.Hash,
|
TransactionHash: tx.Hash,
|
||||||
TransactionIndex: tx.TransactionIndex,
|
TransactionIndex: tx.TransactionIndex,
|
||||||
BlockHash: tx.BlockHash,
|
BlockHash: tx.BlockHash,
|
||||||
@ -883,7 +883,7 @@ func NewEthTxReceipt(tx eth.EthTx, lookup *api.MsgLookup, replay *api.InvocResul
|
|||||||
// Create and Create2 return the same things.
|
// Create and Create2 return the same things.
|
||||||
var ret eam.CreateReturn
|
var ret eam.CreateReturn
|
||||||
if err := ret.UnmarshalCBOR(bytes.NewReader(lookup.Receipt.Return)); err != nil {
|
if err := ret.UnmarshalCBOR(bytes.NewReader(lookup.Receipt.Return)); err != nil {
|
||||||
return eth.EthTxReceipt{}, xerrors.Errorf("failed to parse contract creation result: %w", err)
|
return api.EthTxReceipt{}, xerrors.Errorf("failed to parse contract creation result: %w", err)
|
||||||
}
|
}
|
||||||
addr := eth.EthAddress(ret.EthAddress)
|
addr := eth.EthAddress(ret.EthAddress)
|
||||||
receipt.ContractAddress = &addr
|
receipt.ContractAddress = &addr
|
||||||
|
Loading…
Reference in New Issue
Block a user