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

[BX-1294] Fix missing wallets in Send flow #1368

Merged
merged 3 commits into from
Mar 12, 2024

Conversation

BrodyHughes
Copy link
Member

@BrodyHughes BrodyHughes commented Feb 28, 2024

Fixes BX-1294

What changed (plus any additional context for devs)

  • was previously just checking the order of wallets in useWalletOrderStore() and returning those. this was only ever updated when the order was changed in the walletSwitcher.
  • I updated the send flow to check the existing list of wallets in getAccounts() and then compare that to the order of the wallets in useWalletOrderStore()
  • it then updates the useWalletOrderStore() with all the wallets in the correct order and also updated the useWalletOrderStore()

What to test

  • see if send suggestions includes all the wallets in your bx aside from the current wallet
  • make sure code makes sense

Screen recordings / screenshots

Screen.Recording.2024-02-28.at.4.14.30.PM.mov

Copy link

linear bot commented Feb 28, 2024

Copy link

Here's the packed extension for this build:
node_modules.tar.gz
rainbowbx-3eccd1794c1869d37b739c89c2cbdeab4ea0905c.zip
screenshots

Copy link

Here's the packed extension for this build:
rainbowbx-3eccd1794c1869d37b739c89c2cbdeab4ea0905c.zip

Copy link
Collaborator

@DanielSinclair DanielSinclair left a comment

Choose a reason for hiding this comment

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

Functionality looks good to me; didn't review code

Comment on lines 165 to 202
const [newWalletOrder, setNewWalletOrder] = useState<`0x${string}`[]>([]);
const { walletOrder, saveWalletOrder } = useWalletOrderStore();

// find the items in getAccounts then compare to the current
// walletOrder, then return all items in getAccounts in order

useEffect(() => {
const combineAndOrderArrays = async (orderArray: string[]) => {
const orderSet = new Set(orderArray);
const primaryArray = await getAccounts();
const itemsNotInOrderArray = primaryArray.filter(
(item) => !orderSet.has(item),
);

const primaryMap = new Map(primaryArray.map((item) => [item, item]));

const combinedAndOrdered = [
...orderArray.filter((item) => primaryMap.has(item)),
...itemsNotInOrderArray,
];

return combinedAndOrdered;
};

combineAndOrderArrays(walletOrder).then((orderedAccounts) => {
setNewWalletOrder(orderedAccounts as `0x${string}`[]);
saveWalletOrder(orderedAccounts as `0x${string}`[]);
});
}, [walletOrder, saveWalletOrder]);

const sortedWallets = useMemo(
() => sortWallets(walletOrder, wallets),
[wallets, walletOrder],
() => sortWallets(newWalletOrder, wallets),
[newWalletOrder, wallets],
);
const sortedWatchedWallets = useMemo(
() => sortWallets(walletOrder, watchedWallets),
[watchedWallets, walletOrder],
() => sortWallets(newWalletOrder, watchedWallets),
[newWalletOrder, watchedWallets],
);
Copy link
Contributor

Choose a reason for hiding this comment

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

after playing with it a bit I'm pretty sure the props are in the right state already, we just need to remove all sorting from inside this component
like
Screenshot 2024-03-07 at 15 46 33

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

changed lol

@BrodyHughes BrodyHughes added this pull request to the merge queue Mar 12, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 12, 2024
@DanielSinclair DanielSinclair added this pull request to the merge queue Mar 12, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 12, 2024
@DanielSinclair DanielSinclair added this pull request to the merge queue Mar 12, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 12, 2024
@DanielSinclair DanielSinclair added this pull request to the merge queue Mar 12, 2024
Merged via the queue into master with commit e854e6d Mar 12, 2024
17 checks passed
@DanielSinclair DanielSinclair deleted the brody/send-auto-fill-suggestions branch March 12, 2024 06:00
Copy link

Here's the packed extension for this build:
node_modules.tar.gz
rainbowbx-e854e6dd59f05269dd10b62a7918ddcb967f807b.zip
screenshots

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.

3 participants