-
Notifications
You must be signed in to change notification settings - Fork 45
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
Allow to use eth private key that starts with 0x #1887
Conversation
Deployed to Cloudflare Pages
|
} catch { | ||
return false | ||
} | ||
} | ||
export const isValidEthPrivateKeyLength = (ethPrivateKey: string) => ethPrivateKey.length === 64 | ||
export const isValidEthPrivateKeyLength = (ethPrivateKey: string) => | ||
stripHexPrefix(ethPrivateKey).length === 64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's .replace('0x', '')
a few lines below - should make consistent, either stripHexPrefix or replace('0x'
@@ -10,7 +10,7 @@ export const evmAccountsSlice = createSlice({ | |||
initialState, | |||
reducers: { | |||
add(state, action: PayloadAction<{ ethPrivateKey: string }>) { | |||
const ethAddress = privateToEthAddress(action.payload.ethPrivateKey) | |||
const ethAddress = privateToEthAddress(stripHexPrefix(action.payload.ethPrivateKey)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like how far this has spread :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to reduce mistakes, I'd either isolate 0x prefixes more (mz/privKey...lw/privKey)
or add parsing to all functions that consume it (e.g. privateToEthAddress)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is alter PR #1923
Closes #1868
We cannot call
stripHexPrefix
in a one place while saving a form step, because we need to support form forward/backward functionality.