Skip to content
Merged
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
6 changes: 6 additions & 0 deletions .github/workflows/bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ jobs:
- uses: ./.github/actions/start-local-network
- name: Run the examples
run: make go-examples
- name: Run the release example
run: make go-release-example

kotlin:
if: (!cancelled() && needs.diff.outputs.isBindings == 'true')
Expand All @@ -67,6 +69,8 @@ jobs:
- uses: ./.github/actions/start-local-network
- name: Run the examples
run: make kotlin-examples
- name: Run the release example
run: make kotlin-release-example

python:
if: (!cancelled() && needs.diff.outputs.isBindings == 'true')
Expand All @@ -86,3 +90,5 @@ jobs:
- uses: ./.github/actions/start-local-network
- name: Run the examples
run: make python-examples
- name: Run the release example
run: make python-release-example
5 changes: 4 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@ jobs:

- uses: ./.github/actions/start-local-network

- name: Run examples
- name: Run the examples
run: make examples

- name: Run the release example
run: make rust-release-example

doctests:
if: (!github.event.pull_request.draft || contains(github.event.pull_request.body, '[run-ci]'))
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/target
target/
Cargo.lock
.idea
*.dylib
Expand All @@ -7,3 +7,4 @@ Cargo.lock
__pycache__
build
.vscode
.kotlin
47 changes: 37 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,17 @@ go-example:

