@wagmi/core
Advanced tools
Comparing version 2.13.2 to 2.13.3
@@ -141,9 +141,3 @@ import { createStore as createMipd, } from 'mipd'; | ||
const initialState = getInitialState(); | ||
const chainId = persistedState && | ||
typeof persistedState === 'object' && | ||
'chainId' in persistedState && | ||
typeof persistedState.chainId === 'number' && | ||
chains.getState().some((x) => x.id === persistedState.chainId) | ||
? persistedState.chainId | ||
: initialState.chainId; | ||
const chainId = validatePersistedChainId(persistedState, initialState.chainId); | ||
return { ...initialState, chainId }; | ||
@@ -173,5 +167,8 @@ }, | ||
delete persistedState.status; | ||
// Make sure persisted `chainId` is valid | ||
const chainId = validatePersistedChainId(persistedState, currentState.chainId); | ||
return { | ||
...currentState, | ||
...persistedState, | ||
chainId, | ||
}; | ||
@@ -184,2 +181,11 @@ }, | ||
: getInitialState)); | ||
function validatePersistedChainId(persistedState, defaultChainId) { | ||
return persistedState && | ||
typeof persistedState === 'object' && | ||
'chainId' in persistedState && | ||
typeof persistedState.chainId === 'number' && | ||
chains.getState().some((x) => x.id === persistedState.chainId) | ||
? persistedState.chainId | ||
: defaultChainId; | ||
} | ||
///////////////////////////////////////////////////////////////////////////////////////////////// | ||
@@ -186,0 +192,0 @@ // Subscribe to changes |
@@ -1,2 +0,2 @@ | ||
export const version = '2.13.2'; | ||
export const version = '2.13.3'; | ||
//# sourceMappingURL=version.js.map |
@@ -1,2 +0,2 @@ | ||
export declare const version = "2.13.2"; | ||
export declare const version = "2.13.3"; | ||
//# sourceMappingURL=version.d.ts.map |
{ | ||
"name": "@wagmi/core", | ||
"description": "VanillaJS library for Ethereum", | ||
"version": "2.13.2", | ||
"version": "2.13.3", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -227,10 +227,6 @@ import { | ||
const initialState = getInitialState() | ||
const chainId = | ||
persistedState && | ||
typeof persistedState === 'object' && | ||
'chainId' in persistedState && | ||
typeof persistedState.chainId === 'number' && | ||
chains.getState().some((x) => x.id === persistedState.chainId) | ||
? persistedState.chainId | ||
: initialState.chainId | ||
const chainId = validatePersistedChainId( | ||
persistedState, | ||
initialState.chainId, | ||
) | ||
return { ...initialState, chainId } | ||
@@ -264,5 +260,11 @@ }, | ||
delete persistedState.status | ||
// Make sure persisted `chainId` is valid | ||
const chainId = validatePersistedChainId( | ||
persistedState, | ||
currentState.chainId, | ||
) | ||
return { | ||
...currentState, | ||
...(persistedState as object), | ||
chainId, | ||
} | ||
@@ -278,2 +280,15 @@ }, | ||
function validatePersistedChainId( | ||
persistedState: unknown, | ||
defaultChainId: number, | ||
) { | ||
return persistedState && | ||
typeof persistedState === 'object' && | ||
'chainId' in persistedState && | ||
typeof persistedState.chainId === 'number' && | ||
chains.getState().some((x) => x.id === persistedState.chainId) | ||
? persistedState.chainId | ||
: defaultChainId | ||
} | ||
///////////////////////////////////////////////////////////////////////////////////////////////// | ||
@@ -280,0 +295,0 @@ // Subscribe to changes |
@@ -1,1 +0,1 @@ | ||
export const version = '2.13.2' | ||
export const version = '2.13.3' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1771376
19072