Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix max amt send #102

Merged
merged 4 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 { 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 All @@ -23,7 +24,7 @@
import useWcPreloader from './hooks/useWcPreloader';
import WcPreloader from './common/WcPreloader';
import useAccountSelector from './hooks/useAccountSelector';

Check failure on line 27 in src/App.tsx

View workflow job for this annotation

GitHub Actions / unit-lint

All imports in import declaration are unused
const { WalletSelector, walletSelectorOptions } = Components;

export const availableWalletOptions = [
Expand All @@ -34,7 +35,7 @@
];

export const connectWalletConnect = async(ident:string,setSelExtensionName:any,setWcPreloader:any)=>{
setWcPreloader({

Check warning on line 38 in src/App.tsx

View workflow job for this annotation

GitHub Actions / unit-lint

Missing return type on function

Check failure on line 38 in src/App.tsx

View workflow job for this annotation

GitHub Actions / unit-lint

Missing return type on function

Check warning on line 38 in src/App.tsx

View workflow job for this annotation

GitHub Actions / unit-lint

Argument 'setSelExtensionName' should be typed with a non-any type

Check failure on line 38 in src/App.tsx

View workflow job for this annotation

GitHub Actions / unit-lint

Unexpected any. Specify a different type

Check warning on line 38 in src/App.tsx

View workflow job for this annotation

GitHub Actions / unit-lint

Argument 'setWcPreloader' should be typed with a non-any type

Check failure on line 38 in src/App.tsx

View workflow job for this annotation

GitHub Actions / unit-lint

Unexpected any. Specify a different type
value:true,
message:"initializing mobile app connection"
});
Expand Down Expand Up @@ -62,26 +63,45 @@
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
if(signers?.length && signers?.indexOf(selectedReefSigner!)==-1){

Check warning on line 101 in src/App.tsx

View workflow job for this annotation

GitHub Actions / unit-lint

Forbidden non-null assertion

Check failure on line 101 in src/App.tsx

View workflow job for this annotation

GitHub Actions / unit-lint

Expected '===' and instead saw '=='
reefState.setSelectedAddress(signers[0].address)
}
},[selectedReefSigner,signers])

Check warning on line 104 in src/App.tsx

View workflow job for this annotation

GitHub Actions / unit-lint

React Hook useEffect has a missing dependency: 'reefState'. Either include it or remove the dependency array

const history = useHistory();
const [isBalanceHidden, setBalanceHidden] = useState(getStoredPref());
Expand All @@ -105,7 +125,7 @@
if (selExtensionName === reefExt.REEF_SNAP_IDENT && error?.code === 2) {
history.push(SNAP_URL);
}
}, [extension, error]);

Check warning on line 128 in src/App.tsx

View workflow job for this annotation

GitHub Actions / unit-lint

React Hook useEffect has missing dependencies: 'history' and 'selExtensionName'. Either include them or remove the dependency array

const[errorToast,setErrorToast] = useState<{
message:String;
Expand All @@ -114,7 +134,7 @@

useEffect(()=>{
if(errorToast){
if(errorToast.type == "danger"){

Check failure on line 137 in src/App.tsx

View workflow job for this annotation

GitHub Actions / unit-lint

Expected '===' and instead saw '=='
Uik.notify.danger(errorToast.message.toString());
}else{
Uik.notify.danger({
Expand All @@ -126,7 +146,7 @@
fill
onClick={() => window.location.reload()}
/>
</>

Check failure on line 149 in src/App.tsx

View workflow job for this annotation

GitHub Actions / unit-lint

Expected indentation of 10 space characters but found 20
})
}
}
Expand Down Expand Up @@ -165,9 +185,9 @@
message:""
})
}
},[signers])

Check warning on line 188 in src/App.tsx

View workflow job for this annotation

GitHub Actions / unit-lint

React Hook useEffect has missing dependencies: 'setWcPreloader' and 'wcPreloader.value'. Either include them or remove the dependency array


Check failure on line 190 in src/App.tsx

View workflow job for this annotation

GitHub Actions / unit-lint

Missing return type on function

const onExtensionSelected = async(ident: string) => {
console.log('onExtensionSelected', ident);
Expand All @@ -175,15 +195,13 @@
if (ident === reefExt.REEF_WALLET_CONNECT_IDENT) {
await connectWalletConnect(ident,setSelExtensionName,setWcPreloader);
} else {
setSelExtensionName(ident);

Check failure on line 198 in src/App.tsx

View workflow job for this annotation

GitHub Actions / unit-lint

'error' is already declared in the upper scope
}
} catch (error) {
console.log(error);
}
}

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 @@ -49,14 +49,14 @@
availableExtensions.forEach((ext: Extension) => {
ext.installed = ext.name === extension?.name;
});
setAvailableExtensions(availableExtensions);

Check warning on line 52 in src/common/Nav.tsx

View workflow job for this annotation

GitHub Actions / unit-lint

React Hook useEffect has a missing dependency: 'extension?.name'. Either include it or remove the dependency array
}, [extension, selExtName]);

let menuItems = [
{ title: localizedStrings.dashboard, url: DASHBOARD_URL },
{ title: localizedStrings.bonds, url: BONDS_URL },
];
if (isReefswapUI) {

Check warning on line 59 in src/common/Nav.tsx

View workflow job for this annotation

GitHub Actions / unit-lint

React Hook useEffect has a missing dependency: 'availableExtensions'. Either include it or remove the dependency array. You can also do a functional update 'setAvailableExtensions(a => ...)' if you only need 'availableExtensions' in the 'setAvailableExtensions' call
menuItems = [
{ title: localizedStrings.tokens_pill, url: DASHBOARD_URL },
{ title: localizedStrings.pools, url: POOLS_URL },
Expand Down Expand Up @@ -149,7 +149,7 @@

const updateMetadata = async (): Promise<void> => {
if (!provider) return;
const metadata = getMetadata(provider.api);

Check warning on line 152 in src/common/Nav.tsx

View workflow job for this annotation

GitHub Actions / unit-lint

Forbidden non-null assertion
const updated = await sendToSnap('provideMetadata', metadata);
if (updated) setShowMetadataUpdate(false);
}
Expand Down Expand Up @@ -179,6 +179,7 @@
{menuItemsView}
</ul>}


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