diff --git a/packages/site/src/pages/index.tsx b/packages/site/src/pages/index.tsx index c1476ac..47be446 100644 --- a/packages/site/src/pages/index.tsx +++ b/packages/site/src/pages/index.tsx @@ -55,11 +55,11 @@ import { LoginAccountButton, CreateAccountButton, SnapLogo, - CopyToClipboardButton + CopyToClipboardButton, } from '../components'; import SendIcon from '@mui/icons-material/Send'; import { SHA256 } from 'crypto-js'; -import {Network} from '../components'; +import { Network } from '../components'; const Container = styled.div` display: flex; @@ -418,7 +418,7 @@ const Index = () => { const handleCoinTransfer = async () => { closeSendModal(); try { - await sendCoin(recipientAddress, sendAmount , selectedNetwork); + await sendCoin(recipientAddress, sendAmount, selectedNetwork); const updatedBalance = await sendGetBalance(selectedNetwork); setBalance(updatedBalance); } catch (error) { @@ -447,10 +447,6 @@ const Index = () => { const getTxn = await sendTxnHistory(selectedNetwork); setTxnHistory(getTxn.txnHistory); toggleOpen(); - if (!txncCronJobActive) { - transactionCronJob(); - setTxnCronJobActive(true); - } } catch (error) { console.error(error); dispatch({ type: MetamaskActions.SetError, payload: error }); @@ -470,13 +466,12 @@ const Index = () => { setAnchorEl(null); }; - const handleNetworkSelect = async (network) => { + const handleNetworkSelect = async (network: string) => { setSelectedNetwork(network); handleDropdownClose(); - if(network === 'mainnet'){ + if (network === 'mainnet') { setIsMainnet(true); - } - else{ + } else { setIsMainnet(false); const updatedBalance = await sendGetBalance(network); setBalance(updatedBalance); @@ -634,7 +629,7 @@ const Index = () => { justifyContent: 'flex-start', alignItems: 'center', position: 'relative', - width:'50%', + width: '50%', }} > {' '} @@ -645,10 +640,10 @@ const Index = () => { alignItems: 'center', justifyContent: 'space-between', padding: '10px 0px', - background:'#F2F2F2', + background: '#F2F2F2', boxShadow: '0px 2px 4px rgba(0, 0, 0, 0.25)', borderRadius: '15px 15px 0px 0px', - width:'100%', + width: '100%', }} >
{ - {isMainet? 0 : balance / Math.pow(10, 8)} APT - + variant="h3" + gutterBottom + style={{ textAlign: 'center' }} + > + {isMainet ? 0 : balance / Math.pow(10, 8)} APT + -
+
- {!isMainet && } + {!isMainet && ( + + )}
{!open && ( -

Click on transaction history to view all transactions.

+

+ Click on transaction history to view all transactions. +

)} {open && txnHistory.length > 0 && (
{ overflowX: 'auto', overflowY: 'scroll', maxHeight: '480px', - width:'100%', + width: '100%', }} > @@ -881,21 +894,21 @@ const Index = () => { {milliToDate(txn.timestamp)} - { - window.open( - `https://explorer.aptoslabs.com/txn/${txn.hash}?network=${selectedNetwork}`, - '_blank', - ); - }} - /> + { + window.open( + `https://explorer.aptoslabs.com/txn/${txn.hash}?network=${selectedNetwork}`, + '_blank', + ); + }} + /> ))} diff --git a/packages/site/src/utils/snap.ts b/packages/site/src/utils/snap.ts index eb22e56..59a2177 100644 --- a/packages/site/src/utils/snap.ts +++ b/packages/site/src/utils/snap.ts @@ -139,7 +139,7 @@ export const sendGetBalance = async (network:string) => { }, }, }); - console.log('this is balance', balance); + console.log('this is balance', balance, " network: ", network); return balance.balance; }; diff --git a/packages/snap/snap.manifest.json b/packages/snap/snap.manifest.json index c553001..a78d6d5 100644 --- a/packages/snap/snap.manifest.json +++ b/packages/snap/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/template-snap-monorepo.git" }, "source": { - "shasum": "9g3sncuyfoE35ArTf2gpVpSI5ZarCRXNfOfcBBES7PE=", + "shasum": "8fmWtK9q5KxO5e323+7aa7DHOH6iVSuvI8zpafDP5qo=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/snap/src/utils/aptos/GetBal.ts b/packages/snap/src/utils/aptos/GetBal.ts index e1ef6c0..9e9371b 100644 --- a/packages/snap/src/utils/aptos/GetBal.ts +++ b/packages/snap/src/utils/aptos/GetBal.ts @@ -4,16 +4,25 @@ import getAccount from './GetAccount'; const HOST = 'http://localhost:5500'; export async function getBal(network: string) { - const account = await getAccount(); - const networkType = network.toUpperCase(); - const balance = await fetch(`${HOST}/getBalance`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ address: account.accountAddress.toString(), network: networkType }), - }).then((res) => res.json()); + const account = await getAccount(); + const networkType = network.toUpperCase(); + const balance = await fetch(`${HOST}/getBalance`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + address: account.accountAddress.toString(), + network: networkType, + }), + }).then((res) => res.json()); + if (balance) { + console.log({ balance }); + if ('amount' in balance[0]) { const bal = balance[0].amount; console.log('this is bal', bal); return bal; -} \ No newline at end of file + } + } + return 0; +} diff --git a/server/src/CheckBalance.ts b/server/src/CheckBalance.ts index bf67fa2..a29256b 100644 --- a/server/src/CheckBalance.ts +++ b/server/src/CheckBalance.ts @@ -25,6 +25,8 @@ export default async function checkBalance(request:Request) { const aptos = new Aptos(aptosConfig); const accountCoinsData: GetAccountCoinsDataResponse = await aptos.getAccountCoinsData({accountAddress: request.address}); console.log('this is accountCoinsData', accountCoinsData); + console.log({requestBody}) + console.log('network: ', networkType) return accountCoinsData;