@offckb/cli 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -25,15 +25,6 @@ Start building on Nervos blockchain, right now, right away!
25
25
  - [Get started](#get-started)
26
26
  - [Create a full-stack Project](#create-a-full-stack-project)
27
27
  - [Create a script-only Project](#create-a-script-only-project)
28
- - [Run A dApp Example](#run-a-dapp-example)
29
- - [Step 1: Select A dApp To Init](#step-1-select-a-dapp-to-init)
30
- - [Step 2: Start the Devnet](#step-2-start-the-devnet)
31
- - [Step 3: Access Pre-funded Accounts](#step-3-access-pre-funded-accounts)
32
- - [dApp Examples with Detailed Tutorial](#dapp-examples-with-detailed-tutorial)
33
- - [View and transfer balance](#view-and-transfer-balance)
34
- - [Write \& read on-chain messages](#write--read-on-chain-messages)
35
- - [Issue custom token via xUDT scripts](#issue-custom-token-via-xudt-scripts)
36
- - [Create on-chain digital object via Spore protocol](#create-on-chain-digital-object-via-spore-protocol)
37
28
  - [Built-in scripts](#built-in-scripts)
38
29
  - [Accounts](#accounts)
39
30
  - [About Lumos](#about-lumos)
@@ -59,7 +50,6 @@ Options:
59
50
  -h, --help display help for command
60
51
 
61
52
  Commands:
62
- init [your-project-name] Init a example dApp to learn and run
63
53
  create [your-project-name] Create a new dApp from bare templates
64
54
  node Use the CKB to start devnet
65
55
  clean Clean the devnet data, need to stop running the chain first
@@ -86,7 +76,7 @@ npm install -g @offckb/cli
86
76
 
87
77
  ## Get started
88
78
 
89
- ### Create a full-stack Project
79
+ ### Create a full-stack Project
90
80
 
91
81
  Create a new project from predefined boilerplates.
92
82
 
@@ -106,117 +96,6 @@ offckb create <your-project-name> --script
106
96
 
107
97
  Note: you need to have rust/cargo/cargo-generate/clang 16+ installed in your environment to use this command. offckb doesn't do anything really, it just call [ckb-script-template](https://github.com/cryptape/ckb-script-tempaltes) to do all the magic.
108
98
 
109
- ## Run A dApp Example
110
-
111
- ### Step 1: Select A dApp To Init
112
-
113
- ```sh
114
- offckb init <your-project-name, eg:my-awesome-ckb-dapp>
115
-
116
- ## Select an example dApp
117
- ? Select a dapp template (Use arrow keys)
118
- ❯ Transfer CKB
119
- Issue Coin With XUDT scripts
120
- a simple dapp to check CKB balance and transfer CKB from address to address
121
- init CKB dapp project: /Users/ckb/Desktop/offckb/my-awesome-ckb-dapp
122
- ✨ Done in 7.52s.
123
-
124
- ## start running
125
- cd my-awesome-ckb-dapp
126
- yarn && yarn start
127
-
128
- ## results
129
- yarn run v1.22.19
130
- $ parcel index.html
131
- Server running at http://localhost:1234
132
- ✨ Built in 10ms
133
- ```
134
-
135
- ### Step 2: Start the Devnet
136
-
137
- Open another terminal and run:
138
-
139
- ```sh
140
- offckb node
141
-
142
- # result
143
- # ...
144
- CKB-Miner: 2024-03-04 14:35:12.563 +00:00 client INFO ckb_miner::miner Found! #3181 0x3749481a320824fe21077eaa8ec9d024a7b62d031720c27c1ef1681e8ab349e8
145
-
146
- CKB-Miner: 2024-03-04 14:35:17.567 +00:00 client INFO ckb_miner::miner Found! #3184 0xa612a9ea35f292a6473e23e88856283aea8b1bc6a607147bef5c06c94e964f2f
147
- #...
148
- ```
149
-
150
- You can leave this terminal open to keep the devnet running, feel free to `ctrl+c` to exit the terminal and stop the local blockchain.
151
-
152
- ### Step 3: Access Pre-funded Accounts
153
-
154
- Open another terminal and check the accounts to use:
155
-
156
- ```sh
157
- offckb accounts
158
-
159
- # results
160
-
161
- #### ALL ACCOUNTS ARE FOR TEST AND DEVELOP ONLY ####
162
- #### DON'T USE THESE ACCOUNTS ON MAINNET ####
163
- #### OTHERWISE YOU WILL LOOSE YOUR MONEY ####
164
-
165
- Print account list, each account is funded with 42_000_000_00000000 capacity in the devnet genesis block.
166
-
167
- - "#": 0
168
- address: ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqvwg2cen8extgq8s5puft8vf40px3f599cytcyd8
169
- privkey: 0x6109170b275a09ad54877b82f7d9930f88cab5717d484fb4741ae9d1dd078cd6
170
- pubkey: 0x02025fa7b61b2365aa459807b84df065f1949d58c0ae590ff22dd2595157bffefa
171
- lock_arg: 0x8e42b1999f265a0078503c4acec4d5e134534297
172
- lockScript:
173
- codeHash: 0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8
174
- hashType: type
175
- args: 0x8e42b1999f265a0078503c4acec4d5e134534297
176
-
177
- - "#": 1
178
- address: ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqt435c3epyrupszm7khk6weq5lrlyt52lg48ucew
179
- privkey: 0x9f315d5a9618a39fdc487c7a67a8581d40b045bd7a42d83648ca80ef3b2cb4a1
180
- pubkey: 0x026efa0579f09cc7c1129b78544f70098c90b2ab155c10746316f945829c034a2d
181
- lock_arg: 0x758d311c8483e0602dfad7b69d9053e3f917457d
182
- lockScript:
183
- codeHash: 0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8
184
- hashType: type
185
- args: 0x758d311c8483e0602dfad7b69d9053e3f917457d
186
- ```
187
-
188
- Copy some private keys and visit http://localhost:1234 to play your first CKB dApp!
189
-
190
- ## dApp Examples with Detailed Tutorial
191
-
192
- `offckb` packs some basic minimal dApp examples for you to learn and get started with. By running `offckb init`, you can select the different dApp examples to quickly set up a local dApp project targeting the local blockchain with built-in scripts and accounts.
193
-
194
- The dApp examples often involve interaction with some most useful smart contracts on CKB like xUDT/Spore/Omnilock. The best thing is those dApp examples also come with detailed tutorial documents from [docs.nervos.org](https://docs.nervos.org/). The source codes of these templates are also maintained [here](https://github.com/nervosnetwork/docs.nervos.org/tree/develop-v2/examples).
195
-
196
- ### View and transfer balance
197
-
198
- A simple dApp to check CKB balance and transfer CKB.
199
-
200
- [Tutorial](https://docs.nervos.org/docs/getting-started/transfer-ckb)
201
-
202
- ### Write & read on-chain messages
203
-
204
- A simple dApp to issue your own token via XUDT scripts.
205
-
206
- [Tutorial](https://docs.nervos.org/docs/getting-started/write-message)
207
-
208
- ### Issue custom token via xUDT scripts
209
-
210
- A simple dApp to store & retrieve data from a Cell.
211
-
212
- [Tutorial](https://docs.nervos.org/docs/getting-started/create-token)
213
-
214
- ### Create on-chain digital object via Spore protocol
215
-
216
- A simple dApp to create on-chain digital objects with spore scripts.
217
-
218
- [Tutorial](https://docs.nervos.org/docs/getting-started/create-dob)
219
-
220
99
  ## Built-in scripts
221
100
 
222
101
  - [x] xUDT https://github.com/nervosnetwork/rfcs/pull/428
@@ -14,9 +14,8 @@ export declare const deployedContractInfoFolderPath: string;
14
14
  export declare const accountTargetDir: string;
15
15
  export declare const minimalRequiredCKBVersion = "0.113.1";
16
16
  export declare const defaultLumosVersion = "0.21.0";
17
- export declare const dappTemplateGitRepoUserAndName = "nervosnetwork/docs.nervos.org";
18
- export declare const dappTemplateGitUrl = "https://github.com/nervosnetwork/docs.nervos.org";
17
+ export declare const dappTemplateGitRepoUserAndName = "RetricSu/offckb";
18
+ export declare const dappTemplateGitUrl = "https://github.com/RetricSu/offckb";
19
19
  export declare const dappTemplateGitBranch = "develop";
20
- export declare const dappTemplateGitFolder = "examples";
21
- export declare const dappTemplateGitSelectOptionFile = "options.json";
20
+ export declare const dappTemplateGitFolder = "templates";
22
21
  export declare const bareTemplateGitSelectOptionFile = "template.json";
package/dist/cfg/const.js CHANGED
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.bareTemplateGitSelectOptionFile = exports.dappTemplateGitSelectOptionFile = exports.dappTemplateGitFolder = exports.dappTemplateGitBranch = exports.dappTemplateGitUrl = exports.dappTemplateGitRepoUserAndName = exports.defaultLumosVersion = exports.minimalRequiredCKBVersion = exports.accountTargetDir = exports.deployedContractInfoFolderPath = exports.ckbBinPath = exports.ckbFolderPath = exports.devnetDataPath = exports.devnetPath = exports.devnetSourcePath = exports.userOffCKBConfigPath = exports.predefinedOffCKBConfigTsPath = exports.targetEnvironmentPath = exports.dappTemplatePath = exports.packageRootPath = exports.packageSrcPath = exports.currentExecPath = void 0;
26
+ exports.bareTemplateGitSelectOptionFile = exports.dappTemplateGitFolder = exports.dappTemplateGitBranch = exports.dappTemplateGitUrl = exports.dappTemplateGitRepoUserAndName = exports.defaultLumosVersion = exports.minimalRequiredCKBVersion = exports.accountTargetDir = exports.deployedContractInfoFolderPath = exports.ckbBinPath = exports.ckbFolderPath = exports.devnetDataPath = exports.devnetPath = exports.devnetSourcePath = exports.userOffCKBConfigPath = exports.predefinedOffCKBConfigTsPath = exports.targetEnvironmentPath = exports.dappTemplatePath = exports.packageRootPath = exports.packageSrcPath = exports.currentExecPath = void 0;
27
27
  const path = __importStar(require("path"));
28
28
  // path
29
29
  exports.currentExecPath = process.cwd();
@@ -44,9 +44,8 @@ exports.accountTargetDir = path.join(exports.packageRootPath, `account`);
44
44
  exports.minimalRequiredCKBVersion = '0.113.1';
45
45
  exports.defaultLumosVersion = '0.21.0';
46
46
  // url
47
- exports.dappTemplateGitRepoUserAndName = 'nervosnetwork/docs.nervos.org';
47
+ exports.dappTemplateGitRepoUserAndName = 'RetricSu/offckb';
48
48
  exports.dappTemplateGitUrl = `https://github.com/${exports.dappTemplateGitRepoUserAndName}`;
49
49
  exports.dappTemplateGitBranch = 'develop';
50
- exports.dappTemplateGitFolder = 'examples';
51
- exports.dappTemplateGitSelectOptionFile = 'options.json';
50
+ exports.dappTemplateGitFolder = 'templates';
52
51
  exports.bareTemplateGitSelectOptionFile = 'template.json';
package/dist/cli.js CHANGED
@@ -17,7 +17,6 @@ const list_hashes_1 = require("./cmd/list-hashes");
17
17
  const node_1 = require("./cmd/node");
18
18
  const init_chain_1 = require("./cmd/develop/init-chain");
19
19
  const lumos_config_1 = require("./cmd/develop/lumos-config");
20
- const init_1 = require("./cmd/init");
21
20
  const accounts_1 = require("./cmd/accounts");
22
21
  const clean_1 = require("./cmd/clean");
23
22
  const encoding_1 = require("./util/encoding");
@@ -36,14 +35,6 @@ const description = require('../package.json').description;
36
35
  (0, encoding_1.setUTF8EncodingForWindows)();
37
36
  const program = new commander_1.Command();
38
37
  program.name('offckb').description(description).version(version);
39
- program
40
- .command('init [your-project-name]')
41
- .description('Init a example dApp to learn and run')
42
- .action((projectName) => __awaiter(void 0, void 0, void 0, function* () {
43
- const name = projectName !== null && projectName !== void 0 ? projectName : 'my-awesome-ckb-dapp';
44
- const template = yield (0, init_1.selectTemplate)();
45
- return (0, init_1.init)(name, template);
46
- }));
47
38
  program
48
39
  .command('create [your-project-name]')
49
40
  .description('Create a new dApp from bare templates')
@@ -1,9 +1,3 @@
1
- export interface TutorialOption {
2
- name: string;
3
- value: string;
4
- description: string;
5
- }
6
- export declare function loadTutorialOpts(): Promise<Array<TutorialOption>>;
7
1
  export interface BareTemplateOption {
8
2
  name: string;
9
3
  value: string;
@@ -12,22 +12,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.loadBareTemplateOpts = exports.loadTutorialOpts = void 0;
15
+ exports.loadBareTemplateOpts = void 0;
16
16
  const axios_1 = __importDefault(require("axios"));
17
17
  const const_1 = require("../cfg/const");
18
- function loadTutorialOpts() {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- const githubUrl = `https://raw.githubusercontent.com/${const_1.dappTemplateGitRepoUserAndName}/${const_1.dappTemplateGitBranch}/${const_1.dappTemplateGitFolder}/${const_1.dappTemplateGitSelectOptionFile}`;
21
- try {
22
- const response = yield axios_1.default.get(githubUrl);
23
- return response.data;
24
- }
25
- catch (error) {
26
- throw new Error(`Error fetching JSON: ${error.message}`);
27
- }
28
- });
29
- }
30
- exports.loadTutorialOpts = loadTutorialOpts;
31
18
  function loadBareTemplateOpts() {
32
19
  return __awaiter(this, void 0, void 0, function* () {
33
20
  const githubUrl = `https://raw.githubusercontent.com/${const_1.dappTemplateGitRepoUserAndName}/${const_1.dappTemplateGitBranch}/${const_1.dappTemplateGitFolder}/${const_1.bareTemplateGitSelectOptionFile}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@offckb/cli",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "ckb development network for your first try",
5
5
  "author": "Retric Su <retric@cryptape.com>",
6
6
  "license": "MIT",
@@ -16,7 +16,8 @@
16
16
  "dist",
17
17
  "account",
18
18
  "ckb",
19
- "templates"
19
+ "templates/config.json",
20
+ "templates/offckb.config.ts"
20
21
  ],
21
22
  "private": false,
22
23
  "publishConfig": {
@@ -147,8 +147,8 @@ const mainnetLumosConfig: config.Config = { ...config.predefined.LINA, ...{} } a
147
147
 
148
148
  const offCKBConfig: OffCKBConfig = {
149
149
  version: 'update-me-offckb-config-version',
150
- lumosVersion: '0.21.0',
151
- contractBinFolder: '../../build/release',
150
+ lumosVersion: '0.21.1',
151
+ contractBinFolder: '../build/release',
152
152
  network: {
153
153
  devnet: {
154
154
  lumosConfig,
@@ -1,3 +0,0 @@
1
- import { TutorialOption } from '../util/template';
2
- export declare function init(name: string, template: TutorialOption): void;
3
- export declare function selectTemplate(): Promise<TutorialOption>;
package/dist/cmd/init.js DELETED
@@ -1,50 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.selectTemplate = exports.init = void 0;
16
- const const_1 = require("../cfg/const");
17
- const path_1 = __importDefault(require("path"));
18
- const select_1 = __importDefault(require("@inquirer/select"));
19
- const template_1 = require("../util/template");
20
- const fs_1 = require("../util/fs");
21
- const git_1 = require("../util/git");
22
- function init(name, template) {
23
- const targetPath = path_1.default.resolve(const_1.currentExecPath, name);
24
- const dappTemplateFolderPath = `${const_1.dappTemplateGitFolder}/${template.value}`;
25
- (0, git_1.gitCloneAndDownloadFolderSync)(const_1.dappTemplateGitUrl, const_1.dappTemplateGitBranch, dappTemplateFolderPath, targetPath);
26
- // add some common code files
27
- const ckbDotTs = path_1.default.resolve(const_1.dappTemplatePath, 'ckb.ts');
28
- const configJson = path_1.default.resolve(const_1.dappTemplatePath, 'config.json');
29
- (0, fs_1.copyFileSync)(ckbDotTs, targetPath);
30
- (0, fs_1.copyFileSync)(configJson, targetPath);
31
- console.log(`init CKB dapp project: ${targetPath}`);
32
- }
33
- exports.init = init;
34
- function selectTemplate() {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- const opts = yield (0, template_1.loadTutorialOpts)();
37
- const answer = yield (0, select_1.default)({
38
- message: 'Select an example dApp',
39
- choices: opts.map((opt) => {
40
- return {
41
- name: opt.name,
42
- value: opt.value,
43
- description: opt.description,
44
- };
45
- }),
46
- });
47
- return opts.find((opt) => opt.value === answer);
48
- });
49
- }
50
- exports.selectTemplate = selectTemplate;
package/templates/ckb.ts DELETED
@@ -1,11 +0,0 @@
1
- import { Indexer, RPC, config } from '@ckb-lumos/lumos';
2
- import devConfig from './config.json';
3
-
4
- export const lumosConfig: config.Config = devConfig as config.Config;
5
- //export const lumosConfig: config.Config = config.predefined.AGGRON4;
6
-
7
- export const CKB_RPC_URL = 'http://localhost:8114';
8
- //export const CKB_RPC_URL = "https://testnet.ckb.dev/rpc";
9
-
10
- export const rpc = new RPC(CKB_RPC_URL);
11
- export const indexer = new Indexer(CKB_RPC_URL);