Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: shared utils management #138

Merged
merged 3 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"@heroicons/react": "^2.0.16",
"@mysten/dapp-kit": "^0.11.1",
"@mysten/sui.js": "^0.49.1",
"@next/bundle-analyzer": "^13.1.1",
"@nextui-org/input": "^2.1.16",
"@nextui-org/pagination": "^2.0.26",
"@nextui-org/react": "^2.2.9",
Expand All @@ -48,7 +47,6 @@
"@radix-ui/react-slot": "1.0.2",
"@rainbow-me/rainbowkit": "^1.3.1",
"@reduxjs/toolkit": "^1.9.1",
"@tailwindcss/typography": "^0.5.15",
"@tanstack/react-query": "^5.17.15",
"@tiptap-extend/columns": "2.1.6",
"@vercel/speed-insights": "^1.0.12",
Expand All @@ -60,13 +58,8 @@
"class-variance-authority": "^0.7.1",
"clsx": "^1.2.1",
"copy-to-clipboard": "^3.3.3",
"cross-env": "^7.0.3",
"daisyui": "^4.4.23",
"dayjs": "^1.11.7",
"easymde": "^2.18.0",
"eslint-plugin-react": "^7.31.11",
"eslint-plugin-unused-imports": "^3.0.0",
"ethers": "^6.9.0",
"file-saver": "^2.0.5",
"framer-motion": "^10.16.4",
"github-markdown-css": "^5.2.0",
Expand Down Expand Up @@ -99,9 +92,7 @@
"react-toastify": "^9.1.2",
"react-typed": "^1.2.0",
"recharts": "^2.7.3",
"sass": "^1.64.2",
"sha256": "^0.2.0",
"siwe": "^2.1.4",
"slick-carousel": "^1.8.1",
"striptags": "3.2.0",
"survey-analytics": "^1.9.109",
Expand All @@ -124,24 +115,30 @@
"@commitlint/cli": "19.6.1",
"@commitlint/config-conventional": "19.6.0",
"@knosys/sdk": "^0.0.3",
"@next/bundle-analyzer": "^13.1.1",
"@tailwindcss/line-clamp": "0.4.4",
"@tailwindcss/typography": "0.5.15",
"@types/node": "18.11.3",
"@types/qs": "^6.9.15",
"@types/react": "18.2.0",
"@types/react-dom": "18.2.0",
"@types/sha256": "^0.2.0",
"astro": "4.16.7",
"autoprefixer": "^10.4.12",
"cross-env": "7.0.3",
"eslint": "^8.7.0",
"eslint-config-next": "^13.1.1",
"eslint-plugin-headers": "1.2.1",
"eslint-plugin-perfectionist": "4.8.0",
"eslint-plugin-react": "7.31.11",
"eslint-plugin-tailwindcss": "3.15.1",
"eslint-plugin-unused-imports": "3.0.0",
"husky": "9.1.7",
"ksio": "^0.0.3",
"lint-staged": "15.3.0",
"postcss": "^8.4.18",
"prettier": "^2.5.1",
"sass": "^1.64.2",
"semver": "^7.6.3",
"tailwindcss": "3.4.16"
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/(uc)/signin/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import { EyeIcon, EyeSlashIcon } from '@heroicons/react/24/outline';
import clsx from 'clsx';
import { isEmpty } from 'lodash';
import { signIn } from 'next-auth/react';
import Link from 'next/link';
import { useSearchParams } from 'next/navigation';
Expand All @@ -27,6 +26,7 @@ import { useForm } from 'react-hook-form';
import { toast } from 'react-toastify';

import Loader from '@/components/Loader';
import { isEmpty } from '@/utils';
import { wrapOnChange } from '@/utils/form';

import { signin, emailCodeLogin } from '#/services/auth';
Expand Down
6 changes: 3 additions & 3 deletions src/app/bounties/[id]/AppliedModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

import { parseUnits } from '@ethersproject/units';
import { writeContract } from '@wagmi/core';
import clsx from 'clsx';
import Image from 'next/image';
Expand All @@ -32,6 +31,7 @@ import { BOUNTY_SUPPORTED_CHAIN } from '@/constants/chain';
import { contracts, payTokens } from '@/constants/contract';
import { useAllowance, useApprove } from '@/hooks/useERC20';
import { fetcher } from '@/utils/request';
import { parseTokenUnits } from '@/utils/web3';

