Skip to content

Commit 918c390

Browse files
committed
Merge branch 'release/0.0.2'
2 parents 70c54aa + 87ffb02 commit 918c390

31 files changed

+215
-90
lines changed

.github/ISSUE_TEMPLATE/bug.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: "🐛 Bug"
22
description: File a bug/issue
3-
title: "[BUG] <title>"
3+
title: ":bug: <title>"
44
labels: ["bug", "triage"]
55
# projects: []
66
# assignees: []

.github/ISSUE_TEMPLATE/feature.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: "✨ Feature"
22
description: Request a feature
3-
title: "[Feature] <title>"
3+
title: ":sparkles: <title>"
44
labels: ["feature", "triage"]
55
# projects: []
66
# assignees: []

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.env.*
33
/migrations/dev
44
/migrations/joyid
5-
/migrations/ckb_auth
5+
/migrations/omnilock
66

77
# CKB
88
/ckb-miner.toml

bin/deploy-to-dev-chain.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ bin/generate-blocks.sh 4
4040
sleep 1
4141

4242
# try twice in case the indexer has not updated yet
43-
deploy ckb_auth || deploy ckb_auth
43+
deploy omnilock || deploy omnilock
4444
bin/generate-blocks.sh 4
4545

4646
bin/use-env.sh >.env

bin/dev-faucet.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
set -u
5+
[ -n "${DEBUG:-}" ] && set -x || true
6+
7+
ckb-cli wallet transfer --skip-check-to-address --to-address "$1" --capacity 300000 --privkey-path specs/miner.key

bin/download-contracts.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,4 @@ download joyid_dep3 0x95ecf9b41701b45d431657a67bbfa3f07ef7ceb53bf87097f3674e1a4a
3030
# download joyid_dep4 0x8f8c79eb6671709633fe6a46de93c0fedc9c1b8a6527a18d3983879542635c9f 3
3131
download joyid_dep5 0x8b3255491f3c4dcc1cfca33d5c6bcaec5409efe4bbda243900f9580c47e0242e 1
3232

33-
download ckb_auth 0xd4f72f0504373ff8effadf44f92c46a0062774fb585ebcacc24eb47b98e2d66a 0
34-
download unisat_lock 0xe842b43df31c92d448fa345d60a6df3e03aaab19ef88921654bf95c673a26872 0
33+
download omnilock 0xff234bf2fb0ad2ab5b356ceda317d3dee3efb2c55b9427ef55d9dcbf6eecbf9f 0

bin/generate-blocks.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CKB_RPC_URL="${CKB_RPC_URL:-http://127.0.0.1:8114}"
44

