Options
All
  • Public
  • Public/Protected
  • All
Menu

Package config-manager

@ckb-lumos/config-manager

Example

import { initializeConfig, predefined } from '@ckb-lumos/config';
import { generateAddress } from '@ckb-lumos/helper'

initializeConfig(predefined.AGGRON);
generateAddress({...}) // ckt1...


initializeConfig(predefined.LINA);
generateAddress({...}) // ckb1...

Index

References

Config

Re-exports Config

Config

Re-exports Config

ScriptConfig

Re-exports ScriptConfig

ScriptConfig

Re-exports ScriptConfig

ScriptConfigs

Re-exports ScriptConfigs

ScriptConfigs

Re-exports ScriptConfigs

createConfig

Re-exports createConfig

createConfig

Re-exports createConfig

getConfig

Re-exports getConfig

getConfig

Re-exports getConfig

helpers

Re-exports helpers

helpers

Re-exports helpers

initializeConfig

Re-exports initializeConfig

initializeConfig

Re-exports initializeConfig

predefined

Re-exports predefined

predefined

Re-exports predefined

validateConfig

Re-exports validateConfig

validateConfig

Re-exports validateConfig

Type aliases

ScriptRecord

ScriptRecord: Record<string, ScriptConfig>

ScriptRecord

ScriptRecord: Record<string, ScriptConfig>

ScriptTemplate

ScriptTemplate: Omit<Script, "args">

ScriptTemplate

ScriptTemplate: Omit<Script, "args">

Variables

Const AGGRON4

AGGRON4: { PREFIX: string; SCRIPTS: S } = createConfig({PREFIX: "ckt",SCRIPTS: {SECP256K1_BLAKE160: {CODE_HASH:"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",HASH_TYPE: "type",TX_HASH:"0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37",INDEX: "0x0",DEP_TYPE: "depGroup",SHORT_ID: 0,},SECP256K1_BLAKE160_MULTISIG: {CODE_HASH:"0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8",HASH_TYPE: "type",TX_HASH:"0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37",INDEX: "0x1",DEP_TYPE: "depGroup",SHORT_ID: 1,},DAO: {CODE_HASH:"0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e",HASH_TYPE: "type",TX_HASH:"0x8f8c79eb6671709633fe6a46de93c0fedc9c1b8a6527a18d3983879542635c9f",INDEX: "0x2",DEP_TYPE: "code",},SUDT: {CODE_HASH:"0xc5e5dcf215925f7ef4dfaf5f4b4f105bc321c02776d6e7d52a1db3fcd9d011a4",HASH_TYPE: "type",TX_HASH:"0xe12877ebd2c3c364dc46c5c992bcfaf4fee33fa13eebdf82c591fc9825aab769",INDEX: "0x0",DEP_TYPE: "code",},ANYONE_CAN_PAY: {CODE_HASH:"0x3419a1c09eb2567f6552ee7a8ecffd64155cffe0f1796e6e61ec088d740c1356",HASH_TYPE: "type",TX_HASH:"0xec26b0f85ed839ece5f11c4c4e837ec359f5adc4420410f6453b1f6b60fb96a6",INDEX: "0x0",DEP_TYPE: "depGroup",SHORT_ID: 2,},},})

Type declaration

  • PREFIX: string
  • SCRIPTS: S

Const LINA

LINA: { PREFIX: string; SCRIPTS: S } = createConfig({PREFIX: "ckb",SCRIPTS: {SECP256K1_BLAKE160: {CODE_HASH:"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",HASH_TYPE: "type",TX_HASH:"0x71a7ba8fc96349fea0ed3a5c47992e3b4084b031a42264a018e0072e8172e46c",INDEX: "0x0",DEP_TYPE: "depGroup",SHORT_ID: 0,},SECP256K1_BLAKE160_MULTISIG: {CODE_HASH:"0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8",HASH_TYPE: "type",TX_HASH:"0x71a7ba8fc96349fea0ed3a5c47992e3b4084b031a42264a018e0072e8172e46c",INDEX: "0x1",DEP_TYPE: "depGroup",SHORT_ID: 1,},DAO: {CODE_HASH:"0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e",HASH_TYPE: "type",TX_HASH:"0xe2fb199810d49a4d8beec56718ba2593b665db9d52299a0f9e6e75416d73ff5c",INDEX: "0x2",DEP_TYPE: "code",},SUDT: {CODE_HASH:"0x5e7a36a77e68eecc013dfa2fe6a23f3b6c344b04005808694ae6dd45eea4cfd5",HASH_TYPE: "type",TX_HASH:"0xc7813f6a415144643970c2e88e0bb6ca6a8edc5dd7c1022746f628284a9936d5",INDEX: "0x0",DEP_TYPE: "code",},ANYONE_CAN_PAY: {CODE_HASH:"0xd369597ff47f29fbc0d47d2e3775370d1250b85140c670e4718af712983a2354",HASH_TYPE: "type",TX_HASH:"0x4153a2014952d7cac45f285ce9a7c5c0c0e1b21f2d378b82ac1433cb11c25c4d",INDEX: "0x0",DEP_TYPE: "depGroup",SHORT_ID: 2,},},})

Type declaration

  • PREFIX: string
  • SCRIPTS: S

Let config

config: Config = predefined.LINA

Const predefined

predefined: { AGGRON4: { PREFIX: string; SCRIPTS: { ANYONE_CAN_PAY: { CODE_HASH: string; DEP_TYPE: "depGroup"; HASH_TYPE: "type"; INDEX: string; SHORT_ID: number; TX_HASH: string }; DAO: { CODE_HASH: string; DEP_TYPE: "code"; HASH_TYPE: "type"; INDEX: string; TX_HASH: string }; SECP256K1_BLAKE160: { CODE_HASH: string; DEP_TYPE: "depGroup"; HASH_TYPE: "type"; INDEX: string; SHORT_ID: number; TX_HASH: string }; SECP256K1_BLAKE160_MULTISIG: { CODE_HASH: string; DEP_TYPE: "depGroup"; HASH_TYPE: "type"; INDEX: string; SHORT_ID: number; TX_HASH: string }; SUDT: { CODE_HASH: string; DEP_TYPE: "code"; HASH_TYPE: "type"; INDEX: string; TX_HASH: string } } }; LINA: { PREFIX: string; SCRIPTS: { ANYONE_CAN_PAY: { CODE_HASH: string; DEP_TYPE: "depGroup"; HASH_TYPE: "type"; INDEX: string; SHORT_ID: number; TX_HASH: string }; DAO: { CODE_HASH: string; DEP_TYPE: "code"; HASH_TYPE: "type"; INDEX: string; TX_HASH: string }; SECP256K1_BLAKE160: { CODE_HASH: string; DEP_TYPE: "depGroup"; HASH_TYPE: "type"; INDEX: string; SHORT_ID: number; TX_HASH: string }; SECP256K1_BLAKE160_MULTISIG: { CODE_HASH: string; DEP_TYPE: "depGroup"; HASH_TYPE: "type"; INDEX: string; SHORT_ID: number; TX_HASH: string }; SUDT: { CODE_HASH: string; DEP_TYPE: "code"; HASH_TYPE: "type"; INDEX: string; TX_HASH: string } } } }

