Skip to content

Commit f421c61

Browse files
feat(ffi): Add TransactionBuilder FFI types (#129)
* feat(ffi): Add `TransactionBuilder` FFI types * remove versions from local crates * renames and remove input kind enum * bindings --------- Co-authored-by: Thibault Martinez <[email protected]>
1 parent 9667279 commit f421c61

File tree

14 files changed

+5658
-425
lines changed

14 files changed

+5658
-425
lines changed

bindings/go/iota_sdk_ffi/iota_sdk_ffi.go

Lines changed: 1147 additions & 26 deletions
Large diffs are not rendered by default.

bindings/go/iota_sdk_ffi/iota_sdk_ffi.h

Lines changed: 395 additions & 0 deletions
Large diffs are not rendered by default.

bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt

Lines changed: 2070 additions & 376 deletions
Large diffs are not rendered by default.

bindings/python/lib/iota_sdk_ffi.py

Lines changed: 1512 additions & 0 deletions
Large diffs are not rendered by default.

bindings/python/test.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async def main():
1717
PaginationFilter(direction=Direction.FORWARD, cursor=None, limit=None),
1818
)
1919
for coin in coins.data:
20-
print(f"ID = 0x{coin.id().to_hex()} Balance = {coin.balance()}")
20+
print(f"ID = {coin.id().to_hex()} Balance = {coin.balance()}")
2121

2222
balance = await client.balance(my_address)
2323

@@ -90,6 +90,44 @@ async def main():
9090
linkage_table={id: upgrade_info},
9191
)
9292

93+
builder = TransactionBuilder()
94+
framework_addr = Address.from_hex(
95+
"0x0000000000000000000000000000000000000000000000000000000000000002"
96+
)
97+
builder.move_call(
98+
Function(
99+
package=framework_addr,
100+
module=Identifier("coin"),
101+
function=Identifier("value"),
102+
type_args=[
103+
TypeTag.new_struct(
104+
StructTag(
105+
framework_addr, Identifier("iota"), Identifier("IOTA"), []
106+
)
107+
)
108+
],
109+
),
110+
[Argument.new_input(0)],
111+
)
112+
builder.set_sender(my_address)
113+
builder.set_gas_budget(50000000)
114+
builder.set_gas_price(await client.reference_gas_price() or 100)
115+
coin_0 = await client.object(coins.data[0].id())
116+
if coin_0 is None:
117+
raise InternalError
118+
coin_1 = await client.object(coins.data[1].id())
119+
if coin_1 is None:
120+
raise InternalError
121+
builder.input(UnresolvedInput.from_object(coin_0).with_owned_kind())
122+
builder.add_gas_objects([UnresolvedInput.from_object(coin_1).with_owned_kind()])
123+
txn = builder.finish()
124+
125+
res = await client.dry_run_tx(txn)
126+
if res.error is not None:
127+
print(res.error)
128+
elif res.effects is not None:
129+
print(res.effects.as_v1())
130+
93131

94132
if __name__ == "__main__":
95133
asyncio.run(main())

crates/iota-crypto/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pem = [
5454
]
5555

5656
[dependencies]
57-
iota-sdk-types = { version = "0.0.1", path = "../iota-sdk-types", default-features = false, features = ["hash", "serde"] }
57+
iota-sdk-types = { path = "../iota-sdk-types", default-features = false, features = ["hash", "serde"] }
5858
signature = "2.2"
5959

6060
# RNG support

crates/iota-graphql-client/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ chrono = "0.4.26"
1818
cynic = "3.7.3"
1919
derive_more = { version = "2.0", features = ["from"] }
2020
futures = "0.3.29"
21-
iota-types = { package = "iota-sdk-types", version = "0.0.1", path = "../iota-sdk-types", features = ["serde"] }
21+
iota-types = { package = "iota-sdk-types", path = "../iota-sdk-types", features = ["serde"] }
2222
reqwest = { version = "0.12", default-features = false, features = ["rustls-tls", "json"] }
2323
serde = { version = "1.0.144" }
2424
serde_json = { version = "1.0.95" }
@@ -27,9 +27,9 @@ tracing = "0.1.37"
2727
url = "2.5.3"
2828

2929
[dev-dependencies]
30-
iota-types = { package = "iota-sdk-types", version = "0.0.1", path = "../iota-sdk-types", features = ["serde", "rand", "hash"] }
30+
iota-types = { package = "iota-sdk-types", path = "../iota-sdk-types", features = ["serde", "rand", "hash"] }
3131
rand = "0.8.5"
3232
tokio = { version = "1.40.0", features = ["full"] }
3333

3434
[build-dependencies]
35-
iota-graphql-client-build = { version = "0.0.1", path = "../iota-graphql-client-build" }
35+
iota-graphql-client-build = { path = "../iota-graphql-client-build" }

crates/iota-sdk-ffi/Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ serde_json = "1.0.95"
1919
tokio = { version = "1.36.0", features = ["time"] }
2020
uniffi = { version = "0.29", features = ["cli", "tokio"] }
2121

22-
iota-crypto = { version = "0.0.1", path = "../iota-crypto", features = ["ed25519", "secp256r1", "passkey", "secp256k1", "zklogin", "pem"] }
23-
iota-graphql-client = { version = "0.0.1", path = "../iota-graphql-client" }
24-
iota-types = { package = "iota-sdk-types", version = "0.0.1", path = "../iota-sdk-types", features = ["hash", "rand"] }
22+
iota-crypto = { path = "../iota-crypto", features = ["ed25519", "secp256r1", "passkey", "secp256k1", "zklogin", "pem"] }
23+
iota-graphql-client = { path = "../iota-graphql-client" }
24+
iota-transaction-builder = { path = "../iota-transaction-builder" }
25+
iota-types = { package = "iota-sdk-types", path = "../iota-sdk-types", features = ["hash", "rand"] }

crates/iota-sdk-ffi/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ mod crypto;
110110
mod error;
111111
mod faucet;
112112
mod graphql;
113+
mod transaction_builder;
113114
mod types;
114115
mod uniffi_helpers;
115116

0 commit comments

Comments
 (0)