Skip to content

Commit

Permalink
feat: EthAPI: Add FilecoinAddressToEthAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
simlecode committed Feb 27, 2023
1 parent 9ff47bb commit 5c86c21
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/submodule/eth/dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ func (e *ethAPIDummy) EthAddressToFilecoinAddress(ctx context.Context, ethAddres
return address.Undef, ErrModuleDisabled
}

func (e *ethAPIDummy) FilecoinAddressToEthAddress(ctx context.Context, filecoinAddress address.Address) (types.EthAddress, error) {
return types.EthAddress{}, ErrModuleDisabled
}

func (e *ethAPIDummy) EthGetBlockTransactionCountByNumber(ctx context.Context, blkNum types.EthUint64) (types.EthUint64, error) {
return 0, ErrModuleDisabled
}
Expand Down
4 changes: 4 additions & 0 deletions app/submodule/eth/eth_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ func (a *ethAPI) EthAddressToFilecoinAddress(ctx context.Context, ethAddress typ
return ethAddress.ToFilecoinAddress()
}

func (a *ethAPI) FilecoinAddressToEthAddress(ctx context.Context, filecoinAddress address.Address) (types.EthAddress, error) {
return types.EthAddressFromFilecoinAddress(filecoinAddress)
}

func (a *ethAPI) countTipsetMsgs(ctx context.Context, ts *types.TipSet) (int, error) {
msgs, err := a.em.chainModule.MessageStore.MessagesForTipset(ts)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions venus-shared/api/chain/v1/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type IETH interface {
EthAccounts(ctx context.Context) ([]types.EthAddress, error) //perm:read
// EthAddressToFilecoinAddress converts an EthAddress into an f410 Filecoin Address
EthAddressToFilecoinAddress(ctx context.Context, ethAddress types.EthAddress) (address.Address, error) //perm:read
// FilecoinAddressToEthAddress converts an f410 or f0 Filecoin Address to an EthAddress
FilecoinAddressToEthAddress(ctx context.Context, filecoinAddress address.Address) (types.EthAddress, error) //perm:read
// EthBlockNumber returns the height of the latest (heaviest) TipSet
EthBlockNumber(ctx context.Context) (types.EthUint64, error) //perm:read
// EthGetBlockTransactionCountByNumber returns the number of messages in the TipSet
Expand Down
16 changes: 16 additions & 0 deletions venus-shared/api/chain/v1/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ curl http://<ip>:<port>/rpc/v1 -X POST -H "Content-Type: application/json" -H "
* [EthMaxPriorityFeePerGas](#ethmaxpriorityfeepergas)
* [EthProtocolVersion](#ethprotocolversion)
* [EthSendRawTransaction](#ethsendrawtransaction)
* [FilecoinAddressToEthAddress](#filecoinaddresstoethaddress)
* [NetListening](#netlistening)
* [NetVersion](#netversion)
* [Web3ClientVersion](#web3clientversion)
Expand Down Expand Up @@ -2633,6 +2634,21 @@ Inputs:

Response: `"0x0707070707070707070707070707070707070707070707070707070707070707"`

### FilecoinAddressToEthAddress
FilecoinAddressToEthAddress converts an f410 or f0 Filecoin Address to an EthAddress


Perms: read

Inputs:
```json
[
"f01234"
]
```

Response: `"0x0707070707070707070707070707070707070707"`

### NetListening


Expand Down
15 changes: 15 additions & 0 deletions venus-shared/api/chain/v1/mock/mock_fullnode.go

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

4 changes: 4 additions & 0 deletions venus-shared/api/chain/v1/proxy_gen.go

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

1 change: 1 addition & 0 deletions venus-shared/compatible-checks/api-diff.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v1.FullNode <> github.c
+ Concurrent
- CreateBackup
- Discover
+ FilecoinAddressToEthAddress
+ GasBatchEstimateMessageGas
> GasEstimateMessageGas {[func(context.Context, *types.Message, *types.MessageSendSpec, types.TipSetKey) (*types.Message, error) <> func(context.Context, *types.Message, *api.MessageSendSpec, types.TipSetKey) (*types.Message, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported fields count: 3 != 2; nested=nil}}}}
+ GetActor
Expand Down
1 change: 1 addition & 0 deletions venus-shared/compatible-checks/api-perm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ v1: github.com/filecoin-project/venus/venus-shared/api/chain/v1 <> github.com/fi
- IMinerState.StateMinerSectorSize
- IMinerState.StateMinerWorkerAddress
- EthSubscriber.EthSubscription
- IETH.FilecoinAddressToEthAddress
- IMessagePool.GasBatchEstimateMessageGas
- IMessagePool.MpoolDeleteByAdress
- IMessagePool.MpoolPublishByAddr
Expand Down

0 comments on commit 5c86c21

Please sign in to comment.