From 6fced8eb5e0048aa5c7923a6d0bde107408b26ac Mon Sep 17 00:00:00 2001 From: ashuralyk Date: Thu, 1 Aug 2024 17:13:18 +0800 Subject: [PATCH 1/2] bug: errors from getSporeById are mixed --- packages/core/src/api/joints/spore/getSpore.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/packages/core/src/api/joints/spore/getSpore.ts b/packages/core/src/api/joints/spore/getSpore.ts index 6383e34..c814559 100644 --- a/packages/core/src/api/joints/spore/getSpore.ts +++ b/packages/core/src/api/joints/spore/getSpore.ts @@ -63,19 +63,13 @@ export async function getSporeById(id: HexString, config?: SporeConfig): Promise // Get SporeType script const sporeScript = getSporeScriptCategory(config, 'Spore'); const scripts = (sporeScript.versions ?? []).map((r) => r.script); + const indexer = new Indexer(config.ckbIndexerUrl, config.ckbNodeUrl); // Search target spore from the latest version to the oldest for (const script of scripts) { - try { - return await getSporeByType( - { - ...script, - args: id, - }, - config, - ); - } catch { - // Not found in the script, don't have to do anything + const cell = await getCellByType({ type: { ...script, args: id }, indexer }); + if (cell !== void 0) { + return cell; } } From cfaef444feeecc4992974e259641c2fb469f0980 Mon Sep 17 00:00:00 2001 From: ashuralyk Date: Thu, 1 Aug 2024 17:17:57 +0800 Subject: [PATCH 2/2] chore: add changeset log --- .changeset/khaki-elephants-behave.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/khaki-elephants-behave.md diff --git a/.changeset/khaki-elephants-behave.md b/.changeset/khaki-elephants-behave.md new file mode 100644 index 0000000..e2dca77 --- /dev/null +++ b/.changeset/khaki-elephants-behave.md @@ -0,0 +1,5 @@ +--- +'@spore-sdk/core': patch +--- + +fix vulnerability in getSporeById interface