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

refactor: hide mainsail not supported transactions #439

Closed
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
15 changes: 13 additions & 2 deletions src/domains/transaction/hooks/use-transaction-types.ts
Original file line number Diff line number Diff line change
@@ -85,10 +85,14 @@ export const useTransactionTypes = ({ wallets = [] }: TransactionTypeProperties
},
};

const mainsailUnsupportedTypes = new Set(["htlcClaim", "htlcLock", "htlcRefund", "ipfs", "secondSignature", "magistrate"]);
Copy link
Contributor

Choose a reason for hiding this comment

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

this shouldn't be necessary. The wallet.transactionTypes() should instead only list supported types. For example for Mainsail it currently lists these when you log it:

["delegateRegistration","usernameRegistration","usernameResignation","delegateResignation","ipfs","multiPayment","multiSignature","secondSignature","transfer","vote"]

This still includes IPFS and secondSignature, but that means you need to adjust this on the PSDK side to not return unsupported transaction types


const isMainsail = wallets.some((wallet) => wallet.network().coinName() === "Mainsail");

return {
canViewMagistrate: useMemo(
() =>
wallets.some((wallet) =>
!isMainsail && wallets.some((wallet) =>
(wallet.transactionTypes() as string[]).filter((type) => type === MagistrateTransactionType),
),
[wallets],
@@ -105,7 +109,14 @@ export const useTransactionTypes = ({ wallets = [] }: TransactionTypeProperties
);
}

return uniq(allSupportedTypes);
const types = uniq(allSupportedTypes);

if (isMainsail) {
return types.filter((type) => !mainsailUnsupportedTypes.has(type));
}

return types;

}, [wallets]),
magistrate: [MagistrateTransactionType],
},
Loading