Skip to content

The camelCase function was not called properly #13

@xinbenlv

Description

@xinbenlv
  • Expected Output: getSignedReplayProtectionPacketHash
  • Actual Output: getSignedreplayprotectionPacketHash

To Reproduce:

Setup

git clone git@github.com:danfinlay/eip712-codegen.git
git checkout 73b411e83250755c2a1bd068d9f5eaf7b42be039
cd eip712-codegen
yarn install

Run

node cli.js --input sampleTypes.js --entryPoints ReplayProtection > ReplayProtection.sol

Root Cause

It seems the function camelCase is not being called properly.

For example

function camelCase (str) {
return str.toLowerCase().replace(/_(.)/g, function(match, group1) {
return group1.toUpperCase();
});
}

  • Input: camelCase("FooBar")
  • Expected Output: fooBar
  • Actual Output: foobar

It seems the root cause is that the camelCase above is meant to convert snake_case or SCREAMING_SNAKE_CASE into camelCase.

  • Input: camelCase("foo_bar")

  • Expected Output: fooBar

  • Actual Output: fooBar (same as Expected Output)

  • Input: camelCase("FOO_BAR")

  • Expected Output: fooBar

  • Actual Output: fooBar (same as Expected Output)

Therefore, I'd suggest make the following update:

  1. Rename camelCase to snakeToCamelCase
  2. Add assertion that the input is snake_case and SCREAMING_SNAKE_CASE

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions