Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

80 derivation path localstorage #94

Merged
merged 3 commits into from
Nov 24, 2019
Merged

Conversation

0xjocke
Copy link
Contributor

@0xjocke 0xjocke commented Nov 23, 2019

Create a new derivationPathChange action.

  • This action will set signer
  • Update localstorage
  • And finally, update redux store

Also set the initial state of the derivation path based on localstorage.
This will still will only be used for ledger wallets thanks to the getSignerConfig in snxJSConnector.js

Also a tiny refactor of setting the theme, see commit msg.
#80

- This action will set signer
- Update localstorage
- And finally update redux store
Setting localstorage is a side effect. So just a we would put a fetch call in the action, changing the localstorage should be done in the action.
@0xjocke 0xjocke requested a review from 0xclem November 23, 2019 22:48
@0xclem 0xclem merged commit 83580c6 into staging Nov 24, 2019
@0xclem 0xclem deleted the 80-derivation-path-localstorage branch November 24, 2019 23:04
@0xclem 0xclem restored the 80-derivation-path-localstorage branch November 25, 2019 04:08
@0xclem
Copy link
Contributor

0xclem commented Nov 25, 2019

@bachstatter just reverted this one.

I think localStorage.getItem('derivationPath') in index.js might break Trezor. We need to make sure to set derivationPath to null when this wallet is selected.

@0xjocke
Copy link
Contributor Author

0xjocke commented Nov 25, 2019

Weird I thought it would be fine since getSignerConfig returns an empty object for Trezor.

const getSignerConfig = ({ type, networkId, derivationPath }) => {
	if (type === 'Ledger') {
		const DEFAULT_LEDGER_DERIVATION_PATH = "44'/60'/0'/";
		return { derivationPath: derivationPath || DEFAULT_LEDGER_DERIVATION_PATH };
	}
	if (type === 'Coinbase') {
		return {
			appName: 'Mintr',
			appLogoUrl: `${window.location.origin}/images/mintr-leaf-logo.png`,
			jsonRpcUrl: INFURA_JSON_RPC_URLS[networkId],
			networkId,
		};
	}

	return {};
};

@0xclem
Copy link
Contributor

0xclem commented Nov 25, 2019

Yes of course. You're right, it should be fine.

So the only remaining issue is setSigner({ type, networkId }) in connectToWallet().
It doesn't set Ledger with the correct derivation path. It should check from either the store or localstorage is a value exists, and use it.

0xjocke added a commit that referenced this pull request Nov 25, 2019
@0xclem 0xclem deleted the 80-derivation-path-localstorage branch May 22, 2020 05:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants