generated from theodorusclarence/ts-nextjs-tailwind-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b82481
commit e9c93ba
Showing
10 changed files
with
1,665 additions
and
136 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters