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: merge doc v2 version into production #276

Merged
merged 69 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
d8f803f
refactor: update folder structure for new design (#213)
RetricSu Mar 4, 2024
4ad7410
refactor: update docusaurus v3.1.1 (#214)
RetricSu Mar 4, 2024
f786929
refactor: update some files (#215)
RetricSu Mar 4, 2024
c7dad4b
refactor: rm .dockerignore (#216)
RetricSu Mar 4, 2024
ddcde61
Update general styling & overall structure
yfeng2824 Mar 6, 2024
dff4bbf
Merge pull request #217 from nervosnetwork/update-styling
yfeng2824 Mar 6, 2024
0175b9f
add card component (#218)
yfeng2824 Mar 7, 2024
f375ded
Added an EcoCard component & update ecosystem page
yfeng2824 Mar 7, 2024
b8593cf
update copies & redirect users to /docs
yfeng2824 Mar 8, 2024
ed613e9
Merge pull request #219 from nervosnetwork/component-ecoCard
roughpandaz Mar 11, 2024
3bdd595
feat: add dapp examples (#220)
RetricSu Mar 12, 2024
e5cfb4a
update styling of codeblock (#222)
yfeng2824 Mar 14, 2024
5df94cc
feat: create-custom-token & transfer docs and testnet sandbox (#221)
RetricSu Mar 14, 2024
fc896d0
feat: add write & read message examples (#223)
RetricSu Mar 14, 2024
1e45b33
feat: add spore tutorial and doc (#224)
RetricSu Mar 15, 2024
27f5236
feat: embed reset testnet examples in codebox (#226)
RetricSu Mar 16, 2024
c5abf11
feat: add transfer token to xUDT tutorial, rm the standalone transfer…
RetricSu Mar 16, 2024
8f8260e
feat: add example select options json (#229)
RetricSu Mar 18, 2024
8392b5c
docs: add README for examples (#230)
RetricSu Mar 18, 2024
48b534c
Update view-and-transfer-balance.md (#231)
RetricSu Mar 18, 2024
a271bef
Update create-custom-token.md (#232)
RetricSu Mar 18, 2024
3b41d24
Edit Tutorial Content (#233)
anipenguin Mar 18, 2024
bfd696b
Update cell-model.md
linnnsss Mar 18, 2024
ca1a778
Update consensus.md
linnnsss Mar 18, 2024
2e87770
Update economics.md
linnnsss Mar 18, 2024
5101199
Update ckb-vm.md
linnnsss Mar 18, 2024
e475924
Apply suggestions from code review
RetricSu Mar 18, 2024
86a0c75
Update ckb-vm.md
linnnsss Mar 19, 2024
3d44c03
Update consensus.md
linnnsss Mar 19, 2024
98da3ed
Update cryptowallet.md (#239)
linnnsss Mar 19, 2024
411d510
Merge pull request #235 from linnnsss/concepts-v2-cell-model
roughpandaz Mar 19, 2024
f96563d
Merge pull request #237 from linnnsss/concepts-v2-tokenomics
roughpandaz Mar 19, 2024
1080421
Merge pull request #236 from linnnsss/concepts-v2-consensus
roughpandaz Mar 19, 2024
5c02fe7
Merge pull request #238 from linnnsss/concepts-v2-vm
roughpandaz Mar 19, 2024
693b6ca
Update navbar & devtool & sidebar (#242)
yfeng2824 Mar 19, 2024
1996cfc
fix: use embed share url for codesandbox (#243)
RetricSu Mar 20, 2024
b09e765
Update the RPC page (#244)
yfeng2824 Mar 20, 2024
a61dfbe
fix: examples testnet bugs (#245)
RetricSu Mar 20, 2024
cef2e9a
chore: add example readme and rename nft -> dob (#246)
RetricSu Mar 20, 2024
6a11a41
Update wallet display
yfeng2824 Mar 20, 2024
19c03de
Merge pull request #247 from nervosnetwork/update-wallet-display
roughpandaz Mar 20, 2024
b815b22
Refactor: header/switch-testnet components and some wording (#248)
RetricSu Mar 20, 2024
50933b1
chore: update dev-environment doc (#249)
RetricSu Mar 20, 2024
9693a00
fix: create-dob embed codesandbox (#250)
RetricSu Mar 20, 2024
f5a4f63
update: text updates and styling (#251)
roughpandaz Mar 21, 2024
c81b2ed
update general styling
yfeng2824 Mar 21, 2024
6dfca5a
rename dapp to dapps
Mar 21, 2024
3448122
Merge pull request #252 from nervosnetwork/update-03/21
roughpandaz Mar 21, 2024
77640bf
Update Ecosystem page
yfeng2824 Mar 22, 2024
86623fe
fix image links
yfeng2824 Mar 22, 2024
0201d80
fix doc image
yfeng2824 Mar 22, 2024
ab3c985
Merge pull request #253 from nervosnetwork/update-ecosystem
roughpandaz Mar 22, 2024
fd0101d
fix: dapp links
Mar 27, 2024
cd7135f
Merge pull request #255 from nervosnetwork/rongxin/link-fix
roughpandaz Mar 27, 2024
bc01a06
Simplify wording in tutorials & dev environment
yfeng2824 Mar 27, 2024
7de7a40
Merge pull request #256 from nervosnetwork/update-wording
roughpandaz Mar 27, 2024
25b643b
chore: redirect old-doc to v1 vercel (#257)
RetricSu Mar 28, 2024
b5a0b98
chore: update google gtag (#259)
RetricSu Mar 29, 2024
1f227d8
Update glossary.md
linnnsss Apr 2, 2024
6e0810a
chore: update name for example options (#273)
RetricSu Apr 3, 2024
70e956e
fix: update 61CKB link
RetricSu Apr 3, 2024
b75c07f
Merge pull request #270 from linnnsss/glossary-v2-script-xudt
roughpandaz Apr 3, 2024
9a83db5
Update general UI + structure + wording (#269)
yfeng2824 Apr 3, 2024
91bcd69
Merge pull request #274 from RetricSu/61ckb-link
roughpandaz Apr 3, 2024
71f31af
feat: use local-search (#271)
RetricSu Apr 3, 2024
97e3913
fix: update readme link in examples (#275)
RetricSu Apr 3, 2024
f86ae1b
update editURL
yfeng2824 Apr 3, 2024
49f44d7
fix: link from develop-v2 branch to develop (#277)
RetricSu Apr 3, 2024
640b12f
updated couple links
yfeng2824 Apr 3, 2024
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
2 changes: 0 additions & 2 deletions .dockerignore

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16.x
node-version: 18.x
cache: yarn
cache-dependency-path: website/yarn.lock
- name: Build website
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16.x
node-version: 18.x
cache: yarn
cache-dependency-path: website/yarn.lock
- name: Test build
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ node_modules
lib/core/metadata.js
lib/core/MetadataBlog.js

examples/**/config.json

website/translated_docs
website/build/
website/node_modules
Expand Down
28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

10 changes: 0 additions & 10 deletions Dockerfile

This file was deleted.

18 changes: 0 additions & 18 deletions docker-compose.yml

This file was deleted.

25 changes: 25 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Tutorial Dapp Templates

The Dapp templates often involve interaction with some most useful smart contracts on CKB like xUDT/Spore/Omnilock. Not only can these templates run on CKB Testnet, but also can be initialized as development projects targeting local Blockchain with the help of our CLI tool [offckb](https://github.com/RetricSu/offckb). And the best thing is they come with full detailed tutorial documents!

## Add Dapp templates

Assuming you are trying to add a new template named `my-awesome-template`:

1. add your typescript project to the docs site's example folder: `https://github.com/nervosnetwork/docs.nervos.org/tree/develop-v2/examples/my-awesome-template`
2. copy `templates/ckb.ts` and `templates/config.json` from `offckb` Github repo into your project
- `cp offckb/templates/ckb.ts docs.nervos.org/examples/my-awesome-template`
- `cp offckb/templates/config.json docs.nervos.org/examples/my-awesome-template`
3. finish your `my-awesome-template` with `ckb.ts`, use `offckb` to start a devnet
4. once your project is ready on the local Blockchain, rewrite the `ckb.ts` file to support CKB Testnet
5. update the `options.json` file: `https://github.com/nervosnetwork/docs.nervos.org/tree/develop-v2/examples/options.json`
6. done

## Template Pattern

All Dapp templates must meet the requirements:

- Dapp must be able to run on the CKB Testnet by default
- Dapp must be able to be initialized with `offckb` to run on devnet
- place a `ckb.ts` file in your root folder to manage CKB chain config like RPC URLs.
- use `ckb.ts` to export the `lumosConfig`
2 changes: 2 additions & 0 deletions examples/create-dob/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.parcel-cache
dist
35 changes: 35 additions & 0 deletions examples/create-dob/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# View & Transfer Balance

This is a simple Dapp example to show how to create and view digital objects on the CKB blockchain. Read the step-by-step [tutorial](https://docs.nervos.org/docs/getting-started/create-dob) to understand how it works.

## How to run

### On Testnet

By default, this example can be cloned and directly run on the [CKB Testnet](https://pudge.explorer.nervos.org/):

```sh
git clone https://github.com/nervosnetwork/docs.nervos.org.git
cd docs.nervos.org.git/examples/create-dob
yarn && yarn start
```

### On Devnet

It can also run on the local Blockchain, aka a CKB Devnet. To do this, you need to update the Lumos config defined in the `ckb.ts` file and related codes. Another way to automatically cover these steps is to install and use a CLI tool [`offckb`](https://github.com/RetricSu/offckb).

```sh
npm install -g offckb

# start the devnet
offckb node

# init project
offckb init my-dob
# select the templates for create-on-chain-digital-objects to get initialized
# ...

# start the app
cd my-dob
yarn && yarn start
```
11 changes: 11 additions & 0 deletions examples/create-dob/ckb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Indexer, RPC, config } from "@ckb-lumos/lumos";
//import devConfig from './config.json';

//export const lumosConfig: config.Config = devConfig as config.Config;
export const lumosConfig = config.predefined.AGGRON4 as config.Config;

//export const CKB_RPC_URL = 'http://localhost:8114';
export const CKB_RPC_URL = "https://testnet.ckb.dev/rpc";

export const rpc = new RPC(CKB_RPC_URL);
export const indexer = new Indexer(CKB_RPC_URL);
131 changes: 131 additions & 0 deletions examples/create-dob/helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import {
defaultEmptyWitnessArgs,
updateWitnessArgs,
isScriptValueEquals,
getSporeConfig,
} from "@spore-sdk/core";
import {
hd,
helpers,
RPC,
Address,
Hash,
Script,
HexString,
commons,
} from "@ckb-lumos/lumos";

export interface Wallet {
lock: Script;
address: Address;
signMessage(message: HexString): Hash;
signTransaction(
txSkeleton: helpers.TransactionSkeletonType
): helpers.TransactionSkeletonType;
signAndSendTransaction(
txSkeleton: helpers.TransactionSkeletonType
): Promise<Hash>;
}

/**
* Create a CKB Default Lock (Secp256k1Blake160 Sign-all) Wallet by a private-key and a SporeConfig,
* providing lock/address, and functions to sign message/transaction and send the transaction on-chain.
*/
export function createDefaultLockWallet(privateKey: HexString): Wallet {
const config = getSporeConfig();

// Generate a lock script from the private key
const defaultLock = config.lumos.SCRIPTS.SECP256K1_BLAKE160!;
const lock: Script = {
codeHash: defaultLock.CODE_HASH,
hashType: defaultLock.HASH_TYPE,
args: hd.key.privateKeyToBlake160(privateKey),
};

// Generate address from the lock script
const address = helpers.encodeToAddress(lock, {
config: config.lumos,
});

// Sign for a message
function signMessage(message: HexString): Hash {
return hd.key.signRecoverable(message, privateKey);
}

// Sign prepared signing entries,
// and then fill signatures into Transaction.witnesses
function signTransaction(
txSkeleton: helpers.TransactionSkeletonType
): helpers.TransactionSkeletonType {
const signingEntries = txSkeleton.get("signingEntries");
const signatures = new Map<HexString, Hash>();
const inputs = txSkeleton.get("inputs");

let witnesses = txSkeleton.get("witnesses");
for (let i = 0; i < signingEntries.size; i++) {
const entry = signingEntries.get(i)!;
if (entry.type === "witness_args_lock") {
// Skip if the input's lock does not match to the wallet's lock
const input = inputs.get(entry.index);
if (!input || !isScriptValueEquals(input.cellOutput.lock, lock)) {
continue;
}

// Sign message
if (!signatures.has(entry.message)) {
const sig = signMessage(entry.message);
signatures.set(entry.message, sig);
}

// Update signature to Transaction.witnesses
const signature = signatures.get(entry.message)!;
const witness = witnesses.get(entry.index, defaultEmptyWitnessArgs);
witnesses = witnesses.set(
entry.index,
updateWitnessArgs(witness, "lock", signature)
);
}
}

return txSkeleton.set("witnesses", witnesses);
}

// Sign the transaction and send it via RPC
async function signAndSendTransaction(
txSkeleton: helpers.TransactionSkeletonType
): Promise<Hash> {
// 1. Sign transaction
txSkeleton = commons.common.prepareSigningEntries(txSkeleton, {
config: config.lumos,
});
txSkeleton = signTransaction(txSkeleton);

// 2. Convert TransactionSkeleton to Transaction
const tx = helpers.createTransactionFromSkeleton(txSkeleton);

console.log("tx", tx);

// 3. Send transaction
const rpc = new RPC(config.ckbNodeUrl);
return await rpc.sendTransaction(tx, "passthrough");
}

return {
lock,
address,
signMessage,
signTransaction,
signAndSendTransaction,
};
}

export function hexStringToUint8Array(hexString: string): Uint8Array {
const len = hexString.length;
const buffer = new Uint8Array(len / 2);

for (let i = 0; i < len; i += 2) {
buffer[i / 2] = parseInt(hexString.substr(i, 2), 16);
}

return buffer;
}
13 changes: 13 additions & 0 deletions examples/create-dob/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>View and Transfer Balance</title>
</head>
<body>
<div id="root"></div>
<script src="index.tsx" type="module"></script>
</body>
</html>
Loading
Loading