.PHONY: go-examples
go-examples: ## Run all Go bindings examples
@for example in $$(find bindings/go/examples/* -type d -exec basename {} \;); do \
@for example in $$(find bindings/go/examples/* -type d -not -name release -exec basename {} \;); do \
$(MAKE) go-example "$$example" || exit $$?; \
done

.PHONY: go-examples-format-check
go-examples-format-check: ## Check format of all Go bindings examples
@test -z "$$(gofmt -l bindings/go/examples)"
@test -z "$$(find bindings/go/examples -name "*.go" -not -path "*/release/*" -exec gofmt -l {} \;)"

.PHONY: go-examples-format
go-examples-format: ## Format all Go bindings examples
@gofmt -w bindings/go/examples
@find bindings/go/examples -name "*.go" -not -path "*/release/*" -exec gofmt -w {} \;

.PHONY: kotlin-example
kotlin-example: ## Run a specific Kotlin example. Usage: make kotlin-example example
Expand All @@ -176,20 +176,20 @@ kotlin-example:

.PHONY: kotlin-examples
kotlin-examples: ## Run all Kotlin bindings examples
@for example in $$(find bindings/kotlin/examples -name "*.kt" -exec basename {} .kt \;); do \
@for example in $$(find bindings/kotlin/examples -name "*.kt" -not -path "*/release/*" -exec basename {} .kt \;); do \
$(MAKE) kotlin-example "$$example" || exit $$?; \
done

.PHONY: kotlin-examples-format-check
kotlin-examples-format-check: ## Check format of all Kotlin bindings examples
cd bindings/kotlin; \
./gradlew KtfmtCheck || exit $$?; \
find examples -name "*.kt" -not -path "*/release/*" -exec ./gradlew KtfmtCheck --files {} \; || exit $$?; \
cd -

.PHONY: kotlin-examples-format
kotlin-examples-format: ## Format all Kotlin bindings examples
cd bindings/kotlin; \
./gradlew KtfmtFormat; \
find examples -name "*.kt" -not -path "*/release/*" -exec ./gradlew KtfmtFormat --files {} \; ; \
cd -

.PHONY: python-example
Expand All @@ -202,17 +202,17 @@ python-example:

.PHONY: python-examples
python-examples: ## Run all Python bindings examples
@for example in $$(find bindings/python/examples -name "*.py" -exec basename {} .py \;); do \
@for example in $$(find bindings/python/examples -name "*.py" -not -path "*/release/*" -exec basename {} .py \;); do \
$(MAKE) python-example "$$example" || exit $$?; \
done

.PHONY: python-examples-format-check
python-examples-format-check: ## Check format of all Python bindings examples
@yapf --style google -d bindings/python/examples/*
@yapf --style google -d $$(find bindings/python/examples -name "*.py" -not -path "*/release/*") --recursive

.PHONY: python-examples-format
python-examples-format: ## Format all Python bindings examples
@yapf --style google -i bindings/python/examples/*
@yapf --style google -i $$(find bindings/python/examples -name "*.py" -not -path "*/release/*") --recursive

.PHONY: example
example: ## Run a specific Rust example. Usage: make example example
Expand All @@ -224,10 +224,37 @@ example:

.PHONY: examples
examples: ## Run all Rust examples
@for example in $$(find crates/iota-sdk/examples -name "*.rs" -exec basename {} .rs \;); do \
@for example in $$(find crates/iota-sdk/examples -name "*.rs" -not -path "*/release/*" -exec basename {} .rs \;); do \
$(MAKE) example "$$example" || exit $$?; \
done

.PHONY: rust-release-example
rust-release-example: ## Run the Rust release example
@printf "\nRunning Rust release example\n"
@cd crates/iota-sdk/examples/release && cargo run || exit $$?

.PHONY: go-release-example
go-release-example: ## Run the Go release example
@printf "\nRunning Go release example\n"
@cd bindings/go/examples/release && go get github.com/iotaledger/iota-sdk-go && go run main.go || exit $$?

.PHONY: kotlin-release-example
kotlin-release-example: ## Run the Kotlin release example
@printf "\nRunning Kotlin release example\n"
@cd bindings/kotlin/examples/release && gradle run || exit $$?

.PHONY: python-release-example
python-release-example: ## Run the Python release example
@printf "\nRunning Python release example\n"
@cd bindings/python/examples/release && python3 -m venv .venv && . .venv/bin/activate && pip install --pre --upgrade -r requirements.txt && python example.py || exit $$?;

.PHONY: release-examples
release-examples: ## Run all release examples
@$(MAKE) rust-release-example
@$(MAKE) go-release-example
@$(MAKE) kotlin-release-example
@$(MAKE) python-release-example

.PHONY: help
help: ## Show this help
@printf "Available targets:\n"
Expand Down
9 changes: 9 additions & 0 deletions bindings/go/examples/release/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Full project example using the released package.

```bash
go get github.com/iotaledger/iota-sdk-go
```

```bash
go run main.go
```
21 changes: 21 additions & 0 deletions bindings/go/examples/release/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) 2026 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

package main

import (
"fmt"
"log"

"github.com/iotaledger/iota-sdk-go"
)

func main() {
client := iota_sdk.GraphQlClientNewDevnet()

chainID, err := client.ChainId()
if err.(*iota_sdk.SdkFfiError) != nil {
log.Fatalf("Failed to get chain ID: %v", err)
}
fmt.Println("Chain ID:", chainID)
}
5 changes: 5 additions & 0 deletions bindings/kotlin/examples/release/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Full project example using the released package.

```bash
gradle run
```
19 changes: 19 additions & 0 deletions bindings/kotlin/examples/release/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
plugins {
kotlin("jvm") version "2.2.20"
application
}

group = "com.example"

version = "1.0-SNAPSHOT"

repositories { mavenCentral() }

dependencies {
implementation("org.iota:iota-sdk:latest.release")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")
}

kotlin { jvmToolchain(21) }

application { mainClass.set("MainKt") }
1 change: 1 addition & 0 deletions bindings/kotlin/examples/release/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = "kotlintest"
16 changes: 16 additions & 0 deletions bindings/kotlin/examples/release/src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) 2026 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import iota_sdk.GraphQlClient
import kotlinx.coroutines.runBlocking

fun main() = runBlocking {
try {
val client = GraphQlClient.newDevnet()
val chainId = client.chainId()
println("Chain ID: $chainId")
} catch (e: Exception) {
e.printStackTrace()
kotlin.system.exitProcess(1)
}
}
15 changes: 15 additions & 0 deletions bindings/python/examples/release/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Full project example using the released package.

To set up the environment:

```bash
python -m venv .venv
source .venv/bin/activate
pip install --pre --upgrade -r requirements.txt
```

Then run:

```bash
python example.py
```
17 changes: 17 additions & 0 deletions bindings/python/examples/release/example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (c) 2025 IOTA Stiftung
# SPDX-License-Identifier: Apache-2.0

from iota_sdk import *

import asyncio


async def main():
client = GraphQlClient.new_devnet()

chain_id = await client.chain_id()
print("Chain ID:", chain_id)


if __name__ == "__main__":
asyncio.run(main())
1 change: 1 addition & 0 deletions bindings/python/examples/release/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
iota-sdk
9 changes: 9 additions & 0 deletions crates/iota-sdk/examples/release/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[workspace]
[package]
name = "release"
version = "0.1.0"
edition = "2024"

[dependencies]
iota-sdk = "^3.0.0-alpha"
tokio = "1.40.0"
14 changes: 14 additions & 0 deletions crates/iota-sdk/examples/release/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) 2026 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

use iota_sdk::graphql_client::{Client, error::Result};

#[tokio::main]
async fn main() -> Result<()> {
let client = Client::new_devnet();

let chain_id = client.chain_id().await?;
println!("Chain ID: {chain_id}");

Ok(())
}