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

update metadata and inflation #38

Merged
merged 1 commit into from
Oct 19, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/apps-config/src/api/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@
export const CERE_NETWORK_GENESIS = '0x81443836a9a24caaa23f1241897d1235717535711d1d3fe24eae4fdc942c092c';

export const CERE_NETWORK_TESTNET_GENESIS = '0x42b9b44b4950b6c1edae543a7696caf8d0a160e9bc0424ab4ab217f7a8ba30dc';

export const KATE_NETWORK_TESTNET_GENESIS = '0xd12003ac837853b062aaccca5ce87ac4838c48447e41db4a3dcfb5bf312350c6'

Check failure on line 40 in packages/apps-config/src/api/constants.ts

View workflow job for this annotation

GitHub Actions / pr (lint)

Missing semicolon

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this relevant anymore now that the testnet is being sunset?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ok, it'll be here and update when we have genesis on new testnet

8 changes: 5 additions & 3 deletions packages/apps-config/src/api/params/inflation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import type { ApiPromise } from '@polkadot/api';

import { CERE_NETWORK_GENESIS, CERE_NETWORK_TESTNET_GENESIS, DOCK_POS_TESTNET_GENESIS, KUSAMA_GENESIS, NEATCOIN_GENESIS, NFTMART_GENESIS, POLKADOT_GENESIS } from '../constants.js';
import { CERE_NETWORK_GENESIS, CERE_NETWORK_TESTNET_GENESIS, DOCK_POS_TESTNET_GENESIS, KATE_NETWORK_TESTNET_GENESIS, KUSAMA_GENESIS, NEATCOIN_GENESIS, NFTMART_GENESIS, POLKADOT_GENESIS } from '../constants.js';

interface InflationParams {
auctionAdjust: number;
Expand All @@ -28,6 +28,7 @@
};

const CERE_NETWORK_INFLATION_PARAMS = { ...DEFAULT_PARAMS, maxInflation: 0.05, minInflation: 0.0001, stakeTarget: 0.2 };
const AVAIL_NETWORK_INFLATION_PARAMS = { ...DEFAULT_PARAMS, minInflation: 0.01, maxInflation: 0.05 }

Check failure on line 31 in packages/apps-config/src/api/params/inflation.ts

View workflow job for this annotation

GitHub Actions / pr (lint)

Expected object keys to be in ascending order. 'maxInflation' should be before 'minInflation'

Check failure on line 31 in packages/apps-config/src/api/params/inflation.ts

View workflow job for this annotation

GitHub Actions / pr (lint)

Missing semicolon

const KNOWN_PARAMS: Record<string, InflationParams> = {
[CERE_NETWORK_GENESIS]: CERE_NETWORK_INFLATION_PARAMS,
Expand All @@ -40,9 +41,10 @@
[KUSAMA_GENESIS]: { ...DEFAULT_PARAMS, auctionAdjust: (0.3 / 60), auctionMax: 60, stakeTarget: 0.75 },
[NEATCOIN_GENESIS]: { ...DEFAULT_PARAMS, stakeTarget: 0.75 },
[NFTMART_GENESIS]: { ...DEFAULT_PARAMS, falloff: 0.04, stakeTarget: 0.60 },
[POLKADOT_GENESIS]: { ...DEFAULT_PARAMS, stakeTarget: 0.75 }
[POLKADOT_GENESIS]: { ...DEFAULT_PARAMS, stakeTarget: 0.75 },
[KATE_NETWORK_TESTNET_GENESIS]: AVAIL_NETWORK_INFLATION_PARAMS

Check failure on line 45 in packages/apps-config/src/api/params/inflation.ts

View workflow job for this annotation

GitHub Actions / pr (lint)

Expected object keys to be in ascending order. 'KATE_NETWORK_TESTNET_GENESIS' should be before 'POLKADOT_GENESIS'
};

export function getInflationParams (api: ApiPromise): InflationParams {
export function getInflationParams(api: ApiPromise): InflationParams {

Check failure on line 48 in packages/apps-config/src/api/params/inflation.ts

View workflow job for this annotation

GitHub Actions / pr (lint)

Missing space before function parentheses
return KNOWN_PARAMS[api.genesisHash.toHex()] || DEFAULT_PARAMS;
}
19 changes: 12 additions & 7 deletions packages/page-settings/src/useExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
tokenDecimals: number;
tokenSymbol: string;
ss58Format?: number;
userExtensionsLoaded?: boolean
userExtensionsLoadedOnSpec?: number
}

interface SavedProperties {
Expand All @@ -46,7 +46,7 @@
}

// save the properties for a specific extension
function saveProperties (api: ApiPromise, { name, version }: InjectedExtension, hasLoadedUserExtensions: boolean): void {
function saveProperties (api: ApiPromise, { name, version }: InjectedExtension, hasLoadedUserExtensionsOnSpec: number): void {
const storeKey = `properties:${api.genesisHash.toHex()}`;
const allProperties = store.get(storeKey, {}) as SavedProperties;

Expand All @@ -55,7 +55,7 @@
ss58Format: api.registry.chainSS58,
tokenDecimals: api.registry.chainDecimals[0],
tokenSymbol: api.registry.chainTokens[0],
userExtensionsLoaded: hasLoadedUserExtensions
userExtensionsLoadedOnSpec: hasLoadedUserExtensionsOnSpec
};

store.set(storeKey, allProperties);
Expand All @@ -67,17 +67,17 @@

// when we don't have properties yet, assume nothing has changed and store
if (!allProperties[extension.name]) {
saveProperties(api, extension, false);
saveProperties(api, extension, 0);

return true;
}

const { ss58Format, tokenDecimals, tokenSymbol, userExtensionsLoaded } = allProperties[extension.name];
const { ss58Format, tokenDecimals, tokenSymbol, userExtensionsLoadedOnSpec } = allProperties[extension.name];

return ss58Format === api.registry.chainSS58 &&
tokenDecimals === api.registry.chainDecimals[0] &&
tokenSymbol === api.registry.chainTokens[0] &&
(tokenSymbol !== 'AVL' || Boolean(userExtensionsLoaded));
(tokenSymbol !== 'AVL' || (userExtensionsLoadedOnSpec !== undefined && userExtensionsLoadedOnSpec > 0));
}

// filter extensions based on the properties we have available
Expand Down Expand Up @@ -117,9 +117,14 @@
try {
isOk = await metadata.provide(def);
const hasLoadedUserExtensions = !!def.userExtensions;
const maybeSpec = await api.query.system.lastRuntimeUpgrade()

Check failure on line 120 in packages/page-settings/src/useExtensions.ts

View workflow job for this annotation

GitHub Actions / pr (lint)

Missing semicolon
let spec = 0

Check failure on line 121 in packages/page-settings/src/useExtensions.ts

View workflow job for this annotation

GitHub Actions / pr (lint)

Missing semicolon
if (maybeSpec.isSome) {

Check failure on line 122 in packages/page-settings/src/useExtensions.ts

View workflow job for this annotation

GitHub Actions / pr (lint)

Expected blank line before this statement
spec = maybeSpec.unwrap().specVersion.toNumber()

Check failure on line 123 in packages/page-settings/src/useExtensions.ts

View workflow job for this annotation

GitHub Actions / pr (lint)

Missing semicolon
}

if (isOk) {
saveProperties(api, extension, hasLoadedUserExtensions);
saveProperties(api, extension, hasLoadedUserExtensions ? spec : 0);
triggerAll();
}
} catch {
Expand Down
Loading