firefly-cli icon indicating copy to clipboard operation
firefly-cli copied to clipboard

Ensuring HexAddress is Wrapped in String format and as HexAddress

Open Philip-21 opened this issue 1 year ago • 7 comments

This is pr fixes for #230

@nguyer @awrichar @peterbroadhurst I have been able to implement the fix for issue #230 ensure the HexAddress are wrapped properly please, I would like reviews

Philip-21 avatar Dec 19 '23 14:12 Philip-21

Hey @Philip-21. Sorry I probably should have steered you in the direction of the existing code in the firefly-signer library that we already have that does these sorts of things. Two places you might want to look are:

  • https://github.com/hyperledger/firefly-signer/blob/main/pkg/ethtypes/address.go
  • https://github.com/hyperledger/firefly-signer/blob/main/pkg/ethtypes/hexbytes.go

I'd rather that we use the existing library to handle parsing, validation, or conversion of these types, rather than creating another implementation in an additional repo. If there's functionality missing in firefly-signer that we need here, it would be great to add it to the shared library.

nguyer avatar Dec 19 '23 19:12 nguyer

@nguyer I have been able to use the firefly-signer library to handle validation and parsing. what do you think of the changes I made ?

Philip-21 avatar Dec 25 '23 20:12 Philip-21

@Philip-21 Looks like there are compilation errors now:

Error: ../internal/tokens/erc1155/erc1155_provider.go:93:41: cannot convert loc["address"] (map index expression of type string) to type types.HexAddress
# github.com/hyperledger/firefly-cli/internal/tokens/erc20erc721
Error: ../internal/tokens/erc20erc721/erc20_erc721_provider.go:92:40: cannot convert loc["address"] (map index expression of type string) to type types.HexAddress
Error: ../internal/tokens/erc20erc721/erc20_erc721_provider.go:103:58: invalid operation: factoryAddress != "" (mismatched types types.HexAddress and untyped string)
make: *** [Makefile:25: build] Error 2
Error: Process completed with exit code 2.

nguyer avatar Jan 05 '24 20:01 nguyer

@nguyer please i would like you to review my code , i am still trying to figure out why the checks are failing i was able to tackle the compilation error , but i still have failing e2e tests

Philip-21 avatar Jan 14 '24 17:01 Philip-21

@nguyer, these are error messages i got from the e2e tests

DEBUG evmconnect: FF21040: Invalid listener options: FF23036: Invalid event filter: {"address":"783688521890864681654499112172336319967459785509","event":{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"uint256","name":"type_id","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"TokenPoolCreation","type":"event"}}:

It seems the error is related to an invalid event filter in Ethereum. Specifically, it seems to be related to the event filter for "TokenPoolCreation" on a contract with address "783688521890864681654499112172336319967459785509".

Maybe, the address isn't defined well.

Philip-21 avatar Jan 24 '24 21:01 Philip-21

783688521890864681654499112172336319967459785509 looks like something that was an address which may have been converted to a number. Based on what I see in the E2E test log:

initializing token providers
initializing tokens on member 0
Error: http://localhost:5110/api/v1/init [500] {"statusCode":500,"message":"Internal server error"}

I am guessing that the token connector config or environment variables aren't getting written correctly with these changes

nguyer avatar Feb 06 '24 20:02 nguyer

Contributor

Yes these values don't have the proper Hexaddress format which are meant to be in 20 byte [] type, based on the firefly-signer library the address must be of 20 byte[] type. the unit tests i wrote, gives different examples of how i defined the hexvalues in 20 byte []type

Philip-21 avatar Feb 07 '24 04:02 Philip-21