Skip to content

Commit

Permalink
Fix max amt send (#102)
Browse files Browse the repository at this point in the history
* feat: display locked balance and free balance

* fix: max amt sent

---------

Co-authored-by: matjazonline <matjazonline@gmail.com>
  • Loading branch information
anukulpandey and matjazonline authored Oct 20, 2024
1 parent ce11152 commit ba06c5e
Show file tree
Hide file tree
Showing 2 changed files with 22 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
1 change: 1 addition & 0 deletions src/common/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ const Nav = ({ selectExtension }: Nav): JSX.Element => {
{menuItemsView}
</ul>}


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

0 comments on commit ba06c5e

Please sign in to comment.