Skip to content

Commit

Permalink
feat: auto select the newly added token from the asset list (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Julink-eth authored Oct 3, 2022
1 parent 26c23bd commit b9f0282
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface Props {
}

export const AddTokenModalView = ({ closeModal }: Props) => {
const { addErc20Token } = useStarkNetSnap();
const { setErc20TokenBalance, addErc20Token } = useStarkNetSnap();
const [enabled, setEnabled] = useState(false);
const networks = useAppSelector((state) => state.networks);
const { accounts } = useAppSelector((state) => state.wallet);
Expand Down Expand Up @@ -77,14 +77,15 @@ export const AddTokenModalView = ({ closeModal }: Props) => {
enabled={enabled}
onClick={async () => {
try {
await addErc20Token(
const newToken = await addErc20Token(
fields.address,
fields.name,
fields.symbol,
parseFloat(fields.decimal),
chain,
accounts[0] as unknown as string,
);
setErc20TokenBalance(newToken);
toastr.success('Token added successfully');
closeModal();
} catch (err) {
Expand Down
1 change: 1 addition & 0 deletions packages/wallet-ui/src/services/useStarkNetSnap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ export const useStarkNetSnap = () => {
const tokenWithBalance: Erc20TokenBalance = addMissingPropertiesToToken(token, tokenBalance, usdPrice);
dispatch(upsertErc20TokenBalance(tokenWithBalance));
dispatch(disableLoading());
return tokenWithBalance;
};

const updateTokenBalance = async (tokenAddress: string, accountAddress: string, chainId: string) => {
Expand Down

0 comments on commit b9f0282

Please sign in to comment.