Implementation of toEthAddress function #15
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request adds the required functionality related to issue #4
Developers can utilize this function to convert a f4 FileAddress type into an EthAddress.
Approach and implementation
The starting point was PR #16 which already included the implementation of this function. However, unit tests for various types of addresses were missing. The missing unit tests are added while retaining the existing fuzz tests with minor changes.
Validate function changes
The
validate
function checks the FilAddress in bytes format, which includes a protocol byte and payload.The previous implementation was failing for valid input because it was comparing the bytes length with 10:
This approach is incorrect, as the f0 format contains a protocol byte and payload, which can be a maximum of 10 bytes long. An example is provided in the Filecoin spec document, in the last example in section 6.1.3.1.
Discussion
validate
function also include checks for minimum length for f0 and f4 addresses? For example, should 0x00 be considered a valid f0 address?