Skip to content

Commit

Permalink
ledger: Enable mainnet. (#3906)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeGruffins authored and alexlyp committed Sep 26, 2023
1 parent 75ad133 commit f6d49d6
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions app/actions/LedgerActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ import {

const coin = "decred";

// This error will happen when ledger is on the home screen, but it is called
// "UNKNOWN_ERROR" so may be something else.
const wrongScreenStatus = 25873;
// This error indicates the wrong app, like the btc app, is open and will say
// CLA_NOT_SUPPORTED
const wrongAppStatus = 28160;

import * as selectors from "selectors";

export const LDG_LEDGER_ENABLED = "LDG_LEDGER_ENABLED";
Expand Down Expand Up @@ -133,11 +140,7 @@ export const LDG_GETWALLETCREATIONMASTERPUBKEY_SUCCESS =
export const getWalletCreationMasterPubKey =
() => async (dispatch, getState) => {
dispatch({ type: LDG_GETWALLETCREATIONMASTERPUBKEY_ATTEMPT });
// TODO: Enable on mainnet.
const isTestnet = selectors.isTestNet(getState());
if (!isTestnet) {
throw "disabled on mainnet";
}
try {
const payload = await getPubKey(isTestnet);
const hdpk = ledgerHelpers.fixPubKeyChecksum(payload, isTestnet);
Expand All @@ -155,11 +158,24 @@ function doWithTransport(fn) {
return fn(transport).then((r) =>
transport
.close()
.catch((/*e*/) => {}) // throw?
.catch((e) => {
throw e;
})
.then(() => r)
);
})
.catch((e) => {
const notDecred = "the decred ledger app is not open on the device";
if (e.statusCode && e.message) {
switch (e.statusCode) {
case wrongScreenStatus:
e.message = notDecred;
throw e;
case wrongAppStatus:
e.message = notDecred;
throw e;
}
}
throw e;
});
}
Expand Down

0 comments on commit f6d49d6

Please sign in to comment.