Skip to content

Commit

Permalink
Introduce RescueModal
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans committed Jun 2, 2024
1 parent 4bf6059 commit 5e8ff46
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions src/components/modals/RescueModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { RESCUE_NAME_ABI } from "abi/abi";
import { FC } from "react";
import { useAccount, useChainId, useWriteContract } from "wagmi";

import { CONTRACT_ADDRESS } from "../../constants";
import { Modal } from "./modal";

export const RescueModal: FC<{
onClose: () => void;
vaults: bigint[];
labels: string[][];
}> = ({ onClose, vaults, labels }) => {
const { address } = useAccount();
const chainId = useChainId();
const { writeContract } = useWriteContract();

const totalNames = labels.reduce(
(accumulator, current) => accumulator + current.length,
0
);
const price = 0n;
const recipient = address!;

return (
<Modal onCloseRequest={onClose} title="Rescue Names">
<div className="w-full space-y-2">
<p>You are rescuing {totalNames} names</p>
<div>
{vaults.map((vault, index) => (
<div key={vault}>
<p>Vault: #{vault.toString()}</p>
<ul>
{labels[index].map((label) => (
<li key={label}>{label}.eth</li>
))}
</ul>
</div>
))}
</div>
<div className="h-1 w-full border-t border-t-border"></div>
<div>TODO: Gas Summary</div>
<button
className="btn w-full"
onClick={() => {
writeContract({
abi: RESCUE_NAME_ABI,
address: CONTRACT_ADDRESS[chainId],
functionName: "execute",
args: [vaults, labels, price, recipient]
});
}}
>
Rescue {totalNames} Names
</button>
</div>
</Modal>
);
};

0 comments on commit 5e8ff46

Please sign in to comment.