diff --git a/app/submodule/eth/dummy.go b/app/submodule/eth/dummy.go index a7aa552681..2dff5ec037 100644 --- a/app/submodule/eth/dummy.go +++ b/app/submodule/eth/dummy.go @@ -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 } diff --git a/app/submodule/eth/eth_api.go b/app/submodule/eth/eth_api.go index 215f7bcbe4..7fd8bf4b86 100644 --- a/app/submodule/eth/eth_api.go +++ b/app/submodule/eth/eth_api.go @@ -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 { diff --git a/venus-shared/api/chain/v1/eth.go b/venus-shared/api/chain/v1/eth.go index eff0dc30f8..ce3499a8ce 100644 --- a/venus-shared/api/chain/v1/eth.go +++ b/venus-shared/api/chain/v1/eth.go @@ -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 diff --git a/venus-shared/api/chain/v1/method.md b/venus-shared/api/chain/v1/method.md index e64c585800..6afc1133a2 100644 --- a/venus-shared/api/chain/v1/method.md +++ b/venus-shared/api/chain/v1/method.md @@ -89,6 +89,7 @@ curl http://:/rpc/v1 -X POST -H "Content-Type: application/json" -H " * [EthMaxPriorityFeePerGas](#ethmaxpriorityfeepergas) * [EthProtocolVersion](#ethprotocolversion) * [EthSendRawTransaction](#ethsendrawtransaction) + * [FilecoinAddressToEthAddress](#filecoinaddresstoethaddress) * [NetListening](#netlistening) * [NetVersion](#netversion) * [Web3ClientVersion](#web3clientversion) @@ -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 diff --git a/venus-shared/api/chain/v1/mock/mock_fullnode.go b/venus-shared/api/chain/v1/mock/mock_fullnode.go index 33da7a0e84..79cc9b792f 100644 --- a/venus-shared/api/chain/v1/mock/mock_fullnode.go +++ b/venus-shared/api/chain/v1/mock/mock_fullnode.go @@ -965,6 +965,21 @@ func (mr *MockFullNodeMockRecorder) EthUnsubscribe(arg0, arg1 interface{}) *gomo return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EthUnsubscribe", reflect.TypeOf((*MockFullNode)(nil).EthUnsubscribe), arg0, arg1) } +// FilecoinAddressToEthAddress mocks base method. +func (m *MockFullNode) FilecoinAddressToEthAddress(arg0 context.Context, arg1 address.Address) (types.EthAddress, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "FilecoinAddressToEthAddress", arg0, arg1) + ret0, _ := ret[0].(types.EthAddress) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// FilecoinAddressToEthAddress indicates an expected call of FilecoinAddressToEthAddress. +func (mr *MockFullNodeMockRecorder) FilecoinAddressToEthAddress(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FilecoinAddressToEthAddress", reflect.TypeOf((*MockFullNode)(nil).FilecoinAddressToEthAddress), arg0, arg1) +} + // GasBatchEstimateMessageGas mocks base method. func (m *MockFullNode) GasBatchEstimateMessageGas(arg0 context.Context, arg1 []*types0.EstimateMessage, arg2 uint64, arg3 types0.TipSetKey) ([]*types0.EstimateResult, error) { m.ctrl.T.Helper() diff --git a/venus-shared/api/chain/v1/proxy_gen.go b/venus-shared/api/chain/v1/proxy_gen.go index b2d5a42785..5a1787eb44 100644 --- a/venus-shared/api/chain/v1/proxy_gen.go +++ b/venus-shared/api/chain/v1/proxy_gen.go @@ -863,6 +863,7 @@ type IETHStruct struct { EthMaxPriorityFeePerGas func(ctx context.Context) (types.EthBigInt, error) `perm:"read"` EthProtocolVersion func(ctx context.Context) (types.EthUint64, error) `perm:"read"` EthSendRawTransaction func(ctx context.Context, rawTx types.EthBytes) (types.EthHash, error) `perm:"read"` + FilecoinAddressToEthAddress func(ctx context.Context, filecoinAddress address.Address) (types.EthAddress, error) `perm:"read"` NetListening func(ctx context.Context) (bool, error) `perm:"read"` NetVersion func(ctx context.Context) (string, error) `perm:"read"` Web3ClientVersion func(ctx context.Context) (string, error) `perm:"read"` @@ -944,6 +945,9 @@ func (s *IETHStruct) EthProtocolVersion(p0 context.Context) (types.EthUint64, er func (s *IETHStruct) EthSendRawTransaction(p0 context.Context, p1 types.EthBytes) (types.EthHash, error) { return s.Internal.EthSendRawTransaction(p0, p1) } +func (s *IETHStruct) FilecoinAddressToEthAddress(p0 context.Context, p1 address.Address) (types.EthAddress, error) { + return s.Internal.FilecoinAddressToEthAddress(p0, p1) +} func (s *IETHStruct) NetListening(p0 context.Context) (bool, error) { return s.Internal.NetListening(p0) } diff --git a/venus-shared/compatible-checks/api-diff.txt b/venus-shared/compatible-checks/api-diff.txt index 7dcdf06f5f..e1d57efa9b 100644 --- a/venus-shared/compatible-checks/api-diff.txt +++ b/venus-shared/compatible-checks/api-diff.txt @@ -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 diff --git a/venus-shared/compatible-checks/api-perm.txt b/venus-shared/compatible-checks/api-perm.txt index 2da634626e..8e098be205 100644 --- a/venus-shared/compatible-checks/api-perm.txt +++ b/venus-shared/compatible-checks/api-perm.txt @@ -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