Skip to content

Commit

Permalink
add ETH addrs API to Gateway (filecoin-project#11979)
Browse files Browse the repository at this point in the history
  • Loading branch information
aarshkshah1992 authored and ribasushi committed May 16, 2024
1 parent 7902ddb commit 11fd750
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/api_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ type Gateway interface {
Version(context.Context) (APIVersion, error)
Discover(context.Context) (apitypes.OpenRPCDocument, error)

EthAddressToFilecoinAddress(ctx context.Context, ethAddress ethtypes.EthAddress) (address.Address, error)
FilecoinAddressToEthAddress(ctx context.Context, filecoinAddress address.Address) (ethtypes.EthAddress, error)
EthAccounts(ctx context.Context) ([]ethtypes.EthAddress, error)
EthBlockNumber(ctx context.Context) (ethtypes.EthUint64, error)
EthGetBlockTransactionCountByNumber(ctx context.Context, blkNum ethtypes.EthUint64) (ethtypes.EthUint64, error)
Expand Down
26 changes: 26 additions & 0 deletions api/proxy_gen.go

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

Binary file modified build/openrpc/full.json.gz
Binary file not shown.
Binary file modified build/openrpc/gateway.json.gz
Binary file not shown.
Binary file modified build/openrpc/miner.json.gz
Binary file not shown.
Binary file modified build/openrpc/worker.json.gz
Binary file not shown.
9 changes: 9 additions & 0 deletions gateway/proxy_eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-jsonrpc"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
Expand All @@ -26,6 +27,14 @@ func (gw *Node) EthAccounts(ctx context.Context) ([]ethtypes.EthAddress, error)
return []ethtypes.EthAddress{}, nil
}

func (gw *Node) EthAddressToFilecoinAddress(ctx context.Context, ethAddress ethtypes.EthAddress) (address.Address, error) {
return gw.target.EthAddressToFilecoinAddress(ctx, ethAddress)
}

func (gw *Node) FilecoinAddressToEthAddress(ctx context.Context, filecoinAddress address.Address) (ethtypes.EthAddress, error) {
return gw.target.FilecoinAddressToEthAddress(ctx, filecoinAddress)
}

func (gw *Node) EthBlockNumber(ctx context.Context) (ethtypes.EthUint64, error) {
if err := gw.limit(ctx, chainRateLimitTokens); err != nil {
return 0, err
Expand Down

0 comments on commit 11fd750

Please sign in to comment.