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

feat: [ADN-335] Apply tm2-js-client for creating wallets #324

Merged
merged 6 commits into from
Jan 13, 2024

Conversation

jinoosss
Copy link
Member

@jinoosss jinoosss commented Jan 9, 2024

No description provided.

@@ -110,6 +111,10 @@ const SideMenuContainer: React.FC<SideMenuContainerProps> = ({ open, setOpen })
setOpen(false);
}, [setOpen]);

useEffect(() => {
getSideMenuAccounts().then(setSideMenuAccounts);
}, [getSideMenuAccounts]);
Copy link
Collaborator

@skqksh skqksh Jan 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't we use useQuery instead of useEffect

// e.g
  const { data: sideMenuAccounts = [] } = useQuery<SideMenuAccountInfo[]>(
    ['sideMenuAccounts', accountNames, accounts, accountNativeBalances, currentNetwork],
    () => {
      function mapBalance(
        accountNativeBalances: { [key in string]: TokenBalanceType },
        account: Account,
      ): string {
        const amount = accountNativeBalances[account.id]?.amount;
        if (!amount) {
          return '-';
        }
        return `${maxFractionDigits(amount.value, 6)} ${amount.denom}`;
      }

      return Promise.all(
        accounts.map(async (account) => ({
          accountId: account.id,
          name: formatNickname(accountNames[account.id] || account.name, 10),
          address: await account.getAddress(currentNetwork.addressPrefix),
          type: account.type,
          balance: mapBalance(accountNativeBalances, account),
        })),
      );
    },
    {
      enabled: !locked && accounts.length > 0 && !!currentNetwork,
    },
  );

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice and clear 👍.

@jinoosss jinoosss requested a review from skqksh January 12, 2024 09:08
@jinoosss jinoosss force-pushed the ADN-335-apply-tm-2-js-client-for-creating-wallets branch from b32c1ba to a13d7b5 Compare January 12, 2024 09:09
@skqksh skqksh merged commit a4ac65e into main Jan 13, 2024
2 checks passed
@skqksh skqksh deleted the ADN-335-apply-tm-2-js-client-for-creating-wallets branch January 13, 2024 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants