Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
escottalexander committed Apr 4, 2024
1 parent 9be6ca2 commit 46dab62
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/bitcore-lib-cash/lib/networks.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ function addNetwork(data) {
});
}

for (const value of Object.values(network)) {
const indexBy = data.indexBy || Object.values(network);
for (const value of indexBy) {
if (value != null && typeof value !== 'object') {
if (!networkMaps[value]) {
networkMaps[value] = [];
Expand Down
9 changes: 5 additions & 4 deletions packages/bitcore-wallet-service/src/lib/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,14 @@ export class Utils {
}

static compareNetworks(network1, network2, chain) {
network1 = network1?.toLowerCase();
network2 = network2?.toLowerCase();
network1 = network1 ? this.getNetworkName(chain, network1.toLowerCase()) : null;
network2 = network2 ? this.getNetworkName(chain, network2.toLowerCase()) : null;

if (this.getNetworkName(chain, network1) == network2) return true;
if (Config.allowRegtest && ['testnet', 'regtest'].includes(Utils.getGenericName(network1)) && ['testnet', 'regtest'].includes(Utils.getGenericName(network2))) return true;
if (network1 == network2) return true;
if (Config.allowRegtest && ['testnet', 'regtest'].includes(network1) && ['testnet', 'regtest'].includes(network2)) return true;
return false;
}

// Good for going from generic 'testnet' to specific 'testnet3', 'sepolia', etc
static getNetworkName(chain, network) {
const aliases = Constants.NETWORK_ALIASES[chain];
Expand Down

0 comments on commit 46dab62

Please sign in to comment.