Skip to content

Commit

Permalink
Merge pull request #3752 from Emurgo/ruslan/relevant-networks
Browse files Browse the repository at this point in the history
protocol params only for relevant networks
  • Loading branch information
vsubhuman authored Nov 22, 2024
2 parents 16dc6e6 + 844c132 commit 8ef6279
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 707 deletions.
702 changes: 0 additions & 702 deletions package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const networks = Object.freeze({
]: CardanoHaskellBaseConfig),
CoinType: CoinTypes.CARDANO,
Fork: CardanoForks.Haskell,
isInProduction: true,
}: NetworkRow),
CardanoPreprodTestnet: ({
NetworkId: 2_50,
Expand Down Expand Up @@ -179,6 +180,14 @@ export const networks = Object.freeze({
}: NetworkRow),
});

export function listRelevantNetworkNamesForEnvironment(): Array<string> {
const keys = Object.keys(networks);
if (environment.isProduction() && !environment.isNightly()) {
return keys.filter(k => networks[k].isInProduction);
}
return keys;
}

export function isTestnet(
network: $ReadOnly<NetworkRow>,
): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export type NetworkRow = {|
* To differentiate these, we need some identifier of the fork
*/
Fork: number,
isInProduction?: boolean,
|};
export const NetworkSchema: {|
+name: 'Network',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,7 @@ Object {
"NetworkFeatureName": "mainnet",
"NetworkId": 0,
"NetworkName": "Cardano Mainnet",
"isInProduction": true,
},
Object {
"Backend": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ class WalletSendPage extends Component<AllProps> {
this.props.stores.substores.ada.addresses.getSupportedAddressDomainBannerState();
});
const { loadProtocolParametersRequest } = this.props.stores.protocolParameters;
loadProtocolParametersRequest.reset();
loadProtocolParametersRequest.execute();
if (!loadProtocolParametersRequest.wasExecuted && !loadProtocolParametersRequest.isExecuting) {
loadProtocolParametersRequest.reset();
loadProtocolParametersRequest.execute();
}
ampli.sendInitiated();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
import Store from '../base/Store';
import type { ProtocolParameters } from '@emurgo/yoroi-lib/dist/protocol-parameters/models';
import { getProtocolParameters } from '../../api/thunk';
import { networks } from '../../api/ada/lib/storage/database/prepackaged/networks';
import {
listRelevantNetworkNamesForEnvironment,
networks
} from '../../api/ada/lib/storage/database/prepackaged/networks';
import LocalizedRequest from '../lib/LocalizedRequest';
import { observable } from 'mobx';

Expand All @@ -17,8 +20,12 @@ export default class ProtocolParametersStore<

cache: Map<number, ProtocolParameters> = new Map();

setup(): void {
this.loadProtocolParametersRequest.execute();
}

async loadProtocolParameters(): Promise<void> {
for (const key of Object.keys(networks)) {
for (const key of listRelevantNetworkNamesForEnvironment()) {
const networkId = networks[key].NetworkId;
if (networkId === networks.CardanoSanchoTestnet.NetworkId) continue;
const protocolParameters = await getProtocolParameters({ networkId });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const CreateWallet: HandlerType<CreateWalletRequest, CreateWalletResponse
publicDeriverId: publicDerivers[0].getPublicDeriverId(),
}
});
// noinspection ES6MissingAwait
syncWallet(publicDerivers[0], 'new wallet', 1);
return await getPlaceHolderWalletState(publicDerivers[0]);
},
Expand Down
2 changes: 1 addition & 1 deletion run-dev.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nvm i && . install-all.sh && npm run dev:stable --prefix packages/yoroi-extension
nvm i && . install-all.sh && npm run "dev${1:-:stable}" --prefix packages/yoroi-extension

0 comments on commit 8ef6279

Please sign in to comment.