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

Issue: Repeated magic string. #5

Open
CjHare opened this issue May 26, 2022 · 1 comment
Open

Issue: Repeated magic string. #5

CjHare opened this issue May 26, 2022 · 1 comment
Assignees

Comments

@CjHare
Copy link

CjHare commented May 26, 2022

With the same addresses (hardcoded strings) used throughout, replacing all instances with module level constant helps with readability & maintainability.

const instigator = Address.fromString('0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266');

  const INSTIGATOR = Address.fromString('0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266');

....

  handleAddCollateralWhitelist(
    new AddCollateralWhitelist(
      Address.fromString(BOND_MEDIATOR_ADDRESS),
      defaultBigInt,
      defaultBigInt,
      defaultLogType,
      newBlock(),
      newTransaction(INSTIGATOR.toHex()),
      [
        new ethereum.EventParam('daoId', ethereum.Value.fromI32(DAO_ID)),
        new ethereum.EventParam(
          'collateralTokens',
          ethereum.Value.fromAddress(treasuryAddress)
        ),
        new ethereum.EventParam('instigator', ethereum.Value.fromAddress(INSTIGATOR))
      ],
      null
    )
  );

....

  handleAdminChanged(
    new AdminChanged(
      Address.fromString(BOND_MEDIATOR_ADDRESS),
      defaultBigInt,
      defaultBigInt,
      defaultLogType,
      newBlock(),
      newTransaction(INSTIGATOR.toHex()),
      [
        new ethereum.EventParam(
          'previousAdmin',
          ethereum.Value.fromAddress(previousAdmin)
        ),
        new ethereum.EventParam('newAdmin', ethereum.Value.fromAddress(newAdmin))
      ],
      null
    )
  );
@grezle
Copy link
Contributor

grezle commented May 27, 2022

This is true, I can take a look at this, but as everything is reset between runs, I don't expect to pick up any results from previous runs. The address that we pass in only matter for the lifecycle of the test. It might help with readability to bring these values closer to the test though.

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

2 participants