Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
66 changes: 66 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,40 @@ jobs:
path: napi/${{ env.APP_NAME }}.*.node
if-no-files-found: error

build-wasm:
name: Build & test WASM bindings
needs: rust-checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Rust + wasm target
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: wasm32-unknown-unknown
- name: Install clang/lld (blst needs a C/Clang toolchain for wasm32)
run: sudo apt-get update && sudo apt-get install -y clang lld
- name: Install wasm-pack
uses: jetli/wasm-pack-action@v0.4.0
with:
version: latest
- name: Build NAPI (needed by the parity test)
run: cd napi && npm install && npm run build
- name: Build WASM nodejs target and run parity test
run: cd wasm && npm install && npm run build:node && npm test
- name: Build WASM bundler artifact (published package)
run: cd wasm && npm run build:bundler
- name: Upload wasm pkg
uses: actions/upload-artifact@v4
with:
name: wasm-pkg
path: wasm/pkg
if-no-files-found: error

test-macOS-windows-binding:
name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
needs:
Expand Down Expand Up @@ -315,6 +349,38 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

publish-wasm-npm:
name: Publish WASM to NPM
runs-on: ubuntu-latest
needs:
- build-wasm
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Download wasm pkg
uses: actions/download-artifact@v4
with:
name: wasm-pkg
path: wasm/pkg
- name: Publish to NPM (on version-tag commit)
run: |
npm config set provenance true
if git log -1 --pretty=%B | grep -qE "^[0-9]+\.[0-9]+\.[0-9]+$"; then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
cd wasm/pkg && npm publish --access public
elif git log -1 --pretty=%B | grep -qE "^[0-9]+\.[0-9]+\.[0-9]+"; then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
cd wasm/pkg && npm publish --tag next --access public
else
echo "Not a release, skipping wasm npm publish"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

publish-crates:
name: Publish to Crates.io
runs-on: ubuntu-latest
Expand Down
119 changes: 119 additions & 0 deletions Cargo.lock

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

38 changes: 30 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,39 @@
[workspace]
resolver = "2"
members = [".", "napi"]
members = [".", "napi", "wasm"]

[package]
edition = "2021"
name = "datalayer-driver"
version = "3.0.0"
license = "MIT"
edition = "2021"
authors = ["yakuhito <y@kuhi.to>", "William Wills <wwills2@protonmail.com>"]
homepage = "https://github.com/DIG-Network/DataLayer-Driver"
repository = "https://github.com/DIG-Network/DataLayer-Driver"
description = "Native Chia DataLayer Driver for storing and retrieving data in Chia blockchain"
license = "MIT"
repository = "https://github.com/DIG-Network/DataLayer-Driver"
readme = "README.md"
homepage = "https://github.com/DIG-Network/DataLayer-Driver"
keywords = ["chia", "blockchain", "datalayer", "storage", "web3"]
categories = ["cryptography::cryptocurrencies", "web-programming"]

[dependencies]
chia = "0.26.0"
# chia meta-crate: native-only (chia-client inside it pulls tokio)
chia = { version = "0.26.0", optional = true }
# Individual wasm-safe chia sub-crates (used on both paths)
chia-bls = "0.26.0"
chia-consensus = "0.26.0"
chia-protocol = "0.26.0"
chia-puzzle-types = "0.26.0"
chia-traits = "0.26.0"
chia-puzzles = "0.20.1"
clvm-utils = "0.26.0"
thiserror = "1.0.61"
clvmr = "0.14.0"
tokio = "1.39.3"
chia-wallet-sdk = { version = "0.30.0", features = ["chip-0035", "native-tls", "peer-simulator", "action-layer"] }
tokio = { version = "1.39.3", optional = true }
chia-wallet-sdk = { version = "0.30.0", default-features = false, features = ["chip-0035", "action-layer"], optional = true }
chia-sdk-driver = { version = "0.30.0", features = ["chip-0035", "action-layer"] }
chia-sdk-signer = "0.30.0"
chia-sdk-types = { version = "0.30.0", features = ["chip-0035", "action-layer"] }
chia-sdk-utils = "0.30.0"
hex-literal = "0.4.1"
num-bigint = "0.4.6"
hex = "0.4.3"
Expand All @@ -30,6 +42,16 @@ futures-util = "0.3"
clvm-traits = "0.26.0"
indexmap = "2.11.4"

[features]
default = ["native"]
native = [
"dep:tokio",
"dep:chia",
"dep:chia-wallet-sdk",
"chia-wallet-sdk/native-tls",
"chia-wallet-sdk/peer-simulator",
]

[target.aarch64-unknown-linux-gnu.dependencies]
openssl = { version = "0.10.64", features = ["vendored"] }
openssl-sys = { version = "0.9.102", features = ["vendored"] }
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Native Chia DataLayer Driver for storing and retrieving data in Chia blockchain.

This project provides both Rust library APIs and Node.js bindings for interacting with Chia's DataLayer.

A WebAssembly build is also available as [`@dignetwork/datalayer-driver-wasm`](./wasm/README.md) for browser and bundler environments (webpack, Vite, Next.js, esbuild). The WASM package mirrors the offline subset of the NAPI interface — no networking, no `Peer`/`Tls` — making it ideal for building and signing DIGStore spend bundles client-side without a full node. See [`wasm/README.md`](./wasm/README.md) for installation, usage, and a worked example.

## Installation

### As a Rust Crate
Expand Down
Loading
Loading