Skip to content

Commit

Permalink
feat: support Xverse
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanssen0 committed Sep 28, 2024
1 parent ac221fe commit e904963
Show file tree
Hide file tree
Showing 32 changed files with 1,144 additions and 6 deletions.
9 changes: 9 additions & 0 deletions .changeset/tall-mangos-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@ckb-ccc/xverse": patch
"@ckb-ccc/ccc": patch
"ckb-ccc": patch
"@ckb-ccc/connector": patch
"@ckb-ccc/connector-react": patch
---

feat: support Xverse
5 changes: 0 additions & 5 deletions lerna.json

This file was deleted.

3 changes: 2 additions & 1 deletion packages/ccc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"@ckb-ccc/okx": "workspace:*",
"@ckb-ccc/uni-sat": "workspace:*",
"@ckb-ccc/utxo-global": "workspace:*",
"@ckb-ccc/rei": "workspace:*"
"@ckb-ccc/rei": "workspace:*",
"@ckb-ccc/xverse": "workspace:*"
}
}
1 change: 1 addition & 0 deletions packages/ccc/src/advancedBarrel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from "@ckb-ccc/nip07/advanced";
export * from "@ckb-ccc/okx/advanced";
export * from "@ckb-ccc/uni-sat/advanced";
export * from "@ckb-ccc/utxo-global/advanced";
export * from "@ckb-ccc/xverse/advanced";
1 change: 1 addition & 0 deletions packages/ccc/src/barrel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export * from "@ckb-ccc/okx";
export * from "@ckb-ccc/rei";
export * from "@ckb-ccc/uni-sat";
export * from "@ckb-ccc/utxo-global";
export * from "@ckb-ccc/xverse";
export * from "./signersController.js";
6 changes: 6 additions & 0 deletions packages/ccc/src/signersController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Okx } from "@ckb-ccc/okx";
import { Rei } from "@ckb-ccc/rei";
import { UniSat } from "@ckb-ccc/uni-sat";
import { UtxoGlobal } from "@ckb-ccc/utxo-global";
import { Xverse } from "@ckb-ccc/xverse";
import { ETH_SVG } from "./assets/eth.svg.js";
import { JOY_ID_SVG } from "./assets/joy-id.svg.js";
import { METAMASK_SVG } from "./assets/metamask.svg.js";
Expand Down Expand Up @@ -146,6 +147,11 @@ export class SignersController {
context,
);

await Promise.all(Xverse.getXverseSigners(client, preferredNetworks).map(
({ wallet, signerInfo }) =>
this.addSigner(wallet.name, wallet.icon, signerInfo, context),
));

