Skip to content
Draft
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
33 changes: 33 additions & 0 deletions .github/workflows/bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,36 @@ jobs:
# Release example requires iota-sdk-swift package to be published first
# - name: Run the release example
# run: make swift-release-example

typescript:
if: (!cancelled() && needs.diff.outputs.isBindings == 'true')
needs: diff
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Install uniffi-bindgen-node (patched for UniFFI 0.29)
run: |
git clone https://github.com/livekit/uniffi-bindgen-node.git /tmp/uniffi-bindgen-node
cd /tmp/uniffi-bindgen-node
git checkout 9faabc2d6841498789d4d6737cae57e7a1c0f069
git apply $GITHUB_WORKSPACE/bindings/typescript/uniffi-bindgen-node-0.29.patch
cargo install --path .
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: "22"
- name: Install dependencies
run: cd bindings/typescript && npm install
- name: Build the bindings
run: make typescript
- name: Checks for uncommitted changes
run: git diff --exit-code
- name: Check format of the examples
run: make typescript-examples-format-check
- uses: ./.github/actions/start-local-network
- name: Run the examples
run: make typescript-examples
# Release example requires @iota/sdk package to be published first
# - name: Run the release example
# run: make typescript-release-example
126 changes: 126 additions & 0 deletions .github/workflows/typescript_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Publish TypeScript SDK to npm

on:
release:
types: [published]
workflow_dispatch:
inputs:
test_publish:
description: "Publish to npm with --dry-run only"
required: false
default: true
type: boolean

permissions:
contents: read

jobs:
build:
if: (github.event_name == 'release' && startsWith(github.event.release.tag_name, 'iota-typescript-sdk')) || github.event_name == 'workflow_dispatch'
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
lib: libiota_sdk_ffi.so
folder: linux-x64
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
lib: libiota_sdk_ffi.so
folder: linux-arm64
- os: macos-latest
target: x86_64-apple-darwin
lib: libiota_sdk_ffi.dylib
folder: darwin-x64
- os: macos-latest
target: aarch64-apple-darwin
lib: libiota_sdk_ffi.dylib
folder: darwin-arm64
- os: windows-latest
target: x86_64-pc-windows-msvc
lib: iota_sdk_ffi.dll
folder: win32-x64
- os: windows-latest
target: aarch64-pc-windows-msvc
lib: iota_sdk_ffi.dll
folder: win32-arm64
steps:
- name: Checkout iota-rust-sdk
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
ref: ${{ github.event.release.tag_name || github.ref }}

- name: Install Rust
uses: dtolnay/rust-toolchain@0f44b27771c32bda9f458f75a1e241b09791b331
with:
targets: ${{ matrix.target }}
toolchain: stable

- name: Install cross-compilation tools
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu

- name: Build ${{ matrix.os }} ${{ matrix.target }} library
if: matrix.os == 'macos-latest'
run: RUSTFLAGS="-C link-args=-Wl,-install_name,@rpath/${{ matrix.lib }}" cargo build -p iota-sdk-ffi --lib --release --target ${{ matrix.target }}

- name: Build ${{ matrix.os }} ${{ matrix.target }} library
if: matrix.os == 'ubuntu-latest'
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: /usr/bin/aarch64-linux-gnu-gcc
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER: /usr/bin/x86_64-linux-gnu-gcc
run: RUSTFLAGS="-C link-args=-Wl,-rpath,$ORIGIN" cargo build -p iota-sdk-ffi --lib --release --target ${{ matrix.target }}

- name: Build ${{ matrix.os }} ${{ matrix.target }} library
if: matrix.os == 'windows-latest'
run: cargo build -p iota-sdk-ffi --lib --release --target ${{ matrix.target }}

- name: Prepare library archive
run: |
mkdir -p tmp/lib/${{ matrix.folder }}
cp target/${{ matrix.target }}/release/${{ matrix.lib }} tmp/lib/${{ matrix.folder }}/${{ matrix.lib }}

- name: Upload native library
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: native-lib-${{ matrix.target }}
path: tmp

publish:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
ref: ${{ github.event.release.tag_name || github.ref }}

- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: "22"
registry-url: "https://registry.npmjs.org"

- name: Download native libraries
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
with:
path: bindings/typescript/lib
pattern: native-lib-*
merge-multiple: true

- name: Dry run publish
if: github.event_name == 'workflow_dispatch' && inputs.test_publish == true
run: |
cd bindings/typescript
npm publish --dry-run
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish to npm
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.test_publish == false)
run: |
cd bindings/typescript
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
54 changes: 54 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ bindings: ## Build all bindings
@$(MAKE) python
@$(MAKE) csharp
@$(MAKE) swift
@$(MAKE) typescript

.PHONY: bindings-example
bindings-example: ## Run a specific example for all bindings. Usage: make bindings-example example
Expand All @@ -87,6 +88,7 @@ bindings-example: ## Run a specific example for all bindings. Usage: make bindin
@$(MAKE) python-example $(word 2,$(MAKECMDGOALS))
@$(MAKE) csharp-example $(word 2,$(MAKECMDGOALS))
@$(MAKE) swift-example $(word 2,$(MAKECMDGOALS))
@$(MAKE) typescript-example $(word 2,$(MAKECMDGOALS))

