Skip to content

Commit

Permalink
chore(dcellar-web-ui): upgrade rushjs, pnpm, nextjs and node version. (
Browse files Browse the repository at this point in the history
…#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
3 people authored Dec 14, 2023
1 parent c8ad249 commit 005d785
Show file tree
Hide file tree
Showing 18 changed files with 2,471 additions and 2,208 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/common-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
- name: Cache Rush
uses: actions/cache@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/common-rush-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
- name: Run rush check
run: node common/scripts/install-run-rush.js check
validate-shrinkwrap-file:
Expand All @@ -22,6 +22,6 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
- name: Run rush install --check-only
run: node common/scripts/install-run-rush.js install --check-only
2 changes: 1 addition & 1 deletion apps/dcellar-web-ui/Dockerfile
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

Expand Down
17 changes: 10 additions & 7 deletions apps/dcellar-web-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@
"bignumber.js": "^9.1.1",
"comlink": "^4.4.1",
"dayjs": "^1.11.7",
"eslint-config-next": "13.3.4",
"eslint-config-next": "~14.0.4",
"ethers": "^5.7.2",
"lodash-es": "^4.17.21",
"long": "^5.2.1",
"next": "13.3.4",
"next": "~14.0.4",
"query-string": "^8.1.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react": "~18.2.0",
"react-dom": "~18.2.0",
"react-hook-form": "^7.43.1",
"react-use": "^17.4.0",
"typescript": "5.0.4",
"wagmi": "~1.4.10",
"@sentry/nextjs": "~7.52.1",
"@sentry/nextjs": "~7.86.0",
"@reduxjs/toolkit": "^1.9.5",
"react-redux": "^8.1.1",
"next-redux-wrapper": "^8.1.0",
Expand All @@ -57,7 +57,9 @@
"redux": "~4.2.1",
"react-dnd": "16.0.1",
"react-dnd-html5-backend": "16.0.1",
"viem": "~1.19.11"
"viem": "~1.19.11",
"@wagmi/core": "~1.4.10",
"set-interval-async": "~3.0.3"
},
"devDependencies": {
"@babel/plugin-syntax-flow": "^7.14.5",
Expand All @@ -73,7 +75,7 @@
"@types/node": "18.16.0",
"@types/react": "18.0.38",
"@types/react-dom": "18.0.11",
"eslint": "8.39.0",
"eslint": "~8.55.0",
"husky": "^8.0.3",
"lint-staged": "^13.1.1",
"prettier": "^2.8.4",
Expand All @@ -95,6 +97,7 @@
"next/core-web-vitals"
],
"rules": {
"no-console": 1,
"react/display-name": "off",
"react/react-in-jsx-scope": [
"off"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { GREENFIELD_CHAIN_ID } from '@/base/env';
import { useBalance } from '@/hooks/useBalance';
import { useAppDispatch, useAppSelector } from '@/store';
import {
setBankBalance,
Expand All @@ -9,7 +10,6 @@ import {
import { setupBnbPrice } from '@/store/slices/global';
import { useAsyncEffect, useThrottleEffect } from 'ahooks';
import { useRouter } from 'next/router';
import { useBalance } from 'wagmi';

export const PaymentAccounts = () => {
const dispatch = useAppDispatch();
Expand All @@ -29,8 +29,6 @@ export const PaymentAccounts = () => {
const { data: gnfdBalance, refetch } = useBalance({
address: loginAccount as any,
chainId: GREENFIELD_CHAIN_ID,
watch: true,
cacheTime: 1000,
});
const metamaskValue = gnfdBalance?.formatted ?? '0';
useAsyncEffect(async () => {
Expand Down
49 changes: 49 additions & 0 deletions apps/dcellar-web-ui/src/hooks/useBalance.ts
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,
};
}
2 changes: 1 addition & 1 deletion common/autoinstallers/commitlint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"dependencies": {
"@commitlint/config-conventional": "^16.2.4",
"@microsoft/rush-lib": "^5.97.1",
"@microsoft/rush-lib": "^5.112.1",
"commitlint": "^16.3.0",
"execa": "^5.1.1"
}
Expand Down
Loading

0 comments on commit 005d785

Please sign in to comment.