Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
6a3abbfb
Unverified
Commit
6a3abbfb
authored
Jul 27, 2023
by
Zach Pomerantz
Committed by
GitHub
Jul 27, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update mainnet block (#7042)
* fix: update mainnet block * fix: typecheck
parent
9ced7147
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
13 deletions
+17
-13
permit2.test.ts
cypress/e2e/permit2.test.ts
+2
-2
useBlockNumber.tsx
src/lib/hooks/useBlockNumber.tsx
+15
-11
No files found.
cypress/e2e/permit2.test.ts
View file @
6a3abbfb
...
@@ -29,7 +29,7 @@ describe('Permit2', () => {
...
@@ -29,7 +29,7 @@ describe('Permit2', () => {
cy
.
hardhat
()
cy
.
hardhat
()
.
then
(({
approval
,
wallet
})
=>
approval
.
getTokenAllowanceForPermit2
({
owner
:
wallet
,
token
:
inputToken
}))
.
then
(({
approval
,
wallet
})
=>
approval
.
getTokenAllowanceForPermit2
({
owner
:
wallet
,
token
:
inputToken
}))
.
then
((
allowance
)
=>
{
.
then
((
allowance
)
=>
{
Cypress
.
log
({
name
:
`Token allowace:
${
allowance
.
toString
()}
`
})
Cypress
.
log
({
name
:
`Token allowa
n
ce:
${
allowance
.
toString
()}
`
})
cy
.
wrap
(
allowance
).
should
(
'
deep.equal
'
,
MaxUint256
)
cy
.
wrap
(
allowance
).
should
(
'
deep.equal
'
,
MaxUint256
)
})
})
}
}
...
@@ -39,7 +39,7 @@ describe('Permit2', () => {
...
@@ -39,7 +39,7 @@ describe('Permit2', () => {
cy
.
hardhat
()
cy
.
hardhat
()
.
then
(({
approval
,
wallet
})
=>
approval
.
getPermit2Allowance
({
owner
:
wallet
,
token
:
inputToken
}))
.
then
(({
approval
,
wallet
})
=>
approval
.
getPermit2Allowance
({
owner
:
wallet
,
token
:
inputToken
}))
.
then
((
allowance
)
=>
{
.
then
((
allowance
)
=>
{
Cypress
.
log
({
name
:
`Permit2 allowace:
${
allowance
.
amount
.
toString
()}
`
})
Cypress
.
log
({
name
:
`Permit2 allowa
n
ce:
${
allowance
.
amount
.
toString
()}
`
})
cy
.
wrap
(
allowance
.
amount
).
should
(
'
deep.equal
'
,
MaxUint160
)
cy
.
wrap
(
allowance
.
amount
).
should
(
'
deep.equal
'
,
MaxUint160
)
// Asserts that the on-chain expiration is in 30 days, within a tolerance of 40 seconds.
// Asserts that the on-chain expiration is in 30 days, within a tolerance of 40 seconds.
const
THIRTY_DAYS_SECONDS
=
2
_592_000
const
THIRTY_DAYS_SECONDS
=
2
_592_000
...
...
src/lib/hooks/useBlockNumber.tsx
View file @
6a3abbfb
...
@@ -7,9 +7,9 @@ import { createContext, ReactNode, useCallback, useContext, useEffect, useMemo,
...
@@ -7,9 +7,9 @@ import { createContext, ReactNode, useCallback, useContext, useEffect, useMemo,
const
MISSING_PROVIDER
=
Symbol
()
const
MISSING_PROVIDER
=
Symbol
()
const
BlockNumberContext
=
createContext
<
const
BlockNumberContext
=
createContext
<
|
{
|
{
value
?:
number
fastForward
(
block
:
number
):
void
fastForward
(
block
:
number
):
void
mainnetValue
?:
number
block
?:
number
mainnetBlock
?:
number
}
}
|
typeof
MISSING_PROVIDER
|
typeof
MISSING_PROVIDER
>
(
MISSING_PROVIDER
)
>
(
MISSING_PROVIDER
)
...
@@ -22,17 +22,17 @@ function useBlockNumberContext() {
...
@@ -22,17 +22,17 @@ function useBlockNumberContext() {
return
blockNumber
return
blockNumber
}
}
/** Requires that BlockUpdater be installed in the DOM tree. */
export
default
function
useBlockNumber
():
number
|
undefined
{
return
useBlockNumberContext
().
value
}
export
function
useFastForwardBlockNumber
():
(
block
:
number
)
=>
void
{
export
function
useFastForwardBlockNumber
():
(
block
:
number
)
=>
void
{
return
useBlockNumberContext
().
fastForward
return
useBlockNumberContext
().
fastForward
}
}
/** Requires that BlockUpdater be installed in the DOM tree. */
export
default
function
useBlockNumber
():
number
|
undefined
{
return
useBlockNumberContext
().
block
}
export
function
useMainnetBlockNumber
():
number
|
undefined
{
export
function
useMainnetBlockNumber
():
number
|
undefined
{
return
useBlockNumberContext
().
mainnet
Value
return
useBlockNumberContext
().
mainnet
Block
}
}
export
function
BlockNumberProvider
({
children
}:
{
children
:
ReactNode
})
{
export
function
BlockNumberProvider
({
children
}:
{
children
:
ReactNode
})
{
...
@@ -106,13 +106,17 @@ export function BlockNumberProvider({ children }: { children: ReactNode }) {
...
@@ -106,13 +106,17 @@ export function BlockNumberProvider({ children }: { children: ReactNode }) {
const
value
=
useMemo
(
const
value
=
useMemo
(
()
=>
({
()
=>
({
value
:
chainId
===
activeChainId
?
block
:
undefined
,
fastForward
:
(
update
:
number
)
=>
{
fastForward
:
(
update
:
number
)
=>
{
if
(
block
&&
update
>
block
)
{
if
(
block
&&
update
>
block
)
{
setChainBlock
({
chainId
:
activeChainId
,
block
:
update
})
setChainBlock
({
chainId
:
activeChainId
,
block
:
update
,
mainnetBlock
:
activeChainId
===
ChainId
.
MAINNET
?
update
:
mainnetBlock
,
})
}
}
},
},
mainnetValue
:
mainnetBlock
,
block
:
chainId
===
activeChainId
?
block
:
undefined
,
mainnetBlock
,
}),
}),
[
activeChainId
,
block
,
chainId
,
mainnetBlock
]
[
activeChainId
,
block
,
chainId
,
mainnetBlock
]
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment