ckb-js / kuai

A protocol and framework for building universal dapps on Nervos CKB
MIT License
22 stars 11 forks source link

Kuai Usage Summary From Acceptance Team #532

Open Daryl-L opened 10 months ago

Daryl-L commented 10 months ago

This summary is from Lin Guopeng.

Compile

When he build the Kuai, the error sizzele error comes out. To solve this problem, he added the dom to the tsconfig.json in cli package.

DefinitelyTyped/DefinitelyTyped#52383

npm run build

> kuai@0.0.1 build
> npm run build:lib

> kuai@0.0.1 build:lib
> lerna run build

lerna notice cli v7.3.0

    ✔  @ckb-js/kuai-typeorm:build (2s)
    ✔  @ckb-js/kuai-common:build (4s)
    ✔  @ckb-js/kuai-docker-node:build (2s)
    ✔  @ckb-js/kuai-core:build (4s)

    ✖  @ckb-js/kuai-cli:build
       > @ckb-js/kuai-cli@0.0.1-alpha.2 build
       > tsc

       ../../../../node_modules/@types/sizzle/index.d.ts(14,82): error TS2304: Cannot find name 'Document'.
       ../../../../node_modules/@types/sizzle/index.d.ts(14,93): error TS2304: Cannot find name 'DocumentFragment'.
       ../../../../node_modules/@types/sizzle/index.d.ts(15,44): error TS2304: Cannot find name 'Document'.
       ../../../../node_modules/@types/sizzle/index.d.ts(15,55): error TS2304: Cannot find name 'DocumentFragment'.
       ../../../../node_modules/@types/sizzle/index.d.ts(41,58): error TS2304: Cannot find name 'Document'.
       npm ERR! Lifecycle script `build` failed with error: 
       npm ERR! Error: command failed 
       npm ERR!   in workspace: @ckb-js/kuai-cli@0.0.1-alpha.2 
       npm ERR!   at location: /Users/guopenglin/test_kuai/kuai/packages/cli 

    ✔  @ckb-js/kuai-io:build (4s)

 ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  Lerna (powered by Nx)   Ran target build for 9 projects (14s)

    ✔    5/6 succeeded [0 read from cache]

    ✖    1/6 targets failed, including the following:
         - @ckb-js/kuai-cli:build
Daryl-L commented 10 months ago

Deploy the Node

There is something wrong in Mac.


kuai node start
<jemalloc>: MADV_DONTNEED does not work (memset will be used instead)
<jemalloc>: (This is the expected behaviour if you are running under QEMU)

