Skip to content

Commit

Permalink
update metadata and inflation (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leouarz authored Oct 19, 2023
1 parent 201fa33 commit 0392234
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
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 NFTMART_GENESIS = '0xfcf9074303d8f319ad1bf0195b145871977e7c375883b8
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 / www (lint)

Missing semicolon
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 DEFAULT_PARAMS: InflationParams = {
};

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 / www (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 / www (lint)

Missing semicolon

const KNOWN_PARAMS: Record<string, InflationParams> = {
[CERE_NETWORK_GENESIS]: CERE_NETWORK_INFLATION_PARAMS,
Expand All @@ -40,9 +41,10 @@ const KNOWN_PARAMS: Record<string, InflationParams> = {
[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 / www (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 / www (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 @@ interface ExtensionProperties {
tokenDecimals: number;
tokenSymbol: string;
ss58Format?: number;
userExtensionsLoaded?: boolean
userExtensionsLoadedOnSpec?: number
}

interface SavedProperties {
Expand All @@ -46,7 +46,7 @@ function triggerAll (): void {
}

// 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 @@ function saveProperties (api: ApiPromise, { name, version }: InjectedExtension,
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 @@ function hasCurrentProperties (api: ApiPromise, { extension }: ExtensionKnown):

// 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 @@ async function getExtensionInfo (api: ApiPromise, extension: InjectedExtension):
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 / www (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 / www (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 / www (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 / www (lint)

Missing semicolon
}

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

0 comments on commit 0392234

Please sign in to comment.