diff --git a/components/settings/FeePayingAssetSelect.tsx b/components/settings/FeePayingAssetSelect.tsx new file mode 100644 index 000000000..2ac5ff3e1 --- /dev/null +++ b/components/settings/FeePayingAssetSelect.tsx @@ -0,0 +1,91 @@ +import AssetSelect, { AssetOption } from "components/ui/AssetSelect"; +import { + FOREIGN_ASSET_METADATA, + findAssetImageForSymbol, +} from "lib/constants/foreign-asset"; +import { useAllAssetMetadata } from "lib/hooks/queries/useAssetMetadata"; +import useFeePayingAssetSelection from "lib/state/fee-paying-asset"; +import { useMemo, useState } from "react"; +import { Check } from "react-feather"; + +const isSupportedAsset = (id: number) => { + return Object.keys(FOREIGN_ASSET_METADATA).includes(`${id}`); +}; + +const defaultSelection = { + label: "Default", + additionalText: "Uses first available asset", +}; + +const FeePayingAssetSelect = () => { + const { data: assetMetadata, isSuccess } = useAllAssetMetadata(); + const { assetSelection, setAsset } = useFeePayingAssetSelection(); + const [showSaved, setShowSaved] = useState(false); + + const options = useMemo(() => { + if (!isSuccess) { + return []; + } + let options: AssetOption[] = []; + for (const [id, meta] of assetMetadata) { + if (id === "Ztg") { + options = [ + ...options, + { + label: meta.symbol, + value: { Ztg: null }, + image: findAssetImageForSymbol(), + }, + ]; + } else { + if (!isSupportedAsset(id)) { + continue; + } + options = [ + ...options, + { + label: meta.symbol, + value: { ForeignAsset: id }, + image: findAssetImageForSymbol(meta.symbol), + }, + ]; + } + } + + options.push(defaultSelection); + return options; + }, [assetMetadata, isSuccess]); + + return ( +
+
+ + {showSaved && ( +
+ +
Saved
+
+ )} +
+
+ { + setAsset(option); + setShowSaved(true); + setTimeout(() => { + setShowSaved(false); + }, 1000); + }} + /> +
+
+ ); +}; +export default FeePayingAssetSelect; diff --git a/components/settings/OtherSettingsForm.tsx b/components/settings/OtherSettingsForm.tsx index ec318b111..d3996688d 100644 --- a/components/settings/OtherSettingsForm.tsx +++ b/components/settings/OtherSettingsForm.tsx @@ -6,6 +6,8 @@ import { isRpcSdk } from "@zeitgeistpm/sdk-next"; import { useSdkv2 } from "lib/hooks/useSdkv2"; import { useWallet } from "lib/state/wallet"; import { isValidPolkadotAddress } from "lib/util"; +import InfoPopover from "components/ui/InfoPopover"; +import { AiOutlineInfoCircle } from "react-icons/ai"; export type OtherSettingsFormProps = {}; @@ -57,7 +59,24 @@ const OtherSettingsForm: React.FC = ({}) => { reset(data); })} > - +
+ + + + Proxy Accounts + + } + > +

+ Proxy accounts can be used to allow wallets to sign transactions on + behalf of others. This section allows you to tell this application + to attempt to sign transactions using the connected wallet on behalf + of another account. +

+
+
= ({ open, onClose }) => { @@ -58,7 +59,21 @@ const SettingsModal: React.FC = ({ open, onClose }) => { (selected ? "font-semibold text-black" : "") } > - Other Settings + Proxy + + )} + +
+
+ + {({ selected }) => ( + + Fee Paying Asset )} @@ -73,7 +88,8 @@ const SettingsModal: React.FC = ({ open, onClose }) => { ) : ( <> ), - [TabSelection.Other]: , + [TabSelection.Proxy]: , + [TabSelection.Fees]: , }[tabSelection] } diff --git a/components/ui/AssetSelect.tsx b/components/ui/AssetSelect.tsx index 7f6fa45b9..c73f84df0 100644 --- a/components/ui/AssetSelect.tsx +++ b/components/ui/AssetSelect.tsx @@ -17,8 +17,9 @@ import Select, { export type AssetOption = { label: string; - value: AssetId; - image: string; + value?: AssetId; + image?: string; + additionalText?: string; }; const Control = ({ children, ...rest }: ControlProps) => { @@ -52,21 +53,25 @@ const SingleValue = (props: SingleValueProps) => { const { label, image } = props.data; return (
- {label} + {image ? ( + {label} + ) : ( +
+ )} {label}
); }; const Option = (props: OptionProps) => { - const { label, value, image } = props.data; + const { label, value, image, additionalText } = props.data; const wallet = useWallet(); const address = wallet.activeAccount?.address; @@ -77,20 +82,27 @@ const Option = (props: OptionProps) => { {...props} className="!flex items-center w-full bg-anti-flash-white rounded-md h-14 mb-2 last:mb-0 font-semibold px-4 !cursor-pointer" > - {label} + {image ? ( + {label} + ) : ( +
+ )} {label} {balance && (
Balance: {formatNumberLocalized(balance.div(ZTG).toNumber())}
)} + {additionalText && ( +
{additionalText}
+ )} ); }; @@ -110,16 +122,18 @@ export type AssetSelectProps = { options: AssetOption[]; selectedOption?: AssetOption; onChange: (value: AssetOption) => void; + showArrowRight?: boolean; }; const AssetSelect: React.FC = ({ options, selectedOption, onChange, + showArrowRight = false, }) => { return (