@ -24,6 +24,7 @@ import (
"math/big"
"math/big"
"sort"
"sort"
"strconv"
"strconv"
"strings"
"sync"
"sync"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum"
@ -54,16 +55,16 @@ func (b *Long) UnmarshalGraphQL(input interface{}) error {
switch input := input . ( type ) {
switch input := input . ( type ) {
case string :
case string :
// uncomment to support hex values
// uncomment to support hex values
//if strings.HasPrefix(input, "0x") {
if strings . HasPrefix ( input , "0x" ) {
// // apply leniency and support hex representations of longs.
// apply leniency and support hex representations of longs.
// value, err := hexutil.DecodeUint64(input)
value , err := hexutil . DecodeUint64 ( input )
// *b = Long(value)
* b = Long ( value )
// return err
return err
//} else {
} else {
value , err := strconv . ParseInt ( input , 10 , 64 )
value , err := strconv . ParseInt ( input , 10 , 64 )
* b = Long ( value )
* b = Long ( value )
return err
return err
//}
}
case int32 :
case int32 :
* b = Long ( input )
* b = Long ( input )
case int64 :
case int64 :
@ -156,8 +157,8 @@ func (l *Log) Account(ctx context.Context, args BlockNumberArgs) *Account {
}
}
}
}
func ( l * Log ) Index ( ctx context . Context ) int32 {
func ( l * Log ) Index ( ctx context . Context ) hexutil . Uint64 {
return int32 ( l . log . Index )
return hexutil . Uint64 ( l . log . Index )
}
}
func ( l * Log ) Topics ( ctx context . Context ) [ ] common . Hash {
func ( l * Log ) Topics ( ctx context . Context ) [ ] common . Hash {
@ -391,7 +392,7 @@ func (t *Transaction) Block(ctx context.Context) (*Block, error) {
return block , nil
return block , nil
}
}
func ( t * Transaction ) Index ( ctx context . Context ) ( * int32 , error ) {
func ( t * Transaction ) Index ( ctx context . Context ) ( * hexutil . Uint64 , error ) {
_ , block , err := t . resolve ( ctx )
_ , block , err := t . resolve ( ctx )
if err != nil {
if err != nil {
return nil , err
return nil , err
@ -400,7 +401,7 @@ func (t *Transaction) Index(ctx context.Context) (*int32, error) {
if block == nil {
if block == nil {
return nil , nil
return nil , nil
}
}
index := int32 ( t . index )
index := hexutil . Uint64 ( t . index )
return & index , nil
return & index , nil
}
}
@ -421,7 +422,7 @@ func (t *Transaction) getReceipt(ctx context.Context) (*types.Receipt, error) {
return receipts [ t . index ] , nil
return receipts [ t . index ] , nil
}
}
func ( t * Transaction ) Status ( ctx context . Context ) ( * Long , error ) {
func ( t * Transaction ) Status ( ctx context . Context ) ( * hexutil . Uint64 , error ) {
receipt , err := t . getReceipt ( ctx )
receipt , err := t . getReceipt ( ctx )
if err != nil || receipt == nil {
if err != nil || receipt == nil {
return nil , err
return nil , err
@ -429,25 +430,25 @@ func (t *Transaction) Status(ctx context.Context) (*Long, error) {
if len ( receipt . PostState ) != 0 {
if len ( receipt . PostState ) != 0 {
return nil , nil
return nil , nil
}
}
ret := Long ( receipt . Status )
ret := hexutil . Uint64 ( receipt . Status )
return & ret , nil
return & ret , nil
}
}
func ( t * Transaction ) GasUsed ( ctx context . Context ) ( * Long , error ) {
func ( t * Transaction ) GasUsed ( ctx context . Context ) ( * hexutil . Uint64 , error ) {
receipt , err := t . getReceipt ( ctx )
receipt , err := t . getReceipt ( ctx )
if err != nil || receipt == nil {
if err != nil || receipt == nil {
return nil , err
return nil , err
}
}
ret := Long ( receipt . GasUsed )
ret := hexutil . Uint64 ( receipt . GasUsed )
return & ret , nil
return & ret , nil
}
}
func ( t * Transaction ) CumulativeGasUsed ( ctx context . Context ) ( * Long , error ) {
func ( t * Transaction ) CumulativeGasUsed ( ctx context . Context ) ( * hexutil . Uint64 , error ) {
receipt , err := t . getReceipt ( ctx )
receipt , err := t . getReceipt ( ctx )
if err != nil || receipt == nil {
if err != nil || receipt == nil {
return nil , err
return nil , err
}
}
ret := Long ( receipt . CumulativeGasUsed )
ret := hexutil . Uint64 ( receipt . CumulativeGasUsed )
return & ret , nil
return & ret , nil
}
}
@ -503,12 +504,12 @@ func (t *Transaction) getLogs(ctx context.Context, hash common.Hash) (*[]*Log, e
return & ret , nil
return & ret , nil
}
}
func ( t * Transaction ) Type ( ctx context . Context ) ( * int32 , error ) {
func ( t * Transaction ) Type ( ctx context . Context ) ( * hexutil . Uint64 , error ) {
tx , _ , err := t . resolve ( ctx )
tx , _ , err := t . resolve ( ctx )
if err != nil {
if err != nil {
return nil , err
return nil , err
}
}
txType := int32 ( tx . Type ( ) )
txType := hexutil . Uint64 ( tx . Type ( ) )
return & txType , nil
return & txType , nil
}
}
@ -649,13 +650,13 @@ func (b *Block) resolveReceipts(ctx context.Context) ([]*types.Receipt, error) {
return receipts , nil
return receipts , nil
}
}
func ( b * Block ) Number ( ctx context . Context ) ( Long , error ) {
func ( b * Block ) Number ( ctx context . Context ) ( hexutil . Uint64 , error ) {
header , err := b . resolveHeader ( ctx )
header , err := b . resolveHeader ( ctx )
if err != nil {
if err != nil {
return 0 , err
return 0 , err
}
}
return Long ( header . Number . Uint64 ( ) ) , nil
return hexutil . Uint64 ( header . Number . Uint64 ( ) ) , nil
}
}
func ( b * Block ) Hash ( ctx context . Context ) ( common . Hash , error ) {
func ( b * Block ) Hash ( ctx context . Context ) ( common . Hash , error ) {
@ -664,20 +665,20 @@ func (b *Block) Hash(ctx context.Context) (common.Hash, error) {
return b . hash , nil
return b . hash , nil
}
}
func ( b * Block ) GasLimit ( ctx context . Context ) ( Long , error ) {
func ( b * Block ) GasLimit ( ctx context . Context ) ( hexutil . Uint64 , error ) {
header , err := b . resolveHeader ( ctx )
header , err := b . resolveHeader ( ctx )
if err != nil {
if err != nil {
return 0 , err
return 0 , err
}
}
return Long ( header . GasLimit ) , nil
return hexutil . Uint64 ( header . GasLimit ) , nil
}
}
func ( b * Block ) GasUsed ( ctx context . Context ) ( Long , error ) {
func ( b * Block ) GasUsed ( ctx context . Context ) ( hexutil . Uint64 , error ) {
header , err := b . resolveHeader ( ctx )
header , err := b . resolveHeader ( ctx )
if err != nil {
if err != nil {
return 0 , err
return 0 , err
}
}
return Long ( header . GasUsed ) , nil
return hexutil . Uint64 ( header . GasUsed ) , nil
}
}
func ( b * Block ) BaseFeePerGas ( ctx context . Context ) ( * hexutil . Big , error ) {
func ( b * Block ) BaseFeePerGas ( ctx context . Context ) ( * hexutil . Big , error ) {
@ -793,12 +794,12 @@ func (b *Block) OmmerHash(ctx context.Context) (common.Hash, error) {
return header . UncleHash , nil
return header . UncleHash , nil
}
}
func ( b * Block ) OmmerCount ( ctx context . Context ) ( * int32 , error ) {
func ( b * Block ) OmmerCount ( ctx context . Context ) ( * hexutil . Uint64 , error ) {
block , err := b . resolve ( ctx )
block , err := b . resolve ( ctx )
if err != nil || block == nil {
if err != nil || block == nil {
return nil , err
return nil , err
}
}
count := int32 ( len ( block . Uncles ( ) ) )
count := hexutil . Uint64 ( len ( block . Uncles ( ) ) )
return & count , err
return & count , err
}
}
@ -869,7 +870,7 @@ type BlockNumberArgs struct {
// TODO: Ideally we could use input unions to allow the query to specify the
// TODO: Ideally we could use input unions to allow the query to specify the
// block parameter by hash, block number, or tag but input unions aren't part of the
// block parameter by hash, block number, or tag but input unions aren't part of the
// standard GraphQL schema SDL yet, see: https://github.com/graphql/graphql-spec/issues/488
// standard GraphQL schema SDL yet, see: https://github.com/graphql/graphql-spec/issues/488
Block * hexutil . Uint64
Block * Long
}
}
// NumberOr returns the provided block number argument, or the "current" block number or hash if none
// NumberOr returns the provided block number argument, or the "current" block number or hash if none
@ -900,12 +901,12 @@ func (b *Block) Miner(ctx context.Context, args BlockNumberArgs) (*Account, erro
} , nil
} , nil
}
}
func ( b * Block ) TransactionCount ( ctx context . Context ) ( * int32 , error ) {
func ( b * Block ) TransactionCount ( ctx context . Context ) ( * hexutil . Uint64 , error ) {
block , err := b . resolve ( ctx )
block , err := b . resolve ( ctx )
if err != nil || block == nil {
if err != nil || block == nil {
return nil , err
return nil , err
}
}
count := int32 ( len ( block . Transactions ( ) ) )
count := hexutil . Uint64 ( len ( block . Transactions ( ) ) )
return & count , err
return & count , err
}
}
@ -927,7 +928,7 @@ func (b *Block) Transactions(ctx context.Context) (*[]*Transaction, error) {
return & ret , nil
return & ret , nil
}
}
func ( b * Block ) TransactionAt ( ctx context . Context , args struct { Index int32 } ) ( * Transaction , error ) {
func ( b * Block ) TransactionAt ( ctx context . Context , args struct { Index Long } ) ( * Transaction , error ) {
block , err := b . resolve ( ctx )
block , err := b . resolve ( ctx )
if err != nil || block == nil {
if err != nil || block == nil {
return nil , err
return nil , err
@ -946,7 +947,7 @@ func (b *Block) TransactionAt(ctx context.Context, args struct{ Index int32 }) (
} , nil
} , nil
}
}
func ( b * Block ) OmmerAt ( ctx context . Context , args struct { Index int32 } ) ( * Block , error ) {
func ( b * Block ) OmmerAt ( ctx context . Context , args struct { Index Long } ) ( * Block , error ) {
block , err := b . resolve ( ctx )
block , err := b . resolve ( ctx )
if err != nil || block == nil {
if err != nil || block == nil {
return nil , err
return nil , err
@ -1037,7 +1038,7 @@ func (b *Block) Account(ctx context.Context, args struct {
type CallData struct {
type CallData struct {
From * common . Address // The Ethereum address the call is from.
From * common . Address // The Ethereum address the call is from.
To * common . Address // The Ethereum address the call is to.
To * common . Address // The Ethereum address the call is to.
Gas * hexutil . Uint64 // The amount of gas provided for the call.
Gas * Long // The amount of gas provided for the call.
GasPrice * hexutil . Big // The price of each unit of gas, in wei.
GasPrice * hexutil . Big // The price of each unit of gas, in wei.
MaxFeePerGas * hexutil . Big // The max price of each unit of gas, in wei (1559).
MaxFeePerGas * hexutil . Big // The max price of each unit of gas, in wei (1559).
MaxPriorityFeePerGas * hexutil . Big // The max tip of each unit of gas, in wei (1559).
MaxPriorityFeePerGas * hexutil . Big // The max tip of each unit of gas, in wei (1559).
@ -1047,20 +1048,20 @@ type CallData struct {
// CallResult encapsulates the result of an invocation of the `call` accessor.
// CallResult encapsulates the result of an invocation of the `call` accessor.
type CallResult struct {
type CallResult struct {
data hexutil . Bytes // The return data from the call
data hexutil . Bytes // The return data from the call
gasUsed Long // The amount of gas used
gasUsed hexutil . Uint64 // The amount of gas used
status Long // The return status of the call - 0 for failure or 1 for success.
status hexutil . Uint64 // The return status of the call - 0 for failure or 1 for success.
}
}
func ( c * CallResult ) Data ( ) hexutil . Bytes {
func ( c * CallResult ) Data ( ) hexutil . Bytes {
return c . data
return c . data
}
}
func ( c * CallResult ) GasUsed ( ) Long {
func ( c * CallResult ) GasUsed ( ) hexutil . Uint64 {
return c . gasUsed
return c . gasUsed
}
}
func ( c * CallResult ) Status ( ) Long {
func ( c * CallResult ) Status ( ) hexutil . Uint64 {
return c . status
return c . status
}
}
@ -1071,32 +1072,31 @@ func (b *Block) Call(ctx context.Context, args struct {
if err != nil {
if err != nil {
return nil , err
return nil , err
}
}
status := Long ( 1 )
status := hexutil . Uint64 ( 1 )
if result . Failed ( ) {
if result . Failed ( ) {
status = 0
status = 0
}
}
return & CallResult {
return & CallResult {
data : result . ReturnData ,
data : result . ReturnData ,
gasUsed : Long ( result . UsedGas ) ,
gasUsed : hexutil . Uint64 ( result . UsedGas ) ,
status : status ,
status : status ,
} , nil
} , nil
}
}
func ( b * Block ) EstimateGas ( ctx context . Context , args struct {
func ( b * Block ) EstimateGas ( ctx context . Context , args struct {
Data ethapi . TransactionArgs
Data ethapi . TransactionArgs
} ) ( Long , error ) {
} ) ( hexutil . Uint64 , error ) {
gas , err := ethapi . DoEstimateGas ( ctx , b . r . backend , args . Data , * b . numberOrHash , b . r . backend . RPCGasCap ( ) )
return ethapi . DoEstimateGas ( ctx , b . r . backend , args . Data , * b . numberOrHash , b . r . backend . RPCGasCap ( ) )
return Long ( gas ) , err
}
}
type Pending struct {
type Pending struct {
r * Resolver
r * Resolver
}
}
func ( p * Pending ) TransactionCount ( ctx context . Context ) ( int32 , error ) {
func ( p * Pending ) TransactionCount ( ctx context . Context ) ( hexutil . Uint64 , error ) {
txs , err := p . r . backend . GetPoolTransactions ( )
txs , err := p . r . backend . GetPoolTransactions ( )
return int32 ( len ( txs ) ) , err
return hexutil . Uint64 ( len ( txs ) ) , err
}
}
func ( p * Pending ) Transactions ( ctx context . Context ) ( * [ ] * Transaction , error ) {
func ( p * Pending ) Transactions ( ctx context . Context ) ( * [ ] * Transaction , error ) {
@ -1135,24 +1135,23 @@ func (p *Pending) Call(ctx context.Context, args struct {
if err != nil {
if err != nil {
return nil , err
return nil , err
}
}
status := Long ( 1 )
status := hexutil . Uint64 ( 1 )
if result . Failed ( ) {
if result . Failed ( ) {
status = 0
status = 0
}
}
return & CallResult {
return & CallResult {
data : result . ReturnData ,
data : result . ReturnData ,
gasUsed : Long ( result . UsedGas ) ,
gasUsed : hexutil . Uint64 ( result . UsedGas ) ,
status : status ,
status : status ,
} , nil
} , nil
}
}
func ( p * Pending ) EstimateGas ( ctx context . Context , args struct {
func ( p * Pending ) EstimateGas ( ctx context . Context , args struct {
Data ethapi . TransactionArgs
Data ethapi . TransactionArgs
} ) ( Long , error ) {
} ) ( hexutil . Uint64 , error ) {
pendingBlockNr := rpc . BlockNumberOrHashWithNumber ( rpc . PendingBlockNumber )
pendingBlockNr := rpc . BlockNumberOrHashWithNumber ( rpc . PendingBlockNumber )
gas , err := ethapi . DoEstimateGas ( ctx , p . r . backend , args . Data , pendingBlockNr , p . r . backend . RPCGasCap ( ) )
return ethapi . DoEstimateGas ( ctx , p . r . backend , args . Data , pendingBlockNr , p . r . backend . RPCGasCap ( ) )
return Long ( gas ) , err
}
}
// Resolver is the top-level object in the GraphQL hierarchy.
// Resolver is the top-level object in the GraphQL hierarchy.
@ -1260,8 +1259,8 @@ func (r *Resolver) SendRawTransaction(ctx context.Context, args struct{ Data hex
// FilterCriteria encapsulates the arguments to `logs` on the root resolver object.
// FilterCriteria encapsulates the arguments to `logs` on the root resolver object.
type FilterCriteria struct {
type FilterCriteria struct {
FromBlock * hexutil . Uint64 // beginning of the queried range, nil means genesis block
FromBlock * Long // beginning of the queried range, nil means genesis block
ToBlock * hexutil . Uint64 // end of the range, nil means latest block
ToBlock * Long // end of the range, nil means latest block
Addresses * [ ] common . Address // restricts matches to events created by specific contracts
Addresses * [ ] common . Address // restricts matches to events created by specific contracts
// The Topic list restricts matches to particular event topics. Each event has a list
// The Topic list restricts matches to particular event topics. Each event has a list