-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(dcellar-web-ui): upgrade rushjs, pnpm, nextjs and node version. (…
…#306) * feat(dcellar-web-ui): add object total tip * feat(dcellar-web-ui): upgrade wagmi to 1.x * chore(dcellar-web-ui): upgrade rushjs, pnpm and node version * chore(dcellar-web-ui): upgrade nextjs to 14 * feat(dcellar-web-ui): opt getbalance method * feat(dcellar-web-ui): opt lint function * chore(dcellar-web-ui): upgrade github actions node to 20 * chore(dcellar-web-ui): upgrade dockers node to 20 * feat(dcellar-web-ui): fix image not found (#308) * feat(dcellar-web-ui): upgrade wagmi to 1.x (#305) * feat(dcellar-web-ui): support deploy testnet by tag and sha (#307) * chore(dcellar-web-ui): upgrade rushjs, pnpm and node version * chore(dcellar-web-ui): upgrade nextjs to 14 * feat(dcellar-web-ui): opt getbalance method * feat(dcellar-web-ui): opt lint function * chore(dcellar-web-ui): upgrade github actions node to 20 * chore(dcellar-web-ui): upgrade dockers node to 20 --------- Co-authored-by: aidencao <[email protected]> Co-authored-by: aiden-cao <[email protected]>
- Loading branch information
1 parent
c8ad249
commit 005d785
Showing
18 changed files
with
2,471 additions
and
2,208 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
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,4 +1,4 @@ | ||
FROM node:16.20.1-buster-slim | ||
FROM node:20.10.0-buster-slim | ||
|
||
WORKDIR /opt/deploy | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { useCallback, useEffect, useState } from 'react' | ||
import { FetchBalanceResult, fetchBalance } from '@wagmi/core'; | ||
import { GREENFIELD_CHAIN_ID } from '@/base/env'; | ||
import { setIntervalAsync, clearIntervalAsync, SetIntervalAsyncTimer } from 'set-interval-async'; | ||
|
||
type Timer = { [key: string]: SetIntervalAsyncTimer<[]> | null } | ||
export const useBalance = ({ | ||
address, | ||
chainId = GREENFIELD_CHAIN_ID, | ||
intervalMs = 2000, | ||
}: { | ||
address: `0x${string}`, | ||
chainId: number, | ||
intervalMs?: number, | ||
}) => { | ||
const [balance, setBalance] = useState({} as FetchBalanceResult); | ||
const [timers, setTimers] = useState<Timer>({}) | ||
|
||
const refetch = useCallback(() => { | ||
if (!address || !chainId) return Promise.resolve({} as FetchBalanceResult); | ||
return fetchBalance({ | ||
address: address, | ||
chainId: chainId, | ||
}) | ||
}, [address, chainId]); | ||
|
||
useEffect(() => { | ||
if (!address || !chainId) return; | ||
const key = `${address}_${chainId}`; | ||
const timer = timers[key]; | ||
if (timer) return; | ||
Object.values(timers).forEach((timer) => timer && clearIntervalAsync(timer)); | ||
const newTimer = setIntervalAsync(async () => { | ||
const data = await refetch(); | ||
setBalance(data); | ||
}, intervalMs); | ||
timers[key] = newTimer; | ||
setTimers(timers); | ||
|
||
return () => { | ||
Object.values(timers).forEach((timer) => timer && clearIntervalAsync(timer)); | ||
} | ||
}, [address, chainId]); | ||
|
||
return { | ||
data: balance, | ||
refetch, | ||
}; | ||
} |
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
Oops, something went wrong.