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

Unlock constant address from JSON #1234

Open
vlopes11 opened this issue Dec 19, 2023 · 0 comments
Open

Unlock constant address from JSON #1234

vlopes11 opened this issue Dec 19, 2023 · 0 comments

Comments

@vlopes11
Copy link
Contributor

At present, the constants.json file supports fundamental types like &'static str, u64, among others. However, it would be advantageous to enable the definition of complex types as constants, including addresses, to eliminate the need for frequent parsing during value retrieval.

For instance, consider the gas token address, which is currently represented as a string in constants.json and necessitates parsing every time a transaction hook is called. However, this might not be straightforward due to the context-dependent nature of addresses: their concrete implementation varies depending on the selected context, making them unavailable during module development because the runtime determines the context.

An alternative approach could be representing addresses as [u8; 32] in the constant definition. Since the compiler can optimize C::Address::from([u8; 32]), this would result in a transparent operation if the address' internal representation is equivalent to such an array (which is typically the case).

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

No branches or pull requests

1 participant