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

Fix BTC address calculation - Closes #3772 #3775

Merged
merged 3 commits into from Sep 12, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
31 changes: 18 additions & 13 deletions src/store/actions/account.js
Expand Up @@ -29,8 +29,19 @@ export const accountLoading = () => ({
type: actionTypes.accountLoading,
});

async function getAccounts({ network, params }) {
return Object.keys(params).reduce(async (accountsPromise, token) => {
/**
* Gets the account info for given addresses of different tokens
* We have getAccounts functions for retrieving multiple accounts of
* a single blockchain. This one is for retrieving accounts of
* different blockchains.
*
* @param {Object} data
* @param {Object} data.network Network config from the Redux store
* @param {Object} data.params addresses in the form of {[token]: [address]}
* @returns {Promise<[object]>}
*/
const getAccounts = async ({ network, params }) =>
Object.keys(params).reduce(async (accountsPromise, token) => {
const accounts = await accountsPromise;
const baseUrl = network.networks[token].serviceUrl;
const account = await getAccount({ network, baseUrl, params: params[token] }, token);
Expand All @@ -39,7 +50,6 @@ async function getAccounts({ network, params }) {
[token]: account,
};
}, Promise.resolve({}));
}

/**
* This action is used to update account balance when new block was forged and
Expand All @@ -50,22 +60,17 @@ async function getAccounts({ network, params }) {
*/
export const accountDataUpdated = tokensTypes =>
async (dispatch, getState) => {
const state = getState();
const { network, settings, account } = state;
const { network, settings, account } = getState();

// Get the list of tokens that are enabled in settings
const activeTokens = tokensTypes === 'enabled'
? Object.keys(settings.token.list)
.filter(key => settings.token.list[key])
: [settings.token.active];

// Collect their addresses to send to the API
const params = activeTokens.reduce((acc, token) => {
if (token === tokenMap.LSK.key) {
acc[token] = { address: account.info[tokenMap.LSK.key].summary.address };
} else {
acc[token] = {
address: account.info[token].summary.address,
passphrase: account.passphrase,
};
}
acc[token] = { address: account.info[token].summary.address };
return acc;
}, {});

Expand Down
2 changes: 1 addition & 1 deletion src/store/middlewares/account.js
Expand Up @@ -88,7 +88,7 @@ const checkTransactionsAndUpdateAccount = async (store, action) => {
}).length > 0;

showNotificationsForIncomingTransactions(txs, account, token.active);
const recentBtcTransaction = token.active === 'BTC'
const recentBtcTransaction = token.active === tokenMap.BTC.key
&& transactions.confirmed.filter(t => t.confirmations === 1).length > 0;

if (blockContainsRelevantTransaction || recentBtcTransaction) {
Expand Down