Skip to content

Commit

Permalink
Nicolasbrugneaux/react celo (#677)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasbrugneaux committed Jun 28, 2023
1 parent aff40af commit bf82379
Show file tree
Hide file tree
Showing 106 changed files with 1,380 additions and 1,564 deletions.
10 changes: 10 additions & 0 deletions craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,14 @@ module.exports = {
enable: false,
},
typescript: { enableTypeChecking: false },
// https://github.com/WalletConnect/walletconnect-monorepo/issues/1973
babel: {
plugins: ['@babel/plugin-proposal-nullish-coalescing-operator', '@babel/plugin-proposal-optional-chaining'],
},
jest: {
configure: (jestConfig, { env, paths, resolve, rootDir }) => {
// See https://github.com/WalletConnect/walletconnect-monorepo/issues/1749
return { ...jestConfig, setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'], resolver: 'jest-resolver-enhanced' }
},
},
}
4 changes: 4 additions & 0 deletions jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { TextDecoder, TextEncoder } from 'util'

global.TextEncoder = TextEncoder
global.TextDecoder = TextDecoder
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
"@typescript-eslint/parser": "^4.28.0",
"@ubeswap/injected-connector": "^6.1.0",
"@uniswap/token-lists": "^1.0.0-beta.24",
"@web3-react/core": "^6.1.9",
"@web3-react/types": "^6.0.7",
"ajv": "^8.8.2",
"awesome-typescript-loader": "^5.2.1",
"cids": "^1.1.6",
Expand All @@ -52,6 +50,7 @@
"i18next-browser-languagedetector": "^6.1.1",
"i18next-xhr-backend": "^3.2.2",
"jazzicon": "^1.5.0",
"jest-resolver-enhanced": "^1.1.0",
"lint-staged": ">=11",
"lodash.flatmap": "^4.5.0",
"multicodec": "^3.0.1",
Expand Down Expand Up @@ -107,16 +106,16 @@
},
"license": "GPL-3.0-or-later",
"resolutions": {
"@celo/wallet-walletconnect": "1.2.0",
"@types/react": "^17.0.3",
"@types/react-dom": "^17.0.3",
"prettier": "^2.3.0"
"prettier": "^2.3.0",
"react-error-overlay": "6.0.9"
},
"dependencies": {
"@apollo/client": "^3.6.5",
"@celo-tools/use-contractkit": "^3.1.0",
"@celo/contractkit": "^1.2.0",
"@celo/utils": "^1.2.1",
"@celo/contractkit": "^4.1.0",
"@celo/react-celo": "^5.0.4",
"@celo/utils": "^4.1.0",
"@craco/craco": "^6.1.2",
"@emotion/react": "^11.10.5",
"@ensdomains/ensjs": "^2.0.1",
Expand Down
4 changes: 2 additions & 2 deletions src/components/AccountDetails/Transaction.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContractKit } from '@celo-tools/use-contractkit'
import { useCelo } from '@celo/react-celo'
import { ChainId } from '@ubeswap/sdk'
import React from 'react'
import { CheckCircle, Triangle } from 'react-feather'
Expand Down Expand Up @@ -37,7 +37,7 @@ const IconWrapper = styled.div<{ pending: boolean; success?: boolean }>`
`

export default function Transaction({ hash }: { hash: string }) {
const { network } = useContractKit()
const { network } = useCelo()
const chainId = network.chainId as unknown as ChainId
const allTransactions = useAllTransactions()

Expand Down
4 changes: 2 additions & 2 deletions src/components/AccountDetails/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContractKit, WalletTypes } from '@celo-tools/use-contractkit'
import { useCelo, WalletTypes } from '@celo/react-celo'
import { ChainId } from '@ubeswap/sdk'
import React, { useCallback, useContext } from 'react'
import { ExternalLink as LinkIcon } from 'react-feather'
Expand Down Expand Up @@ -215,7 +215,7 @@ export default function AccountDetails({
confirmedTransactions,
ENSName,
}: AccountDetailsProps) {
const { connect, destroy, address, walletType, network } = useContractKit()
const { connect, destroy, address, walletType, network } = useCelo()
const chainId = network.chainId as unknown as ChainId
const closeModals = useCloseModals()
const theme = useContext(ThemeContext)
Expand Down
4 changes: 2 additions & 2 deletions src/components/AddressInputPanel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContractKit } from '@celo-tools/use-contractkit'
import { useCelo } from '@celo/react-celo'
import { ChainId } from '@ubeswap/sdk'
import React, { useCallback, useContext } from 'react'
import { useTranslation } from 'react-i18next'
Expand Down Expand Up @@ -78,7 +78,7 @@ export default function AddressInputPanel({
// triggers whenever the typed value changes
onChange: (value: string) => void
}) {
const { network } = useContractKit()
const { network } = useCelo()
const chainId = network.chainId as unknown as ChainId
const theme = useContext(ThemeContext)

Expand Down
4 changes: 2 additions & 2 deletions src/components/CurrencyInputPanel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChainId, useContractKit } from '@celo-tools/use-contractkit'
import { ChainId, useCelo } from '@celo/react-celo'
import { Pair, Token, TokenAmount } from '@ubeswap/sdk'
import { darken } from 'polished'
import React, { useCallback, useState } from 'react'
Expand Down Expand Up @@ -145,7 +145,7 @@ export default function CurrencyInputPanel({
const { t } = useTranslation()

const [modalOpen, setModalOpen] = useState(false)
const { address: account } = useContractKit()
const { address: account } = useCelo()

const userBalance = useCurrencyBalance(account ?? undefined, currency ?? undefined)
const selectedCurrencyBalance = balanceOverride ?? userBalance
Expand Down
4 changes: 2 additions & 2 deletions src/components/Header/OpticsV1Warning.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContractKit } from '@celo-tools/use-contractkit'
import { useCelo } from '@celo/react-celo'
import { JSBI, Token } from '@ubeswap/sdk'
import { AutoColumn, TopSection } from 'components/Column'
import { CardSection } from 'components/earn/styled'
Expand All @@ -20,7 +20,7 @@ const WarningCard = styled(AutoColumn)<{ disabled?: boolean }>`
`

export default function OpticsV1Warning() {
const { address: account, network } = useContractKit()
const { address: account, network } = useCelo()
const theme = useContext(ThemeContext)
const chainId = network.chainId
const allTokens = useAllTokens(chainId)
Expand Down
4 changes: 2 additions & 2 deletions src/components/Header/Polling.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContractKit } from '@celo-tools/use-contractkit'
import { useCelo } from '@celo/react-celo'
import { ChainId } from '@ubeswap/sdk'
import React, { useEffect, useState } from 'react'
import styled, { keyframes } from 'styled-components'
Expand Down Expand Up @@ -63,7 +63,7 @@ const Spinner = styled.div`
`

export default function Polling() {
const { network } = useContractKit()
const { network } = useCelo()
const chainId = network.chainId as unknown as ChainId

const blockNumber = useBlockNumber()
Expand Down
4 changes: 2 additions & 2 deletions src/components/Header/URLWarning.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContractKit } from '@celo-tools/use-contractkit'
import { useCelo } from '@celo/react-celo'
import { ChainId } from '@ubeswap/sdk'
import React from 'react'
import { isMobile } from 'react-device-detect'
Expand Down Expand Up @@ -35,7 +35,7 @@ const appURL: Record<string, string> = {
export default function URLWarning() {
const toggleURLWarning = useURLWarningToggle()
const showURLWarning = useURLWarningVisible()
const { network } = useContractKit()
const { network } = useCelo()
const chainId = network.chainId

return isMobile ? (
Expand Down
4 changes: 2 additions & 2 deletions src/components/Header/UbeBalanceContent.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContractKit } from '@celo-tools/use-contractkit'
import { useCelo } from '@celo/react-celo'
import { ChainId as UbeswapChainId, TokenAmount } from '@ubeswap/sdk'
import Loader from 'components/Loader'
import React from 'react'
Expand Down Expand Up @@ -43,7 +43,7 @@ const StyledClose = styled(X)`
* Content for balance stats modal
*/
export default function UbeBalanceContent({ setShowUbeBalanceModal }: { setShowUbeBalanceModal: any }) {
const { address: account, network } = useContractKit()
const { address: account, network } = useCelo()
const chainId = network.chainId
const ube = chainId ? UBE[chainId as unknown as UbeswapChainId] : undefined

Expand Down
6 changes: 3 additions & 3 deletions src/components/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'rc-drawer/assets/index.css'

import { ChainId, useContractKit } from '@celo-tools/use-contractkit'
import { ChainId, useCelo } from '@celo/react-celo'
import { CELO, ChainId as UbeswapChainId, TokenAmount } from '@ubeswap/sdk'
import { CardNoise } from 'components/earn/styled'
import Modal from 'components/Modal'
Expand Down Expand Up @@ -357,8 +357,8 @@ const NETWORK_LABELS: { [chainId in ChainId]?: string } = {
}

export default function Header() {
const { address: account, network } = useContractKit()
const chainId = network.chainId
const { address: account, network } = useCelo()
const chainId = network.chainId as UbeswapChainId
const { t } = useTranslation()

const userCELOBalance = useTokenBalance(account ?? undefined, CELO[chainId as unknown as UbeswapChainId])
Expand Down
4 changes: 2 additions & 2 deletions src/components/Header/useCirculatingSupply.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContractKit } from '@celo-tools/use-contractkit'
import { useCelo } from '@celo/react-celo'
import { ChainId as UbeswapChainId, JSBI, TokenAmount } from '@ubeswap/sdk'
import { UBE } from 'constants/tokens'
import { BigNumber } from 'ethers'
Expand All @@ -21,7 +21,7 @@ const nonCirculatingAddresses = {
* Fetches the circulating supply
*/
export const useCirculatingSupply = (): TokenAmount | undefined => {
const { network } = useContractKit()
const { network } = useCelo()
const chainId = network.chainId
const ube = chainId ? UBE[chainId as unknown as UbeswapChainId] : undefined
const ubeContract = useTokenContract(ube?.address)
Expand Down
4 changes: 2 additions & 2 deletions src/components/Identicon/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContractKit } from '@celo-tools/use-contractkit'
import { useCelo } from '@celo/react-celo'
import Jazzicon from 'jazzicon'
import React, { useEffect, useRef } from 'react'
import styled from 'styled-components'
Expand All @@ -13,7 +13,7 @@ const StyledIdenticonContainer = styled.div`
export default function Identicon() {
const ref = useRef<HTMLDivElement>()

const { address: account } = useContractKit()
const { address: account } = useCelo()

useEffect(() => {
if (account && ref.current) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/LimitOrderHistory/LimitOrderHistoryItem.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContractKit } from '@celo-tools/use-contractkit'
import { useCelo } from '@celo/react-celo'
import { ChainId as UbeswapChainId, JSBI, Token, TokenAmount } from '@ubeswap/sdk'
import { BigNumber } from 'ethers'
import { useToken } from 'hooks/Tokens'
Expand Down Expand Up @@ -115,7 +115,7 @@ interface LimitOrderHistoryItemProps {
}

export default function LimitOrderHistoryItem({ item, rewardCurrency, lastDisplayItem }: LimitOrderHistoryItemProps) {
const { network } = useContractKit()
const { network } = useCelo()
const chainId = network.chainId as unknown as UbeswapChainId
const { callback: cancelOrder } = useCancelOrderCallback(item.orderHash)
const theme = useTheme()
Expand Down
4 changes: 2 additions & 2 deletions src/components/ModalViews/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContractKit } from '@celo-tools/use-contractkit'
import { useCelo } from '@celo/react-celo'
import { ChainId } from '@ubeswap/sdk'
import React, { useContext } from 'react'
import { ArrowUpCircle } from 'react-feather'
Expand Down Expand Up @@ -50,7 +50,7 @@ export function SubmittedView({
hash: string | undefined
}) {
const theme = useContext(ThemeContext)
const { network } = useContractKit()
const { network } = useCelo()
const chainId = network.chainId as unknown as ChainId

const { t } = useTranslation()
Expand Down
4 changes: 2 additions & 2 deletions src/components/Popups/TransactionPopup.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContractKit } from '@celo-tools/use-contractkit'
import { useCelo } from '@celo/react-celo'
import { ChainId } from '@ubeswap/sdk'
import React, { useContext } from 'react'
import { AlertCircle, CheckCircle } from 'react-feather'
Expand All @@ -23,7 +23,7 @@ export default function TransactionPopup({
success?: boolean
summary?: string
}) {
const { network } = useContractKit()
const { network } = useCelo()
const chainId = network.chainId as unknown as ChainId

const theme = useContext(ThemeContext)
Expand Down
6 changes: 3 additions & 3 deletions src/components/PositionCard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContractKit } from '@celo-tools/use-contractkit'
import { useCelo } from '@celo/react-celo'
import { JSBI, Pair, Percent, TokenAmount } from '@ubeswap/sdk'
import { darken, transparentize } from 'polished'
import React, { useState } from 'react'
Expand Down Expand Up @@ -48,7 +48,7 @@ interface PositionCardProps {
}

export function MinimalPositionCard({ pair, border }: PositionCardProps) {
const { address: account } = useContractKit()
const { address: account } = useCelo()

const currency0 = pair.token0
const currency1 = pair.token1
Expand Down Expand Up @@ -157,7 +157,7 @@ export function MinimalPositionCard({ pair, border }: PositionCardProps) {

export default function FullPositionCard({ pair, border, stakedBalance }: PositionCardProps) {
const { t } = useTranslation()
const { address: account } = useContractKit()
const { address: account } = useCelo()

const currency0 = pair.token0
const currency1 = pair.token1
Expand Down
2 changes: 1 addition & 1 deletion src/components/SearchModal/ChainSearchModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Network } from '@celo-tools/use-contractkit'
import { Network } from '@celo/react-celo'
import CurrencyLogo from 'components/CurrencyLogo'
import React, { useCallback } from 'react'
import { WrappedTokenInfo } from 'state/lists/hooks'
Expand Down
4 changes: 2 additions & 2 deletions src/components/SearchModal/CurrencyList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContractKit } from '@celo-tools/use-contractkit'
import { useCelo } from '@celo/react-celo'
import { currencyEquals, Token, TokenAmount } from '@ubeswap/sdk'
import React, { CSSProperties, MutableRefObject, useCallback } from 'react'
import { FixedSizeList } from 'react-window'
Expand Down Expand Up @@ -94,7 +94,7 @@ function CurrencyRow({
otherSelected: boolean
style: CSSProperties
}) {
const { address: account } = useContractKit()
const { address: account } = useCelo()

const key = currencyKey(currency)
const selectedTokenList = useCombinedActiveList()
Expand Down
2 changes: 1 addition & 1 deletion src/components/SearchModal/CurrencySearch.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChainId } from '@celo-tools/use-contractkit'
import { ChainId } from '@celo/react-celo'
import { ChainId as UbeswapChainId, cUSD, Token } from '@ubeswap/sdk'
import { ButtonLight } from 'components/Button'
import { useOnClickOutside } from 'hooks/useOnClickOutside'
Expand Down
2 changes: 1 addition & 1 deletion src/components/SearchModal/CurrencySearchModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChainId } from '@celo-tools/use-contractkit'
import { ChainId } from '@celo/react-celo'
import { Token } from '@ubeswap/sdk'
import { TokenList } from '@uniswap/token-lists'
import usePrevious from 'hooks/usePrevious'
Expand Down
4 changes: 2 additions & 2 deletions src/components/SearchModal/ImportRow.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContractKit } from '@celo-tools/use-contractkit'
import { useCelo } from '@celo/react-celo'
import { Token } from '@ubeswap/sdk'
import { ButtonPrimary } from 'components/Button'
import { AutoColumn } from 'components/Column'
Expand Down Expand Up @@ -54,7 +54,7 @@ export default function ImportRow({
setImportToken: (token: Token) => void
}) {
// gloabls
const { network } = useContractKit()
const { network } = useCelo()
const chainId = network.chainId
const theme = useTheme()

Expand Down
4 changes: 2 additions & 2 deletions src/components/SearchModal/ImportToken.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContractKit } from '@celo-tools/use-contractkit'
import { useCelo } from '@celo/react-celo'
import { ChainId, Token } from '@ubeswap/sdk'
import { ButtonPrimary } from 'components/Button'
import Card from 'components/Card'
Expand Down Expand Up @@ -50,7 +50,7 @@ interface ImportProps {
export function ImportToken({ tokens, onBack, onDismiss, handleCurrencySelect }: ImportProps) {
const theme = useTheme()

const { network } = useContractKit()
const { network } = useCelo()
const chainId = network.chainId as unknown as ChainId

const [confirmed, setConfirmed] = useState(false)
Expand Down
4 changes: 2 additions & 2 deletions src/components/SearchModal/ManageTokens.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContractKit } from '@celo-tools/use-contractkit'
import { useCelo } from '@celo/react-celo'
import { ChainId, Token } from '@ubeswap/sdk'
import Card from 'components/Card'
import Column from 'components/Column'
Expand Down Expand Up @@ -43,7 +43,7 @@ export default function ManageTokens({
setModalView: (view: CurrencyModalView) => void
setImportToken: (token: Token) => void
}) {
const { network } = useContractKit()
const { network } = useCelo()
const chainId = network.chainId as unknown as ChainId

const [searchQuery, setSearchQuery] = useState<string>('')
Expand Down
7 changes: 4 additions & 3 deletions src/components/Stake/ChangeDelegateModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useContractKit } from '@celo-tools/use-contractkit'
import { useCelo } from '@celo/react-celo'
import { ChainId } from '@ubeswap/sdk'
import { ButtonError } from 'components/Button'
import { SearchInput } from 'components/SearchModal/styleds'
import { useDoTransaction } from 'components/swap/routing'
Expand Down Expand Up @@ -31,12 +32,12 @@ interface ChangeDelegateModalProps {
export default function ChangeDelegateModal({ isOpen, onDismiss }: ChangeDelegateModalProps) {
const { t } = useTranslation()

const { network } = useContractKit()
const { network } = useCelo()
const inputRef = useRef<HTMLInputElement>()
const [delegateAddress, setDelegateAddress] = useState<string>('')
const [error, setError] = useState<string | undefined>('ChangeDelegate')

const romulusAddress = ubeGovernanceAddresses[network.chainId]
const romulusAddress = ubeGovernanceAddresses[network.chainId as ChainId]
const { tokenAddress } = useRomulusInfo(romulusAddress)
const c = usePoofTokenContract(tokenAddress)
const doTransaction = useDoTransaction()
Expand Down

1 comment on commit bf82379

@vercel
Copy link

@vercel vercel bot commented on bf82379 Jun 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.