Skip to content

Commit

Permalink
build: update prettier to 2.7.1 (#3827)
Browse files Browse the repository at this point in the history
  • Loading branch information
dajohi authored Nov 22, 2022
1 parent 4ec52dc commit 936820a
Show file tree
Hide file tree
Showing 110 changed files with 3,834 additions and 4,160 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Build and Test
on: [push, pull_request]
permissions:
contents: read

jobs:
build:
Expand All @@ -9,13 +11,13 @@ jobs:
node-version: [14.x]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a #v3.2.1
with:
go-version: 1.18
go-version: 1.19
- name: Use nodejs ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 #v3.5.1
with:
node-version: ${{ matrix.node-version }}

Expand Down
4 changes: 2 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"useTabs": false,
"jsxSingleQuote": false,
"bracketSpacing": true,
"jsxBracketSameLine": true,
"bracketSameLine": true,
"arrowParens": "always",
"endOfLine": "lf",
"trailingComma": "none"
}
}
252 changes: 126 additions & 126 deletions app/actions/AccountMixerActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,84 +70,88 @@ export const RUNACCOUNTMIXER_NOBALANCE = "RUNACCOUNTMIXER_NOBALANCE";
export const RUNACCOUNTMIXER_SUFFICIENTBALANCE =
"RUNACCOUNTMIXER_SUFFICIENTBALANCE";

export const checkUnmixedAccountBalance = (changeAccount) => async (
dispatch
) => {
const spendableBal = await dispatch(getAcctSpendableBalance(changeAccount));
if (spendableBal < MIN_RELAY_FEE_ATOMS + MIN_MIX_DENOMINATION_ATOMS) {
dispatch({
error: (
<T
id="accountMixer.insufficientUnmixedAccountBalance"
m="Insufficient unmixed account balance"
/>
),
type: RUNACCOUNTMIXER_NOBALANCE
});
} else {
dispatch({
type: RUNACCOUNTMIXER_SUFFICIENTBALANCE
});
}
};
export const checkUnmixedAccountBalance =
(changeAccount) => async (dispatch) => {
const spendableBal = await dispatch(getAcctSpendableBalance(changeAccount));
if (spendableBal < MIN_RELAY_FEE_ATOMS + MIN_MIX_DENOMINATION_ATOMS) {
dispatch({
error: (
<T
id="accountMixer.insufficientUnmixedAccountBalance"
m="Insufficient unmixed account balance"
/>
),
type: RUNACCOUNTMIXER_NOBALANCE
});
} else {
dispatch({
type: RUNACCOUNTMIXER_SUFFICIENTBALANCE
});
}
};