Type declaration

  • AGGRON4: { PREFIX: string; SCRIPTS: { ANYONE_CAN_PAY: { CODE_HASH: string; DEP_TYPE: "depGroup"; HASH_TYPE: "type"; INDEX: string; SHORT_ID: number; TX_HASH: string }; DAO: { CODE_HASH: string; DEP_TYPE: "code"; HASH_TYPE: "type"; INDEX: string; TX_HASH: string }; SECP256K1_BLAKE160: { CODE_HASH: string; DEP_TYPE: "depGroup"; HASH_TYPE: "type"; INDEX: string; SHORT_ID: number; TX_HASH: string }; SECP256K1_BLAKE160_MULTISIG: { CODE_HASH: string; DEP_TYPE: "depGroup"; HASH_TYPE: "type"; INDEX: string; SHORT_ID: number; TX_HASH: string }; SUDT: { CODE_HASH: string; DEP_TYPE: "code"; HASH_TYPE: "type"; INDEX: string; TX_HASH: string } } }
    • PREFIX: string
    • SCRIPTS: { ANYONE_CAN_PAY: { CODE_HASH: string; DEP_TYPE: "depGroup"; HASH_TYPE: "type"; INDEX: string; SHORT_ID: number; TX_HASH: string }; DAO: { CODE_HASH: string; DEP_TYPE: "code"; HASH_TYPE: "type"; INDEX: string; TX_HASH: string }; SECP256K1_BLAKE160: { CODE_HASH: string; DEP_TYPE: "depGroup"; HASH_TYPE: "type"; INDEX: string; SHORT_ID: number; TX_HASH: string }; SECP256K1_BLAKE160_MULTISIG: { CODE_HASH: string; DEP_TYPE: "depGroup"; HASH_TYPE: "type"; INDEX: string; SHORT_ID: number; TX_HASH: string }; SUDT: { CODE_HASH: string; DEP_TYPE: "code"; HASH_TYPE: "type"; INDEX: string; TX_HASH: string } }
      • ANYONE_CAN_PAY: { CODE_HASH: string; DEP_TYPE: "depGroup"; HASH_TYPE: "type"; INDEX: string; SHORT_ID: number; TX_HASH: string }
        • CODE_HASH: string
        • DEP_TYPE: "depGroup"
        • HASH_TYPE: "type"
        • INDEX: string
        • SHORT_ID: number
        • TX_HASH: string
      • DAO: { CODE_HASH: string; DEP_TYPE: "code"; HASH_TYPE: "type"; INDEX: string; TX_HASH: string }
        • CODE_HASH: string
        • DEP_TYPE: "code"
        • HASH_TYPE: "type"
        • INDEX: string
        • TX_HASH: string
      • SECP256K1_BLAKE160: { CODE_HASH: string; DEP_TYPE: "depGroup"; HASH_TYPE: "type"; INDEX: string; SHORT_ID: number; TX_HASH: string }
        • CODE_HASH: string
        • DEP_TYPE: "depGroup"
        • HASH_TYPE: "type"
        • INDEX: string
        • SHORT_ID: number
        • TX_HASH: string
      • SECP256K1_BLAKE160_MULTISIG: { CODE_HASH: string; DEP_TYPE: "depGroup"; HASH_TYPE: "type"; INDEX: string; SHORT_ID: number; TX_HASH: string }
        • CODE_HASH: string
        • DEP_TYPE: "depGroup"
        • HASH_TYPE: "type"
        • INDEX: string
        • SHORT_ID: number
        • TX_HASH: string
      • SUDT: { CODE_HASH: string; DEP_TYPE: "code"; HASH_TYPE: "type"; INDEX: string; TX_HASH: string }
        • CODE_HASH: string
        • DEP_TYPE: "code"
        • HASH_TYPE: "type"
        • INDEX: string
        • TX_HASH: string
  • LINA: { PREFIX: string; SCRIPTS: { ANYONE_CAN_PAY: { CODE_HASH: string; DEP_TYPE: "depGroup"; HASH_TYPE: "type"; INDEX: string; SHORT_ID: number; TX_HASH: string }; DAO: { CODE_HASH: string; DEP_TYPE: "code"; HASH_TYPE: "type"; INDEX: string; TX_HASH: string }; SECP256K1_BLAKE160: { CODE_HASH: string; DEP_TYPE: "depGroup"; HASH_TYPE: "type"; INDEX: string; SHORT_ID: number; TX_HASH: string }; SECP256K1_BLAKE160_MULTISIG: { CODE_HASH: string; DEP_TYPE: "depGroup"; HASH_TYPE: "type"; INDEX: string; SHORT_ID: number; TX_HASH: string }; SUDT: { CODE_HASH: string; DEP_TYPE: "code"; HASH_TYPE: "type"; INDEX: string; TX_HASH: string } } }
    • PREFIX: string
    • SCRIPTS: { ANYONE_CAN_PAY: { CODE_HASH: string; DEP_TYPE: "depGroup"; HASH_TYPE: "type"; INDEX: string; SHORT_ID: number; TX_HASH: string }; DAO: { CODE_HASH: string; DEP_TYPE: "code"; HASH_TYPE: "type"; INDEX: string; TX_HASH: string }; SECP256K1_BLAKE160: { CODE_HASH: string; DEP_TYPE: "depGroup"; HASH_TYPE: "type"; INDEX: string; SHORT_ID: number; TX_HASH: string }; SECP256K1_BLAKE160_MULTISIG: { CODE_HASH: string; DEP_TYPE: "depGroup"; HASH_TYPE: "type"; INDEX: string; SHORT_ID: number; TX_HASH: string }; SUDT: { CODE_HASH: string; DEP_TYPE: "code"; HASH_TYPE: "type"; INDEX: string; TX_HASH: string } }
      • ANYONE_CAN_PAY: { CODE_HASH: string; DEP_TYPE: "depGroup"; HASH_TYPE: "type"; INDEX: string; SHORT_ID: number; TX_HASH: string }
        • CODE_HASH: string
        • DEP_TYPE: "depGroup"
        • HASH_TYPE: "type"
        • INDEX: string
        • SHORT_ID: number
        • TX_HASH: string
      • DAO: { CODE_HASH: string; DEP_TYPE: "code"; HASH_TYPE: "type"; INDEX: string; TX_HASH: string }
        • CODE_HASH: string
        • DEP_TYPE: "code"
        • HASH_TYPE: "type"
        • INDEX: string
        • TX_HASH: string
      • SECP256K1_BLAKE160: { CODE_HASH: string; DEP_TYPE: "depGroup"; HASH_TYPE: "type"; INDEX: string; SHORT_ID: number; TX_HASH: string }
        • CODE_HASH: string
        • DEP_TYPE: "depGroup"
        • HASH_TYPE: "type"
        • INDEX: string
        • SHORT_ID: number
        • TX_HASH: string
      • SECP256K1_BLAKE160_MULTISIG: { CODE_HASH: string; DEP_TYPE: "depGroup"; HASH_TYPE: "type"; INDEX: string; SHORT_ID: number; TX_HASH: string }
        • CODE_HASH: string
        • DEP_TYPE: "depGroup"
        • HASH_TYPE: "type"
        • INDEX: string
        • SHORT_ID: number
        • TX_HASH: string
      • SUDT: { CODE_HASH: string; DEP_TYPE: "code"; HASH_TYPE: "type"; INDEX: string; TX_HASH: string }
        • CODE_HASH: string
        • DEP_TYPE: "code"
        • HASH_TYPE: "type"
        • INDEX: string
        • TX_HASH: string

