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

feat: set native token env var #64

Merged
merged 2 commits into from
Jan 25, 2024
Merged

Conversation

juan518munoz
Copy link

What ❔

Set a native token environment variable: CONTRACTS_L1_NATIVE_ERC20_TOKEN_ADDR on native token deployment.

Note: with the current implementation, if the previously mentioned env var is set, testing will be done with native token variables.

Why ❔

Prevent user from having to set token related environment variables manually, which is error prone.

Checklist

  • PR title corresponds to the body of PR (we generate changelog entries from PRs).
  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • Code has been formatted via zk fmt and zk lint.

Comment on lines +51 to 54
const nativeErc20Testing = process.env.CONTRACTS_L1_NATIVE_ERC20_TOKEN_ADDR ? true : false; // if set, we assume user wants to test native erc20 tokens

let mainWalletPK;
if (nativeErc20Testing) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know is not exactly part of this PR but you could do if (process.env.CONTRACTS_L1_NATIVE_ERC20_TOKEN_ADDR) and it should work fine.

Copy link
Author

Choose a reason for hiding this comment

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

Yes it would, but I though that it would be better to declare a shorter variable once, and then use it three times, than calling calling process.env.CONTRACTS_L1_NATIVE_ERC20_TOKEN_ADDR each time.

Comment on lines 635 to 643
try {
return JSON.parse(
fs.readFileSync(configPath, {
encoding: 'utf-8'
})
);
} catch (e) {
throw e;
}
Copy link
Collaborator

@IAvecilla IAvecilla Jan 20, 2024

Choose a reason for hiding this comment

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

Let me know if I'm overlooking smth, but if you plan to leave the error as is and simply propagate it, you can remove the try/catch block and keep only the parsing function, right?

Copy link
Author

Choose a reason for hiding this comment

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

Correct, I'm still confused about some aspects of the language.

Copy link
Member

@juanbono juanbono left a comment

Choose a reason for hiding this comment

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

LGTM

@jrchatruc jrchatruc enabled auto-merge (squash) January 25, 2024 14:00
@jrchatruc jrchatruc merged commit 2212e89 into native_erc20 Jan 25, 2024
11 of 15 checks passed
@jrchatruc jrchatruc deleted the native_erc20_env_vars branch January 25, 2024 14:00
Oppen pushed a commit that referenced this pull request Feb 9, 2024
* use compatible error codes with the previous version

* update hashes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants