Skip to content

Commit

Permalink
fix: filter proxy wallets and base accounts (#2657)
Browse files Browse the repository at this point in the history
  • Loading branch information
sokolova-an authored Nov 15, 2024
1 parent 52ace73 commit 53c448e
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/renderer/entities/signatory/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ function getSignatoryWallet(wallets: Wallet[], accountId: AccountId): Wallet | u
return wallets.find((wallet) => {
const hasMatch = wallet.accounts.some((account) => account.accountId === accountId);

return hasMatch && walletUtils.isValidSignSignatory(wallet);
return hasMatch && walletUtils.isValidSignatory(wallet);
});
}
4 changes: 2 additions & 2 deletions src/renderer/pages/Operations/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const getSignatoryAccounts = (
const isChainMatch = accountUtils.isChainIdMatch(a, chainId);
const wallet = walletsMap.get(a.walletId);

return isChainMatch && walletUtils.isValidSignSignatory(wallet);
return isChainMatch && walletUtils.isValidSignatory(wallet);
});

if (signatoryAccount) {
Expand Down Expand Up @@ -236,7 +236,7 @@ export const getDelegationTracks = (tx: MultisigTransaction): string[] | undefin

if (!coreTxs || coreTxs.length === 0) return;

return coreTxs.map((tx: Transaction) => tx.args.track.toString());
return coreTxs.map((tx: Transaction) => tx.args.track?.toString());
};

export const getUndelegationData = async (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const Confirmation = ({ tx, account, chainConnection, signAccount, feeTx,

const wallets = useUnit(walletModel.$wallets);
const signerWallet = walletUtils.getWalletFilteredAccounts(wallets, {
walletFn: walletUtils.isValidSignSignatory,
walletFn: walletUtils.isValidSignatory,
accountFn: (acc) => signAccount?.accountId === acc.accountId,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const RejectTxModal = ({ tx, account, connection, children }: Props) => {
const asset = getAssetById(tx.transaction?.args.assetId, connection.assets);

const signAccount = walletUtils.getWalletFilteredAccounts(wallets, {
walletFn: (wallet) => !walletUtils.isWatchOnly(wallet) && !walletUtils.isProxied(wallet),
walletFn: walletUtils.isValidSignatory,
accountFn: (account) => account.accountId === tx.depositor,
})?.accounts[0];

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/widgets/CreateWallet/model/signatory-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const $ownedSignatoriesWallets = combine(
{ wallets: walletModel.$wallets, signatories: $signatories },
({ wallets, signatories }) =>
walletUtils.getWalletsFilteredAccounts(wallets, {
walletFn: (w) => !walletUtils.isWatchOnly(w) && !walletUtils.isMultisig(w),
walletFn: (w) => walletUtils.isValidSignatory(w),
accountFn: (a) => signatories.some((s) => toAccountId(s.address) === a.accountId),
}) || [],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const SelectSignatories = () => {
isOwnAccount={index === 0}
signatoryName={value.name}
signatoryAddress={value.address}
selectedWallet={value.walletId}
selectedWalletId={value.walletId}
onDelete={signatoryModel.events.deleteSignatory}
/>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface Props {
signatoryName: string;
signatoryAddress: string;
signatoryIndex: number;
selectedWallet: string;
selectedWalletId: string;
isOwnAccount?: boolean;
onDelete?: (index: number) => void;
}
Expand All @@ -41,7 +41,7 @@ export const Signatory = ({
isOwnAccount = false,
signatoryName,
signatoryAddress,
selectedWallet,
selectedWalletId,
}: Props) => {
const { t } = useI18n();
const [query, setQuery] = useState('');
Expand All @@ -67,10 +67,7 @@ export const Signatory = ({

const ownAccountName =
walletUtils.getWalletsFilteredAccounts(wallets, {
walletFn: (w) =>
!walletUtils.isWatchOnly(w) &&
!walletUtils.isMultisig(w) &&
(!selectedWallet || w.id.toString() === selectedWallet),
walletFn: (w) => walletUtils.isValidSignatory(w) && (!selectedWalletId || w.id.toString() === selectedWalletId),
accountFn: (a) =>
toAccountId(signatoryAddress) === a.accountId && accountUtils.isChainIdMatch(a, chain.value.chainId),
})?.[0]?.name || '';
Expand Down Expand Up @@ -102,7 +99,11 @@ export const Signatory = ({

return acc.concat(
wallet.accounts
.filter((account) => accountUtils.isChainAndCryptoMatch(account, chain.value))
.filter(
(account) =>
accountUtils.isChainAndCryptoMatch(account, chain.value) &&
accountUtils.isNonBaseVaultAccount(account, wallet),
)
.map((account) => {
const address = toAddress(account.accountId, { prefix: chain.value.addressPrefix });

Expand All @@ -128,7 +129,7 @@ export const Signatory = ({
{
id: index.toString(),
element: (
<div className="flex items-center gap-x-2" key={walletType}>
<div className="flex items-center gap-x-2" key={`${walletType}-${index}`}>
<WalletIcon type={walletType as WalletFamily} />
<CaptionText className="font-semibold uppercase text-text-secondary">
{t(GroupLabels[walletType as WalletFamily])}
Expand Down Expand Up @@ -173,7 +174,7 @@ export const Signatory = ({
index: signatoryIndex,
name: newName,
address: signatoryAddress,
walletId: selectedWallet,
walletId: selectedWalletId,
});
};

Expand Down

0 comments on commit 53c448e

Please sign in to comment.