Skip to content

Commit

Permalink
chore(website): remove unnecessary webpack config (#720)
Browse files Browse the repository at this point in the history
  • Loading branch information
homura authored Jun 27, 2024
1 parent 36866bb commit 263456a
Show file tree
Hide file tree
Showing 18 changed files with 1,768 additions and 1,828 deletions.
5 changes: 5 additions & 0 deletions .changeset/angry-rabbits-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ckb-lumos/base": minor
---

**BREAKING CHANGE**: remove unused `isDeepEqual` function to reduce the package size
5 changes: 5 additions & 0 deletions .changeset/calm-crews-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ckb-lumos/common-scripts": minor
---

**BREAKING CHANGE**: default `generateDeployWithDataTx` to `data1` since `data2` is not active
5 changes: 5 additions & 0 deletions .changeset/green-pumpkins-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ckb-lumos/common-scripts": minor
---

**BREAKING CHANGE**: `createOmnilockScript` uses the `allows` option to restrict allowed btc addresses
6 changes: 6 additions & 0 deletions .changeset/lemon-tomatoes-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@ckb-lumos/common-scripts": minor
"@ckb-lumos/lumos": minor
---

feat: support eth displaying auth mode for omnilock
6 changes: 3 additions & 3 deletions packages/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@
"@types/blake2b": "^2.1.0",
"@types/lodash.isequal": "^4.5.5",
"blake2b": "^2.1.3",
"js-xxhash": "^1.0.4",
"lodash.isequal": "^4.5.0"
"js-xxhash": "^1.0.4"
},
"devDependencies": {
"jsbi": "^4.1.0"
"jsbi": "^4.1.0",
"lodash.isequal": "^4.5.0"
},
"publishConfig": {
"access": "public"
Expand Down
6 changes: 0 additions & 6 deletions packages/base/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import blake2b, { Blake2b } from "blake2b";
import isEqual from "lodash.isequal";
import { xxHash32 } from "js-xxhash";
import { bytes, number, BytesLike } from "@ckb-lumos/codec";
import { BI, BIish } from "@ckb-lumos/bi";
Expand Down Expand Up @@ -149,10 +148,6 @@ function assertHexadecimal(debugPath: string, str: string): void {
}
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
function isDeepEqual(a: any, b: any): boolean {
return isEqual(a, b);
}
// Buffer.from('TYPE_ID')
const TYPE_ID_CODE_HASH =
"0x00000000000000000000000000000000000000000000000000545950455f4944";
Expand Down Expand Up @@ -272,6 +267,5 @@ export {
hashCode,
assertHexString,
assertHexadecimal,
isDeepEqual,
generateTypeIdScript,
};
5 changes: 3 additions & 2 deletions packages/base/tests/since.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const test = require("ava");
const isEqual = require("lodash.isequal");
const { BI } = require("@ckb-lumos/bi");

const { since, utils } = require("../src");
const { since } = require("../src");

const {
parseSinceCompatible,
Expand Down Expand Up @@ -91,7 +92,7 @@ test.before(() => {
test("parsedSince", (t) => {
fixtrues.forEach((v) => {
const parsed = parseSinceCompatible(v.since);
t.true(utils.isDeepEqual(parsed, v.parsed));
t.true(isEqual(parsed, v.parsed));
});
});

Expand Down
3 changes: 2 additions & 1 deletion packages/common-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"@ckb-lumos/helpers": "0.23.0",
"@ckb-lumos/rpc": "0.23.0",
"@ckb-lumos/toolkit": "0.23.0",
"bs58": "^5.0.0",
"bech32": "^2.0.0",
"bs58": "^5.0.0",
"immutable": "^4.3.0"
},
"repository": {
Expand Down Expand Up @@ -59,6 +59,7 @@
"@ckb-lumos/crypto": "0.23.0",
"@ckb-lumos/debugger": "0.23.0",
"@ckb-lumos/hd": "0.23.0",
"@ethereumjs/util": "^9.0.3",
"@unisat/wallet-sdk": "^1.1.2",
"tweetnacl": "^1.0.3"
},
Expand Down
68 changes: 26 additions & 42 deletions packages/common-scripts/src/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import {
blockchain,
} from "@ckb-lumos/base";
import { bytes } from "@ckb-lumos/codec";
import { getConfig, Config, helpers } from "@ckb-lumos/config-manager";
import {
getConfig,
Config,
helpers,
ScriptConfig,
} from "@ckb-lumos/config-manager";
import {
TransactionSkeletonType,
TransactionSkeleton,
Expand All @@ -21,18 +26,10 @@ import {
} from "@ckb-lumos/helpers";
import { Set } from "immutable";
import { FromInfo, parseFromInfo, MultisigScript } from "./from_info";
import { BI, BIish } from "@ckb-lumos/bi";
import { BI, BIish, parseUnit } from "@ckb-lumos/bi";
import { RPC } from "@ckb-lumos/rpc";
const { ScriptValue } = values;

function bytesToHex(bytes: Uint8Array): string {
let res = "0x";
for (let i = 0; i < bytes.length; i++) {
res += bytes[i].toString(16).padStart(2, "0");
}
return res;
}

async function findCellsByLock(
lockScript: Script,
cellProvider: CellProvider
Expand Down Expand Up @@ -127,6 +124,8 @@ async function completeTx(
return txSkeleton;
}

const ONE_CKB = parseUnit("1", "ckb");

async function injectCapacity(
txSkeleton: TransactionSkeletonType,
fromInfo: FromInfo,
Expand All @@ -140,8 +139,8 @@ async function injectCapacity(
const _feeRate = feeRate || 1000;
let _amount = BI.from(amount);
const { fromScript, multisigScript } = parseFromInfo(fromInfo, { config });
_amount = _amount.add(BI.from(10).pow(8));
let changeCapacity = BI.from(10).pow(8);
_amount = _amount.add(ONE_CKB);
let changeCapacity = ONE_CKB;
const changeCell: Cell = {
cellOutput: {
capacity: "0x0",
Expand All @@ -152,7 +151,7 @@ async function injectCapacity(
};
const minimalChangeCapacity: BI = BI.from(
minimalCellCapacityCompatible(changeCell)
).add(BI.from(10).pow(8));
).add(ONE_CKB);

if (_amount.lt(0)) {
changeCapacity = changeCapacity.sub(_amount);
Expand Down Expand Up @@ -236,12 +235,14 @@ async function injectCapacity(

if (typeof fromInfo !== "string") {
newWitnessArgs = {
lock:
"0x" +
multisigScript!.slice(2) +
SECP_SIGNATURE_PLACEHOLDER.slice(2).repeat(
(fromInfo as MultisigScript).M
),
lock: bytes.hexify(
bytes.concat(
multisigScript!,

Check warning on line 240 in packages/common-scripts/src/deploy.ts

View workflow job for this annotation

GitHub Actions / lint-staged

Forbidden non-null assertion
...new Array((fromInfo as MultisigScript).M).fill(
SECP_SIGNATURE_PLACEHOLDER
)
)
),
};
} else {
newWitnessArgs = { lock: SECP_SIGNATURE_PLACEHOLDER };
Expand Down Expand Up @@ -298,7 +299,8 @@ function getTransactionSize(txSkeleton: TransactionSkeletonType): number {
function getTransactionSizeByTx(tx: Transaction): number {
const serializedTx = blockchain.Transaction.pack(tx);
// 4 is serialized offset bytesize
const size = serializedTx.byteLength + 4;
const MOLECULE_TABLE_OFFSET = 4;
const size = serializedTx.byteLength + MOLECULE_TABLE_OFFSET;
return size;
}

Expand Down Expand Up @@ -341,24 +343,6 @@ async function getDataHash(outPoint: OutPoint, rpc: RPC): Promise<string> {
return new utils.CKBHasher().update(bytes.bytify(outputData)).digestHex();
}

interface ScriptConfig {
// if hashType is type, codeHash is ckbHash(type_script)
// if hashType is data, codeHash is ckbHash(data)
CODE_HASH: string;

HASH_TYPE: "type" | "data2";

TX_HASH: string;
// the deploy cell can be found at index of tx's outputs
INDEX: string;

// now deployWithX only supportted `code `
DEP_TYPE: "depGroup" | "code";

// empty
SHORT_ID?: number;
}

function calculateTxHash(txSkeleton: TransactionSkeletonType): string {
const tx = createTransactionFromSkeleton(txSkeleton);
const txHash = utils.ckbHash(blockchain.RawTransaction.pack(tx));
Expand All @@ -374,7 +358,7 @@ function getScriptConfigByDataHash(
const txHash = calculateTxHash(txSkeleton);
const scriptConfig: ScriptConfig = {
CODE_HASH: codeHash,
HASH_TYPE: "data2",
HASH_TYPE: "data1",
TX_HASH: txHash,
INDEX: "0x0",
DEP_TYPE: "code",
Expand Down Expand Up @@ -485,7 +469,7 @@ export async function generateDeployWithDataTx(
capacity: "0x0",
lock: fromScript,
},
data: bytesToHex(options.scriptBinary),
data: bytes.hexify(options.scriptBinary),
};

txSkeleton = updateOutputs(txSkeleton, output);
Expand Down Expand Up @@ -535,7 +519,7 @@ export async function generateDeployWithTypeIdTx(
lock: fromScript,
type: typeId,
},
data: bytesToHex(options.scriptBinary),
data: bytes.hexify(options.scriptBinary),
};

txSkeleton = updateOutputs(txSkeleton, output);
Expand Down Expand Up @@ -584,7 +568,7 @@ export async function generateUpgradeTypeIdDataTx(
lock: fromScript,
type: options.typeId,
},
data: bytesToHex(options.scriptBinary),
data: bytes.hexify(options.scriptBinary),
};

txSkeleton = updateOutputs(txSkeleton, output);
Expand Down
Loading

0 comments on commit 263456a

Please sign in to comment.