From 00bfe4942047a8c14623757377b3a9f4bfc3c595 Mon Sep 17 00:00:00 2001 From: Hanssen0 Date: Sun, 25 Aug 2024 22:18:24 +0800 Subject: [PATCH] refactor(core): remove Lumos --- packages/core/package.json | 1 - packages/core/src/ckb/index.ts | 1 + packages/core/src/ckb/transaction.ts | 6 +- packages/core/src/ckb/transactionLumos.ts | 26 +++++++ pnpm-lock.yaml | 91 ----------------------- 5 files changed, 31 insertions(+), 94 deletions(-) create mode 100644 packages/core/src/ckb/transactionLumos.ts diff --git a/packages/core/package.json b/packages/core/package.json index d0b2ac6a..b5e4d3d4 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -57,7 +57,6 @@ "access": "public" }, "dependencies": { - "@ckb-lumos/helpers": "^0.22.2", "@joyid/ckb": "^1.0.1", "@noble/ciphers": "^0.5.3", "@noble/curves": "^1.4.2", diff --git a/packages/core/src/ckb/index.ts b/packages/core/src/ckb/index.ts index e2dc4043..fe1d46ed 100644 --- a/packages/core/src/ckb/index.ts +++ b/packages/core/src/ckb/index.ts @@ -1,2 +1,3 @@ export * from "./script.js"; export * from "./transaction.js"; +export * from "./transactionLumos.js"; diff --git a/packages/core/src/ckb/transaction.ts b/packages/core/src/ckb/transaction.ts index eb6e3606..05b4eae5 100644 --- a/packages/core/src/ckb/transaction.ts +++ b/packages/core/src/ckb/transaction.ts @@ -1,4 +1,3 @@ -import type { TransactionSkeletonType } from "@ckb-lumos/helpers"; import { ClientCollectableSearchKeyFilterLike } from "../advancedBarrel.js"; import { Bytes, BytesLike, bytesFrom } from "../bytes/index.js"; import { CellDepInfoLike, Client, KnownScript } from "../client/index.js"; @@ -22,6 +21,7 @@ import { apply, reduceAsync } from "../utils/index.js"; import * as mol from "./molecule.advanced/index.js"; import { Script, ScriptLike } from "./script.js"; import { DEP_TYPE_TO_NUM, NUM_TO_DEP_TYPE } from "./transaction.advanced.js"; +import { LumosTransactionSkeletonType } from "./transactionLumos.js"; /** * @public @@ -990,7 +990,9 @@ export class Transaction { * ``` */ - static fromLumosSkeleton(skeleton: TransactionSkeletonType): Transaction { + static fromLumosSkeleton( + skeleton: LumosTransactionSkeletonType, + ): Transaction { return Transaction.from({ version: 0n, cellDeps: skeleton.cellDeps.toArray(), diff --git a/packages/core/src/ckb/transactionLumos.ts b/packages/core/src/ckb/transactionLumos.ts new file mode 100644 index 00000000..2873a0e6 --- /dev/null +++ b/packages/core/src/ckb/transactionLumos.ts @@ -0,0 +1,26 @@ +import { CellDepLike, CellOutputLike, HexLike, OutPointLike } from "../barrel"; + +export interface LumosTransactionSkeletonType { + cellDeps: { + toArray(): CellDepLike[]; + }; + headerDeps: { + toArray(): HexLike[]; + }; + inputs: { + toArray(): { + outPoint?: OutPointLike; + cellOutput: CellOutputLike; + data: HexLike; + }[]; + }; + inputSinces: { + get(i: number, defaultVal: string): HexLike; + }; + outputs: { + toArray(): { cellOutput: CellOutputLike; data: HexLike }[]; + }; + witnesses: { + toArray(): HexLike[]; + }; +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4f954d84..a17f7765 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -213,9 +213,6 @@ importers: packages/core: dependencies: - '@ckb-lumos/helpers': - specifier: ^0.22.2 - version: 0.22.2(encoding@0.1.13) '@joyid/ckb': specifier: ^1.0.1 version: 1.0.1(encoding@0.1.13)(typescript@5.4.5) @@ -1083,18 +1080,10 @@ packages: '@changesets/write@0.3.1': resolution: {integrity: sha512-SyGtMXzH3qFqlHKcvFY2eX+6b0NGiFcNav8AFsYwy5l8hejOeoeTDemu5Yjmke2V5jpzY+pBvM0vCCQ3gdZpfw==} - '@ckb-lumos/base@0.22.2': - resolution: {integrity: sha512-nosUCSa5rTV2IzxbEpqzrvUeQNXB66mgA0h40+QEdnE/gV/s4ke83AScrTAxWkErJy1G/sToIHCc2kWwO95DfQ==} - engines: {node: '>=12.0.0'} - '@ckb-lumos/base@0.24.0-next.1': resolution: {integrity: sha512-p9veifS3aT0DqdIYWlG6jCUgA68m9baTDzyELIGU1RlLga0yXEElSkY9F534u6eqgriNWBb1b9imMV75sEPauw==} engines: {node: '>=12.0.0'} - '@ckb-lumos/bi@0.22.2': - resolution: {integrity: sha512-F+dLC/tE+xdtNuGgJxlDqbgX/f8azg1tvIFTR5mu7Vhz08nkFgnA+Z+yC0t/I3fDwwH4p/SlGP/yducrsfVTqw==} - engines: {node: '>=12.0.0'} - '@ckb-lumos/bi@0.24.0-next.1': resolution: {integrity: sha512-rSkEFSO97b6z58aPrvpXQEBkOBFn/qM2w4VZRhiK64SAwlPPU7c9Pxfd6VBfvp3kK6D3fE9TtVeF/7GRc23Wzw==} engines: {node: '>=12.0.0'} @@ -1103,10 +1092,6 @@ packages: resolution: {integrity: sha512-mdl9cB0IjS8oEixKSWXynObAADjtJIZr1YFFzICLErDHYSOp+KfM7kkmcakE2hLEIpNUPflkOY1eTBilGD7Z0Q==} engines: {node: '>=12.0.0'} - '@ckb-lumos/codec@0.22.2': - resolution: {integrity: sha512-P5SyhT2qkJwCwcHF3yMLInE0z3wWHDkqJNbSM2Q9oyu0+9kjMQfexNia3T+atBl2M7ELFzN5WvttojYr6DrCwQ==} - engines: {node: '>=12.0.0'} - '@ckb-lumos/codec@0.24.0-next.1': resolution: {integrity: sha512-Nc0OtH3WZpa7Ryp/o7QodCuf49/806cz2J4S3KEhL7WZnPwHCwKAhpUNeRTubNzQRlRzUqok3/NoJAlKclOuhw==} engines: {node: '>=12.0.0'} @@ -1115,10 +1100,6 @@ packages: resolution: {integrity: sha512-4QvQZ8wigZSYzMNfI2R6OrZsIb2pRD1jt6gHXk8WF1bnyZmiyPlNlKyo8sgpXFNdR6x2it5z5yFdv9s4OPl7wA==} engines: {node: '>=12.0.0'} - '@ckb-lumos/config-manager@0.22.2': - resolution: {integrity: sha512-LJ4p80VrCHh178Ks4wW1rEyHC/JWtZxrFiwHinA9aG6aOm2Z9hbZO0/ZKoS5pLfW0gxP2+ZHA3oMVt0UJhlTKA==} - engines: {node: '>=12.0.0'} - '@ckb-lumos/config-manager@0.24.0-next.1': resolution: {integrity: sha512-rKgzpVJ0rhFnVjPW2NWnQF/keZTe382GlNt/N2Fz/lEQJidnxfqTb9UizpcuTX2LXYz53iS13c9/PwoLUzmlEw==} engines: {node: '>=12.0.0'} @@ -1127,26 +1108,14 @@ packages: resolution: {integrity: sha512-sJLZKtnL0C6gi2yKbu4mp6UDNzOpaeidCTGCWhG39527PvQ1CYDh6PVr2zq5K6AL7OgnxsWZK1yvJ+KoHdVOqQ==} engines: {node: '>=18.0.0'} - '@ckb-lumos/helpers@0.22.2': - resolution: {integrity: sha512-6ztXwxsaCuoHjkbclAnfAv9BYl02t+/XxNtl3Et4Sl09xIp9HJ9/vyJouC9JjdQdnfkv1zVGN9tLiKwc6QudaQ==} - engines: {node: '>=12.0.0'} - '@ckb-lumos/helpers@0.24.0-next.1': resolution: {integrity: sha512-w9L3TdbUEWQXa8CFVDCNuoyrDYba/6+j6ZCXfAWe16CRu5vWsf6gNwMrHy9w9jPJAY2mDRNvgwcMiO7KCMfzbw==} engines: {node: '>=12.0.0'} - '@ckb-lumos/rpc@0.22.2': - resolution: {integrity: sha512-c2SX0ooDJO3dV2JOTTQtKZs0k+dHst+NHfbYJ6mYWApcZWx2nG4bQR3CQFMIKnd5CKYP/r2JuaonDkcRH9vmzw==} - engines: {node: '>=12.0.0'} - '@ckb-lumos/rpc@0.24.0-next.1': resolution: {integrity: sha512-RBIqxxzmkdcSlgwyEv9ezW+x+uovVT7P5+6Ox8eEtoN6L/+hOgLH2MYzishFJXSn93H86GLz/9BPQ/0qx2wUWA==} engines: {node: '>=12.0.0'} - '@ckb-lumos/toolkit@0.22.2': - resolution: {integrity: sha512-HmKz2dGQeaW2XDqkvjJfLv50VQWGKbthg2RDfIxGsZyjveluRROTyuHP1akypy4pqF8TApGLsXci2MaHCRau+w==} - engines: {node: '>=12.0.0'} - '@ckb-lumos/toolkit@0.24.0-next.1': resolution: {integrity: sha512-BN0phy014RJV+MhnHkkcO+skQxHN7JPwfszEML0aPnhwtEyZpHjMJx01+BijLUCli9rCZqZrM0QvMoM2wpJV1w==} engines: {node: '>=12.0.0'} @@ -3636,9 +3605,6 @@ packages: resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} engines: {node: '>=10'} - lodash.isequal@4.5.0: - resolution: {integrity: sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==} - lodash.memoize@4.1.2: resolution: {integrity: sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==} @@ -5520,17 +5486,6 @@ snapshots: human-id: 1.0.2 prettier: 2.8.8 - '@ckb-lumos/base@0.22.2': - dependencies: - '@ckb-lumos/bi': 0.22.2 - '@ckb-lumos/codec': 0.22.2 - '@ckb-lumos/toolkit': 0.22.2 - '@types/blake2b': 2.1.3 - '@types/lodash.isequal': 4.5.8 - blake2b: 2.1.4 - js-xxhash: 1.0.4 - lodash.isequal: 4.5.0 - '@ckb-lumos/base@0.24.0-next.1': dependencies: '@ckb-lumos/bi': 0.24.0-next.1 @@ -5541,10 +5496,6 @@ snapshots: blake2b: 2.1.4 js-xxhash: 1.0.4 - '@ckb-lumos/bi@0.22.2': - dependencies: - jsbi: 4.3.0 - '@ckb-lumos/bi@0.24.0-next.1': dependencies: jsbi: 4.3.0 @@ -5561,10 +5512,6 @@ snapshots: transitivePeerDependencies: - encoding - '@ckb-lumos/codec@0.22.2': - dependencies: - '@ckb-lumos/bi': 0.22.2 - '@ckb-lumos/codec@0.24.0-next.1': dependencies: '@ckb-lumos/bi': 0.24.0-next.1 @@ -5585,17 +5532,6 @@ snapshots: transitivePeerDependencies: - encoding - '@ckb-lumos/config-manager@0.22.2(encoding@0.1.13)': - dependencies: - '@ckb-lumos/base': 0.22.2 - '@ckb-lumos/bi': 0.22.2 - '@ckb-lumos/codec': 0.22.2 - '@ckb-lumos/rpc': 0.22.2(encoding@0.1.13) - '@types/deep-freeze-strict': 1.1.2 - deep-freeze-strict: 1.1.1 - transitivePeerDependencies: - - encoding - '@ckb-lumos/config-manager@0.24.0-next.1(encoding@0.1.13)': dependencies: '@ckb-lumos/base': 0.24.0-next.1 @@ -5612,18 +5548,6 @@ snapshots: '@noble/ciphers': 0.5.3 '@noble/hashes': 1.4.0 - '@ckb-lumos/helpers@0.22.2(encoding@0.1.13)': - dependencies: - '@ckb-lumos/base': 0.22.2 - '@ckb-lumos/bi': 0.22.2 - '@ckb-lumos/codec': 0.22.2 - '@ckb-lumos/config-manager': 0.22.2(encoding@0.1.13) - '@ckb-lumos/toolkit': 0.22.2 - bech32: 2.0.0 - immutable: 4.3.5 - transitivePeerDependencies: - - encoding - '@ckb-lumos/helpers@0.24.0-next.1(encoding@0.1.13)': dependencies: '@ckb-lumos/base': 0.24.0-next.1 @@ -5636,15 +5560,6 @@ snapshots: transitivePeerDependencies: - encoding - '@ckb-lumos/rpc@0.22.2(encoding@0.1.13)': - dependencies: - '@ckb-lumos/base': 0.22.2 - '@ckb-lumos/bi': 0.22.2 - abort-controller: 3.0.0 - cross-fetch: 3.1.8(encoding@0.1.13) - transitivePeerDependencies: - - encoding - '@ckb-lumos/rpc@0.24.0-next.1(encoding@0.1.13)': dependencies: '@ckb-lumos/base': 0.24.0-next.1 @@ -5654,10 +5569,6 @@ snapshots: transitivePeerDependencies: - encoding - '@ckb-lumos/toolkit@0.22.2': - dependencies: - '@ckb-lumos/bi': 0.22.2 - '@ckb-lumos/toolkit@0.24.0-next.1': dependencies: '@ckb-lumos/bi': 0.24.0-next.1 @@ -8966,8 +8877,6 @@ snapshots: dependencies: p-locate: 5.0.0 - lodash.isequal@4.5.0: {} - lodash.memoize@4.1.2: {} lodash.merge@4.6.2: {}