55
function generate_one() {
66
curl --request POST \
7+
-H "Content-Type: application/json" \
78
--url "$CKB_RPC_URL" \
89
--data '{
910
"id": 42,

bin/generate-epochs.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CKB_RPC_URL="${CKB_RPC_URL:-http://127.0.0.1:8114}"
55
function generate() {
66
local n="$(printf '%x' "${1:-1}")"
77
curl --request POST \
8+
-H "Content-Type: application/json" \
89
--url http://127.0.0.1:8114/ \
910
--data '{
1011
"id": 42,

bin/run-dev-miner.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ set -u
66

77
function has_tx() {
88
curl --request POST \
9+
-H "Content-Type: application/json" \
910
--silent \
1011
--url http://127.0.0.1:8114/ \
1112
--data '{

bin/use-env.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ case "${1:-}" in
2424
esac
2525

2626
JOYID_INFO_FILE="$(ls migrations/joyid/*.json | grep -v deployment | head -n 1)"
27-
CKB_AUTH_INFO_FILE="$(ls migrations/ckb_auth/*.json | grep -v deployment | head -n 1)"
27+
OMNILOCK_INFO_FILE="$(ls migrations/omnilock/*.json | grep -v deployment | head -n 1)"
2828

2929
sed -n \
3030
-e 's/,$//' \
@@ -38,10 +38,10 @@ sed -n \
3838

3939
sed -n \
4040
-e 's/,$//' \
41-
-e 's/^ *"type_id": "/NEXT_PUBLIC_UNISAT_CODE_HASH="/p' \
42-
"$CKB_AUTH_INFO_FILE" | head -1
41+
-e 's/^ *"type_id": "/NEXT_PUBLIC_OMNILOCK_CODE_HASH="/p' \
42+
"$OMNILOCK_INFO_FILE" | head -1
4343

4444
sed -n \
4545
-e 's/,$//' \
46-
-e 's/^ *"tx_hash": /NEXT_PUBLIC_AUTH_TX_HASH=/p' \
47-
"$CKB_AUTH_INFO_FILE" | tail -1
46+
-e 's/^ *"tx_hash": /NEXT_PUBLIC_OMNILOCK_TX_HASH=/p' \
47+
"$OMNILOCK_INFO_FILE" | tail -1

docs/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ We love your input! We want to make contributing to this project as easy and tra
1212

1313
We use github to host code, to track issues and feature requests, as well as accept pull requests.
1414

15-
## Pull Requests and [Changesets](https://github.com/changesets/changesets)
15+
## Pull Requests
1616

1717
Pull requests are the best way to propose changes to the codebase. We actively welcome your pull requests:
1818

docs/dev.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Connect a wallet and copy the CKB address displayed at the top of the page.
5656
Transfer some CKB tokens from the miner account to the copied address. Replace `ckbt1qz...` with the real address in the following command.
5757

5858
```bash
59-
ckb-cli wallet transfer --skip-check-to-address --to-address ckt1qz... --capacity 300000 --privkey-path specs/miner.key
59+
bin/dev-faucet.sh ckt1qz...
6060
```
6161

6262
Mine some blocks to commit the transfer transaction.

migrations/templates/ckb_auth.toml

Lines changed: 0 additions & 19 deletions
This file was deleted.

migrations/templates/omnilock.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[[cells]]
2+
name = "omnilock"
3+
enable_type_id = true
4+
location = { file = "build/release/omnilock" }
5+
6+
# The lock script set to output cells
7+
[lock]
8+
code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
9+
args = "0xc8328aabcd9b9e8e64fbc566c4385c3bdeb219d7"
10+
hash_type = "type"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ckb-dao-cobuild-poc",
33
"type": "module",
4-
"version": "0.0.1",
4+
"version": "0.0.2",
55
"private": true,
66
"scripts": {
77
"dev": "next dev",

src/app/connector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export default function Connector() {
8585
connections = await walletSelector.connect(wallet);
8686
} catch (err) {
8787
console.error(err.stack);
88-
reset(err.toString());
88+
reset(err.message ?? err.toString());
8989
return;
9090
}
9191

src/app/u/[wallet]/[connection]/account-header.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
import * as walletSelector from "@/lib/wallet/selector";
21
import SignOut from "./sign-out";
32

43
export default function AccountHeader({
54
address,
65
wallet,
76
connection,
8-
config: { ckbChain },
7+
config: { ckbChain, ckbChainConfig },
98
}) {
10-
const walletName = walletSelector.walletName(wallet);
11-
129
return (
1310
<header>
1411
<SignOut
15-
walletName={walletName}
12+
wallet={wallet}
1613
connection={connection !== address ? connection : null}
14+
address={address}
15+
ckbChainConfig={ckbChainConfig}
1716
/>
1817

1918
<p className="break-all">

src/app/u/[wallet]/[connection]/sign-form.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default function SignForm({
4444
);
4545
} catch (err) {
4646
console.error(err.stack);
47-
setError(err.toString());
47+
setError(err.message ?? err.toString());
4848
}
4949
};
5050

src/app/u/[wallet]/[connection]/sign-out.js

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,71 @@
11
"use client";
22

3-
import { useRouter } from "next/navigation";
3+
import * as walletSelector from "@/lib/wallet/selector";
44
import { Dropdown } from "flowbite-react";
5+
import { useRouter } from "next/navigation";
6+
import * as lumosHelpers from "@ckb-lumos/helpers";
7+
8+
export function LockScriptName({ lockScriptName, address, ckbChainConfig }) {
9+
if (
10+
ckbChainConfig.EXPLORER_URL !== null &&
11+
ckbChainConfig.EXPLORER_URL !== undefined
12+
) {
13+
const script = lumosHelpers.addressToScript(address, {
14+
config: ckbChainConfig,
15+
});
16+
const href = `${ckbChainConfig.EXPLORER_URL}/script/${script.codeHash}/${script.hashType}`;
17+
return (
18+
<a
19+
className="inline-flex items-center font-medium text-blue-600 hover:underline"
20+
href={href}
21+
rel="noopener noreferrer"
22+
target="_blank"
23+
>
24+
{lockScriptName}
25+
<svg
26+
class="w-4 h-4 ms-2 rtl:rotate-180"
27+
aria-hidden="true"
28+
xmlns="http://www.w3.org/2000/svg"
29+
fill="none"
30+
viewBox="0 0 14 10"
31+
>
32+
<path
33+
stroke="currentColor"
34+
stroke-linecap="round"
35+
stroke-linejoin="round"
36+
stroke-width="2"
37+
d="M1 5h12m0 0L9 1m4 4L9 9"
38+
/>
39+
</svg>
40+
</a>
41+
);
42+
}
43+
return <span>{lockScriptName}</span>;
44+
}
45+
46+
export default function SignOut({
47+
wallet,
48+
connection,
49+
address,
50+
ckbChainConfig,
51+
}) {
52+
const walletName = walletSelector.walletName(wallet);
53+
const lockScriptNameProps = {
54+
lockScriptName: walletSelector.lockScriptName(wallet),
55+
address,
56+
ckbChainConfig,
57+
};
558

6-
export default function SignOut({ walletName, connection }) {
759
const router = useRouter();
860
return (
961
<aside className="not-prose relative flex justify-end">
1062
<Dropdown inline label={walletName}>
11-
{connection !== null ? (
12-
<Dropdown.Header className="break-all">{connection}</Dropdown.Header>
13-
) : null}
63+
<Dropdown.Header className="break-all flex flex-col gap-2">
64+
{connection !== null ? <p>{connection}</p> : null}
65+
<p>
66+
Via <LockScriptName {...lockScriptNameProps} />
67+
</p>
68+
</Dropdown.Header>
1469
<Dropdown.Item onClick={() => router.push("/")}>Sign Out</Dropdown.Item>
1570
</Dropdown>
1671
</aside>

src/lib/cobuild/fee-manager.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,15 @@ function storeWitnessForFeeEstimation(
5959
// Variable length, but 500 is usually enough.
6060
() => bytes.hexify(new Uint8Array(500)),
6161
);
62-
} else if (script.codeHash === ckbChainConfig.SCRIPTS.UNISAT.CODE_HASH) {
62+
} else if (
63+
script.codeHash === ckbChainConfig.SCRIPTS.OMNILOCK_CUSTOM.CODE_HASH
64+
) {
6365
return generalLockActions.storeWitnessForFeeEstimation(
6466
buildingPacket,
6567
scriptHash,
6668
inputIndices,
67-
() => `0x${"0".repeat(65 * 2)}`,
69+
// 85 = 65 signature in OmnilockWitnessLock
70+
() => `0x${"0".repeat(85 * 2)}`,
6871
);
6972
}
7073

src/lib/cobuild/lock-actions.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ function dispatchLockActions(
8989
},
9090
() => `0x${"0".repeat(129 * 2)}`,
9191
);
92-
} else if (script.codeHash === ckbChainConfig.SCRIPTS.UNISAT.CODE_HASH) {
92+
} else if (
93+
script.codeHash === ckbChainConfig.SCRIPTS.OMNILOCK_CUSTOM.CODE_HASH
94+
) {
9395
return generalLockActions.prepareLockActionWithWitnessStore(
9496
buildingPacket,
9597
scriptHash,
@@ -99,7 +101,8 @@ function dispatchLockActions(
99101
inputIndices,
100102
},
101103
},
102-
() => `0x${"0".repeat(65 * 2)}`,
104+
// 85 = 65 signature in OmnilockWitnessLock
105+
() => `0x${"0".repeat(85 * 2)}`,
103106
);
104107
}
105108

src/lib/cobuild/react/building-packet-review.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,16 @@ export function TxSection({
199199

200200
return (
201201
<dl className="divide-y divide-gray-100">
202+
{process.env.DEBUG !== undefined ? (
203+
<div className="x-4 py-3 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0">
204+
<dt className="leading-6 text-gray-900">Hash</dt>
205+
<dd className="text-gray-700 sm:col-span-2 sm:mt-0 break-all">
206+
<pre className="font-mono p-4 bg-slate-800 text-slate-300 rounded overflow-scroll">
207+
{JSON.stringify(buildingPacket, null, 2)}
208+
</pre>
209+
</dd>
210+
</div>
211+
) : null}
202212
<div className="x-4 py-3 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0">
203213
<dt className="leading-6 text-gray-900">Hash</dt>
204214
<dd className="text-gray-700 sm:col-span-2 sm:mt-0 break-all">

src/lib/config.js

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const CKB_CHAINS_CONFIGS = {
66
EXPLORER_URL: "https://pudge.explorer.nervos.org",
77
SCRIPTS: {
88
...predefined.AGGRON4.SCRIPTS,
9+
910
JOYID: {
1011
CODE_HASH:
1112
"0xd23761b364210735c19c60561d213fb3beae2fd6172743719eff6920e020baac",
@@ -15,18 +16,14 @@ const CKB_CHAINS_CONFIGS = {
1516
INDEX: "0x0",
1617
DEP_TYPE: "depGroup",
1718
},
18-
AUTH: {
19-
TX_HASH:
20-
"0xd4f72f0504373ff8effadf44f92c46a0062774fb585ebcacc24eb47b98e2d66a",
21-
INDEX: "0x0",
22-
DEP_TYPE: "code",
23-
},
24-
UNISAT: {
19+
// Disable OMNILOCK bundled in lumos
20+
OMNILOCK: undefined,
21+
OMNILOCK_CUSTOM: {
2522
CODE_HASH:
26-
"0xd7aac16927b2d572b3803c1f68e49d082d3acc2af2614c9be752ff9cec5dc3ea",
27-
HASH_TYPE: "data1",
23+
"0xf329effd1c475a2978453c8600e1eaf0bc2087ee093c3ee64cc96ec6847752cb",
24+
HASH_TYPE: "type",
2825
TX_HASH:
29-
"0xe842b43df31c92d448fa345d60a6df3e03aaab19ef88921654bf95c673a26872",
26+
"0xff234bf2fb0ad2ab5b356ceda317d3dee3efb2c55b9427ef55d9dcbf6eecbf9f",
3027
INDEX: "0x0",
3128
DEP_TYPE: "code",
3229
},
@@ -62,13 +59,11 @@ function buildCkbChainConfig(ckbChain) {
6259
TX_HASH: presence(process.env.NEXT_PUBLIC_JOYID_TX_HASH),
6360
},
6461
);
65-
const UNISAT = assign(
66-
{ ...template.SCRIPTS.JOYID },
62+
const OMNILOCK_CUSTOM = assign(
63+
{ ...template.SCRIPTS.OMNILOCK_CUSTOM },
6764
{
68-
CODE_HASH: presence(process.env.NEXT_PUBLIC_UNISAT_CODE_HASH),
69-
HASH_TYPE: "type",
70-
TX_HASH: presence(process.env.NEXT_PUBLIC_AUTH_TX_HASH),
71-
DEP_TYPE: "depGroup",
65+
CODE_HASH: presence(process.env.NEXT_PUBLIC_OMNILOCK_CODE_HASH),
66+
TX_HASH: presence(process.env.NEXT_PUBLIC_OMNILOCK_TX_HASH),
7267
},
7368
);
7469

@@ -84,8 +79,7 @@ function buildCkbChainConfig(ckbChain) {
8479
EXPLORER_URL: null,
8580
SCRIPTS: {
8681
JOYID,
87-
UNISAT,
88-
AUTH: template.SCRIPTS.AUTH,
82+
OMNILOCK_CUSTOM,
8983
DAO: {
9084
...template.SCRIPTS.DAO,
9185
TX_HASH: tx0,

0 commit comments

Comments
 (0)