import { useBountyEnvCheck } from '#/domain/bounty/hooks';
import { EXPERIENCE_OPTIONS } from '#/lib/user';
Expand Down Expand Up @@ -123,7 +123,7 @@ export function AppliedModal({ open, closeModal, bounty }) {
bounty.task,
currUser?.user_wallet,
payToken.address,
parseUnits((bounty.amount / 100).toString(), payToken.decimals),
parseTokenUnits((bounty.amount / 100).toString(), payToken.decimals),
],
});
// console.log(hash)
Expand Down Expand Up @@ -160,7 +160,7 @@ export function AppliedModal({ open, closeModal, bounty }) {
setApproveConfirmLoading(true);
try {
if (
Number(allowance.toString()) < Number(parseUnits((bounty.amount / 100).toString(), payToken.decimals).toString())
Number(allowance.toString()) < Number(parseTokenUnits((bounty.amount / 100).toString(), payToken.decimals).toString())
&&
approveAsync
) {
Expand Down
5 changes: 2 additions & 3 deletions src/app/bounties/[id]/ApplyFinishedModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

import { parseUnits } from '@ethersproject/units';
import { useState } from 'react';
import { toast } from 'react-toastify';
import { useNetwork, useWalletClient } from 'wagmi';
Expand All @@ -24,7 +23,7 @@ import { Modal } from '@/components/Modal';
import { BOUNTY_SUPPORTED_CHAIN } from '@/constants/chain';
import { contracts, payTokens } from '@/constants/contract';
import { currentTime } from '@/utils/date';
import { signBounty } from '@/utils/web3';
import { parseTokenUnits, signBounty } from '@/utils/web3';

import { useBountyEnvCheck } from '#/domain/bounty/hooks';
import { biulderFinish } from '#/services/bounties';
Expand All @@ -46,7 +45,7 @@ export function ApplyFinishedModal({open, close, bounty}) {
setLoading(true);
const _deadline = currentTime() + 7 * 24 * 60 * 60;
// bounty withdraw
const _s = await signBounty(chain?.id, _contracts.bounty, walletClient, bounty.task, parseUnits(amount.toString(), payToken.decimals), _deadline);
const _s = await signBounty(chain?.id, _contracts.bounty, walletClient, bounty.task, parseTokenUnits(amount.toString(), payToken.decimals), _deadline);
if (_s === 'error') {
setLoading(false);
return;
Expand Down
5 changes: 2 additions & 3 deletions src/app/bounties/[id]/TerminateModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

import { parseUnits } from '@ethersproject/units';
import { useState } from 'react';
import { toast } from 'react-toastify';
import { useNetwork, useWalletClient } from 'wagmi';
Expand All @@ -24,7 +23,7 @@ import { Modal } from '@/components/Modal';
import { BOUNTY_SUPPORTED_CHAIN } from '@/constants/chain';
import { contracts, payTokens } from '@/constants/contract';
import { currentTime } from '@/utils/date';
import { signBounty } from '@/utils/web3';
import { parseTokenUnits, signBounty } from '@/utils/web3';

import { termination } from '#/services/bounties';

Expand All @@ -51,7 +50,7 @@ export function TerminateModal({open, close, bounty, type}) {
_contracts.bounty,
walletClient,
bounty.task,
parseUnits(amount.toString(), payToken.decimals),
parseTokenUnits(amount.toString(), payToken.decimals),
_deadline
);
if (_s === 'error') {
Expand Down
6 changes: 3 additions & 3 deletions src/app/creator/build/[type]/AppliedModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

import { parseUnits } from '@ethersproject/units';
import { EyeIcon } from '@heroicons/react/24/outline';
import { useConnectModal } from '@rainbow-me/rainbowkit';
import { writeContract } from '@wagmi/core';
Expand All @@ -35,6 +34,7 @@ import { BountyABI } from '@/constants/abis/bounty';
import { BOUNTY_SUPPORTED_CHAIN } from '@/constants/chain';
import { contracts, payTokens } from '@/constants/contract';
import { useAllowance, useApprove } from '@/hooks/useERC20';
import { parseTokenUnits } from '@/utils/web3';

import { EXPERIENCE_OPTIONS } from '#/lib/user';
import { denyBuilder, approveBuilder } from '#/services/creator';
Expand Down Expand Up @@ -165,7 +165,7 @@ export function AppliedModal({ open, closeModal, bounty, applyCallback }) {
bounty.task,
currUser?.user_wallet,
payToken.address,
parseUnits((bounty.amount / 100).toString(), payToken.decimals),
parseTokenUnits((bounty.amount / 100).toString(), payToken.decimals),
],
});

Expand Down Expand Up @@ -197,7 +197,7 @@ export function AppliedModal({ open, closeModal, bounty, applyCallback }) {
}
setApproveConfirmLoading(true);
if (
Number(allowance.toString()) < Number(parseUnits((bounty.amount / 100).toString(), payToken.decimals).toString())
Number(allowance.toString()) < Number(parseTokenUnits((bounty.amount / 100).toString(), payToken.decimals).toString())
&&
approveAsync
) {
Expand Down
6 changes: 2 additions & 4 deletions src/app/creator/build/[type]/ManageModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

import { parseUnits } from '@ethersproject/units';
import clsx from 'clsx';
import Image from 'next/image';
import { useCallback, useEffect } from 'react';
Expand All @@ -30,7 +29,7 @@ import { BOUNTY_SUPPORTED_CHAIN } from '@/constants/chain';
import { contracts, payTokens } from '@/constants/contract';
import { currentTime, fromNow } from '@/utils/date';
import { formatTime } from '@/utils/date';
import { signBounty } from '@/utils/web3';
import { parseTokenUnits, signBounty } from '@/utils/web3';

import {
getProgressList,
Expand All @@ -46,7 +45,6 @@ import { AddProgressModal } from './AddProgressModal';

// import { writeContract, prepareWriteContract } from '@wagmi/core'
// import { BountyABI } from '@/constants/abis/bounty'
// import { parseUnits } from '@ethersproject/units'

export function ManageModal({
open,
Expand Down Expand Up @@ -107,7 +105,7 @@ export function ManageModal({
_contracts.bounty,
walletClient,
bounty.task,
parseUnits(amount.toString(), payToken.decimals),
parseTokenUnits(amount.toString(), payToken.decimals),
_deadline
);
if (_s === 'error') {
Expand Down
6 changes: 4 additions & 2 deletions src/app/creator/learn/[type]/[id]/Chllenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@

import { ChevronLeftIcon, ChevronRightIcon, CalendarDaysIcon } from '@heroicons/react/24/outline';
import clsx from 'clsx';
import range from 'lodash/range';
import { forwardRef } from 'react';
import DatePicker from 'react-datepicker';
import 'react-datepicker/dist/react-datepicker.css';

import { ReactSelect } from '@/components/Select/ReactSelect';

import 'react-datepicker/dist/react-datepicker.css';

import { BASE_INPUT_STYLE } from '@/constants/config';
import { TIME_ZONE } from '@/constants/timezone';
import range from '@/utils';
import { getTime } from '@/utils/date';

import { SelectCountry } from '../../../../profile/SelectCountry';
Expand Down
4 changes: 2 additions & 2 deletions src/app/dashboard/hire/DepositModal.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/app/dashboard/hire/ExpendHireTimeModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

import { parseUnits } from '@ethersproject/units';
import { waitForTransaction } from '@wagmi/core';
import { writeContract } from '@wagmi/core';
import { BigNumber } from 'bignumber.js';
Expand All @@ -27,6 +26,7 @@ import { TipsIcon } from '@/components/Icons';
import { Modal } from '@/components/Modal';
import { ReactSelect } from '@/components/Select/ReactSelect';
import { MouseoverTooltip } from '@/components/Tooltip';
import { parseTokenUnits } from '@/utils/web3';

import { hireExtend } from '#/services/shilling';
import { useSlillhubChain } from '#/state/application/hooks';
Expand Down Expand Up @@ -127,7 +127,7 @@ export function ExpendHireTimeModal({ open, closeModal, data }) {
<p className="opacity-40">Total Fees</p>
<p>${totalFees.toFixed(2)}</p>
</div>
{balance?.data?.value.lt(parseUnits(totalFees.toString(), coin?.decimals)) ? (
{balance?.data?.value.lt(parseTokenUnits(totalFees.toString(), coin?.decimals)) ? (
<Button disabled variant="contained" fullWidth>
Insufficient balance
</Button>
Expand Down
4 changes: 2 additions & 2 deletions src/app/dashboard/hire/ManageModal.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/app/dashboard/hire/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

'use client';
import { formatUnits } from '@ethersproject/units';

import { Popover, Transition } from '@headlessui/react';
import { useConnectModal } from '@rainbow-me/rainbowkit';
import { readContract } from '@wagmi/core';
Expand All @@ -39,7 +39,7 @@ import Loader from '@/components/Loader';
import { NoData } from '@/components/NoData';
import { Paging } from '@/components/Paging';
import { formatTime, currentTime } from '@/utils/date';
import { signSkillHub } from '@/utils/web3';
import { formatTokenUnits, signSkillHub } from '@/utils/web3';

import { useSkillsHireList } from '#/services/dashboard/hooks';
import { permissionsHireStatus, permissionsStatusApprove } from '#/services/shilling';
Expand Down Expand Up @@ -164,7 +164,7 @@ export default function DashboardHire() {
args: [Number(current.contract_index_id)],
});

setAvailableFund(formatUnits(_available, slillhubChain.use_coins[0].decimals));
setAvailableFund(formatTokenUnits(_available, slillhubChain.use_coins[0].decimals));
}
}, [slillhubChain, current]);

Expand Down Expand Up @@ -229,12 +229,12 @@ export default function DashboardHire() {
</li>
<li className="col-span-2 pl-6">
<p className="mb-1 truncate pr-4">
${formatUnits(i.total_cost, slillhubChain?.use_coins[0].decimals)}
${formatTokenUnits(i.total_cost, slillhubChain?.use_coins[0].decimals)}
</p>
<p className="text-xs opacity-80">${i.hourly_wage.toFixed(2)} / hour</p>
</li>
<li className="col-span-2 flex items-center">
<p>${formatUnits(i.claimed_cost, slillhubChain?.use_coins[0].decimals).toString()}</p>
<p>${formatTokenUnits(i.claimed_cost, slillhubChain?.use_coins[0].decimals).toString()}</p>
</li>
<li className="col-span-2 flex items-center">
{i.status === -1 && (
Expand Down
3 changes: 2 additions & 1 deletion src/app/home/Contributor.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
'use client';

import { clsx } from 'clsx';
import { chunk } from 'lodash';
import P14 from 'public/images/home/AlongHudson.png';
import P11 from 'public/images/home/Frank.png';
// import { LocationIcon } from '@/components/Icons'
Expand All @@ -41,6 +40,8 @@
import { createRef } from 'react';
import Slider from 'react-slick';

import { chunk } from '@/utils';

const DATAS = [
{ name: 'NPC_Leo', picture: P19, x: 'NPC_Leo', title: 'Founder of DevBase @DevBase' },
{ name: 'justin', picture: P15, x: 'hiCaptainZ', title: 'Researcher. Focusing on Onchain Game' },
Expand Down Expand Up @@ -138,7 +139,7 @@
key={`contributor-slider-item-${k}-${t}`}
className={clsx('relative group w-full rounded-full hover:w-[calc(100%)]')}
>
<img src={j.picture.src} alt="" className={clsx('w-full aspect-square object-cover rounded-full relative z-[2] group-hover:z-10')} />

Check warning on line 142 in src/app/home/Contributor.js

View workflow job for this annotation

GitHub Actions / lint

Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element

Check warning on line 142 in src/app/home/Contributor.js

View workflow job for this annotation

GitHub Actions / lint

Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element

<div className={clsx('text-white box-border py-6 absolute top-[1px] left-[1px] w-[99%] h-[99%] transition-width !duration-300 overflow-hidden bg-gray rounded-full z-0',
'group-hover:w-[calc(200%+40px)] group-hover:pl-[100%] group-hover:ml-2 group-hover:z-[3]',
Expand Down
Loading
Loading