// Copyright 2017-2025 @pezkuwi/types authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { Registry } from '@pezkuwi/types-codec/types';
import type { StorageEntry } from '../../../primitive/types.js';
import type { ManualMetadata } from './util.js';

import { createRuntimeFunction } from './util.js';

type Creator = (registry: Registry) => StorageEntry;

const prefix = 'Bizinikiwi';
const section = 'bizinikiwi';

function createBizinikiwiFn (method: string, key: string, meta: ManualMetadata): Creator {
  return createRuntimeFunction({ method, prefix, section }, key, meta);
}

export const bizinikiwi: Record<string, Creator> = {
  changesTrieConfig: createBizinikiwiFn('changesTrieConfig', ':changes_trie', {
    docs: 'Changes trie configuration is stored under this key.',
    type: 'u32'
  }),
  childStorageKeyPrefix: createBizinikiwiFn('childStorageKeyPrefix', ':child_storage:', {
    docs: 'Prefix of child storage keys.',
    type: 'u32'
  }),
  code: createBizinikiwiFn('code', ':code', {
    docs: 'Wasm code of the runtime.',
    type: 'Bytes'
  }),
  defaultChildStorageKeyPrefix: createBizinikiwiFn('defaultChildStorageKeyPrefix', ':child_storage:default:', {
    docs: 'Prefix of the default child storage keys in the top trie.',
    type: 'u32'
  }),
  extrinsicIndex: createBizinikiwiFn('extrinsicIndex', ':extrinsic_index', {
    docs: 'Current extrinsic index (u32) is stored under this key.',
    type: 'u32'
  }),
  heapPages: createBizinikiwiFn('heapPages', ':heappages', {
    docs: 'Number of wasm linear memory pages required for execution of the runtime.',
    type: 'u64'
  }),
  intrablockEntropy: createBizinikiwiFn('intrablockEntropy', ':intrablock_entropy', {
    docs: 'Current intra-block entropy (a universally unique `[u8; 32]` value) is stored here.',
    type: '[u8; 32]'
  }),
  storageVersionStorageKeyPostfix: createBizinikiwiFn('storageVersionStorageKeyPostfix', ':__STORAGE_VERSION__:', {
    docs: 'The storage key postfix that is used to store the [`StorageVersion`] per pallet.',
    type: 'u16'
  }),
  transactionLevelKey: createBizinikiwiFn('transactionLevelKey', ':transaction_level:', {
    docs: 'The key that holds the current number of active layers.',
    type: 'u32'
  })
};
