Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BCFR-147] - Add DecodeHook to convert between string and common.Address types #14508

Draft
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

Farber98
Copy link
Contributor

@Farber98 Farber98 commented Sep 20, 2024

Task Description:

Add an EVM exclusive modifier/hook that changes onchain common.Address type to string.

This PR:

Adds addressStringDecodeHook to convert between string and common.Address types. It handles the following conversions:

  • string or *string -> common.Address or *common.Address
  • common.Address or *common.Address -> string or *string

Ticket:

@Farber98 Farber98 changed the title add hook to parse addresses as string [BCFR-147] - Add DecodeHook to convert between string and common.Address types Sep 21, 2024
@Farber98 Farber98 marked this pull request as ready for review September 23, 2024 10:29
@Farber98 Farber98 requested review from Atrax1, ilija42, silaslenihan and EasterTheBunny and removed request for a team, RensR, matYang, RayXpub, elatoskinas and Atrax1 September 23, 2024 10:29
Copy link
Contributor

@ilija42 ilija42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you run this in a LOOP this won't work because here the contract type will still have common.Address types for fields, which is why we need a codec modifer too.

EasterTheBunny
EasterTheBunny previously approved these changes Sep 23, 2024
Copy link
Contributor

@EasterTheBunny EasterTheBunny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small change, but looks like it will work.

Comment on lines +183 to +184
stringType, stringPtrType := reflect.TypeOf(""), reflect.PointerTo(reflect.TypeOf(""))
addressType, addressPtrType := reflect.TypeOf(common.Address{}), reflect.TypeOf(&common.Address{})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These can be constants outside the function scope. This would save them being declared every time the function runs.

@Farber98 Farber98 marked this pull request as draft September 23, 2024 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants