-
Notifications
You must be signed in to change notification settings - Fork 119
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
e19b7da
commit 15f5fa5
Showing
43 changed files
with
562 additions
and
429 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@namada/namadillo", | ||
"version": "1.0.6", | ||
"version": "1.1.0", | ||
"description": "Namadillo", | ||
"repository": "https://github.com/anoma/namada-interface/", | ||
"author": "Heliax Dev <[email protected]>", | ||
|
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,111 @@ | ||
import { Modal, SkeletonLoading } from "@namada/components"; | ||
import { chainAssetsMapAtom, nativeTokenAddressAtom } from "atoms/chain"; | ||
import { | ||
gasPriceForAllTokensAtom, | ||
storageGasTokenAtom, | ||
} from "atoms/fees/atoms"; | ||
import { tokenPricesFamily } from "atoms/prices/atoms"; | ||
import BigNumber from "bignumber.js"; | ||
import { useAtomValue, useSetAtom } from "jotai"; | ||
import { IoClose } from "react-icons/io5"; | ||
import { twMerge } from "tailwind-merge"; | ||
import { GasConfig } from "types"; | ||
import { unknownAsset } from "utils/assets"; | ||
import { getDisplayGasFee } from "utils/gas"; | ||
import { FiatCurrency } from "./FiatCurrency"; | ||
import { TokenCurrency } from "./TokenCurrency"; | ||
|
||
export const GasFeeModal = ({ | ||
gasConfig, | ||
onClose, | ||
}: { | ||
gasConfig: GasConfig; | ||
onClose: () => void; | ||
}): JSX.Element => { | ||
const setStorageGasToken = useSetAtom(storageGasTokenAtom); | ||
const gasPriceForAllTokens = useAtomValue(gasPriceForAllTokensAtom); | ||
const chainAssetsMap = useAtomValue(chainAssetsMapAtom); | ||
const nativeTokenAddress = useAtomValue(nativeTokenAddressAtom).data; | ||
|
||
const data = gasPriceForAllTokens.data ?? []; | ||
|
||
const tokenAddresses = data.map((item) => item.token); | ||
const gasDollarMap = useAtomValue(tokenPricesFamily(tokenAddresses)); | ||
|
||
return ( | ||
<Modal onClose={onClose}> | ||
<div | ||
className={twMerge( | ||
"fixed min-w-[550px] top-1/2 left-1/2 -translate-y-1/2 -translate-x-1/2", | ||
"px-6 py-7 bg-rblack border border-neutral-500 rounded-md" | ||
)} | ||
> | ||
<i | ||
className={twMerge( | ||
"cursor-pointer text-white absolute right-3 top-3 text-xl", | ||
"hover:text-yellow transition-colors" | ||
)} | ||
onClick={onClose} | ||
> | ||
<IoClose /> | ||
</i> | ||
<div className="text-center"> | ||
<h2 className="font-medium">Select Gas Token</h2> | ||
<div className="text-sm mt-1"> | ||
Gas fees deducted from your Namada accounts | ||
</div> | ||
</div> | ||
<div className="flex flex-col mt-4 max-h-[60vh] overflow-auto"> | ||
{!data.length ? | ||
<SkeletonLoading height="100px" width="100%" /> | ||
: data | ||
.sort((a, b) => | ||
a.token === nativeTokenAddress ? -1 | ||
: b.token === nativeTokenAddress ? 1 | ||
: 0 | ||
) | ||
.map(({ token, minDenomAmount }) => { | ||
const asset = chainAssetsMap[token] ?? unknownAsset(token); | ||
const symbol = asset.symbol; | ||
const fee = getDisplayGasFee({ | ||
gasLimit: gasConfig.gasLimit, | ||
gasPrice: BigNumber(minDenomAmount), | ||
gasToken: token, | ||
asset, | ||
}); | ||
const price = gasDollarMap.data?.[token]; | ||
const dollar = price ? fee.multipliedBy(price) : undefined; | ||
|
||
const selected = token === gasConfig.gasToken; | ||
|
||
return ( | ||
<button | ||
key={token} | ||
className={twMerge( | ||
"flex justify-between items-center", | ||
"bg-rblack rounded-sm px-5 min-h-[58px]", | ||
"hover:text-yellow hover:border-yellow transition-colors duration-300", | ||
selected ? "border border-white" : "m-px" | ||
)} | ||
type="button" | ||
onClick={() => { | ||
setStorageGasToken(token); | ||
onClose(); | ||
}} | ||
> | ||
<div>{symbol}</div> | ||
<div className="text-right"> | ||
{dollar && <FiatCurrency amount={dollar} />} | ||
<div className="text-xs"> | ||
<TokenCurrency amount={fee} symbol={symbol} /> | ||
</div> | ||
</div> | ||
</button> | ||
); | ||
}) | ||
} | ||
</div> | ||
</div> | ||
</Modal> | ||
); | ||
}; |
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,21 @@ | ||
import { GasConfig } from "types"; | ||
import { unknownAsset } from "utils/assets"; | ||
import { getDisplayGasFee } from "utils/gas"; | ||
import { TokenCurrency } from "./TokenCurrency"; | ||
|
||
export const TransactionFee = ({ | ||
gasConfig, | ||
}: { | ||
gasConfig: GasConfig; | ||
}): JSX.Element => { | ||
const asset = gasConfig.asset ?? unknownAsset(gasConfig.gasToken); | ||
const symbol = asset.symbol; | ||
const fee = getDisplayGasFee(gasConfig); | ||
|
||
return ( | ||
<div className="text-sm"> | ||
<span className="underline">Transaction fee:</span>{" "} | ||
<TokenCurrency symbol={symbol} amount={fee} className="font-medium " /> | ||
</div> | ||
); | ||
}; |
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,30 @@ | ||
import { useState } from "react"; | ||
import { GasConfig } from "types"; | ||
import { GasFeeModal } from "./GasFeeModal"; | ||
import { TransactionFee } from "./TransactionFee"; | ||
|
||
export const TransactionFeeButton = ({ | ||
gasConfig, | ||
}: { | ||
gasConfig: GasConfig; | ||
}): JSX.Element => { | ||
const [modalOpen, setModalOpen] = useState(false); | ||
|
||
return ( | ||
<> | ||
<button | ||
type="button" | ||
className="hover:underline cursor-pointer" | ||
onClick={() => setModalOpen(true)} | ||
> | ||
<TransactionFee gasConfig={gasConfig} /> | ||
</button> | ||
{modalOpen && ( | ||
<GasFeeModal | ||
gasConfig={gasConfig} | ||
onClose={() => setModalOpen(false)} | ||
/> | ||
)} | ||
</> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
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
File renamed without changes
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
Oops, something went wrong.
15f5fa5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Published on https://namada-interface-dev.netlify.app as production
🚀 Deployed on https://67630e106a809f281c02582b--namada-interface-dev.netlify.app