Skip to content

Commit

Permalink
Add etherIcon and balance functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-vahn committed Apr 26, 2024
1 parent 8f4bfdd commit fb4a4a6
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -63,7 +64,9 @@ function App() {

// Get Accounts
const [account, setAccount] = useState<string | null>(null);
const getAccounts = () => {
const [balance, setBalance] = useState<string | null>(null);

const getAccountAndBalance = () => {
const providerId = window.localStorage.getItem('providerId');
axios
.get(BRIDGE_URL + '/accounts/' + providerId, {
Expand All @@ -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 = () => {
Expand Down Expand Up @@ -110,7 +126,7 @@ function App() {
WebApp.MainButton.textColor = '#ffffff';
WebApp.MainButton.onClick(openWallet);

getAccounts();
getAccountAndBalance();
}
if (view === View.WALLET) {
WebApp.MainButton.show();
Expand Down Expand Up @@ -251,7 +267,7 @@ function App() {
<p>{account}</p>
</div>
<div className="wallet-provider-icon">
<img src={tonConnectIcon} alt="" />
<img src={etherIcon} alt="" />
</div>
<div className="wallet-balance-details">
<div className="wallet-balance-header">
Expand All @@ -264,7 +280,7 @@ function App() {
/>
</div>
<div className="wallet-balance-value">
200
{balance || 0}
</div>
</div>
</div>
Expand Down
35 changes: 35 additions & 0 deletions src/assets/ethereum.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fb4a4a6

Please sign in to comment.