Skip to content

Commit

Permalink
Import script watch only (#2423)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlyp committed Mar 5, 2020
1 parent 327eb63 commit c6c7372
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 37 deletions.
2 changes: 1 addition & 1 deletion app/actions/ControlActions.js
Expand Up @@ -129,7 +129,7 @@ export const importScriptAttempt = (passphrase, script) =>
dispatch({ type: IMPORTSCRIPT_ATTEMPT });
const walletService = sel.walletService(getState());
try {
const importScriptResponse = await wallet.importScript(walletService, passphrase, script, false, 0);
const importScriptResponse = await wallet.importScript(walletService, passphrase, script);
dispatch({ importScriptResponse, type: IMPORTSCRIPT_SUCCESS });
return importScriptResponse;
} catch (error) {
Expand Down
47 changes: 16 additions & 31 deletions app/components/views/TicketsPage/PurchaseTab/index.js
Expand Up @@ -2,7 +2,6 @@ import { substruct, compose, eq, get } from "fp";
import { service, ticketsPage } from "connectors";
import PurchasePage from "./Page";
import { FormattedMessage as T } from "react-intl";
import WatchingOnlyWarnModal from "PseudoModal/WatchingOnlyWarn";

@autobind
class Purchase extends React.Component {
Expand All @@ -28,36 +27,22 @@ class Purchase extends React.Component {
}

render() {
const { isTicketPurchaseTabDisabled } = this.props;
return (
<>
{
isTicketPurchaseTabDisabled && <WatchingOnlyWarnModal />
}
<div className={ isTicketPurchaseTabDisabled ? "pseudo-modal-wrapper blur" : null }>
<PurchasePage
{...{
...this.props,
...this.state,
stakePool: this.getStakePool(),
account: this.getAccount(),
...substruct({
onChangeStakePool: null,
onChangeAccount: null,
onShowImportScript: null,
onShowRevokeTicket: null,
onCancelImportScript: null,
onToggleTicketStakePool: null,
onShowStakePoolConfig: null,
onHideStakePoolConfig: null,
onImportScript: null,
onRevokeTickets: null
}, this)
}}
/>
</div>
</>
);
return <PurchasePage {...{ ...this.props, ...this.state,
stakePool: this.getStakePool(),
account: this.getAccount(),
...substruct({
onChangeStakePool: null,
onChangeAccount: null,
onShowImportScript: null,
onShowRevokeTicket: null,
onCancelImportScript: null,
onToggleTicketStakePool: null,
onShowStakePoolConfig: null,
onHideStakePoolConfig: null,
onImportScript: null,
onRevokeTickets: null
}, this)
}} />;
}

onToggleTicketStakePool(side) {
Expand Down
1 change: 0 additions & 1 deletion app/connectors/ticketsPage.js
Expand Up @@ -29,7 +29,6 @@ const mapStateToProps = selectorMap({
isPurchasingTickets: sel.isPurchasingTickets,
isSavingStakePoolConfig: sel.isSavingStakePoolConfig,
isTestNet: sel.isTestNet,
isTicketPurchaseTabDisabled: sel.isTicketPurchaseTabDisabled,
numTicketsToBuy: sel.numTicketsToBuy,
sidebarOnBottom: sel.sidebarOnBottom
});
Expand Down
1 change: 0 additions & 1 deletion app/selectors.js
Expand Up @@ -906,7 +906,6 @@ export const isSignMessageDisabled = and(isWatchingOnly, not(isTrezor));
export const isCreateAccountDisabled = isWatchingOnly;
export const isChangePassPhraseDisabled = isWatchingOnly;
export const isTransactionsSendTabDisabled = not(isTrezor);
export const isTicketPurchaseTabDisabled = isWatchingOnly;

export const politeiaURL = createSelector(
[ isTestNet ],
Expand Down
6 changes: 3 additions & 3 deletions app/wallet/control.js
Expand Up @@ -48,13 +48,13 @@ export const importPrivateKey = (walletService, passphrase, accountNum, wif, res
walletService.importPrivateKey(request, (err, res) => err ? fail(err) : ok(res));
});

export const importScript = (walletService, passphrase, script, rescan, scanFrom) =>
export const importScript = (walletService, passphrase, script) =>
new Promise((ok, fail) => {
const request = new api.ImportScriptRequest();
request.setPassphrase(new Uint8Array(Buffer.from(passphrase)));
request.setScript(new Uint8Array(Buffer.from(hexToBytes(script))));
request.setRescan(rescan);
request.setScanFrom(scanFrom);
request.setRescan(false);
request.setScanFrom(0);
request.setRequireRedeemable(true);
walletService.importScript(request, (err, res) => err ? fail(err) : ok(res));
});
Expand Down

0 comments on commit c6c7372

Please sign in to comment.