From 0ffaba97b06a66815eb8cef22c17454009bbf86a Mon Sep 17 00:00:00 2001 From: selim <138768831+sprrwhwk@users.noreply.github.com> Date: Fri, 2 Feb 2024 14:38:04 +0300 Subject: [PATCH] [retire] disable fiat payments for icr projects (#2178) * disable fiat payments for icr projects * rename prop * remove logging statement * use usdc as default for icr * trigger rebuild * trigger rebuild * touch api module * touch api module * revert * log current api url * bump version * change version * revert unnecessary changes * bump api version * log timeout message --------- Co-authored-by: Michael Collins <0xemc@protonmail.com> --- .../pages/Project/Retire/Pool/RetireForm.tsx | 14 ++++++++++++-- .../pages/Project/Retire/Pool/RetireInputs.tsx | 3 ++- carbonmark/lib/getPaymentMethods.ts | 2 +- carbonmark/lib/types/carbonmark.types.ts | 7 ++++++- carbonmark/lib/waitForApi.ts | 1 + 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/carbonmark/components/pages/Project/Retire/Pool/RetireForm.tsx b/carbonmark/components/pages/Project/Retire/Pool/RetireForm.tsx index d0fbcc95ff..dfcf2e856d 100644 --- a/carbonmark/components/pages/Project/Retire/Pool/RetireForm.tsx +++ b/carbonmark/components/pages/Project/Retire/Pool/RetireForm.tsx @@ -21,6 +21,8 @@ import { getFiatInfo } from "lib/fiat/fiatInfo"; import { getPoolApprovalValue } from "lib/getPoolData"; import { TransactionStatusMessage, TxnStatus } from "lib/statusMessage"; import { + CarbonmarkPaymentMethod, + CarbonmarkPaymentMethods, ListingProduct, PoolProduct, Product, @@ -74,6 +76,8 @@ export const RetireForm: FC = (props) => { const [costs, setCosts] = useState(""); const { product } = props; + const defaultPaymentMethod: CarbonmarkPaymentMethod = + props.project.registry.startsWith("ICR") ? "usdc" : "fiat"; const methods = useForm({ mode: "onChange", @@ -81,7 +85,7 @@ export const RetireForm: FC = (props) => { projectTokenAddress: isPool(product) ? product?.projectTokenAddress : undefined, - paymentMethod: "fiat", + paymentMethod: defaultPaymentMethod, ...inputValues, }, }); @@ -96,7 +100,7 @@ export const RetireForm: FC = (props) => { // for the usdc icons to be visible for the required transition // on first load the default paymentMethod is set as usdc & then // immediately set to fiat. - methods.setValue("paymentMethod", "fiat"); + methods.setValue("paymentMethod", defaultPaymentMethod); }, []); useEffect(() => { @@ -335,6 +339,11 @@ export const RetireForm: FC = (props) => { } }, [retirementBlockNumber]); + const permittedPaymentMethods: Array = + props.project.registry.startsWith("ICR") + ? CarbonmarkPaymentMethods.filter((method) => method !== "fiat") + : Array.from(CarbonmarkPaymentMethods); + return ( @@ -353,6 +362,7 @@ export const RetireForm: FC = (props) => { address={address} fiatAmountError={fiatAmountError} approvalValue={getApprovalValue()} + enabledPaymentMethods={permittedPaymentMethods} /> ; }; const validations = ( @@ -338,7 +339,7 @@ export const RetireInputs: FC = (props) => { <>