Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add advanced settings to multisig sign page #1361

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/components/AdvancedSettingsAccordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ import colors from "../style/colors";
import { mutezToTez, tezToMutez } from "../utils/format";
import { Estimation, TEZ_DECIMALS } from "../utils/tezos";

export const AdvancedSettingsAccordion = ({ index = 0 }) => {
type AdvancedSettingsAccordionProps = {
index?: number;
};

export const AdvancedSettingsAccordion = ({ index = 0 }: AdvancedSettingsAccordionProps) => {
const {
register,
getValues,
Expand Down
4 changes: 3 additions & 1 deletion src/components/SendFlow/BatchModalBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export const BatchModalBody: React.FC<{
title: string;
operation: EstimatedAccountOperations;
transactionCount: number;
}> = ({ title, operation, transactionCount }) => (
children?: React.ReactNode;
}> = ({ title, operation, transactionCount, children }) => (
<>
<FormPageHeader subTitle={subTitle(operation.signer)} title={title} />
<ModalBody>
Expand All @@ -29,6 +30,7 @@ export const BatchModalBody: React.FC<{
</Flex>
<SignPageFee fee={totalFee(operation.estimates)} />
</Flex>
{children}
</ModalBody>
</>
);
20 changes: 14 additions & 6 deletions src/components/SendFlow/Multisig/SignPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { EstimatedAccountOperations } from "../../../types/AccountOperations";
import { ApproveOrExecute } from "../../../types/Operation";
import { useAsyncActionHandler } from "../../../utils/hooks/useAsyncActionHandler";
import { executeOperations } from "../../../utils/tezos";
import { AdvancedSettingsAccordion } from "../../AdvancedSettingsAccordion";
import { DynamicModalContext } from "../../DynamicModal";
import { BatchModalBody } from "../BatchModalBody";
import { SignButton } from "../SignButton";
Expand All @@ -28,14 +29,15 @@ export const SignPage: React.FC<{
defaultValues: { executeParams: operation.estimates },
});

// TODO: add advanced execute params component
const estimatedOperations = {
...operation,
estimates: form.watch("executeParams"),
};

const approveOrExecute = (tezosToolkit: TezosToolkit) =>
handleAsyncAction(
async () => {
const { opHash } = await executeOperations(
{ ...operation, estimates: form.watch("executeParams") },
tezosToolkit
);
const { opHash } = await executeOperations(estimatedOperations, tezosToolkit);

return openWith(<SuccessStep hash={opHash} />);
},
Expand All @@ -48,7 +50,13 @@ export const SignPage: React.FC<{
<FormProvider {...form}>
<ModalContent>
<form>
<BatchModalBody operation={operation} title={title} transactionCount={transactionCount} />
<BatchModalBody
operation={estimatedOperations}
title={title}
transactionCount={transactionCount}
>
<AdvancedSettingsAccordion />
</BatchModalBody>

<ModalFooter>
<SignButton onSubmit={approveOrExecute} signer={signer} text={title} />
Expand Down
Loading