Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:support lumos #4

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 31 additions & 9 deletions config/config.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
import {config, helpers, Indexer, RPC} from "@ckb-lumos/lumos";
import {LightClient} from "../service/node";
import {LightClientCli} from "../service/light-cli";
import {LightClientRPC} from "@ckb-lumos/light-client";

const CKB_CLIENT_CLI_PATH = "tmp/ckb-cli-light-client"
const CKB_LIGHT_CLIENT_PATH = "tmp/startBlockchain/ckbLightClient/ckb-light-client"
const RPC_DEBUG = false
const DEV_PATH = "tmp/startBlockchain/ckbDevWithIndexAndeLightClient"
const CKB_DEV_PATH = "tmp/startBlockchain/ckbDevWithIndexAndeLightClient/ckb/target/release"
const CKB_DEV_INDEX_PATH = "tmp/startBlockchain/ckbDevWithIndexAndeLightClient/ckb-indexer/target/release"
const CKB_DEV_LIGHT_CLIENT_PATH = "tmp/startBlockchain/ckbDevWithIndexAndeLightClient/ckb-light-client/target/release"

const CKB_DEV_RPC_URL = "http://localhost:8114";
const CKB_DEV_RPC_INDEX_URL = "http://localhost:8116";

const RPC_DEBUG = true
const CKB_RPC_URL = "https://testnet.ckb.dev";
// const CKB_RPC_URL = CKB_DEV_RPC_URL;
const CKB_RPC_INDEX_URL = "https://testnet.ckb.dev/indexer";
// const CKB_RPC_INDEX_URL = CKB_DEV_RPC_INDEX_URL;
const CKB_LIGHT_RPC_URL = "http://localhost:9000";

export enum FeeRate {
SLOW = 1000,
NORMAL = 100000,
NORMAL = 10000,
FAST = 10000000
}

const uint = 100000000
const uint = 100000000

