diff --git a/packages/adapter/src/extension/index.ts b/packages/adapter/src/extension/index.ts index 2b807cd2..ba3b200f 100644 --- a/packages/adapter/src/extension/index.ts +++ b/packages/adapter/src/extension/index.ts @@ -21,9 +21,10 @@ interface IInjectPolkadotSnap extends IEnablePolkadotSnapParams { injectedSnapId?: string; } -function transformAccounts(accounts: string[]): InjectedAccount[] { +function transformAccounts(accounts: string[], config?: SnapConfig): InjectedAccount[] { return accounts.map((address, i) => ({ address, + genesisHash: config?.genesisHash, name: `Polkadot Snap #${i}`, type: 'ed25519' })); @@ -46,7 +47,7 @@ function injectPolkadotSnap({ accounts: { get: async (): Promise => { const response = await snap.getAddress(); - return transformAccounts([response]); + return transformAccounts([response], config); }, // Currently there is only available only one account, in that case this method will never return anything // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/packages/snap/src/configuration/predefined.ts b/packages/snap/src/configuration/predefined.ts index 71dd2fe7..f3f08792 100644 --- a/packages/snap/src/configuration/predefined.ts +++ b/packages/snap/src/configuration/predefined.ts @@ -3,6 +3,7 @@ import type { SnapConfig } from '@chainsafe/metamask-polkadot-types'; export const kusamaConfiguration: SnapConfig = { addressPrefix: 2, networkName: 'kusama', + genesisHash: '0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe', unit: { decimals: 12, image: 'https://svgshare.com/i/L3o.svg', @@ -14,6 +15,7 @@ export const kusamaConfiguration: SnapConfig = { export const westendConfiguration: SnapConfig = { addressPrefix: 42, networkName: 'westend', + genesisHash: '0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e', unit: { decimals: 12, image: 'https://svgshare.com/i/L2d.svg', @@ -25,6 +27,7 @@ export const westendConfiguration: SnapConfig = { export const polkadotConfiguration: SnapConfig = { addressPrefix: 0, networkName: 'polkadot', + genesisHash: '0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3', unit: { decimals: 12, image: 'https://polkadot.js.org/apps/static/polkadot-circle.1eea41b2..svg', diff --git a/packages/types/index.d.ts b/packages/types/index.d.ts index d1dd8fa4..9dc44427 100644 --- a/packages/types/index.d.ts +++ b/packages/types/index.d.ts @@ -16,7 +16,7 @@ export interface ExportAccountRequest { method: 'exportAccount'; params: { jsonPassphrase?: string; - } + }; } export interface GetTransactionsRequest { @@ -136,6 +136,7 @@ export type SnapNetworks = 'polkadot' | 'kusama' | 'westend' | string; export interface SnapConfig { networkName: SnapNetworks; + genesisHash?: `0x${string}`; wsRpcUrl?: string; addressPrefix?: number; unit?: UnitConfiguration;