Functions

assert

  • assert(condition: unknown, debugPath?: string): assertscondition
  • Parameters

    • condition: unknown
    • Default value debugPath: string = "variable"

    Returns assertscondition

assertHash

  • assertHash(debugPath: string, hash: string): void
  • Parameters

    • debugPath: string
    • hash: string

    Returns void

assertHexString

  • assertHexString(debugPath: string, string: string): void
  • Parameters

    • debugPath: string
    • string: string

    Returns void

assertInteger

  • assertInteger(debugPath: string, i: string): void
  • Parameters

    • debugPath: string
    • i: string

    Returns void

createConfig

  • createConfig<S>(configShape: { PREFIX: string; SCRIPTS: S }): typeof configShape
  • create a frozen ScriptConfig, also this is a TypeScript helper to create an autocomplete-friendly ScriptConfigs

    Type parameters

    Parameters

    • configShape: { PREFIX: string; SCRIPTS: S }
      • PREFIX: string
      • SCRIPTS: S

    Returns typeof configShape

createConfig

  • createConfig<S>(configShape: { PREFIX: string; SCRIPTS: S }): typeof configShape
  • create a frozen ScriptConfig, also this is a TypeScript helper to create an autocomplete-friendly ScriptConfigs

    Type parameters

    Parameters

    • configShape: { PREFIX: string; SCRIPTS: S }
      • PREFIX: string
      • SCRIPTS: S

    Returns typeof configShape

findConfigByScript

findConfigByScript

getConfig

  • Returns Config

getConfig

  • Returns Config

initializeConfig

  • initializeConfig(inputConfig?: Config): void
  • Parameters

    • Optional inputConfig: Config

    Returns void

initializeConfig

  • initializeConfig(inputConfig?: Config): void
  • Parameters

    • Optional inputConfig: Config

    Returns void

initializeConfigLegacy

  • initializeConfigLegacy(): void
  • Initialize current app with a config. The initializaton steps work as follows:

    1. If LUMOS_CONFIG_NAME environment variable is set to a predefined config, the predefined config is loaded;
    2. If LUMOS_CONFIG_FILE environment variable is set, it will be used as the name of a file containing the Config to use.
    3. A file named config.json in current running directory will be used as the file containing the Config to use.
    deprecated

    Returns void

    void

nameOfScript

  • We may need to determine if a scriptTemplate is a kind of ScriptConfig

    if (keyOfScript({ codeHash... })  === 'SECP256K1')  {
      // ...
    }

    Type parameters

    Parameters

    Returns keyof S | undefined

nameOfScript

  • We may need to determine if a scriptTemplate is a kind of ScriptConfig

    if (keyOfScript({ codeHash... })  === 'SECP256K1')  {
      // ...
    }

    Type parameters

    Parameters

    Returns keyof S | undefined

validateConfig

  • validateConfig(config: Config): void
  • Parameters

    Returns void

validateConfig

  • validateConfig(config: Config): void
  • Parameters

    Returns void

Object literals

Const predefined

predefined: object

AGGRON4

AGGRON4: { PREFIX: string; SCRIPTS: S }

Type declaration

  • PREFIX: string
  • SCRIPTS: S

LINA

LINA: { PREFIX: string; SCRIPTS: S }

Type declaration

  • PREFIX: string
  • SCRIPTS: S

Generated using TypeDoc