- 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:
- Rename
camelCase to snakeToCamelCase
- Add assertion that the input is
snake_case and SCREAMING_SNAKE_CASE
getSignedReplayProtectionPacketHashgetSignedreplayprotectionPacketHashTo Reproduce:
Setup
git clone git@github.com:danfinlay/eip712-codegen.git git checkout 73b411e83250755c2a1bd068d9f5eaf7b42be039 cd eip712-codegen yarn installRun
node cli.js --input sampleTypes.js --entryPoints ReplayProtection > ReplayProtection.solRoot Cause
It seems the function
camelCaseis not being called properly.For example
eip712-codegen/index.ts
Lines 5 to 9 in 73b411e
camelCase("FooBar")fooBarfoobarIt seems the root cause is that the
camelCaseabove is meant to convertsnake_caseorSCREAMING_SNAKE_CASEintocamelCase.Input:
camelCase("foo_bar")Expected Output:
fooBarActual Output:
fooBar(same as Expected Output)Input:
camelCase("FOO_BAR")Expected Output:
fooBarActual Output:
fooBar(same as Expected Output)Therefore, I'd suggest make the following update:
camelCasetosnakeToCamelCasesnake_caseandSCREAMING_SNAKE_CASE