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

[tickets] Remove revoke tickets functionality #3754

Merged
merged 4 commits into from May 10, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 1 addition & 55 deletions app/actions/ControlActions.js
Expand Up @@ -2,11 +2,7 @@
import { wallet } from "wallet-preload-shim";
import * as sel from "selectors";
import { isValidAddress, isValidMasterPubKey } from "helpers";
import {
getStakeInfoAttempt,
startWalletServices,
getStartupWalletInfo
} from "./ClientActions";
import { startWalletServices, getStartupWalletInfo } from "./ClientActions";
import { rawToHex } from "helpers/byteActions";
import { listUnspentOutputs } from "./TransactionActions";
import { updateUsedVSPs, getVSPTrackedTickets } from "./VSPActions";
Expand Down Expand Up @@ -521,56 +517,6 @@ export const newPurchaseTicketsAttempt = (
}
};

export const REVOKETICKETS_ATTEMPT = "REVOKETICKETS_ATTEMPT";
export const REVOKETICKETS_FAILED = "REVOKETICKETS_FAILED";
export const REVOKETICKETS_SUCCESS = "REVOKETICKETS_SUCCESS";

export const revokeTicketsAttempt = (passphrase) => async (
dispatch,
getState
) => {
dispatch({ type: REVOKETICKETS_ATTEMPT });
const walletService = sel.walletService(getState());
try {
const revokeTicketsResponse = await dispatch(
unlockAllAcctAndExecFn(passphrase, () =>
wallet.revokeTickets(walletService)
)
);
dispatch({ revokeTicketsResponse, type: REVOKETICKETS_SUCCESS });
setTimeout(() => {
dispatch(getStakeInfoAttempt());
}, 4000);
} catch (error) {
dispatch({ error, type: REVOKETICKETS_FAILED });
}
};

export const REVOKETICKET_ATTEMPT = "REVOKETICKET_ATTEMPT";
export const REVOKETICKET_FAILED = "REVOKETICKET_FAILED";
export const REVOKETICKET_SUCCESS = "REVOKETICKET_SUCCESS";

export const revokeTicketAttempt = (passphrase, ticketHash) => async (
dispatch,
getState
) => {
dispatch({ type: REVOKETICKET_ATTEMPT });
const walletService = sel.walletService(getState());
try {
const revokeTicketResponse = await dispatch(
unlockAllAcctAndExecFn(passphrase, () =>
wallet.revokeTicket(walletService, ticketHash)
)
);
dispatch({ revokeTicketResponse, type: REVOKETICKET_SUCCESS });
setTimeout(() => {
dispatch(getStakeInfoAttempt());
}, 4000);
} catch (error) {
dispatch({ error, type: REVOKETICKET_FAILED });
}
};

export const DISCOVERUSAGE_ATTEMPT = "DISCOVERUSAGE_ATTEMPT";
export const DISCOVERUSAGE_FAILED = "DISCOVERUSAGE_FAILED";
export const DISCOVERUSAGE_SUCCESS = "DISCOVERUSAGE_SUCCESS";
Expand Down
1 change: 0 additions & 1 deletion app/components/buttons/index.js
Expand Up @@ -147,7 +147,6 @@ export const AppPassAndPassphraseModalButton = mbb(
KeyBlueButton
);

export const RevokeModalButton = mbb(null, PassphraseModal, PiUiButton);
export const TicketPurchaseModalButton = mbb(null, PassphraseModal, PiUiButton);

