Skip to content

Commit

Permalink
Merge pull request #42 from nervina-labs/develop
Browse files Browse the repository at this point in the history
Release v0.4.7
  • Loading branch information
duanyytop authored Jun 9, 2022
2 parents 30ef9f1 + 3d45142 commit fff2e8e
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 40 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
/target/
.idea
.env
store.db/
store.db/
.vscode
103 changes: 78 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[package]
name = "cota-registry-aggregator"
version = "0.4.6"
version = "0.4.7"
edition = "2018"

[dependencies]
jsonrpc-http-server = "18.0.0"
env_logger = "0.9"
log = {version = "0.4", features = ["release_max_level_debug", "max_level_debug"]}
rocksdb = { package = "ckb-rocksdb", version = "=0.16.2", features = ["snappy"] }
rocksdb = { package = "ckb-rocksdb", version = "=0.18.0", features = ["snappy"] }
hex = "0.4"
failure = "0.1.8"
lazy_static = "1.4"
crc = "2.1.0"
crc = "3.0.0"
chrono = "0.4"
diesel = { version = "1.4.8", features = ["mysql", "r2d2", "numeric"] }
dotenv = "0.15.0"
Expand All @@ -20,7 +20,7 @@ serde = { version = "1.0", features = [ "derive" ] }
sparse-merkle-tree = "0.5.3"
ckb-types = "=0.101.8"
ckb-jsonrpc-types = ">=0.103.0"
parking_lot = "0.12.0"
parking_lot = "0.12.1"
reqwest = { version = "0.11", features = ["json"] }
serde_json = "1.0"
cota-smt = {package = "cota-smt", git = "https://github.com/nervina-labs/cota-smt", tag = "0.1.0"}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:1.60 as builder
FROM rust:1.61 as builder

WORKDIR /app

Expand Down
36 changes: 29 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

The registry aggregator service of [CoTA](https://talk.nervos.org/t/rfc-cota-a-compact-token-aggregator-standard-for-extremely-low-cost-nfts-and-fts/6338)

[CoTA Docs](https://developer.mibao.net/docs/develop/cota/overview)
[CoTA Docs](https://developer.mibao.net/docs/cota/overview)

## Prerequisites

Expand All @@ -16,6 +16,7 @@ The registry aggregator service of [CoTA](https://talk.nervos.org/t/rfc-cota-a-c
- `mysql-client` for macOS: `brew install mysql-client`

If the output is as blow:

```shell
If you need to have mysql-client first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/mysql-client/bin:$PATH"' >> ~/.zshrc
Expand All @@ -24,16 +25,17 @@ For compilers to find mysql-client you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/mysql-client/lib"
export CPPFLAGS="-I/opt/homebrew/opt/mysql-client/include"
```

Then put the `RUSTFLAGS='-L/opt/homebrew/opt/mysql-client/lib'` before `cargo build` and `cargo test`

## Quick Start

### Manual

- Rename `.env.example` to `.env`
- Update the database connection string in `DATABASE_URL` key
- Update the ckb-indexer url string in `CKB_INDEXER`
- Update the miannet or testnet in `IS_MAINNET`
- Update the database connection string in `DATABASE_URL` key
- Update the ckb-indexer url string in `CKB_INDEXER`
- Update the miannet or testnet in `IS_MAINNET`
- Build with release profile: `make build-release`
- Run with release profile: `make run-release`

Expand All @@ -43,9 +45,10 @@ Then put the `RUSTFLAGS='-L/opt/homebrew/opt/mysql-client/lib'` before `cargo bu
RUST_LOG=info DATABASE_URL=mysql://root:passport@localhost:3306/db_name CKB_INDEXER=http://localhost:8116 IS_MAINNET=false ./target/release/cota-registry-aggregator
```


### docker

> The RocksDB data of SMT will be saved into `src/store.db`, so the store.db should be mounted into docker. E.g. `-v "$(pwd)":/app/store.db`
```shell
# Build cota-aggregator images from the Dockerfile and run cota-aggregator via docker
docker build -t cota-registry-aggregator .
Expand All @@ -62,10 +65,14 @@ testnet:
https://cota.nervina.dev/registry-aggregator
```

## SDK

[SDK](https://github.com/nervina-labs/cota-sdk-js) can help you implement RPC APIs call and build ckb transactions

## APIs

### register_cota_cells

**Register cota cells through lock hashes**

- Everyone should register cota cell before minting or transferring CoTA NFTs
Expand All @@ -85,6 +92,14 @@ echo '{
http://localhost:3050
```

#### Response

```
block_number - The latest block number of cota-nft-entries-syncer
registry_smt_entry - The SMT registry information (origin SMT leaves, SMT proof and other information)
smt_root_hash - The latest SMT root hash after registry
```

```shell
{
"jsonrpc":"2.0",
Expand Down Expand Up @@ -114,6 +129,13 @@ echo '{
http://localhost:3050
```

#### Response

```
block_number - The latest block number of cota-nft-entries-syncer
registered - true for registered and false for unregistered
```

```shell
{
"jsonrpc":"2.0",
Expand All @@ -123,4 +145,4 @@ http://localhost:3050
},
"id":2
}
```
```
Loading

0 comments on commit fff2e8e

Please sign in to comment.