Closed Keith-CY closed 1 year ago
https://github.com/ckb-js/kuai/issues/1#issuecomment-1280014575
Which directory should the api of a kuai project be placed in?
Which directory should the api of a kuai project be placed in?
How about creating a private demo repo and link dependencies to local kuai project
#1 (comment) Which directory should the api of a kuai project be placed in?
How about creating a private demo repo and link dependencies to local kuai project
Ok, I thought kuai project template included the api, similar to nestjs
#1 (comment) Which directory should the api of a kuai project be placed in?
How about creating a private demo repo and link dependencies to local kuai project
Ok, I thought kuai project template included the api, similar to nestjs
It would be better to provide a template of API service if we could.
The template could be added in kuai
and initialize a project by kuai-cli
linked locally
#1 (comment) Which directory should the api of a kuai project be placed in?
How about creating a private demo repo and link dependencies to local kuai project
Ok, I thought kuai project template included the api, similar to nestjs
Would you add a backend template or create a new project from scratch temporarily? If one of them will be done by you, I will finish the UI part. Or you can take over the UI part and I'm going to work on the server part
Would you add a backend template or create a new project from scratch temporarily? If one of them will be done by you, I will finish the UI part. Or you can take over the UI part and I'm going to work on the server part
Ok, I'm adding the api part to the initial project template. I can follow the documentation to mock api input and output first, and then integrate the specific logic after the store part is done.
And other qustion, mvp project files should be placed where, a new repository?
Would you add a backend template or create a new project from scratch temporarily? If one of them will be done by you, I will finish the UI part. Or you can take over the UI part and I'm going to work on the server part
Ok, I'm adding the api part to the initial project template. I can follow the documentation to mock api input and output first, and then integrate the specific logic after the store part is done.
And other qustion, mvp project files should be placed where, a new repository?
Opening a private repo in https://github.com/Magickbase/ is fine
How is it going
The current api server side code is here: https://github.com/Magickbase/kuai-mvp-server
run this projecy need link the local kuai package, the operating steps are written in readme.md
need review this peoject structure, if not problem , this structure will integrate to kuai init
as project template
create a pull request: https://github.com/Magickbase/kuai-mvp-server/pull/1
https://github.com/Magickbase/kuai-mvp-server/pull/1 has been approved by 2 reviewers and was merged into the main branch. Please add it in kuai as the backend template.
Will be pull request later
After the template
is ready in kuai, please add a directory named samples
, and use the cli to create an mvp-dapp
project in the directory, just as nest.js dis https://github.com/nestjs/nest/tree/master/sample @PainterPuppets
Once the mvp-dapp
skeleton is ready, we should start the actual coding. I'd like to divide the job into 3 tasks from the perspective of MVC
claim
, set
, clear
APIs are called, inputs and outputs will be returned from storage model, and should be transformed into a raw transaction to the front-endread
, load
APIs are called, structured data should be returned to the front-endschema
should be implemented additionally.Would you pick one up from tasks? @PainterPuppets @Daryl-L @yanguoyu
The tasks not picked will be arranged later(about 18:30 this day).
I will be doing the controller
part, which is more related to kuai/io
.
After the
template
is ready in kuai, please add a directory namedsamples
, and use the cli to create anmvp-dapp
project in the directory, just as nest.js dis https://github.com/nestjs/nest/tree/master/sample @PainterPuppetsOnce the
mvp-dapp
skeleton is ready, we should start the actual coding. I'd like to divide the job into 3 tasks from the perspective of MVC
View:
- when
claim
,set
,clear
APIs are called, inputs and outputs will be returned from storage model, and should be transformed into a raw transaction to the front-end- when
read
,load
APIs are called, structured data should be returned to the front-end- Controller: define the interface of APIs and parse arguments. The second function has been implemented by @kuai/io, so only function one should be considered. Mainly about the identity of requests cuz business logic is simple.
- Model: the storage model. The MVP dapp simply covers the preset methods, so only the
schema
should be implemented additionally.Would you pick one up from tasks? @PainterPuppets @Daryl-L @yanguoyu
The tasks not picked will be arranged later(about 18:30 this day).
I think the View
partial is front end in this project according to this demo, right?
After the
template
is ready in kuai, please add a directory namedsamples
, and use the cli to create anmvp-dapp
project in the directory, just as nest.js dis nestjs/nest@master
/sample @PainterPuppets Once themvp-dapp
skeleton is ready, we should start the actual coding. I'd like to divide the job into 3 tasks from the perspective of MVC
View:
- when
claim
,set
,clear
APIs are called, inputs and outputs will be returned from storage model, and should be transformed into a raw transaction to the front-end- when
read
,load
APIs are called, structured data should be returned to the front-end- Controller: define the interface of APIs and parse arguments. The second function has been implemented by @kuai/io, so only function one should be considered. Mainly about the identity of requests cuz business logic is simple.
- Model: the storage model. The MVP dapp simply covers the preset methods, so only the
schema
should be implemented additionally.Would you pick one up from tasks? @PainterPuppets @Daryl-L @yanguoyu The tasks not picked will be arranged later(about 18:30 this day).
I think the
View
partial is front end in this project according to this demo, right?
It could be done in either backend or front-end.
The main work of View
is to transform inputs
and outputs
into a transaction to sign.
If inputs
and outputs
are returned from API, front-end should construct the transaction and request a signature via metamask, then the View
is in UI.
If inputs
and outputs
are returned from model
but are constructed into a transaction just before responding to the front-end, then the View
is in backend.
Either is fine.
I think there is only Model
left for me. I will do it.
I'm going to finish View
part.
Will be pull request later
How is it going?
Will be pull request later
How is it going?
After the
template
is ready in kuai, please add a directory namedsamples
, and use the cli to create anmvp-dapp
project in the directory, just as nest.js dis nestjs/nest@master
/sample @PainterPuppetsOnce the
mvp-dapp
skeleton is ready, we should start the actual coding. I'd like to divide the job into 3 tasks from the perspective of MVC
View:
- when
claim
,set
,clear
APIs are called, inputs and outputs will be returned from storage model, and should be transformed into a raw transaction to the front-end- when
read
,load
APIs are called, structured data should be returned to the front-end- Controller: define the interface of APIs and parse arguments. The second function has been implemented by @kuai/io, so only function one should be considered. Mainly about the identity of requests cuz business logic is simple.
- Model: the storage model. The MVP dapp simply covers the preset methods, so only the
schema
should be implemented additionally.Would you pick one up from tasks? @PainterPuppets @Daryl-L @yanguoyu
The tasks not picked will be arranged later(about 18:30 this day).
Please create a project named mvp-dapp
in kuai/samples
, then we can start the coding of MVP @PainterPuppets
Model
, View
, and Controller
will be ready for code review by 02-03
Model
,View
, andController
will be ready for code review by 02-03
Any problem with proposing PRs for review today?
pr for resource binding to initiate Store
while registered #125
Model
,View
, andController
will be ready for code review by 02-03Any problem with proposing PRs for review today?
The PR for View
will be proposed as soon as possible rest of today. And I think the bootstrap is more complex than expected after finishing the ResourceBinding
, so I think maybe it is necessary for me to participate in.
Model definition. https://github.com/ckb-js/kuai/pull/126
View #127
View: https://github.com/ckb-js/kuai/pull/127 Controller: https://github.com/ckb-js/kuai/pull/124 Model: https://github.com/ckb-js/kuai/pull/126 have been merged, the backend service could be launched now
Some logic may have to be complemented in app.controller.ts
, all routes are expected to parse params/body, and redirect them to model
which returns inputs/outputs
or structured data
, then respond them via view
. If the response is a structured data, UI will render them directly, if the response is a transaction constructed by view
, UI will request a signature from metamask
Some logic may have to be complemented in
app.controller.ts
, all routes are expected to parse params/body, and redirect them tomodel
which returnsinputs/outputs
orstructured data
, then respond them viaview
. If the response is a structured data, UI will render them directly, if the response is a transaction constructed byview
, UI will request a signature from metamask
@PainterPuppets
We may need 2 models for the controller
The one that has been added(https://github.com/ckb-js/kuai/blob/develop/packages/samples/mvp-dapp/src/record/record.model.ts) works with a claimed
store, it can be set
, get
and load
, but cannot be initialized by the claim
method
So another model is required to transform a group of omnilock
cells into a store
cell(named record
in this case).
The possible workflow would be as follows:
model_a
gathers 10 61 CKB and turns them into 1 610 CKB with a specific pattern for record model
, say, data starts with
mvp_dapp`record model
syncs the 610 CKB cell by the pattern set by model_a
and returns the empty data structure
parsed from the 610 CKBrecord model
syncs the 610 CKB and adopts modification on it, returns inputs/outputs
, in this case, 610 CKB/610 CKB
Correct me if it doesn't work or is unnecessary @yanguoyu
We may need 2 models for the controller
The one that has been added(https://github.com/ckb-js/kuai/blob/develop/packages/samples/mvp-dapp/src/record/record.model.ts) works with a
claimed
store, it can beset
,get
andload
, but cannot be initialized by theclaim
methodSo another model is required to transform a group of
omnilock
cells into astore
cell(namedrecord
in this case).The possible workflow would be as follows:
- user => claim 610 CKB =>
model_a
gathers 10 61 CKB and turns them into 1 610 CKB with a specific pattern forrecord model
, say,data starts with
mvp_dapp`- user => load store =>
record model
syncs the 610 CKB cell by the pattern set bymodel_a
and returns the emptydata structure
parsed from the 610 CKB- user => set store =>
record model
syncs the 610 CKB and adopts modification on it, returnsinputs/outputs
, in this case,610 CKB/610 CKB
Correct me if it doesn't work or is unnecessary @yanguoyu
I thought ActorBase
is enough, it only needs to gather spec256
cells, and there are no data needed to serialize
or deserialize
.
We may need 2 models for the controller The one that has been added(
develop
/packages/samples/mvp-dapp/src/record/record.model.ts) works with aclaimed
store, it can beset
,get
andload
, but cannot be initialized by theclaim
method So another model is required to transform a group ofomnilock
cells into astore
cell(namedrecord
in this case). The possible workflow would be as follows: 1. user => claim 610 CKB =>model_a
gathers 10 61 CKB and turns them into 1 610 CKB with a specific pattern forrecord model
, say,data starts with
mvp_dapp2. user => load store =>
record modelsyncs the 610 CKB cell by the pattern set by
model_aand returns the empty
data structureparsed from the 610 CKB 3. user => set store =>
record modelsyncs the 610 CKB and adopts modification on it, returns
inputs/outputs, in this case,
610 CKB/610 CKB` Correct me if it doesn't work or is unnecessary @yanguoyuI thought
ActorBase
is enough, it only needs to gatherspec256
cells, and there are no data needed toserialize
ordeserialize
.
secp256k1
doesn't work with metamask, so omnilock
will be used, but it's not the point. My point is how can the record model
construct a cell to store data without a claim
action. Will the cells be gathered by demand, like,
Do you mean how to init a cell with initialization data? @Keith-CY
I think it may init like this:
Init the output cell's data by initOnChain
, and then gather needs capacity cells as inputs.
const initModel = new RecordModel()
const { data } = initModel.initOnChain({
data: {
profile: [],
addresses: [],
custom: [],
dweb: [],
}
})
const tx = {
inputs,
outputs,
outputs_data: [data]
}
Then broadcast the tx to init a cell
Do you mean how to init a cell with initialization data? @Keith-CY
I think it may init like this: Init the output cell's data by
initOnChain
, and then gather needs capacity cells as inputs.const initModel = new RecordModel() const { data } = initModel.initOnChain({ data: { profile: [], addresses: [], custom: [], dweb: [], } }) const tx = { inputs, outputs, outputs_data: [data] }
Then broadcast the tx to init a cell
Get it, except one point we can talk about later. If 2 services are running, without a pattern for record
, how can the cell initialized by service A be detected by service B
If 2 services are running, without a pattern for
record
, how can the cell initialized by service A be detected by service B
The above-defined RecordModel
is only used to get the outputs_data
, but not a RecordModel
for resource-binding, RecordModel
need to define a pattern with resource-binding.
After the tx is broadcast, service B will receive the tx and store it in record
by resource-binding.
If 2 services are running, without a pattern for
record
, how can the cell initialized by service A be detected by service BThe above-defined
RecordModel
is only used to get theoutputs_data
, but not aRecordModel
for resource-binding,RecordModel
need to define a pattern with resource-binding. After the tx is broadcast, service B will receive the tx and store it inrecord
by resource-binding.
Here's my understanding(https://github.com/ckb-js/kuai/issues/85#issuecomment-1368789335), but it was not confirmed or disputed by @Daryl-L
From the code(https://github.com/ckb-js/kuai/blob/develop/packages/models/src/resource-binding/manager.ts#L20) we can see that resource-binding
doesn't care about an explicit pattern, the key was roughly set type_script + lock_script
.
That means, not every cell sent from resource binding manager
to store
will update internal state of the store
, store
should filter out cells those not match pattern defined in store
If 2 services are running, without a pattern for
record
, how can the cell initialized by service A be detected by service BThe above-defined
RecordModel
is only used to get theoutputs_data
, but not aRecordModel
for resource-binding,RecordModel
need to define a pattern with resource-binding. After the tx is broadcast, service B will receive the tx and store it inrecord
by resource-binding.Here's my understanding(#85 (comment)), but it was not confirmed or disputed by @Daryl-L
From the code(https://github.com/ckb-js/kuai/blob/develop/packages/models/src/resource-binding/manager.ts#L20) we can see that
resource-binding
doesn't care about an explicit pattern, the key was roughly settype_script + lock_script
.That means, not every cell sent from
resource binding manager
tostore
will update internal state of thestore
,store
should filter out cells those not match pattern defined instore
Do you mean I forget to filter cells in handleCall
by pattern? If so, I will add it later.
If 2 services are running, without a pattern for
record
, how can the cell initialized by service A be detected by service BThe above-defined
RecordModel
is only used to get theoutputs_data
, but not aRecordModel
for resource-binding,RecordModel
need to define a pattern with resource-binding. After the tx is broadcast, service B will receive the tx and store it inrecord
by resource-binding.Here's my understanding(#85 (comment)), but it was not confirmed or disputed by @Daryl-L From the code(
develop
/packages/models/src/resource-binding/manager.ts#L20) we can see thatresource-binding
doesn't care about an explicit pattern, the key was roughly settype_script + lock_script
. That means, not every cell sent fromresource binding manager
tostore
will update internal state of thestore
,store
should filter out cells those not match pattern defined instore
Do you mean I forget to filter cells in
handleCall
by pattern? If so, I will add it later.
It should be done in resource-binding, but could be too hurry to finish it for now, filtering in store would be simple in the MVP dapp
If 2 services are running, without a pattern for
record
, how can the cell initialized by service A be detected by service BThe above-defined
RecordModel
is only used to get theoutputs_data
, but not aRecordModel
for resource-binding,RecordModel
need to define a pattern with resource-binding. After the tx is broadcast, service B will receive the tx and store it inrecord
by resource-binding.Here's my understanding(https://github.com/ckb-js/kuai/issues/85#issuecomment-1368789335), but it was not confirmed or disputed by @Daryl-L
From the code(https://github.com/ckb-js/kuai/blob/develop/packages/models/src/resource-binding/manager.ts#L20) we can see that
resource-binding
doesn't care about an explicit pattern, the key was roughly settype_script + lock_script
.That means, not every cell sent from
resource binding manager
tostore
will update internal state of thestore
,store
should filter out cells those not match pattern defined instore
So the resource binding manager should not only filter the cells by type script and lock script, but also parse the data with storage and filter the cells out by pattern, right?
If 2 services are running, without a pattern for
record
, how can the cell initialized by service A be detected by service BThe above-defined
RecordModel
is only used to get theoutputs_data
, but not aRecordModel
for resource-binding,RecordModel
need to define a pattern with resource-binding. After the tx is broadcast, service B will receive the tx and store it inrecord
by resource-binding.Here's my understanding(#85 (comment)), but it was not confirmed or disputed by @Daryl-L From the code(
develop
/packages/models/src/resource-binding/manager.ts#L20) we can see thatresource-binding
doesn't care about an explicit pattern, the key was roughly settype_script + lock_script
. That means, not every cell sent fromresource binding manager
tostore
will update internal state of thestore
,store
should filter out cells those not match pattern defined instore
So the resource binding manager should not only filter the cells by type script and lock script, but also parse the data with storage and filter the cells out by pattern, right?
We haven't discussed it much, so there's no conclusion yet.
For me, yes. Resource-binding means providing resources asked by others. Say that, module A declares that it wants A, B, C, to Z, they are all letters, then resource-binding should give letters to module A, but not characters which covers letters and digits.
However, in a meeting, we've talked about a compromise that resource-binding could provide a superset of cells to store
while store
filter them again to update its internal state.
This is my understanding of the MVP API process:
store
store
to save data
to state
store
store
store
to save data
to state
store
to set datainputs
and outputs
from store
store
to save data
to state
inputs
and outputs
from store
I think there are some things we need to implement:
store
, I don't know when we need to register store
and what will be set as the store
's path.ChainSource
to instantiate a resource-binding.inputs
, outputs
, and outputs_data
This is my understanding of the MVP API process:
- claim
- get init output_data create output by lock gather inputs * create tx and return
- read
- register lock/type by resource-binding generator/get
store
send message tostore
to savedata
tostate
* return data bystore
- set
- register lock/type by resource-binding generator/get
store
send message tostore
to savedata
tostate
send message tostore
to set data getinputs
andoutputs
fromstore
if capacity is not enough, gather extra inputs create tx and return- load: I think it seems as read when calling it without a path.
- clear
- register lock/type by resource-binding generator/get store send message to
store
to savedata
tostate
clear data by store getinputs
andoutputs
fromstore
* create tx and returnI think there are some things we need to implement:
- gather extra inputs when the inputs' capacity is not enough.
- generator and register
store
, I don't know when we need to registerstore
and what will be set as thestore
's path.- create an instance of
ChainSource
to instantiate a resource-binding.- gather a tx from
inputs
,outputs
, andoutputs_data
The confusion may come from the timing of claim
and register
a store
As the PRD(https://github.com/ckb-js/kuai/issues/54#issuecomment-1365629078) said
claim(capacity): Transaction
: claim a group of cells with a given capacity as the user infoStore
to store user info
claim(capacity)
gathers cells to instantiate a store
with empty data
. after claim
, a cell should be on the chain to hold the user's info. Then the user's info could be updated and loaded.
Besides, the capacity
of a store
is declared at first, so once data written to the cell is out of limit, it should be rejected.
Missing parts:
/claim/:address
model
and format responses with view
claim
method, assigned to @yanguoyu :
set
and return inputs/outputs
Model and claim method https://github.com/ckb-js/kuai/pull/137
PRD: https://github.com/ckb-js/kuai/issues/54