export const AutoBuyerPassphraseModalSwitch = mbb(
Expand Down
34 changes: 0 additions & 34 deletions app/components/shared/PurchaseTicketsForm/PurchaseTicketsForm.jsx
Expand Up @@ -2,7 +2,6 @@ import { FormattedMessage as T, defineMessages } from "react-intl";
import { classNames, Checkbox, Tooltip } from "pi-ui";
import {
TicketPurchaseModalButton,
RevokeModalButton,
PiUiButton,
TicketsCogs,
ImportScriptIconButton,
Expand All @@ -20,7 +19,6 @@ import styles from "./PurchaseTicketsForm.module.css";
import { useIntl } from "react-intl";

const purchaseLabel = () => <T id="purchaseTickets.purchaseBtn" m="Purchase" />;
const revokeLabel = () => <T id="purchaseTickets.revokeBtn" m="Revoke" />;

const messages = defineMessages({
insufficientBalanceErrorMsg: {
Expand All @@ -30,7 +28,6 @@ const messages = defineMessages({
});

const PurchaseTicketsForm = ({
spvMode,
isValid,
handleOnKeyDown,
numTicketsToBuy,
Expand All @@ -46,7 +43,6 @@ const PurchaseTicketsForm = ({
vspFee,
setVspFee,
onPurchaseTickets,
onRevokeTickets,
availableVSPs,
isLoading,
rememberedVspHost,
Expand Down Expand Up @@ -243,36 +239,6 @@ const PurchaseTicketsForm = ({
</div>
)}
<div className={styles.buttonsArea}>
{getRunningIndicator ? (
<Tooltip
contentClassName={styles.disabledTooltip}
content={
<T
id="tickets.revoke.running"
m="Privacy Mixer or Autobuyer running, please shut them off before revoking tickets."
/>
}>
<PiUiButton disabled={true} className={styles.revokeButton}>
{revokeLabel()}
</PiUiButton>
</Tooltip>
) : (
!spvMode && (
<RevokeModalButton
modalTitle={
<T
id="tickets.revokeConfirmations"
m="Revoke Tickets Confirmation"
/>
}
className={styles.revokeButton}
onSubmit={onRevokeTickets}
kind="secondary"
buttonLabel={revokeLabel()}
/>
)
)}

{isWatchingOnly ? (
<PiUiButton disabled={!isValid} onClick={onPurchaseTickets}>
{purchaseLabel()}
Expand Down
Expand Up @@ -121,9 +121,6 @@
width: 764px;
justify-content: flex-end;
}
.revokeButton {
margin-right: 10px;
}
.vspContainer {
display: flex;
font-size: 16px;
Expand Down
Expand Up @@ -2,7 +2,7 @@ import { FormattedMessage as T } from "react-intl";
import { SettingsInput } from "inputs";
import styles from "./MiscSettings.module.css";
import { DiscoverUsageModal } from "modals";
import { KeyBlueButton, ImportScriptIconButton } from "buttons";
import { KeyBlueButton } from "buttons";
import { useSettings } from "hooks";
import { Label, Box } from "../../helpers";

Expand Down Expand Up @@ -63,12 +63,6 @@ const MiscSettings = ({ tempSettings, currencies, onChangeTempSettings }) => {
}}
/>
</div>
<div>
<Label id="import-script">
<T id="settings.importScript" m="Import script" />
</Label>
<ImportScriptIconButton ariaLabel="Import script button" />
</div>
</div>
</Box>
);
Expand Down
Expand Up @@ -69,7 +69,6 @@ export function PurchasePage({
isLoading,
rememberedVspHost,
toggleRememberVspHostCheckBox,
onRevokeTickets,
notMixedAccounts,
isVSPListingEnabled,
onEnableVSPListing,
Expand Down Expand Up @@ -114,7 +113,6 @@ export function PurchasePage({
isLoading,
rememberedVspHost,
toggleRememberVspHostCheckBox,
onRevokeTickets,
getRunningIndicator,
toggleIsLegacy,
isLegacy: false
Expand Down
Expand Up @@ -22,7 +22,6 @@ const Tickets = ({ toggleIsLegacy }) => {
isLoading,
rememberedVspHost,
setRememberedVspHost,
onRevokeTickets,
notMixedAccounts,
isVSPListingEnabled,
onEnableVSPListing,
Expand Down Expand Up @@ -138,7 +137,6 @@ const Tickets = ({ toggleIsLegacy }) => {
isLoading,
rememberedVspHost,
toggleRememberVspHostCheckBox,
onRevokeTickets,
notMixedAccounts,
isVSPListingEnabled,
onEnableVSPListing,
Expand Down
4 changes: 0 additions & 4 deletions app/components/views/TicketsPage/PurchaseTab/hooks.js
Expand Up @@ -80,9 +80,6 @@ export const usePurchaseTab = () => {
dispatch(vspa.toggleIsLegacy(isLegacy));
};

const onRevokeTickets = (passphrase) =>
dispatch(ca.revokeTicketsAttempt(passphrase));

const setRememberedVspHost = (vsp) =>
dispatch(vspa.setRememberedVspHost(vsp));

Expand Down Expand Up @@ -118,7 +115,6 @@ export const usePurchaseTab = () => {
isLoading,
rememberedVspHost,
setRememberedVspHost,
onRevokeTickets,
notMixedAccounts,
isVSPListingEnabled,
onEnableVSPListing,
Expand Down
@@ -1,7 +1,6 @@
import { Balance, ExternalLink } from "shared";
import {
KeyBlueButton,
RevokeModalButton,
CopyToClipboardButton,
PassphraseModalButton
} from "buttons";
Expand Down Expand Up @@ -46,10 +45,8 @@ const TransactionContent = ({
transactionDetails,
decodedTransaction,
abandonTransaction,
onRevokeTicket,
publishUnminedTransactions,
currentBlockHeight,
isSPV,
agendas,
getAgendaSelectedChoice,
getVSPTicketStatus,
Expand Down Expand Up @@ -105,10 +102,6 @@ const TransactionContent = ({
.map(mapNonWalletOutput);
}

const revokeTicket = (passphrase) => {
onRevokeTicket(passphrase, txHash);
};

return (
<>
<div className={styles.top}>
Expand Down Expand Up @@ -322,7 +315,7 @@ const TransactionContent = ({
</>
)}
</div>
{isPending ? (
{isPending && (
<div className={styles.buttonContainer}>
<div className={styles.rebroadcastBtnContainer}>
<KeyBlueButton
Expand All @@ -342,34 +335,6 @@ const TransactionContent = ({
</KeyBlueButton>
</div>
</div>
) : (
txType == TICKET &&
isSPV && (
<div>
<div className={styles.revokeBtnContainer}>
<RevokeModalButton
modalTitle={
<T
id="tickets.revokeTicketConfirmations"
m="Revoke Ticket Confirmation"
/>
}
modalDescription={
<T
id="tickets.revokeTicketDescription"
m="Before continuing, please confirm that this ticket is missed or expired on dcrdata. Any ticket that is still awaiting vote, may not be revoked and you may be left with an errored transaction that must be abandoned."
/>
}
className={styles.revokeBtn}
onSubmit={revokeTicket}
kind="secondary"
buttonLabel={
<T id="txDetails.revokeTicket" m="Revoke Ticket" />
}
/>
</div>
</div>
)
)}
<div className={styles.io}>
<div className={styles.title}>
Expand Down
2 changes: 0 additions & 2 deletions app/components/views/TransactionPage/TransactionPage.jsx
Expand Up @@ -10,7 +10,6 @@ const Transaction = () => {
const { txHash } = useParams();
const {
abandonTransaction,
onRevokeTicket,
publishUnminedTransactions,
currentBlockHeight,
state,
Expand Down Expand Up @@ -46,7 +45,6 @@ const Transaction = () => {
transactionDetails: viewedTransaction,
decodedTransaction: decodedTx,
abandonTransaction,
onRevokeTicket,
publishUnminedTransactions,
currentBlockHeight,
isSPV,
Expand Down
6 changes: 0 additions & 6 deletions app/components/views/TransactionPage/hooks.js
Expand Up @@ -37,11 +37,6 @@ export function useTransactionPage(txHash) {
(txHash) => dispatch(clia.abandonTransactionAttempt(txHash)),
[dispatch]
);
const onRevokeTicket = useCallback(
(passphrase, ticketHash) =>
dispatch(ca.revokeTicketAttempt(passphrase, ticketHash)),
[dispatch]
);
const decodeRawTransactions = useCallback(
(hexTx, txHash) => dispatch(ta.decodeRawTransaction(hexTx, txHash)),
[dispatch]
Expand Down Expand Up @@ -108,7 +103,6 @@ export function useTransactionPage(txHash) {

return {
abandonTransaction,
onRevokeTicket,
publishUnminedTransactions,
currentBlockHeight,
state,
Expand Down
44 changes: 0 additions & 44 deletions app/reducers/control.js
Expand Up @@ -41,12 +41,6 @@ import {
PURCHASETICKETS_FAILED,
PURCHASETICKETS_SUCCESS,
PURCHASETICKETS_SUCCESS_LESS,
REVOKETICKETS_ATTEMPT,
REVOKETICKETS_FAILED,
REVOKETICKETS_SUCCESS,
REVOKETICKET_ATTEMPT,
REVOKETICKET_FAILED,
REVOKETICKET_SUCCESS,
GETTICKETBUYERCONFIG_ATTEMPT,
GETTICKETBUYERCONFIG_FAILED,
GETTICKETBUYERCONFIG_SUCCESS,
Expand Down Expand Up @@ -383,44 +377,6 @@ export default function control(state = {}, action) {
purchaseTicketsResponse: action.purchaseTicketsResponse,
numTicketsToBuy: 1
};
case REVOKETICKETS_ATTEMPT:
return {
...state,
revokeTicketsError: null,
revokeTicketsRequestAttempt: true
};
case REVOKETICKETS_FAILED:
return {
...state,
revokeTicketsError: String(action.error),
revokeTicketsRequestAttempt: false
};
case REVOKETICKETS_SUCCESS:
return {
...state,
revokeTicketsError: null,
revokeTicketsRequestAttempt: false,
revokeTicketsResponse: action.revokeTicketsResponse
};
case REVOKETICKET_ATTEMPT:
return {
...state,
revokeTicketError: null,
revokeTicketRequestAttempt: true
};
case REVOKETICKET_FAILED:
return {
...state,
revokeTicketError: String(action.error),
revokeTicketRequestAttempt: false
};
case REVOKETICKET_SUCCESS:
return {
...state,
revokeTicketError: null,
revokeTicketRequestAttempt: false,
revokeTicketResponse: action.revokeTicketResponse
};
case GETTICKETBUYERCONFIG_ATTEMPT:
return {
...state,
Expand Down