-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* auto scrollheight function * hook returns token symbol and decimals, and util function formats decimals * resize minimum height of textarea * remove console.log and refactor token symbol variables * useFormatExpiry hook * add margin to bottom of app * remove useSetProtocolFee from this pr * fix useFormatExpiry hook to use formatDistanceToNow utility from date-fns --------- Co-authored-by: Don Mosites <[email protected]>
- Loading branch information
1 parent
27a48dd
commit 5e3ae02
Showing
9 changed files
with
103 additions
and
9 deletions.
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
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
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { formatDistanceToNow } from 'date-fns'; | ||
|
||
export const useFormatExpiry = ( | ||
expiry: number | undefined | ||
): string | undefined => { | ||
if (!expiry) { | ||
return undefined; | ||
} | ||
|
||
const expiryDate = new Date(expiry * 1000); | ||
const distance = formatDistanceToNow(expiryDate, { addSuffix: true }); | ||
|
||
return distance; | ||
}; |
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,22 @@ | ||
import { Address, erc20Abi } from 'viem'; | ||
import { useChainId, useReadContract } from 'wagmi'; | ||
|
||
export const useTokenData = (contract: Address | undefined) => { | ||
const chainId = useChainId(); | ||
|
||
const { data: decimals } = useReadContract({ | ||
address: contract, | ||
abi: erc20Abi, | ||
chainId: chainId, | ||
functionName: 'decimals', | ||
}); | ||
|
||
const { data: symbol } = useReadContract({ | ||
address: contract, | ||
abi: erc20Abi, | ||
chainId: chainId, | ||
functionName: 'symbol', | ||
}); | ||
|
||
return { decimals, symbol }; | ||
}; |
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,11 @@ | ||
export const autoResizeTextarea = (textarea: HTMLTextAreaElement | null) => { | ||
if (!textarea) return; | ||
|
||
textarea.style.height = 'fit'; | ||
|
||
if (textarea.value === '' || !textarea.value) { | ||
textarea.style.height = '3rem'; | ||
} else { | ||
textarea.style.height = textarea.scrollHeight + 'px'; | ||
} | ||
}; |
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,13 @@ | ||
export const formatDecimals = ({ | ||
amount, | ||
decimals, | ||
}: { | ||
amount: string | undefined; | ||
decimals: number | undefined; | ||
}) => { | ||
if (!amount || !decimals) { | ||
return undefined; | ||
} else { | ||
return Number(amount) / 10 ** decimals; | ||
} | ||
}; |
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 |
---|---|---|
|
@@ -3463,6 +3463,11 @@ date-fns@^2.29.3: | |
dependencies: | ||
"@babel/runtime" "^7.21.0" | ||
|
||
date-fns@^3.6.0: | ||
version "3.6.0" | ||
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-3.6.0.tgz#f20ca4fe94f8b754951b24240676e8618c0206bf" | ||
integrity sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww== | ||
|
||
[email protected]: | ||
version "1.11.10" | ||
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.10.tgz#68acea85317a6e164457d6d6947564029a6a16a0" | ||
|