forked from leather-io/extension
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: verify tx request, handle expired
- Loading branch information
Showing
9 changed files
with
201 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
import { useRecoilValue } from 'recoil'; | ||
import { getRequestOrigin, StorageKey } from '@common/storage'; | ||
import { requestTokenState } from '@store/transactions/requests'; | ||
import { requestTokenOriginState } from '@store/transactions/requests'; | ||
|
||
export function useOrigin() { | ||
const requestToken = useRecoilValue(requestTokenState); | ||
return requestToken ? getRequestOrigin(StorageKey.transactionRequests, requestToken) : null; | ||
return useRecoilValue(requestTokenOriginState); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// https://github.com/moldy530/react-use-scroll-lock/blob/master/src/use-scroll-lock.ts | ||
import { useEffect, useState } from 'react'; | ||
|
||
declare global { | ||
// tslint:disable-next-line: interface-name | ||
interface Window { | ||
__useScrollLockStyle: string | undefined | null; | ||
__useScrollLockInstances: Set<{}> | undefined | null; | ||
} | ||
} | ||
|
||
let instances: Set<{}> = new Set(); | ||
|
||
if (typeof window !== 'undefined') { | ||
// this is necessary because we may share instances of this file on a page so we store these globally | ||
window.__useScrollLockInstances = window.__useScrollLockInstances || new Set<{}>(); | ||
instances = window.__useScrollLockInstances; | ||
} | ||
|
||
const registerInstance = (instance: {}) => { | ||
if (instances.size === 0) { | ||
setBodyOverflow(true); | ||
} | ||
|
||
instances.add(instance); | ||
}; | ||
|
||
const unregisterInstance = (instance: {}) => { | ||
instances.delete(instance); | ||
|
||
if (instances.size === 0) { | ||
setBodyOverflow(false); | ||
} | ||
}; | ||
|
||
const setBodyOverflow = (shouldLock: boolean) => { | ||
if (shouldLock) { | ||
document.body.classList.add('no-scroll'); | ||
} else { | ||
document.body.classList.remove('no-scroll'); | ||
} | ||
}; | ||
|
||
export const useScrollLock = (shouldLock: boolean) => { | ||
// we generate a unique reference to the component that uses this thing | ||
const [elementId] = useState({}); | ||
|
||
useEffect(() => { | ||
if (shouldLock) { | ||
registerInstance(elementId); | ||
} | ||
|
||
// Re-enable scrolling when component unmounts | ||
return () => unregisterInstance(elementId); | ||
}, [elementId, shouldLock]); // ensures effect is only run on mount, unmount, and on shouldLock change | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters