diff --git a/dapp/src/components/TokenBalanceInput/index.tsx b/dapp/src/components/TokenBalanceInput/index.tsx new file mode 100644 index 000000000..036f9b283 --- /dev/null +++ b/dapp/src/components/TokenBalanceInput/index.tsx @@ -0,0 +1,128 @@ +// import { FC, useEffect, useRef } from "react" +// import { +// Button, +// Icon, +// InputGroup, +// InputLeftElement, +// InputProps, +// InputRightElement, +// FormControl, +// FormLabel, +// useColorModeValue, +// NumberFormatInput, +// NumberFormatInputValues, +// NumberFormatInputProps, +// } from "@threshold-network/components" +// import { createIcon } from "@chakra-ui/icons" +// import { formatUnits, parseUnits } from "@ethersproject/units" +// import { Zero } from "@ethersproject/constants" +// import { BigNumber } from "@ethersproject/bignumber" +// import { web3 as web3Constants } from "../../constants" +// import HelperErrorText from "../Forms/HelperErrorText" + +// export interface TokenBalanceInputProps +// extends InputProps, +// Omit { +// icon: ReturnType +// max: number | string +// amount?: string | number +// setAmount: (val?: string | number) => void +// label?: string | JSX.Element +// hasError?: boolean +// errorMsgText?: string | JSX.Element +// helperText?: string | JSX.Element +// tokenDecimals?: number +// } + +// const TokenBalanceInput: FC = ({ +// icon, +// max, +// amount, +// setAmount, +// label, +// errorMsgText, +// helperText, +// hasError = false, +// tokenDecimals = web3Constants.STANDARD_ERC20_DECIMALS, +// ...inputProps +// }) => { +// const inputRef = useRef() +// const valueRef = useRef(amount) +// const labelColor = useColorModeValue("gray.700", "gray.300") + +// useEffect(() => { +// if (amount === "" && inputRef.current) { +// const setValue = Object.getOwnPropertyDescriptor( +// window.HTMLInputElement.prototype, +// "value", +// )?.set +// setValue!.call(inputRef.current, "") +// const event = new Event("change", { bubbles: true }) +// inputRef.current.dispatchEvent(event) +// valueRef.current = undefined +// } +// }) + +// const setToMax = () => { +// let remainder = Zero +// const { decimalScale } = inputProps +// if (decimalScale && decimalScale > 0 && decimalScale < tokenDecimals) { +// remainder = BigNumber.from(max).mod( +// BigNumber.from(10).pow(tokenDecimals - decimalScale), +// ) +// } +// _setAmount(formatUnits(BigNumber.from(max).sub(remainder), tokenDecimals)) +// setAmount(valueRef.current) +// } + +// const _setAmount = (value: string | number) => { +// valueRef.current = value +// ? parseUnits(value.toString(), tokenDecimals).toString() +// : undefined +// } + +// return ( +// +// {label && ( +// +// {label} +// +// )} +// +// +// +// +// +// _setAmount(values.value) +// } +// value={amount ? formatUnits(amount, tokenDecimals) : undefined} +// onChange={() => { +// setAmount(valueRef.current) +// }} +// id={inputProps.name} +// /> +// {!inputProps.isDisabled && ( +// +// +// +// )} +// +// +// +// ) +// } + +// export default TokenBalanceInput diff --git a/dapp/src/contexts/WalletContext.tsx b/dapp/src/contexts/WalletContext.tsx index 63fb3faba..374c9bbc8 100644 --- a/dapp/src/contexts/WalletContext.tsx +++ b/dapp/src/contexts/WalletContext.tsx @@ -22,7 +22,7 @@ export function WalletContextProvider({ }): React.ReactElement { const [btcAccount, setBtcAccount] = useState(undefined) const [ethAccount, setEthAccount] = useState(undefined) - + console.log("btcAccount ", btcAccount) const contextValue: WalletContextValue = useMemo( () => ({ btcAccount, diff --git a/dapp/src/types/index.ts b/dapp/src/types/index.ts index 32b259c7f..0280f088e 100644 --- a/dapp/src/types/index.ts +++ b/dapp/src/types/index.ts @@ -1,3 +1,4 @@ export * from "./ledger-live-app" export * from "./currency" export * from "./staking" +export * from "./wallet" diff --git a/dapp/src/types/wallet.ts b/dapp/src/types/wallet.ts new file mode 100644 index 000000000..cc304a2aa --- /dev/null +++ b/dapp/src/types/wallet.ts @@ -0,0 +1,8 @@ +/* eslint-disable import/no-cycle */ +import { Currency } from "." + +export type Account = { + address: string + balance: number + currency: Currency +}