Skip to content

Commit db34aef

Browse files
authoredOct 13, 2023
refactor: remove peerDependency of toolkit (#560)
1 parent ed5dc56 commit db34aef

File tree

6 files changed

+46
-25
lines changed

6 files changed

+46
-25
lines changed
 

‎.changeset/green-tips-accept.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ckb-lumos/toolkit": patch
3+
---
4+
5+
remove peer dependencies in toolkit

‎packages/toolkit/package.json

+4-6
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,14 @@
2626
},
2727
"author": "Xuejie Xiao",
2828
"license": "MIT",
29-
"peerDependencies": {
30-
"cross-fetch": "^3.1.4",
31-
"jsbi": "^4.1.0"
32-
},
3329
"publishConfig": {
3430
"access": "public"
3531
},
32+
"dependencies": {
33+
"@ckb-lumos/bi": "0.21.0-next.0"
34+
},
3635
"devDependencies": {
3736
"@babel/plugin-proposal-export-namespace-from": "^7.18.9",
38-
"@babel/plugin-transform-modules-commonjs": "^7.21.5",
39-
"jsbi": "^4.1.0"
37+
"@babel/plugin-transform-modules-commonjs": "^7.21.5"
4038
}
4139
}

‎packages/toolkit/src/normalizers.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
// Note this is only used when you need to deal with CKB structures in molecule
1111
// format. If you are using RPCs or GraphQL to interact with CKB, chances are you
1212
// will not need this package.
13-
import JSBI from "jsbi";
13+
import { BI } from "@ckb-lumos/bi";
1414
import { Reader } from "./reader";
1515
/**
1616
* @deprecated please follow the {@link https://lumos-website.vercel.app/migrations/migrate-to-v0.19 migration-guide}
1717
*/
1818
function normalizeHexNumber(length) {
1919
return function (debugPath, value) {
2020
if (!(value instanceof ArrayBuffer)) {
21-
let intValue = JSBI.BigInt(value).toString(16);
21+
let intValue = BI.from(value).toString(16);
2222
if (intValue.length % 2 !== 0) {
2323
intValue = "0" + intValue;
2424
}
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const test = require("ava");
2+
const { normalizers } = require("../lib");
3+
4+
test("correct outPoint should pass validation", (t) => {
5+
const normalizedOutpoint = normalizers.NormalizeOutPoint({
6+
txHash: `0x${"00".repeat(32)}`,
7+
index: "0x1",
8+
});
9+
const expectedNormalizedIndex = new ArrayBuffer(4);
10+
const view = new Int32Array(expectedNormalizedIndex);
11+
view[0] = 1;
12+
13+
t.deepEqual(normalizedOutpoint, {
14+
index: expectedNormalizedIndex,
15+
txHash: new ArrayBuffer(32),
16+
});
17+
});
18+
19+
test("error outPoint should not pass validation", (t) => {
20+
t.throws(() => {
21+
normalizers.NormalizeOutPoint({
22+
txHash: `0x${"00".repeat(32)}`,
23+
index: "0x",
24+
});
25+
});
26+
t.throws(() => {
27+
normalizers.NormalizeOutPoint({
28+
txHash: `0x${"00".repeat(32)}`,
29+
index: "not a number",
30+
});
31+
});
32+
});

‎packages/toolkit/types/index.d.ts

-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import JSBI from "jsbi";
2-
31
export * as validators from "./validators";
42

53
/**
@@ -17,15 +15,6 @@ export class Reader {
1715
serializeJson(): string;
1816
}
1917

20-
/**
21-
* @deprecated please follow the {@link https://lumos-website.vercel.app/migrations/migrate-to-v0.19 migration-guide}
22-
*/
23-
export function HexStringToBigInt(hexString: string): JSBI;
24-
/**
25-
* @deprecated please follow the {@link https://lumos-website.vercel.app/migrations/migrate-to-v0.19 migration-guide}
26-
*/
27-
export function BigIntToHexString(i: JSBI): string;
28-
2918
/**
3019
* @deprecated please follow the {@link https://lumos-website.vercel.app/migrations/migrate-to-v0.19 migration-guide}
3120
*/

‎pnpm-lock.yaml

+3-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

2 commit comments

Comments
 (2)

github-actions[bot] commented on Oct 13, 2023

@github-actions[bot]
Contributor

🚀 New canary release: 0.0.0-canary-db34aef-20231013061434

npm install @ckb-lumos/lumos@0.0.0-canary-db34aef-20231013061434

vercel[bot] commented on Oct 13, 2023

@vercel[bot]
Please sign in to comment.