export const runAccountMixer = ({
passphrase,
mixedAccount,
mixedAccountBranch,
changeAccount,
csppServer
}) => (dispatch, getState) =>
new Promise((resolve) => {
dispatch({ type: RUNACCOUNTMIXER_ATTEMPT });
const accountUnlocks = [changeAccount];
const runMixerAsync = async () => {
const mixerStreamer = await dispatch(
unlockAcctAndExecFn(
passphrase,
accountUnlocks,
() =>
wallet.runAccountMixerRequest(sel.accountMixerService(getState()), {
mixedAccount,
mixedAccountBranch,
changeAccount,
csppServer
}),
true
)
);
return { mixerStreamer };
};
export const runAccountMixer =
({
passphrase,
mixedAccount,
mixedAccountBranch,
changeAccount,
csppServer
}) =>
(dispatch, getState) =>
new Promise((resolve) => {
dispatch({ type: RUNACCOUNTMIXER_ATTEMPT });
const accountUnlocks = [changeAccount];
const runMixerAsync = async () => {
const mixerStreamer = await dispatch(
unlockAcctAndExecFn(
passphrase,
accountUnlocks,
() =>
wallet.runAccountMixerRequest(
sel.accountMixerService(getState()),
{
mixedAccount,
mixedAccountBranch,
changeAccount,
csppServer
}
),
true
)
);
return { mixerStreamer };
};

runMixerAsync()
.then(async (resp) => {
const { mixerStreamer, error } = resp;
// we can throw errors, like when the account has a small balance,
// so this check is necessary.
if (error) {
runMixerAsync()
.then(async (resp) => {
const { mixerStreamer, error } = resp;
// we can throw errors, like when the account has a small balance,
// so this check is necessary.
if (error) {
await dispatch({ error: error + "", type: RUNACCOUNTMIXER_FAILED });
dispatch(relockAccounts(accountUnlocks));
return;
}
mixerStreamer.on("data", () => resolve());
mixerStreamer.on("error", (error) => {
// if context was cancelled we can ignore it, as it probably means
// mixer was stopped.
if (!String(error).includes("Cancelled")) {
dispatch({ error: error + "", type: RUNACCOUNTMIXER_FAILED });
}
});
mixerStreamer.on("end", (data) => {
// not supposed to get here, but if it does, we log to see.
console.log(data);
});
dispatch({ type: RUNACCOUNTMIXER_SUCCESS, mixerStreamer });
})
.catch(async (error) => {
await dispatch({ error: error + "", type: RUNACCOUNTMIXER_FAILED });
dispatch(relockAccounts(accountUnlocks));
return;
}
mixerStreamer.on("data", () => resolve());
mixerStreamer.on("error", (error) => {
// if context was cancelled we can ignore it, as it probably means
// mixer was stopped.
if (!String(error).includes("Cancelled")) {
dispatch({ error: error + "", type: RUNACCOUNTMIXER_FAILED });
}
});
mixerStreamer.on("end", (data) => {
// not supposed to get here, but if it does, we log to see.
console.log(data);
});
dispatch({ type: RUNACCOUNTMIXER_SUCCESS, mixerStreamer });
})
.catch(async (error) => {
await dispatch({ error: error + "", type: RUNACCOUNTMIXER_FAILED });
dispatch(relockAccounts(accountUnlocks));
});
});
});

export const STOPMIXER_ATTEMPT = "STOPMIXER_ATTEMPT";
export const STOPMIXER_FAILED = "STOPMIXER_FAILED";
Expand Down Expand Up @@ -177,66 +181,62 @@ export const CREATEMIXERACCOUNTS_ATTEMPT = "CREATEMIXERACCOUNTS_ATTEMPT";
export const CREATEMIXERACCOUNTS_FAILED = "CREATEMIXERACCOUNTS_FAILED";
export const CREATEMIXERACCOUNTS_SUCCESS = "CREATEMIXERACCOUNTS_SUCCESS";

export const createNeededAccounts = (
passphrase,
mixedAccountName,
changeAccountName
) => async (dispatch) => {
dispatch({ type: CREATEMIXERACCOUNTS_ATTEMPT });
export const createNeededAccounts =
(passphrase, mixedAccountName, changeAccountName) => async (dispatch) => {
dispatch({ type: CREATEMIXERACCOUNTS_ATTEMPT });

try {
const mixedAccount = await dispatch(
getNextAccountAttempt(passphrase, mixedAccountName)
);
const changeAccount = await dispatch(
getNextAccountAttempt(passphrase, changeAccountName)
);
try {
const mixedAccount = await dispatch(
getNextAccountAttempt(passphrase, mixedAccountName)
);
const changeAccount = await dispatch(
getNextAccountAttempt(passphrase, changeAccountName)
);

// update accounts selectors
dispatch(getAccountsAttempt(true));
const mixedNumber = mixedAccount.getNextAccountResponse.accountNumber;
const changeNumber = changeAccount.getNextAccountResponse.accountNumber;
// update accounts selectors
dispatch(getAccountsAttempt(true));
const mixedNumber = mixedAccount.getNextAccountResponse.accountNumber;
const changeNumber = changeAccount.getNextAccountResponse.accountNumber;

dispatch(
setCoinjoinCfg({
mixedNumber,
changeNumber
})
);
dispatch(getMixerAcctsSpendableBalances());
} catch (error) {
dispatch({ type: CREATEMIXERACCOUNTS_FAILED, error });
}
};
dispatch(
setCoinjoinCfg({
mixedNumber,
changeNumber
})
);
dispatch(getMixerAcctsSpendableBalances());
} catch (error) {
dispatch({ type: CREATEMIXERACCOUNTS_FAILED, error });
}
};

export const setCoinjoinCfg = ({ mixedNumber, changeNumber }) => (
dispatch,
getState
) => {
const isTestnet = sel.isTestNet(getState());
const walletName = sel.getWalletName(getState());
const cfg = wallet.getWalletCfg(isTestnet, walletName);
export const setCoinjoinCfg =
({ mixedNumber, changeNumber }) =>
(dispatch, getState) => {
const isTestnet = sel.isTestNet(getState());
const walletName = sel.getWalletName(getState());
const cfg = wallet.getWalletCfg(isTestnet, walletName);

const csppServer = CSPP_URL;
const csppPort = isTestnet ? CSPP_PORT_TESTNET : CSPP_PORT_MAINNET;
const csppServer = CSPP_URL;
const csppPort = isTestnet ? CSPP_PORT_TESTNET : CSPP_PORT_MAINNET;

cfg.set(CSPP_SERVER, csppServer);
cfg.set(CSPP_PORT, csppPort);
cfg.set(MIXED_ACCOUNT_CFG, mixedNumber);
cfg.set(CHANGE_ACCOUNT_CFG, changeNumber);
cfg.set(MIXED_ACC_BRANCH, 0);
// by default it is only allowed to send from mixed account.
cfg.set(SEND_FROM_UNMIXED, false);
cfg.set(CSPP_SERVER, csppServer);
cfg.set(CSPP_PORT, csppPort);
cfg.set(MIXED_ACCOUNT_CFG, mixedNumber);
cfg.set(CHANGE_ACCOUNT_CFG, changeNumber);
cfg.set(MIXED_ACC_BRANCH, 0);
// by default it is only allowed to send from mixed account.
cfg.set(SEND_FROM_UNMIXED, false);

dispatch({
type: CREATEMIXERACCOUNTS_SUCCESS,
mixedAccount: mixedNumber,
changeAccount: changeNumber,
csppPort,
csppServer,
mixedAccountBranch: 0
});
};
dispatch({
type: CREATEMIXERACCOUNTS_SUCCESS,
mixedAccount: mixedNumber,
changeAccount: changeNumber,
csppPort,
csppServer,
mixedAccountBranch: 0
});
};

// getCoinjoinOutputspByAcct get all possible coinjoin outputs which an account
// may have. This is used so we can recover privacy wallets and don't miss
Expand Down
Loading

0 comments on commit 936820a

Please sign in to comment.