You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.1 KiB
37 lines
1.1 KiB
import { cloneDeep } from 'lodash';
|
|
import { LEDGER_TRANSPORT_TYPES } from '../../../shared/constants/hardware-wallets';
|
|
|
|
const version = 66;
|
|
|
|
/**
|
|
* Changes the useLedgerLive boolean property to the ledgerTransportType enum
|
|
*/
|
|
export default {
|
|
version,
|
|
async migrate(originalVersionedData) {
|
|
const versionedData = cloneDeep(originalVersionedData);
|
|
versionedData.meta.version = version;
|
|
const state = versionedData.data;
|
|
const newState = transformState(state);
|
|
versionedData.data = newState;
|
|
return versionedData;
|
|
},
|
|
};
|
|
|
|
function transformState(state) {
|
|
const defaultTransportType = window.navigator.hid
|
|
? LEDGER_TRANSPORT_TYPES.WEBHID
|
|
: LEDGER_TRANSPORT_TYPES.U2F;
|
|
const useLedgerLive = Boolean(state.PreferencesController?.useLedgerLive);
|
|
const newState = {
|
|
...state,
|
|
PreferencesController: {
|
|
...state?.PreferencesController,
|
|
ledgerTransportType: useLedgerLive
|
|
? LEDGER_TRANSPORT_TYPES.LIVE
|
|
: defaultTransportType,
|
|
},
|
|
};
|
|
delete newState.PreferencesController.useLedgerLive;
|
|
return newState;
|
|
}
|
|
|