Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
45 changes: 45 additions & 0 deletions bindings/go/examples/owned_objects.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) 2025 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

package main

import (
"fmt"
"log"

sdk "bindings/iota_sdk_ffi"
)

func isNilError(err error) bool {
if sdkErr, ok := err.(*sdk.SdkFfiError); ok {
return sdkErr == nil
}
return false
}

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

address, err := sdk.AddressFromHex("0x0")
if err != nil {
log.Fatalf("Failed to parse address: %v", err)
}

objectFilter := sdk.ObjectFilter{
Owner: &address,
}
pagination := sdk.PaginationFilter{
Direction: sdk.DirectionForward,
Cursor: nil,
Limit: nil,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in a757975

}

objectsPage, err := client.Objects(pagination, &objectFilter)
if !isNilError(err) {
log.Fatalf("Failed to get owned objects: %v", err)
}
fmt.Printf("Owned objects (%d):\n", len(objectsPage.Data))
for _, obj := range objectsPage.Data {
fmt.Println(obj.ObjectId().ToHex())
}
}
25 changes: 25 additions & 0 deletions bindings/kotlin/examples/OwnedObjects.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) 2025 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import iota_sdk.Address
import iota_sdk.Direction
import iota_sdk.GraphQlClient
import iota_sdk.ObjectFilter
import iota_sdk.PaginationFilter
import kotlinx.coroutines.runBlocking

fun main() = runBlocking {
try {
val client = GraphQlClient.newDevnet()
val address = Address.fromHex("0x0")
val objectFilter = ObjectFilter(typeTag = null, owner = address, objectIds = null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove the null fields right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, removed 045fba9

val pagination = PaginationFilter(direction = Direction.FORWARD)
val objectsPage = client.objects(pagination, objectFilter)
println("Owned objects (${objectsPage.data.size}):")
for (obj in objectsPage.data) {
println(obj.objectId().toHex())
}
} catch (e: Exception) {
e.printStackTrace()
}
}
20 changes: 20 additions & 0 deletions bindings/python/examples/owned_objects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) 2025 IOTA Stiftung
# SPDX-License-Identifier: Apache-2.0

from lib.iota_sdk_ffi import *
import asyncio

async def main():
client = GraphQlClient.new_devnet()
address = "0x0" # Example address, replace as needed
address = Address.from_hex(address)
objects_page = await client.objects(
PaginationFilter(direction=Direction.FORWARD),
ObjectFilter(type_tag=None, owner=address, object_ids=None)
)
print(f"Owned objects({len(objects_page.data)}):")
for obj in objects_page.data:
print(obj.object_id().to_hex())

if __name__ == "__main__":
asyncio.run(main())
28 changes: 28 additions & 0 deletions crates/iota-graphql-client/examples/owned_objects.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) 2025 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

use anyhow::Result;
use iota_graphql_client::{Client, pagination::PaginationFilter, query_types::ObjectFilter};
use iota_types::Address;

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

let address = Address::from_hex("0x0")?;
let owned_objects_page = client
.objects(
Some(ObjectFilter {
owner: Some(address),
..Default::default()
}),
PaginationFilter::default(),
)
.await?;
println!("Owned objects ({}):", owned_objects_page.data.len());
for obj in owned_objects_page.data {
println!("{}", obj.object_id());
}

Ok(())
}