node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^
AxiosError: socket hang up
    at connResetException (node:internal/errors:720:14)
    at Socket.socketOnEnd (node:_http_client:525:23)
    at Socket.emit (node:events:529:35)
    at endReadableNT (node:internal/streams/readable:1368:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 'ECONNRESET',
...
  1. kuai node start --port 8200 the port is useless in this command.
  2. Users don't know the private key of the Node, and they should to enter into the container to find the private key from the config file of ckb.
  3. When the node starts, there is no omnilock script in config. Should users to add the config to predefined.config of lumos in the devnet?
Daryl-L commented 10 months ago

Deploy the Contract

  1. The version of capsule in capsule.toml is 0.9.0 which is generated in running kuai init. So maybe it is necessary to tell users to upgrade the capsule to the version 0.9.0.
cargo install ckb-capsule --git https://github.com/nervosnetwork/capsule.git --tag v0.9.0
  1. The ckb-cli should be installed before deploying the contract, and the private key should be imported to the ckb-cli.
ckb-cli account import  --privkey-path  ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80.json 
Password: 
address:
  mainnet: ckb1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq2ml7ehvnfcm86xc8xjezyvcnvu5w576rgmcuk83
  testnet: ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq2ml7ehvnfcm86xc8xjezyvcnvu5w576rg42hedf
address(deprecated):
  mainnet: ckb1qyq9hlanwexn3k05dswd9jyge3xeegafa5xs7nt0dl
  testnet: ckt1qyq9hlanwexn3k05dswd9jyge3xeegafa5xsrk4spr
lock_arg: 0x5bffb3764d38d9f46c1cd2c888cc4d9ca3a9ed0d
  1. It is not easy for most fresh users to build the contract.json by the transaction hash which is returned from the transcation of contract deployment.
{
  "kuai-mvp-contract": {
    "depType": "code",
    "outPoint": {
      "txHash": "0x005a153ec6a35adbc8d82544ae11d8c6f8c0601fc9059f8a872e01f638fc9f62",
      "index": "0x0"
    },
    "script": {
      "codeHash": "0x1a3de2a61b454e8492a775cf438748e362e71930170bec90c4e6b79e4dd7ea3c",
      "hashType": "type",
      "args": "0x"
    }
  }
}
Daryl-L commented 10 months ago

The MVP

  1. the npm run dev could exist caused by the timeout of calling ckb.
npm run dev

> kuai-mvp-dapp@0.0.1-alpha.2 dev
> ts-node src/main.ts

kuai app listening to http://127.0.0.1:3000
Registry `find` catch error Error: No matching bindings found for serviceIdentifier: local://0xf329effd1c475a2978453c8600e1eaf0bc2087ee093c3ee64cc96ec6847752cb/type/0x01f39fd6e51aad88f6f4ce6ab8827279cfffb9226600/record
    at _validateActiveBindingCount (/Users/guopenglin/test_kuai/kuai/node_modules/inversify/src/planning/planner.ts:113:15)
    at _getActiveBindings (/Users/guopenglin/test_kuai/kuai/node_modules/inversify/src/planning/planner.ts:91:3)
    at _createSubRequests (/Users/guopenglin/test_kuai/kuai/node_modules/inversify/src/planning/planner.ts:146:22)
    at plan (/Users/guopenglin/test_kuai/kuai/node_modules/inversify/src/planning/planner.ts:240:5)
    at /Users/guopenglin/test_kuai/kuai/node_modules/inversify/src/container/container.ts:623:25
    at Container._get (/Users/guopenglin/test_kuai/kuai/node_modules/inversify/src/container/container.ts:574:37)
    at Container._getButThrowIfAsync (/Users/guopenglin/test_kuai/kuai/node_modules/inversify/src/container/container.ts:580:25)
    at Container.get (/Users/guopenglin/test_kuai/kuai/node_modules/inversify/src/container/container.ts:325:17)
    at Registry.<anonymous> (/Users/guopenglin/test_kuai/kuai/packages/models/lib/actor/registry.js:25:87)
    at Registry.findOrBind (/Users/guopenglin/test_kuai/kuai/packages/models/lib/actor/registry.js:50:85)
Registry `find` catch error Error: No matching bindings found for serviceIdentifier: local://0x01f39fd6e51aad88f6f4ce6ab8827279cfffb9226600/omnilock
    at _validateActiveBindingCount (/Users/guopenglin/test_kuai/kuai/node_modules/inversify/src/planning/planner.ts:113:15)
    at _getActiveBindings (/Users/guopenglin/test_kuai/kuai/node_modules/inversify/src/planning/planner.ts:91:3)
    at _createSubRequests (/Users/guopenglin/test_kuai/kuai/node_modules/inversify/src/planning/planner.ts:146:22)
    at plan (/Users/guopenglin/test_kuai/kuai/node_modules/inversify/src/planning/planner.ts:240:5)
    at /Users/guopenglin/test_kuai/kuai/node_modules/inversify/src/container/container.ts:623:25
    at Container._get (/Users/guopenglin/test_kuai/kuai/node_modules/inversify/src/container/container.ts:574:37)
    at Container._getButThrowIfAsync (/Users/guopenglin/test_kuai/kuai/node_modules/inversify/src/container/container.ts:580:25)
    at Container.get (/Users/guopenglin/test_kuai/kuai/node_modules/inversify/src/container/container.ts:325:17)
    at Registry.<anonymous> (/Users/guopenglin/test_kuai/kuai/packages/models/lib/actor/registry.js:25:87)
    at Registry.findOrBind (/Users/guopenglin/test_kuai/kuai/packages/models/lib/actor/registry.js:50:85)
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "AxiosError: timeout of 30000ms exceeded".] {
  code: 'ERR_UNHANDLED_REJECTION'
}
npm ERR! Lifecycle script `dev` failed with error: 
npm ERR! Error: command failed 
npm ERR!   in workspace: kuai-mvp-dapp@0.0.1-alpha.2 
npm ERR!   at location: /Users/guopenglin/test_kuai/kuai/packages/samples/mvp-dapp
  1. Unit test should be added to the MVP project.
  2. It is not timely for model to update the chainData when call the api /meta/:address.
  3. Is it necessary to explain how does the model update the data?
  4. It is convenient for users to learn how to write unit tests by adding a valid address of /load:address` in mvp unit tests.
  5. Users may need to learn the moleculec which is used in the MVP contract.
  6. The MVP contract may use the moleculec, but I did not see any serializing and deserializing in the project. Is it a json string?
Daryl-L commented 10 months ago

Something more in kuai/models

  1. Comments should be added into the Store class to explain the meanings of the parameters.

  2. https://github.com/ckb-js/kuai/blob/879251ffabb010064c1631acbf4f7c60c5c777a6/packages/models/src/store/store.ts#L52-L74