-
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.
- Loading branch information
1 parent
1da9e86
commit 3b0324c
Showing
4 changed files
with
138 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<NumberFormatInputProps, "onValueChange"> { | ||
// icon: ReturnType<typeof createIcon> | ||
// 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<TokenBalanceInputProps> = ({ | ||
// icon, | ||
// max, | ||
// amount, | ||
// setAmount, | ||
// label, | ||
// errorMsgText, | ||
// helperText, | ||
// hasError = false, | ||
// tokenDecimals = web3Constants.STANDARD_ERC20_DECIMALS, | ||
// ...inputProps | ||
// }) => { | ||
// const inputRef = useRef<HTMLInputElement>() | ||
// const valueRef = useRef<string | number | undefined>(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 ( | ||
// <FormControl isInvalid={hasError} isDisabled={inputProps.isDisabled}> | ||
// {label && ( | ||
// <FormLabel htmlFor={inputProps.name} color={labelColor}> | ||
// {label} | ||
// </FormLabel> | ||
// )} | ||
// <InputGroup size="md"> | ||
// <InputLeftElement> | ||
// <Icon boxSize="20px" as={icon} /> | ||
// </InputLeftElement> | ||
// <NumberFormatInput | ||
// // @ts-ignore | ||
// ref={inputRef} | ||
// placeholder="Enter an amount" | ||
// paddingLeft="2.5rem" | ||
// paddingRight="4.5rem" | ||
// {...inputProps} | ||
// onValueChange={(values: NumberFormatInputValues) => | ||
// _setAmount(values.value) | ||
// } | ||
// value={amount ? formatUnits(amount, tokenDecimals) : undefined} | ||
// onChange={() => { | ||
// setAmount(valueRef.current) | ||
// }} | ||
// id={inputProps.name} | ||
// /> | ||
// {!inputProps.isDisabled && ( | ||
// <InputRightElement width="4.5rem"> | ||
// <Button h="1.75rem" size="sm" onClick={setToMax}> | ||
// MAX | ||
// </Button> | ||
// </InputRightElement> | ||
// )} | ||
// </InputGroup> | ||
// <HelperErrorText | ||
// helperText={helperText} | ||
// errorMsgText={errorMsgText} | ||
// hasError={hasError} | ||
// /> | ||
// </FormControl> | ||
// ) | ||
// } | ||
|
||
// export default TokenBalanceInput |
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,3 +1,4 @@ | ||
export * from "./ledger-live-app" | ||
export * from "./currency" | ||
export * from "./staking" | ||
export * from "./wallet" | ||
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,8 @@ | ||
/* eslint-disable import/no-cycle */ | ||
import { Currency } from "." | ||
|
||
export type Account = { | ||
address: string | ||
balance: number | ||
currency: Currency | ||
} |