mirror of
https://github.com/pezkuwichain/pezkuwi-extension.git
synced 2026-07-17 02:35:43 +00:00
Update domain references to pezkuwichain.app and rebrand from polkadot
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
// Copyright 2019-2025 @pezkuwi/extension-chains authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { MetadataDef } from '@pezkuwi/extension-inject/types';
|
||||
import type { ChainProperties } from '@pezkuwi/types/interfaces';
|
||||
import type { Chain } from './types.js';
|
||||
|
||||
import { Metadata, TypeRegistry } from '@pezkuwi/types';
|
||||
import { base64Decode } from '@pezkuwi/util-crypto';
|
||||
|
||||
export { packageInfo } from './packageInfo.js';
|
||||
|
||||
// imports chain details, generally metadata. For the generation of these,
|
||||
// inside the api, run `yarn chain:info --ws <url>`
|
||||
|
||||
const definitions = new Map<string, MetadataDef>(
|
||||
// [kusama].map((def) => [def.genesisHash, def])
|
||||
);
|
||||
|
||||
const expanded = new Map<string, Chain>();
|
||||
|
||||
export function metadataExpand (definition: MetadataDef, isPartial = false): Chain {
|
||||
const cached = expanded.get(definition.genesisHash);
|
||||
|
||||
if (cached && cached.specVersion === definition.specVersion) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
const { chain, genesisHash, icon, metaCalls, specVersion, ss58Format, tokenDecimals, tokenSymbol, types, userExtensions } = definition;
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
if (!isPartial) {
|
||||
registry.register(types);
|
||||
}
|
||||
|
||||
registry.setChainProperties(registry.createType('ChainProperties', {
|
||||
ss58Format,
|
||||
tokenDecimals,
|
||||
tokenSymbol
|
||||
}) as unknown as ChainProperties);
|
||||
|
||||
const hasMetadata = !!metaCalls && !isPartial;
|
||||
|
||||
if (hasMetadata) {
|
||||
registry.setMetadata(new Metadata(registry, base64Decode(metaCalls)), undefined, userExtensions);
|
||||
}
|
||||
|
||||
const isUnknown = genesisHash === '0x';
|
||||
|
||||
const result = {
|
||||
definition,
|
||||
genesisHash: isUnknown
|
||||
? undefined
|
||||
: genesisHash,
|
||||
hasMetadata,
|
||||
icon: icon || 'substrate',
|
||||
isUnknown,
|
||||
name: chain,
|
||||
registry,
|
||||
specVersion,
|
||||
ss58Format,
|
||||
tokenDecimals,
|
||||
tokenSymbol
|
||||
};
|
||||
|
||||
if (result.genesisHash && !isPartial) {
|
||||
expanded.set(result.genesisHash, result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export function findChain (definitions: MetadataDef[], genesisHash?: string | null): Chain | null {
|
||||
const def = definitions.find((def) => def.genesisHash === genesisHash);
|
||||
|
||||
return def
|
||||
? metadataExpand(def)
|
||||
: null;
|
||||
}
|
||||
|
||||
export function addMetadata (def: MetadataDef): void {
|
||||
definitions.set(def.genesisHash, def);
|
||||
}
|
||||
|
||||
export function knownMetadata (): MetadataDef[] {
|
||||
return [...definitions.values()];
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// Copyright 2019-2025 @pezkuwi/extension-chains authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Since we inject into pages, we skip this
|
||||
// import './packageDetect.js';
|
||||
|
||||
export * from './bundle.js';
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright 2017-2025 @pezkuwi/extension-chains authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @pezkuwi/dev
|
||||
// (packageInfo imports will be kept as-is, user-editable)
|
||||
|
||||
import { packageInfo as injectInfo } from '@pezkuwi/extension-inject/packageInfo';
|
||||
import { detectPackage } from '@pezkuwi/util';
|
||||
|
||||
import { packageInfo } from './packageInfo.js';
|
||||
|
||||
detectPackage(packageInfo, null, [injectInfo]);
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2025 @pezkuwi/extension-chains authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @pezkuwi/dev
|
||||
|
||||
export const packageInfo = { name: '@pezkuwi/extension-chains', path: 'auto', type: 'auto', version: '0.62.6' };
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright 2019-2025 @pezkuwi/extension-chains authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { MetadataDef } from '@pezkuwi/extension-inject/types';
|
||||
import type { Registry } from '@pezkuwi/types/types';
|
||||
|
||||
export interface Chain {
|
||||
definition: MetadataDef;
|
||||
genesisHash?: string;
|
||||
hasMetadata: boolean;
|
||||
icon: string;
|
||||
isEthereum?: boolean;
|
||||
isUnknown?: boolean;
|
||||
name: string;
|
||||
registry: Registry;
|
||||
specVersion: number;
|
||||
ss58Format: number;
|
||||
tokenDecimals: number;
|
||||
tokenSymbol: string;
|
||||
}
|
||||
Reference in New Issue
Block a user