Skip to content

Commit

Permalink
working on tx history
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen-Gordon committed Feb 1, 2024
1 parent 6b82481 commit e9c93ba
Show file tree
Hide file tree
Showing 10 changed files with 1,665 additions and 136 deletions.
1,606 changes: 1,509 additions & 97 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"prepare": "husky install"
},
"dependencies": {
"@headlessui/react": "^1.7.18",
"@radix-ui/themes": "^2.0.3",
"@reduxjs/toolkit": "^2.1.0",
"@tanstack/react-query": "^5.17.19",
"@wagmi/core": "^2.6.1",
Expand Down
3 changes: 1 addition & 2 deletions src/app/components/Balance/Balance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ export default function Balance() {


return (
<div>
<div className="text-white">
{result?.data?.formatted}

</div>
);
}
11 changes: 6 additions & 5 deletions src/app/components/Layouts/Sheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ const Sheet = ({ children }) => {
transition={{ type: 'spring', damping: 20, stiffness: 300 }}
style={{
width: '100%',
maxHeight: '80%',
minHeight: '80%',
backgroundColor: '#2C2D33',
borderTopLeftRadius: '16px',
borderTopRightRadius: '16px',

minHeight: '90%',
backgroundColor: '',
borderTopLeftRadius: '32px',
borderTopRightRadius: '32px',
}}
className='bg-paper'
>
<div>{children}</div>
</motion.div>
Expand Down
48 changes: 48 additions & 0 deletions src/app/components/activity/Activity.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use client'
import useGetAddress from "@/app/hooks/useGetAddress";
import useGetRecentTransactions from "@/app/hooks/useGetRecentTransactions";
import { useEffect, useState } from "react";

export default function Activity() {
const [transactions, setTransactions] = useState(null);
const address = useGetAddress();

useEffect(() => {

const getData = async () => {
try {
const recentTransactions = await useGetRecentTransactions();

setTransactions(recentTransactions);
} catch (error) {
console.error("Error while getting recent transactions:", error);
}
};

getData();
}, [address]); // Add address as a dependency if it's used inside useGetRecentTransactions

useEffect(() => {
if (transactions) {
console.log("transactions", transactions);
}
}, [transactions]); // Add transactions as a dependency

return (
<>
<div className='h-96 bg-paper rounded-xl w-full text-xl p-4'>
<div>
Recent
</div>
{/* Uncomment this section to render transactions when available */}
<div className="mt-4">
{/* {transactions && transactions.map((t, i) => (
<div key={i}>
{i} hello
</div>
))} */}
</div>
</div>
</>
);
}
77 changes: 55 additions & 22 deletions src/app/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import Balance from '../components/Balance/Balance';
import Send from '../components/Send/Send';
import { useSelector } from 'react-redux';
import { RootState } from '@/GlobalRedux/store';
import { Tab } from '@headlessui/react'


import Activity from '@/app/components/activity/activity';

export default function Page() {
const kernalReduxState = useSelector(
Expand All @@ -14,33 +18,62 @@ export default function Page() {
console.log('kernalReduxState', kernalReduxState);

return (
<div>
<div className='mt-60 items-center text-center text-5xl'>
<div className='pt-40 p-8'>
<div className=' items-center text-center text-5xl'>
<Balance />
</div>

<Link
href={{
pathname: '/send',
query: { address: '12345' },
}}
>
<button className='rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700'>
Go to send Usdc
</button>
</Link>
<Link
href={{
pathname: '/search',
}}
>
<button className='rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700'>
Search Address
</button>
</Link>
<div className='mt-10 flex justify-between'>
<Link
href={{
pathname: '/search',
query: { address: '12345' },
}}
>
<button className='rounded w-40 bg-purple px-4 py-2 text-white hover:bg-blue-700 text-lg'>
Send
</button>

</Link>
<Link
href={{
pathname: '/receive',
query: { address: '12345' },
}}
>
<button className='rounded w-40 bg-purple px-4 py-2 text-white hover:bg-blue-700 text-lg'>
Receive
</button>
</Link>

</div>
<Tab.Group>
<Tab.List >
<div className=' flex justify-between'>
<Tab>
<div className='text-xl text-gray-300'>
Account
</div>
</Tab>
<Tab>
<div className='text-xl text-gray-300'>
Activity
</div>
</Tab>
</div>
</Tab.List>
<Tab.Panels>
<Tab.Panel>
<Activity />

</Tab.Panel>
<Tab.Panel>Content 2</Tab.Panel>
</Tab.Panels>
</Tab.Group>

{/* <Send /> */}
{/* <Account />
<Connect /> */}
</div>
</div >
);
}
29 changes: 29 additions & 0 deletions src/app/hooks/useGetRecentTransactions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

import useGetAddress from '@/app/hooks/useGetAddress';
import { Alchemy, Network } from 'alchemy-sdk';

const useGetRecentTransactions = async () => {
try {

const config = {
apiKey: process.env.NEXT_PUBLIC_ALCHEMY_API_KEY,
network: Network.MATIC_MUMBAI,
};
const alchemy = new Alchemy(config);
console.log("env", process.env.NEXT_PUBLIC_ALCHEMY_API_KEY)

const data = await alchemy.core.getAssetTransfers({
fromBlock: "0x0",
fromAddress: "0xc8C26Ab40fe4723519fE66B8dBb625FC070A982c",
category: ["erc20"],
});


return data;
} catch (error) {
console.log(error);
}

}

export default useGetRecentTransactions;
13 changes: 7 additions & 6 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Metadata } from 'next';
import * as React from 'react';

import { useEffect } from 'react';

import '@radix-ui/themes/styles.css';
// Redux
import { Providers } from '../GlobalRedux/provider';

Expand Down Expand Up @@ -68,6 +68,7 @@ import { PersistGate } from 'redux-persist/integration/react';
*/

import Link from 'next/link';
import { Theme, ThemePanel } from '@radix-ui/themes';
export default function RootLayout({
auth,
children,
Expand All @@ -92,11 +93,11 @@ export default function RootLayout({
<PersistGate loading={null} persistor={persistor}>
<WagmiProvider config={config!}>
<QueryClientProvider client={queryClient}>
<nav>
<Link href='/search'>Open modal</Link>
</nav>
<div>{authState && auth}</div>
<main>{children}</main>

<div>{auth}</div>
<main className='bg-dark w-screen h-screen text-gray-300'>{children}</main>


</QueryClientProvider>
</WagmiProvider>
</PersistGate>
Expand Down
6 changes: 3 additions & 3 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default function HomePage() {
const getDetails = async () => {
try {
console.log(provider);
} catch (error) {}
} catch (error) { }
};

const unloggedInView = (
Expand All @@ -125,7 +125,7 @@ export default function HomePage() {
console.log('setting kernal');
dispatch(setKernalClient(kernalClient));
console.log('kernal set');
} catch (error) {}
} catch (error) { }
};
setReduxKernal();
}, [kernalClient]);
Expand All @@ -151,7 +151,7 @@ export default function HomePage() {
});

console.log('userOp hash:', userOpHash);
} catch (error) {}
} catch (error) { }
};
/* const result = useBalance({
address: kernalClient?.account?.address,
Expand Down
6 changes: 5 additions & 1 deletion tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export default {
primary: ['Inter', ...defaultTheme.fontFamily.sans],
},
colors: {
main: '#101012',
dark: '#101012',
paper: '#2C2D33',
purple: '#6A48F2',
primary: {
// Customize it on globals.css :root
50: 'rgb(var(--tw-color-primary-50) / <alpha-value>)',
Expand All @@ -23,7 +27,7 @@ export default {
900: 'rgb(var(--tw-color-primary-900) / <alpha-value>)',
950: 'rgb(var(--tw-color-primary-950) / <alpha-value>)',
},
dark: '#222222',

},
keyframes: {
flicker: {
Expand Down

0 comments on commit e9c93ba

Please sign in to comment.