Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] BSC related change #109

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/ethereum/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ func (c *EthereumClient) ParseOps(
var ops []*RosettaTypes.Operation

// Compute fee operations
feeOps := services.FeeOps(tx)
feeOps := services.FeeOps(tx, sdkTypes.Currency)
ops = append(ops, feeOps...)

traceOps := services.TraceOps(tx.Trace, len(ops))
traceOps := services.TraceOps(tx.Trace, len(ops), sdkTypes.Currency)
ops = append(ops, traceOps...)

return ops, nil
Expand Down
23 changes: 23 additions & 0 deletions mocks/services/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions services/construction/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
evmClient "github.com/coinbase/rosetta-geth-sdk/client"
"github.com/coinbase/rosetta-geth-sdk/configuration"
RosettaTypes "github.com/coinbase/rosetta-sdk-go/types"
Eth "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
EthTypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/rpc"
Expand Down Expand Up @@ -194,4 +195,10 @@ type Client interface {
ParseOps(
tx *evmClient.LoadedTransaction,
) ([]*RosettaTypes.Operation, error)

// EstimateGas tries to estimate the gas needed to execute a specific transaction based on
// the current pending state of the backend blockchain. There is no guarantee that this is
// the true gas limit requirement as other transactions may be added or removed by miners,
// but it should provide a basis for setting a reasonable default.
EstimateGas(ctx context.Context, msg Eth.CallMsg) (uint64, error)
}
15 changes: 8 additions & 7 deletions services/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func TransferOps(tx *evmClient.LoadedTransaction, startIndex int) []*RosettaType
return ops
}

func FeeOps(tx *evmClient.LoadedTransaction) []*RosettaTypes.Operation {
func FeeOps(tx *evmClient.LoadedTransaction, native_currency *RosettaTypes.Currency) []*RosettaTypes.Operation {
var minerEarnedAmount *big.Int
if tx.FeeBurned == nil {
minerEarnedAmount = tx.FeeAmount
Expand All @@ -157,7 +157,7 @@ func FeeOps(tx *evmClient.LoadedTransaction) []*RosettaTypes.Operation {
Account: &RosettaTypes.AccountIdentifier{
Address: evmClient.MustChecksum(tx.From.String()),
},
Amount: evmClient.Amount(new(big.Int).Neg(minerEarnedAmount), sdkTypes.Currency),
Amount: evmClient.Amount(new(big.Int).Neg(minerEarnedAmount), native_currency),
},

{
Expand All @@ -174,7 +174,7 @@ func FeeOps(tx *evmClient.LoadedTransaction) []*RosettaTypes.Operation {
Account: &RosettaTypes.AccountIdentifier{
Address: evmClient.MustChecksum(feeRewarder),
},
Amount: evmClient.Amount(minerEarnedAmount, sdkTypes.Currency),
Amount: evmClient.Amount(minerEarnedAmount, native_currency),
},
}

Expand All @@ -189,7 +189,7 @@ func FeeOps(tx *evmClient.LoadedTransaction) []*RosettaTypes.Operation {
Type: sdkTypes.FeeOpType,
Status: RosettaTypes.String(sdkTypes.SuccessStatus),
Account: evmClient.Account(tx.From),
Amount: evmClient.Amount(new(big.Int).Neg(tx.FeeBurned), sdkTypes.Currency),
Amount: evmClient.Amount(new(big.Int).Neg(tx.FeeBurned), native_currency),
}

ops = append(ops, burntOp)
Expand All @@ -203,6 +203,7 @@ func FeeOps(tx *evmClient.LoadedTransaction) []*RosettaTypes.Operation {
func TraceOps(
calls []*evmClient.FlatCall,
startIndex int,
native_currency *RosettaTypes.Currency,
) []*RosettaTypes.Operation { // nolint: gocognit
var ops []*RosettaTypes.Operation
if len(calls) == 0 {
Expand Down Expand Up @@ -250,7 +251,7 @@ func TraceOps(
},
Amount: &RosettaTypes.Amount{
Value: new(big.Int).Neg(trace.Value).String(),
Currency: sdkTypes.Currency,
Currency: native_currency,
},
Metadata: metadata,
}
Expand Down Expand Up @@ -311,7 +312,7 @@ func TraceOps(
},
Amount: &RosettaTypes.Amount{
Value: trace.Value.String(),
Currency: sdkTypes.Currency,
Currency: native_currency,
},
Metadata: metadata,
}
Expand Down Expand Up @@ -355,7 +356,7 @@ func TraceOps(
},
Amount: &RosettaTypes.Amount{
Value: new(big.Int).Neg(val).String(),
Currency: sdkTypes.Currency,
Currency: native_currency,
},
})
}
Expand Down
Loading