const nostrSigner = Nip07.getNip07Signer(client);
if (nostrSigner) {
await this.addSigner(
Expand Down
12 changes: 12 additions & 0 deletions packages/xverse/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
node_modules/
misc/

tsconfig.json
tsconfig.*.json
eslint.config.mjs
.prettierrc
.prettierignore

tsconfig.tsbuildinfo
tsconfig.*.tsbuildinfo
.github/
13 changes: 13 additions & 0 deletions packages/xverse/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
node_modules/

dist/
dist.commonjs/

.npmignore
.prettierrc
tsconfig.json
eslint.config.mjs
.prettierrc

tsconfig.tsbuildinfo
.github/
5 changes: 5 additions & 0 deletions packages/xverse/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": false,
"trailingComma": "all",
"plugins": ["prettier-plugin-organize-imports"]
}
51 changes: 51 additions & 0 deletions packages/xverse/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<p align="center">
<a href="https://app.ckbccc.com/">
<img alt="Logo" src="https://raw.githubusercontent.com/ckb-ecofund/ccc/master/assets/logo.svg" width="20%" />
</a>
</p>

<h1 align="center" style="font-size: 48px;">
CCC's support for Xverse
</h1>

<p align="center">
<a href="https://www.npmjs.com/package/@ckb-ccc/xverse"><img
alt="NPM Version" src="https://img.shields.io/npm/v/%40ckb-ccc%2Fxverse"
/></a>
<img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/ckb-ecofund/ccc" />
<img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/ckb-ecofund/ccc/master" />
<img alt="GitHub branch check runs" src="https://img.shields.io/github/check-runs/ckb-ecofund/ccc/master" />
<a href="https://live.ckbccc.com/"><img
alt="Playground" src="https://img.shields.io/website?url=https%3A%2F%2Flive.ckbccc.com%2F&label=Playground"
/></a>
<a href="https://app.ckbccc.com/"><img
alt="App" src="https://img.shields.io/website?url=https%3A%2F%2Fapp.ckbccc.com%2F&label=App"
/></a>
<a href="https://docs.ckbccc.com/"><img
alt="Docs" src="https://img.shields.io/website?url=https%3A%2F%2Fdocs.ckbccc.com%2F&label=Docs"
/></a>
</p>

<p align="center">
"CCC - CKBers' Codebase" is the next step of "Common Chains Connector".
<br />
Empower yourself with CCC to discover the unlimited potential of CKB.
<br />
Interoperate with wallets from different chain ecosystems.
<br />
Fully enabling CKB's Turing completeness and cryptographic freedom power.
</p>

## Preview

<p align="center">
<a href="https://app.ckbccc.com/">
<img src="https://raw.githubusercontent.com/ckb-ecofund/ccc/master/assets/preview.png" width="30%" />
</a>
</p>

This project is still under active development, and we are looking forward to your feedback. [Try its demo now here](https://app.ckbccc.com/). It showcases how to use CCC for some basic scenarios in CKB.

<h3 align="center">
Read more about CCC on <a href="https://docs.ckbccc.com">our website</a> or <a href="https://github.com/ckb-ecofund/ccc">GitHub Repo</a>.
</h3>
29 changes: 29 additions & 0 deletions packages/xverse/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// @ts-check

import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier";

import { fileURLToPath } from "url";
import { dirname } from "path";

export default tseslint.config({
files: ["./src/**/*.ts"],
extends: [
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
],
rules: {
"@typescript-eslint/require-await": "off",
"@typescript-eslint/no-redundant-type-constituents": "off",
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"@typescript-eslint/unbound-method": ["error", { "ignoreStatic": true }],
},
plugins: { prettier: eslintPluginPrettierRecommended },
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: dirname(fileURLToPath(import.meta.url)),
},
},
});
3 changes: 3 additions & 0 deletions packages/xverse/misc/basedirs/dist.commonjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
3 changes: 3 additions & 0 deletions packages/xverse/misc/basedirs/dist/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
57 changes: 57 additions & 0 deletions packages/xverse/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"name": "@ckb-ccc/xverse",
"version": "0.0.14",
"description": "CCC - CKBer's Codebase. Common Chains Connector's support for Xverse",
"author": "Hanssen0 <[email protected]>",
"license": "MIT",
"private": false,
"homepage": "https://github.com/ckb-ecofund/ccc",
"repository": {
"type": "git",
"url": "git://github.com/ckb-ecofund/ccc.git"
},
"main": "dist.commonjs/index.js",
"module": "dist/index.js",
"exports": {
".": {
"import": "./dist/index.js",
"default": "./dist.commonjs/index.js"
},
"./barrel": {
"import": "./dist/barrel.js",
"default": "./dist.commonjs/barrel.js"
},
"./advanced": {
"import": "./dist/advanced.js",
"default": "./dist.commonjs/advanced.js"
},
"./advancedBarrel": {
"import": "./dist/advancedBarrel.js",
"default": "./dist.commonjs/advancedBarrel.js"
}
},
"scripts": {
"build": "rimraf ./dist && rimraf ./dist.commonjs && tsc && tsc --project tsconfig.commonjs.json && copyfiles -u 2 misc/basedirs/**/* .",
"lint": "eslint",
"format": "prettier --write . && eslint --fix"
},
"devDependencies": {
"@eslint/js": "^9.1.1",
"copyfiles": "^2.4.1",
"eslint": "^9.1.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"prettier": "^3.2.5",
"prettier-plugin-organize-imports": "^3.2.4",
"rimraf": "^5.0.5",
"typescript": "^5.4.5",
"typescript-eslint": "^7.7.0"
},
"publishConfig": {
"access": "public"
},
"dependencies": {
"@ckb-ccc/core": "workspace:*",
"valibot": "^0.42.1"
}
}
1 change: 1 addition & 0 deletions packages/xverse/src/advanced.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * as XverseA from "./advancedBarrel.js";
1 change: 1 addition & 0 deletions packages/xverse/src/advancedBarrel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./sat-connect-core/advanced.js";
2 changes: 2 additions & 0 deletions packages/xverse/src/barrel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./signer.js";
export * from "./signersFactory.js";
1 change: 1 addition & 0 deletions packages/xverse/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * as Xverse from "./barrel.js";
4 changes: 4 additions & 0 deletions packages/xverse/src/sat-connect-core/advanced.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from "./btcMethods.advanced";
export * from "./provider.advanced";
export * from "./requests.advanced";
export * from "./types.advanced";
Loading

0 comments on commit e904963

Please sign in to comment.