Skip to content

Commit

Permalink
fix(suite): wait on solana transaction confirmation in review
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamSchinzel committed Mar 8, 2024
1 parent 1e1a116 commit 766c424
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const TransactionReviewModalContent = ({
const isActionAbortable = useSelector(selectIsActionAbortable);
const dispatch = useDispatch();
const [detailsOpen, setDetailsOpen] = useState(false);
const [isSending, setIsSending] = useState(false);

const deviceModelInternal = device?.features?.internal_model;

Expand Down Expand Up @@ -73,10 +74,6 @@ export const TransactionReviewModalContent = ({

const ethereumStakeType =
'ethereumStakeType' in precomposedForm ? precomposedForm.ethereumStakeType : null;
const actionText = getTransactionReviewModalActionText({
ethereumStakeType,
isRbfAction,
});

// omit other button requests (like passphrase)
const buttonRequests = device.buttonRequests.filter(
Expand Down Expand Up @@ -140,7 +137,10 @@ export const TransactionReviewModalContent = ({
broadcast={precomposedForm.options.includes('broadcast')}
detailsOpen={detailsOpen}
onDetailsClick={() => setDetailsOpen(!detailsOpen)}
actionText={actionText}
actionText={getTransactionReviewModalActionText({
ethereumStakeType,
isRbfAction,
})}
/>
<TransactionReviewOutputList
account={selectedAccount.account}
Expand All @@ -152,7 +152,13 @@ export const TransactionReviewModalContent = ({
outputs={outputs}
buttonRequestsCount={buttonRequestsCount}
isRbfAction={isRbfAction}
actionText={actionText}
actionText={getTransactionReviewModalActionText({
ethereumStakeType,
isRbfAction,
isSending,
})}
isSending={isSending}
setIsSending={() => setIsSending(true)}
/>
<TransactionReviewEvmExplanation account={selectedAccount.account} />
</StyledModal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ export interface TransactionReviewOutputListProps {
buttonRequestsCount: number;
isRbfAction: boolean;
actionText: TranslationKey;
isSending?: boolean;
setIsSending?: () => void;
}

export const TransactionReviewOutputList = ({
Expand All @@ -102,6 +104,8 @@ export const TransactionReviewOutputList = ({
buttonRequestsCount,
isRbfAction,
actionText,
isSending,
setIsSending,
}: TransactionReviewOutputListProps) => {
const dispatch = useDispatch();
const { networkType } = account;
Expand Down Expand Up @@ -141,6 +145,9 @@ export const TransactionReviewOutputList = ({
},
});
const handleSend = () => {
if (networkType === 'solana') {
setIsSending?.();
}
if (decision) {
decision.resolve(true);

Expand Down Expand Up @@ -228,6 +235,7 @@ export const TransactionReviewOutputList = ({
<StyledButton
data-test="@modal/send"
isDisabled={!signedTx}
isLoading={isSending}
onClick={handleSend}
>
<Translation id={actionText} />
Expand Down
4 changes: 4 additions & 0 deletions packages/suite/src/support/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6487,6 +6487,10 @@ export default defineMessages({
id: 'TR_REPLACE_TX',
defaultMessage: 'Replace transaction',
},
TR_CONFIRMING_TX: {
id: 'TR_CONFIRMING_TX',
defaultMessage: 'Confirming transaction',
},
TR_FINALIZE_TX: {
id: 'TR_FINALIZE_TX',
defaultMessage: 'Finalize transaction',
Expand Down
6 changes: 6 additions & 0 deletions packages/suite/src/utils/suite/transactionReview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { StakeFormState } from '@suite-common/wallet-types';
interface getTransactionReviewModalActionTextParams {
ethereumStakeType: StakeFormState['ethereumStakeType'] | null;
isRbfAction: boolean;
isSending?: boolean;
}

export const getTransactionReviewModalActionText = ({
ethereumStakeType,
isRbfAction,
isSending,
}: getTransactionReviewModalActionTextParams): TranslationKey => {
switch (ethereumStakeType) {
case 'stake':
Expand All @@ -24,5 +26,9 @@ export const getTransactionReviewModalActionText = ({
return 'TR_REPLACE_TX';
}

if (isSending) {
return 'TR_CONFIRMING_TX';
}

return 'SEND_TRANSACTION';
};

0 comments on commit 766c424

Please sign in to comment.