Skip to content

Commit

Permalink
removed transactions modal
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen-Gordon committed Mar 28, 2024
1 parent 0acf907 commit 091b01e
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 367 deletions.
4 changes: 2 additions & 2 deletions src/app/@auth/(.)send/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ export default function Page() {
</DrawerHeader>
</div>

<div className=''>

<SendUsdc />
</div>

</>
);
}
229 changes: 0 additions & 229 deletions src/app/@drawer/(.)transactions/page.tsx

This file was deleted.

76 changes: 17 additions & 59 deletions src/app/components/SendUsdc/SendUsdc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,71 +63,29 @@ export default function SendUsdc() {
}
}, [usdcAmount]);

// Send transaction function
const sendTx = async () => {
try {
// Encode the data with Viem Function
// Requires the abi of the contract, the function name, and the arguments address and amount
// @ts-ignore
if (!zeroDevReady) {
console.log('not ready to send');
return;
}
if (usdcAmount == '' || usdcAmount == '0') {
console.log('amount is 0');
return;
}
const encoded: any = encodeFunctionData({
// @ts-ignore
abi: erc20Abi,
functionName: 'transfer',
args: [payee as `0x${string}`, parseUnits(usdcAmount, 6)],
});
console.log('Sending USDC');
setLoading(true);
const txnHash = await sendTransaction({
to: usdc, // ERC20 address
value: BigInt(0), // default to 0
data: encoded,
});
console.log('Txn hash:', txnHash);

if (txnHash) {
setLoading(false);
setTransactionStatus(true);
setTimeout(() => {
dispatch(setSheet(false));
/* router.push(`/transaction?hash=${txnHash}`); */
const balance = router.push('/home');
}, 1000);
}
} catch (error) {
console.log(error);
}
};


return (
<>
<div className='grid content-start justify-center p-4 text-white'>
<KeyPad usdcAmount={usdcAmount} setUsdcAmount={setUsdcAmount} />

<DrawerFooter>
<Link
href={{
pathname: '/confirm',
query: { payee: payee, amount: usdcAmount },
}}
>
<Button className='text-xl' size={'lg'} variant={'default'}>
<div className='flex content-center items-center'>
<div className='text-xl'>
<div>Send</div>
</div>
</div>
</Button>
</Link>
</DrawerFooter>
</div>
<DrawerFooter>
<Link
href={{
pathname: '/confirm',
query: { payee: payee, amount: usdcAmount },
}}
>
<Button className='text-xl' size={'lg'} variant={'default'}>
<div className='flex content-center items-center'>
<div className='text-xl'>
<div>Send</div>
</div>
</div>
</Button>
</Link>
</DrawerFooter>
</>
);
}
3 changes: 1 addition & 2 deletions src/app/components/activity/Activity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ export default function Activity() {
<Link
className='w-fit'
href={{
pathname: '/transactions',
query: { isSheetOpen: true },
pathname: '/transactions'
}}
>
<Button
Expand Down
Loading

0 comments on commit 091b01e

Please sign in to comment.