const FEE = FeeRate.NORMAL
config.initializeConfig(
Expand All @@ -28,29 +38,33 @@ const MINER_SCRIPT = helpers.parseAddress("ckt1qyqvjdmh4re8t7mfjr0v0z27lwwjqu384
const MINER_SCRIPT2 = helpers.parseAddress("ckt1qyq8ph2ywxpvkl5l0rcsugcnwcfswqpqngeqqmfuwq")
const MINER_SCRIPT3 = helpers.parseAddress("ckt1qyqd5eyygtdmwdr7ge736zw6z0ju6wsw7rssu8fcve")
const CkbClientNode = new LightClient(CKB_LIGHT_CLIENT_PATH)
const lightClientRPC = new LightClientRPC(CKB_LIGHT_RPC_URL)

const deprecatedAddr = helpers.generateAddress(script);
const newFullAddr = helpers.encodeToAddress(script);
const rpcCLient = new RPC(CKB_RPC_URL);
const rpcDevCLient = new RPC(CKB_DEV_RPC_URL);

const {AGGRON4} = config.predefined;
const RPC_NETWORK = AGGRON4;
const ACCOUNT_PRIVATE = "0xdd50cac37ec6dd12539a968c1a2cbedda75bd8724f7bcad486548eaabb87fc8b"
const ACCOUNT_PRIVATE2 = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
const indexer = new Indexer(CKB_RPC_INDEX_URL, CKB_RPC_URL);
const LightCli = new LightClientCli(CKB_CLIENT_CLI_PATH,CKB_LIGHT_RPC_URL)
const LightCli = new LightClientCli(CKB_CLIENT_CLI_PATH, CKB_LIGHT_RPC_URL)
const indexerMockLightRpc = new LightClientRPC( CKB_RPC_INDEX_URL)


const EVERY_ONE_CAN_PAY_DATA = {
"CODE_HASH": '0xe683b04139344768348499c23eb1326d5a52d6db006c0d2fece00a831f3660d7',
"HASH_TYPE":"data",
"HASH_TYPE": "data",
"TX_HASH": '0xbe5d236f316f5608c53aa682351be4114db07b2e843435e843661ded30924c04',
"INDEX": '0x0',
"DEP_TYPE": 'code'
}

const EVERY_ONE_CAN_PAY_DATA1 = {
"CODE_HASH": '0xe683b04139344768348499c23eb1326d5a52d6db006c0d2fece00a831f3660d7',
"HASH_TYPE":"data1",
"HASH_TYPE": "data1",
"TX_HASH": '0xbe5d236f316f5608c53aa682351be4114db07b2e843435e843661ded30924c04',
"INDEX": '0x0',
"DEP_TYPE": 'code'
Expand Down Expand Up @@ -86,6 +100,14 @@ export {
ACCOUNT_PRIVATE2,
LightCli,
EVERY_ONE_CAN_PAY_TYPE_ID,
EVERY_ONE_CAN_PAY_DATA

EVERY_ONE_CAN_PAY_DATA,
CKB_DEV_PATH,
rpcDevCLient,
CKB_DEV_RPC_URL,
CKB_DEV_RPC_INDEX_URL,
DEV_PATH,
CKB_DEV_INDEX_PATH,
CKB_DEV_LIGHT_CLIENT_PATH,
lightClientRPC,
indexerMockLightRpc
}
16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"node": ">=10"
},
"dependencies": {
"@ckb-lumos/lumos": "0.18.0-rc7",
"@ckb-lumos/light-client": "^0.20.0-alpha.0",
"@ckb-lumos/lumos": "0.19.0",
"@ckb-lumos/codec": "0.19.0",
"dotenv": "^16.0.1",
"mochawesome-merge": "^4.2.1",
"npm-run-all": "^4.1.5"
Expand All @@ -19,6 +21,7 @@
"@types/chai": "^4.2.6",
"@types/mocha": "^5.2.7",
"chai": "^4.2.0",
"ckb-js-toolkit": "^0.10.2",
"decimal.js": "^10.2.1",
"mocha": "^9.2.2",
"mocha-chai-jest-snapshot": "^1.1.0",
Expand All @@ -31,15 +34,18 @@
"ts-generator": "^0.1.1",
"ts-node": "^8.5.4",
"typechain": "^4.0.0",
"typescript": "^3.7.3",
"ckb-js-toolkit": "^0.10.2"

"typescript": "^3.7.3"
},
"scripts": {
"test": "mocha --config test/runners/mocha/.mocharc.jsonc --reporter mochawesome",
"test-load": "mocha --config test/runners/mocha/.mocharc.load.jsonc --reporter mochawesome",
"test-data": "mocha --config test/runners/mocha/.mocharc.data.jsonc --reporter mochawesome",
"test-cli": "mocha --config test/runners/mocha/.mocharc.cli.jsonc --reporter mochawesome",
"test-transfer-issue": "mocha --config test/runners/mocha/.mocharc.issue.jsonc --reporter mochawesome"
"test-transfer-issue": "mocha --config test/runners/mocha/.mocharc.issue.jsonc --reporter mochawesome",
"test-index-panic": "mocha --config test/runners/mocha/.mocharc.index-panic.jsonc --reporter mochawesome",
"test-roll-back": "mocha --config test/runners/mocha/.mocharc.light.rollback.jsonc --reporter mochawesome",
"test-roll-back:transfer": "mocha --config test/runners/mocha/.mocharc.light.rollback.jsonc --grep \"transfer\"--reporter mochawesome",
"test-roll-back:cut10": "mocha --config test/runners/mocha/.mocharc.light.rollback.jsonc --grep \"cut 10\"--reporter mochawesome",
"test-roll-back:cut300": "mocha --config test/runners/mocha/.mocharc.light.rollback.jsonc --grep \"cut 300\"--reporter mochawesome"
}
}
2 changes: 1 addition & 1 deletion prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sh prepare.sh
sh start.sh
sh status.sh
cat ckb-light-client/target/release/node.log
echo "prepare ckbLightClient finish"
echo "prepare ckb Light Client finish"
cd ../../
git clone https://github.com/TheWaWaR/ckb-cli-light-client.git
cd ckb-cli-light-client
Expand Down
39 changes: 17 additions & 22 deletions resource/cli/example-search-key.withFilter.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
{
"script": {
"code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
"hash_type": "type",
"args": "0x00010203"
},
"script_type": "lock",
"filter": {
"script": {
"code_hash": "0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e",
"hash_type": "type",
"args": "0x00010203"
},
"script_len_range": null,
"output_data_len_range": [
"0x16",
"0x378"
],
"output_capacity_range": [
"0xf4240",
"0x5f5e100"
],
"block_range": [
"0x21",
"0x3e7"
],
"script": {
"args": "0x00010203",
"code_hash": "0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e",
"hash_type": "type"
},
"script_len_range": [
"0x0",
"0x6f"
]
},
"with_data": false,
"group_by_transaction": null
"group_by_transaction": false,
"script": {
"args": "0x00010203",
"code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
"hash_type": "type"
},
"script_type": "lock",
"with_data": false
}
Loading