Skip to content

Commit

Permalink
feat: display locked balance and free balance
Browse files Browse the repository at this point in the history
  • Loading branch information
anukulpandey committed Sep 5, 2024
1 parent 47d52fe commit b17f5e6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { extension as reefExt } from '@reef-chain/util-lib';
import { Components } from '@reef-chain/react-lib';
import Nav from './common/Nav';
import OptionContext from './context/OptionContext';
import { BigNumber} from "ethers";
import ReefSignersContext from './context/ReefSigners';
import ContentRouter from './pages/ContentRouter';
import { notify } from './utils/utils';
Expand Down Expand Up @@ -62,19 +63,38 @@ const App = (): JSX.Element => {
const {loading:wcPreloader,setLoading:setWcPreloader} = useWcPreloader()
const [accounts,setAccounts] = useState<ReefSigner[]>([]);
const [selectedSigner,setSelectedSigner] = useState<ReefSigner | undefined>(undefined);


const {
loading, error, signers, selectedReefSigner, network, provider, reefState, extension
} = hooks.useInitReefStateExtension(
'Reef App', selExtensionName, { ipfsHashResolverFn: getIpfsGatewayUrl },
);

const accountsBalances = hooks.useObservableState(reefState.accounts$);

useEffect(()=>{
let updatedAccountsList:any = []

Check failure on line 77 in src/App.tsx

View workflow job for this annotation

GitHub Actions / unit-lint

Unexpected any. Specify a different type
if(signers && accountsBalances){
signers.forEach((sgnr,idx)=>{
let accountUpdatedBal = {
...sgnr,
freeBalance: accountsBalances[idx].freeBalance?? BigNumber.from("0"),
lockedBalance:accountsBalances[idx].lockedBalance?? BigNumber.from("0")
}
updatedAccountsList.push(accountUpdatedBal);
})

setAccounts(updatedAccountsList);
}
},[accountsBalances,signers])

useEffect(()=>{
setAccounts([]);
setSelectedSigner(undefined);
},[selExtensionName])

useEffect(()=>{
setAccounts(signers);
setSelectedSigner(selectedReefSigner);

// if account connected , hide preloader & set account address
Expand Down Expand Up @@ -182,8 +202,6 @@ useEffect(()=>{
}
}

const {isAccountSelectorOpen} = useAccountSelector()

// @ts-ignore
return (
<>
Expand Down
3 changes: 3 additions & 0 deletions src/common/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ const Nav = ({ selectExtension }: Nav): JSX.Element => {
window.location.reload();
}

console.log(accounts)

const {setLoading:setWcPreloader}=useWcPreloader();
const {isAccountSelectorOpen,setIsAccountSelectorOpen} = useAccountSelector();

Expand All @@ -179,6 +181,7 @@ const Nav = ({ selectExtension }: Nav): JSX.Element => {
{menuItemsView}
</ul>}


<Components.AccountSelector
selExtName={selExtName}
availableExtensions={availableExtensions}
Expand Down

0 comments on commit b17f5e6

Please sign in to comment.