.PHONY: bindings-examples
bindings-examples: ## Run all bindings examples
Expand All @@ -95,6 +97,7 @@ bindings-examples: ## Run all bindings examples
@$(MAKE) python-examples
@$(MAKE) csharp-examples
@$(MAKE) swift-examples
@$(MAKE) typescript-examples

.PHONY: bindings-examples-format-check
bindings-examples-format-check: ## Check format of all bindings examples
Expand All @@ -103,6 +106,7 @@ bindings-examples-format-check: ## Check format of all bindings examples
@$(MAKE) python-examples-format-check
@$(MAKE) csharp-examples-format-check
@$(MAKE) swift-examples-format-check
@$(MAKE) typescript-examples-format-check

.PHONY: bindings-examples-format
bindings-examples-format: ## Format all bindings examples
Expand All @@ -111,6 +115,7 @@ bindings-examples-format: ## Format all bindings examples
@$(MAKE) python-examples-format
@$(MAKE) csharp-examples-format
@$(MAKE) swift-examples-format
@$(MAKE) typescript-examples-format

# Build ffi crate and detect platform
define build_binding
Expand Down Expand Up @@ -315,6 +320,49 @@ swift-examples-format-check: ## Check format of all Swift bindings examples
swift-examples-format: ## Format all Swift bindings examples
@swift-format format --recursive bindings/swift/examples --in-place

.PHONY: typescript
typescript: ## Build TypeScript bindings
@printf "Building TypeScript bindings...\n"
@$(build_binding) \
uniffi-bindgen-node generate target/release/libiota_sdk_ffi$${LIB_EXT} --crate-name iota_sdk_ffi --out-dir bindings/typescript/lib || exit $$?; \
cp target/release/libiota_sdk_ffi$${LIB_EXT} bindings/typescript/lib/

.PHONY: typescript-example
typescript-example: ## Run a specific TypeScript example. Usage: make typescript-example example
%:
@true
typescript-example:
@printf "\nRunning TypeScript example \"$(word 2,$(MAKECMDGOALS))\"\n"
@cd bindings/typescript; \
npx tsx examples/$(word 2,$(MAKECMDGOALS)).ts || exit $$?; \
cd -

# transaction_signer_callback: requires callback interface support not yet available in uniffi-bindgen-node
# abstract_account: requires specific local network config (also fails in Go bindings)
TYPESCRIPT_SKIP_EXAMPLES := transaction_signer_callback abstract_account

.PHONY: typescript-examples
typescript-examples: ## Run all TypeScript bindings examples
@for example in $$(find bindings/typescript/examples -name "*.ts" -not -path "*/release/*" -exec basename {} .ts \;); do \
skip=false; \
for s in $(TYPESCRIPT_SKIP_EXAMPLES); do \
if [ "$$example" = "$$s" ]; then skip=true; break; fi; \
done; \
if [ "$$skip" = "true" ]; then \
printf "\nSkipping TypeScript example \"$$example\"\n"; \
else \
$(MAKE) typescript-example "$$example" || exit $$?; \
fi; \
done

.PHONY: typescript-examples-format-check
typescript-examples-format-check: ## Check format of all TypeScript bindings examples
@cd bindings/typescript && npx prettier --check "examples/**/*.ts"

.PHONY: typescript-examples-format
typescript-examples-format: ## Format all TypeScript bindings examples
@cd bindings/typescript && npx prettier --write "examples/**/*.ts"

.PHONY: example
example: ## Run a specific Rust example. Usage: make example example
%:
Expand Down Expand Up @@ -359,6 +407,11 @@ swift-release-example: ## Run the Swift release example
@printf "\nRunning Swift release example\n"
@cd bindings/swift/examples/release && swift run || exit $$?

.PHONY: typescript-release-example
typescript-release-example: ## Run the TypeScript release example
@printf "\nRunning TypeScript release example\n"
@cd bindings/typescript/examples/release && npm install && npx tsx example.ts || exit $$?

.PHONY: release-examples
release-examples: ## Run all release examples
@$(MAKE) rust-release-example
Expand All @@ -367,6 +420,7 @@ release-examples: ## Run all release examples
@$(MAKE) python-release-example
@$(MAKE) csharp-release-example
@$(MAKE) swift-release-example
@$(MAKE) typescript-release-example

.PHONY: help
help: ## Show this help
Expand Down
7 changes: 7 additions & 0 deletions bindings/typescript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Node modules
node_modules

# Native library files (platform-specific, built at compile time)
lib/*.dylib
lib/*.so
lib/*.dll
7 changes: 7 additions & 0 deletions bindings/typescript/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": false,
"printWidth": 100,
"tabWidth": 2
}
3 changes: 3 additions & 0 deletions bindings/typescript/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## [0.0.1-alpha.1] - 2026-XX-XX

Initial Release
Loading
Loading