-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Allow to use eth private key that starts with 0x |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { PayloadAction } from '@reduxjs/toolkit' | ||
import { createSlice } from 'utils/@reduxjs/toolkit' | ||
import { EvmAccounts } from './types' | ||
import { privateToEthAddress } from '../../lib/eth-helpers' | ||
import { privateToEthAddress, stripHexPrefix } from '../../lib/eth-helpers' | ||
|
||
export const initialState: EvmAccounts = {} | ||
|
||
|
@@ -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 commentThe 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 commentThe 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) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is alter PR #1923 |
||
state[ethAddress] = { | ||
ethPrivateKey: action.payload.ethPrivateKey, | ||
ethAddress: ethAddress, | ||
|
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'