2022-12-16 09:48:38 +00:00
|
|
|
// Copyright 2021 Evmos Foundation
|
|
|
|
// This file is part of Evmos' Ethermint library.
|
|
|
|
//
|
|
|
|
// The Ethermint library is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// The Ethermint library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with the Ethermint library. If not, see https://github.com/evmos/ethermint/blob/main/LICENSE
|
2020-10-22 20:39:51 +00:00
|
|
|
package types
|
|
|
|
|
|
|
|
import (
|
2021-11-17 11:58:52 +00:00
|
|
|
"math/big"
|
|
|
|
|
2020-10-22 20:39:51 +00:00
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
2021-05-10 16:34:00 +00:00
|
|
|
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
2020-10-22 20:39:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Copied the Account and StorageResult types since they are registered under an
|
|
|
|
// internal pkg on geth.
|
|
|
|
|
|
|
|
// AccountResult struct for account proof
|
|
|
|
type AccountResult struct {
|
|
|
|
Address common.Address `json:"address"`
|
|
|
|
AccountProof []string `json:"accountProof"`
|
|
|
|
Balance *hexutil.Big `json:"balance"`
|
|
|
|
CodeHash common.Hash `json:"codeHash"`
|
|
|
|
Nonce hexutil.Uint64 `json:"nonce"`
|
|
|
|
StorageHash common.Hash `json:"storageHash"`
|
|
|
|
StorageProof []StorageResult `json:"storageProof"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// StorageResult defines the format for storage proof return
|
|
|
|
type StorageResult struct {
|
|
|
|
Key string `json:"key"`
|
|
|
|
Value *hexutil.Big `json:"value"`
|
|
|
|
Proof []string `json:"proof"`
|
|
|
|
}
|
|
|
|
|
2021-05-10 16:34:00 +00:00
|
|
|
// RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction
|
|
|
|
type RPCTransaction struct {
|
|
|
|
BlockHash *common.Hash `json:"blockHash"`
|
|
|
|
BlockNumber *hexutil.Big `json:"blockNumber"`
|
|
|
|
From common.Address `json:"from"`
|
|
|
|
Gas hexutil.Uint64 `json:"gas"`
|
|
|
|
GasPrice *hexutil.Big `json:"gasPrice"`
|
2021-10-05 15:38:20 +00:00
|
|
|
GasFeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"`
|
|
|
|
GasTipCap *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"`
|
2021-05-10 16:34:00 +00:00
|
|
|
Hash common.Hash `json:"hash"`
|
|
|
|
Input hexutil.Bytes `json:"input"`
|
|
|
|
Nonce hexutil.Uint64 `json:"nonce"`
|
|
|
|
To *common.Address `json:"to"`
|
|
|
|
TransactionIndex *hexutil.Uint64 `json:"transactionIndex"`
|
|
|
|
Value *hexutil.Big `json:"value"`
|
|
|
|
Type hexutil.Uint64 `json:"type"`
|
|
|
|
Accesses *ethtypes.AccessList `json:"accessList,omitempty"`
|
|
|
|
ChainID *hexutil.Big `json:"chainId,omitempty"`
|
|
|
|
V *hexutil.Big `json:"v"`
|
|
|
|
R *hexutil.Big `json:"r"`
|
|
|
|
S *hexutil.Big `json:"s"`
|
2020-10-22 20:39:51 +00:00
|
|
|
}
|
|
|
|
|
2021-05-10 16:34:00 +00:00
|
|
|
// StateOverride is the collection of overridden accounts.
|
|
|
|
type StateOverride map[common.Address]OverrideAccount
|
|
|
|
|
|
|
|
// OverrideAccount indicates the overriding fields of account during the execution of
|
2020-10-22 20:39:51 +00:00
|
|
|
// a message call.
|
2021-04-18 16:39:15 +00:00
|
|
|
// Note, state and stateDiff can't be specified at the same time. If state is
|
2020-10-22 20:39:51 +00:00
|
|
|
// set, message execution will only use the data in the given state. Otherwise
|
|
|
|
// if statDiff is set, all diff will be applied first and then execute the call
|
|
|
|
// message.
|
2021-05-10 16:34:00 +00:00
|
|
|
type OverrideAccount struct {
|
2020-10-22 20:39:51 +00:00
|
|
|
Nonce *hexutil.Uint64 `json:"nonce"`
|
|
|
|
Code *hexutil.Bytes `json:"code"`
|
|
|
|
Balance **hexutil.Big `json:"balance"`
|
|
|
|
State *map[common.Hash]common.Hash `json:"state"`
|
|
|
|
StateDiff *map[common.Hash]common.Hash `json:"stateDiff"`
|
|
|
|
}
|
2021-10-06 11:22:32 +00:00
|
|
|
|
|
|
|
type FeeHistoryResult struct {
|
|
|
|
OldestBlock *hexutil.Big `json:"oldestBlock"`
|
|
|
|
Reward [][]*hexutil.Big `json:"reward,omitempty"`
|
|
|
|
BaseFee []*hexutil.Big `json:"baseFeePerGas,omitempty"`
|
|
|
|
GasUsedRatio []float64 `json:"gasUsedRatio"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// SignTransactionResult represents a RLP encoded signed transaction.
|
|
|
|
type SignTransactionResult struct {
|
|
|
|
Raw hexutil.Bytes `json:"raw"`
|
|
|
|
Tx *ethtypes.Transaction `json:"tx"`
|
|
|
|
}
|
2021-11-17 11:58:52 +00:00
|
|
|
|
|
|
|
type OneFeeHistory struct {
|
|
|
|
BaseFee *big.Int // base fee for each block
|
|
|
|
Reward []*big.Int // each element of the array will have the tip provided to miners for the percentile given
|
|
|
|
GasUsedRatio float64 // the ratio of gas used to the gas limit for each block
|
|
|
|
}
|