2023-08-02 08:13:19 +03:00
|
|
|
import { ConnectionType } from '../../src/connection/types'
|
2023-04-26 00:24:57 +03:00
|
|
|
import { UserState } from '../../src/state/user/reducer'
|
|
|
|
|
2023-08-02 08:13:19 +03:00
|
|
|
export const CONNECTED_WALLET_USER_STATE: Partial<UserState> = { selectedWallet: ConnectionType.INJECTED }
|
2023-07-07 00:01:13 +03:00
|
|
|
|
|
|
|
export const DISCONNECTED_WALLET_USER_STATE: Partial<UserState> = { selectedWallet: undefined }
|
2023-08-16 20:56:06 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This sets the initial value of the "user" slice in IndexedDB.
|
|
|
|
* Other persisted slices are not set, so they will be filled with their respective initial values
|
|
|
|
* when the app runs.
|
|
|
|
*/
|
|
|
|
export function setInitialUserState(win: Cypress.AUTWindow, initialUserState: any) {
|
|
|
|
win.indexedDB.deleteDatabase('redux')
|
|
|
|
|
|
|
|
const dbRequest = win.indexedDB.open('redux')
|
|
|
|
|
|
|
|
dbRequest.onsuccess = function () {
|
|
|
|
const db = dbRequest.result
|
|
|
|
const transaction = db.transaction('keyvaluepairs', 'readwrite')
|
|
|
|
const store = transaction.objectStore('keyvaluepairs')
|
|
|
|
store.put(
|
|
|
|
{
|
|
|
|
user: initialUserState,
|
|
|
|
},
|
|
|
|
'persist:interface'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
dbRequest.onupgradeneeded = function () {
|
|
|
|
const db = dbRequest.result
|
|
|
|
db.createObjectStore('keyvaluepairs')
|
|
|
|
}
|
|
|
|
}
|