From 306ae308598f49f4fdeda0e0ef893f74e36b151d Mon Sep 17 00:00:00 2001 From: zhangyouxin Date: Fri, 12 Aug 2022 09:03:15 +0800 Subject: [PATCH] upgrate lumos to 0.19 --- packages/light-godwoken/package.json | 8 +- .../light-godwoken/src/LightGodwokenV0.ts | 31 ++- .../light-godwoken/src/LightGodwokenV1.ts | 28 +-- .../src/__tests__/codec.spec.ts | 8 +- .../src/__tests__/lightGodwoken.spec.ts | 22 +- .../src/__tests__/lightGodwokenConfig.ts | 56 ++--- .../__tests__/lightGodwokenDeposit.spec.ts | 8 +- .../src/__tests__/sudtFaucet.spec.ts | 2 +- .../light-godwoken/src/__tests__/utils.ts | 32 +-- .../src/constants/configTypes.ts | 8 +- .../src/constants/configUtils.ts | 6 +- .../src/constants/lightGodwokenConfig.ts | 112 +++++----- .../src/godwoken/godwokenScannerV1.ts | 4 +- packages/light-godwoken/src/lightGodwoken.ts | 208 +++++++++--------- .../src/lightGodwokenProvider.ts | 47 ++-- .../light-godwoken/src/lightGodwokenType.ts | 2 +- .../light-godwoken/src/schemas/codecLayer1.ts | 3 +- .../light-godwoken/src/schemas/codecV0.ts | 15 +- .../light-godwoken/src/schemas/codecV1.ts | 15 +- packages/light-godwoken/src/sudtFaucet.ts | 82 ++++--- yarn.lock | 151 ++++++++++--- 21 files changed, 464 insertions(+), 384 deletions(-) diff --git a/packages/light-godwoken/package.json b/packages/light-godwoken/package.json index ac17e184..1ed370ce 100644 --- a/packages/light-godwoken/package.json +++ b/packages/light-godwoken/package.json @@ -16,10 +16,10 @@ "dist" ], "dependencies": { - "@ckb-lumos/bi": "^0.17.0-rc10", - "@ckb-lumos/base": "^0.17.0-rc10", - "@ckb-lumos/codec": "^0.17.0-rc10", - "@ckb-lumos/lumos": "^0.17.0-rc10", + "@ckb-lumos/bi": "^0.19.0-alpha.0", + "@ckb-lumos/base": "^0.19.0-alpha.0", + "@ckb-lumos/codec": "^0.19.0-alpha.0", + "@ckb-lumos/lumos": "^0.19.0-alpha.0", "@polyjuice-provider/base": "^0.1.1", "@polyjuice-provider/ethers": "^0.1.5", "@polyjuice-provider/godwoken": "^0.1.1", diff --git a/packages/light-godwoken/src/LightGodwokenV0.ts b/packages/light-godwoken/src/LightGodwokenV0.ts index f46a4ce0..4443294f 100644 --- a/packages/light-godwoken/src/LightGodwokenV0.ts +++ b/packages/light-godwoken/src/LightGodwokenV0.ts @@ -1,5 +1,4 @@ import { BI, Hash, HashType, helpers, HexNumber, HexString, Script, toolkit, utils } from "@ckb-lumos/lumos"; -import { Hexadecimal } from "@ckb-lumos/base"; import EventEmitter from "events"; import DefaultLightGodwoken from "./lightGodwoken"; import { @@ -61,11 +60,11 @@ export default class DefaultLightGodwokenV0 extends DefaultLightGodwoken impleme getMinimalWithdrawalCapacity(): BI { const minimalCapacity = 8 + // capacity - 32 + // withdrawal_lock.code_hash - 1 + // withdrawal_lock.hash_type + 32 + // withdrawal_lock.codeHash + 1 + // withdrawal_lock.hashType 303 + // withdrawal_lock.args TODO: explain why this is 303 - 32 + // sudt_type.code_hash - 1 + // sudt_type.hash_type + 32 + // sudt_type.codeHash + 1 + // sudt_type.hashType 32 + // sudt_type.args 16; // sudt_amount @@ -104,8 +103,8 @@ export default class DefaultLightGodwokenV0 extends DefaultLightGodwoken impleme const sudtScriptConfig = this.provider.getConfig().layer1Config.SCRIPTS.sudt; getTokenList().v0.forEach((token) => { const tokenL1Script: Script = { - code_hash: sudtScriptConfig.code_hash, - hash_type: sudtScriptConfig.hash_type as HashType, + codeHash: sudtScriptConfig.codeHash, + hashType: sudtScriptConfig.hashType as HashType, args: token.l1LockArgs, }; const tokenScriptHash = utils.computeScriptHash(tokenL1Script); @@ -138,8 +137,8 @@ export default class DefaultLightGodwokenV0 extends DefaultLightGodwoken impleme const sudtScriptConfig = this.provider.getConfig().layer1Config.SCRIPTS.sudt; getTokenList().v0.forEach((token) => { const tokenL1Script: Script = { - code_hash: sudtScriptConfig.code_hash, - hash_type: sudtScriptConfig.hash_type as HashType, + codeHash: sudtScriptConfig.codeHash, + hashType: sudtScriptConfig.hashType as HashType, args: token.l1LockArgs, }; map.push({ @@ -223,7 +222,7 @@ export default class DefaultLightGodwokenV0 extends DefaultLightGodwoken impleme return { balances: balances.map((b) => b.toHexString()) }; } - async getErc20Balance(address: HexString): Promise { + async getErc20Balance(address: HexString): Promise { const contract = new this.provider.web3.eth.Contract(SUDT_ERC20_PROXY_ABI as AbiItems, address); return await contract.methods.balanceOf(this.provider.l2Address).call(); } @@ -253,8 +252,8 @@ export default class DefaultLightGodwokenV0 extends DefaultLightGodwoken impleme return { isFastWithdrawal: item.is_fast_withdrawal, layer1TxHash: item.layer1_tx_hash, - withdrawalBlockNumber: item.block_number, - remainingBlockNumber: Math.max(0, item.block_number - lastFinalizedBlockNumber), + withdrawalBlockNumber: item.blockNumber, + remainingBlockNumber: Math.max(0, item.blockNumber - lastFinalizedBlockNumber), capacity: BI.from(item.capacity).toHexString(), amount, sudt_script_hash: item.udt_script_hash, @@ -273,8 +272,8 @@ export default class DefaultLightGodwokenV0 extends DefaultLightGodwoken impleme const { layer2Config } = this.provider.getLightGodwokenConfig(); return { script: { - code_hash: layer2Config.SCRIPTS.withdrawal_lock.script_type_hash, - hash_type: "type" as HashType, + codeHash: layer2Config.SCRIPTS.withdrawal_lock.script_type_hash, + hashType: "type" as HashType, args: `${layer2Config.ROLLUP_CONFIG.rollup_type_hash}${accountScriptHash.slice(2)}`, }, script_type: "lock", @@ -480,8 +479,8 @@ export default class DefaultLightGodwokenV0 extends DefaultLightGodwoken impleme ).serializeJson(); const { SCRIPTS, ROLLUP_CONFIG } = this.provider.getLightGodwokenConfig().layer2Config; const depositLock: Script = { - code_hash: SCRIPTS.deposit_lock.script_type_hash, - hash_type: "type", + codeHash: SCRIPTS.deposit_lock.script_type_hash, + hashType: "type", args: ROLLUP_CONFIG.rollup_type_hash + depositLockArgsHexString.slice(2), }; return depositLock; diff --git a/packages/light-godwoken/src/LightGodwokenV1.ts b/packages/light-godwoken/src/LightGodwokenV1.ts index 778dc30f..614a22d3 100644 --- a/packages/light-godwoken/src/LightGodwokenV1.ts +++ b/packages/light-godwoken/src/LightGodwokenV1.ts @@ -114,8 +114,8 @@ export default class DefaultLightGodwokenV1 extends DefaultLightGodwoken impleme const sudtScriptConfig = this.provider.getConfig().layer1Config.SCRIPTS.sudt; getTokenList().v1.forEach((token) => { const tokenL1Script: Script = { - code_hash: sudtScriptConfig.code_hash, - hash_type: sudtScriptConfig.hash_type as HashType, + codeHash: sudtScriptConfig.codeHash, + hashType: sudtScriptConfig.hashType as HashType, args: token.l1LockArgs, }; sudtList.push({ @@ -134,8 +134,8 @@ export default class DefaultLightGodwokenV1 extends DefaultLightGodwoken impleme const sudtScriptConfig = this.provider.getConfig().layer1Config.SCRIPTS.sudt; getTokenList().v1.forEach((token) => { const tokenL1Script: Script = { - code_hash: sudtScriptConfig.code_hash, - hash_type: sudtScriptConfig.hash_type as HashType, + codeHash: sudtScriptConfig.codeHash, + hashType: sudtScriptConfig.hashType as HashType, args: token.l1LockArgs, }; const tokenScriptHash = utils.computeScriptHash(tokenL1Script); @@ -229,8 +229,8 @@ export default class DefaultLightGodwokenV1 extends DefaultLightGodwoken impleme } return { layer1TxHash: item.layer1_tx_hash, - withdrawalBlockNumber: item.block_number, - remainingBlockNumber: Math.max(0, item.block_number - lastFinalizedBlockNumber), + withdrawalBlockNumber: item.blockNumber, + remainingBlockNumber: Math.max(0, item.blockNumber - lastFinalizedBlockNumber), capacity: BI.from(item.capacity).toHexString(), amount, sudt_script_hash: item.udt_script_hash, @@ -248,8 +248,8 @@ export default class DefaultLightGodwokenV1 extends DefaultLightGodwoken impleme const { layer2Config } = this.provider.getLightGodwokenConfig(); return { script: { - code_hash: layer2Config.SCRIPTS.withdrawal_lock.script_type_hash, - hash_type: "type" as HashType, + codeHash: layer2Config.SCRIPTS.withdrawal_lock.script_type_hash, + hashType: "type" as HashType, args: "0x", }, script_type: "lock", @@ -329,8 +329,8 @@ export default class DefaultLightGodwokenV1 extends DefaultLightGodwoken impleme chainId: Number(rawWithdrawalRequest.chain_id), fee: 0, layer1OwnerLock: { - codeHash: ownerLock.code_hash, - hashType: ownerLock.hash_type, + codeHash: ownerLock.codeHash, + hashType: ownerLock.hashType, args: ownerLock.args, }, withdraw: { @@ -384,8 +384,8 @@ export default class DefaultLightGodwokenV1 extends DefaultLightGodwoken impleme const ownerLockHash = utils.computeScriptHash(ownerLock); const ethAddress = this.provider.l2Address; const l2AccountScript: Script = { - code_hash: layer2Config.SCRIPTS.eth_account_lock.script_type_hash, - hash_type: "type", + codeHash: layer2Config.SCRIPTS.eth_account_lock.script_type_hash, + hashType: "type", args: layer2Config.ROLLUP_CONFIG.rollup_type_hash + ethAddress.slice(2), }; const layer2AccountScriptHash = utils.computeScriptHash(l2AccountScript); @@ -464,8 +464,8 @@ export default class DefaultLightGodwokenV1 extends DefaultLightGodwoken impleme const { SCRIPTS, ROLLUP_CONFIG } = this.provider.getLightGodwokenConfig().layer2Config; const depositLock: Script = { - code_hash: SCRIPTS.deposit_lock.script_type_hash, - hash_type: "type", + codeHash: SCRIPTS.deposit_lock.script_type_hash, + hashType: "type", args: ROLLUP_CONFIG.rollup_type_hash + depositLockArgsHexString.slice(2), }; return depositLock; diff --git a/packages/light-godwoken/src/__tests__/codec.spec.ts b/packages/light-godwoken/src/__tests__/codec.spec.ts index a87de310..de872e30 100644 --- a/packages/light-godwoken/src/__tests__/codec.spec.ts +++ b/packages/light-godwoken/src/__tests__/codec.spec.ts @@ -19,8 +19,8 @@ describe("test codec", () => { const depositArgs = { owner_lock_hash: "0xea8e5a6ed260ee56af7d66ddb8c7c09a3ade6c38d207c30a6d11b3d8e11387df", layer2_lock: { - code_hash: "0x07521d0aa8e66ef441ebc31204d86bb23fc83e9edc58c19dbb1b0ebe64336ec0", - hash_type: "type", + codeHash: "0x07521d0aa8e66ef441ebc31204d86bb23fc83e9edc58c19dbb1b0ebe64336ec0", + hashType: "type", args: "0x702359ea7f073558921eb50d8c1c77e92f760c8f8656bde4995f26b8963e2dd862a67949836b389ec146b3b2187e949f7faef679", }, cancel_timeout: BI.from("0xc0000000000004b0"), @@ -35,8 +35,8 @@ describe("test codec", () => { const depositArgs = { owner_lock_hash: "0xea8e5a6ed260ee56af7d66ddb8c7c09a3ade6c38d207c30a6d11b3d8e11387df", layer2_lock: { - code_hash: "0x07521d0aa8e66ef441ebc31204d86bb23fc83e9edc58c19dbb1b0ebe64336ec0", - hash_type: "type", + codeHash: "0x07521d0aa8e66ef441ebc31204d86bb23fc83e9edc58c19dbb1b0ebe64336ec0", + hashType: "type", args: "0x702359ea7f073558921eb50d8c1c77e92f760c8f8656bde4995f26b8963e2dd862a67949836b389ec146b3b2187e949f7faef679", }, cancel_timeout: BI.from("0xc000000000093a81"), diff --git a/packages/light-godwoken/src/__tests__/lightGodwoken.spec.ts b/packages/light-godwoken/src/__tests__/lightGodwoken.spec.ts index 60a884eb..ecd3c2cf 100644 --- a/packages/light-godwoken/src/__tests__/lightGodwoken.spec.ts +++ b/packages/light-godwoken/src/__tests__/lightGodwoken.spec.ts @@ -29,7 +29,7 @@ describe("test light godwoken generateDepositOutputCell", () => { capacity: BI.from(400e8).toHexString(), }); expect(outputCells.length).toEqual(1); - expect(outputCells[0].cell_output.capacity).toEqual(BI.from(400e8).toHexString()); + expect(outputCells[0].cellOutput.capacity).toEqual(BI.from(400e8).toHexString()); }); it("should deposit 400 CKB, 300 pure CKB and 100 free CKB", async () => { const typeScript: Script = randomSudtTypeScript(lightGodwokenV1.getConfig()); @@ -40,9 +40,9 @@ describe("test light godwoken generateDepositOutputCell", () => { }); const [sudtExchangeCell, depositCell] = outputCells; expect(outputCells.length).toEqual(2); - expect(sudtExchangeCell.cell_output.capacity).toEqual(BI.from(144e8).toHexString()); - expect(sudtExchangeCell.cell_output.type).toEqual(typeScript); - expect(depositCell.cell_output.capacity).toEqual(BI.from(400e8).toHexString()); + expect(sudtExchangeCell.cellOutput.capacity).toEqual(BI.from(144e8).toHexString()); + expect(sudtExchangeCell.cellOutput.type).toEqual(typeScript); + expect(depositCell.cellOutput.capacity).toEqual(BI.from(400e8).toHexString()); }); it("should deposit 400 CKB, 250 pure CKB and 100 from free CKB and 50 from sudt cell", async () => { const freeTypeScript: Script = randomSudtTypeScript(lightGodwokenV1.getConfig()); @@ -58,15 +58,15 @@ describe("test light godwoken generateDepositOutputCell", () => { const [sudtExchangeCell, depositCell, ckbExchangeCell] = outputCells; expect(outputCells.length).toEqual(3); // output 0 is free ckb provider cell after taken free ckb away - expect(sudtExchangeCell.cell_output.capacity).toEqual(BI.from(144e8).toHexString()); - expect(sudtExchangeCell.cell_output.type).toEqual(freeTypeScript); + expect(sudtExchangeCell.cellOutput.capacity).toEqual(BI.from(144e8).toHexString()); + expect(sudtExchangeCell.cellOutput.type).toEqual(freeTypeScript); // output 1 is deposit cell - expect(depositCell.cell_output.capacity).toEqual(BI.from(400e8).toHexString()); - expect(depositCell.cell_output.type).toEqual(depositSudtTypeScript); + expect(depositCell.cellOutput.capacity).toEqual(BI.from(400e8).toHexString()); + expect(depositCell.cellOutput.type).toEqual(depositSudtTypeScript); // output 2 is exchangecell - expect(ckbExchangeCell.cell_output.capacity).toEqual(BI.from(144e8).toHexString()); - expect(ckbExchangeCell.cell_output.type).toEqual(undefined); - expect(ckbExchangeCell.cell_output.lock).toEqual(lightGodwokenV1.provider.getLayer1Lock()); + expect(ckbExchangeCell.cellOutput.capacity).toEqual(BI.from(144e8).toHexString()); + expect(ckbExchangeCell.cellOutput.type).toEqual(undefined); + expect(ckbExchangeCell.cellOutput.lock).toEqual(lightGodwokenV1.provider.getLayer1Lock()); }); it("should generateDepositTx if user deposit 400 CKB, and user has 250 pure CKB and 100 from free CKB and 50 from sudt cell", async () => { const freeTypeScript: Script = randomSudtTypeScript(lightGodwokenV1.getConfig()); diff --git a/packages/light-godwoken/src/__tests__/lightGodwokenConfig.ts b/packages/light-godwoken/src/__tests__/lightGodwokenConfig.ts index 4cf25ca8..f82bd33b 100644 --- a/packages/light-godwoken/src/__tests__/lightGodwokenConfig.ts +++ b/packages/light-godwoken/src/__tests__/lightGodwokenConfig.ts @@ -3,25 +3,25 @@ import { Layer1Config, LightGodwokenConfigMap } from "../constants/configTypes"; const layer1ConfigAggron: Layer1Config = { SCRIPTS: { omni_lock: { - code_hash: "0x79f90bb5e892d80dd213439eeab551120eb417678824f282b4ffb5f21bad2e1e", - hash_type: "type", - tx_hash: "0x9154df4f7336402114d04495175b37390ce86a4906d2d4001cf02c3e6d97f39c", + codeHash: "0x79f90bb5e892d80dd213439eeab551120eb417678824f282b4ffb5f21bad2e1e", + hashType: "type", + txHash: "0x9154df4f7336402114d04495175b37390ce86a4906d2d4001cf02c3e6d97f39c", index: "0x0", - dep_type: "code", + depType: "code", }, secp256k1_blake160: { - code_hash: "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", - hash_type: "type", - tx_hash: "0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37", + codeHash: "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", + hashType: "type", + txHash: "0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37", index: "0x0", - dep_type: "dep_group", + depType: "depGroup", }, sudt: { - code_hash: "0xc5e5dcf215925f7ef4dfaf5f4b4f105bc321c02776d6e7d52a1db3fcd9d011a4", - hash_type: "type", - tx_hash: "0xe12877ebd2c3c364dc46c5c992bcfaf4fee33fa13eebdf82c591fc9825aab769", + codeHash: "0xc5e5dcf215925f7ef4dfaf5f4b4f105bc321c02776d6e7d52a1db3fcd9d011a4", + hashType: "type", + txHash: "0xe12877ebd2c3c364dc46c5c992bcfaf4fee33fa13eebdf82c591fc9825aab769", index: "0x0", - dep_type: "code", + depType: "code", }, }, CKB_INDEXER_URL: "https://testnet.ckb.dev/indexer", @@ -37,21 +37,21 @@ export const testConfig: LightGodwokenConfigMap = { deposit_lock: { script_type_hash: "0x5a2506bb68d81a11dcadad4cb7eae62a17c43c619fe47ac8037bc8ce2dd90360", cell_dep: { - out_point: { - tx_hash: "0x9caeec735f3cd2a60b9d12be59bb161f7c61ddab1ac22c4383a94c33ba6404a2", + outPoint: { + txHash: "0x9caeec735f3cd2a60b9d12be59bb161f7c61ddab1ac22c4383a94c33ba6404a2", index: "0x0", }, - dep_type: "code", + depType: "code", }, }, withdrawal_lock: { script_type_hash: "0x170ef156e9f6132dbca6069dfd3e436f7d91c29d3ac7332c4b33e633b6a299b5", cell_dep: { - out_point: { - tx_hash: "0xb4b07dcd1571ac18683b515ada40e13b99bd0622197b6817047adc9f407f4828", + outPoint: { + txHash: "0xb4b07dcd1571ac18683b515ada40e13b99bd0622197b6817047adc9f407f4828", index: "0x0", }, - dep_type: "code", + depType: "code", }, }, eth_account_lock: { @@ -61,8 +61,8 @@ export const testConfig: LightGodwokenConfigMap = { ROLLUP_CONFIG: { rollup_type_hash: "0x4cc2e6526204ae6a2e8fcf12f7ad472f41a1606d5b9624beebd215d780809f6a", rollup_type_script: { - code_hash: "0x5c365147bb6c40e817a2a53e0dec3661f7390cc77f0c02db138303177b12e9fb", - hash_type: "type", + codeHash: "0x5c365147bb6c40e817a2a53e0dec3661f7390cc77f0c02db138303177b12e9fb", + hashType: "type", args: "0x213743d13048e9f36728c547ab736023a7426e15a3d7d1c82f43ec3b5f266df2", }, }, @@ -82,21 +82,21 @@ export const testConfig: LightGodwokenConfigMap = { deposit_lock: { script_type_hash: "0x50704b84ecb4c4b12b43c7acb260ddd69171c21b4c0ba15f3c469b7d143f6f18", cell_dep: { - out_point: { - tx_hash: "0x9caeec735f3cd2a60b9d12be59bb161f7c61ddab1ac22c4383a94c33ba6404a2", + outPoint: { + txHash: "0x9caeec735f3cd2a60b9d12be59bb161f7c61ddab1ac22c4383a94c33ba6404a2", index: "0x0", }, - dep_type: "code", + depType: "code", }, }, withdrawal_lock: { script_type_hash: "0x06ae0706bb2d7997d66224741d3ec7c173dbb2854a6d2cf97088796b677269c6", cell_dep: { - out_point: { - tx_hash: "0x9c607a9a75ea4699dd01b1c2a478002343998cac8346d2aa582f35b532bd2b93", + outPoint: { + txHash: "0x9c607a9a75ea4699dd01b1c2a478002343998cac8346d2aa582f35b532bd2b93", index: "0x0", }, - dep_type: "code", + depType: "code", }, }, eth_account_lock: { @@ -106,8 +106,8 @@ export const testConfig: LightGodwokenConfigMap = { ROLLUP_CONFIG: { rollup_type_hash: "0x702359ea7f073558921eb50d8c1c77e92f760c8f8656bde4995f26b8963e2dd8", rollup_type_script: { - code_hash: "0x1e44736436b406f8e48a30dfbddcf044feb0c9eebfe63b0f81cb5bb727d84854", - hash_type: "type", + codeHash: "0x1e44736436b406f8e48a30dfbddcf044feb0c9eebfe63b0f81cb5bb727d84854", + hashType: "type", args: "0x86c7429247beba7ddd6e4361bcdfc0510b0b644131e2afb7e486375249a01802", }, }, diff --git a/packages/light-godwoken/src/__tests__/lightGodwokenDeposit.spec.ts b/packages/light-godwoken/src/__tests__/lightGodwokenDeposit.spec.ts index c2ae9ad1..f27abc2f 100644 --- a/packages/light-godwoken/src/__tests__/lightGodwokenDeposit.spec.ts +++ b/packages/light-godwoken/src/__tests__/lightGodwokenDeposit.spec.ts @@ -85,8 +85,8 @@ describe("test light godwoken v1 deposit", () => { const lock = await lightGodwokenV1.generateDepositLock(); expect(lock).toEqual({ args: "0x702359ea7f073558921eb50d8c1c77e92f760c8f8656bde4995f26b8963e2dd8a900000014000000340000009d000000a50000003837aad0e28da55d366d62b7df9b1b0613c39c730c4c409b9722d4bed8cfa9266900000010000000300000003100000007521d0aa8e66ef441ebc31204d86bb23fc83e9edc58c19dbb1b0ebe64336ec00134000000702359ea7f073558921eb50d8c1c77e92f760c8f8656bde4995f26b8963e2dd80c1efcca2bcb65a532274f3ef24c044ef4ab6d73803a0900000000c002000000", - code_hash: "0x50704b84ecb4c4b12b43c7acb260ddd69171c21b4c0ba15f3c469b7d143f6f18", - hash_type: "type", + codeHash: "0x50704b84ecb4c4b12b43c7acb260ddd69171c21b4c0ba15f3c469b7d143f6f18", + hashType: "type", }); }); it("should deposit 2000 ckb ok when user balance is 2000", async () => { @@ -95,7 +95,7 @@ describe("test light godwoken v1 deposit", () => { capacity: BI.from(2000).mul(BI.from(10).pow(8)).toHexString(), }); - expect(tx.outputs.get(0)?.cell_output.capacity).toEqual(BI.from(2000).mul(BI.from(10).pow(8)).toHexString()); + expect(tx.outputs.get(0)?.cellOutput.capacity).toEqual(BI.from(2000).mul(BI.from(10).pow(8)).toHexString()); expect(outputCapacityOf(tx).toString()).toEqual("2000"); }); it("should deposit 2000 ckb fail when user balance is 1999", async () => { @@ -158,7 +158,7 @@ describe("test light godwoken v0 deposit", () => { capacity: BI.from(2000).mul(BI.from(10).pow(8)).toHexString(), }); - expect(tx.outputs.get(0)?.cell_output.capacity).toEqual(BI.from(2000).mul(BI.from(10).pow(8)).toHexString()); + expect(tx.outputs.get(0)?.cellOutput.capacity).toEqual(BI.from(2000).mul(BI.from(10).pow(8)).toHexString()); expect(outputCapacityOf(tx).toString()).toEqual("2000"); }); it("should deposit 2000 ckb fail when user balance is 1999", async () => { diff --git a/packages/light-godwoken/src/__tests__/sudtFaucet.spec.ts b/packages/light-godwoken/src/__tests__/sudtFaucet.spec.ts index 2f0bc0e1..69e3432b 100644 --- a/packages/light-godwoken/src/__tests__/sudtFaucet.spec.ts +++ b/packages/light-godwoken/src/__tests__/sudtFaucet.spec.ts @@ -13,7 +13,7 @@ describe("test faucet", () => { { collector: () => mockCollector }, "0xb60bf0787fa97c52bb62d41131757954d5bda2f2054fb0c5efa172fa6b945296", ); - expect(helpers.createTransactionFromSkeleton(generatedTx).outputs_data[1]).toEqual( + expect(helpers.createTransactionFromSkeleton(generatedTx).outputsData[1]).toEqual( utils.toBigUInt128LE(BI.from(1000).mul(BI.from(10).pow(18))), ); const signature = await userSignTransaction(generatedTx, { request: sinon.stub().returns(randomHexString(65)) }); diff --git a/packages/light-godwoken/src/__tests__/utils.ts b/packages/light-godwoken/src/__tests__/utils.ts index 12308ea0..d0d76285 100644 --- a/packages/light-godwoken/src/__tests__/utils.ts +++ b/packages/light-godwoken/src/__tests__/utils.ts @@ -16,42 +16,42 @@ export const dummyScriptHash: HexString = `0x${"0".repeat(64)}`; export const randomScript = (byteLength: number): Script => { return { - code_hash: randomHexString(32), - hash_type: "type" as HashType, + codeHash: randomHexString(32), + hashType: "type" as HashType, args: randomHexString(byteLength), }; }; export const randomSudtTypeScriptWithoutArgs = (config: LightGodwokenConfig): Script => { return { - code_hash: config.layer1Config.SCRIPTS.sudt.code_hash, - hash_type: config.layer1Config.SCRIPTS.sudt.hash_type, + codeHash: config.layer1Config.SCRIPTS.sudt.codeHash, + hashType: config.layer1Config.SCRIPTS.sudt.hashType, args: "0x", }; }; export const randomSudtTypeScript = (config: LightGodwokenConfig): Script => { return { - code_hash: config.layer1Config.SCRIPTS.sudt.code_hash, - hash_type: config.layer1Config.SCRIPTS.sudt.hash_type, + codeHash: config.layer1Config.SCRIPTS.sudt.codeHash, + hashType: config.layer1Config.SCRIPTS.sudt.hashType, args: randomHexString(32), }; }; export const generateCellInput = (capacity: number, type?: Script, sudtData?: number) => { - const tx_hash = randomHexString(32); + const txHash = randomHexString(32); const lock = { args: randomHexString(20), - code_hash: randomHexString(32), - hash_type: "type" as HashType, + codeHash: randomHexString(32), + hashType: "type" as HashType, }; const cellInput: Cell = { - block_number: "0x0", - out_point: { + blockNumber: "0x0", + outPoint: { index: "0x0", - tx_hash, + txHash, }, - cell_output: { + cellOutput: { capacity: BI.from(capacity).mul(100000000).toHexString(), lock, type, @@ -63,17 +63,17 @@ export const generateCellInput = (capacity: number, type?: Script, sudtData?: nu export const outputCapacityOf = (tx: helpers.TransactionSkeletonType): BI => { const outputs = tx.outputs.toArray(); - return outputs.reduce((sum, current) => sum.add(current.cell_output.capacity), BI.from(0)).div(100000000); + return outputs.reduce((sum, current) => sum.add(current.cellOutput.capacity), BI.from(0)).div(100000000); }; export const inputCapacityOf = (tx: helpers.TransactionSkeletonType): BI => { const inputs = tx.inputs.toArray(); - return inputs.reduce((sum, current) => sum.add(current.cell_output.capacity), BI.from(0)).div(100000000); + return inputs.reduce((sum, current) => sum.add(current.cellOutput.capacity), BI.from(0)).div(100000000); }; export const outputSudtAmountOf = (tx: helpers.TransactionSkeletonType): BI => { const outputs = tx.outputs.toArray(); return outputs .reduce((sum, current) => { - if (current.cell_output.type) { + if (current.cellOutput.type) { return sum.add(utils.readBigUInt128LECompatible(current.data)); } else { return sum; diff --git a/packages/light-godwoken/src/constants/configTypes.ts b/packages/light-godwoken/src/constants/configTypes.ts index 8d7630bd..adfaa526 100644 --- a/packages/light-godwoken/src/constants/configTypes.ts +++ b/packages/light-godwoken/src/constants/configTypes.ts @@ -29,11 +29,11 @@ export type Layer2Config = { }; export type ScriptType = { - code_hash: Hash; - hash_type: HashType; - tx_hash: Hash; + codeHash: Hash; + hashType: HashType; + txHash: Hash; index: Hexadecimal; - dep_type: DepType; + depType: DepType; }; export type Layer1Config = { diff --git a/packages/light-godwoken/src/constants/configUtils.ts b/packages/light-godwoken/src/constants/configUtils.ts index e20c5282..5e2a700a 100644 --- a/packages/light-godwoken/src/constants/configUtils.ts +++ b/packages/light-godwoken/src/constants/configUtils.ts @@ -3,10 +3,10 @@ import { ScriptType } from "./configTypes"; export const getCellDep = (script: ScriptType): CellDep => { return { - out_point: { - tx_hash: script.tx_hash, + outPoint: { + txHash: script.txHash, index: script.index, }, - dep_type: script.dep_type, + depType: script.depType, }; }; diff --git a/packages/light-godwoken/src/constants/lightGodwokenConfig.ts b/packages/light-godwoken/src/constants/lightGodwokenConfig.ts index 824ef02b..af4216b8 100644 --- a/packages/light-godwoken/src/constants/lightGodwokenConfig.ts +++ b/packages/light-godwoken/src/constants/lightGodwokenConfig.ts @@ -3,25 +3,25 @@ import { Layer1Config, LightGodwokenConfig, LightGodwokenConfigMap } from "./con const layer1ConfigAggron: Layer1Config = { SCRIPTS: { omni_lock: { - code_hash: "0x79f90bb5e892d80dd213439eeab551120eb417678824f282b4ffb5f21bad2e1e", - hash_type: "type", - tx_hash: "0x9154df4f7336402114d04495175b37390ce86a4906d2d4001cf02c3e6d97f39c", + codeHash: "0x79f90bb5e892d80dd213439eeab551120eb417678824f282b4ffb5f21bad2e1e", + hashType: "type", + txHash: "0x9154df4f7336402114d04495175b37390ce86a4906d2d4001cf02c3e6d97f39c", index: "0x0", - dep_type: "code", + depType: "code", }, secp256k1_blake160: { - code_hash: "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", - hash_type: "type", - tx_hash: "0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37", + codeHash: "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", + hashType: "type", + txHash: "0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37", index: "0x0", - dep_type: "dep_group", + depType: "depGroup", }, sudt: { - code_hash: "0xc5e5dcf215925f7ef4dfaf5f4b4f105bc321c02776d6e7d52a1db3fcd9d011a4", - hash_type: "type", - tx_hash: "0xe12877ebd2c3c364dc46c5c992bcfaf4fee33fa13eebdf82c591fc9825aab769", + codeHash: "0xc5e5dcf215925f7ef4dfaf5f4b4f105bc321c02776d6e7d52a1db3fcd9d011a4", + hashType: "type", + txHash: "0xe12877ebd2c3c364dc46c5c992bcfaf4fee33fa13eebdf82c591fc9825aab769", index: "0x0", - dep_type: "code", + depType: "code", }, }, CKB_INDEXER_URL: "https://testnet.ckb.dev/indexer", @@ -32,25 +32,25 @@ const layer1ConfigAggron: Layer1Config = { const layer1ConfigLina: Layer1Config = { SCRIPTS: { omni_lock: { - code_hash: "0x9f3aeaf2fc439549cbc870c653374943af96a0658bd6b51be8d8983183e6f52f", - hash_type: "type", - tx_hash: "0xaa8ab7e97ed6a268be5d7e26d63d115fa77230e51ae437fc532988dd0c3ce10a", + codeHash: "0x9f3aeaf2fc439549cbc870c653374943af96a0658bd6b51be8d8983183e6f52f", + hashType: "type", + txHash: "0xaa8ab7e97ed6a268be5d7e26d63d115fa77230e51ae437fc532988dd0c3ce10a", index: "0x1", - dep_type: "code", + depType: "code", }, secp256k1_blake160: { - code_hash: "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", - hash_type: "type", - tx_hash: "0x71a7ba8fc96349fea0ed3a5c47992e3b4084b031a42264a018e0072e8172e46c", + codeHash: "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", + hashType: "type", + txHash: "0x71a7ba8fc96349fea0ed3a5c47992e3b4084b031a42264a018e0072e8172e46c", index: "0x0", - dep_type: "dep_group", + depType: "depGroup", }, sudt: { - code_hash: "0x5e7a36a77e68eecc013dfa2fe6a23f3b6c344b04005808694ae6dd45eea4cfd5", - hash_type: "type", - tx_hash: "0xc7813f6a415144643970c2e88e0bb6ca6a8edc5dd7c1022746f628284a9936d5", + codeHash: "0x5e7a36a77e68eecc013dfa2fe6a23f3b6c344b04005808694ae6dd45eea4cfd5", + hashType: "type", + txHash: "0xc7813f6a415144643970c2e88e0bb6ca6a8edc5dd7c1022746f628284a9936d5", index: "0x0", - dep_type: "code", + depType: "code", }, }, CKB_INDEXER_URL: "https://mainnet.ckb.dev/indexer", @@ -66,21 +66,21 @@ const v0ConfigAggron: LightGodwokenConfig = { deposit_lock: { script_type_hash: "0x5a2506bb68d81a11dcadad4cb7eae62a17c43c619fe47ac8037bc8ce2dd90360", cell_dep: { - out_point: { - tx_hash: "0x97614145cdec9ba924001c11cd49f1c424927437b40ed3ca3b82fff358f2e3de", + outPoint: { + txHash: "0x97614145cdec9ba924001c11cd49f1c424927437b40ed3ca3b82fff358f2e3de", index: "0x0", }, - dep_type: "code", + depType: "code", }, }, withdrawal_lock: { script_type_hash: "0x170ef156e9f6132dbca6069dfd3e436f7d91c29d3ac7332c4b33e633b6a299b5", cell_dep: { - out_point: { - tx_hash: "0xa8c2fe2aaaf405b2b1fd33dd63adc4c514a3d1f6dd1a64244489ad75c51a5d14", + outPoint: { + txHash: "0xa8c2fe2aaaf405b2b1fd33dd63adc4c514a3d1f6dd1a64244489ad75c51a5d14", index: "0x0", }, - dep_type: "code", + depType: "code", }, }, eth_account_lock: { @@ -90,8 +90,8 @@ const v0ConfigAggron: LightGodwokenConfig = { ROLLUP_CONFIG: { rollup_type_hash: "0x4cc2e6526204ae6a2e8fcf12f7ad472f41a1606d5b9624beebd215d780809f6a", rollup_type_script: { - code_hash: "0x5c365147bb6c40e817a2a53e0dec3661f7390cc77f0c02db138303177b12e9fb", - hash_type: "type", + codeHash: "0x5c365147bb6c40e817a2a53e0dec3661f7390cc77f0c02db138303177b12e9fb", + hashType: "type", args: "0x213743d13048e9f36728c547ab736023a7426e15a3d7d1c82f43ec3b5f266df2", }, }, @@ -114,21 +114,21 @@ const v0ConfigLina: LightGodwokenConfig = { deposit_lock: { script_type_hash: "0xe24164e2204f998b088920405dece3dcfd5c1fbcb23aecfce4b3d3edf1488897", cell_dep: { - out_point: { - tx_hash: "0x23fe9d6410c93b49039a9efa3b1549ff18772c03919bc6f2aa91643c4caa01ba", + outPoint: { + txHash: "0x23fe9d6410c93b49039a9efa3b1549ff18772c03919bc6f2aa91643c4caa01ba", index: "0x0", }, - dep_type: "code", + depType: "code", }, }, withdrawal_lock: { script_type_hash: "0xf1717ee388b181fcb14352055c00b7ea7cd7c27350ffd1a2dd231e059dde2fed", cell_dep: { - out_point: { - tx_hash: "0x3d727bd8bb1d87ba79638b63bfbf4c9a4feb9ac5ac5a0b356f3aaf4ccb4d3a1c", + outPoint: { + txHash: "0x3d727bd8bb1d87ba79638b63bfbf4c9a4feb9ac5ac5a0b356f3aaf4ccb4d3a1c", index: "0x0", }, - dep_type: "code", + depType: "code", }, }, eth_account_lock: { @@ -138,8 +138,8 @@ const v0ConfigLina: LightGodwokenConfig = { ROLLUP_CONFIG: { rollup_type_hash: "0x40d73f0d3c561fcaae330eabc030d8d96a9d0af36d0c5114883658a350cb9e3b", rollup_type_script: { - code_hash: "0xa9267ff5a16f38aa9382608eb9022883a78e6a40855107bb59f8406cce00e981", - hash_type: "type", + codeHash: "0xa9267ff5a16f38aa9382608eb9022883a78e6a40855107bb59f8406cce00e981", + hashType: "type", args: "0x2d8d67c8d73453c1a6d6d600e491b303910802e0cc90a709da9b15d26c5c48b3", }, }, @@ -163,21 +163,21 @@ const v1ConfigAggron: LightGodwokenConfig = { deposit_lock: { script_type_hash: "0x50704b84ecb4c4b12b43c7acb260ddd69171c21b4c0ba15f3c469b7d143f6f18", cell_dep: { - out_point: { - tx_hash: "0x9caeec735f3cd2a60b9d12be59bb161f7c61ddab1ac22c4383a94c33ba6404a2", + outPoint: { + txHash: "0x9caeec735f3cd2a60b9d12be59bb161f7c61ddab1ac22c4383a94c33ba6404a2", index: "0x0", }, - dep_type: "code", + depType: "code", }, }, withdrawal_lock: { script_type_hash: "0x06ae0706bb2d7997d66224741d3ec7c173dbb2854a6d2cf97088796b677269c6", cell_dep: { - out_point: { - tx_hash: "0x9c607a9a75ea4699dd01b1c2a478002343998cac8346d2aa582f35b532bd2b93", + outPoint: { + txHash: "0x9c607a9a75ea4699dd01b1c2a478002343998cac8346d2aa582f35b532bd2b93", index: "0x0", }, - dep_type: "code", + depType: "code", }, }, eth_account_lock: { @@ -187,8 +187,8 @@ const v1ConfigAggron: LightGodwokenConfig = { ROLLUP_CONFIG: { rollup_type_hash: "0x702359ea7f073558921eb50d8c1c77e92f760c8f8656bde4995f26b8963e2dd8", rollup_type_script: { - code_hash: "0x1e44736436b406f8e48a30dfbddcf044feb0c9eebfe63b0f81cb5bb727d84854", - hash_type: "type", + codeHash: "0x1e44736436b406f8e48a30dfbddcf044feb0c9eebfe63b0f81cb5bb727d84854", + hashType: "type", args: "0x86c7429247beba7ddd6e4361bcdfc0510b0b644131e2afb7e486375249a01802", }, }, @@ -213,21 +213,21 @@ const v1ConfigLina: LightGodwokenConfig = { deposit_lock: { script_type_hash: "0xff602581f07667eef54232cce850cbca2c418b3418611c132fca849d1edcd775", cell_dep: { - out_point: { - tx_hash: "0x61e576a7e5d2398ecc5b1a969d1af0142c87db0996c2f6fce41bf28f68d805b2", + outPoint: { + txHash: "0x61e576a7e5d2398ecc5b1a969d1af0142c87db0996c2f6fce41bf28f68d805b2", index: "0x0", }, - dep_type: "code", + depType: "code", }, }, withdrawal_lock: { script_type_hash: "0x3714af858b8b82b2bb8f13d51f3cffede2dd8d352a6938334bb79e6b845e3658", cell_dep: { - out_point: { - tx_hash: "0xe6389b5cf63eec1e2592e930414bc43f92508e529bdd5f5a07fa1dd140f4f20a", + outPoint: { + txHash: "0xe6389b5cf63eec1e2592e930414bc43f92508e529bdd5f5a07fa1dd140f4f20a", index: "0x0", }, - dep_type: "code", + depType: "code", }, }, eth_account_lock: { @@ -237,8 +237,8 @@ const v1ConfigLina: LightGodwokenConfig = { ROLLUP_CONFIG: { rollup_type_hash: "0x1ca35cb5fda4bd542e71d94a6d5f4c0d255d6d6fba73c41cf45d2693e59b3072", rollup_type_script: { - code_hash: "0xfef1d086d9f74d143c60bf03bd04bab29200dbf484c801c72774f2056d4c6718", - hash_type: "type", + codeHash: "0xfef1d086d9f74d143c60bf03bd04bab29200dbf484c801c72774f2056d4c6718", + hashType: "type", args: "0xab21bfe2bf85927bb42faaf3006a355222e24d5ea1d4dec0e62f53a8e0c04690", }, }, diff --git a/packages/light-godwoken/src/godwoken/godwokenScannerV1.ts b/packages/light-godwoken/src/godwoken/godwokenScannerV1.ts index a1726738..42348ed3 100644 --- a/packages/light-godwoken/src/godwoken/godwokenScannerV1.ts +++ b/packages/light-godwoken/src/godwoken/godwokenScannerV1.ts @@ -4,8 +4,8 @@ import axios from "axios"; type WithdrawalHistory = { amount: string; capacity: string; - block_hash: Hash; - block_number: number; + blockHash: Hash; + blockNumber: number; l2_script_hash: Hash; layer1_block_number: number; layer1_output_index: number; diff --git a/packages/light-godwoken/src/lightGodwoken.ts b/packages/light-godwoken/src/lightGodwoken.ts index c8ea85c9..c7f8f7b5 100644 --- a/packages/light-godwoken/src/lightGodwoken.ts +++ b/packages/light-godwoken/src/lightGodwoken.ts @@ -1,16 +1,4 @@ -import { - Cell, - Hash, - helpers, - HexNumber, - HexString, - Script, - toolkit, - utils, - BI, - core, - Transaction, -} from "@ckb-lumos/lumos"; +import { Cell, Hash, helpers, HexNumber, HexString, Script, toolkit, utils, BI, Transaction } from "@ckb-lumos/lumos"; import * as secp256k1 from "secp256k1"; import { getCellDep } from "./constants/configUtils"; import LightGodwokenProvider from "./lightGodwokenProvider"; @@ -48,7 +36,7 @@ import { TransactionSignError, WithdrawalTimeoutError, } from "./constants/error"; -import { CellDep, CellWithStatus, DepType, OutPoint, Output, TransactionWithStatus } from "@ckb-lumos/base"; +import { blockchain, CellDep, CellWithStatus, DepType, OutPoint, Output, TransactionWithStatus } from "@ckb-lumos/base"; import EventEmitter from "events"; import isEqual from "lodash.isequal"; import { isSpecialWallet } from "./utils"; @@ -109,7 +97,7 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase } async getCkbCurrentBlockNumber(): Promise { - return BI.from((await this.provider.ckbIndexer.tip()).block_number); + return BI.from((await this.provider.ckbIndexer.tip()).blockNumber); } async getDepositList(): Promise { @@ -123,14 +111,14 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase const amount = cell.data && cell.data !== "0x" ? utils.readBigUInt128LECompatible(cell.data) : BI.from(0); depositList.push({ rawCell: cell, - blockNumber: BI.from(cell.block_number), - capacity: BI.from(cell.cell_output.capacity), + blockNumber: BI.from(cell.blockNumber), + capacity: BI.from(cell.cellOutput.capacity), cancelTime: BI.from(this.getCancelTimeout()) .mul(1000) // milliseconds per second - .sub(BI.from(currentCkbBlockNumber).sub(BI.from(cell.block_number)).mul(this.getCkbBlockProduceTime())), + .sub(BI.from(currentCkbBlockNumber).sub(BI.from(cell.blockNumber)).mul(this.getCkbBlockProduceTime())), amount, - sudt: cell.cell_output.type - ? this.getBuiltinSUDTMapByTypeHash()[utils.computeScriptHash(cell.cell_output.type)] + sudt: cell.cellOutput.type + ? this.getBuiltinSUDTMapByTypeHash()[utils.computeScriptHash(cell.cellOutput.type)] : undefined, }); } @@ -149,7 +137,7 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase async cancelDeposit(depositTxHash: string, cancelTimeout: number): Promise { const depositLock = this.generateDepositLock(cancelTimeout); - const tx = await this.provider.ckbRpc.get_transaction(depositTxHash); + const tx = await this.provider.ckbRpc.getTransaction(depositTxHash); if (!tx) { throw new DepositTxNotFoundError(depositTxHash, "Deposit transaction not found"); } @@ -159,14 +147,14 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase const output = txOutputs[index]; if (utils.computeScriptHash(output.lock) === utils.computeScriptHash(depositLock)) { depositCell = { - cell_output: { + cellOutput: { capacity: output.capacity, lock: output.lock, type: output.type, }, - data: tx.transaction.outputs_data[index], - out_point: { - tx_hash: depositTxHash, + data: tx.transaction.outputsData[index], + outPoint: { + txHash: depositTxHash, index: BI.from(index).toHexString(), }, }; @@ -190,7 +178,7 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase let txSkeleton = helpers.TransactionSkeleton({ cellProvider: this.provider.ckbIndexer }); const outputCells: Cell[] = []; const inputCells: Cell[] = [cell]; - const inputCapacity = BI.from(cell.cell_output.capacity); + const inputCapacity = BI.from(cell.cellOutput.capacity); const ownerLock = this.provider.getLayer1Lock(); // collect one owner cell @@ -201,22 +189,22 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase }); let ownerCellCapacity = BI.from(0); for await (const cell of ownerCellCollector.collect()) { - ownerCellCapacity = ownerCellCapacity.add(cell.cell_output.capacity); + ownerCellCapacity = ownerCellCapacity.add(cell.cellOutput.capacity); inputCells.unshift(cell); break; } - if (!!cell.cell_output.type) { + if (!!cell.cellOutput.type) { outputCells.push({ - cell_output: { + cellOutput: { capacity: BI.from(14400000000).toHexString(), lock: ownerLock, - type: cell.cell_output.type, + type: cell.cellOutput.type, }, data: cell.data, }); outputCells.push({ - cell_output: { + cellOutput: { capacity: inputCapacity.sub(14400000000).add(ownerCellCapacity).toHexString(), lock: ownerLock, }, @@ -224,7 +212,7 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase }); } else { outputCells.push({ - cell_output: { + cellOutput: { capacity: inputCapacity.add(ownerCellCapacity).toHexString(), lock: ownerLock, }, @@ -233,11 +221,11 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase } const { layer2Config, layer1Config } = this.provider.getLightGodwokenConfig(); const depositLockDep: CellDep = { - out_point: { - tx_hash: layer2Config.SCRIPTS.deposit_lock.cell_dep.out_point.tx_hash, - index: layer2Config.SCRIPTS.deposit_lock.cell_dep.out_point.index, + outPoint: { + txHash: layer2Config.SCRIPTS.deposit_lock.cell_dep.outPoint.txHash, + index: layer2Config.SCRIPTS.deposit_lock.cell_dep.outPoint.index, }, - dep_type: layer2Config.SCRIPTS.deposit_lock.cell_dep.dep_type as DepType, + depType: layer2Config.SCRIPTS.deposit_lock.cell_dep.depType as DepType, }; const rollupCellDep: CellDep = await this.getRollupCellDep(); @@ -248,22 +236,22 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase .update("outputs", (outputs) => { return outputs.push(...outputCells); }) - .update("cellDeps", (cell_deps) => { - return cell_deps.push(getCellDep(layer1Config.SCRIPTS.omni_lock)); + .update("cellDeps", (cellDeps) => { + return cellDeps.push(getCellDep(layer1Config.SCRIPTS.omni_lock)); }) - .update("cellDeps", (cell_deps) => { - return cell_deps.push(depositLockDep); + .update("cellDeps", (cellDeps) => { + return cellDeps.push(depositLockDep); }) - .update("cellDeps", (cell_deps) => { - return cell_deps.push(rollupCellDep); + .update("cellDeps", (cellDeps) => { + return cellDeps.push(rollupCellDep); }) - .update("cellDeps", (cell_deps) => { - return cell_deps.push(getCellDep(layer1Config.SCRIPTS.secp256k1_blake160)); + .update("cellDeps", (cellDeps) => { + return cellDeps.push(getCellDep(layer1Config.SCRIPTS.secp256k1_blake160)); }); - if (!!cell.cell_output.type) { - txSkeleton = txSkeleton.update("cellDeps", (cell_deps) => { - return cell_deps.push(getCellDep(layer1Config.SCRIPTS.sudt)); + if (!!cell.cellOutput.type) { + txSkeleton = txSkeleton.update("cellDeps", (cellDeps) => { + return cellDeps.push(getCellDep(layer1Config.SCRIPTS.sudt)); }); } return txSkeleton; @@ -281,11 +269,11 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase return output.type && utils.computeScriptHash(output.type) === layer2Config.ROLLUP_CONFIG.rollup_type_hash; }); return { - out_point: { - tx_hash: txHash, + outPoint: { + txHash: txHash, index: `0x${rollupIndex.toString(16)}`, }, - dep_type: "code", + depType: "code", }; } @@ -293,7 +281,7 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase let tx: TransactionWithStatus | null = null; // retry 10 times, and sleep 1s for (let i = 0; i < 10; i++) { - tx = await this.provider.ckbRpc.get_transaction(txHash); + tx = (await this.provider.ckbRpc.getTransaction(txHash)) as TransactionWithStatus | null; if (tx != null) { return tx; } @@ -329,7 +317,7 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase outputDataLenRange: ["0x0", "0x1"], }); for await (const cell of ckbCollector.collect()) { - collectedCapatity = collectedCapatity.add(BI.from(cell.cell_output.capacity)); + collectedCapatity = collectedCapatity.add(BI.from(cell.cellOutput.capacity)); collectedCells.push(cell); if (collectedCapatity.gte(neededCapacity)) break; } @@ -344,7 +332,7 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase type: payload.sudtType, }); for await (const cell of sudtCollector.collect()) { - collectedCapatity = collectedCapatity.add(BI.from(cell.cell_output.capacity)); + collectedCapatity = collectedCapatity.add(BI.from(cell.cellOutput.capacity)); collectedSudtAmount = collectedSudtAmount.add(utils.readBigUInt128LECompatible(cell.data)); collectedCells.push(cell); if (collectedSudtAmount.gte(neededSudtAmount)) break; @@ -356,17 +344,17 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase const freeCkbCollector = this.provider.ckbIndexer.collector({ lock: helpers.parseAddress(this.provider.l1Address), type: { - code_hash: this.getConfig().layer1Config.SCRIPTS.sudt.code_hash, - hash_type: this.getConfig().layer1Config.SCRIPTS.sudt.hash_type, + codeHash: this.getConfig().layer1Config.SCRIPTS.sudt.codeHash, + hashType: this.getConfig().layer1Config.SCRIPTS.sudt.hashType, args: "0x", }, }); for await (const cell of freeCkbCollector.collect()) { - const haveFreeCapacity = BI.from(SUDT_CELL_CAPACITY).lt(cell.cell_output.capacity); + const haveFreeCapacity = BI.from(SUDT_CELL_CAPACITY).lt(cell.cellOutput.capacity); const alreadyCollected = collectedCells.some((collectedCell) => { if ( - isEqual(collectedCell.out_point?.tx_hash, cell.out_point?.tx_hash) && - isEqual(collectedCell.out_point?.index, cell.out_point?.index) + isEqual(collectedCell.outPoint?.txHash, cell.outPoint?.txHash) && + isEqual(collectedCell.outPoint?.index, cell.outPoint?.index) ) { return true; } @@ -375,7 +363,7 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase // envolve SUDT cells that has more capacity than SUDT_CELL_CAPACITY if (haveFreeCapacity && !alreadyCollected) { freeCapacityProviderCells.push(cell); - collectedCapatity = collectedCapatity.add(cell.cell_output.capacity).sub(SUDT_CELL_CAPACITY); + collectedCapatity = collectedCapatity.add(cell.cellOutput.capacity).sub(SUDT_CELL_CAPACITY); } if (collectedCapatity.gte(neededCapacity)) { break; @@ -410,16 +398,16 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase .update("outputs", (outputs) => { return outputs.push(...outputCell); }) - .update("cellDeps", (cell_deps) => { - return cell_deps.push(getCellDep(layer1Config.SCRIPTS.omni_lock)); + .update("cellDeps", (cellDeps) => { + return cellDeps.push(getCellDep(layer1Config.SCRIPTS.omni_lock)); }) - .update("cellDeps", (cell_deps) => { - return cell_deps.push(getCellDep(layer1Config.SCRIPTS.secp256k1_blake160)); + .update("cellDeps", (cellDeps) => { + return cellDeps.push(getCellDep(layer1Config.SCRIPTS.secp256k1_blake160)); }); if (payload.sudtType || freeCapacityProviderCells.length > 0) { - txSkeleton = txSkeleton.update("cellDeps", (cell_deps) => { - return cell_deps.push(getCellDep(layer1Config.SCRIPTS.sudt)); + txSkeleton = txSkeleton.update("cellDeps", (cellDeps) => { + return cellDeps.push(getCellDep(layer1Config.SCRIPTS.sudt)); }); } return txSkeleton; @@ -430,7 +418,7 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase const txFee = await this.calculateTxFee(signedTx); txSkeleton = txSkeleton.update("outputs", (outputs) => { const exchagneOutput: Cell = outputs.get(outputs.size - 1)!; - exchagneOutput.cell_output.capacity = BI.from(exchagneOutput.cell_output.capacity).sub(txFee).toHexString(); + exchagneOutput.cellOutput.capacity = BI.from(exchagneOutput.cellOutput.capacity).sub(txFee).toHexString(); return outputs; }); return txSkeleton; @@ -496,13 +484,15 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase // 1. wait for deposit tx to be commited if (!depositTx) { - const txOnChain = await this.provider.ckbRpc.get_transaction(txHash as unknown as Hash); - if (txOnChain && txOnChain.tx_status.status === "committed") { + const txOnChain = (await this.provider.ckbRpc.getTransaction( + txHash as unknown as Hash, + )) as TransactionWithStatus | null; + if (txOnChain && txOnChain.txStatus.status === "committed") { depositTx = txOnChain; loop = 0; debug("depositTx", depositTx); } - if (txOnChain && txOnChain.tx_status.status === "rejected") { + if (txOnChain && txOnChain.txStatus.status === "rejected") { clearInterval(nIntervId); eventEmitter.emit("fail", new DepositRejectedError(txHash, "Deposit rejected")); } @@ -515,12 +505,12 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase const output = txOutputs[index]; const depositLock = this.generateDepositLock(); if ( - depositLock.code_hash === output.lock.code_hash && - depositLock.hash_type === output.lock.hash_type && + depositLock.codeHash === output.lock.codeHash && + depositLock.hashType === output.lock.hashType && depositLock.args === output.lock.args ) { depositCellOutPoint = { - tx_hash: txHash, + txHash: txHash, index: BI.from(index).toHexString(), }; loop = 0; @@ -532,7 +522,7 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase // 3. wait for deposit cell to be consumed if (depositCellOutPoint) { - depositCell = await this.provider.ckbRpc.get_live_cell(depositCellOutPoint, false); + depositCell = (await this.provider.ckbRpc.getLiveCell(depositCellOutPoint, false)) as CellWithStatus | null; debug("depositCell", depositCell); } @@ -541,16 +531,20 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase const depositLock = await this.generateDepositLock(); const ownerLock = this.provider.getLayer1Lock(); const transactions = await this.provider.ckbIndexer.getTransactions({ - script: depositLock, + script: { + code_hash: depositLock.codeHash, + hash_type: depositLock.hashType, + args: depositLock.args, + }, script_type: "lock", }); const txHashList = transactions.objects - .map((object) => object.tx_hash) + .map((object) => object.txHash) .slice(-10) .reverse(); debug("txHashList", txHashList); const promises = txHashList.map(async (txHash) => { - return this.provider.ckbRpc.get_transaction(txHash as unknown as Hash); + return this.provider.ckbRpc.getTransaction(txHash as unknown as Hash); }); const txList = await Promise.all(promises); for (let index = 0; index < txList.length; index++) { @@ -558,16 +552,16 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase // eslint-disable-next-line no-loop-func const txConsumedDepositCell = tx?.transaction.inputs.some((input) => { return ( - input.previous_output.tx_hash === depositCellOutPoint!.tx_hash && - input.previous_output.index === depositCellOutPoint!.index + input.previousOutput!.txHash === depositCellOutPoint!.txHash && + input.previousOutput!.index === depositCellOutPoint!.index ); }); if (txConsumedDepositCell) { // eslint-disable-next-line no-loop-func const outputContainsOwnerLock = tx?.transaction.outputs.some((output) => { return ( - output.lock.code_hash === ownerLock.code_hash && - output.lock.hash_type === ownerLock.hash_type && + output.lock.codeHash === ownerLock.codeHash && + output.lock.hashType === ownerLock.hashType && output.lock.args === ownerLock.args ); }); @@ -592,7 +586,7 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase const eventEmitter = new EventEmitter(); for (let index = 0; index < payload.length; index++) { const element = payload[index]; - this.waitForDepositToComplete(element.tx_hash, eventEmitter); + this.waitForDepositToComplete(element.txHash, eventEmitter); } return eventEmitter; } @@ -648,7 +642,7 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase } getTransactionSizeByTx(tx: Transaction): number { - const serializedTx = core.SerializeTransaction(toolkit.normalizers.NormalizeTransaction(tx)); + const serializedTx = blockchain.Transaction.pack(tx); // 4 is serialized offset bytesize const size = serializedTx.byteLength + 4; return size; @@ -667,30 +661,30 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase payload: DepositPayload, ): Cell[] { const depositLock = this.generateDepositLock(); - let sumCapacity = collectedCells.reduce((acc, cell) => acc.add(cell.cell_output.capacity), BI.from(0)); + let sumCapacity = collectedCells.reduce((acc, cell) => acc.add(cell.cellOutput.capacity), BI.from(0)); // start freeCapacityProviderCells: extract free capacity and return SUDT cell from freeCapacityProviderCells const freeCapacity = freeCapacityProviderCells.reduce( - (acc, cell) => acc.add(cell.cell_output.capacity).sub(SUDT_CELL_CAPACITY), + (acc, cell) => acc.add(cell.cellOutput.capacity).sub(SUDT_CELL_CAPACITY), BI.from(0), ); sumCapacity = sumCapacity.add(freeCapacity); const returnFreeCapacityCells = freeCapacityProviderCells.map((cell) => ({ ...cell, - // we don't need block number and out_point in tx output cells - block_number: undefined, - out_point: undefined, - cell_output: { ...cell.cell_output, capacity: BI.from(SUDT_CELL_CAPACITY).toHexString() }, + // we don't need block number and outPoint in tx output cells + blockNumber: undefined, + outPoint: undefined, + cellOutput: { ...cell.cellOutput, capacity: BI.from(SUDT_CELL_CAPACITY).toHexString() }, })); // end freeCapacityProviderCells const sumSudtAmount = collectedCells.reduce((acc, cell) => { - if (cell.cell_output.type) { + if (cell.cellOutput.type) { return acc.add(utils.readBigUInt128LE(cell.data)); } else { return acc; } }, BI.from(0)); const depositCell: Cell = { - cell_output: { + cellOutput: { capacity: BI.from(payload.capacity).toHexString(), lock: depositLock, }, @@ -699,7 +693,7 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase const exchangeCapacity = sumCapacity.sub(payload.capacity); const exchangeCell: Cell = { - cell_output: { + cellOutput: { capacity: "0x" + exchangeCapacity.toString(16), lock: helpers.parseAddress(this.provider.l1Address), }, @@ -707,14 +701,14 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase }; if (payload.sudtType && payload.amount && payload.amount !== "0x" && payload.amount !== "0x0") { - depositCell.cell_output.type = payload.sudtType; + depositCell.cellOutput.type = payload.sudtType; depositCell.data = utils.toBigUInt128LE(payload.amount); let outputCells = [...returnFreeCapacityCells, depositCell]; // contruct sudt exchange cell const sudtAmount = utils.toBigUInt128LE(sumSudtAmount.sub(payload.amount)); const exchangeSudtCell: Cell = { - cell_output: { + cellOutput: { capacity: "0x0", lock: helpers.parseAddress(this.provider.l1Address), type: payload.sudtType, @@ -722,24 +716,24 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase data: sudtAmount, }; const sudtCapacity = helpers.minimalCellCapacity(exchangeSudtCell); - exchangeSudtCell.cell_output.capacity = "0x" + sudtCapacity.toString(16); + exchangeSudtCell.cellOutput.capacity = "0x" + sudtCapacity.toString(16); // exchange sudt if any left after deposit if (BI.from(sudtAmount).gt(BI.from(0))) { outputCells = [exchangeSudtCell].concat(...outputCells); - exchangeCell.cell_output.capacity = exchangeCapacity.sub(sudtCapacity).toHexString(); + exchangeCell.cellOutput.capacity = exchangeCapacity.sub(sudtCapacity).toHexString(); } else { - exchangeCell.cell_output.capacity = `0x${exchangeCapacity.toString(16)}`; + exchangeCell.cellOutput.capacity = `0x${exchangeCapacity.toString(16)}`; } - if (BI.from(exchangeCell.cell_output.capacity).gte(BI.from(6300000000))) { + if (BI.from(exchangeCell.cellOutput.capacity).gte(BI.from(6300000000))) { outputCells = outputCells.concat(exchangeCell); } return outputCells; } else { let outputCells = [...returnFreeCapacityCells, depositCell]; - if (BI.from(exchangeCell.cell_output.capacity).gte(BI.from(6300000000))) { + if (BI.from(exchangeCell.cellOutput.capacity).gte(BI.from(6300000000))) { outputCells = outputCells.concat(exchangeCell); } return outputCells; @@ -788,7 +782,7 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase generateWithdrawalMessageToSign(serializedRawWithdrawalRequest: HexString, rollupTypeHash: Hash): Hash { const data = new toolkit.Reader(rollupTypeHash + serializedRawWithdrawalRequest.slice(2)).toArrayBuffer(); - const message = utils.ckbHash(data).serializeJson(); + const message = utils.ckbHash(data); return message; } @@ -814,22 +808,22 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase // debug("serialized", serialized, serialized.length); const args = dummyRollupTypeHash + "00".repeat(dummyWithdrawalLockArgsByteLength); const lock: Script = { - code_hash: dummyHash, - hash_type: "data", + codeHash: dummyHash, + hashType: "data", args, }; let type: Script | undefined = undefined; let data = "0x"; if (isSudt) { type = { - code_hash: dummyHash, - hash_type: "data", + codeHash: dummyHash, + hashType: "data", args: dummyHash, }; data = "0x" + "00".repeat(16); } const cell: Cell = { - cell_output: { + cellOutput: { lock, type, capacity: dummyHexNumber, @@ -864,7 +858,7 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase const typeScriptHashList = payload.types.map((typeScript) => utils.computeScriptHash(typeScript)); for await (const cell of collector.collect()) { - const currentCellTypeHash = utils.computeScriptHash(cell.cell_output.type!); + const currentCellTypeHash = utils.computeScriptHash(cell.cellOutput.type!); const currentSudtIndex = typeScriptHashList.indexOf(currentCellTypeHash); if (currentSudtIndex !== -1) { let currentSudtSum = result.balances[currentSudtIndex]; @@ -899,7 +893,7 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase outputDataLenRange: ["0x0", "0x1"], }); for await (const cell of collector.collect()) { - collectedSum = collectedSum.add(cell.cell_output.capacity); + collectedSum = collectedSum.add(cell.cellOutput.capacity); collectedCells.push(cell); if (collectedSum.gte(neededCapacity)) break; } @@ -909,7 +903,7 @@ export default abstract class DefaultLightGodwoken implements LightGodwokenBase throw error; } const changeOutput: Cell = { - cell_output: { + cellOutput: { capacity: collectedSum.toHexString(), lock: fromScript, }, diff --git a/packages/light-godwoken/src/lightGodwokenProvider.ts b/packages/light-godwoken/src/lightGodwokenProvider.ts index 4d9b9e0e..f41d0e16 100644 --- a/packages/light-godwoken/src/lightGodwokenProvider.ts +++ b/packages/light-godwoken/src/lightGodwokenProvider.ts @@ -6,7 +6,6 @@ import { Transaction, HexString, utils, - core, toolkit, Hash, Cell, @@ -27,6 +26,8 @@ import { EnvNotFoundError, EthereumNotFoundError, LightGodwokenConfigNotValidErr import { OmniLockWitnessLockCodec } from "./schemas/codecLayer1"; import { isSpecialWallet } from "./utils"; import { initConfig } from "./constants/configManager"; +import { bytes } from "@ckb-lumos/codec"; +import { blockchain } from "@ckb-lumos/base"; export default class DefaultLightGodwokenProvider implements LightGodwokenProvider { l2Address: Address = ""; @@ -77,8 +78,8 @@ export default class DefaultLightGodwokenProvider implements LightGodwokenProvid } async getMinFeeRate(): Promise { - const feeRate = await this.ckbRpc.tx_pool_info(); - return BI.from(feeRate.min_fee_rate); + const feeRate = await this.ckbRpc.txPoolInfo(); + return BI.from(feeRate.minFeeRate); } getL2Address(): string { @@ -97,18 +98,18 @@ export default class DefaultLightGodwokenProvider implements LightGodwokenProvid outputDataLenRange: ["0x0", "0x1"], }); for await (const cell of pureCkbCollector.collect()) { - ckbBalance = ckbBalance.add(cell.cell_output.capacity); + ckbBalance = ckbBalance.add(cell.cellOutput.capacity); } const freeCkbCollector = this.ckbIndexer.collector({ lock: helpers.parseAddress(queryAddress), type: { - code_hash: this.getConfig().layer1Config.SCRIPTS.sudt.code_hash, - hash_type: this.getConfig().layer1Config.SCRIPTS.sudt.hash_type, + codeHash: this.getConfig().layer1Config.SCRIPTS.sudt.codeHash, + hashType: this.getConfig().layer1Config.SCRIPTS.sudt.hashType, args: "0x", }, }); for await (const cell of freeCkbCollector.collect()) { - ckbBalance = ckbBalance.add(cell.cell_output.capacity).sub(SUDT_CELL_CAPACITY); + ckbBalance = ckbBalance.add(cell.cellOutput.capacity).sub(SUDT_CELL_CAPACITY); } return ckbBalance; } @@ -139,8 +140,8 @@ export default class DefaultLightGodwokenProvider implements LightGodwokenProvid generateL1Address(l2Address: Address): Address { const omniLock: Script = { - code_hash: this.lightGodwokenConfig.layer1Config.SCRIPTS.omni_lock.code_hash, - hash_type: this.lightGodwokenConfig.layer1Config.SCRIPTS.omni_lock.hash_type as HashType, + codeHash: this.lightGodwokenConfig.layer1Config.SCRIPTS.omni_lock.codeHash, + hashType: this.lightGodwokenConfig.layer1Config.SCRIPTS.omni_lock.hashType as HashType, // omni flag pubkey hash omni lock flags // chain identity eth addr function flag() // 00: Nervos 👇 00: owner @@ -153,7 +154,7 @@ export default class DefaultLightGodwokenProvider implements LightGodwokenProvid // // now only supported omni lock, the other lock type will be supported later async sendL1Transaction(tx: Transaction): Promise { - return await this.ckbRpc.send_transaction(tx, "passthrough"); + return await this.ckbRpc.sendTransaction(tx, "passthrough"); } async signMessage(message: string, dummySign = false): Promise { @@ -170,11 +171,11 @@ export default class DefaultLightGodwokenProvider implements LightGodwokenProvid if (v >= 27) v -= 27; signedMessage = "0x" + signedMessage.slice(2, -2) + v.toString(16).padStart(2, "0"); debug("message after sign", signedMessage); - const signedWitness = new toolkit.Reader( - core.SerializeWitnessArgs({ + const signedWitness = bytes.hexify( + blockchain.WitnessArgs.pack({ lock: OmniLockWitnessLockCodec.pack({ signature: signedMessage }).buffer, }), - ).serializeJson(); + ); debug("signedWitness", signedWitness); return signedWitness; } @@ -201,12 +202,8 @@ export default class DefaultLightGodwokenProvider implements LightGodwokenProvid generateMessageByTransaction(transaction: Transaction): HexString { const hasher = new utils.CKBHasher(); - const rawTxHash = utils.ckbHash( - core.SerializeRawTransaction(toolkit.normalizers.NormalizeRawTransaction(transaction)), - ); - const serializedWitness = core.SerializeWitnessArgs({ - lock: new toolkit.Reader("0x" + "00".repeat(85)), - }); + const rawTxHash = utils.ckbHash(blockchain.RawTransaction.pack(transaction)); + const serializedWitness = blockchain.WitnessArgs.pack({ lock: new Uint8Array(85) }); hasher.update(rawTxHash); this.hashWitness(hasher, serializedWitness); return hasher.digestHex(); @@ -224,8 +221,8 @@ export default class DefaultLightGodwokenProvider implements LightGodwokenProvid const rollupConfig = this.lightGodwokenConfig.layer2Config.ROLLUP_CONFIG; const queryOptions = { type: { - code_hash: rollupConfig.rollup_type_script.code_hash, - hash_type: rollupConfig.rollup_type_script.hash_type, + codeHash: rollupConfig.rollup_type_script.codeHash, + hashType: rollupConfig.rollup_type_script.hashType, args: rollupConfig.rollup_type_script.args, }, }; @@ -244,8 +241,8 @@ export default class DefaultLightGodwokenProvider implements LightGodwokenProvid getLayer2LockScript(): Script { const layer2Lock: Script = { - code_hash: this.lightGodwokenConfig.layer2Config.SCRIPTS.eth_account_lock.script_type_hash as string, - hash_type: "type", + codeHash: this.lightGodwokenConfig.layer2Config.SCRIPTS.eth_account_lock.script_type_hash as string, + hashType: "type", args: this.lightGodwokenConfig.layer2Config.ROLLUP_CONFIG.rollup_type_hash + this.l2Address.slice(2).toLowerCase(), }; @@ -265,9 +262,9 @@ export default class DefaultLightGodwokenProvider implements LightGodwokenProvid getLayer1LockScriptHash(): Hash { const ownerCKBLock = helpers.parseAddress(this.l1Address); const ownerLock: Script = { - code_hash: ownerCKBLock.code_hash, + codeHash: ownerCKBLock.codeHash, args: ownerCKBLock.args, - hash_type: ownerCKBLock.hash_type as HashType, + hashType: ownerCKBLock.hashType as HashType, }; const ownerLockHash = utils.computeScriptHash(ownerLock); debug("ownerLockHash", ownerLockHash); diff --git a/packages/light-godwoken/src/lightGodwokenType.ts b/packages/light-godwoken/src/lightGodwokenType.ts index 34297d97..c59f77ce 100644 --- a/packages/light-godwoken/src/lightGodwokenType.ts +++ b/packages/light-godwoken/src/lightGodwokenType.ts @@ -134,7 +134,7 @@ export interface DepositPayload { } export interface PendingDepositTransaction { - tx_hash: Hash; + txHash: Hash; } type Promisable = Promise | T; diff --git a/packages/light-godwoken/src/schemas/codecLayer1.ts b/packages/light-godwoken/src/schemas/codecLayer1.ts index c8e36bf8..44eeb01b 100644 --- a/packages/light-godwoken/src/schemas/codecLayer1.ts +++ b/packages/light-godwoken/src/schemas/codecLayer1.ts @@ -1,4 +1,5 @@ -import { molecule, number, blockchain } from "@ckb-lumos/codec/"; +import { blockchain } from "@ckb-lumos/base/"; +import { molecule, number } from "@ckb-lumos/codec/"; import { HexString } from "@ckb-lumos/lumos"; const { table, option, vector, array } = molecule; diff --git a/packages/light-godwoken/src/schemas/codecV0.ts b/packages/light-godwoken/src/schemas/codecV0.ts index 6f8eec7f..5981f7b1 100644 --- a/packages/light-godwoken/src/schemas/codecV0.ts +++ b/packages/light-godwoken/src/schemas/codecV0.ts @@ -1,4 +1,5 @@ -import { molecule, number, blockchain } from "@ckb-lumos/codec/"; +import { blockchain } from "@ckb-lumos/base/"; +import { molecule, number } from "@ckb-lumos/codec/"; import { BI, HexString } from "@ckb-lumos/lumos"; import { hashTypeCodec } from "./baseCodec"; @@ -65,11 +66,11 @@ export const WithdrawalRequestExtraCodec = table( owner_lock: option( table( { - code_hash: Byte32, - hash_type: hashTypeCodec, + codeHash: Byte32, + hashType: hashTypeCodec, args: Bytes, }, - ["code_hash", "hash_type", "args"], + ["codeHash", "hashType", "args"], ), ), withdraw_to_v1: Uint8, @@ -82,11 +83,11 @@ export const V0DepositLockArgs = table( owner_lock_hash: Byte32, layer2_lock: table( { - code_hash: Byte32, - hash_type: hashTypeCodec, + codeHash: Byte32, + hashType: hashTypeCodec, args: Bytes, }, - ["code_hash", "hash_type", "args"], + ["codeHash", "hashType", "args"], ), cancel_timeout: Uint64, }, diff --git a/packages/light-godwoken/src/schemas/codecV1.ts b/packages/light-godwoken/src/schemas/codecV1.ts index e0df757f..bcc8682e 100644 --- a/packages/light-godwoken/src/schemas/codecV1.ts +++ b/packages/light-godwoken/src/schemas/codecV1.ts @@ -1,5 +1,6 @@ import { BI, HexString } from "@ckb-lumos/lumos"; -import { molecule, number, blockchain, createObjectCodec, enhancePack } from "@ckb-lumos/codec/"; +import { blockchain } from "@ckb-lumos/base/"; +import { molecule, number, createObjectCodec, enhancePack } from "@ckb-lumos/codec/"; import { hashTypeCodec } from "./baseCodec"; const { table, struct } = molecule; @@ -72,11 +73,11 @@ export const WithdrawalRequestExtraCodec = table( ), owner_lock: table( { - code_hash: Byte32, - hash_type: hashTypeCodec, + codeHash: Byte32, + hashType: hashTypeCodec, args: Bytes, }, - ["code_hash", "hash_type", "args"], + ["codeHash", "hashType", "args"], ), }, ["request", "owner_lock"], @@ -94,11 +95,11 @@ export const V1DepositLockArgs = table( owner_lock_hash: Byte32, layer2_lock: table( { - code_hash: Byte32, - hash_type: hashTypeCodec, + codeHash: Byte32, + hashType: hashTypeCodec, args: Bytes, }, - ["code_hash", "hash_type", "args"], + ["codeHash", "hashType", "args"], ), cancel_timeout: Uint64, registry_id: Uint32, diff --git a/packages/light-godwoken/src/sudtFaucet.ts b/packages/light-godwoken/src/sudtFaucet.ts index bcbdadbe..fb95312c 100644 --- a/packages/light-godwoken/src/sudtFaucet.ts +++ b/packages/light-godwoken/src/sudtFaucet.ts @@ -1,11 +1,13 @@ import { isSpecialWallet } from "./utils"; import { OmniLockWitnessLockCodec } from "./schemas/codecLayer1"; import { ecdsaSign } from "secp256k1"; -import { Cell, CellDep, core, hd, HexString, toolkit } from "@ckb-lumos/lumos"; +import { Cell, CellDep, hd, HexString, toolkit } from "@ckb-lumos/lumos"; import { helpers, RPC, utils, Script, HashType, BI } from "@ckb-lumos/lumos"; import { debug } from "./debug"; import { LightGodwokenConfig } from "./constants/configTypes"; import { NotEnoughCapacityError } from "./constants/error"; +import { blockchain } from "@ckb-lumos/base"; +import { bytes } from "@ckb-lumos/codec"; const issuerPrivateKey = process.env.REACT_APP_L1_TEST_TOKEN_ISSUER_PRIVATE_KEY!; @@ -22,7 +24,7 @@ export async function claimUSDC( txSkeleton = txSkeleton.update("witnesses", (witnesses) => witnesses.push(userSignature, issuerSignature)); const signedTx = helpers.createTransactionFromSkeleton(txSkeleton); - const txHash = await rpc.send_transaction(signedTx, "passthrough"); + const txHash = await rpc.sendTransaction(signedTx, "passthrough"); debug("claim sudt txHash is:", txHash); return txHash; } @@ -38,19 +40,19 @@ export async function generateClaimUSDCTxSkeleton( const issuerPubKey = hd.key.privateToPublic(issuerPrivKey || issuerPrivateKey); const issuerArgs = hd.key.publicKeyToBlake160(issuerPubKey); const issuerLock: Script = { - code_hash: secp256k1.code_hash, - hash_type: secp256k1.hash_type, + codeHash: secp256k1.codeHash, + hashType: secp256k1.hashType, args: issuerArgs, }; const sudtType: Script = { - code_hash: sudt.code_hash, - hash_type: sudt.hash_type, + codeHash: sudt.codeHash, + hashType: sudt.hashType, args: utils.computeScriptHash(issuerLock), }; const userOmniLock: Script = { - code_hash: omniLock.code_hash, - hash_type: "type" as HashType, + codeHash: omniLock.codeHash, + hashType: "type" as HashType, args: `0x01${ethAddress.substring(2)}00`, }; @@ -68,7 +70,7 @@ export async function generateClaimUSDCTxSkeleton( let collectedSum = BI.from(0); const collectedCells: Cell[] = []; for await (const cell of userCellCollector.collect()) { - collectedSum = collectedSum.add(cell.cell_output.capacity); + collectedSum = collectedSum.add(cell.cellOutput.capacity); collectedCells.push(cell); if (collectedSum.gte(needCkb)) { break; @@ -90,7 +92,7 @@ export async function generateClaimUSDCTxSkeleton( }); let issuerCellCapacity = BI.from(0); for await (const cell of issuerCellCollector.collect()) { - issuerCellCapacity = issuerCellCapacity.add(cell.cell_output.capacity); + issuerCellCapacity = issuerCellCapacity.add(cell.cellOutput.capacity); collectedCells.push(cell); break; } @@ -99,7 +101,7 @@ export async function generateClaimUSDCTxSkeleton( return inputs.push(...collectedCells); }); const sudtCell: Cell = { - cell_output: { + cellOutput: { capacity: sudtCellCapacity.toHexString(), lock: userOmniLock, type: sudtType, @@ -107,14 +109,14 @@ export async function generateClaimUSDCTxSkeleton( data: utils.toBigUInt128LE(BI.from(1000).mul(BI.from(10).pow(18))), // 1000 sudt in uint128 }; const exchangeCell: Cell = { - cell_output: { + cellOutput: { capacity: collectedSum.sub(sudtCellCapacity).sub(txFee).toHexString(), lock: userOmniLock, }, data: "0x", }; const issuerExchangeCell: Cell = { - cell_output: { + cellOutput: { capacity: issuerCellCapacity.toHexString(), lock: issuerLock, }, @@ -136,25 +138,25 @@ function getClaimSUDTCellDeps(config: LightGodwokenConfig): CellDep[] { return [ { - out_point: { - tx_hash: omniLock.tx_hash, + outPoint: { + txHash: omniLock.txHash, index: omniLock.index, }, - dep_type: "code", + depType: "code", }, { - out_point: { - tx_hash: secp256k1.tx_hash, + outPoint: { + txHash: secp256k1.txHash, index: secp256k1.index, }, - dep_type: secp256k1.dep_type, + depType: secp256k1.depType, }, { - out_point: { - tx_hash: sudt.tx_hash, + outPoint: { + txHash: sudt.txHash, index: sudt.index, }, - dep_type: sudt.dep_type, + depType: sudt.depType, }, ]; } @@ -171,11 +173,11 @@ export async function userSignTransaction( let v = Number.parseInt(signedMessage.slice(-2), 16); if (v >= 27) v -= 27; signedMessage = "0x" + signedMessage.slice(2, -2) + v.toString(16).padStart(2, "0"); - const signedWitness = new toolkit.Reader( - core.SerializeWitnessArgs({ - lock: OmniLockWitnessLockCodec.pack({ signature: signedMessage }).buffer, + const signedWitness = bytes.hexify( + blockchain.WitnessArgs.pack({ + lock: OmniLockWitnessLockCodec.pack({ signature: signedMessage }), }), - ).serializeJson(); + ); return signedWitness; } @@ -185,23 +187,19 @@ async function issuerSignTransaction(txSkeleton: helpers.TransactionSkeletonType let v = Number.parseInt(signedMessage.slice(-2), 16); if (v >= 27) v -= 27; signedMessage = "0x" + signedMessage.slice(2, -2) + v.toString(16).padStart(2, "0"); - const signedWitness = new toolkit.Reader( - core.SerializeWitnessArgs({ - lock: new toolkit.Reader(signedMessage), + const signedWitness = bytes.hexify( + blockchain.WitnessArgs.pack({ + lock: signedMessage, }), - ).serializeJson(); + ); return signedWitness; } function generateUserMessage(tx: helpers.TransactionSkeletonType): HexString { const hasher = new utils.CKBHasher(); - const rawTxHash = utils.ckbHash( - core.SerializeRawTransaction( - toolkit.normalizers.NormalizeRawTransaction(helpers.createTransactionFromSkeleton(tx)), - ), - ); - const serializedWitness = core.SerializeWitnessArgs({ - lock: new toolkit.Reader("0x" + "00".repeat(85)), + const rawTxHash = utils.ckbHash(blockchain.RawTransaction.pack(helpers.createTransactionFromSkeleton(tx))); + const serializedWitness = blockchain.WitnessArgs.pack({ + lock: new Uint8Array(85), }); hasher.update(rawTxHash); hashWitness(hasher, serializedWitness); @@ -210,14 +208,10 @@ function generateUserMessage(tx: helpers.TransactionSkeletonType): HexString { function generateIssuerMessage(tx: helpers.TransactionSkeletonType): HexString { const hasher = new utils.CKBHasher(); - const rawTxHash = utils.ckbHash( - core.SerializeRawTransaction( - toolkit.normalizers.NormalizeRawTransaction(helpers.createTransactionFromSkeleton(tx)), - ), - ); + const rawTxHash = utils.ckbHash(blockchain.RawTransaction.pack(helpers.createTransactionFromSkeleton(tx))); hasher.update(rawTxHash); - const serializedSudtWitness = core.SerializeWitnessArgs({ - lock: new toolkit.Reader(`0x${"00".repeat(65)}`), + const serializedSudtWitness = blockchain.WitnessArgs.pack({ + lock: new Uint8Array(65), }); hashWitness(hasher, serializedSudtWitness); return hasher.digestHex(); diff --git a/yarn.lock b/yarn.lock index 7819ddd4..4c59727f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1450,25 +1450,19 @@ js-xxhash "^1.0.4" lodash.isequal "^4.5.0" -"@ckb-lumos/base@^0.17.0-rc10": - version "0.17.0" - resolved "https://registry.yarnpkg.com/@ckb-lumos/base/-/base-0.17.0.tgz#4d6d6081947aae7bdea633c7de41f5a23bbeec04" - integrity sha512-Yb3/g9vNwS+O+xKgkypcoIhkNwBXbpmhWUZvxzH5iKdZik0gH92bfFH5geFx2w03EtgBkfy1jbveF48mz0Ia0Q== - dependencies: - "@ckb-lumos/bi" "0.17.0" - "@ckb-lumos/toolkit" "0.17.0" +"@ckb-lumos/base@^0.19.0-alpha.0": + version "0.19.0-alpha.0" + resolved "https://registry.yarnpkg.com/@ckb-lumos/base/-/base-0.19.0-alpha.0.tgz#2ab6fc913f42391b84737ce8fda8a2808be76c7a" + integrity sha512-yttemuaMbInLZGBi1XjAgFS9NqiQBAgL1kugVDm01LpqgCCxjDJ9e4KA2TabxwoSy7NclnGu0IJQo7QjqWu9ZA== + dependencies: + "@ckb-lumos/bi" "^0.19.0-alpha.0" + "@ckb-lumos/codec" "^0.19.0-alpha.0" + "@ckb-lumos/toolkit" "^0.19.0-alpha.0" "@types/lodash.isequal" "^4.5.5" blake2b "^2.1.3" js-xxhash "^1.0.4" lodash.isequal "^4.5.0" -"@ckb-lumos/bi@0.17.0": - version "0.17.0" - resolved "https://registry.yarnpkg.com/@ckb-lumos/bi/-/bi-0.17.0.tgz#65ab8300451b1a2f7105b0167f9bebe0c895ce09" - integrity sha512-MNLNVoX1jO4JoEkSvt8JZI48KkKjzbsEUt9JqAWMc3iNgJ7SIXXGX1Cv9YxY5Kxwsq64Cs6O4nm5iEE4wH6vlA== - dependencies: - jsbi "^4.1.0" - "@ckb-lumos/bi@0.17.0-rc10", "@ckb-lumos/bi@^0.17.0-rc10": version "0.17.0-rc10" resolved "https://registry.npmjs.org/@ckb-lumos/bi/-/bi-0.17.0-rc10.tgz" @@ -1483,6 +1477,13 @@ dependencies: jsbi "^4.1.0" +"@ckb-lumos/bi@^0.19.0-alpha.0": + version "0.19.0-alpha.0" + resolved "https://registry.yarnpkg.com/@ckb-lumos/bi/-/bi-0.19.0-alpha.0.tgz#9386f9e32c6fef13f83ea59fd9c0a94fc955faa7" + integrity sha512-Dykikys0UWvIdlS/7yjumkkhj2zJVKr5/UknzgzJikFYvE/dXSlFoYG7xHelxiRaC9WSZ6Qyxhm37aXkFR/U4g== + dependencies: + jsbi "^4.1.0" + "@ckb-lumos/ckb-indexer@0.17.0-rc10": version "0.17.0-rc10" resolved "https://registry.npmjs.org/@ckb-lumos/ckb-indexer/-/ckb-indexer-0.17.0-rc10.tgz" @@ -1495,12 +1496,24 @@ cross-fetch "^3.1.5" events "^3.3.0" -"@ckb-lumos/codec@^0.17.0-rc10": - version "0.17.0-rc10" - resolved "https://registry.npmjs.org/@ckb-lumos/codec/-/codec-0.17.0-rc10.tgz" - integrity sha512-yPCelxOzDh4Tc7AW5RoQT9NIMNo8NxejYZMrxPF3t/mQKgbFGAFpnfyEBiZEnRWTQT9uWCVQQTh3BTZ9AqO3tQ== +"@ckb-lumos/ckb-indexer@^0.19.0-alpha.0": + version "0.19.0-alpha.0" + resolved "https://registry.yarnpkg.com/@ckb-lumos/ckb-indexer/-/ckb-indexer-0.19.0-alpha.0.tgz#29aff03a90f0f1450e0d9f906c0f6e41e19d1ae0" + integrity sha512-rtDKwH5zin3xDERHBLcyi9Mn8NbKRduujtTc+laB9P8AAK9+dzJeXKYGNSpQHoK5cE3ppP5r6C7XI8ZCF+Kzgw== dependencies: - "@ckb-lumos/bi" "0.17.0-rc10" + "@ckb-lumos/base" "^0.19.0-alpha.0" + "@ckb-lumos/bi" "^0.19.0-alpha.0" + "@ckb-lumos/rpc" "^0.19.0-alpha.0" + "@ckb-lumos/toolkit" "^0.19.0-alpha.0" + cross-fetch "^3.1.5" + events "^3.3.0" + +"@ckb-lumos/codec@^0.19.0-alpha.0": + version "0.19.0-alpha.0" + resolved "https://registry.yarnpkg.com/@ckb-lumos/codec/-/codec-0.19.0-alpha.0.tgz#902a95c240422c1f9c7f7e3fc1a391cf983aadb3" + integrity sha512-CAD5teDf3q/KBdbUgHtDxgj1m/HHueYNBiVlJjFA8pm5mJmZZhgoIbWmteH5puj6tIpbXh8zSEWEzghAeM0Lug== + dependencies: + "@ckb-lumos/bi" "^0.19.0-alpha.0" "@ckb-lumos/common-scripts@0.17.0-rc10": version "0.17.0-rc10" @@ -1515,6 +1528,20 @@ "@ckb-lumos/toolkit" "0.17.0-rc10" immutable "^4.0.0-rc.12" +"@ckb-lumos/common-scripts@^0.19.0-alpha.0": + version "0.19.0-alpha.0" + resolved "https://registry.yarnpkg.com/@ckb-lumos/common-scripts/-/common-scripts-0.19.0-alpha.0.tgz#024eb1a5d8da5bf64f67584b6abfb9a75039de43" + integrity sha512-Xm9F3iQMgrNMnpXBWh5Kycfq3KHIyvtSP6SzNkgvC8/NiH+j9JcRKukPWRoB8g6Vw3rAKbO+YfOCEWsFrvEX0w== + dependencies: + "@ckb-lumos/base" "^0.19.0-alpha.0" + "@ckb-lumos/bi" "^0.19.0-alpha.0" + "@ckb-lumos/codec" "^0.19.0-alpha.0" + "@ckb-lumos/config-manager" "^0.19.0-alpha.0" + "@ckb-lumos/helpers" "^0.19.0-alpha.0" + "@ckb-lumos/rpc" "^0.19.0-alpha.0" + "@ckb-lumos/toolkit" "^0.19.0-alpha.0" + immutable "^4.0.0-rc.12" + "@ckb-lumos/config-manager@0.17.0-rc10": version "0.17.0-rc10" resolved "https://registry.npmjs.org/@ckb-lumos/config-manager/-/config-manager-0.17.0-rc10.tgz" @@ -1525,6 +1552,17 @@ "@types/deep-freeze-strict" "^1.1.0" deep-freeze-strict "^1.1.1" +"@ckb-lumos/config-manager@^0.19.0-alpha.0": + version "0.19.0-alpha.0" + resolved "https://registry.yarnpkg.com/@ckb-lumos/config-manager/-/config-manager-0.19.0-alpha.0.tgz#40cb5f68fa024f160dec5ce4e6d83eb2964e4e2d" + integrity sha512-Up7b6xkUuatB/v8ZNhxxPqgtMRZ6mq8ogt3UbW9OHA/S14pM29B6SD98Sh+SowJSh7wtwiGpwBFjRIaRUOYaYQ== + dependencies: + "@ckb-lumos/base" "^0.19.0-alpha.0" + "@ckb-lumos/bi" "^0.19.0-alpha.0" + "@ckb-lumos/codec" "^0.19.0-alpha.0" + "@types/deep-freeze-strict" "^1.1.0" + deep-freeze-strict "^1.1.1" + "@ckb-lumos/hd@0.17.0-rc10": version "0.17.0-rc10" resolved "https://registry.npmjs.org/@ckb-lumos/hd/-/hd-0.17.0-rc10.tgz" @@ -1537,6 +1575,18 @@ sha3 "^2.1.3" uuid "^8.3.0" +"@ckb-lumos/hd@^0.19.0-alpha.0": + version "0.19.0-alpha.0" + resolved "https://registry.yarnpkg.com/@ckb-lumos/hd/-/hd-0.19.0-alpha.0.tgz#f4d616412b7fa753961d8c99f40e6225b3da8e01" + integrity sha512-YNI4w91+kOftDfHuJ6DvWj7ND8dA3yqwQVAc39O6PRWX7fLMP7pHL0VMAikd5PJkD0jlJgzq2LPrczdvAc4yoQ== + dependencies: + "@ckb-lumos/base" "^0.19.0-alpha.0" + "@ckb-lumos/bi" "^0.19.0-alpha.0" + bn.js "^5.1.3" + elliptic "^6.5.4" + sha3 "^2.1.3" + uuid "^8.3.0" + "@ckb-lumos/helpers@0.17.0-rc10": version "0.17.0-rc10" resolved "https://registry.npmjs.org/@ckb-lumos/helpers/-/helpers-0.17.0-rc10.tgz" @@ -1549,6 +1599,18 @@ bech32 "^2.0.0" immutable "^4.0.0-rc.12" +"@ckb-lumos/helpers@^0.19.0-alpha.0": + version "0.19.0-alpha.0" + resolved "https://registry.yarnpkg.com/@ckb-lumos/helpers/-/helpers-0.19.0-alpha.0.tgz#eb4b4f923851f7be3a8674dbd63ed65a07196e9e" + integrity sha512-Y1TXzDKwD49IQ8h0UviKZVPvTz7rDP16bAfnKGMSpBLhKr9JFG8T0eANkTkdFSdvQ7mF5GQwF8k2fW6NSCwVag== + dependencies: + "@ckb-lumos/base" "^0.19.0-alpha.0" + "@ckb-lumos/bi" "^0.19.0-alpha.0" + "@ckb-lumos/config-manager" "^0.19.0-alpha.0" + "@ckb-lumos/toolkit" "^0.19.0-alpha.0" + bech32 "^2.0.0" + immutable "^4.0.0-rc.12" + "@ckb-lumos/lumos@^0.17.0-rc10": version "0.17.0-rc10" resolved "https://registry.npmjs.org/@ckb-lumos/lumos/-/lumos-0.17.0-rc10.tgz" @@ -1564,6 +1626,21 @@ "@ckb-lumos/rpc" "0.17.0-rc10" "@ckb-lumos/toolkit" "0.17.0-rc10" +"@ckb-lumos/lumos@^0.19.0-alpha.0": + version "0.19.0-alpha.0" + resolved "https://registry.yarnpkg.com/@ckb-lumos/lumos/-/lumos-0.19.0-alpha.0.tgz#f1af6f39b2eee35d630408e1e34668cd4a23345a" + integrity sha512-HgglPMGhG5UNz3PN2cskriLrnERlQvXTaAtWsv/tjeIHbhMpeEio3Ts8rmqoLWdAjj4mwudmVXWXcVH+eQxexw== + dependencies: + "@ckb-lumos/base" "^0.19.0-alpha.0" + "@ckb-lumos/bi" "^0.19.0-alpha.0" + "@ckb-lumos/ckb-indexer" "^0.19.0-alpha.0" + "@ckb-lumos/common-scripts" "^0.19.0-alpha.0" + "@ckb-lumos/config-manager" "^0.19.0-alpha.0" + "@ckb-lumos/hd" "^0.19.0-alpha.0" + "@ckb-lumos/helpers" "^0.19.0-alpha.0" + "@ckb-lumos/rpc" "^0.19.0-alpha.0" + "@ckb-lumos/toolkit" "^0.19.0-alpha.0" + "@ckb-lumos/rpc@0.17.0-rc10": version "0.17.0-rc10" resolved "https://registry.npmjs.org/@ckb-lumos/rpc/-/rpc-0.17.0-rc10.tgz" @@ -1573,10 +1650,14 @@ "@ckb-lumos/bi" "0.17.0-rc10" "@ckb-lumos/toolkit" "0.17.0-rc10" -"@ckb-lumos/toolkit@0.17.0": - version "0.17.0" - resolved "https://registry.yarnpkg.com/@ckb-lumos/toolkit/-/toolkit-0.17.0.tgz#4df2bb822b3d8de3deeee02aa8a658017efffe5c" - integrity sha512-y9MrQMjH3qVj6bZCnps5aydu1wAwM4u/cv0c4o2AqxHNq9axIt5hZmI8Z9hswDctcyeWll1aLpYamy3Wt+wz4Q== +"@ckb-lumos/rpc@^0.19.0-alpha.0": + version "0.19.0-alpha.0" + resolved "https://registry.yarnpkg.com/@ckb-lumos/rpc/-/rpc-0.19.0-alpha.0.tgz#c5e375ac8d7ad6d5ad10407174241d14093df08d" + integrity sha512-rDgQwVEakgrhlTKUCqw3S8Xl4VlxrhqRAB/bUpgAlvoujOEx5y4jh/BpW3XEzuVACLL/Y5jGe7tD5P+gRTy9iQ== + dependencies: + "@ckb-lumos/bi" "^0.19.0-alpha.0" + axios "0.21.4" + tslib "2.3.1" "@ckb-lumos/toolkit@0.17.0-rc10": version "0.17.0-rc10" @@ -1588,6 +1669,11 @@ resolved "https://registry.yarnpkg.com/@ckb-lumos/toolkit/-/toolkit-0.18.0-rc6.tgz#e11849aab895bd152b953ce0cd25101970111d06" integrity sha512-s4VweBERcelCupeaAZlspaAXJFZH9BGlLkPbYUDbVuNz7Fmss39FqKQOJohS9rBqLkeINxO4BmuSjdCaqnuDfg== +"@ckb-lumos/toolkit@^0.19.0-alpha.0": + version "0.19.0-alpha.0" + resolved "https://registry.yarnpkg.com/@ckb-lumos/toolkit/-/toolkit-0.19.0-alpha.0.tgz#953e7aeb0f0afbdcb5aa2ac640c5986f6a309337" + integrity sha512-McHoklGiv7f2/nYo4Iih2yQuxNfsLVLJoQRAjI/oR/XS5iOwDXUr7QRPsWB/hEgtR/aHyR3MSq0gZAIQNYzm+Q== + "@cnakazawa/watch@^1.0.3": version "1.0.4" resolved "https://registry.npmjs.org/@cnakazawa/watch/-/watch-1.0.4.tgz" @@ -5277,6 +5363,13 @@ axe-core@^4.3.5: resolved "https://registry.npmjs.org/axe-core/-/axe-core-4.3.5.tgz" integrity sha512-WKTW1+xAzhMS5dJsxWkliixlO/PqC4VhmO9T4juNYcaTg9jzWiJsou6m5pxWYGfigWbwzJWeFY6z47a+4neRXA== +axios@0.21.4: + version "0.21.4" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575" + integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg== + dependencies: + follow-redirects "^1.14.0" + axios@^0.27.2: version "0.27.2" resolved "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz" @@ -9137,7 +9230,7 @@ flush-write-stream@^1.0.0: inherits "^2.0.3" readable-stream "^2.3.6" -follow-redirects@^1.0.0, follow-redirects@^1.14.9: +follow-redirects@^1.0.0, follow-redirects@^1.14.0, follow-redirects@^1.14.9: version "1.15.1" resolved "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.1.tgz" integrity sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA== @@ -17980,16 +18073,16 @@ tsconfig-paths@^3.9.0: minimist "^1.2.6" strip-bom "^3.0.0" +tslib@2.3.1, tslib@^2.0.3: + version "2.3.1" + resolved "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz" + integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw== + tslib@^1.8.1, tslib@^1.9.3: version "1.14.1" resolved "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== -tslib@^2.0.3: - version "2.3.1" - resolved "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz" - integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw== - tslib@^2.1.0, tslib@^2.3.0: version "2.4.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3"