From 2bb230a96e4adc4fcb20103405ef4921a34a690b Mon Sep 17 00:00:00 2001 From: homura Date: Thu, 11 Jan 2024 12:19:22 +0800 Subject: [PATCH 1/4] fix(lumos): export some utility function from helpers --- packages/lumos/src/config.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/lumos/src/config.ts b/packages/lumos/src/config.ts index 9a0817dac..b39a2e50a 100644 --- a/packages/lumos/src/config.ts +++ b/packages/lumos/src/config.ts @@ -16,4 +16,13 @@ export { validateConfig, initializeConfig, getConfig, + /** + * @deprecated use the {@link nameOfScript} and {@link findConfigByScript} function instead + */ + helpers, } from "@ckb-lumos/config-manager"; + +export { + nameOfScript, + findConfigByScript, +} from "@ckb-lumos/config-manager/lib/helpers"; From 98040f6bea2adb3c7d40f8f856048ca9ca7b7af4 Mon Sep 17 00:00:00 2001 From: homura Date: Thu, 11 Jan 2024 12:19:54 +0800 Subject: [PATCH 2/4] fix(website): cannot parse address --- pnpm-lock.yaml | 3 ++ website/package.json | 1 + .../parseMultiVersionAddress.ts | 33 ++++++++----------- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d4145f21e..28bd88b0b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -753,6 +753,9 @@ importers: website: dependencies: + '@ckb-lumos/helpers': + specifier: canary + version: link:../packages/helpers '@ckb-lumos/lumos': specifier: canary version: link:../packages/lumos diff --git a/website/package.json b/website/package.json index 79351507c..e37eadf61 100644 --- a/website/package.json +++ b/website/package.json @@ -20,6 +20,7 @@ }, "dependencies": { "@ckb-lumos/lumos": "canary", + "@ckb-lumos/helpers": "canary", "@ckb-lumos/molecule": "canary", "@docusaurus/core": "^3.0.0", "@docusaurus/preset-classic": "^3.0.0", diff --git a/website/src/components/address-conversion/parseMultiVersionAddress.ts b/website/src/components/address-conversion/parseMultiVersionAddress.ts index d3f512d58..1b8f78b5a 100644 --- a/website/src/components/address-conversion/parseMultiVersionAddress.ts +++ b/website/src/components/address-conversion/parseMultiVersionAddress.ts @@ -1,42 +1,37 @@ -import { config as lumosConfig, helpers, Script } from "@ckb-lumos/lumos"; -import { Err, MultiVersionAddress } from "@site/src/types"; +import { config as lumosConfig, Script } from "@ckb-lumos/lumos" +import * as helpers from "@ckb-lumos/helpers" +import { Err, MultiVersionAddress } from "@site/src/types" -export type ParseResult = MultiVersionAddress | Err; +export type ParseResult = MultiVersionAddress | Err -export function parseMultiVersionAddress( - script: Script, - config: lumosConfig.Config -): ParseResult { +export function parseMultiVersionAddress(script: Script, config: lumosConfig.Config): ParseResult { try { - const name = lumosConfig.helpers.nameOfScript(script, config.SCRIPTS) as - | string - | undefined; - const ckb2021 = helpers.encodeToAddress(script, { config }); + const name = lumosConfig.helpers.nameOfScript(script, config.SCRIPTS) as string | undefined + const ckb2021 = helpers.encodeToAddress(script, { config }) - if (script.hashType === "data1" || script.hashType === 'data2') { + if (script.hashType === "data1" || script.hashType === "data2") { return { name, script, ckb2019FullFormat: undefined, ckb2019ShortFormat: undefined, ckb2021FullFormat: ckb2021, - }; + } } const ckb2019Full = helpers.generateAddress(script, { config: { SCRIPTS: {}, PREFIX: config.PREFIX }, - }); - const ckb2019Short = helpers.generateAddress(script, { config }); + }) + const ckb2019Short = helpers.generateAddress(script, { config }) return { script, name, ckb2019FullFormat: ckb2019Full, - ckb2019ShortFormat: - ckb2019Short === ckb2019Full ? undefined : ckb2019Short, + ckb2019ShortFormat: ckb2019Short === ckb2019Full ? undefined : ckb2019Short, ckb2021FullFormat: helpers.encodeToAddress(script, { config }), - }; + } } catch { - return { error: "Invalid script" }; + return { error: "Invalid script" } } } From d08937c7d3b348e898852e20ee2eb71de0c67f14 Mon Sep 17 00:00:00 2001 From: homura Date: Thu, 11 Jan 2024 12:43:53 +0800 Subject: [PATCH 3/4] feat(config-manager): deprecate the confused name helpers --- packages/config-manager/src/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/config-manager/src/index.ts b/packages/config-manager/src/index.ts index de250a254..916dfb350 100644 --- a/packages/config-manager/src/index.ts +++ b/packages/config-manager/src/index.ts @@ -1,5 +1,9 @@ export * from "./types"; export { initializeConfig, getConfig, validateConfig } from "./manager"; +/** + * @deprecated use the {@link nameOfScript} and {@link findConfigByScript} function instead + */ export * as helpers from "./helpers"; +export { nameOfScript, findConfigByScript } from "./helpers"; export { predefined, createConfig } from "./predefined"; export { generateGenesisScriptConfigs } from "./genesis"; From e066038444944eb0c8d32a197c18dcdfea8ee448 Mon Sep 17 00:00:00 2001 From: homura Date: Thu, 11 Jan 2024 12:48:47 +0800 Subject: [PATCH 4/4] chore: changeset for deprecated config-managers/helpers --- .changeset/wild-dodos-notice.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/wild-dodos-notice.md diff --git a/.changeset/wild-dodos-notice.md b/.changeset/wild-dodos-notice.md new file mode 100644 index 000000000..e9d845b97 --- /dev/null +++ b/.changeset/wild-dodos-notice.md @@ -0,0 +1,6 @@ +--- +"@ckb-lumos/config-manager": minor +"@ckb-lumos/lumos": minor +--- + +feat: **deprecated** the `helpers` in `config-manager` to avoid confused with `@ckb-lumos/helpers`