From fb4a4a6a0a0a441c4cfbd5cf1d1b2fe13d9caebf Mon Sep 17 00:00:00 2001 From: daniel-vahn Date: Fri, 26 Apr 2024 09:38:58 +0200 Subject: [PATCH] Add etherIcon and balance functionality --- src/App.tsx | 24 ++++++++++++++++++++---- src/assets/ethereum.svg | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 src/assets/ethereum.svg diff --git a/src/App.tsx b/src/App.tsx index 86308f7..b67ee4f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -23,6 +23,7 @@ import avatarTable from './assets/avatar_table.png'; import evmConnectIcon from './assets/EVM_connect_logos.png'; import tonConnectIcon from './assets/ton_connect.png'; +import etherIcon from './assets/ethereum.svg'; import sendIcon from './assets/send_icon.svg'; import receiveIcon from './assets/receive_icon.svg'; import sellIcon from './assets/sell_icon.svg'; @@ -63,7 +64,9 @@ function App() { // Get Accounts const [account, setAccount] = useState(null); - const getAccounts = () => { + const [balance, setBalance] = useState(null); + + const getAccountAndBalance = () => { const providerId = window.localStorage.getItem('providerId'); axios .get(BRIDGE_URL + '/accounts/' + providerId, { @@ -78,6 +81,19 @@ function App() { console.log(response.data.accounts[0]); setAccount(response.data.accounts[0]); }); + + axios + .get(BRIDGE_URL + '/balance/' + account, { + withCredentials: true, + headers: { + 'Content-Type': 'application/json', + 'ngrok-skip-browser-warning': 'true', + }, + }) + .then((response) => { + console.log(response.data.balance); + setBalance(response.data.balance); + }); }; const handleConnect = () => { @@ -110,7 +126,7 @@ function App() { WebApp.MainButton.textColor = '#ffffff'; WebApp.MainButton.onClick(openWallet); - getAccounts(); + getAccountAndBalance(); } if (view === View.WALLET) { WebApp.MainButton.show(); @@ -251,7 +267,7 @@ function App() {

{account}

- +
@@ -264,7 +280,7 @@ function App() { />
- 200 + {balance || 0}
diff --git a/src/assets/ethereum.svg b/src/assets/ethereum.svg new file mode 100644 index 0000000..4620c0e --- /dev/null +++ b/src/assets/ethereum.svg @@ -0,0 +1,35 @@ + + + + +Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + +