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

Allow to use eth private key that starts with 0x #1887

Closed
wants to merge 2 commits into from
Closed

Conversation

buberdds
Copy link
Contributor

@buberdds buberdds commented Apr 11, 2024

Closes #1868

We cannot call stripHexPrefix in a one place while saving a form step, because we need to support form forward/backward functionality.

Copy link

github-actions bot commented Apr 11, 2024

Deployed to Cloudflare Pages

Latest commit: 230864b8533ec351b7b11bb908588031d3f67ef0
Status:✅ Deploy successful!
Preview URL: https://3dc91cc5.oasis-wallet.pages.dev

@buberdds buberdds marked this pull request as ready for review April 15, 2024 07:17
@buberdds buberdds requested a review from lukaw3d April 16, 2024 06:20
} catch {
return false
}
}
export const isValidEthPrivateKeyLength = (ethPrivateKey: string) => ethPrivateKey.length === 64
export const isValidEthPrivateKeyLength = (ethPrivateKey: string) =>
stripHexPrefix(ethPrivateKey).length === 64
Copy link
Member

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))
Copy link
Member

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 :/

Copy link
Member

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)

Copy link
Contributor Author

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

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

Successfully merging this pull request may close these issues.

Trim 0x from the Ethereum Private key
2 participants