diff --git a/bindings/go/examples/dev_inspect/main.go b/bindings/go/examples/dev_inspect/main.go index 58ce69c85..cbcbdf206 100644 --- a/bindings/go/examples/dev_inspect/main.go +++ b/bindings/go/examples/dev_inspect/main.go @@ -48,7 +48,7 @@ func main() { name := "name.iota" fmt.Printf("Looking up name: %s\n", name) - builder := sdk.TransactionBuilderInit(sender, client) + builder := sdk.NewTransactionBuilder(sender).WithClient(client) // Create identifiers iotaNamesModule := identifier("iota_names") diff --git a/bindings/go/examples/gas_sponsor/main.go b/bindings/go/examples/gas_sponsor/main.go index a07b556cc..1993aea43 100644 --- a/bindings/go/examples/gas_sponsor/main.go +++ b/bindings/go/examples/gas_sponsor/main.go @@ -39,7 +39,7 @@ func main() { sender := addrFromHex("0x0000a4984bd495d4346fa208ddff4f5d5e5ad48c21dec631ddebc99809f16900") sponsor := addrFromHex("0x611830d3641a68f94a690dcc25d1f4b0dac948325ac18f6dd32564371735f32c") - builder := sdk.TransactionBuilderInit(sender, client) + builder := sdk.NewTransactionBuilder(sender).WithClient(client) packageAddr := sdk.AddressStdLib() moduleName := identifier("u8") diff --git a/bindings/go/examples/gas_station/main.go b/bindings/go/examples/gas_station/main.go index f73dca0ee..356aabf3f 100644 --- a/bindings/go/examples/gas_station/main.go +++ b/bindings/go/examples/gas_station/main.go @@ -25,7 +25,7 @@ func main() { sender := keypair.PublicKey().DeriveAddress() simpleKey := sdk.SimpleKeypairFromEd25519(keypair) - builder := sdk.TransactionBuilderInit(sender, client) + builder := sdk.NewTransactionBuilder(sender).WithClient(client) package_id := sdk.AddressStdLib() module_name := identifier("u64") diff --git a/bindings/go/examples/generic_move_function/main.go b/bindings/go/examples/generic_move_function/main.go index 9f819776a..a270e2fd3 100644 --- a/bindings/go/examples/generic_move_function/main.go +++ b/bindings/go/examples/generic_move_function/main.go @@ -31,7 +31,7 @@ func main() { sender := addrFromHex("0x71b4b4f171b4355ff691b7c470579cf1a926f96f724e5f9a30efc4b5f75d085e") - builder := sdk.TransactionBuilderInit(sender, client) + builder := sdk.NewTransactionBuilder(sender).WithClient(client) addr1 := addrFromHex("0xde49ea53fbadee67d3e35a097cdbea210b659676fc680a0b0c5f11d0763d375e") addr2 := addrFromHex("0xe512234aa4ef6184c52663f09612b68f040dd0c45de037d96190a071ca5525b3") diff --git a/bindings/go/examples/prepare_merge_coins/main.go b/bindings/go/examples/prepare_merge_coins/main.go index ea3b21b43..ad4d3e19f 100644 --- a/bindings/go/examples/prepare_merge_coins/main.go +++ b/bindings/go/examples/prepare_merge_coins/main.go @@ -33,7 +33,7 @@ func main() { coin0 := objIdFromHex("0x0b0270ee9d27da0db09651e5f7338dfa32c7ee6441ccefa1f6e305735bcfc7ab") coin1 := objIdFromHex("0xd04077fe3b6fad13b3d4ed0d535b7ca92afcac8f0f2a0e0925fb9f4f0b30c699") - builder := sdk.TransactionBuilderInit(sender, client) + builder := sdk.NewTransactionBuilder(sender).WithClient(client) builder.MergeCoins(coin0, []*sdk.PtbArgument{coin1}) txn, err := builder.Finish() diff --git a/bindings/go/examples/prepare_send_coins/main.go b/bindings/go/examples/prepare_send_coins/main.go index 80f74fc97..c90bbf240 100644 --- a/bindings/go/examples/prepare_send_coins/main.go +++ b/bindings/go/examples/prepare_send_coins/main.go @@ -36,7 +36,7 @@ func main() { coinObjId := objIdFromHex("0x8ef4259fa2a3499826fa4b8aebeb1d8e478cf5397d05361c96438940b43d28c9") amount := sdk.PtbArgumentU64(50000000000) - builder := sdk.TransactionBuilderInit(fromAddress, client) + builder := sdk.NewTransactionBuilder(fromAddress).WithClient(client) builder.SendCoins([]*sdk.PtbArgument{coinObjId}, toAddress, &amount) txn, err := builder.Finish() diff --git a/bindings/go/examples/prepare_send_iota/main.go b/bindings/go/examples/prepare_send_iota/main.go index ae489f839..3845e8bcf 100644 --- a/bindings/go/examples/prepare_send_iota/main.go +++ b/bindings/go/examples/prepare_send_iota/main.go @@ -24,7 +24,7 @@ func main() { toAddress := addrFromHex("0x0000a4984bd495d4346fa208ddff4f5d5e5ad48c21dec631ddebc99809f16900") - builder := sdk.TransactionBuilderInit(fromAddress, client) + builder := sdk.NewTransactionBuilder(fromAddress).WithClient(client) builder.SendIota(toAddress, sdk.PtbArgumentU64(5000000000)) txn, err := builder.Finish() diff --git a/bindings/go/examples/prepare_send_iota_multi/main.go b/bindings/go/examples/prepare_send_iota_multi/main.go index bdc93cfb1..6391e1df9 100644 --- a/bindings/go/examples/prepare_send_iota_multi/main.go +++ b/bindings/go/examples/prepare_send_iota_multi/main.go @@ -41,7 +41,7 @@ func main() { {"0x2222b466a24399ebcf5ec0f04820812ae20fea1037c736cfec608753aa38b522", 2_000_000_000}, } - builder := sdk.TransactionBuilderInit(sender, client) + builder := sdk.NewTransactionBuilder(sender).WithClient(client) // Prepare amounts and labels var amounts []*sdk.PtbArgument diff --git a/bindings/go/examples/prepare_split_coins/main.go b/bindings/go/examples/prepare_split_coins/main.go index 3a8836b11..ec09d8da7 100644 --- a/bindings/go/examples/prepare_split_coins/main.go +++ b/bindings/go/examples/prepare_split_coins/main.go @@ -32,7 +32,7 @@ func main() { coinObjId := objIdFromHex("0x0b0270ee9d27da0db09651e5f7338dfa32c7ee6441ccefa1f6e305735bcfc7ab") - builder := sdk.TransactionBuilderInit(sender, client) + builder := sdk.NewTransactionBuilder(sender).WithClient(client) builder.SplitCoins( sdk.PtbArgumentObjectId(coinObjId), []*sdk.PtbArgument{ diff --git a/bindings/go/examples/prepare_transfer_objects/main.go b/bindings/go/examples/prepare_transfer_objects/main.go index 3649ba93d..1d2cbb8e8 100644 --- a/bindings/go/examples/prepare_transfer_objects/main.go +++ b/bindings/go/examples/prepare_transfer_objects/main.go @@ -38,7 +38,7 @@ func main() { objIdFromHex("0x8ef4259fa2a3499826fa4b8aebeb1d8e478cf5397d05361c96438940b43d28c9"), } - builder := sdk.TransactionBuilderInit(fromAddress, client) + builder := sdk.NewTransactionBuilder(fromAddress).WithClient(client) builder.TransferObjects(toAddress, objsToTransfer) txn, err := builder.Finish() diff --git a/bindings/go/examples/prepare_transfer_objects_offline/main.go b/bindings/go/examples/prepare_transfer_objects_offline/main.go new file mode 100644 index 000000000..ce86f16d0 --- /dev/null +++ b/bindings/go/examples/prepare_transfer_objects_offline/main.go @@ -0,0 +1,90 @@ +// Copyright (c) 2025 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package main + +import ( + "log" + + sdk "bindings/iota_sdk_ffi" +) + +func objIdFromHex(hex string) *sdk.ObjectId { + id, err := sdk.ObjectIdFromHex(hex) + if err != nil { + log.Fatalf("Failed to parse object ID: %v", err) + } + return id +} + +func addrFromHex(hex string) *sdk.Address { + address, err := sdk.AddressFromHex(hex) + if err != nil { + log.Fatalf("Failed to parse address: %v", err) + } + return address +} + +func getObject(client *sdk.GraphQlClient, objId *sdk.ObjectId) *sdk.Object { + obj, err := client.Object(objId, nil) + if err.(*sdk.SdkFfiError) != nil { + log.Fatalf("Failed to get object: %v", err) + } + if obj == nil { + log.Fatalf("Missing object: %v", objId) + } + return *obj +} + +func main() { + client := sdk.GraphQlClientNewDevnet() + + fromAddress := addrFromHex("0x611830d3641a68f94a690dcc25d1f4b0dac948325ac18f6dd32564371735f32c") + + toAddress := addrFromHex("0x0000a4984bd495d4346fa208ddff4f5d5e5ad48c21dec631ddebc99809f16900") + + objIds := []*sdk.ObjectId{ + objIdFromHex("0xd04077fe3b6fad13b3d4ed0d535b7ca92afcac8f0f2a0e0925fb9f4f0b30c699"), + objIdFromHex("0x0b0270ee9d27da0db09651e5f7338dfa32c7ee6441ccefa1f6e305735bcfc7ab"), + objIdFromHex("0x8ef4259fa2a3499826fa4b8aebeb1d8e478cf5397d05361c96438940b43d28c9"), + } + objsToTransfer := []*sdk.PtbArgument{} + for _, objId := range objIds { + obj := getObject(client, objId) + objsToTransfer = append(objsToTransfer, sdk.PtbArgumentObjectRef(obj.ObjectRef())) + } + + gasCoinId := objIdFromHex("0xd04077fe3b6fad13b3d4ed0d535b7ca92afcac8f0f2a0e0925fb9f4f0b30c699") + gasCoin := getObject(client, gasCoinId).ObjectRef() + + gasPrice, err := client.ReferenceGasPrice(nil) + if err.(*sdk.SdkFfiError) != nil { + log.Fatalf("Failed to get gas price: %v", err) + } + if gasPrice == nil { + *gasPrice = uint64(100) + } + + builder := sdk.NewTransactionBuilder(fromAddress) + builder.TransferObjects(toAddress, objsToTransfer) + builder.Gas([]sdk.ObjectReference{gasCoin}).GasPrice(*gasPrice).GasBudget(500000000) + + txn, err := builder.Finish() + if err != nil { + log.Fatalf("Failed to create transaction: %v", err) + } + + log.Printf("Signing Digest: %v", txn.SigningDigestHex()) + log.Printf("Txn Bytes: %v", txn.ToBase64()) + + res, err := client.DryRunTx(txn, false) + if err.(*sdk.SdkFfiError) != nil { + log.Fatalf("Failed to transfer objects: %v", err) + } + + if res.Error != nil { + log.Fatalf("Failed to transfer objects: %v", *res.Error) + } + + log.Print("Transfer objects dry run was successful!") +} diff --git a/bindings/go/examples/publish_upgrade/main.go b/bindings/go/examples/publish_upgrade/main.go index 5a4a7db25..a43cfdd58 100644 --- a/bindings/go/examples/publish_upgrade/main.go +++ b/bindings/go/examples/publish_upgrade/main.go @@ -69,7 +69,7 @@ func main() { client := sdk.GraphQlClientNewLocalnet() // Build the `publish` PTB - builderPublish := sdk.TransactionBuilderInit(sender, client) + builderPublish := sdk.NewTransactionBuilder(sender).WithClient(client) // Publish the package and receive the upgrade cap in return builderPublish.Publish(packageData, "upgrade_cap") // Transfer the upgrade cap to the sender address @@ -145,7 +145,7 @@ func main() { } // Build the `upgrade` PTB - builderUpgrade := sdk.TransactionBuilderInit(sender, client) + builderUpgrade := sdk.NewTransactionBuilder(sender).WithClient(client) // Authorize the upgrade by providing the upgrade cap object id to receive an upgrade // ticket diff --git a/bindings/go/examples/sign_send_iota/main.go b/bindings/go/examples/sign_send_iota/main.go index 78d2f0e34..10ba1edd0 100644 --- a/bindings/go/examples/sign_send_iota/main.go +++ b/bindings/go/examples/sign_send_iota/main.go @@ -32,7 +32,7 @@ func main() { client := sdk.GraphQlClientNewLocalnet() - builder := sdk.TransactionBuilderInit(senderAddress, client) + builder := sdk.NewTransactionBuilder(senderAddress).WithClient(client) builder.SendIota(recipientAddress, sdk.PtbArgumentU64(1000)) txn, err := builder.Finish() if err.(*sdk.SdkFfiError) != nil { diff --git a/bindings/go/examples/stake/main.go b/bindings/go/examples/stake/main.go index 623a64c3d..8d3904f43 100644 --- a/bindings/go/examples/stake/main.go +++ b/bindings/go/examples/stake/main.go @@ -40,7 +40,7 @@ func main() { } log.Printf("Staking to validator %v", validatorName) - builder := sdk.TransactionBuilderInit(myAddress, client) + builder := sdk.NewTransactionBuilder(myAddress).WithClient(client) builder.Stake(sdk.PtbArgumentU64(1000000000), validator.Address) diff --git a/bindings/go/examples/tx_command_results/main.go b/bindings/go/examples/tx_command_results/main.go index a3f729b2c..3ee35d77d 100644 --- a/bindings/go/examples/tx_command_results/main.go +++ b/bindings/go/examples/tx_command_results/main.go @@ -30,7 +30,7 @@ func main() { sender := addrFromHex("0x611830d3641a68f94a690dcc25d1f4b0dac948325ac18f6dd32564371735f32c") - builder := sdk.TransactionBuilderInit(sender, client) + builder := sdk.NewTransactionBuilder(sender).WithClient(client) packageAddr := sdk.AddressStdLib() moduleName := identifier("u64") diff --git a/bindings/go/examples/unstake/main.go b/bindings/go/examples/unstake/main.go index 2ef93c3d1..a151ea5d1 100644 --- a/bindings/go/examples/unstake/main.go +++ b/bindings/go/examples/unstake/main.go @@ -22,7 +22,7 @@ func main() { } stakedIota := stakedIotas.Data[0] - builder := sdk.TransactionBuilderInit(stakedIota.Owner().AsAddress(), client) + builder := sdk.NewTransactionBuilder(stakedIota.Owner().AsAddress()).WithClient(client) builder.Unstake(sdk.PtbArgumentObjectId(stakedIota.ObjectId())) res, err := builder.DryRun(false) diff --git a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go index 3c6d96ed8..858d5b946 100644 --- a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go +++ b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go @@ -2924,6 +2924,195 @@ func uniffiCheckChecksums() { } } { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_dry_run() + }) + if checksum != 10983 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_dry_run: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_execute() + }) + if checksum != 45165 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_execute: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_execute_with_sponsor() + }) + if checksum != 64410 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_execute_with_sponsor: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_expiration() + }) + if checksum != 32958 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_expiration: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_finish() + }) + if checksum != 56677 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_finish: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas() + }) + if checksum != 522 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas_budget() + }) + if checksum != 27427 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas_budget: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas_price() + }) + if checksum != 56003 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas_price: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas_station_sponsor() + }) + if checksum != 25572 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas_station_sponsor: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_make_move_vec() + }) + if checksum != 4858 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_make_move_vec: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_merge_coins() + }) + if checksum != 43478 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_merge_coins: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_move_call() + }) + if checksum != 13617 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_move_call: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_publish() + }) + if checksum != 25909 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_publish: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_send_coins() + }) + if checksum != 65187 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_send_coins: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_send_iota() + }) + if checksum != 65011 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_send_iota: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_split_coins() + }) + if checksum != 2932 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_split_coins: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_sponsor() + }) + if checksum != 44990 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_sponsor: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_stake() + }) + if checksum != 9961 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_stake: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_transfer_objects() + }) + if checksum != 23790 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_transfer_objects: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_unstake() + }) + if checksum != 40181 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_unstake: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_upgrade() + }) + if checksum != 59977 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_upgrade: UniFFI API checksum mismatch") + } + } + { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_method_coin_balance() }) @@ -4571,6 +4760,15 @@ func uniffiCheckChecksums() { } } { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_object_object_ref() + }) + if checksum != 13587 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_object_object_ref: UniFFI API checksum mismatch") + } + } + { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_method_object_object_type() }) @@ -5823,29 +6021,11 @@ func uniffiCheckChecksums() { } { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { - return C.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_dry_run() - }) - if checksum != 11138 { - // If this happens try cleaning and rebuilding your project - panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_dry_run: UniFFI API checksum mismatch") - } - } - { - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { - return C.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_execute() - }) - if checksum != 45882 { - // If this happens try cleaning and rebuilding your project - panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_execute: UniFFI API checksum mismatch") - } - } - { - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { - return C.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_execute_with_sponsor() + return C.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_execute_with_gas_station() }) - if checksum != 45688 { + if checksum != 6268 { // If this happens try cleaning and rebuilding your project - panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_execute_with_sponsor: UniFFI API checksum mismatch") + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_execute_with_gas_station: UniFFI API checksum mismatch") } } { @@ -5861,7 +6041,7 @@ func uniffiCheckChecksums() { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_finish() }) - if checksum != 32200 { + if checksum != 39582 { // If this happens try cleaning and rebuilding your project panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_finish: UniFFI API checksum mismatch") } @@ -5870,7 +6050,7 @@ func uniffiCheckChecksums() { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_gas() }) - if checksum != 26787 { + if checksum != 23371 { // If this happens try cleaning and rebuilding your project panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_gas: UniFFI API checksum mismatch") } @@ -5960,7 +6140,7 @@ func uniffiCheckChecksums() { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_split_coins() }) - if checksum != 25229 { + if checksum != 17747 { // If this happens try cleaning and rebuilding your project panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_split_coins: UniFFI API checksum mismatch") } @@ -6011,6 +6191,15 @@ func uniffiCheckChecksums() { } } { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_with_client() + }) + if checksum != 32496 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_with_client: UniFFI API checksum mismatch") + } + } + { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_method_transactioneffects_as_v1() }) @@ -8270,6 +8459,15 @@ func uniffiCheckChecksums() { } } { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_constructor_ptbargument_object_ref() + }) + if checksum != 24215 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_ptbargument_object_ref: UniFFI API checksum mismatch") + } + } + { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_constructor_ptbargument_option() }) @@ -9270,11 +9468,11 @@ func uniffiCheckChecksums() { } { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { - return C.uniffi_iota_sdk_ffi_checksum_constructor_transactionbuilder_init() + return C.uniffi_iota_sdk_ffi_checksum_constructor_transactionbuilder_new() }) - if checksum != 29935 { + if checksum != 35216 { // If this happens try cleaning and rebuilding your project - panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_transactionbuilder_init: UniFFI API checksum mismatch") + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_transactionbuilder_new: UniFFI API checksum mismatch") } } { @@ -12534,102 +12732,600 @@ func (c FfiConverterCircomG1) Lower(value *CircomG1) unsafe.Pointer { } -func (c FfiConverterCircomG1) Write(writer io.Writer, value *CircomG1) { - writeUint64(writer, uint64(uintptr(c.Lower(value)))) +func (c FfiConverterCircomG1) Write(writer io.Writer, value *CircomG1) { + writeUint64(writer, uint64(uintptr(c.Lower(value)))) +} + +type FfiDestroyerCircomG1 struct {} + +func (_ FfiDestroyerCircomG1) Destroy(value *CircomG1) { + value.Destroy() +} + + + +// A G2 point +// +// This represents the canonical decimal representation of the coefficients of +// the projective coordinates in Fq2. +// +// # BCS +// +// The BCS serialized form for this type is defined by the following ABNF: +// +// ```text +// circom-g2 = %x03 3(%x02 2(bn254-field-element)) +// ``` +type CircomG2Interface interface { +} +// A G2 point +// +// This represents the canonical decimal representation of the coefficients of +// the projective coordinates in Fq2. +// +// # BCS +// +// The BCS serialized form for this type is defined by the following ABNF: +// +// ```text +// circom-g2 = %x03 3(%x02 2(bn254-field-element)) +// ``` +type CircomG2 struct { + ffiObject FfiObject +} +func NewCircomG2(el00 *Bn254FieldElement, el01 *Bn254FieldElement, el10 *Bn254FieldElement, el11 *Bn254FieldElement, el20 *Bn254FieldElement, el21 *Bn254FieldElement) *CircomG2 { + return FfiConverterCircomG2INSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_circomg2_new(FfiConverterBn254FieldElementINSTANCE.Lower(el00), FfiConverterBn254FieldElementINSTANCE.Lower(el01), FfiConverterBn254FieldElementINSTANCE.Lower(el10), FfiConverterBn254FieldElementINSTANCE.Lower(el11), FfiConverterBn254FieldElementINSTANCE.Lower(el20), FfiConverterBn254FieldElementINSTANCE.Lower(el21),_uniffiStatus) + })) +} + + + +func (object *CircomG2) Destroy() { + runtime.SetFinalizer(object, nil) + object.ffiObject.destroy() +} + +type FfiConverterCircomG2 struct {} + +var FfiConverterCircomG2INSTANCE = FfiConverterCircomG2{} + + +func (c FfiConverterCircomG2) Lift(pointer unsafe.Pointer) *CircomG2 { + result := &CircomG2 { + newFfiObject( + pointer, + func(pointer unsafe.Pointer, status *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_clone_circomg2(pointer, status) + }, + func(pointer unsafe.Pointer, status *C.RustCallStatus) { + C.uniffi_iota_sdk_ffi_fn_free_circomg2(pointer, status) + }, + ), + } + runtime.SetFinalizer(result, (*CircomG2).Destroy) + return result +} + +func (c FfiConverterCircomG2) Read(reader io.Reader) *CircomG2 { + return c.Lift(unsafe.Pointer(uintptr(readUint64(reader)))) +} + +func (c FfiConverterCircomG2) Lower(value *CircomG2) unsafe.Pointer { + // TODO: this is bad - all synchronization from ObjectRuntime.go is discarded here, + // because the pointer will be decremented immediately after this function returns, + // and someone will be left holding onto a non-locked pointer. + pointer := value.ffiObject.incrementPointer("*CircomG2") + defer value.ffiObject.decrementPointer() + return pointer + +} + +func (c FfiConverterCircomG2) Write(writer io.Writer, value *CircomG2) { + writeUint64(writer, uint64(uintptr(c.Lower(value)))) +} + +type FfiDestroyerCircomG2 struct {} + +func (_ FfiDestroyerCircomG2) Destroy(value *CircomG2) { + value.Destroy() +} + + + +// A builder for creating transactions which uses a GraphQL client to +// automatically resolve inputs. Use `finish` to finalize the transaction data. +type ClientTransactionBuilderInterface interface { + // Dry run the transaction. + DryRun(skipChecks bool) (DryRunResult, error) + // Execute the transaction and optionally wait for finalization. + Execute(keypair *SimpleKeypair, waitFor *WaitForTx) (*TransactionEffects, error) + // Execute the transaction and optionally wait for finalization. + ExecuteWithSponsor(keypair *SimpleKeypair, sponsorKeypair *SimpleKeypair, waitFor *WaitForTx) (*TransactionEffects, error) + // Set the expiration of the transaction to be a specific epoch. + Expiration(epoch uint64) *ClientTransactionBuilder + // Convert this builder into a transaction. + Finish() (*Transaction, error) + // Add gas coins that will be consumed. Optional. + Gas(objectIds []*ObjectId) *ClientTransactionBuilder + // Set the gas budget for the transaction. + GasBudget(budget uint64) *ClientTransactionBuilder + // Set the gas price for the transaction. + GasPrice(price uint64) *ClientTransactionBuilder + // Set the gas station sponsor. + GasStationSponsor(url string, duration *time.Duration, headers *map[string][]string) *ClientTransactionBuilder + // Make a move vector from a list of elements. The elements must all be of + // the type indicated by `type_tag`. + MakeMoveVec(elements []*MoveArg, typeTag *TypeTag, name string) *ClientTransactionBuilder + // Merge multiple coins into one. + // + // This method combines the balances of multiple coins of the same coin + // type into a single coin. The `primary_coin` will receive the balances + // from all `consumed_coins`. After merging, the `consumed_coins` will + // be consumed and no longer exist. + MergeCoins(primaryCoin *PtbArgument, consumedCoins []*PtbArgument) *ClientTransactionBuilder + // Call a Move function with the given arguments. + MoveCall(varPackage *Address, module *Identifier, function *Identifier, arguments []*PtbArgument, typeArgs []*TypeTag, names []string) *ClientTransactionBuilder + // Publish a list of modules with the given dependencies. The result + // assigned to `upgrade_cap_name` is the `0x2::package::UpgradeCap` + // Move type. Note that the upgrade capability needs to be handled + // after this call: + // - transfer it to the transaction sender or another address + // - burn it + // - wrap it for access control + // - discard the it to make a package immutable + // + // The arguments required for this command are: + // - `modules`: is the modules' bytecode to be published + // - `dependencies`: is the list of IDs of the transitive dependencies of + // the package + Publish(packageData *MovePackageData, upgradeCapName string) *ClientTransactionBuilder + // Transfer some coins to a recipient address. If multiple coins are + // provided then they will be merged. + // + // The `amount` parameter specifies the quantity in NANOS, where 1 IOTA + // equals 1_000_000_000 NANOS. + // If `amount` is provided, that amount is split from the provided coins + // and sent. + // If `amount` is `None`, the entire coins are transferred. + // + // All provided coins must have the same coin type. Mixing coins of + // different types will result in an error. + // + // If you intend to transfer all provided coins to another address in a + // single transaction, consider using + // `TransactionBuilder::transfer_objects()` instead. + SendCoins(coins []*PtbArgument, recipient *Address, amount **PtbArgument) *ClientTransactionBuilder + // Send IOTA to a recipient address. + // + // The `amount` parameter specifies the quantity in NANOS, where 1 IOTA + // equals 1_000_000_000 NANOS. That amount is split from the gas coin and + // sent. + SendIota(recipient *Address, amount *PtbArgument) *ClientTransactionBuilder + // Split a coin into many. + SplitCoins(coin *PtbArgument, amounts []*PtbArgument, names []string) *ClientTransactionBuilder + // Set the sponsor of the transaction. + Sponsor(sponsor *Address) *ClientTransactionBuilder + // Add stake to a validator's staking pool. + // + // This is a high-level function which will split the provided stake amount + // from the gas coin and then stake using the resulting coin. + Stake(stake *PtbArgument, validatorAddress *Address) *ClientTransactionBuilder + // Transfer a list of objects to the given address, without producing any + // result. + TransferObjects(recipient *Address, objects []*PtbArgument) *ClientTransactionBuilder + // Withdraw stake from a validator's staking pool. + Unstake(stakedIota *PtbArgument) *ClientTransactionBuilder + // Upgrade a Move package. + // + // - `modules`: is the modules' bytecode for the modules to be published + // - `dependencies`: is the list of IDs of the transitive dependencies of + // the package to be upgraded + // - `package`: is the ID of the current package being upgraded + // - `ticket`: is the upgrade ticket + // + // To get the ticket, you have to call the + // `0x2::package::authorize_upgrade` function, and pass the package + // ID, the upgrade policy, and package digest. + Upgrade(packageId *ObjectId, packageData *MovePackageData, upgradeTicket *PtbArgument, name *string) *ClientTransactionBuilder +} +// A builder for creating transactions which uses a GraphQL client to +// automatically resolve inputs. Use `finish` to finalize the transaction data. +type ClientTransactionBuilder struct { + ffiObject FfiObject +} + + + + +// Dry run the transaction. +func (_self *ClientTransactionBuilder) DryRun(skipChecks bool) (DryRunResult, error) { + _pointer := _self.ffiObject.incrementPointer("*ClientTransactionBuilder") + defer _self.ffiObject.decrementPointer() + res, err :=uniffiRustCallAsync[SdkFfiError]( + FfiConverterSdkFfiErrorINSTANCE, + // completeFn + func(handle C.uint64_t, status *C.RustCallStatus) RustBufferI { + res := C.ffi_iota_sdk_ffi_rust_future_complete_rust_buffer(handle, status) + return GoRustBuffer { + inner: res, + } + }, + // liftFn + func(ffi RustBufferI) DryRunResult { + return FfiConverterDryRunResultINSTANCE.Lift(ffi) + }, + C.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_dry_run( + _pointer,FfiConverterBoolINSTANCE.Lower(skipChecks)), + // pollFn + func (handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { + C.ffi_iota_sdk_ffi_rust_future_poll_rust_buffer(handle, continuation, data) + }, + // freeFn + func (handle C.uint64_t) { + C.ffi_iota_sdk_ffi_rust_future_free_rust_buffer(handle) + }, + ) + + return res, err +} + +// Execute the transaction and optionally wait for finalization. +func (_self *ClientTransactionBuilder) Execute(keypair *SimpleKeypair, waitFor *WaitForTx) (*TransactionEffects, error) { + _pointer := _self.ffiObject.incrementPointer("*ClientTransactionBuilder") + defer _self.ffiObject.decrementPointer() + res, err :=uniffiRustCallAsync[SdkFfiError]( + FfiConverterSdkFfiErrorINSTANCE, + // completeFn + func(handle C.uint64_t, status *C.RustCallStatus) unsafe.Pointer { + res := C.ffi_iota_sdk_ffi_rust_future_complete_pointer(handle, status) + return res + }, + // liftFn + func(ffi unsafe.Pointer) *TransactionEffects { + return FfiConverterTransactionEffectsINSTANCE.Lift(ffi) + }, + C.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_execute( + _pointer,FfiConverterSimpleKeypairINSTANCE.Lower(keypair), FfiConverterOptionalWaitForTxINSTANCE.Lower(waitFor)), + // pollFn + func (handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { + C.ffi_iota_sdk_ffi_rust_future_poll_pointer(handle, continuation, data) + }, + // freeFn + func (handle C.uint64_t) { + C.ffi_iota_sdk_ffi_rust_future_free_pointer(handle) + }, + ) + + return res, err +} + +// Execute the transaction and optionally wait for finalization. +func (_self *ClientTransactionBuilder) ExecuteWithSponsor(keypair *SimpleKeypair, sponsorKeypair *SimpleKeypair, waitFor *WaitForTx) (*TransactionEffects, error) { + _pointer := _self.ffiObject.incrementPointer("*ClientTransactionBuilder") + defer _self.ffiObject.decrementPointer() + res, err :=uniffiRustCallAsync[SdkFfiError]( + FfiConverterSdkFfiErrorINSTANCE, + // completeFn + func(handle C.uint64_t, status *C.RustCallStatus) unsafe.Pointer { + res := C.ffi_iota_sdk_ffi_rust_future_complete_pointer(handle, status) + return res + }, + // liftFn + func(ffi unsafe.Pointer) *TransactionEffects { + return FfiConverterTransactionEffectsINSTANCE.Lift(ffi) + }, + C.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_execute_with_sponsor( + _pointer,FfiConverterSimpleKeypairINSTANCE.Lower(keypair), FfiConverterSimpleKeypairINSTANCE.Lower(sponsorKeypair), FfiConverterOptionalWaitForTxINSTANCE.Lower(waitFor)), + // pollFn + func (handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { + C.ffi_iota_sdk_ffi_rust_future_poll_pointer(handle, continuation, data) + }, + // freeFn + func (handle C.uint64_t) { + C.ffi_iota_sdk_ffi_rust_future_free_pointer(handle) + }, + ) + + return res, err +} + +// Set the expiration of the transaction to be a specific epoch. +func (_self *ClientTransactionBuilder) Expiration(epoch uint64) *ClientTransactionBuilder { + _pointer := _self.ffiObject.incrementPointer("*ClientTransactionBuilder") + defer _self.ffiObject.decrementPointer() + return FfiConverterClientTransactionBuilderINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_expiration( + _pointer,FfiConverterUint64INSTANCE.Lower(epoch),_uniffiStatus) + })) +} + +// Convert this builder into a transaction. +func (_self *ClientTransactionBuilder) Finish() (*Transaction, error) { + _pointer := _self.ffiObject.incrementPointer("*ClientTransactionBuilder") + defer _self.ffiObject.decrementPointer() + res, err :=uniffiRustCallAsync[SdkFfiError]( + FfiConverterSdkFfiErrorINSTANCE, + // completeFn + func(handle C.uint64_t, status *C.RustCallStatus) unsafe.Pointer { + res := C.ffi_iota_sdk_ffi_rust_future_complete_pointer(handle, status) + return res + }, + // liftFn + func(ffi unsafe.Pointer) *Transaction { + return FfiConverterTransactionINSTANCE.Lift(ffi) + }, + C.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_finish( + _pointer,), + // pollFn + func (handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { + C.ffi_iota_sdk_ffi_rust_future_poll_pointer(handle, continuation, data) + }, + // freeFn + func (handle C.uint64_t) { + C.ffi_iota_sdk_ffi_rust_future_free_pointer(handle) + }, + ) + + return res, err +} + +// Add gas coins that will be consumed. Optional. +func (_self *ClientTransactionBuilder) Gas(objectIds []*ObjectId) *ClientTransactionBuilder { + _pointer := _self.ffiObject.incrementPointer("*ClientTransactionBuilder") + defer _self.ffiObject.decrementPointer() + return FfiConverterClientTransactionBuilderINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas( + _pointer,FfiConverterSequenceObjectIdINSTANCE.Lower(objectIds),_uniffiStatus) + })) +} + +// Set the gas budget for the transaction. +func (_self *ClientTransactionBuilder) GasBudget(budget uint64) *ClientTransactionBuilder { + _pointer := _self.ffiObject.incrementPointer("*ClientTransactionBuilder") + defer _self.ffiObject.decrementPointer() + return FfiConverterClientTransactionBuilderINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas_budget( + _pointer,FfiConverterUint64INSTANCE.Lower(budget),_uniffiStatus) + })) +} + +// Set the gas price for the transaction. +func (_self *ClientTransactionBuilder) GasPrice(price uint64) *ClientTransactionBuilder { + _pointer := _self.ffiObject.incrementPointer("*ClientTransactionBuilder") + defer _self.ffiObject.decrementPointer() + return FfiConverterClientTransactionBuilderINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas_price( + _pointer,FfiConverterUint64INSTANCE.Lower(price),_uniffiStatus) + })) +} + +// Set the gas station sponsor. +func (_self *ClientTransactionBuilder) GasStationSponsor(url string, duration *time.Duration, headers *map[string][]string) *ClientTransactionBuilder { + _pointer := _self.ffiObject.incrementPointer("*ClientTransactionBuilder") + defer _self.ffiObject.decrementPointer() + return FfiConverterClientTransactionBuilderINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas_station_sponsor( + _pointer,FfiConverterStringINSTANCE.Lower(url), FfiConverterOptionalDurationINSTANCE.Lower(duration), FfiConverterOptionalMapStringSequenceStringINSTANCE.Lower(headers),_uniffiStatus) + })) +} + +// Make a move vector from a list of elements. The elements must all be of +// the type indicated by `type_tag`. +func (_self *ClientTransactionBuilder) MakeMoveVec(elements []*MoveArg, typeTag *TypeTag, name string) *ClientTransactionBuilder { + _pointer := _self.ffiObject.incrementPointer("*ClientTransactionBuilder") + defer _self.ffiObject.decrementPointer() + return FfiConverterClientTransactionBuilderINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_make_move_vec( + _pointer,FfiConverterSequenceMoveArgINSTANCE.Lower(elements), FfiConverterTypeTagINSTANCE.Lower(typeTag), FfiConverterStringINSTANCE.Lower(name),_uniffiStatus) + })) +} + +// Merge multiple coins into one. +// +// This method combines the balances of multiple coins of the same coin +// type into a single coin. The `primary_coin` will receive the balances +// from all `consumed_coins`. After merging, the `consumed_coins` will +// be consumed and no longer exist. +func (_self *ClientTransactionBuilder) MergeCoins(primaryCoin *PtbArgument, consumedCoins []*PtbArgument) *ClientTransactionBuilder { + _pointer := _self.ffiObject.incrementPointer("*ClientTransactionBuilder") + defer _self.ffiObject.decrementPointer() + return FfiConverterClientTransactionBuilderINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_merge_coins( + _pointer,FfiConverterPtbArgumentINSTANCE.Lower(primaryCoin), FfiConverterSequencePtbArgumentINSTANCE.Lower(consumedCoins),_uniffiStatus) + })) +} + +// Call a Move function with the given arguments. +func (_self *ClientTransactionBuilder) MoveCall(varPackage *Address, module *Identifier, function *Identifier, arguments []*PtbArgument, typeArgs []*TypeTag, names []string) *ClientTransactionBuilder { + _pointer := _self.ffiObject.incrementPointer("*ClientTransactionBuilder") + defer _self.ffiObject.decrementPointer() + return FfiConverterClientTransactionBuilderINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_move_call( + _pointer,FfiConverterAddressINSTANCE.Lower(varPackage), FfiConverterIdentifierINSTANCE.Lower(module), FfiConverterIdentifierINSTANCE.Lower(function), FfiConverterSequencePtbArgumentINSTANCE.Lower(arguments), FfiConverterSequenceTypeTagINSTANCE.Lower(typeArgs), FfiConverterSequenceStringINSTANCE.Lower(names),_uniffiStatus) + })) +} + +// Publish a list of modules with the given dependencies. The result +// assigned to `upgrade_cap_name` is the `0x2::package::UpgradeCap` +// Move type. Note that the upgrade capability needs to be handled +// after this call: +// - transfer it to the transaction sender or another address +// - burn it +// - wrap it for access control +// - discard the it to make a package immutable +// +// The arguments required for this command are: +// - `modules`: is the modules' bytecode to be published +// - `dependencies`: is the list of IDs of the transitive dependencies of +// the package +func (_self *ClientTransactionBuilder) Publish(packageData *MovePackageData, upgradeCapName string) *ClientTransactionBuilder { + _pointer := _self.ffiObject.incrementPointer("*ClientTransactionBuilder") + defer _self.ffiObject.decrementPointer() + return FfiConverterClientTransactionBuilderINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_publish( + _pointer,FfiConverterMovePackageDataINSTANCE.Lower(packageData), FfiConverterStringINSTANCE.Lower(upgradeCapName),_uniffiStatus) + })) +} + +// Transfer some coins to a recipient address. If multiple coins are +// provided then they will be merged. +// +// The `amount` parameter specifies the quantity in NANOS, where 1 IOTA +// equals 1_000_000_000 NANOS. +// If `amount` is provided, that amount is split from the provided coins +// and sent. +// If `amount` is `None`, the entire coins are transferred. +// +// All provided coins must have the same coin type. Mixing coins of +// different types will result in an error. +// +// If you intend to transfer all provided coins to another address in a +// single transaction, consider using +// `TransactionBuilder::transfer_objects()` instead. +func (_self *ClientTransactionBuilder) SendCoins(coins []*PtbArgument, recipient *Address, amount **PtbArgument) *ClientTransactionBuilder { + _pointer := _self.ffiObject.incrementPointer("*ClientTransactionBuilder") + defer _self.ffiObject.decrementPointer() + return FfiConverterClientTransactionBuilderINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_send_coins( + _pointer,FfiConverterSequencePtbArgumentINSTANCE.Lower(coins), FfiConverterAddressINSTANCE.Lower(recipient), FfiConverterOptionalPtbArgumentINSTANCE.Lower(amount),_uniffiStatus) + })) +} + +// Send IOTA to a recipient address. +// +// The `amount` parameter specifies the quantity in NANOS, where 1 IOTA +// equals 1_000_000_000 NANOS. That amount is split from the gas coin and +// sent. +func (_self *ClientTransactionBuilder) SendIota(recipient *Address, amount *PtbArgument) *ClientTransactionBuilder { + _pointer := _self.ffiObject.incrementPointer("*ClientTransactionBuilder") + defer _self.ffiObject.decrementPointer() + return FfiConverterClientTransactionBuilderINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_send_iota( + _pointer,FfiConverterAddressINSTANCE.Lower(recipient), FfiConverterPtbArgumentINSTANCE.Lower(amount),_uniffiStatus) + })) +} + +// Split a coin into many. +func (_self *ClientTransactionBuilder) SplitCoins(coin *PtbArgument, amounts []*PtbArgument, names []string) *ClientTransactionBuilder { + _pointer := _self.ffiObject.incrementPointer("*ClientTransactionBuilder") + defer _self.ffiObject.decrementPointer() + return FfiConverterClientTransactionBuilderINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_split_coins( + _pointer,FfiConverterPtbArgumentINSTANCE.Lower(coin), FfiConverterSequencePtbArgumentINSTANCE.Lower(amounts), FfiConverterSequenceStringINSTANCE.Lower(names),_uniffiStatus) + })) } -type FfiDestroyerCircomG1 struct {} - -func (_ FfiDestroyerCircomG1) Destroy(value *CircomG1) { - value.Destroy() +// Set the sponsor of the transaction. +func (_self *ClientTransactionBuilder) Sponsor(sponsor *Address) *ClientTransactionBuilder { + _pointer := _self.ffiObject.incrementPointer("*ClientTransactionBuilder") + defer _self.ffiObject.decrementPointer() + return FfiConverterClientTransactionBuilderINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_sponsor( + _pointer,FfiConverterAddressINSTANCE.Lower(sponsor),_uniffiStatus) + })) } +// Add stake to a validator's staking pool. +// +// This is a high-level function which will split the provided stake amount +// from the gas coin and then stake using the resulting coin. +func (_self *ClientTransactionBuilder) Stake(stake *PtbArgument, validatorAddress *Address) *ClientTransactionBuilder { + _pointer := _self.ffiObject.incrementPointer("*ClientTransactionBuilder") + defer _self.ffiObject.decrementPointer() + return FfiConverterClientTransactionBuilderINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_stake( + _pointer,FfiConverterPtbArgumentINSTANCE.Lower(stake), FfiConverterAddressINSTANCE.Lower(validatorAddress),_uniffiStatus) + })) +} +// Transfer a list of objects to the given address, without producing any +// result. +func (_self *ClientTransactionBuilder) TransferObjects(recipient *Address, objects []*PtbArgument) *ClientTransactionBuilder { + _pointer := _self.ffiObject.incrementPointer("*ClientTransactionBuilder") + defer _self.ffiObject.decrementPointer() + return FfiConverterClientTransactionBuilderINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_transfer_objects( + _pointer,FfiConverterAddressINSTANCE.Lower(recipient), FfiConverterSequencePtbArgumentINSTANCE.Lower(objects),_uniffiStatus) + })) +} -// A G2 point -// -// This represents the canonical decimal representation of the coefficients of -// the projective coordinates in Fq2. -// -// # BCS -// -// The BCS serialized form for this type is defined by the following ABNF: -// -// ```text -// circom-g2 = %x03 3(%x02 2(bn254-field-element)) -// ``` -type CircomG2Interface interface { +// Withdraw stake from a validator's staking pool. +func (_self *ClientTransactionBuilder) Unstake(stakedIota *PtbArgument) *ClientTransactionBuilder { + _pointer := _self.ffiObject.incrementPointer("*ClientTransactionBuilder") + defer _self.ffiObject.decrementPointer() + return FfiConverterClientTransactionBuilderINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_unstake( + _pointer,FfiConverterPtbArgumentINSTANCE.Lower(stakedIota),_uniffiStatus) + })) } -// A G2 point -// -// This represents the canonical decimal representation of the coefficients of -// the projective coordinates in Fq2. -// -// # BCS + +// Upgrade a Move package. // -// The BCS serialized form for this type is defined by the following ABNF: +// - `modules`: is the modules' bytecode for the modules to be published +// - `dependencies`: is the list of IDs of the transitive dependencies of +// the package to be upgraded +// - `package`: is the ID of the current package being upgraded +// - `ticket`: is the upgrade ticket // -// ```text -// circom-g2 = %x03 3(%x02 2(bn254-field-element)) -// ``` -type CircomG2 struct { - ffiObject FfiObject -} -func NewCircomG2(el00 *Bn254FieldElement, el01 *Bn254FieldElement, el10 *Bn254FieldElement, el11 *Bn254FieldElement, el20 *Bn254FieldElement, el21 *Bn254FieldElement) *CircomG2 { - return FfiConverterCircomG2INSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { - return C.uniffi_iota_sdk_ffi_fn_constructor_circomg2_new(FfiConverterBn254FieldElementINSTANCE.Lower(el00), FfiConverterBn254FieldElementINSTANCE.Lower(el01), FfiConverterBn254FieldElementINSTANCE.Lower(el10), FfiConverterBn254FieldElementINSTANCE.Lower(el11), FfiConverterBn254FieldElementINSTANCE.Lower(el20), FfiConverterBn254FieldElementINSTANCE.Lower(el21),_uniffiStatus) +// To get the ticket, you have to call the +// `0x2::package::authorize_upgrade` function, and pass the package +// ID, the upgrade policy, and package digest. +func (_self *ClientTransactionBuilder) Upgrade(packageId *ObjectId, packageData *MovePackageData, upgradeTicket *PtbArgument, name *string) *ClientTransactionBuilder { + _pointer := _self.ffiObject.incrementPointer("*ClientTransactionBuilder") + defer _self.ffiObject.decrementPointer() + return FfiConverterClientTransactionBuilderINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_upgrade( + _pointer,FfiConverterObjectIdINSTANCE.Lower(packageId), FfiConverterMovePackageDataINSTANCE.Lower(packageData), FfiConverterPtbArgumentINSTANCE.Lower(upgradeTicket), FfiConverterOptionalStringINSTANCE.Lower(name),_uniffiStatus) })) } - - - -func (object *CircomG2) Destroy() { +func (object *ClientTransactionBuilder) Destroy() { runtime.SetFinalizer(object, nil) object.ffiObject.destroy() } -type FfiConverterCircomG2 struct {} +type FfiConverterClientTransactionBuilder struct {} -var FfiConverterCircomG2INSTANCE = FfiConverterCircomG2{} +var FfiConverterClientTransactionBuilderINSTANCE = FfiConverterClientTransactionBuilder{} -func (c FfiConverterCircomG2) Lift(pointer unsafe.Pointer) *CircomG2 { - result := &CircomG2 { +func (c FfiConverterClientTransactionBuilder) Lift(pointer unsafe.Pointer) *ClientTransactionBuilder { + result := &ClientTransactionBuilder { newFfiObject( pointer, func(pointer unsafe.Pointer, status *C.RustCallStatus) unsafe.Pointer { - return C.uniffi_iota_sdk_ffi_fn_clone_circomg2(pointer, status) + return C.uniffi_iota_sdk_ffi_fn_clone_clienttransactionbuilder(pointer, status) }, func(pointer unsafe.Pointer, status *C.RustCallStatus) { - C.uniffi_iota_sdk_ffi_fn_free_circomg2(pointer, status) + C.uniffi_iota_sdk_ffi_fn_free_clienttransactionbuilder(pointer, status) }, ), } - runtime.SetFinalizer(result, (*CircomG2).Destroy) + runtime.SetFinalizer(result, (*ClientTransactionBuilder).Destroy) return result } -func (c FfiConverterCircomG2) Read(reader io.Reader) *CircomG2 { +func (c FfiConverterClientTransactionBuilder) Read(reader io.Reader) *ClientTransactionBuilder { return c.Lift(unsafe.Pointer(uintptr(readUint64(reader)))) } -func (c FfiConverterCircomG2) Lower(value *CircomG2) unsafe.Pointer { +func (c FfiConverterClientTransactionBuilder) Lower(value *ClientTransactionBuilder) unsafe.Pointer { // TODO: this is bad - all synchronization from ObjectRuntime.go is discarded here, // because the pointer will be decremented immediately after this function returns, // and someone will be left holding onto a non-locked pointer. - pointer := value.ffiObject.incrementPointer("*CircomG2") + pointer := value.ffiObject.incrementPointer("*ClientTransactionBuilder") defer value.ffiObject.decrementPointer() return pointer } -func (c FfiConverterCircomG2) Write(writer io.Writer, value *CircomG2) { +func (c FfiConverterClientTransactionBuilder) Write(writer io.Writer, value *ClientTransactionBuilder) { writeUint64(writer, uint64(uintptr(c.Lower(value)))) } -type FfiDestroyerCircomG2 struct {} +type FfiDestroyerClientTransactionBuilder struct {} -func (_ FfiDestroyerCircomG2) Destroy(value *CircomG2) { +func (_ FfiDestroyerClientTransactionBuilder) Destroy(value *ClientTransactionBuilder) { value.Destroy() } @@ -19944,6 +20640,8 @@ type ObjectInterface interface { Digest() *Digest // Return this object's id ObjectId() *ObjectId + // Return this object's reference + ObjectRef() ObjectReference // Return this object's type ObjectType() *ObjectType // Return this object's owner @@ -20057,6 +20755,18 @@ func (_self *Object) ObjectId() *ObjectId { })) } +// Return this object's reference +func (_self *Object) ObjectRef() ObjectReference { + _pointer := _self.ffiObject.incrementPointer("*Object") + defer _self.ffiObject.decrementPointer() + return FfiConverterObjectReferenceINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer { + inner: C.uniffi_iota_sdk_ffi_fn_method_object_object_ref( + _pointer,_uniffiStatus), + } + })) +} + // Return this object's type func (_self *Object) ObjectType() *ObjectType { _pointer := _self.ffiObject.incrementPointer("*Object") @@ -20999,6 +21709,12 @@ func PtbArgumentObjectIdFromHex(hex string) (*PtbArgument, error) { } } +func PtbArgumentObjectRef(id ObjectReference) *PtbArgument { + return FfiConverterPtbArgumentINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_ptbargument_object_ref(FfiConverterObjectReferenceINSTANCE.Lower(id),_uniffiStatus) + })) +} + func PtbArgumentOption(value **MoveArg) *PtbArgument { return FfiConverterPtbArgumentINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { return C.uniffi_iota_sdk_ffi_fn_constructor_ptbargument_option(FfiConverterOptionalMoveArgINSTANCE.Lower(value),_uniffiStatus) @@ -25327,18 +26043,19 @@ func (_ FfiDestroyerTransaction) Destroy(value *Transaction) { // A builder for creating transactions. Use `finish` to finalize the // transaction data. type TransactionBuilderInterface interface { - // Dry run the transaction. - DryRun(skipChecks bool) (DryRunResult, error) - // Execute the transaction and optionally wait for finalization. - Execute(keypair *SimpleKeypair, waitFor *WaitForTx) (*TransactionEffects, error) - // Execute the transaction and optionally wait for finalization. - ExecuteWithSponsor(keypair *SimpleKeypair, sponsorKeypair *SimpleKeypair, waitFor *WaitForTx) (*TransactionEffects, error) + // Execute the transaction using the gas station and return the JSON + // transaction effects. This will fail unless data is set with the + // `gas_station_sponsor` function. + // + // NOTE: These effects are not necessarily compatible with + // `TransactionEffects` + ExecuteWithGasStation(keypair *SimpleKeypair) (Value, error) // Set the expiration of the transaction to be a specific epoch. Expiration(epoch uint64) *TransactionBuilder // Convert this builder into a transaction. Finish() (*Transaction, error) // Add gas coins that will be consumed. Optional. - Gas(objectIds []*ObjectId) *TransactionBuilder + Gas(objectRefs []ObjectReference) *TransactionBuilder // Set the gas budget for the transaction. GasBudget(budget uint64) *TransactionBuilder // Set the gas price for the transaction. @@ -25393,7 +26110,7 @@ type TransactionBuilderInterface interface { // equals 1_000_000_000 NANOS. That amount is split from the gas coin and // sent. SendIota(recipient *Address, amount *PtbArgument) *TransactionBuilder - // Split a coin into many. + // Split a coin by the provided amounts. SplitCoins(coin *PtbArgument, amounts []*PtbArgument, names []string) *TransactionBuilder // Set the sponsor of the transaction. Sponsor(sponsor *Address) *TransactionBuilder @@ -25419,45 +26136,30 @@ type TransactionBuilderInterface interface { // `0x2::package::authorize_upgrade` function, and pass the package // ID, the upgrade policy, and package digest. Upgrade(packageId *ObjectId, packageData *MovePackageData, upgradeTicket *PtbArgument, name *string) *TransactionBuilder + WithClient(client *GraphQlClient) *ClientTransactionBuilder } // A builder for creating transactions. Use `finish` to finalize the // transaction data. type TransactionBuilder struct { ffiObject FfiObject } - - // Create a new transaction builder and initialize its elements to default. -func TransactionBuilderInit(sender *Address, client *GraphQlClient) *TransactionBuilder { - res, _ :=uniffiRustCallAsync[error]( - nil, - // completeFn - func(handle C.uint64_t, status *C.RustCallStatus) unsafe.Pointer { - res := C.ffi_iota_sdk_ffi_rust_future_complete_pointer(handle, status) - return res - }, - // liftFn - func(ffi unsafe.Pointer) *TransactionBuilder { - return FfiConverterTransactionBuilderINSTANCE.Lift(ffi) - }, - C.uniffi_iota_sdk_ffi_fn_constructor_transactionbuilder_init(FfiConverterAddressINSTANCE.Lower(sender), FfiConverterGraphQlClientINSTANCE.Lower(client)), - // pollFn - func (handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { - C.ffi_iota_sdk_ffi_rust_future_poll_pointer(handle, continuation, data) - }, - // freeFn - func (handle C.uint64_t) { - C.ffi_iota_sdk_ffi_rust_future_free_pointer(handle) - }, - ) - - return res +func NewTransactionBuilder(sender *Address) *TransactionBuilder { + return FfiConverterTransactionBuilderINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_transactionbuilder_new(FfiConverterAddressINSTANCE.Lower(sender),_uniffiStatus) + })) } -// Dry run the transaction. -func (_self *TransactionBuilder) DryRun(skipChecks bool) (DryRunResult, error) { + +// Execute the transaction using the gas station and return the JSON +// transaction effects. This will fail unless data is set with the +// `gas_station_sponsor` function. +// +// NOTE: These effects are not necessarily compatible with +// `TransactionEffects` +func (_self *TransactionBuilder) ExecuteWithGasStation(keypair *SimpleKeypair) (Value, error) { _pointer := _self.ffiObject.incrementPointer("*TransactionBuilder") defer _self.ffiObject.decrementPointer() res, err :=uniffiRustCallAsync[SdkFfiError]( @@ -25470,11 +26172,11 @@ func (_self *TransactionBuilder) DryRun(skipChecks bool) (DryRunResult, error) { } }, // liftFn - func(ffi RustBufferI) DryRunResult { - return FfiConverterDryRunResultINSTANCE.Lift(ffi) + func(ffi RustBufferI) Value { + return FfiConverterTypeValueINSTANCE.Lift(ffi) }, - C.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_dry_run( - _pointer,FfiConverterBoolINSTANCE.Lower(skipChecks)), + C.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_execute_with_gas_station( + _pointer,FfiConverterSimpleKeypairINSTANCE.Lower(keypair)), // pollFn func (handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { C.ffi_iota_sdk_ffi_rust_future_poll_rust_buffer(handle, continuation, data) @@ -25488,66 +26190,6 @@ func (_self *TransactionBuilder) DryRun(skipChecks bool) (DryRunResult, error) { return res, err } -// Execute the transaction and optionally wait for finalization. -func (_self *TransactionBuilder) Execute(keypair *SimpleKeypair, waitFor *WaitForTx) (*TransactionEffects, error) { - _pointer := _self.ffiObject.incrementPointer("*TransactionBuilder") - defer _self.ffiObject.decrementPointer() - res, err :=uniffiRustCallAsync[SdkFfiError]( - FfiConverterSdkFfiErrorINSTANCE, - // completeFn - func(handle C.uint64_t, status *C.RustCallStatus) unsafe.Pointer { - res := C.ffi_iota_sdk_ffi_rust_future_complete_pointer(handle, status) - return res - }, - // liftFn - func(ffi unsafe.Pointer) *TransactionEffects { - return FfiConverterTransactionEffectsINSTANCE.Lift(ffi) - }, - C.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_execute( - _pointer,FfiConverterSimpleKeypairINSTANCE.Lower(keypair), FfiConverterOptionalWaitForTxINSTANCE.Lower(waitFor)), - // pollFn - func (handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { - C.ffi_iota_sdk_ffi_rust_future_poll_pointer(handle, continuation, data) - }, - // freeFn - func (handle C.uint64_t) { - C.ffi_iota_sdk_ffi_rust_future_free_pointer(handle) - }, - ) - - return res, err -} - -// Execute the transaction and optionally wait for finalization. -func (_self *TransactionBuilder) ExecuteWithSponsor(keypair *SimpleKeypair, sponsorKeypair *SimpleKeypair, waitFor *WaitForTx) (*TransactionEffects, error) { - _pointer := _self.ffiObject.incrementPointer("*TransactionBuilder") - defer _self.ffiObject.decrementPointer() - res, err :=uniffiRustCallAsync[SdkFfiError]( - FfiConverterSdkFfiErrorINSTANCE, - // completeFn - func(handle C.uint64_t, status *C.RustCallStatus) unsafe.Pointer { - res := C.ffi_iota_sdk_ffi_rust_future_complete_pointer(handle, status) - return res - }, - // liftFn - func(ffi unsafe.Pointer) *TransactionEffects { - return FfiConverterTransactionEffectsINSTANCE.Lift(ffi) - }, - C.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_execute_with_sponsor( - _pointer,FfiConverterSimpleKeypairINSTANCE.Lower(keypair), FfiConverterSimpleKeypairINSTANCE.Lower(sponsorKeypair), FfiConverterOptionalWaitForTxINSTANCE.Lower(waitFor)), - // pollFn - func (handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { - C.ffi_iota_sdk_ffi_rust_future_poll_pointer(handle, continuation, data) - }, - // freeFn - func (handle C.uint64_t) { - C.ffi_iota_sdk_ffi_rust_future_free_pointer(handle) - }, - ) - - return res, err -} - // Set the expiration of the transaction to be a specific epoch. func (_self *TransactionBuilder) Expiration(epoch uint64) *TransactionBuilder { _pointer := _self.ffiObject.incrementPointer("*TransactionBuilder") @@ -25562,39 +26204,25 @@ func (_self *TransactionBuilder) Expiration(epoch uint64) *TransactionBuilder { func (_self *TransactionBuilder) Finish() (*Transaction, error) { _pointer := _self.ffiObject.incrementPointer("*TransactionBuilder") defer _self.ffiObject.decrementPointer() - res, err :=uniffiRustCallAsync[SdkFfiError]( - FfiConverterSdkFfiErrorINSTANCE, - // completeFn - func(handle C.uint64_t, status *C.RustCallStatus) unsafe.Pointer { - res := C.ffi_iota_sdk_ffi_rust_future_complete_pointer(handle, status) - return res - }, - // liftFn - func(ffi unsafe.Pointer) *Transaction { - return FfiConverterTransactionINSTANCE.Lift(ffi) - }, - C.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_finish( - _pointer,), - // pollFn - func (handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { - C.ffi_iota_sdk_ffi_rust_future_poll_pointer(handle, continuation, data) - }, - // freeFn - func (handle C.uint64_t) { - C.ffi_iota_sdk_ffi_rust_future_free_pointer(handle) - }, - ) - - return res, err + _uniffiRV, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_finish( + _pointer,_uniffiStatus) + }) + if _uniffiErr != nil { + var _uniffiDefaultValue *Transaction + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterTransactionINSTANCE.Lift(_uniffiRV), nil + } } // Add gas coins that will be consumed. Optional. -func (_self *TransactionBuilder) Gas(objectIds []*ObjectId) *TransactionBuilder { +func (_self *TransactionBuilder) Gas(objectRefs []ObjectReference) *TransactionBuilder { _pointer := _self.ffiObject.incrementPointer("*TransactionBuilder") defer _self.ffiObject.decrementPointer() return FfiConverterTransactionBuilderINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { return C.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_gas( - _pointer,FfiConverterSequenceObjectIdINSTANCE.Lower(objectIds),_uniffiStatus) + _pointer,FfiConverterSequenceObjectReferenceINSTANCE.Lower(objectRefs),_uniffiStatus) })) } @@ -25724,7 +26352,7 @@ func (_self *TransactionBuilder) SendIota(recipient *Address, amount *PtbArgumen })) } -// Split a coin into many. +// Split a coin by the provided amounts. func (_self *TransactionBuilder) SplitCoins(coin *PtbArgument, amounts []*PtbArgument, names []string) *TransactionBuilder { _pointer := _self.ffiObject.incrementPointer("*TransactionBuilder") defer _self.ffiObject.decrementPointer() @@ -25797,6 +26425,35 @@ func (_self *TransactionBuilder) Upgrade(packageId *ObjectId, packageData *MoveP _pointer,FfiConverterObjectIdINSTANCE.Lower(packageId), FfiConverterMovePackageDataINSTANCE.Lower(packageData), FfiConverterPtbArgumentINSTANCE.Lower(upgradeTicket), FfiConverterOptionalStringINSTANCE.Lower(name),_uniffiStatus) })) } + +func (_self *TransactionBuilder) WithClient(client *GraphQlClient) *ClientTransactionBuilder { + _pointer := _self.ffiObject.incrementPointer("*TransactionBuilder") + defer _self.ffiObject.decrementPointer() + res, _ :=uniffiRustCallAsync[error]( + nil, + // completeFn + func(handle C.uint64_t, status *C.RustCallStatus) unsafe.Pointer { + res := C.ffi_iota_sdk_ffi_rust_future_complete_pointer(handle, status) + return res + }, + // liftFn + func(ffi unsafe.Pointer) *ClientTransactionBuilder { + return FfiConverterClientTransactionBuilderINSTANCE.Lift(ffi) + }, + C.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_with_client( + _pointer,FfiConverterGraphQlClientINSTANCE.Lower(client)), + // pollFn + func (handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { + C.ffi_iota_sdk_ffi_rust_future_poll_pointer(handle, continuation, data) + }, + // freeFn + func (handle C.uint64_t) { + C.ffi_iota_sdk_ffi_rust_future_free_pointer(handle) + }, + ) + + return res +} func (object *TransactionBuilder) Destroy() { runtime.SetFinalizer(object, nil) object.ffiObject.destroy() diff --git a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h index 673b75aa4..c98473a44 100644 --- a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h +++ b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h @@ -1032,6 +1032,121 @@ void uniffi_iota_sdk_ffi_fn_free_circomg2(void* ptr, RustCallStatus *out_status void* uniffi_iota_sdk_ffi_fn_constructor_circomg2_new(void* el_0_0, void* el_0_1, void* el_1_0, void* el_1_1, void* el_2_0, void* el_2_1, RustCallStatus *out_status ); #endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_CLIENTTRANSACTIONBUILDER +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_CLIENTTRANSACTIONBUILDER +void* uniffi_iota_sdk_ffi_fn_clone_clienttransactionbuilder(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_FREE_CLIENTTRANSACTIONBUILDER +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_FREE_CLIENTTRANSACTIONBUILDER +void uniffi_iota_sdk_ffi_fn_free_clienttransactionbuilder(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_DRY_RUN +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_DRY_RUN +uint64_t uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_dry_run(void* ptr, int8_t skip_checks +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_EXECUTE +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_EXECUTE +uint64_t uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_execute(void* ptr, void* keypair, RustBuffer wait_for +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_EXECUTE_WITH_SPONSOR +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_EXECUTE_WITH_SPONSOR +uint64_t uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_execute_with_sponsor(void* ptr, void* keypair, void* sponsor_keypair, RustBuffer wait_for +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_EXPIRATION +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_EXPIRATION +void* uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_expiration(void* ptr, uint64_t epoch, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_FINISH +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_FINISH +uint64_t uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_finish(void* ptr +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_GAS +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_GAS +void* uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas(void* ptr, RustBuffer object_ids, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_GAS_BUDGET +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_GAS_BUDGET +void* uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas_budget(void* ptr, uint64_t budget, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_GAS_PRICE +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_GAS_PRICE +void* uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas_price(void* ptr, uint64_t price, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_GAS_STATION_SPONSOR +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_GAS_STATION_SPONSOR +void* uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas_station_sponsor(void* ptr, RustBuffer url, RustBuffer duration, RustBuffer headers, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_MAKE_MOVE_VEC +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_MAKE_MOVE_VEC +void* uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_make_move_vec(void* ptr, RustBuffer elements, void* type_tag, RustBuffer name, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_MERGE_COINS +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_MERGE_COINS +void* uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_merge_coins(void* ptr, void* primary_coin, RustBuffer consumed_coins, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_MOVE_CALL +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_MOVE_CALL +void* uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_move_call(void* ptr, void* package, void* module, void* function, RustBuffer arguments, RustBuffer type_args, RustBuffer names, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_PUBLISH +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_PUBLISH +void* uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_publish(void* ptr, void* package_data, RustBuffer upgrade_cap_name, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_SEND_COINS +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_SEND_COINS +void* uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_send_coins(void* ptr, RustBuffer coins, void* recipient, RustBuffer amount, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_SEND_IOTA +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_SEND_IOTA +void* uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_send_iota(void* ptr, void* recipient, void* amount, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_SPLIT_COINS +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_SPLIT_COINS +void* uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_split_coins(void* ptr, void* coin, RustBuffer amounts, RustBuffer names, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_SPONSOR +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_SPONSOR +void* uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_sponsor(void* ptr, void* sponsor, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_STAKE +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_STAKE +void* uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_stake(void* ptr, void* stake, void* validator_address, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_TRANSFER_OBJECTS +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_TRANSFER_OBJECTS +void* uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_transfer_objects(void* ptr, void* recipient, RustBuffer objects, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_UNSTAKE +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_UNSTAKE +void* uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_unstake(void* ptr, void* staked_iota, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_UPGRADE +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_CLIENTTRANSACTIONBUILDER_UPGRADE +void* uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_upgrade(void* ptr, void* package_id, void* package_data, void* upgrade_ticket, RustBuffer name, RustCallStatus *out_status +); +#endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_COIN #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_COIN void* uniffi_iota_sdk_ffi_fn_clone_coin(void* ptr, RustCallStatus *out_status @@ -2846,6 +2961,11 @@ void* uniffi_iota_sdk_ffi_fn_method_object_digest(void* ptr, RustCallStatus *out void* uniffi_iota_sdk_ffi_fn_method_object_object_id(void* ptr, RustCallStatus *out_status ); #endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_OBJECT_OBJECT_REF +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_OBJECT_OBJECT_REF +RustBuffer uniffi_iota_sdk_ffi_fn_method_object_object_ref(void* ptr, RustCallStatus *out_status +); +#endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_OBJECT_OBJECT_TYPE #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_OBJECT_OBJECT_TYPE void* uniffi_iota_sdk_ffi_fn_method_object_object_type(void* ptr, RustCallStatus *out_status @@ -3192,6 +3312,11 @@ void* uniffi_iota_sdk_ffi_fn_constructor_ptbargument_object_id(void* id, RustCal void* uniffi_iota_sdk_ffi_fn_constructor_ptbargument_object_id_from_hex(RustBuffer hex, RustCallStatus *out_status ); #endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_PTBARGUMENT_OBJECT_REF +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_PTBARGUMENT_OBJECT_REF +void* uniffi_iota_sdk_ffi_fn_constructor_ptbargument_object_ref(RustBuffer id, RustCallStatus *out_status +); +#endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_PTBARGUMENT_OPTION #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_PTBARGUMENT_OPTION void* uniffi_iota_sdk_ffi_fn_constructor_ptbargument_option(RustBuffer value, RustCallStatus *out_status @@ -4603,24 +4728,14 @@ void* uniffi_iota_sdk_ffi_fn_clone_transactionbuilder(void* ptr, RustCallStatus void uniffi_iota_sdk_ffi_fn_free_transactionbuilder(void* ptr, RustCallStatus *out_status ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_TRANSACTIONBUILDER_INIT -#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_TRANSACTIONBUILDER_INIT -uint64_t uniffi_iota_sdk_ffi_fn_constructor_transactionbuilder_init(void* sender, void* client +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_TRANSACTIONBUILDER_NEW +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_TRANSACTIONBUILDER_NEW +void* uniffi_iota_sdk_ffi_fn_constructor_transactionbuilder_new(void* sender, RustCallStatus *out_status ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTIONBUILDER_DRY_RUN -#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTIONBUILDER_DRY_RUN -uint64_t uniffi_iota_sdk_ffi_fn_method_transactionbuilder_dry_run(void* ptr, int8_t skip_checks -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTIONBUILDER_EXECUTE -#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTIONBUILDER_EXECUTE -uint64_t uniffi_iota_sdk_ffi_fn_method_transactionbuilder_execute(void* ptr, void* keypair, RustBuffer wait_for -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTIONBUILDER_EXECUTE_WITH_SPONSOR -#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTIONBUILDER_EXECUTE_WITH_SPONSOR -uint64_t uniffi_iota_sdk_ffi_fn_method_transactionbuilder_execute_with_sponsor(void* ptr, void* keypair, void* sponsor_keypair, RustBuffer wait_for +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTIONBUILDER_EXECUTE_WITH_GAS_STATION +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTIONBUILDER_EXECUTE_WITH_GAS_STATION +uint64_t uniffi_iota_sdk_ffi_fn_method_transactionbuilder_execute_with_gas_station(void* ptr, void* keypair ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTIONBUILDER_EXPIRATION @@ -4630,12 +4745,12 @@ void* uniffi_iota_sdk_ffi_fn_method_transactionbuilder_expiration(void* ptr, uin #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTIONBUILDER_FINISH #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTIONBUILDER_FINISH -uint64_t uniffi_iota_sdk_ffi_fn_method_transactionbuilder_finish(void* ptr +void* uniffi_iota_sdk_ffi_fn_method_transactionbuilder_finish(void* ptr, RustCallStatus *out_status ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTIONBUILDER_GAS #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTIONBUILDER_GAS -void* uniffi_iota_sdk_ffi_fn_method_transactionbuilder_gas(void* ptr, RustBuffer object_ids, RustCallStatus *out_status +void* uniffi_iota_sdk_ffi_fn_method_transactionbuilder_gas(void* ptr, RustBuffer object_refs, RustCallStatus *out_status ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTIONBUILDER_GAS_BUDGET @@ -4713,6 +4828,11 @@ void* uniffi_iota_sdk_ffi_fn_method_transactionbuilder_unstake(void* ptr, void* void* uniffi_iota_sdk_ffi_fn_method_transactionbuilder_upgrade(void* ptr, void* package_id, void* package_data, void* upgrade_ticket, RustBuffer name, RustCallStatus *out_status ); #endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTIONBUILDER_WITH_CLIENT +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTIONBUILDER_WITH_CLIENT +uint64_t uniffi_iota_sdk_ffi_fn_method_transactionbuilder_with_client(void* ptr, void* client +); +#endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_TRANSACTIONEFFECTS #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_TRANSACTIONEFFECTS void* uniffi_iota_sdk_ffi_fn_clone_transactioneffects(void* ptr, RustCallStatus *out_status @@ -8736,6 +8856,132 @@ uint16_t uniffi_iota_sdk_ffi_checksum_method_checkpointtransactioninfo_signature #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CHECKPOINTTRANSACTIONINFO_TRANSACTION uint16_t uniffi_iota_sdk_ffi_checksum_method_checkpointtransactioninfo_transaction(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_DRY_RUN +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_DRY_RUN +uint16_t uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_dry_run(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_EXECUTE +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_EXECUTE +uint16_t uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_execute(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_EXECUTE_WITH_SPONSOR +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_EXECUTE_WITH_SPONSOR +uint16_t uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_execute_with_sponsor(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_EXPIRATION +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_EXPIRATION +uint16_t uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_expiration(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_FINISH +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_FINISH +uint16_t uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_finish(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_GAS +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_GAS +uint16_t uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_GAS_BUDGET +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_GAS_BUDGET +uint16_t uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas_budget(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_GAS_PRICE +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_GAS_PRICE +uint16_t uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas_price(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_GAS_STATION_SPONSOR +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_GAS_STATION_SPONSOR +uint16_t uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas_station_sponsor(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_MAKE_MOVE_VEC +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_MAKE_MOVE_VEC +uint16_t uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_make_move_vec(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_MERGE_COINS +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_MERGE_COINS +uint16_t uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_merge_coins(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_MOVE_CALL +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_MOVE_CALL +uint16_t uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_move_call(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_PUBLISH +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_PUBLISH +uint16_t uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_publish(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_SEND_COINS +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_SEND_COINS +uint16_t uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_send_coins(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_SEND_IOTA +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_SEND_IOTA +uint16_t uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_send_iota(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_SPLIT_COINS +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_SPLIT_COINS +uint16_t uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_split_coins(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_SPONSOR +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_SPONSOR +uint16_t uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_sponsor(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_STAKE +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_STAKE +uint16_t uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_stake(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_TRANSFER_OBJECTS +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_TRANSFER_OBJECTS +uint16_t uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_transfer_objects(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_UNSTAKE +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_UNSTAKE +uint16_t uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_unstake(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_UPGRADE +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_CLIENTTRANSACTIONBUILDER_UPGRADE +uint16_t uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_upgrade(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_COIN_BALANCE @@ -9834,6 +10080,12 @@ uint16_t uniffi_iota_sdk_ffi_checksum_method_object_digest(void #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_OBJECT_OBJECT_ID uint16_t uniffi_iota_sdk_ffi_checksum_method_object_object_id(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_OBJECT_OBJECT_REF +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_OBJECT_OBJECT_REF +uint16_t uniffi_iota_sdk_ffi_checksum_method_object_object_ref(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_OBJECT_OBJECT_TYPE @@ -10670,21 +10922,9 @@ uint16_t uniffi_iota_sdk_ffi_checksum_method_transaction_to_base64(void ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_TRANSACTIONBUILDER_DRY_RUN -#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_TRANSACTIONBUILDER_DRY_RUN -uint16_t uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_dry_run(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_TRANSACTIONBUILDER_EXECUTE -#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_TRANSACTIONBUILDER_EXECUTE -uint16_t uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_execute(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_TRANSACTIONBUILDER_EXECUTE_WITH_SPONSOR -#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_TRANSACTIONBUILDER_EXECUTE_WITH_SPONSOR -uint16_t uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_execute_with_sponsor(void +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_TRANSACTIONBUILDER_EXECUTE_WITH_GAS_STATION +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_TRANSACTIONBUILDER_EXECUTE_WITH_GAS_STATION +uint16_t uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_execute_with_gas_station(void ); #endif @@ -10794,6 +11034,12 @@ uint16_t uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_unstake(void #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_TRANSACTIONBUILDER_UPGRADE uint16_t uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_upgrade(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_TRANSACTIONBUILDER_WITH_CLIENT +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_TRANSACTIONBUILDER_WITH_CLIENT +uint16_t uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_with_client(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_TRANSACTIONEFFECTS_AS_V1 @@ -12300,6 +12546,12 @@ uint16_t uniffi_iota_sdk_ffi_checksum_constructor_ptbargument_object_id(void #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_PTBARGUMENT_OBJECT_ID_FROM_HEX uint16_t uniffi_iota_sdk_ffi_checksum_constructor_ptbargument_object_id_from_hex(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_PTBARGUMENT_OBJECT_REF +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_PTBARGUMENT_OBJECT_REF +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_ptbargument_object_ref(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_PTBARGUMENT_OPTION @@ -12968,9 +13220,9 @@ uint16_t uniffi_iota_sdk_ffi_checksum_constructor_transaction_new_v1(void ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_TRANSACTIONBUILDER_INIT -#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_TRANSACTIONBUILDER_INIT -uint16_t uniffi_iota_sdk_ffi_checksum_constructor_transactionbuilder_init(void +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_TRANSACTIONBUILDER_NEW +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_TRANSACTIONBUILDER_NEW +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_transactionbuilder_new(void ); #endif diff --git a/bindings/kotlin/examples/DevInspect.kt b/bindings/kotlin/examples/DevInspect.kt index 00df976b0..864a9e43a 100644 --- a/bindings/kotlin/examples/DevInspect.kt +++ b/bindings/kotlin/examples/DevInspect.kt @@ -1,14 +1,7 @@ // Copyright (c) 2025 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import iota_sdk.Address -import iota_sdk.GraphQlClient -import iota_sdk.Identifier -import iota_sdk.ObjectId -import iota_sdk.PtbArgument -import iota_sdk.StructTag -import iota_sdk.TransactionBuilder -import iota_sdk.TypeTag +import iota_sdk.* import kotlin.collections.emptyList import kotlinx.coroutines.runBlocking @@ -31,7 +24,7 @@ fun main() = runBlocking { val name = "name.iota" println("Looking up name: $name") - val builder = TransactionBuilder.init(sender, client) + val builder = TransactionBuilder(sender).withClient(client) // 1. Get the registry builder.moveCall( diff --git a/bindings/kotlin/examples/GasSponsor.kt b/bindings/kotlin/examples/GasSponsor.kt index a1e7a4f5a..a7855b82c 100644 --- a/bindings/kotlin/examples/GasSponsor.kt +++ b/bindings/kotlin/examples/GasSponsor.kt @@ -17,7 +17,7 @@ fun main() = runBlocking { "0x611830d3641a68f94a690dcc25d1f4b0dac948325ac18f6dd32564371735f32c" ) - val builder = TransactionBuilder.init(sender, client) + val builder = TransactionBuilder(sender).withClient(client) val packageAddr = Address.stdLib() val moduleName = Identifier("u8") diff --git a/bindings/kotlin/examples/GasStation.kt b/bindings/kotlin/examples/GasStation.kt index eb2b893a0..86dcf89f1 100644 --- a/bindings/kotlin/examples/GasStation.kt +++ b/bindings/kotlin/examples/GasStation.kt @@ -13,7 +13,7 @@ fun main() = runBlocking { var sender = keypair.publicKey().deriveAddress() var simpleKey = SimpleKeypair.fromEd25519(keypair) - val builder = TransactionBuilder.init(sender, client) + val builder = TransactionBuilder(sender).withClient(client) builder.moveCall( Address.stdLib(), diff --git a/bindings/kotlin/examples/GenericMoveFunction.kt b/bindings/kotlin/examples/GenericMoveFunction.kt index df69a8c12..b4dc41ebf 100644 --- a/bindings/kotlin/examples/GenericMoveFunction.kt +++ b/bindings/kotlin/examples/GenericMoveFunction.kt @@ -1,13 +1,7 @@ // Copyright (c) 2025 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import iota_sdk.Address -import iota_sdk.GraphQlClient -import iota_sdk.Identifier -import iota_sdk.PtbArgument -import iota_sdk.TransactionBuilder -import java.nio.ByteBuffer -import java.nio.ByteOrder +import iota_sdk.* import kotlinx.coroutines.runBlocking fun main() = runBlocking { @@ -19,7 +13,7 @@ fun main() = runBlocking { "0x71b4b4f171b4355ff691b7c470579cf1a926f96f724e5f9a30efc4b5f75d085e" ) - val builder = TransactionBuilder.init(sender, client) + val builder = TransactionBuilder(sender).withClient(client) val address1 = Address.fromHex( @@ -56,10 +50,3 @@ fun main() = runBlocking { kotlin.system.exitProcess(1) } } - -fun uLongToBytes(num: ULong): ByteArray { - return ByteBuffer.allocate(ULong.SIZE_BYTES) - .order(ByteOrder.LITTLE_ENDIAN) - .putLong(num.toLong()) - .array() -} diff --git a/bindings/kotlin/examples/PrepareMergeCoins.kt b/bindings/kotlin/examples/PrepareMergeCoins.kt index 4121e3ddf..7f65f9d18 100644 --- a/bindings/kotlin/examples/PrepareMergeCoins.kt +++ b/bindings/kotlin/examples/PrepareMergeCoins.kt @@ -22,7 +22,7 @@ fun main() = runBlocking { "0xd04077fe3b6fad13b3d4ed0d535b7ca92afcac8f0f2a0e0925fb9f4f0b30c699" ) - val builder = TransactionBuilder.init(sender, client) + val builder = TransactionBuilder(sender).withClient(client) builder.mergeCoins(coin0, listOf(coin1)) diff --git a/bindings/kotlin/examples/PrepareSendCoins.kt b/bindings/kotlin/examples/PrepareSendCoins.kt index 37e40e02b..f72413698 100644 --- a/bindings/kotlin/examples/PrepareSendCoins.kt +++ b/bindings/kotlin/examples/PrepareSendCoins.kt @@ -24,7 +24,7 @@ fun main() = runBlocking { "0x8ef4259fa2a3499826fa4b8aebeb1d8e478cf5397d05361c96438940b43d28c9" ) - val builder = TransactionBuilder.init(fromAddress, client) + val builder = TransactionBuilder(fromAddress).withClient(client) builder.sendCoins(listOf(coinId), toAddress, PtbArgument.u64(50000000000uL)) diff --git a/bindings/kotlin/examples/PrepareSendIota.kt b/bindings/kotlin/examples/PrepareSendIota.kt index 04c31bc38..e433834e0 100644 --- a/bindings/kotlin/examples/PrepareSendIota.kt +++ b/bindings/kotlin/examples/PrepareSendIota.kt @@ -18,7 +18,7 @@ fun main() = runBlocking { "0x0000a4984bd495d4346fa208ddff4f5d5e5ad48c21dec631ddebc99809f16900" ) - val builder = TransactionBuilder.init(fromAddress, client) + val builder = TransactionBuilder(fromAddress).withClient(client) builder.sendIota( toAddress, diff --git a/bindings/kotlin/examples/PrepareSendIotaMulti.kt b/bindings/kotlin/examples/PrepareSendIotaMulti.kt index 25af24d24..2f2fab558 100644 --- a/bindings/kotlin/examples/PrepareSendIotaMulti.kt +++ b/bindings/kotlin/examples/PrepareSendIotaMulti.kt @@ -39,7 +39,7 @@ fun main() = runBlocking { ) ) - val builder = TransactionBuilder.init(sender, client) + val builder = TransactionBuilder(sender).withClient(client) val labels = recipients.indices.map { "coin${it}" } val amounts = recipients.map { PtbArgument.u64(it.second) } diff --git a/bindings/kotlin/examples/PrepareSplitCoins.kt b/bindings/kotlin/examples/PrepareSplitCoins.kt index 62810b71f..812375ac9 100644 --- a/bindings/kotlin/examples/PrepareSplitCoins.kt +++ b/bindings/kotlin/examples/PrepareSplitCoins.kt @@ -18,7 +18,7 @@ fun main() = runBlocking { "0x0b0270ee9d27da0db09651e5f7338dfa32c7ee6441ccefa1f6e305735bcfc7ab" ) - val builder = TransactionBuilder.init(sender, client) + val builder = TransactionBuilder(sender).withClient(client) builder.splitCoins( PtbArgument.objectId(coinId), diff --git a/bindings/kotlin/examples/PrepareTransferObjects.kt b/bindings/kotlin/examples/PrepareTransferObjects.kt index 9a0af89e1..c7c220956 100644 --- a/bindings/kotlin/examples/PrepareTransferObjects.kt +++ b/bindings/kotlin/examples/PrepareTransferObjects.kt @@ -29,7 +29,7 @@ fun main() = runBlocking { ) ) - val builder = TransactionBuilder.init(fromAddress, client) + val builder = TransactionBuilder(fromAddress).withClient(client) builder.transferObjects(toAddress, objsToTransfer) diff --git a/bindings/kotlin/examples/PrepareTransferObjectsOffline.kt b/bindings/kotlin/examples/PrepareTransferObjectsOffline.kt new file mode 100644 index 000000000..5aad7ac5e --- /dev/null +++ b/bindings/kotlin/examples/PrepareTransferObjectsOffline.kt @@ -0,0 +1,70 @@ +// Copyright (c) 2025 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import iota_sdk.* +import kotlinx.coroutines.runBlocking + +fun main() = runBlocking { + try { + val client = GraphQlClient.newDevnet() + + val fromAddress = + Address.fromHex( + "0x611830d3641a68f94a690dcc25d1f4b0dac948325ac18f6dd32564371735f32c" + ) + val toAddress = + Address.fromHex( + "0x0000a4984bd495d4346fa208ddff4f5d5e5ad48c21dec631ddebc99809f16900" + ) + val objects = + listOf( + ObjectId.fromHex( + "0xd04077fe3b6fad13b3d4ed0d535b7ca92afcac8f0f2a0e0925fb9f4f0b30c699" + ), + ObjectId.fromHex( + "0x0b0270ee9d27da0db09651e5f7338dfa32c7ee6441ccefa1f6e305735bcfc7ab" + ), + ObjectId.fromHex( + "0x8ef4259fa2a3499826fa4b8aebeb1d8e478cf5397d05361c96438940b43d28c9" + ) + ) + val objsToTransfer = + objects.map { + val obj = client.`object`(it) + if (obj == null) { + throw Exception("Missing object: ${it}") + } + PtbArgument.objectRef(obj.objectRef()) + } + val gasCoinId = + ObjectId.fromHex( + "0xd04077fe3b6fad13b3d4ed0d535b7ca92afcac8f0f2a0e0925fb9f4f0b30c699" + ) + val gasCoin = client.`object`(gasCoinId) + if (gasCoin == null) { + throw Exception("Missing gas coin: ${gasCoinId}") + } + var gasPrice = client.referenceGasPrice() + + val builder = TransactionBuilder(fromAddress) + + builder.transferObjects(toAddress, objsToTransfer) + builder.gas(listOf(gasCoin.objectRef())).gasPrice(gasPrice ?: 100uL).gasBudget(500000000uL) + + val txn = builder.finish() + + println("Signing Digest: ${txn.signingDigestHex()}") + println("Txn Bytes: ${txn.toBase64()}") + + val res = client.dryRunTx(txn) + + if (res.error != null) { + throw Exception("Failed to transfer objects: ${res.error}") + } + + println("Transfer objects dry run was successful!") + } catch (e: Exception) { + e.printStackTrace() + kotlin.system.exitProcess(1) + } +} diff --git a/bindings/kotlin/examples/PublishUpgrade.kt b/bindings/kotlin/examples/PublishUpgrade.kt index 920544460..378835292 100644 --- a/bindings/kotlin/examples/PublishUpgrade.kt +++ b/bindings/kotlin/examples/PublishUpgrade.kt @@ -57,7 +57,7 @@ fun main() = runBlocking { val client = GraphQlClient.newLocalnet() // Build the `publish` PTB - val builderPublish = TransactionBuilder.init(sender, client) + val builderPublish = TransactionBuilder(sender).withClient(client) // Publish the package and receive the upgrade cap in return builderPublish.publish(packageData, "upgrade_cap") // Transfer the upgrade cap to the sender address @@ -114,7 +114,7 @@ fun main() = runBlocking { } // Build the `upgrade` PTB, that consists of 3 steps - val builderUpgrade = TransactionBuilder.init(sender, client) + val builderUpgrade = TransactionBuilder(sender).withClient(client) // Authorize the upgrade by providing the upgrade cap object id to receive an upgrade // ticket diff --git a/bindings/kotlin/examples/SignSendIota.kt b/bindings/kotlin/examples/SignSendIota.kt index a670055bf..ba687e59d 100644 --- a/bindings/kotlin/examples/SignSendIota.kt +++ b/bindings/kotlin/examples/SignSendIota.kt @@ -24,7 +24,7 @@ fun main() = runBlocking { val client = GraphQlClient.newLocalnet() - val builder = TransactionBuilder.init(senderAddress, client) + val builder = TransactionBuilder(senderAddress).withClient(client) builder.sendIota(recipientAddress, PtbArgument.u64(amount)) val txn = builder.finish() diff --git a/bindings/kotlin/examples/Stake.kt b/bindings/kotlin/examples/Stake.kt index ba6644fcf..bb6348210 100644 --- a/bindings/kotlin/examples/Stake.kt +++ b/bindings/kotlin/examples/Stake.kt @@ -1,10 +1,7 @@ // Copyright (c) 2025 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import iota_sdk.Address -import iota_sdk.GraphQlClient -import iota_sdk.PtbArgument -import iota_sdk.TransactionBuilder +import iota_sdk.* import kotlinx.coroutines.runBlocking fun main() = runBlocking { @@ -24,7 +21,7 @@ fun main() = runBlocking { println("Staking to validator ${validator.name ?: "with no name"}") - val builder = TransactionBuilder.init(myAddress, client) + val builder = TransactionBuilder(myAddress).withClient(client) builder.stake(PtbArgument.u64(1000000000uL), validator.address) diff --git a/bindings/kotlin/examples/TxCommandResults.kt b/bindings/kotlin/examples/TxCommandResults.kt index 37c677f87..4f9e6f515 100644 --- a/bindings/kotlin/examples/TxCommandResults.kt +++ b/bindings/kotlin/examples/TxCommandResults.kt @@ -13,7 +13,7 @@ fun main() = runBlocking { "0x611830d3641a68f94a690dcc25d1f4b0dac948325ac18f6dd32564371735f32c" ) - val builder = TransactionBuilder.init(sender, client) + val builder = TransactionBuilder(sender).withClient(client) val packageAddr = Address.stdLib() val moduleName = Identifier("u64") diff --git a/bindings/kotlin/examples/Unstake.kt b/bindings/kotlin/examples/Unstake.kt index 2430bf8d2..c9d1ce3d6 100644 --- a/bindings/kotlin/examples/Unstake.kt +++ b/bindings/kotlin/examples/Unstake.kt @@ -1,11 +1,7 @@ // Copyright (c) 2025 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import iota_sdk.GraphQlClient -import iota_sdk.ObjectFilter -import iota_sdk.PtbArgument -import iota_sdk.StructTag -import iota_sdk.TransactionBuilder +import iota_sdk.* import kotlinx.coroutines.runBlocking fun main() = runBlocking { @@ -19,7 +15,7 @@ fun main() = runBlocking { } val stakedIota = stakedIotas.data[0] - val builder = TransactionBuilder.init(stakedIota.owner().asAddress(), client) + val builder = TransactionBuilder(stakedIota.owner().asAddress()).withClient(client) builder.unstake(PtbArgument.objectId(stakedIota.objectId())) diff --git a/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt b/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt index d71270798..d6d07e7ae 100644 --- a/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt +++ b/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt @@ -2992,6 +2992,52 @@ internal interface UniffiForeignFutureCompleteVoid : com.sun.jna.Callback { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -3598,6 +3644,48 @@ fun uniffi_iota_sdk_ffi_checksum_method_checkpointtransactioninfo_signatures( ): Short fun uniffi_iota_sdk_ffi_checksum_method_checkpointtransactioninfo_transaction( ): Short +fun uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_dry_run( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_execute( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_execute_with_sponsor( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_expiration( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_finish( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas_budget( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas_price( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas_station_sponsor( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_make_move_vec( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_merge_coins( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_move_call( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_publish( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_send_coins( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_send_iota( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_split_coins( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_sponsor( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_stake( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_transfer_objects( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_unstake( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_upgrade( +): Short fun uniffi_iota_sdk_ffi_checksum_method_coin_balance( ): Short fun uniffi_iota_sdk_ffi_checksum_method_coin_coin_type( @@ -3964,6 +4052,8 @@ fun uniffi_iota_sdk_ffi_checksum_method_object_digest( ): Short fun uniffi_iota_sdk_ffi_checksum_method_object_object_id( ): Short +fun uniffi_iota_sdk_ffi_checksum_method_object_object_ref( +): Short fun uniffi_iota_sdk_ffi_checksum_method_object_object_type( ): Short fun uniffi_iota_sdk_ffi_checksum_method_object_owner( @@ -4242,11 +4332,7 @@ fun uniffi_iota_sdk_ffi_checksum_method_transaction_signing_digest_hex( ): Short fun uniffi_iota_sdk_ffi_checksum_method_transaction_to_base64( ): Short -fun uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_dry_run( -): Short -fun uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_execute( -): Short -fun uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_execute_with_sponsor( +fun uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_execute_with_gas_station( ): Short fun uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_expiration( ): Short @@ -4284,6 +4370,8 @@ fun uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_unstake( ): Short fun uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_upgrade( ): Short +fun uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_with_client( +): Short fun uniffi_iota_sdk_ffi_checksum_method_transactioneffects_as_v1( ): Short fun uniffi_iota_sdk_ffi_checksum_method_transactioneffects_digest( @@ -4786,6 +4874,8 @@ fun uniffi_iota_sdk_ffi_checksum_constructor_ptbargument_object_id( ): Short fun uniffi_iota_sdk_ffi_checksum_constructor_ptbargument_object_id_from_hex( ): Short +fun uniffi_iota_sdk_ffi_checksum_constructor_ptbargument_object_ref( +): Short fun uniffi_iota_sdk_ffi_checksum_constructor_ptbargument_option( ): Short fun uniffi_iota_sdk_ffi_checksum_constructor_ptbargument_receiving( @@ -5008,7 +5098,7 @@ fun uniffi_iota_sdk_ffi_checksum_constructor_transaction_from_base64( ): Short fun uniffi_iota_sdk_ffi_checksum_constructor_transaction_new_v1( ): Short -fun uniffi_iota_sdk_ffi_checksum_constructor_transactionbuilder_init( +fun uniffi_iota_sdk_ffi_checksum_constructor_transactionbuilder_new( ): Short fun uniffi_iota_sdk_ffi_checksum_constructor_transactioneffects_new_v1( ): Short @@ -5407,6 +5497,52 @@ fun uniffi_iota_sdk_ffi_fn_free_circomg2(`ptr`: Pointer,uniffi_out_err: UniffiRu ): Unit fun uniffi_iota_sdk_ffi_fn_constructor_circomg2_new(`el00`: Pointer,`el01`: Pointer,`el10`: Pointer,`el11`: Pointer,`el20`: Pointer,`el21`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Pointer +fun uniffi_iota_sdk_ffi_fn_clone_clienttransactionbuilder(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_free_clienttransactionbuilder(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Unit +fun uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_dry_run(`ptr`: Pointer,`skipChecks`: Byte, +): Long +fun uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_execute(`ptr`: Pointer,`keypair`: Pointer,`waitFor`: RustBuffer.ByValue, +): Long +fun uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_execute_with_sponsor(`ptr`: Pointer,`keypair`: Pointer,`sponsorKeypair`: Pointer,`waitFor`: RustBuffer.ByValue, +): Long +fun uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_expiration(`ptr`: Pointer,`epoch`: Long,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_finish(`ptr`: Pointer, +): Long +fun uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas(`ptr`: Pointer,`objectIds`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas_budget(`ptr`: Pointer,`budget`: Long,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas_price(`ptr`: Pointer,`price`: Long,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas_station_sponsor(`ptr`: Pointer,`url`: RustBuffer.ByValue,`duration`: RustBuffer.ByValue,`headers`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_make_move_vec(`ptr`: Pointer,`elements`: RustBuffer.ByValue,`typeTag`: Pointer,`name`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_merge_coins(`ptr`: Pointer,`primaryCoin`: Pointer,`consumedCoins`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_move_call(`ptr`: Pointer,`package`: Pointer,`module`: Pointer,`function`: Pointer,`arguments`: RustBuffer.ByValue,`typeArgs`: RustBuffer.ByValue,`names`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_publish(`ptr`: Pointer,`packageData`: Pointer,`upgradeCapName`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_send_coins(`ptr`: Pointer,`coins`: RustBuffer.ByValue,`recipient`: Pointer,`amount`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_send_iota(`ptr`: Pointer,`recipient`: Pointer,`amount`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_split_coins(`ptr`: Pointer,`coin`: Pointer,`amounts`: RustBuffer.ByValue,`names`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_sponsor(`ptr`: Pointer,`sponsor`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_stake(`ptr`: Pointer,`stake`: Pointer,`validatorAddress`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_transfer_objects(`ptr`: Pointer,`recipient`: Pointer,`objects`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_unstake(`ptr`: Pointer,`stakedIota`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_upgrade(`ptr`: Pointer,`packageId`: Pointer,`packageData`: Pointer,`upgradeTicket`: Pointer,`name`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Pointer fun uniffi_iota_sdk_ffi_fn_clone_coin(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_iota_sdk_ffi_fn_free_coin(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, @@ -6125,6 +6261,8 @@ fun uniffi_iota_sdk_ffi_fn_method_object_digest(`ptr`: Pointer,uniffi_out_err: U ): Pointer fun uniffi_iota_sdk_ffi_fn_method_object_object_id(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Pointer +fun uniffi_iota_sdk_ffi_fn_method_object_object_ref(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue fun uniffi_iota_sdk_ffi_fn_method_object_object_type(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_iota_sdk_ffi_fn_method_object_owner(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, @@ -6261,6 +6399,8 @@ fun uniffi_iota_sdk_ffi_fn_constructor_ptbargument_object_id(`id`: Pointer,uniff ): Pointer fun uniffi_iota_sdk_ffi_fn_constructor_ptbargument_object_id_from_hex(`hex`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Pointer +fun uniffi_iota_sdk_ffi_fn_constructor_ptbargument_object_ref(`id`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Pointer fun uniffi_iota_sdk_ffi_fn_constructor_ptbargument_option(`value`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_iota_sdk_ffi_fn_constructor_ptbargument_receiving(`id`: Pointer,uniffi_out_err: UniffiRustCallStatus, @@ -6813,19 +6953,15 @@ fun uniffi_iota_sdk_ffi_fn_clone_transactionbuilder(`ptr`: Pointer,uniffi_out_er ): Pointer fun uniffi_iota_sdk_ffi_fn_free_transactionbuilder(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Unit -fun uniffi_iota_sdk_ffi_fn_constructor_transactionbuilder_init(`sender`: Pointer,`client`: Pointer, -): Long -fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_dry_run(`ptr`: Pointer,`skipChecks`: Byte, -): Long -fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_execute(`ptr`: Pointer,`keypair`: Pointer,`waitFor`: RustBuffer.ByValue, -): Long -fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_execute_with_sponsor(`ptr`: Pointer,`keypair`: Pointer,`sponsorKeypair`: Pointer,`waitFor`: RustBuffer.ByValue, +fun uniffi_iota_sdk_ffi_fn_constructor_transactionbuilder_new(`sender`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_execute_with_gas_station(`ptr`: Pointer,`keypair`: Pointer, ): Long fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_expiration(`ptr`: Pointer,`epoch`: Long,uniffi_out_err: UniffiRustCallStatus, ): Pointer -fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_finish(`ptr`: Pointer, -): Long -fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_gas(`ptr`: Pointer,`objectIds`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_finish(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_gas(`ptr`: Pointer,`objectRefs`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_gas_budget(`ptr`: Pointer,`budget`: Long,uniffi_out_err: UniffiRustCallStatus, ): Pointer @@ -6857,6 +6993,8 @@ fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_unstake(`ptr`: Pointer,`sta ): Pointer fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_upgrade(`ptr`: Pointer,`packageId`: Pointer,`packageData`: Pointer,`upgradeTicket`: Pointer,`name`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Pointer +fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_with_client(`ptr`: Pointer,`client`: Pointer, +): Long fun uniffi_iota_sdk_ffi_fn_clone_transactioneffects(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_iota_sdk_ffi_fn_free_transactioneffects(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, @@ -8646,6 +8784,69 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_method_checkpointtransactioninfo_transaction() != 58570.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_dry_run() != 10983.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_execute() != 45165.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_execute_with_sponsor() != 64410.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_expiration() != 32958.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_finish() != 56677.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas() != 522.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas_budget() != 27427.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas_price() != 56003.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas_station_sponsor() != 25572.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_make_move_vec() != 4858.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_merge_coins() != 43478.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_move_call() != 13617.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_publish() != 25909.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_send_coins() != 65187.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_send_iota() != 65011.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_split_coins() != 2932.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_sponsor() != 44990.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_stake() != 9961.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_transfer_objects() != 23790.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_unstake() != 40181.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_upgrade() != 59977.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_iota_sdk_ffi_checksum_method_coin_balance() != 29928.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -9195,6 +9396,9 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_method_object_object_id() != 6575.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_iota_sdk_ffi_checksum_method_object_object_ref() != 13587.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_iota_sdk_ffi_checksum_method_object_object_type() != 1843.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -9612,22 +9816,16 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_method_transaction_to_base64() != 51030.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_dry_run() != 11138.toShort()) { - throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - } - if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_execute() != 45882.toShort()) { - throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - } - if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_execute_with_sponsor() != 45688.toShort()) { + if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_execute_with_gas_station() != 6268.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_expiration() != 5328.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_finish() != 32200.toShort()) { + if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_finish() != 39582.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_gas() != 26787.toShort()) { + if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_gas() != 23371.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_gas_budget() != 48686.toShort()) { @@ -9657,7 +9855,7 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_send_iota() != 2185.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_split_coins() != 25229.toShort()) { + if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_split_coins() != 17747.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_sponsor() != 25655.toShort()) { @@ -9675,6 +9873,9 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_upgrade() != 14493.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_with_client() != 32496.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_iota_sdk_ffi_checksum_method_transactioneffects_as_v1() != 48710.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -10428,6 +10629,9 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_constructor_ptbargument_object_id_from_hex() != 47640.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_ptbargument_object_ref() != 24215.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_iota_sdk_ffi_checksum_constructor_ptbargument_option() != 37559.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -10761,7 +10965,7 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_constructor_transaction_new_v1() != 58632.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_iota_sdk_ffi_checksum_constructor_transactionbuilder_init() != 29935.toShort()) { + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_transactionbuilder_new() != 35216.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } if (lib.uniffi_iota_sdk_ffi_checksum_constructor_transactioneffects_new_v1() != 63561.toShort()) { @@ -17262,18 +17466,804 @@ public object FfiConverterTypeCircomG2: FfiConverter { // -public interface CoinInterface { +/** + * A builder for creating transactions which uses a GraphQL client to + * automatically resolve inputs. Use `finish` to finalize the transaction data. + */ +public interface ClientTransactionBuilderInterface { - fun `balance`(): kotlin.ULong + /** + * Dry run the transaction. + */ + suspend fun `dryRun`(`skipChecks`: kotlin.Boolean = false): DryRunResult - fun `coinType`(): TypeTag + /** + * Execute the transaction and optionally wait for finalization. + */ + suspend fun `execute`(`keypair`: SimpleKeypair, `waitFor`: WaitForTx? = null): TransactionEffects - fun `id`(): ObjectId + /** + * Execute the transaction and optionally wait for finalization. + */ + suspend fun `executeWithSponsor`(`keypair`: SimpleKeypair, `sponsorKeypair`: SimpleKeypair, `waitFor`: WaitForTx? = null): TransactionEffects + + /** + * Set the expiration of the transaction to be a specific epoch. + */ + fun `expiration`(`epoch`: kotlin.ULong): ClientTransactionBuilder + + /** + * Convert this builder into a transaction. + */ + suspend fun `finish`(): Transaction + + /** + * Add gas coins that will be consumed. Optional. + */ + fun `gas`(`objectIds`: List): ClientTransactionBuilder + + /** + * Set the gas budget for the transaction. + */ + fun `gasBudget`(`budget`: kotlin.ULong): ClientTransactionBuilder + + /** + * Set the gas price for the transaction. + */ + fun `gasPrice`(`price`: kotlin.ULong): ClientTransactionBuilder + + /** + * Set the gas station sponsor. + */ + fun `gasStationSponsor`(`url`: kotlin.String, `duration`: java.time.Duration? = null, `headers`: Map>? = null): ClientTransactionBuilder + + /** + * Make a move vector from a list of elements. The elements must all be of + * the type indicated by `type_tag`. + */ + fun `makeMoveVec`(`elements`: List, `typeTag`: TypeTag, `name`: kotlin.String): ClientTransactionBuilder + + /** + * Merge multiple coins into one. + * + * This method combines the balances of multiple coins of the same coin + * type into a single coin. The `primary_coin` will receive the balances + * from all `consumed_coins`. After merging, the `consumed_coins` will + * be consumed and no longer exist. + */ + fun `mergeCoins`(`primaryCoin`: PtbArgument, `consumedCoins`: List): ClientTransactionBuilder + + /** + * Call a Move function with the given arguments. + */ + fun `moveCall`(`package`: Address, `module`: Identifier, `function`: Identifier, `arguments`: List = listOf(), `typeArgs`: List = listOf(), `names`: List = listOf()): ClientTransactionBuilder + + /** + * Publish a list of modules with the given dependencies. The result + * assigned to `upgrade_cap_name` is the `0x2::package::UpgradeCap` + * Move type. Note that the upgrade capability needs to be handled + * after this call: + * - transfer it to the transaction sender or another address + * - burn it + * - wrap it for access control + * - discard the it to make a package immutable + * + * The arguments required for this command are: + * - `modules`: is the modules' bytecode to be published + * - `dependencies`: is the list of IDs of the transitive dependencies of + * the package + */ + fun `publish`(`packageData`: MovePackageData, `upgradeCapName`: kotlin.String): ClientTransactionBuilder + + /** + * Transfer some coins to a recipient address. If multiple coins are + * provided then they will be merged. + * + * The `amount` parameter specifies the quantity in NANOS, where 1 IOTA + * equals 1_000_000_000 NANOS. + * If `amount` is provided, that amount is split from the provided coins + * and sent. + * If `amount` is `None`, the entire coins are transferred. + * + * All provided coins must have the same coin type. Mixing coins of + * different types will result in an error. + * + * If you intend to transfer all provided coins to another address in a + * single transaction, consider using + * `TransactionBuilder::transfer_objects()` instead. + */ + fun `sendCoins`(`coins`: List, `recipient`: Address, `amount`: PtbArgument? = null): ClientTransactionBuilder + + /** + * Send IOTA to a recipient address. + * + * The `amount` parameter specifies the quantity in NANOS, where 1 IOTA + * equals 1_000_000_000 NANOS. That amount is split from the gas coin and + * sent. + */ + fun `sendIota`(`recipient`: Address, `amount`: PtbArgument): ClientTransactionBuilder + + /** + * Split a coin into many. + */ + fun `splitCoins`(`coin`: PtbArgument, `amounts`: List, `names`: List = listOf()): ClientTransactionBuilder + + /** + * Set the sponsor of the transaction. + */ + fun `sponsor`(`sponsor`: Address): ClientTransactionBuilder + + /** + * Add stake to a validator's staking pool. + * + * This is a high-level function which will split the provided stake amount + * from the gas coin and then stake using the resulting coin. + */ + fun `stake`(`stake`: PtbArgument, `validatorAddress`: Address): ClientTransactionBuilder + + /** + * Transfer a list of objects to the given address, without producing any + * result. + */ + fun `transferObjects`(`recipient`: Address, `objects`: List): ClientTransactionBuilder + + /** + * Withdraw stake from a validator's staking pool. + */ + fun `unstake`(`stakedIota`: PtbArgument): ClientTransactionBuilder + + /** + * Upgrade a Move package. + * + * - `modules`: is the modules' bytecode for the modules to be published + * - `dependencies`: is the list of IDs of the transitive dependencies of + * the package to be upgraded + * - `package`: is the ID of the current package being upgraded + * - `ticket`: is the upgrade ticket + * + * To get the ticket, you have to call the + * `0x2::package::authorize_upgrade` function, and pass the package + * ID, the upgrade policy, and package digest. + */ + fun `upgrade`(`packageId`: ObjectId, `packageData`: MovePackageData, `upgradeTicket`: PtbArgument, `name`: kotlin.String? = null): ClientTransactionBuilder companion object } -open class Coin: Disposable, AutoCloseable, CoinInterface +/** + * A builder for creating transactions which uses a GraphQL client to + * automatically resolve inputs. Use `finish` to finalize the transaction data. + */ +open class ClientTransactionBuilder: Disposable, AutoCloseable, ClientTransactionBuilderInterface +{ + + constructor(pointer: Pointer) { + this.pointer = pointer + this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer)) + } + + /** + * This constructor can be used to instantiate a fake object. Only used for tests. Any + * attempt to actually use an object constructed this way will fail as there is no + * connected Rust object. + */ + @Suppress("UNUSED_PARAMETER") + constructor(noPointer: NoPointer) { + this.pointer = null + this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer)) + } + + protected val pointer: Pointer? + protected val cleanable: UniffiCleaner.Cleanable + + private val wasDestroyed = AtomicBoolean(false) + private val callCounter = AtomicLong(1) + + override fun destroy() { + // Only allow a single call to this method. + // TODO: maybe we should log a warning if called more than once? + if (this.wasDestroyed.compareAndSet(false, true)) { + // This decrement always matches the initial count of 1 given at creation time. + if (this.callCounter.decrementAndGet() == 0L) { + cleanable.clean() + } + } + } + + @Synchronized + override fun close() { + this.destroy() + } + + internal inline fun callWithPointer(block: (ptr: Pointer) -> R): R { + // Check and increment the call counter, to keep the object alive. + // This needs a compare-and-set retry loop in case of concurrent updates. + do { + val c = this.callCounter.get() + if (c == 0L) { + throw IllegalStateException("${this.javaClass.simpleName} object has already been destroyed") + } + if (c == Long.MAX_VALUE) { + throw IllegalStateException("${this.javaClass.simpleName} call counter would overflow") + } + } while (! this.callCounter.compareAndSet(c, c + 1L)) + // Now we can safely do the method call without the pointer being freed concurrently. + try { + return block(this.uniffiClonePointer()) + } finally { + // This decrement always matches the increment we performed above. + if (this.callCounter.decrementAndGet() == 0L) { + cleanable.clean() + } + } + } + + // Use a static inner class instead of a closure so as not to accidentally + // capture `this` as part of the cleanable's action. + private class UniffiCleanAction(private val pointer: Pointer?) : Runnable { + override fun run() { + pointer?.let { ptr -> + uniffiRustCall { status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_free_clienttransactionbuilder(ptr, status) + } + } + } + } + + fun uniffiClonePointer(): Pointer { + return uniffiRustCall() { status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_clone_clienttransactionbuilder(pointer!!, status) + } + } + + + /** + * Dry run the transaction. + */ + @Throws(SdkFfiException::class) + @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") + override suspend fun `dryRun`(`skipChecks`: kotlin.Boolean) : DryRunResult { + return uniffiRustCallAsync( + callWithPointer { thisPtr -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_dry_run( + thisPtr, + FfiConverterBoolean.lower(`skipChecks`), + ) + }, + { future, callback, continuation -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_poll_rust_buffer(future, callback, continuation) }, + { future, continuation -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_complete_rust_buffer(future, continuation) }, + { future -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_free_rust_buffer(future) }, + // lift function + { FfiConverterTypeDryRunResult.lift(it) }, + // Error FFI converter + SdkFfiException.ErrorHandler, + ) + } + + + /** + * Execute the transaction and optionally wait for finalization. + */ + @Throws(SdkFfiException::class) + @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") + override suspend fun `execute`(`keypair`: SimpleKeypair, `waitFor`: WaitForTx?) : TransactionEffects { + return uniffiRustCallAsync( + callWithPointer { thisPtr -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_execute( + thisPtr, + FfiConverterTypeSimpleKeypair.lower(`keypair`),FfiConverterOptionalTypeWaitForTx.lower(`waitFor`), + ) + }, + { future, callback, continuation -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_poll_pointer(future, callback, continuation) }, + { future, continuation -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_complete_pointer(future, continuation) }, + { future -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_free_pointer(future) }, + // lift function + { FfiConverterTypeTransactionEffects.lift(it) }, + // Error FFI converter + SdkFfiException.ErrorHandler, + ) + } + + + /** + * Execute the transaction and optionally wait for finalization. + */ + @Throws(SdkFfiException::class) + @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") + override suspend fun `executeWithSponsor`(`keypair`: SimpleKeypair, `sponsorKeypair`: SimpleKeypair, `waitFor`: WaitForTx?) : TransactionEffects { + return uniffiRustCallAsync( + callWithPointer { thisPtr -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_execute_with_sponsor( + thisPtr, + FfiConverterTypeSimpleKeypair.lower(`keypair`),FfiConverterTypeSimpleKeypair.lower(`sponsorKeypair`),FfiConverterOptionalTypeWaitForTx.lower(`waitFor`), + ) + }, + { future, callback, continuation -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_poll_pointer(future, callback, continuation) }, + { future, continuation -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_complete_pointer(future, continuation) }, + { future -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_free_pointer(future) }, + // lift function + { FfiConverterTypeTransactionEffects.lift(it) }, + // Error FFI converter + SdkFfiException.ErrorHandler, + ) + } + + + /** + * Set the expiration of the transaction to be a specific epoch. + */override fun `expiration`(`epoch`: kotlin.ULong): ClientTransactionBuilder { + return FfiConverterTypeClientTransactionBuilder.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_expiration( + it, FfiConverterULong.lower(`epoch`),_status) +} + } + ) + } + + + + /** + * Convert this builder into a transaction. + */ + @Throws(SdkFfiException::class) + @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") + override suspend fun `finish`() : Transaction { + return uniffiRustCallAsync( + callWithPointer { thisPtr -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_finish( + thisPtr, + + ) + }, + { future, callback, continuation -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_poll_pointer(future, callback, continuation) }, + { future, continuation -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_complete_pointer(future, continuation) }, + { future -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_free_pointer(future) }, + // lift function + { FfiConverterTypeTransaction.lift(it) }, + // Error FFI converter + SdkFfiException.ErrorHandler, + ) + } + + + /** + * Add gas coins that will be consumed. Optional. + */override fun `gas`(`objectIds`: List): ClientTransactionBuilder { + return FfiConverterTypeClientTransactionBuilder.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas( + it, FfiConverterSequenceTypeObjectId.lower(`objectIds`),_status) +} + } + ) + } + + + + /** + * Set the gas budget for the transaction. + */override fun `gasBudget`(`budget`: kotlin.ULong): ClientTransactionBuilder { + return FfiConverterTypeClientTransactionBuilder.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas_budget( + it, FfiConverterULong.lower(`budget`),_status) +} + } + ) + } + + + + /** + * Set the gas price for the transaction. + */override fun `gasPrice`(`price`: kotlin.ULong): ClientTransactionBuilder { + return FfiConverterTypeClientTransactionBuilder.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas_price( + it, FfiConverterULong.lower(`price`),_status) +} + } + ) + } + + + + /** + * Set the gas station sponsor. + */override fun `gasStationSponsor`(`url`: kotlin.String, `duration`: java.time.Duration?, `headers`: Map>?): ClientTransactionBuilder { + return FfiConverterTypeClientTransactionBuilder.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas_station_sponsor( + it, FfiConverterString.lower(`url`),FfiConverterOptionalDuration.lower(`duration`),FfiConverterOptionalMapStringSequenceString.lower(`headers`),_status) +} + } + ) + } + + + + /** + * Make a move vector from a list of elements. The elements must all be of + * the type indicated by `type_tag`. + */override fun `makeMoveVec`(`elements`: List, `typeTag`: TypeTag, `name`: kotlin.String): ClientTransactionBuilder { + return FfiConverterTypeClientTransactionBuilder.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_make_move_vec( + it, FfiConverterSequenceTypeMoveArg.lower(`elements`),FfiConverterTypeTypeTag.lower(`typeTag`),FfiConverterString.lower(`name`),_status) +} + } + ) + } + + + + /** + * Merge multiple coins into one. + * + * This method combines the balances of multiple coins of the same coin + * type into a single coin. The `primary_coin` will receive the balances + * from all `consumed_coins`. After merging, the `consumed_coins` will + * be consumed and no longer exist. + */override fun `mergeCoins`(`primaryCoin`: PtbArgument, `consumedCoins`: List): ClientTransactionBuilder { + return FfiConverterTypeClientTransactionBuilder.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_merge_coins( + it, FfiConverterTypePTBArgument.lower(`primaryCoin`),FfiConverterSequenceTypePTBArgument.lower(`consumedCoins`),_status) +} + } + ) + } + + + + /** + * Call a Move function with the given arguments. + */override fun `moveCall`(`package`: Address, `module`: Identifier, `function`: Identifier, `arguments`: List, `typeArgs`: List, `names`: List): ClientTransactionBuilder { + return FfiConverterTypeClientTransactionBuilder.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_move_call( + it, FfiConverterTypeAddress.lower(`package`),FfiConverterTypeIdentifier.lower(`module`),FfiConverterTypeIdentifier.lower(`function`),FfiConverterSequenceTypePTBArgument.lower(`arguments`),FfiConverterSequenceTypeTypeTag.lower(`typeArgs`),FfiConverterSequenceString.lower(`names`),_status) +} + } + ) + } + + + + /** + * Publish a list of modules with the given dependencies. The result + * assigned to `upgrade_cap_name` is the `0x2::package::UpgradeCap` + * Move type. Note that the upgrade capability needs to be handled + * after this call: + * - transfer it to the transaction sender or another address + * - burn it + * - wrap it for access control + * - discard the it to make a package immutable + * + * The arguments required for this command are: + * - `modules`: is the modules' bytecode to be published + * - `dependencies`: is the list of IDs of the transitive dependencies of + * the package + */override fun `publish`(`packageData`: MovePackageData, `upgradeCapName`: kotlin.String): ClientTransactionBuilder { + return FfiConverterTypeClientTransactionBuilder.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_publish( + it, FfiConverterTypeMovePackageData.lower(`packageData`),FfiConverterString.lower(`upgradeCapName`),_status) +} + } + ) + } + + + + /** + * Transfer some coins to a recipient address. If multiple coins are + * provided then they will be merged. + * + * The `amount` parameter specifies the quantity in NANOS, where 1 IOTA + * equals 1_000_000_000 NANOS. + * If `amount` is provided, that amount is split from the provided coins + * and sent. + * If `amount` is `None`, the entire coins are transferred. + * + * All provided coins must have the same coin type. Mixing coins of + * different types will result in an error. + * + * If you intend to transfer all provided coins to another address in a + * single transaction, consider using + * `TransactionBuilder::transfer_objects()` instead. + */override fun `sendCoins`(`coins`: List, `recipient`: Address, `amount`: PtbArgument?): ClientTransactionBuilder { + return FfiConverterTypeClientTransactionBuilder.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_send_coins( + it, FfiConverterSequenceTypePTBArgument.lower(`coins`),FfiConverterTypeAddress.lower(`recipient`),FfiConverterOptionalTypePTBArgument.lower(`amount`),_status) +} + } + ) + } + + + + /** + * Send IOTA to a recipient address. + * + * The `amount` parameter specifies the quantity in NANOS, where 1 IOTA + * equals 1_000_000_000 NANOS. That amount is split from the gas coin and + * sent. + */override fun `sendIota`(`recipient`: Address, `amount`: PtbArgument): ClientTransactionBuilder { + return FfiConverterTypeClientTransactionBuilder.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_send_iota( + it, FfiConverterTypeAddress.lower(`recipient`),FfiConverterTypePTBArgument.lower(`amount`),_status) +} + } + ) + } + + + + /** + * Split a coin into many. + */override fun `splitCoins`(`coin`: PtbArgument, `amounts`: List, `names`: List): ClientTransactionBuilder { + return FfiConverterTypeClientTransactionBuilder.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_split_coins( + it, FfiConverterTypePTBArgument.lower(`coin`),FfiConverterSequenceTypePTBArgument.lower(`amounts`),FfiConverterSequenceString.lower(`names`),_status) +} + } + ) + } + + + + /** + * Set the sponsor of the transaction. + */override fun `sponsor`(`sponsor`: Address): ClientTransactionBuilder { + return FfiConverterTypeClientTransactionBuilder.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_sponsor( + it, FfiConverterTypeAddress.lower(`sponsor`),_status) +} + } + ) + } + + + + /** + * Add stake to a validator's staking pool. + * + * This is a high-level function which will split the provided stake amount + * from the gas coin and then stake using the resulting coin. + */override fun `stake`(`stake`: PtbArgument, `validatorAddress`: Address): ClientTransactionBuilder { + return FfiConverterTypeClientTransactionBuilder.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_stake( + it, FfiConverterTypePTBArgument.lower(`stake`),FfiConverterTypeAddress.lower(`validatorAddress`),_status) +} + } + ) + } + + + + /** + * Transfer a list of objects to the given address, without producing any + * result. + */override fun `transferObjects`(`recipient`: Address, `objects`: List): ClientTransactionBuilder { + return FfiConverterTypeClientTransactionBuilder.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_transfer_objects( + it, FfiConverterTypeAddress.lower(`recipient`),FfiConverterSequenceTypePTBArgument.lower(`objects`),_status) +} + } + ) + } + + + + /** + * Withdraw stake from a validator's staking pool. + */override fun `unstake`(`stakedIota`: PtbArgument): ClientTransactionBuilder { + return FfiConverterTypeClientTransactionBuilder.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_unstake( + it, FfiConverterTypePTBArgument.lower(`stakedIota`),_status) +} + } + ) + } + + + + /** + * Upgrade a Move package. + * + * - `modules`: is the modules' bytecode for the modules to be published + * - `dependencies`: is the list of IDs of the transitive dependencies of + * the package to be upgraded + * - `package`: is the ID of the current package being upgraded + * - `ticket`: is the upgrade ticket + * + * To get the ticket, you have to call the + * `0x2::package::authorize_upgrade` function, and pass the package + * ID, the upgrade policy, and package digest. + */override fun `upgrade`(`packageId`: ObjectId, `packageData`: MovePackageData, `upgradeTicket`: PtbArgument, `name`: kotlin.String?): ClientTransactionBuilder { + return FfiConverterTypeClientTransactionBuilder.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_upgrade( + it, FfiConverterTypeObjectId.lower(`packageId`),FfiConverterTypeMovePackageData.lower(`packageData`),FfiConverterTypePTBArgument.lower(`upgradeTicket`),FfiConverterOptionalString.lower(`name`),_status) +} + } + ) + } + + + + + + + companion object + +} + +/** + * @suppress + */ +public object FfiConverterTypeClientTransactionBuilder: FfiConverter { + + override fun lower(value: ClientTransactionBuilder): Pointer { + return value.uniffiClonePointer() + } + + override fun lift(value: Pointer): ClientTransactionBuilder { + return ClientTransactionBuilder(value) + } + + override fun read(buf: ByteBuffer): ClientTransactionBuilder { + // The Rust code always writes pointers as 8 bytes, and will + // fail to compile if they don't fit. + return lift(Pointer(buf.getLong())) + } + + override fun allocationSize(value: ClientTransactionBuilder) = 8UL + + override fun write(value: ClientTransactionBuilder, buf: ByteBuffer) { + // The Rust code always expects pointers written as 8 bytes, + // and will fail to compile if they don't fit. + buf.putLong(Pointer.nativeValue(lower(value))) + } +} + + +// This template implements a class for working with a Rust struct via a Pointer/Arc +// to the live Rust struct on the other side of the FFI. +// +// Each instance implements core operations for working with the Rust `Arc` and the +// Kotlin Pointer to work with the live Rust struct on the other side of the FFI. +// +// There's some subtlety here, because we have to be careful not to operate on a Rust +// struct after it has been dropped, and because we must expose a public API for freeing +// theq Kotlin wrapper object in lieu of reliable finalizers. The core requirements are: +// +// * Each instance holds an opaque pointer to the underlying Rust struct. +// Method calls need to read this pointer from the object's state and pass it in to +// the Rust FFI. +// +// * When an instance is no longer needed, its pointer should be passed to a +// special destructor function provided by the Rust FFI, which will drop the +// underlying Rust struct. +// +// * Given an instance, calling code is expected to call the special +// `destroy` method in order to free it after use, either by calling it explicitly +// or by using a higher-level helper like the `use` method. Failing to do so risks +// leaking the underlying Rust struct. +// +// * We can't assume that calling code will do the right thing, and must be prepared +// to handle Kotlin method calls executing concurrently with or even after a call to +// `destroy`, and to handle multiple (possibly concurrent!) calls to `destroy`. +// +// * We must never allow Rust code to operate on the underlying Rust struct after +// the destructor has been called, and must never call the destructor more than once. +// Doing so may trigger memory unsafety. +// +// * To mitigate many of the risks of leaking memory and use-after-free unsafety, a `Cleaner` +// is implemented to call the destructor when the Kotlin object becomes unreachable. +// This is done in a background thread. This is not a panacea, and client code should be aware that +// 1. the thread may starve if some there are objects that have poorly performing +// `drop` methods or do significant work in their `drop` methods. +// 2. the thread is shared across the whole library. This can be tuned by using `android_cleaner = true`, +// or `android = true` in the [`kotlin` section of the `uniffi.toml` file](https://mozilla.github.io/uniffi-rs/kotlin/configuration.html). +// +// If we try to implement this with mutual exclusion on access to the pointer, there is the +// possibility of a race between a method call and a concurrent call to `destroy`: +// +// * Thread A starts a method call, reads the value of the pointer, but is interrupted +// before it can pass the pointer over the FFI to Rust. +// * Thread B calls `destroy` and frees the underlying Rust struct. +// * Thread A resumes, passing the already-read pointer value to Rust and triggering +// a use-after-free. +// +// One possible solution would be to use a `ReadWriteLock`, with each method call taking +// a read lock (and thus allowed to run concurrently) and the special `destroy` method +// taking a write lock (and thus blocking on live method calls). However, we aim not to +// generate methods with any hidden blocking semantics, and a `destroy` method that might +// block if called incorrectly seems to meet that bar. +// +// So, we achieve our goals by giving each instance an associated `AtomicLong` counter to track +// the number of in-flight method calls, and an `AtomicBoolean` flag to indicate whether `destroy` +// has been called. These are updated according to the following rules: +// +// * The initial value of the counter is 1, indicating a live object with no in-flight calls. +// The initial value for the flag is false. +// +// * At the start of each method call, we atomically check the counter. +// If it is 0 then the underlying Rust struct has already been destroyed and the call is aborted. +// If it is nonzero them we atomically increment it by 1 and proceed with the method call. +// +// * At the end of each method call, we atomically decrement and check the counter. +// If it has reached zero then we destroy the underlying Rust struct. +// +// * When `destroy` is called, we atomically flip the flag from false to true. +// If the flag was already true we silently fail. +// Otherwise we atomically decrement and check the counter. +// If it has reached zero then we destroy the underlying Rust struct. +// +// Astute readers may observe that this all sounds very similar to the way that Rust's `Arc` works, +// and indeed it is, with the addition of a flag to guard against multiple calls to `destroy`. +// +// The overall effect is that the underlying Rust struct is destroyed only when `destroy` has been +// called *and* all in-flight method calls have completed, avoiding violating any of the expectations +// of the underlying Rust code. +// +// This makes a cleaner a better alternative to _not_ calling `destroy()` as +// and when the object is finished with, but the abstraction is not perfect: if the Rust object's `drop` +// method is slow, and/or there are many objects to cleanup, and it's on a low end Android device, then the cleaner +// thread may be starved, and the app will leak memory. +// +// In this case, `destroy`ing manually may be a better solution. +// +// The cleaner can live side by side with the manual calling of `destroy`. In the order of responsiveness, uniffi objects +// with Rust peers are reclaimed: +// +// 1. By calling the `destroy` method of the object, which calls `rustObject.free()`. If that doesn't happen: +// 2. When the object becomes unreachable, AND the Cleaner thread gets to call `rustObject.free()`. If the thread is starved then: +// 3. The memory is reclaimed when the process terminates. +// +// [1] https://stackoverflow.com/questions/24376768/can-java-finalize-an-object-when-it-is-still-in-scope/24380219 +// + + +public interface CoinInterface { + + fun `balance`(): kotlin.ULong + + fun `coinType`(): TypeTag + + fun `id`(): ObjectId + + companion object +} + +open class Coin: Disposable, AutoCloseable, CoinInterface { constructor(pointer: Pointer) { @@ -31034,6 +32024,11 @@ public interface ObjectInterface { */ fun `objectId`(): ObjectId + /** + * Return this object's reference + */ + fun `objectRef`(): ObjectReference + /** * Return this object's type */ @@ -31273,6 +32268,21 @@ open class Object: Disposable, AutoCloseable, ObjectInterface + /** + * Return this object's reference + */override fun `objectRef`(): ObjectReference { + return FfiConverterTypeObjectReference.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_object_object_ref( + it, _status) +} + } + ) + } + + + /** * Return this object's type */override fun `objectType`(): ObjectType { @@ -33245,6 +34255,16 @@ open class PtbArgument: Disposable, AutoCloseable, PtbArgumentInterface } + fun `objectRef`(`id`: ObjectReference): PtbArgument { + return FfiConverterTypePTBArgument.lift( + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_ptbargument_object_ref( + FfiConverterTypeObjectReference.lower(`id`),_status) +} + ) + } + + fun `option`(`value`: MoveArg?): PtbArgument { return FfiConverterTypePTBArgument.lift( uniffiRustCall() { _status -> @@ -42247,19 +43267,14 @@ public object FfiConverterTypeTransaction: FfiConverter { public interface TransactionBuilderInterface { /** - * Dry run the transaction. - */ - suspend fun `dryRun`(`skipChecks`: kotlin.Boolean = false): DryRunResult - - /** - * Execute the transaction and optionally wait for finalization. - */ - suspend fun `execute`(`keypair`: SimpleKeypair, `waitFor`: WaitForTx? = null): TransactionEffects - - /** - * Execute the transaction and optionally wait for finalization. + * Execute the transaction using the gas station and return the JSON + * transaction effects. This will fail unless data is set with the + * `gas_station_sponsor` function. + * + * NOTE: These effects are not necessarily compatible with + * `TransactionEffects` */ - suspend fun `executeWithSponsor`(`keypair`: SimpleKeypair, `sponsorKeypair`: SimpleKeypair, `waitFor`: WaitForTx? = null): TransactionEffects + suspend fun `executeWithGasStation`(`keypair`: SimpleKeypair): Value /** * Set the expiration of the transaction to be a specific epoch. @@ -42269,12 +43284,12 @@ public interface TransactionBuilderInterface { /** * Convert this builder into a transaction. */ - suspend fun `finish`(): Transaction + fun `finish`(): Transaction /** * Add gas coins that will be consumed. Optional. */ - fun `gas`(`objectIds`: List): TransactionBuilder + fun `gas`(`objectRefs`: List): TransactionBuilder /** * Set the gas budget for the transaction. @@ -42358,7 +43373,7 @@ public interface TransactionBuilderInterface { fun `sendIota`(`recipient`: Address, `amount`: PtbArgument): TransactionBuilder /** - * Split a coin into many. + * Split a coin by the provided amounts. */ fun `splitCoins`(`coin`: PtbArgument, `amounts`: List, `names`: List = listOf()): TransactionBuilder @@ -42401,6 +43416,8 @@ public interface TransactionBuilderInterface { */ fun `upgrade`(`packageId`: ObjectId, `packageData`: MovePackageData, `upgradeTicket`: PtbArgument, `name`: kotlin.String? = null): TransactionBuilder + suspend fun `withClient`(`client`: GraphQlClient): ClientTransactionBuilder + companion object } @@ -42426,6 +43443,16 @@ open class TransactionBuilder: Disposable, AutoCloseable, TransactionBuilderInte this.pointer = null this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer)) } + /** + * Create a new transaction builder and initialize its elements to default. + */ + constructor(`sender`: Address) : + this( + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_transactionbuilder_new( + FfiConverterTypeAddress.lower(`sender`),_status) +} + ) protected val pointer: Pointer? protected val cleanable: UniffiCleaner.Cleanable @@ -42492,71 +43519,28 @@ open class TransactionBuilder: Disposable, AutoCloseable, TransactionBuilderInte /** - * Dry run the transaction. + * Execute the transaction using the gas station and return the JSON + * transaction effects. This will fail unless data is set with the + * `gas_station_sponsor` function. + * + * NOTE: These effects are not necessarily compatible with + * `TransactionEffects` */ @Throws(SdkFfiException::class) @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") - override suspend fun `dryRun`(`skipChecks`: kotlin.Boolean) : DryRunResult { + override suspend fun `executeWithGasStation`(`keypair`: SimpleKeypair) : Value { return uniffiRustCallAsync( callWithPointer { thisPtr -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_dry_run( + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_execute_with_gas_station( thisPtr, - FfiConverterBoolean.lower(`skipChecks`), + FfiConverterTypeSimpleKeypair.lower(`keypair`), ) }, { future, callback, continuation -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_poll_rust_buffer(future, callback, continuation) }, { future, continuation -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_complete_rust_buffer(future, continuation) }, { future -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_free_rust_buffer(future) }, // lift function - { FfiConverterTypeDryRunResult.lift(it) }, - // Error FFI converter - SdkFfiException.ErrorHandler, - ) - } - - - /** - * Execute the transaction and optionally wait for finalization. - */ - @Throws(SdkFfiException::class) - @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") - override suspend fun `execute`(`keypair`: SimpleKeypair, `waitFor`: WaitForTx?) : TransactionEffects { - return uniffiRustCallAsync( - callWithPointer { thisPtr -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_execute( - thisPtr, - FfiConverterTypeSimpleKeypair.lower(`keypair`),FfiConverterOptionalTypeWaitForTx.lower(`waitFor`), - ) - }, - { future, callback, continuation -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_poll_pointer(future, callback, continuation) }, - { future, continuation -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_complete_pointer(future, continuation) }, - { future -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_free_pointer(future) }, - // lift function - { FfiConverterTypeTransactionEffects.lift(it) }, - // Error FFI converter - SdkFfiException.ErrorHandler, - ) - } - - - /** - * Execute the transaction and optionally wait for finalization. - */ - @Throws(SdkFfiException::class) - @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") - override suspend fun `executeWithSponsor`(`keypair`: SimpleKeypair, `sponsorKeypair`: SimpleKeypair, `waitFor`: WaitForTx?) : TransactionEffects { - return uniffiRustCallAsync( - callWithPointer { thisPtr -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_execute_with_sponsor( - thisPtr, - FfiConverterTypeSimpleKeypair.lower(`keypair`),FfiConverterTypeSimpleKeypair.lower(`sponsorKeypair`),FfiConverterOptionalTypeWaitForTx.lower(`waitFor`), - ) - }, - { future, callback, continuation -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_poll_pointer(future, callback, continuation) }, - { future, continuation -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_complete_pointer(future, continuation) }, - { future -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_free_pointer(future) }, - // lift function - { FfiConverterTypeTransactionEffects.lift(it) }, + { FfiConverterTypeValue.lift(it) }, // Error FFI converter SdkFfiException.ErrorHandler, ) @@ -42581,35 +43565,27 @@ open class TransactionBuilder: Disposable, AutoCloseable, TransactionBuilderInte /** * Convert this builder into a transaction. */ - @Throws(SdkFfiException::class) - @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") - override suspend fun `finish`() : Transaction { - return uniffiRustCallAsync( - callWithPointer { thisPtr -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_finish( - thisPtr, - - ) - }, - { future, callback, continuation -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_poll_pointer(future, callback, continuation) }, - { future, continuation -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_complete_pointer(future, continuation) }, - { future -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_free_pointer(future) }, - // lift function - { FfiConverterTypeTransaction.lift(it) }, - // Error FFI converter - SdkFfiException.ErrorHandler, + @Throws(SdkFfiException::class)override fun `finish`(): Transaction { + return FfiConverterTypeTransaction.lift( + callWithPointer { + uniffiRustCallWithError(SdkFfiException) { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_finish( + it, _status) +} + } ) } + /** * Add gas coins that will be consumed. Optional. - */override fun `gas`(`objectIds`: List): TransactionBuilder { + */override fun `gas`(`objectRefs`: List): TransactionBuilder { return FfiConverterTypeTransactionBuilder.lift( callWithPointer { uniffiRustCall() { _status -> UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_gas( - it, FfiConverterSequenceTypeObjectId.lower(`objectIds`),_status) + it, FfiConverterSequenceTypeObjectReference.lower(`objectRefs`),_status) } } ) @@ -42789,7 +43765,7 @@ open class TransactionBuilder: Disposable, AutoCloseable, TransactionBuilderInte /** - * Split a coin into many. + * Split a coin by the provided amounts. */override fun `splitCoins`(`coin`: PtbArgument, `amounts`: List, `names`: List): TransactionBuilder { return FfiConverterTypeTransactionBuilder.lift( callWithPointer { @@ -42892,29 +43868,30 @@ open class TransactionBuilder: Disposable, AutoCloseable, TransactionBuilderInte - - - companion object { - - /** - * Create a new transaction builder and initialize its elements to default. - */ @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") - suspend fun `init`(`sender`: Address, `client`: GraphQlClient) : TransactionBuilder { + override suspend fun `withClient`(`client`: GraphQlClient) : ClientTransactionBuilder { return uniffiRustCallAsync( - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_transactionbuilder_init(FfiConverterTypeAddress.lower(`sender`),FfiConverterTypeGraphQLClient.lower(`client`),), + callWithPointer { thisPtr -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_with_client( + thisPtr, + FfiConverterTypeGraphQLClient.lower(`client`), + ) + }, { future, callback, continuation -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_poll_pointer(future, callback, continuation) }, { future, continuation -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_complete_pointer(future, continuation) }, { future -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_free_pointer(future) }, // lift function - { FfiConverterTypeTransactionBuilder.lift(it) }, + { FfiConverterTypeClientTransactionBuilder.lift(it) }, // Error FFI converter UniffiNullRustCallStatusErrorHandler, ) } - - } + + + + + companion object } diff --git a/bindings/python/examples/dev_inspect.py b/bindings/python/examples/dev_inspect.py index 2f3d73585..6ebb9725f 100644 --- a/bindings/python/examples/dev_inspect.py +++ b/bindings/python/examples/dev_inspect.py @@ -6,6 +6,7 @@ import sys import asyncio + async def main(): client = GraphQlClient.new_devnet() @@ -22,7 +23,7 @@ async def main(): name = "name.iota" print(f"Looking up name: {name}") - builder = await TransactionBuilder.init(sender, client) + builder = await TransactionBuilder(sender).with_client(client) # 1. Get the registry builder.move_call( @@ -119,5 +120,6 @@ async def main(): else: print("No results found") + if __name__ == "__main__": asyncio.run(main()) diff --git a/bindings/python/examples/gas_sponsor.py b/bindings/python/examples/gas_sponsor.py index 5dd94edc1..719e81b48 100644 --- a/bindings/python/examples/gas_sponsor.py +++ b/bindings/python/examples/gas_sponsor.py @@ -6,6 +6,7 @@ import sys import asyncio + async def main(): client = GraphQlClient.new_devnet() @@ -16,7 +17,7 @@ async def main(): "0x611830d3641a68f94a690dcc25d1f4b0dac948325ac18f6dd32564371735f32c" ) - builder = await TransactionBuilder.init(sender, client) + builder = await TransactionBuilder(sender).with_client(client) package_addr = Address.std_lib() module_name = Identifier("u8") @@ -42,5 +43,6 @@ async def main(): print("Gas sponsor tx dry run was successful!") + if __name__ == "__main__": asyncio.run(main()) diff --git a/bindings/python/examples/gas_station.py b/bindings/python/examples/gas_station.py index 5f9cfdd95..8d2f2c18f 100644 --- a/bindings/python/examples/gas_station.py +++ b/bindings/python/examples/gas_station.py @@ -13,7 +13,7 @@ async def main(): sender = keypair.public_key().derive_address() simple_key = SimpleKeypair.from_ed25519(keypair) - builder = await TransactionBuilder.init(sender, client) + builder = await TransactionBuilder(sender).with_client(client) builder.move_call( Address.std_lib(), diff --git a/bindings/python/examples/generic_move_function.py b/bindings/python/examples/generic_move_function.py index e351d155a..ae41531d1 100644 --- a/bindings/python/examples/generic_move_function.py +++ b/bindings/python/examples/generic_move_function.py @@ -12,7 +12,7 @@ async def main(): "0x71b4b4f171b4355ff691b7c470579cf1a926f96f724e5f9a30efc4b5f75d085e" ) - builder = await TransactionBuilder.init(sender, client) + builder = await TransactionBuilder(sender).with_client(client) addr1 = Address.from_hex( "0xde49ea53fbadee67d3e35a097cdbea210b659676fc680a0b0c5f11d0763d375e" diff --git a/bindings/python/examples/prepare_merge_coins.py b/bindings/python/examples/prepare_merge_coins.py index 45636129d..3d9bcdd9b 100644 --- a/bindings/python/examples/prepare_merge_coins.py +++ b/bindings/python/examples/prepare_merge_coins.py @@ -21,7 +21,7 @@ async def main(): "0xd04077fe3b6fad13b3d4ed0d535b7ca92afcac8f0f2a0e0925fb9f4f0b30c699" ) - builder = await TransactionBuilder.init(sender, client) + builder = await TransactionBuilder(sender).with_client(client) builder.merge_coins(coin_0, [coin_1]) @@ -36,5 +36,6 @@ async def main(): print("Merge coins dry run was successful!") + if __name__ == "__main__": asyncio.run(main()) diff --git a/bindings/python/examples/prepare_send_coins.py b/bindings/python/examples/prepare_send_coins.py index 477f680ce..6b35ca1ed 100644 --- a/bindings/python/examples/prepare_send_coins.py +++ b/bindings/python/examples/prepare_send_coins.py @@ -23,7 +23,7 @@ async def main(): "0x8ef4259fa2a3499826fa4b8aebeb1d8e478cf5397d05361c96438940b43d28c9" ) - builder = await TransactionBuilder.init(from_address, client) + builder = await TransactionBuilder(from_address).with_client(client) builder.send_coins( [coin_id], to_address, @@ -41,5 +41,6 @@ async def main(): print("Send coins dry run was successful!") + if __name__ == "__main__": asyncio.run(main()) diff --git a/bindings/python/examples/prepare_send_iota.py b/bindings/python/examples/prepare_send_iota.py index e6ec08cfc..a67198de2 100644 --- a/bindings/python/examples/prepare_send_iota.py +++ b/bindings/python/examples/prepare_send_iota.py @@ -18,7 +18,7 @@ async def main(): "0x0000a4984bd495d4346fa208ddff4f5d5e5ad48c21dec631ddebc99809f16900" ) - builder = await TransactionBuilder.init(from_address, client) + builder = await TransactionBuilder(from_address).with_client(client) builder.send_iota(to_address, PtbArgument.u64(5000000000)) txn = await builder.finish() @@ -32,5 +32,6 @@ async def main(): print("Send IOTA dry run was successful!") + if __name__ == "__main__": asyncio.run(main()) diff --git a/bindings/python/examples/prepare_send_iota_multi.py b/bindings/python/examples/prepare_send_iota_multi.py index d02843d43..846f13b54 100644 --- a/bindings/python/examples/prepare_send_iota_multi.py +++ b/bindings/python/examples/prepare_send_iota_multi.py @@ -29,7 +29,7 @@ async def main(): amounts = [PtbArgument.u64(r[1]) for r in recipients] labels = [f"coin{i}" for i in range(len(recipients))] - builder = await TransactionBuilder.init(sender, client) + builder = await TransactionBuilder(sender).with_client(client) builder.split_coins(PtbArgument.object_id(coin_id), amounts, labels) for i, r in enumerate(recipients): diff --git a/bindings/python/examples/prepare_split_coins.py b/bindings/python/examples/prepare_split_coins.py index ba489f76d..6759b0811 100644 --- a/bindings/python/examples/prepare_split_coins.py +++ b/bindings/python/examples/prepare_split_coins.py @@ -18,7 +18,7 @@ async def main(): "0x0b0270ee9d27da0db09651e5f7338dfa32c7ee6441ccefa1f6e305735bcfc7ab" ) - builder = await TransactionBuilder.init(sender, client) + builder = await TransactionBuilder(sender).with_client(client) builder.split_coins( PtbArgument.object_id(coin_id), @@ -44,5 +44,6 @@ async def main(): print("Split coins dry run was successful!") + if __name__ == "__main__": asyncio.run(main()) diff --git a/bindings/python/examples/prepare_transfer_objects.py b/bindings/python/examples/prepare_transfer_objects.py index d28c9120f..d4a27846d 100644 --- a/bindings/python/examples/prepare_transfer_objects.py +++ b/bindings/python/examples/prepare_transfer_objects.py @@ -28,7 +28,7 @@ async def main(): ), ] - builder = await TransactionBuilder.init(from_address, client) + builder = await TransactionBuilder(from_address).with_client(client) builder.transfer_objects( to_address, objs_to_transfer, @@ -45,5 +45,6 @@ async def main(): print("Transfer objects dry run was successful!") + if __name__ == "__main__": asyncio.run(main()) diff --git a/bindings/python/examples/prepare_transfer_objects_offline.py b/bindings/python/examples/prepare_transfer_objects_offline.py new file mode 100644 index 000000000..c54e570ae --- /dev/null +++ b/bindings/python/examples/prepare_transfer_objects_offline.py @@ -0,0 +1,64 @@ +# 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() + + from_address = Address.from_hex( + "0x611830d3641a68f94a690dcc25d1f4b0dac948325ac18f6dd32564371735f32c" + ) + to_address = Address.from_hex( + "0x0000a4984bd495d4346fa208ddff4f5d5e5ad48c21dec631ddebc99809f16900" + ) + obj_ids = [ + ObjectId.from_hex( + "0xd04077fe3b6fad13b3d4ed0d535b7ca92afcac8f0f2a0e0925fb9f4f0b30c699" + ), + ObjectId.from_hex( + "0x0b0270ee9d27da0db09651e5f7338dfa32c7ee6441ccefa1f6e305735bcfc7ab" + ), + ObjectId.from_hex( + "0x8ef4259fa2a3499826fa4b8aebeb1d8e478cf5397d05361c96438940b43d28c9" + ), + ] + objs_to_transfer = [] + for obj_id in obj_ids: + obj = await client.object(obj_id) + if obj == None: + raise Exception("Missing object:", obj_id) + objs_to_transfer.append(PtbArgument.object_ref(obj.object_ref())) + + gas_coin_id = ObjectId.from_hex( + "0xd04077fe3b6fad13b3d4ed0d535b7ca92afcac8f0f2a0e0925fb9f4f0b30c699" + ) + gas_coin = await client.object(gas_coin_id) + if gas_coin == None: + raise Exception("Missing gas coin:", gas_coin) + gas_price = await client.reference_gas_price() or 100 + + builder = TransactionBuilder(from_address) + builder.transfer_objects( + to_address, + objs_to_transfer, + ) + builder.gas([gas_coin.object_ref()]).gas_price(gas_price).gas_budget(500000000) + + txn = builder.finish() + + print("Signing Digest:", txn.signing_digest_hex()) + print("Txn Bytes:", txn.to_base64()) + + res = await client.dry_run_tx(txn) + if res.error is not None: + raise Exception("Failed to transfer objects:", res.error) + + print("Transfer objects dry run was successful!") + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/bindings/python/examples/publish_upgrade.py b/bindings/python/examples/publish_upgrade.py index b2133c709..6b3a7e23a 100644 --- a/bindings/python/examples/publish_upgrade.py +++ b/bindings/python/examples/publish_upgrade.py @@ -61,7 +61,7 @@ async def main(): client = GraphQlClient.new_localnet() # Build the `publish` PTB - builder = await TransactionBuilder.init(sender, client) + builder = await TransactionBuilder(sender).with_client(client) # Publish the package and receive the upgrade cap in return builder.publish(package_data, "upgrade_cap") # Transfer the upgrade cap to the sender address @@ -114,7 +114,7 @@ async def main(): raise Exception("Missing package id") # Build the `upgrade` PTB - builder = await TransactionBuilder.init(sender, client) + builder = await TransactionBuilder(sender).with_client(client) # Authorize the upgrade by providing the upgrade cap object id to receive an upgrade # ticket diff --git a/bindings/python/examples/sign_send_iota.py b/bindings/python/examples/sign_send_iota.py index 4b3024837..435f05b80 100644 --- a/bindings/python/examples/sign_send_iota.py +++ b/bindings/python/examples/sign_send_iota.py @@ -25,7 +25,7 @@ async def main(): client = GraphQlClient.new_localnet() - builder = await TransactionBuilder.init(sender_address, client) + builder = await TransactionBuilder(sender_address).with_client(client) builder.send_iota(recipient_address, PtbArgument.u64(amount)) txn = await builder.finish() @@ -42,5 +42,6 @@ async def main(): print(f"Transaction status: {effects.as_v1().status}") print(f"Effects: {effects.as_v1()}") + if __name__ == "__main__": asyncio.run(main()) diff --git a/bindings/python/examples/stake.py b/bindings/python/examples/stake.py index d89817c2f..823ebc694 100644 --- a/bindings/python/examples/stake.py +++ b/bindings/python/examples/stake.py @@ -21,7 +21,7 @@ async def main(): print("Staking to validator", validator.name or "with no name") - builder = await TransactionBuilder.init(my_address, client) + builder = await TransactionBuilder(my_address).with_client(client) builder.stake(PtbArgument.u64(1000000000), validator.address) @@ -31,5 +31,6 @@ async def main(): print("Stake dry run was successful!") + if __name__ == "__main__": asyncio.run(main()) diff --git a/bindings/python/examples/tx_command_results.py b/bindings/python/examples/tx_command_results.py index e31a55510..e84802679 100644 --- a/bindings/python/examples/tx_command_results.py +++ b/bindings/python/examples/tx_command_results.py @@ -14,7 +14,7 @@ async def main(): "0x611830d3641a68f94a690dcc25d1f4b0dac948325ac18f6dd32564371735f32c" ) - builder = await TransactionBuilder.init(sender, client) + builder = await TransactionBuilder(sender).with_client(client) package_addr = Address.std_lib() module_name = Identifier("u64") diff --git a/bindings/python/examples/unstake.py b/bindings/python/examples/unstake.py index e5ee076b6..2e202baf3 100644 --- a/bindings/python/examples/unstake.py +++ b/bindings/python/examples/unstake.py @@ -17,8 +17,8 @@ async def main(): raise Exception("no staked iotas found") staked_iota = staked_iotas.data[0] - builder = await TransactionBuilder.init( - staked_iota.owner().as_address(), client + builder = await TransactionBuilder(staked_iota.owner().as_address()).with_client( + client ) builder.unstake(PtbArgument.object_id(staked_iota.object_id())) @@ -29,5 +29,6 @@ async def main(): print("Unstake dry run was successful!") + if __name__ == "__main__": asyncio.run(main()) diff --git a/bindings/python/lib/iota_sdk_ffi.py b/bindings/python/lib/iota_sdk_ffi.py index 0871dc540..4260cc938 100644 --- a/bindings/python/lib/iota_sdk_ffi.py +++ b/bindings/python/lib/iota_sdk_ffi.py @@ -1031,6 +1031,48 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_checkpointtransactioninfo_transaction() != 58570: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_dry_run() != 10983: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_execute() != 45165: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_execute_with_sponsor() != 64410: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_expiration() != 32958: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_finish() != 56677: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas() != 522: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas_budget() != 27427: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas_price() != 56003: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas_station_sponsor() != 25572: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_make_move_vec() != 4858: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_merge_coins() != 43478: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_move_call() != 13617: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_publish() != 25909: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_send_coins() != 65187: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_send_iota() != 65011: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_split_coins() != 2932: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_sponsor() != 44990: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_stake() != 9961: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_transfer_objects() != 23790: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_unstake() != 40181: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_upgrade() != 59977: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_coin_balance() != 29928: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_coin_coin_type() != 18211: @@ -1397,6 +1439,8 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_object_object_id() != 6575: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_object_object_ref() != 13587: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_object_object_type() != 1843: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_object_owner() != 3724: @@ -1675,17 +1719,13 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_transaction_to_base64() != 51030: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_dry_run() != 11138: - raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_execute() != 45882: - raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_execute_with_sponsor() != 45688: + if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_execute_with_gas_station() != 6268: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_expiration() != 5328: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_finish() != 32200: + if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_finish() != 39582: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_gas() != 26787: + if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_gas() != 23371: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_gas_budget() != 48686: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") @@ -1705,7 +1745,7 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_send_iota() != 2185: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_split_coins() != 25229: + if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_split_coins() != 17747: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_sponsor() != 25655: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") @@ -1717,6 +1757,8 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_upgrade() != 14493: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_with_client() != 32496: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_transactioneffects_as_v1() != 48710: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_transactioneffects_digest() != 46963: @@ -2219,6 +2261,8 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_ptbargument_object_id_from_hex() != 47640: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_constructor_ptbargument_object_ref() != 24215: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_ptbargument_option() != 37559: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_ptbargument_receiving() != 50553: @@ -2441,7 +2485,7 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_transaction_new_v1() != 58632: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_iota_sdk_ffi_checksum_constructor_transactionbuilder_init() != 29935: + if lib.uniffi_iota_sdk_ffi_checksum_constructor_transactionbuilder_new() != 35216: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_transactioneffects_new_v1() != 63561: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") @@ -3324,6 +3368,161 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_circomg2_new.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_clienttransactionbuilder.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_clienttransactionbuilder.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_free_clienttransactionbuilder.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_free_clienttransactionbuilder.restype = None +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_dry_run.argtypes = ( + ctypes.c_void_p, + ctypes.c_int8, +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_dry_run.restype = ctypes.c_uint64 +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_execute.argtypes = ( + ctypes.c_void_p, + ctypes.c_void_p, + _UniffiRustBuffer, +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_execute.restype = ctypes.c_uint64 +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_execute_with_sponsor.argtypes = ( + ctypes.c_void_p, + ctypes.c_void_p, + ctypes.c_void_p, + _UniffiRustBuffer, +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_execute_with_sponsor.restype = ctypes.c_uint64 +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_expiration.argtypes = ( + ctypes.c_void_p, + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_expiration.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_finish.argtypes = ( + ctypes.c_void_p, +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_finish.restype = ctypes.c_uint64 +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas_budget.argtypes = ( + ctypes.c_void_p, + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas_budget.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas_price.argtypes = ( + ctypes.c_void_p, + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas_price.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas_station_sponsor.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + _UniffiRustBuffer, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas_station_sponsor.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_make_move_vec.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_make_move_vec.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_merge_coins.argtypes = ( + ctypes.c_void_p, + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_merge_coins.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_move_call.argtypes = ( + ctypes.c_void_p, + ctypes.c_void_p, + ctypes.c_void_p, + ctypes.c_void_p, + _UniffiRustBuffer, + _UniffiRustBuffer, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_move_call.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_publish.argtypes = ( + ctypes.c_void_p, + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_publish.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_send_coins.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_send_coins.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_send_iota.argtypes = ( + ctypes.c_void_p, + ctypes.c_void_p, + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_send_iota.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_split_coins.argtypes = ( + ctypes.c_void_p, + ctypes.c_void_p, + _UniffiRustBuffer, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_split_coins.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_sponsor.argtypes = ( + ctypes.c_void_p, + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_sponsor.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_stake.argtypes = ( + ctypes.c_void_p, + ctypes.c_void_p, + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_stake.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_transfer_objects.argtypes = ( + ctypes.c_void_p, + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_transfer_objects.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_unstake.argtypes = ( + ctypes.c_void_p, + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_unstake.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_upgrade.argtypes = ( + ctypes.c_void_p, + ctypes.c_void_p, + ctypes.c_void_p, + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_upgrade.restype = ctypes.c_void_p _UniffiLib.uniffi_iota_sdk_ffi_fn_clone_coin.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), @@ -5194,6 +5393,11 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_iota_sdk_ffi_fn_method_object_object_id.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_object_object_ref.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_object_object_ref.restype = _UniffiRustBuffer _UniffiLib.uniffi_iota_sdk_ffi_fn_method_object_object_type.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), @@ -5531,6 +5735,11 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_ptbargument_object_id_from_hex.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_ptbargument_object_ref.argtypes = ( + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_ptbargument_object_ref.restype = ctypes.c_void_p _UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_ptbargument_option.argtypes = ( _UniffiRustBuffer, ctypes.POINTER(_UniffiRustCallStatus), @@ -6935,29 +7144,16 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_iota_sdk_ffi_fn_free_transactionbuilder.restype = None -_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_transactionbuilder_init.argtypes = ( - ctypes.c_void_p, - ctypes.c_void_p, -) -_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_transactionbuilder_init.restype = ctypes.c_uint64 -_UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_dry_run.argtypes = ( +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_transactionbuilder_new.argtypes = ( ctypes.c_void_p, - ctypes.c_int8, -) -_UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_dry_run.restype = ctypes.c_uint64 -_UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_execute.argtypes = ( - ctypes.c_void_p, - ctypes.c_void_p, - _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_execute.restype = ctypes.c_uint64 -_UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_execute_with_sponsor.argtypes = ( +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_transactionbuilder_new.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_execute_with_gas_station.argtypes = ( ctypes.c_void_p, ctypes.c_void_p, - ctypes.c_void_p, - _UniffiRustBuffer, ) -_UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_execute_with_sponsor.restype = ctypes.c_uint64 +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_execute_with_gas_station.restype = ctypes.c_uint64 _UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_expiration.argtypes = ( ctypes.c_void_p, ctypes.c_uint64, @@ -6966,8 +7162,9 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_expiration.restype = ctypes.c_void_p _UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_finish.argtypes = ( ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_finish.restype = ctypes.c_uint64 +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_finish.restype = ctypes.c_void_p _UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_gas.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, @@ -7085,6 +7282,11 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_upgrade.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_with_client.argtypes = ( + ctypes.c_void_p, + ctypes.c_void_p, +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_with_client.restype = ctypes.c_uint64 _UniffiLib.uniffi_iota_sdk_ffi_fn_clone_transactioneffects.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), @@ -10250,6 +10452,69 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_checkpointtransactioninfo_transaction.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_checkpointtransactioninfo_transaction.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_dry_run.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_dry_run.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_execute.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_execute.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_execute_with_sponsor.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_execute_with_sponsor.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_expiration.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_expiration.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_finish.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_finish.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas_budget.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas_budget.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas_price.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas_price.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas_station_sponsor.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_gas_station_sponsor.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_make_move_vec.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_make_move_vec.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_merge_coins.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_merge_coins.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_move_call.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_move_call.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_publish.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_publish.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_send_coins.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_send_coins.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_send_iota.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_send_iota.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_split_coins.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_split_coins.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_sponsor.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_sponsor.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_stake.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_stake.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_transfer_objects.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_transfer_objects.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_unstake.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_unstake.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_upgrade.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_clienttransactionbuilder_upgrade.restype = ctypes.c_uint16 _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_coin_balance.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_coin_balance.restype = ctypes.c_uint16 @@ -10799,6 +11064,9 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_object_object_id.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_object_object_id.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_object_object_ref.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_object_object_ref.restype = ctypes.c_uint16 _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_object_object_type.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_object_object_type.restype = ctypes.c_uint16 @@ -11216,15 +11484,9 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_transaction_to_base64.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_transaction_to_base64.restype = ctypes.c_uint16 -_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_dry_run.argtypes = ( -) -_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_dry_run.restype = ctypes.c_uint16 -_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_execute.argtypes = ( -) -_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_execute.restype = ctypes.c_uint16 -_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_execute_with_sponsor.argtypes = ( +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_execute_with_gas_station.argtypes = ( ) -_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_execute_with_sponsor.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_execute_with_gas_station.restype = ctypes.c_uint16 _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_expiration.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_expiration.restype = ctypes.c_uint16 @@ -11279,6 +11541,9 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_upgrade.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_upgrade.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_with_client.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_with_client.restype = ctypes.c_uint16 _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_transactioneffects_as_v1.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_transactioneffects_as_v1.restype = ctypes.c_uint16 @@ -12032,6 +12297,9 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_ptbargument_object_id_from_hex.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_ptbargument_object_id_from_hex.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_ptbargument_object_ref.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_ptbargument_object_ref.restype = ctypes.c_uint16 _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_ptbargument_option.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_ptbargument_option.restype = ctypes.c_uint16 @@ -12365,9 +12633,9 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_transaction_new_v1.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_transaction_new_v1.restype = ctypes.c_uint16 -_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_transactionbuilder_init.argtypes = ( +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_transactionbuilder_new.argtypes = ( ) -_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_transactionbuilder_init.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_transactionbuilder_new.restype = ctypes.c_uint16 _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_transactioneffects_new_v1.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_transactioneffects_new_v1.restype = ctypes.c_uint16 @@ -12924,6 +13192,8 @@ def write(value, buf): + + @@ -28729,157 +28999,193 @@ def read(cls, buf: _UniffiRustBuffer): @classmethod def write(cls, value: CircomG2Protocol, buf: _UniffiRustBuffer): buf.write_u64(cls.lower(value)) -class CoinProtocol(typing.Protocol): - def balance(self, ): - raise NotImplementedError - def coin_type(self, ): - raise NotImplementedError - def id(self, ): - raise NotImplementedError -# Coin is a Rust-only trait - it's a wrapper around a Rust implementation. -class Coin(): - _pointer: ctypes.c_void_p - - def __init__(self, *args, **kwargs): - raise ValueError("This class has no default constructor") - - def __del__(self): - # In case of partial initialization of instances. - pointer = getattr(self, "_pointer", None) - if pointer is not None: - _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_free_coin, pointer) +class ClientTransactionBuilderProtocol(typing.Protocol): + """ + A builder for creating transactions which uses a GraphQL client to + automatically resolve inputs. Use `finish` to finalize the transaction data. + """ - def _uniffi_clone_pointer(self): - return _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_coin, self._pointer) + def dry_run(self, skip_checks: "typing.Union[object, bool]" = _DEFAULT): + """ + Dry run the transaction. + """ - # Used by alternative constructors or any methods which return this type. - @classmethod - def _make_instance_(cls, pointer): - # Lightly yucky way to bypass the usual __init__ logic - # and just create a new instance with the required pointer. - inst = cls.__new__(cls) - inst._pointer = pointer - return inst - @classmethod - def try_from_object(cls, object: "Object"): - _UniffiConverterTypeObject.check_lower(object) - - # Call the (fallible) function before creating any half-baked object instances. - pointer = _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_coin_try_from_object, - _UniffiConverterTypeObject.lower(object)) - return cls._make_instance_(pointer) + raise NotImplementedError + def execute(self, keypair: "SimpleKeypair",wait_for: "typing.Union[object, typing.Optional[WaitForTx]]" = _DEFAULT): + """ + Execute the transaction and optionally wait for finalization. + """ + raise NotImplementedError + def execute_with_sponsor(self, keypair: "SimpleKeypair",sponsor_keypair: "SimpleKeypair",wait_for: "typing.Union[object, typing.Optional[WaitForTx]]" = _DEFAULT): + """ + Execute the transaction and optionally wait for finalization. + """ + raise NotImplementedError + def expiration(self, epoch: "int"): + """ + Set the expiration of the transaction to be a specific epoch. + """ - def balance(self, ) -> "int": - return _UniffiConverterUInt64.lift( - _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_coin_balance,self._uniffi_clone_pointer(),) - ) + raise NotImplementedError + def finish(self, ): + """ + Convert this builder into a transaction. + """ + raise NotImplementedError + def gas(self, object_ids: "typing.List[ObjectId]"): + """ + Add gas coins that will be consumed. Optional. + """ + raise NotImplementedError + def gas_budget(self, budget: "int"): + """ + Set the gas budget for the transaction. + """ + raise NotImplementedError + def gas_price(self, price: "int"): + """ + Set the gas price for the transaction. + """ + raise NotImplementedError + def gas_station_sponsor(self, url: "str",duration: "typing.Union[object, typing.Optional[Duration]]" = _DEFAULT,headers: "typing.Union[object, typing.Optional[dict[str, typing.List[str]]]]" = _DEFAULT): + """ + Set the gas station sponsor. + """ - def coin_type(self, ) -> "TypeTag": - return _UniffiConverterTypeTypeTag.lift( - _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_coin_coin_type,self._uniffi_clone_pointer(),) - ) + raise NotImplementedError + def make_move_vec(self, elements: "typing.List[MoveArg]",type_tag: "TypeTag",name: "str"): + """ + Make a move vector from a list of elements. The elements must all be of + the type indicated by `type_tag`. + """ + raise NotImplementedError + def merge_coins(self, primary_coin: "PtbArgument",consumed_coins: "typing.List[PtbArgument]"): + """ + Merge multiple coins into one. + This method combines the balances of multiple coins of the same coin + type into a single coin. The `primary_coin` will receive the balances + from all `consumed_coins`. After merging, the `consumed_coins` will + be consumed and no longer exist. + """ + raise NotImplementedError + def move_call(self, package: "Address",module: "Identifier",function: "Identifier",arguments: "typing.Union[object, typing.List[PtbArgument]]" = _DEFAULT,type_args: "typing.Union[object, typing.List[TypeTag]]" = _DEFAULT,names: "typing.Union[object, typing.List[str]]" = _DEFAULT): + """ + Call a Move function with the given arguments. + """ + raise NotImplementedError + def publish(self, package_data: "MovePackageData",upgrade_cap_name: "str"): + """ + Publish a list of modules with the given dependencies. The result + assigned to `upgrade_cap_name` is the `0x2::package::UpgradeCap` + Move type. Note that the upgrade capability needs to be handled + after this call: + - transfer it to the transaction sender or another address + - burn it + - wrap it for access control + - discard the it to make a package immutable - def id(self, ) -> "ObjectId": - return _UniffiConverterTypeObjectId.lift( - _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_coin_id,self._uniffi_clone_pointer(),) - ) + The arguments required for this command are: + - `modules`: is the modules' bytecode to be published + - `dependencies`: is the list of IDs of the transitive dependencies of + the package + """ + raise NotImplementedError + def send_coins(self, coins: "typing.List[PtbArgument]",recipient: "Address",amount: "typing.Union[object, typing.Optional[PtbArgument]]" = _DEFAULT): + """ + Transfer some coins to a recipient address. If multiple coins are + provided then they will be merged. + The `amount` parameter specifies the quantity in NANOS, where 1 IOTA + equals 1_000_000_000 NANOS. + If `amount` is provided, that amount is split from the provided coins + and sent. + If `amount` is `None`, the entire coins are transferred. + All provided coins must have the same coin type. Mixing coins of + different types will result in an error. + If you intend to transfer all provided coins to another address in a + single transaction, consider using + `TransactionBuilder::transfer_objects()` instead. + """ + raise NotImplementedError + def send_iota(self, recipient: "Address",amount: "PtbArgument"): + """ + Send IOTA to a recipient address. -class _UniffiConverterTypeCoin: + The `amount` parameter specifies the quantity in NANOS, where 1 IOTA + equals 1_000_000_000 NANOS. That amount is split from the gas coin and + sent. + """ - @staticmethod - def lift(value: int): - return Coin._make_instance_(value) + raise NotImplementedError + def split_coins(self, coin: "PtbArgument",amounts: "typing.List[PtbArgument]",names: "typing.Union[object, typing.List[str]]" = _DEFAULT): + """ + Split a coin into many. + """ - @staticmethod - def check_lower(value: Coin): - if not isinstance(value, Coin): - raise TypeError("Expected Coin instance, {} found".format(type(value).__name__)) + raise NotImplementedError + def sponsor(self, sponsor: "Address"): + """ + Set the sponsor of the transaction. + """ - @staticmethod - def lower(value: CoinProtocol): - if not isinstance(value, Coin): - raise TypeError("Expected Coin instance, {} found".format(type(value).__name__)) - return value._uniffi_clone_pointer() + raise NotImplementedError + def stake(self, stake: "PtbArgument",validator_address: "Address"): + """ + Add stake to a validator's staking pool. - @classmethod - def read(cls, buf: _UniffiRustBuffer): - ptr = buf.read_u64() - if ptr == 0: - raise InternalError("Raw pointer value was null") - return cls.lift(ptr) + This is a high-level function which will split the provided stake amount + from the gas coin and then stake using the resulting coin. + """ - @classmethod - def write(cls, value: CoinProtocol, buf: _UniffiRustBuffer): - buf.write_u64(cls.lower(value)) -class CommandProtocol(typing.Protocol): - """ - A single command in a programmable transaction. + raise NotImplementedError + def transfer_objects(self, recipient: "Address",objects: "typing.List[PtbArgument]"): + """ + Transfer a list of objects to the given address, without producing any + result. + """ - # BCS + raise NotImplementedError + def unstake(self, staked_iota: "PtbArgument"): + """ + Withdraw stake from a validator's staking pool. + """ - The BCS serialized form for this type is defined by the following ABNF: + raise NotImplementedError + def upgrade(self, package_id: "ObjectId",package_data: "MovePackageData",upgrade_ticket: "PtbArgument",name: "typing.Union[object, typing.Optional[str]]" = _DEFAULT): + """ + Upgrade a Move package. - ```text - command = command-move-call - =/ command-transfer-objects - =/ command-split-coins - =/ command-merge-coins - =/ command-publish - =/ command-make-move-vector - =/ command-upgrade + - `modules`: is the modules' bytecode for the modules to be published + - `dependencies`: is the list of IDs of the transitive dependencies of + the package to be upgraded + - `package`: is the ID of the current package being upgraded + - `ticket`: is the upgrade ticket - command-move-call = %x00 move-call - command-transfer-objects = %x01 transfer-objects - command-split-coins = %x02 split-coins - command-merge-coins = %x03 merge-coins - command-publish = %x04 publish - command-make-move-vector = %x05 make-move-vector - command-upgrade = %x06 upgrade - ``` - """ + To get the ticket, you have to call the + `0x2::package::authorize_upgrade` function, and pass the package + ID, the upgrade policy, and package digest. + """ - pass -# Command is a Rust-only trait - it's a wrapper around a Rust implementation. -class Command(): + raise NotImplementedError +# ClientTransactionBuilder is a Rust-only trait - it's a wrapper around a Rust implementation. +class ClientTransactionBuilder(): """ - A single command in a programmable transaction. - - # BCS - - The BCS serialized form for this type is defined by the following ABNF: - - ```text - command = command-move-call - =/ command-transfer-objects - =/ command-split-coins - =/ command-merge-coins - =/ command-publish - =/ command-make-move-vector - =/ command-upgrade - - command-move-call = %x00 move-call - command-transfer-objects = %x01 transfer-objects - command-split-coins = %x02 split-coins - command-merge-coins = %x03 merge-coins - command-publish = %x04 publish - command-make-move-vector = %x05 make-move-vector - command-upgrade = %x06 upgrade - ``` + A builder for creating transactions which uses a GraphQL client to + automatically resolve inputs. Use `finish` to finalize the transaction data. """ _pointer: ctypes.c_void_p @@ -28891,10 +29197,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_free_command, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_free_clienttransactionbuilder, pointer) def _uniffi_clone_pointer(self): - return _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_command, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_clienttransactionbuilder, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -28904,54 +29210,772 @@ def _make_instance_(cls, pointer): inst = cls.__new__(cls) inst._pointer = pointer return inst - @classmethod - def new_make_move_vector(cls, make_move_vector: "MakeMoveVector"): - """ - Given n-values of the same type, it constructs a vector. For non objects - or an empty vector, the type tag must be specified. - """ - - _UniffiConverterTypeMakeMoveVector.check_lower(make_move_vector) - - # Call the (fallible) function before creating any half-baked object instances. - pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_command_new_make_move_vector, - _UniffiConverterTypeMakeMoveVector.lower(make_move_vector)) - return cls._make_instance_(pointer) - @classmethod - def new_merge_coins(cls, merge_coins: "MergeCoins"): + async def dry_run(self, skip_checks: "typing.Union[object, bool]" = _DEFAULT) -> "DryRunResult": """ - It merges n-coins into the first coin + Dry run the transaction. """ - _UniffiConverterTypeMergeCoins.check_lower(merge_coins) + if skip_checks is _DEFAULT: + skip_checks = False + _UniffiConverterBool.check_lower(skip_checks) - # Call the (fallible) function before creating any half-baked object instances. - pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_command_new_merge_coins, - _UniffiConverterTypeMergeCoins.lower(merge_coins)) - return cls._make_instance_(pointer) + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_dry_run( + self._uniffi_clone_pointer(), + _UniffiConverterBool.lower(skip_checks) + ), + _UniffiLib.ffi_iota_sdk_ffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_iota_sdk_ffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_iota_sdk_ffi_rust_future_free_rust_buffer, + # lift function + _UniffiConverterTypeDryRunResult.lift, + + # Error FFI converter +_UniffiConverterTypeSdkFfiError, - @classmethod - def new_move_call(cls, move_call: "MoveCall"): - """ - A call to either an entry or a public Move function - """ + ) - _UniffiConverterTypeMoveCall.check_lower(move_call) - - # Call the (fallible) function before creating any half-baked object instances. - pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_command_new_move_call, - _UniffiConverterTypeMoveCall.lower(move_call)) - return cls._make_instance_(pointer) - @classmethod - def new_publish(cls, publish: "Publish"): + + async def execute(self, keypair: "SimpleKeypair",wait_for: "typing.Union[object, typing.Optional[WaitForTx]]" = _DEFAULT) -> "TransactionEffects": """ - Publishes a Move package. It takes the package bytes and a list of the - package's transitive dependencies to link against on-chain. + Execute the transaction and optionally wait for finalization. """ - _UniffiConverterTypePublish.check_lower(publish) + _UniffiConverterTypeSimpleKeypair.check_lower(keypair) + + if wait_for is _DEFAULT: + wait_for = None + _UniffiConverterOptionalTypeWaitForTx.check_lower(wait_for) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_execute( + self._uniffi_clone_pointer(), + _UniffiConverterTypeSimpleKeypair.lower(keypair), + _UniffiConverterOptionalTypeWaitForTx.lower(wait_for) + ), + _UniffiLib.ffi_iota_sdk_ffi_rust_future_poll_pointer, + _UniffiLib.ffi_iota_sdk_ffi_rust_future_complete_pointer, + _UniffiLib.ffi_iota_sdk_ffi_rust_future_free_pointer, + # lift function + _UniffiConverterTypeTransactionEffects.lift, + + # Error FFI converter +_UniffiConverterTypeSdkFfiError, + + ) + + + + async def execute_with_sponsor(self, keypair: "SimpleKeypair",sponsor_keypair: "SimpleKeypair",wait_for: "typing.Union[object, typing.Optional[WaitForTx]]" = _DEFAULT) -> "TransactionEffects": + """ + Execute the transaction and optionally wait for finalization. + """ + + _UniffiConverterTypeSimpleKeypair.check_lower(keypair) + + _UniffiConverterTypeSimpleKeypair.check_lower(sponsor_keypair) + + if wait_for is _DEFAULT: + wait_for = None + _UniffiConverterOptionalTypeWaitForTx.check_lower(wait_for) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_execute_with_sponsor( + self._uniffi_clone_pointer(), + _UniffiConverterTypeSimpleKeypair.lower(keypair), + _UniffiConverterTypeSimpleKeypair.lower(sponsor_keypair), + _UniffiConverterOptionalTypeWaitForTx.lower(wait_for) + ), + _UniffiLib.ffi_iota_sdk_ffi_rust_future_poll_pointer, + _UniffiLib.ffi_iota_sdk_ffi_rust_future_complete_pointer, + _UniffiLib.ffi_iota_sdk_ffi_rust_future_free_pointer, + # lift function + _UniffiConverterTypeTransactionEffects.lift, + + # Error FFI converter +_UniffiConverterTypeSdkFfiError, + + ) + + + + + def expiration(self, epoch: "int") -> "ClientTransactionBuilder": + """ + Set the expiration of the transaction to be a specific epoch. + """ + + _UniffiConverterUInt64.check_lower(epoch) + + return _UniffiConverterTypeClientTransactionBuilder.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_expiration,self._uniffi_clone_pointer(), + _UniffiConverterUInt64.lower(epoch)) + ) + + + + + async def finish(self, ) -> "Transaction": + """ + Convert this builder into a transaction. + """ + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_finish( + self._uniffi_clone_pointer(), + ), + _UniffiLib.ffi_iota_sdk_ffi_rust_future_poll_pointer, + _UniffiLib.ffi_iota_sdk_ffi_rust_future_complete_pointer, + _UniffiLib.ffi_iota_sdk_ffi_rust_future_free_pointer, + # lift function + _UniffiConverterTypeTransaction.lift, + + # Error FFI converter +_UniffiConverterTypeSdkFfiError, + + ) + + + + + def gas(self, object_ids: "typing.List[ObjectId]") -> "ClientTransactionBuilder": + """ + Add gas coins that will be consumed. Optional. + """ + + _UniffiConverterSequenceTypeObjectId.check_lower(object_ids) + + return _UniffiConverterTypeClientTransactionBuilder.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas,self._uniffi_clone_pointer(), + _UniffiConverterSequenceTypeObjectId.lower(object_ids)) + ) + + + + + + def gas_budget(self, budget: "int") -> "ClientTransactionBuilder": + """ + Set the gas budget for the transaction. + """ + + _UniffiConverterUInt64.check_lower(budget) + + return _UniffiConverterTypeClientTransactionBuilder.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas_budget,self._uniffi_clone_pointer(), + _UniffiConverterUInt64.lower(budget)) + ) + + + + + + def gas_price(self, price: "int") -> "ClientTransactionBuilder": + """ + Set the gas price for the transaction. + """ + + _UniffiConverterUInt64.check_lower(price) + + return _UniffiConverterTypeClientTransactionBuilder.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas_price,self._uniffi_clone_pointer(), + _UniffiConverterUInt64.lower(price)) + ) + + + + + + def gas_station_sponsor(self, url: "str",duration: "typing.Union[object, typing.Optional[Duration]]" = _DEFAULT,headers: "typing.Union[object, typing.Optional[dict[str, typing.List[str]]]]" = _DEFAULT) -> "ClientTransactionBuilder": + """ + Set the gas station sponsor. + """ + + _UniffiConverterString.check_lower(url) + + if duration is _DEFAULT: + duration = None + _UniffiConverterOptionalDuration.check_lower(duration) + + if headers is _DEFAULT: + headers = None + _UniffiConverterOptionalMapStringSequenceString.check_lower(headers) + + return _UniffiConverterTypeClientTransactionBuilder.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_gas_station_sponsor,self._uniffi_clone_pointer(), + _UniffiConverterString.lower(url), + _UniffiConverterOptionalDuration.lower(duration), + _UniffiConverterOptionalMapStringSequenceString.lower(headers)) + ) + + + + + + def make_move_vec(self, elements: "typing.List[MoveArg]",type_tag: "TypeTag",name: "str") -> "ClientTransactionBuilder": + """ + Make a move vector from a list of elements. The elements must all be of + the type indicated by `type_tag`. + """ + + _UniffiConverterSequenceTypeMoveArg.check_lower(elements) + + _UniffiConverterTypeTypeTag.check_lower(type_tag) + + _UniffiConverterString.check_lower(name) + + return _UniffiConverterTypeClientTransactionBuilder.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_make_move_vec,self._uniffi_clone_pointer(), + _UniffiConverterSequenceTypeMoveArg.lower(elements), + _UniffiConverterTypeTypeTag.lower(type_tag), + _UniffiConverterString.lower(name)) + ) + + + + + + def merge_coins(self, primary_coin: "PtbArgument",consumed_coins: "typing.List[PtbArgument]") -> "ClientTransactionBuilder": + """ + Merge multiple coins into one. + + This method combines the balances of multiple coins of the same coin + type into a single coin. The `primary_coin` will receive the balances + from all `consumed_coins`. After merging, the `consumed_coins` will + be consumed and no longer exist. + """ + + _UniffiConverterTypePtbArgument.check_lower(primary_coin) + + _UniffiConverterSequenceTypePtbArgument.check_lower(consumed_coins) + + return _UniffiConverterTypeClientTransactionBuilder.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_merge_coins,self._uniffi_clone_pointer(), + _UniffiConverterTypePtbArgument.lower(primary_coin), + _UniffiConverterSequenceTypePtbArgument.lower(consumed_coins)) + ) + + + + + + def move_call(self, package: "Address",module: "Identifier",function: "Identifier",arguments: "typing.Union[object, typing.List[PtbArgument]]" = _DEFAULT,type_args: "typing.Union[object, typing.List[TypeTag]]" = _DEFAULT,names: "typing.Union[object, typing.List[str]]" = _DEFAULT) -> "ClientTransactionBuilder": + """ + Call a Move function with the given arguments. + """ + + _UniffiConverterTypeAddress.check_lower(package) + + _UniffiConverterTypeIdentifier.check_lower(module) + + _UniffiConverterTypeIdentifier.check_lower(function) + + if arguments is _DEFAULT: + arguments = [] + _UniffiConverterSequenceTypePtbArgument.check_lower(arguments) + + if type_args is _DEFAULT: + type_args = [] + _UniffiConverterSequenceTypeTypeTag.check_lower(type_args) + + if names is _DEFAULT: + names = [] + _UniffiConverterSequenceString.check_lower(names) + + return _UniffiConverterTypeClientTransactionBuilder.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_move_call,self._uniffi_clone_pointer(), + _UniffiConverterTypeAddress.lower(package), + _UniffiConverterTypeIdentifier.lower(module), + _UniffiConverterTypeIdentifier.lower(function), + _UniffiConverterSequenceTypePtbArgument.lower(arguments), + _UniffiConverterSequenceTypeTypeTag.lower(type_args), + _UniffiConverterSequenceString.lower(names)) + ) + + + + + + def publish(self, package_data: "MovePackageData",upgrade_cap_name: "str") -> "ClientTransactionBuilder": + """ + Publish a list of modules with the given dependencies. The result + assigned to `upgrade_cap_name` is the `0x2::package::UpgradeCap` + Move type. Note that the upgrade capability needs to be handled + after this call: + - transfer it to the transaction sender or another address + - burn it + - wrap it for access control + - discard the it to make a package immutable + + The arguments required for this command are: + - `modules`: is the modules' bytecode to be published + - `dependencies`: is the list of IDs of the transitive dependencies of + the package + """ + + _UniffiConverterTypeMovePackageData.check_lower(package_data) + + _UniffiConverterString.check_lower(upgrade_cap_name) + + return _UniffiConverterTypeClientTransactionBuilder.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_publish,self._uniffi_clone_pointer(), + _UniffiConverterTypeMovePackageData.lower(package_data), + _UniffiConverterString.lower(upgrade_cap_name)) + ) + + + + + + def send_coins(self, coins: "typing.List[PtbArgument]",recipient: "Address",amount: "typing.Union[object, typing.Optional[PtbArgument]]" = _DEFAULT) -> "ClientTransactionBuilder": + """ + Transfer some coins to a recipient address. If multiple coins are + provided then they will be merged. + + The `amount` parameter specifies the quantity in NANOS, where 1 IOTA + equals 1_000_000_000 NANOS. + If `amount` is provided, that amount is split from the provided coins + and sent. + If `amount` is `None`, the entire coins are transferred. + + All provided coins must have the same coin type. Mixing coins of + different types will result in an error. + + If you intend to transfer all provided coins to another address in a + single transaction, consider using + `TransactionBuilder::transfer_objects()` instead. + """ + + _UniffiConverterSequenceTypePtbArgument.check_lower(coins) + + _UniffiConverterTypeAddress.check_lower(recipient) + + if amount is _DEFAULT: + amount = None + _UniffiConverterOptionalTypePtbArgument.check_lower(amount) + + return _UniffiConverterTypeClientTransactionBuilder.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_send_coins,self._uniffi_clone_pointer(), + _UniffiConverterSequenceTypePtbArgument.lower(coins), + _UniffiConverterTypeAddress.lower(recipient), + _UniffiConverterOptionalTypePtbArgument.lower(amount)) + ) + + + + + + def send_iota(self, recipient: "Address",amount: "PtbArgument") -> "ClientTransactionBuilder": + """ + Send IOTA to a recipient address. + + The `amount` parameter specifies the quantity in NANOS, where 1 IOTA + equals 1_000_000_000 NANOS. That amount is split from the gas coin and + sent. + """ + + _UniffiConverterTypeAddress.check_lower(recipient) + + _UniffiConverterTypePtbArgument.check_lower(amount) + + return _UniffiConverterTypeClientTransactionBuilder.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_send_iota,self._uniffi_clone_pointer(), + _UniffiConverterTypeAddress.lower(recipient), + _UniffiConverterTypePtbArgument.lower(amount)) + ) + + + + + + def split_coins(self, coin: "PtbArgument",amounts: "typing.List[PtbArgument]",names: "typing.Union[object, typing.List[str]]" = _DEFAULT) -> "ClientTransactionBuilder": + """ + Split a coin into many. + """ + + _UniffiConverterTypePtbArgument.check_lower(coin) + + _UniffiConverterSequenceTypePtbArgument.check_lower(amounts) + + if names is _DEFAULT: + names = [] + _UniffiConverterSequenceString.check_lower(names) + + return _UniffiConverterTypeClientTransactionBuilder.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_split_coins,self._uniffi_clone_pointer(), + _UniffiConverterTypePtbArgument.lower(coin), + _UniffiConverterSequenceTypePtbArgument.lower(amounts), + _UniffiConverterSequenceString.lower(names)) + ) + + + + + + def sponsor(self, sponsor: "Address") -> "ClientTransactionBuilder": + """ + Set the sponsor of the transaction. + """ + + _UniffiConverterTypeAddress.check_lower(sponsor) + + return _UniffiConverterTypeClientTransactionBuilder.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_sponsor,self._uniffi_clone_pointer(), + _UniffiConverterTypeAddress.lower(sponsor)) + ) + + + + + + def stake(self, stake: "PtbArgument",validator_address: "Address") -> "ClientTransactionBuilder": + """ + Add stake to a validator's staking pool. + + This is a high-level function which will split the provided stake amount + from the gas coin and then stake using the resulting coin. + """ + + _UniffiConverterTypePtbArgument.check_lower(stake) + + _UniffiConverterTypeAddress.check_lower(validator_address) + + return _UniffiConverterTypeClientTransactionBuilder.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_stake,self._uniffi_clone_pointer(), + _UniffiConverterTypePtbArgument.lower(stake), + _UniffiConverterTypeAddress.lower(validator_address)) + ) + + + + + + def transfer_objects(self, recipient: "Address",objects: "typing.List[PtbArgument]") -> "ClientTransactionBuilder": + """ + Transfer a list of objects to the given address, without producing any + result. + """ + + _UniffiConverterTypeAddress.check_lower(recipient) + + _UniffiConverterSequenceTypePtbArgument.check_lower(objects) + + return _UniffiConverterTypeClientTransactionBuilder.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_transfer_objects,self._uniffi_clone_pointer(), + _UniffiConverterTypeAddress.lower(recipient), + _UniffiConverterSequenceTypePtbArgument.lower(objects)) + ) + + + + + + def unstake(self, staked_iota: "PtbArgument") -> "ClientTransactionBuilder": + """ + Withdraw stake from a validator's staking pool. + """ + + _UniffiConverterTypePtbArgument.check_lower(staked_iota) + + return _UniffiConverterTypeClientTransactionBuilder.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_unstake,self._uniffi_clone_pointer(), + _UniffiConverterTypePtbArgument.lower(staked_iota)) + ) + + + + + + def upgrade(self, package_id: "ObjectId",package_data: "MovePackageData",upgrade_ticket: "PtbArgument",name: "typing.Union[object, typing.Optional[str]]" = _DEFAULT) -> "ClientTransactionBuilder": + """ + Upgrade a Move package. + + - `modules`: is the modules' bytecode for the modules to be published + - `dependencies`: is the list of IDs of the transitive dependencies of + the package to be upgraded + - `package`: is the ID of the current package being upgraded + - `ticket`: is the upgrade ticket + + To get the ticket, you have to call the + `0x2::package::authorize_upgrade` function, and pass the package + ID, the upgrade policy, and package digest. + """ + + _UniffiConverterTypeObjectId.check_lower(package_id) + + _UniffiConverterTypeMovePackageData.check_lower(package_data) + + _UniffiConverterTypePtbArgument.check_lower(upgrade_ticket) + + if name is _DEFAULT: + name = None + _UniffiConverterOptionalString.check_lower(name) + + return _UniffiConverterTypeClientTransactionBuilder.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_clienttransactionbuilder_upgrade,self._uniffi_clone_pointer(), + _UniffiConverterTypeObjectId.lower(package_id), + _UniffiConverterTypeMovePackageData.lower(package_data), + _UniffiConverterTypePtbArgument.lower(upgrade_ticket), + _UniffiConverterOptionalString.lower(name)) + ) + + + + + + +class _UniffiConverterTypeClientTransactionBuilder: + + @staticmethod + def lift(value: int): + return ClientTransactionBuilder._make_instance_(value) + + @staticmethod + def check_lower(value: ClientTransactionBuilder): + if not isinstance(value, ClientTransactionBuilder): + raise TypeError("Expected ClientTransactionBuilder instance, {} found".format(type(value).__name__)) + + @staticmethod + def lower(value: ClientTransactionBuilderProtocol): + if not isinstance(value, ClientTransactionBuilder): + raise TypeError("Expected ClientTransactionBuilder instance, {} found".format(type(value).__name__)) + return value._uniffi_clone_pointer() + + @classmethod + def read(cls, buf: _UniffiRustBuffer): + ptr = buf.read_u64() + if ptr == 0: + raise InternalError("Raw pointer value was null") + return cls.lift(ptr) + + @classmethod + def write(cls, value: ClientTransactionBuilderProtocol, buf: _UniffiRustBuffer): + buf.write_u64(cls.lower(value)) +class CoinProtocol(typing.Protocol): + def balance(self, ): + raise NotImplementedError + def coin_type(self, ): + raise NotImplementedError + def id(self, ): + raise NotImplementedError +# Coin is a Rust-only trait - it's a wrapper around a Rust implementation. +class Coin(): + _pointer: ctypes.c_void_p + + def __init__(self, *args, **kwargs): + raise ValueError("This class has no default constructor") + + def __del__(self): + # In case of partial initialization of instances. + pointer = getattr(self, "_pointer", None) + if pointer is not None: + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_free_coin, pointer) + + def _uniffi_clone_pointer(self): + return _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_coin, self._pointer) + + # Used by alternative constructors or any methods which return this type. + @classmethod + def _make_instance_(cls, pointer): + # Lightly yucky way to bypass the usual __init__ logic + # and just create a new instance with the required pointer. + inst = cls.__new__(cls) + inst._pointer = pointer + return inst + @classmethod + def try_from_object(cls, object: "Object"): + _UniffiConverterTypeObject.check_lower(object) + + # Call the (fallible) function before creating any half-baked object instances. + pointer = _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_coin_try_from_object, + _UniffiConverterTypeObject.lower(object)) + return cls._make_instance_(pointer) + + + + def balance(self, ) -> "int": + return _UniffiConverterUInt64.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_coin_balance,self._uniffi_clone_pointer(),) + ) + + + + + + def coin_type(self, ) -> "TypeTag": + return _UniffiConverterTypeTypeTag.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_coin_coin_type,self._uniffi_clone_pointer(),) + ) + + + + + + def id(self, ) -> "ObjectId": + return _UniffiConverterTypeObjectId.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_coin_id,self._uniffi_clone_pointer(),) + ) + + + + + + +class _UniffiConverterTypeCoin: + + @staticmethod + def lift(value: int): + return Coin._make_instance_(value) + + @staticmethod + def check_lower(value: Coin): + if not isinstance(value, Coin): + raise TypeError("Expected Coin instance, {} found".format(type(value).__name__)) + + @staticmethod + def lower(value: CoinProtocol): + if not isinstance(value, Coin): + raise TypeError("Expected Coin instance, {} found".format(type(value).__name__)) + return value._uniffi_clone_pointer() + + @classmethod + def read(cls, buf: _UniffiRustBuffer): + ptr = buf.read_u64() + if ptr == 0: + raise InternalError("Raw pointer value was null") + return cls.lift(ptr) + + @classmethod + def write(cls, value: CoinProtocol, buf: _UniffiRustBuffer): + buf.write_u64(cls.lower(value)) +class CommandProtocol(typing.Protocol): + """ + A single command in a programmable transaction. + + # BCS + + The BCS serialized form for this type is defined by the following ABNF: + + ```text + command = command-move-call + =/ command-transfer-objects + =/ command-split-coins + =/ command-merge-coins + =/ command-publish + =/ command-make-move-vector + =/ command-upgrade + + command-move-call = %x00 move-call + command-transfer-objects = %x01 transfer-objects + command-split-coins = %x02 split-coins + command-merge-coins = %x03 merge-coins + command-publish = %x04 publish + command-make-move-vector = %x05 make-move-vector + command-upgrade = %x06 upgrade + ``` + """ + + pass +# Command is a Rust-only trait - it's a wrapper around a Rust implementation. +class Command(): + """ + A single command in a programmable transaction. + + # BCS + + The BCS serialized form for this type is defined by the following ABNF: + + ```text + command = command-move-call + =/ command-transfer-objects + =/ command-split-coins + =/ command-merge-coins + =/ command-publish + =/ command-make-move-vector + =/ command-upgrade + + command-move-call = %x00 move-call + command-transfer-objects = %x01 transfer-objects + command-split-coins = %x02 split-coins + command-merge-coins = %x03 merge-coins + command-publish = %x04 publish + command-make-move-vector = %x05 make-move-vector + command-upgrade = %x06 upgrade + ``` + """ + + _pointer: ctypes.c_void_p + + def __init__(self, *args, **kwargs): + raise ValueError("This class has no default constructor") + + def __del__(self): + # In case of partial initialization of instances. + pointer = getattr(self, "_pointer", None) + if pointer is not None: + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_free_command, pointer) + + def _uniffi_clone_pointer(self): + return _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_command, self._pointer) + + # Used by alternative constructors or any methods which return this type. + @classmethod + def _make_instance_(cls, pointer): + # Lightly yucky way to bypass the usual __init__ logic + # and just create a new instance with the required pointer. + inst = cls.__new__(cls) + inst._pointer = pointer + return inst + @classmethod + def new_make_move_vector(cls, make_move_vector: "MakeMoveVector"): + """ + Given n-values of the same type, it constructs a vector. For non objects + or an empty vector, the type tag must be specified. + """ + + _UniffiConverterTypeMakeMoveVector.check_lower(make_move_vector) + + # Call the (fallible) function before creating any half-baked object instances. + pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_command_new_make_move_vector, + _UniffiConverterTypeMakeMoveVector.lower(make_move_vector)) + return cls._make_instance_(pointer) + + @classmethod + def new_merge_coins(cls, merge_coins: "MergeCoins"): + """ + It merges n-coins into the first coin + """ + + _UniffiConverterTypeMergeCoins.check_lower(merge_coins) + + # Call the (fallible) function before creating any half-baked object instances. + pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_command_new_merge_coins, + _UniffiConverterTypeMergeCoins.lower(merge_coins)) + return cls._make_instance_(pointer) + + @classmethod + def new_move_call(cls, move_call: "MoveCall"): + """ + A call to either an entry or a public Move function + """ + + _UniffiConverterTypeMoveCall.check_lower(move_call) + + # Call the (fallible) function before creating any half-baked object instances. + pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_command_new_move_call, + _UniffiConverterTypeMoveCall.lower(move_call)) + return cls._make_instance_(pointer) + + @classmethod + def new_publish(cls, publish: "Publish"): + """ + Publishes a Move package. It takes the package bytes and a list of the + package's transitive dependencies to link against on-chain. + """ + + _UniffiConverterTypePublish.check_lower(publish) # Call the (fallible) function before creating any half-baked object instances. pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_command_new_publish, @@ -36491,6 +37515,12 @@ def object_id(self, ): Return this object's id """ + raise NotImplementedError + def object_ref(self, ): + """ + Return this object's reference + """ + raise NotImplementedError def object_type(self, ): """ @@ -36667,6 +37697,19 @@ def object_id(self, ) -> "ObjectId": + def object_ref(self, ) -> "ObjectReference": + """ + Return this object's reference + """ + + return _UniffiConverterTypeObjectReference.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_object_object_ref,self._uniffi_clone_pointer(),) + ) + + + + + def object_type(self, ) -> "ObjectType": """ Return this object's type @@ -38337,6 +39380,15 @@ def object_id_from_hex(cls, hex: "str"): _UniffiConverterString.lower(hex)) return cls._make_instance_(pointer) + @classmethod + def object_ref(cls, id: "ObjectReference"): + _UniffiConverterTypeObjectReference.check_lower(id) + + # Call the (fallible) function before creating any half-baked object instances. + pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_ptbargument_object_ref, + _UniffiConverterTypeObjectReference.lower(id)) + return cls._make_instance_(pointer) + @classmethod def option(cls, value: "typing.Optional[MoveArg]"): _UniffiConverterOptionalTypeMoveArg.check_lower(value) @@ -42215,21 +43267,14 @@ class TransactionBuilderProtocol(typing.Protocol): transaction data. """ - def dry_run(self, skip_checks: "typing.Union[object, bool]" = _DEFAULT): - """ - Dry run the transaction. + def execute_with_gas_station(self, keypair: "SimpleKeypair"): """ + Execute the transaction using the gas station and return the JSON + transaction effects. This will fail unless data is set with the + `gas_station_sponsor` function. - raise NotImplementedError - def execute(self, keypair: "SimpleKeypair",wait_for: "typing.Union[object, typing.Optional[WaitForTx]]" = _DEFAULT): - """ - Execute the transaction and optionally wait for finalization. - """ - - raise NotImplementedError - def execute_with_sponsor(self, keypair: "SimpleKeypair",sponsor_keypair: "SimpleKeypair",wait_for: "typing.Union[object, typing.Optional[WaitForTx]]" = _DEFAULT): - """ - Execute the transaction and optionally wait for finalization. + NOTE: These effects are not necessarily compatible with + `TransactionEffects` """ raise NotImplementedError @@ -42245,7 +43290,7 @@ def finish(self, ): """ raise NotImplementedError - def gas(self, object_ids: "typing.List[ObjectId]"): + def gas(self, object_refs: "typing.List[ObjectReference]"): """ Add gas coins that will be consumed. Optional. """ @@ -42343,7 +43388,7 @@ def send_iota(self, recipient: "Address",amount: "PtbArgument"): raise NotImplementedError def split_coins(self, coin: "PtbArgument",amounts: "typing.List[PtbArgument]",names: "typing.Union[object, typing.List[str]]" = _DEFAULT): """ - Split a coin into many. + Split a coin by the provided amounts. """ raise NotImplementedError @@ -42390,6 +43435,8 @@ def upgrade(self, package_id: "ObjectId",package_data: "MovePackageData",upgrade ID, the upgrade policy, and package digest. """ + raise NotImplementedError + def with_client(self, client: "GraphQlClient"): raise NotImplementedError # TransactionBuilder is a Rust-only trait - it's a wrapper around a Rust implementation. class TransactionBuilder(): @@ -42399,9 +43446,15 @@ class TransactionBuilder(): """ _pointer: ctypes.c_void_p - - def __init__(self, *args, **kwargs): - raise ValueError("This class has no default constructor") + def __init__(self, sender: "Address"): + """ + Create a new transaction builder and initialize its elements to default. + """ + + _UniffiConverterTypeAddress.check_lower(sender) + + self._pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_transactionbuilder_new, + _UniffiConverterTypeAddress.lower(sender)) def __del__(self): # In case of partial initialization of instances. @@ -42420,115 +43473,29 @@ def _make_instance_(cls, pointer): inst = cls.__new__(cls) inst._pointer = pointer return inst - @classmethod - async def init(cls, sender: "Address",client: "GraphQlClient"): - """ - Create a new transaction builder and initialize its elements to default. - """ - - _UniffiConverterTypeAddress.check_lower(sender) - - _UniffiConverterTypeGraphQlClient.check_lower(client) - - - return await _uniffi_rust_call_async( - _UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_transactionbuilder_init( - _UniffiConverterTypeAddress.lower(sender), - _UniffiConverterTypeGraphQlClient.lower(client)), - _UniffiLib.ffi_iota_sdk_ffi_rust_future_poll_pointer, - _UniffiLib.ffi_iota_sdk_ffi_rust_future_complete_pointer, - _UniffiLib.ffi_iota_sdk_ffi_rust_future_free_pointer, - _UniffiConverterTypeTransactionBuilder.lift, - - # Error FFI converter - None, - - ) - - - async def dry_run(self, skip_checks: "typing.Union[object, bool]" = _DEFAULT) -> "DryRunResult": + async def execute_with_gas_station(self, keypair: "SimpleKeypair") -> "Value": """ - Dry run the transaction. + Execute the transaction using the gas station and return the JSON + transaction effects. This will fail unless data is set with the + `gas_station_sponsor` function. + + NOTE: These effects are not necessarily compatible with + `TransactionEffects` """ - if skip_checks is _DEFAULT: - skip_checks = False - _UniffiConverterBool.check_lower(skip_checks) + _UniffiConverterTypeSimpleKeypair.check_lower(keypair) return await _uniffi_rust_call_async( - _UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_dry_run( + _UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_execute_with_gas_station( self._uniffi_clone_pointer(), - _UniffiConverterBool.lower(skip_checks) + _UniffiConverterTypeSimpleKeypair.lower(keypair) ), _UniffiLib.ffi_iota_sdk_ffi_rust_future_poll_rust_buffer, _UniffiLib.ffi_iota_sdk_ffi_rust_future_complete_rust_buffer, _UniffiLib.ffi_iota_sdk_ffi_rust_future_free_rust_buffer, # lift function - _UniffiConverterTypeDryRunResult.lift, - - # Error FFI converter -_UniffiConverterTypeSdkFfiError, - - ) - - - - async def execute(self, keypair: "SimpleKeypair",wait_for: "typing.Union[object, typing.Optional[WaitForTx]]" = _DEFAULT) -> "TransactionEffects": - """ - Execute the transaction and optionally wait for finalization. - """ - - _UniffiConverterTypeSimpleKeypair.check_lower(keypair) - - if wait_for is _DEFAULT: - wait_for = None - _UniffiConverterOptionalTypeWaitForTx.check_lower(wait_for) - - return await _uniffi_rust_call_async( - _UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_execute( - self._uniffi_clone_pointer(), - _UniffiConverterTypeSimpleKeypair.lower(keypair), - _UniffiConverterOptionalTypeWaitForTx.lower(wait_for) - ), - _UniffiLib.ffi_iota_sdk_ffi_rust_future_poll_pointer, - _UniffiLib.ffi_iota_sdk_ffi_rust_future_complete_pointer, - _UniffiLib.ffi_iota_sdk_ffi_rust_future_free_pointer, - # lift function - _UniffiConverterTypeTransactionEffects.lift, - - # Error FFI converter -_UniffiConverterTypeSdkFfiError, - - ) - - - - async def execute_with_sponsor(self, keypair: "SimpleKeypair",sponsor_keypair: "SimpleKeypair",wait_for: "typing.Union[object, typing.Optional[WaitForTx]]" = _DEFAULT) -> "TransactionEffects": - """ - Execute the transaction and optionally wait for finalization. - """ - - _UniffiConverterTypeSimpleKeypair.check_lower(keypair) - - _UniffiConverterTypeSimpleKeypair.check_lower(sponsor_keypair) - - if wait_for is _DEFAULT: - wait_for = None - _UniffiConverterOptionalTypeWaitForTx.check_lower(wait_for) - - return await _uniffi_rust_call_async( - _UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_execute_with_sponsor( - self._uniffi_clone_pointer(), - _UniffiConverterTypeSimpleKeypair.lower(keypair), - _UniffiConverterTypeSimpleKeypair.lower(sponsor_keypair), - _UniffiConverterOptionalTypeWaitForTx.lower(wait_for) - ), - _UniffiLib.ffi_iota_sdk_ffi_rust_future_poll_pointer, - _UniffiLib.ffi_iota_sdk_ffi_rust_future_complete_pointer, - _UniffiLib.ffi_iota_sdk_ffi_rust_future_free_pointer, - # lift function - _UniffiConverterTypeTransactionEffects.lift, + _UniffiConverterTypeValue.lift, # Error FFI converter _UniffiConverterTypeSdkFfiError, @@ -42553,39 +43520,30 @@ def expiration(self, epoch: "int") -> "TransactionBuilder": - async def finish(self, ) -> "Transaction": + + def finish(self, ) -> "Transaction": """ Convert this builder into a transaction. """ - return await _uniffi_rust_call_async( - _UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_finish( - self._uniffi_clone_pointer(), - ), - _UniffiLib.ffi_iota_sdk_ffi_rust_future_poll_pointer, - _UniffiLib.ffi_iota_sdk_ffi_rust_future_complete_pointer, - _UniffiLib.ffi_iota_sdk_ffi_rust_future_free_pointer, - # lift function - _UniffiConverterTypeTransaction.lift, - - # Error FFI converter -_UniffiConverterTypeSdkFfiError, - + return _UniffiConverterTypeTransaction.lift( + _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_finish,self._uniffi_clone_pointer(),) ) - def gas(self, object_ids: "typing.List[ObjectId]") -> "TransactionBuilder": + + def gas(self, object_refs: "typing.List[ObjectReference]") -> "TransactionBuilder": """ Add gas coins that will be consumed. Optional. """ - _UniffiConverterSequenceTypeObjectId.check_lower(object_ids) + _UniffiConverterSequenceTypeObjectReference.check_lower(object_refs) return _UniffiConverterTypeTransactionBuilder.lift( _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_gas,self._uniffi_clone_pointer(), - _UniffiConverterSequenceTypeObjectId.lower(object_ids)) + _UniffiConverterSequenceTypeObjectReference.lower(object_refs)) ) @@ -42828,7 +43786,7 @@ def send_iota(self, recipient: "Address",amount: "PtbArgument") -> "TransactionB def split_coins(self, coin: "PtbArgument",amounts: "typing.List[PtbArgument]",names: "typing.Union[object, typing.List[str]]" = _DEFAULT) -> "TransactionBuilder": """ - Split a coin into many. + Split a coin by the provided amounts. """ _UniffiConverterTypePtbArgument.check_lower(coin) @@ -42960,6 +43918,28 @@ def upgrade(self, package_id: "ObjectId",package_data: "MovePackageData",upgrade + async def with_client(self, client: "GraphQlClient") -> "ClientTransactionBuilder": + _UniffiConverterTypeGraphQlClient.check_lower(client) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_with_client( + self._uniffi_clone_pointer(), + _UniffiConverterTypeGraphQlClient.lower(client) + ), + _UniffiLib.ffi_iota_sdk_ffi_rust_future_poll_pointer, + _UniffiLib.ffi_iota_sdk_ffi_rust_future_complete_pointer, + _UniffiLib.ffi_iota_sdk_ffi_rust_future_free_pointer, + # lift function + _UniffiConverterTypeClientTransactionBuilder.lift, + + # Error FFI converter + + None, + + ) + + + class _UniffiConverterTypeTransactionBuilder: @@ -49171,6 +50151,7 @@ def zk_login_public_identifier_to_bcs(data: "ZkLoginPublicIdentifier") -> "bytes "CheckpointTransactionInfo", "CircomG1", "CircomG2", + "ClientTransactionBuilder", "Coin", "Command", "ConsensusCommitPrologueV1", diff --git a/crates/iota-sdk-ffi/src/transaction_builder/builder.rs b/crates/iota-sdk-ffi/src/transaction_builder/builder.rs new file mode 100644 index 000000000..3fbe56d0c --- /dev/null +++ b/crates/iota-sdk-ffi/src/transaction_builder/builder.rs @@ -0,0 +1,355 @@ +// Copyright (c) 2025 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::{ + collections::HashMap, + sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard}, + time::Duration, +}; + +use iota_sdk::{graphql_client::WaitForTx, types::Input}; + +use super::client_builder::ClientTransactionBuilder; +use crate::{ + crypto::simple::SimpleKeypair, + error::Result, + graphql::GraphQLClient, + transaction_builder::ptb_arg::{MoveArg, PTBArgument}, + types::{ + address::Address, + graphql::DryRunResult, + move_package::MovePackageData, + object::{ObjectId, ObjectReference}, + struct_tag::Identifier, + transaction::{Argument, Transaction, TransactionEffects}, + type_tag::TypeTag, + }, +}; + +/// A builder for creating transactions. Use `finish` to finalize the +/// transaction data. +#[derive(derive_more::From, uniffi::Object)] +pub struct TransactionBuilder(RwLock>); + +impl TransactionBuilder { + fn read(&self, f: F) -> T + where + F: FnOnce(&iota_sdk::transaction_builder::TransactionBuilder<()>) -> T, + { + let lock = self.0.read().expect("error reading from builder"); + f(&lock) + } + + fn write(&self, f: F) -> T + where + F: FnOnce(&mut iota_sdk::transaction_builder::TransactionBuilder<()>) -> T, + { + let mut lock = self.0.write().expect("error writing to builder"); + f(&mut lock) + } +} + +#[uniffi::export(async_runtime = "tokio")] +impl TransactionBuilder { + /// Create a new transaction builder and initialize its elements to default. + #[uniffi::constructor] + pub fn new(sender: &Address) -> Self { + Self(iota_sdk::transaction_builder::TransactionBuilder::new(**sender).into()) + } + + pub async fn with_client(&self, client: &GraphQLClient) -> ClientTransactionBuilder { + let client = client.inner().read().await.clone(); + ClientTransactionBuilder( + self.read(|builder| builder.clone().with_client(client)) + .into(), + ) + } + + /// Add gas coins that will be consumed. Optional. + pub fn gas(self: Arc, object_refs: Vec) -> Arc { + self.write(|builder| { + builder.gas(object_refs.into_iter().map(|id| id.into())); + }); + self + } + + /// Set the gas budget for the transaction. + pub fn gas_budget(self: Arc, budget: u64) -> Arc { + self.write(|builder| { + builder.gas_budget(budget); + }); + self + } + + /// Set the gas price for the transaction. + pub fn gas_price(self: Arc, price: u64) -> Arc { + self.write(|builder| { + builder.gas_price(price); + }); + self + } + + /// Set the sponsor of the transaction. + pub fn sponsor(self: Arc, sponsor: &Address) -> Arc { + self.write(|builder| { + builder.sponsor(**sponsor); + }); + self + } + + /// Set the gas station sponsor. + #[uniffi::method(default(duration = None, headers = None))] + pub fn gas_station_sponsor( + self: Arc, + url: String, + duration: Option, + headers: Option>>, + ) -> Arc { + self.write(|builder| { + let b = builder.gas_station_sponsor(url.parse().expect("invalid URL")); + if let Some(duration) = duration { + b.gas_reservation_duration(duration); + } + if let Some(headers) = headers { + for (name, values) in headers { + for value in values { + b.add_gas_station_header( + name.parse().expect("invalid header name"), + value.parse().expect("invalid header value"), + ); + } + } + } + }); + self + } + + /// Set the expiration of the transaction to be a specific epoch. + pub fn expiration(self: Arc, epoch: u64) -> Arc { + self.write(|builder| { + builder.expiration(epoch); + }); + self + } + + // Commands + + /// Call a Move function with the given arguments. + #[uniffi::method(default(type_args = [], arguments = [], names = []))] + pub fn move_call( + self: Arc, + package: &Address, + module: &Identifier, + function: &Identifier, + arguments: Vec>, + type_args: Vec>, + names: Vec, + ) -> Arc { + self.write(|builder| { + builder + .move_call(**package, &module.as_str(), &function.as_str()) + .arguments(arguments) + .type_tags(type_args.into_iter().map(|v| v.0.clone())) + .name(names); + }); + self + } + + /// Send IOTA to a recipient address. + /// + /// The `amount` parameter specifies the quantity in NANOS, where 1 IOTA + /// equals 1_000_000_000 NANOS. That amount is split from the gas coin and + /// sent. + pub fn send_iota(self: Arc, recipient: &Address, amount: &PTBArgument) -> Arc { + self.write(|builder| { + builder.send_iota(**recipient, amount); + }); + self + } + + /// Transfer some coins to a recipient address. If multiple coins are + /// provided then they will be merged. + /// + /// The `amount` parameter specifies the quantity in NANOS, where 1 IOTA + /// equals 1_000_000_000 NANOS. + /// If `amount` is provided, that amount is split from the provided coins + /// and sent. + /// If `amount` is `None`, the entire coins are transferred. + /// + /// All provided coins must have the same coin type. Mixing coins of + /// different types will result in an error. + /// + /// If you intend to transfer all provided coins to another address in a + /// single transaction, consider using + /// `TransactionBuilder::transfer_objects()` instead. + #[uniffi::method(default(amount = None))] + pub fn send_coins( + self: Arc, + coins: Vec>, + recipient: &Address, + amount: Option>, + ) -> Arc { + self.write(|builder| { + builder.send_coins::<_, &PTBArgument>(coins, **recipient, amount.as_deref()); + }); + self + } + + /// Transfer a list of objects to the given address, without producing any + /// result. + pub fn transfer_objects( + self: Arc, + recipient: &Address, + objects: Vec>, + ) -> Arc { + self.write(|builder| { + builder.transfer_objects(**recipient, objects); + }); + self + } + + /// Split a coin by the provided amounts. + #[uniffi::method(default(names = []))] + pub fn split_coins( + self: Arc, + coin: &PTBArgument, + amounts: Vec>, + names: Vec, + ) -> Arc { + self.write(|builder| { + builder.split_coins(coin, amounts).name(names); + }); + self + } + + /// Merge multiple coins into one. + /// + /// This method combines the balances of multiple coins of the same coin + /// type into a single coin. The `primary_coin` will receive the balances + /// from all `consumed_coins`. After merging, the `consumed_coins` will + /// be consumed and no longer exist. + pub fn merge_coins( + self: Arc, + primary_coin: &PTBArgument, + consumed_coins: Vec>, + ) -> Arc { + self.write(|builder| { + builder.merge_coins(primary_coin, consumed_coins); + }); + self + } + + /// Make a move vector from a list of elements. The elements must all be of + /// the type indicated by `type_tag`. + pub fn make_move_vec( + self: Arc, + elements: Vec>, + type_tag: &TypeTag, + name: String, + ) -> Arc { + use iota_sdk::transaction_builder::unresolved::{Command, MakeMoveVector}; + self.write(|builder| { + let cmd = Command::MakeMoveVector(MakeMoveVector { + type_: Some(type_tag.0.clone()), + elements: elements + .iter() + .map(|e| builder.apply_argument(e.as_ref())) + .collect(), + }); + builder.named_command(cmd, name); + }); + self + } + + /// Publish a list of modules with the given dependencies. The result + /// assigned to `upgrade_cap_name` is the `0x2::package::UpgradeCap` + /// Move type. Note that the upgrade capability needs to be handled + /// after this call: + /// - transfer it to the transaction sender or another address + /// - burn it + /// - wrap it for access control + /// - discard the it to make a package immutable + /// + /// The arguments required for this command are: + /// - `modules`: is the modules' bytecode to be published + /// - `dependencies`: is the list of IDs of the transitive dependencies of + /// the package + pub fn publish( + self: Arc, + package_data: &MovePackageData, + upgrade_cap_name: String, + ) -> Arc { + self.write(|builder| { + builder + .publish(package_data.0.clone()) + .upgrade_cap(upgrade_cap_name); + }); + self + } + + /// Upgrade a Move package. + /// + /// - `modules`: is the modules' bytecode for the modules to be published + /// - `dependencies`: is the list of IDs of the transitive dependencies of + /// the package to be upgraded + /// - `package`: is the ID of the current package being upgraded + /// - `ticket`: is the upgrade ticket + /// + /// To get the ticket, you have to call the + /// `0x2::package::authorize_upgrade` function, and pass the package + /// ID, the upgrade policy, and package digest. + #[uniffi::method(default(name = None))] + pub fn upgrade( + self: Arc, + package_id: &ObjectId, + package_data: &MovePackageData, + upgrade_ticket: &PTBArgument, + name: Option, + ) -> Arc { + self.write(|builder| { + builder + .upgrade(**package_id, package_data.0.clone(), upgrade_ticket) + .name(name); + }); + self + } + + /// Add stake to a validator's staking pool. + /// + /// This is a high-level function which will split the provided stake amount + /// from the gas coin and then stake using the resulting coin. + pub fn stake(self: Arc, stake: &PTBArgument, validator_address: &Address) -> Arc { + self.write(|builder| { + builder.stake(stake, **validator_address); + }); + self + } + + /// Withdraw stake from a validator's staking pool. + pub fn unstake(self: Arc, staked_iota: &PTBArgument) -> Arc { + self.write(|builder| { + builder.unstake(staked_iota); + }); + self + } + + /// Convert this builder into a transaction. + pub fn finish(&self) -> Result { + Ok(Transaction(self.read(|builder| builder.clone().finish())?)) + } + + /// Execute the transaction using the gas station and return the JSON + /// transaction effects. This will fail unless data is set with the + /// `gas_station_sponsor` function. + /// + /// NOTE: These effects are not necessarily compatible with + /// `TransactionEffects` + pub async fn execute_with_gas_station( + &self, + keypair: &SimpleKeypair, + ) -> Result { + Ok(self + .read(|builder| builder.clone().execute_with_gas_station(&keypair.0)) + .await?) + } +} diff --git a/crates/iota-sdk-ffi/src/transaction_builder/client_builder.rs b/crates/iota-sdk-ffi/src/transaction_builder/client_builder.rs new file mode 100644 index 000000000..52d964bf0 --- /dev/null +++ b/crates/iota-sdk-ffi/src/transaction_builder/client_builder.rs @@ -0,0 +1,373 @@ +// Copyright (c) 2025 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::{ + collections::HashMap, + sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard}, + time::Duration, +}; + +use iota_sdk::{graphql_client::WaitForTx, types::Input}; + +use crate::{ + crypto::simple::SimpleKeypair, + error::Result, + graphql::GraphQLClient, + transaction_builder::ptb_arg::{MoveArg, PTBArgument}, + types::{ + address::Address, + graphql::DryRunResult, + move_package::MovePackageData, + object::ObjectId, + struct_tag::Identifier, + transaction::{Argument, Transaction, TransactionEffects}, + type_tag::TypeTag, + }, +}; + +/// A builder for creating transactions which uses a GraphQL client to +/// automatically resolve inputs. Use `finish` to finalize the transaction data. +#[derive(derive_more::From, uniffi::Object)] +pub struct ClientTransactionBuilder( + pub RwLock>, +); + +impl ClientTransactionBuilder { + fn read(&self, f: F) -> T + where + F: FnOnce( + &iota_sdk::transaction_builder::TransactionBuilder, + ) -> T, + { + let lock = self.0.read().expect("error reading from builder"); + f(&lock) + } + + fn write(&self, f: F) -> T + where + F: FnOnce( + &mut iota_sdk::transaction_builder::TransactionBuilder, + ) -> T, + { + let mut lock = self.0.write().expect("error writing to builder"); + f(&mut lock) + } +} + +#[uniffi::export(async_runtime = "tokio")] +impl ClientTransactionBuilder { + /// Add gas coins that will be consumed. Optional. + pub fn gas(self: Arc, object_ids: Vec>) -> Arc { + self.write(|builder| { + builder.gas(object_ids.into_iter().map(|id| **id)); + }); + self + } + + /// Set the gas budget for the transaction. + pub fn gas_budget(self: Arc, budget: u64) -> Arc { + self.write(|builder| { + builder.gas_budget(budget); + }); + self + } + + /// Set the gas price for the transaction. + pub fn gas_price(self: Arc, price: u64) -> Arc { + self.write(|builder| { + builder.gas_price(price); + }); + self + } + + /// Set the sponsor of the transaction. + pub fn sponsor(self: Arc, sponsor: &Address) -> Arc { + self.write(|builder| { + builder.sponsor(**sponsor); + }); + self + } + + /// Set the gas station sponsor. + #[uniffi::method(default(duration = None, headers = None))] + pub fn gas_station_sponsor( + self: Arc, + url: String, + duration: Option, + headers: Option>>, + ) -> Arc { + self.write(|builder| { + let b = builder.gas_station_sponsor(url.parse().expect("invalid URL")); + if let Some(duration) = duration { + b.gas_reservation_duration(duration); + } + if let Some(headers) = headers { + for (name, values) in headers { + for value in values { + b.add_gas_station_header( + name.parse().expect("invalid header name"), + value.parse().expect("invalid header value"), + ); + } + } + } + }); + self + } + + /// Set the expiration of the transaction to be a specific epoch. + pub fn expiration(self: Arc, epoch: u64) -> Arc { + self.write(|builder| { + builder.expiration(epoch); + }); + self + } + + // Commands + + /// Call a Move function with the given arguments. + #[uniffi::method(default(type_args = [], arguments = [], names = []))] + pub fn move_call( + self: Arc, + package: &Address, + module: &Identifier, + function: &Identifier, + arguments: Vec>, + type_args: Vec>, + names: Vec, + ) -> Arc { + self.write(|builder| { + builder + .move_call(**package, &module.as_str(), &function.as_str()) + .arguments(arguments) + .type_tags(type_args.into_iter().map(|v| v.0.clone())) + .name(names); + }); + self + } + + /// Send IOTA to a recipient address. + /// + /// The `amount` parameter specifies the quantity in NANOS, where 1 IOTA + /// equals 1_000_000_000 NANOS. That amount is split from the gas coin and + /// sent. + pub fn send_iota(self: Arc, recipient: &Address, amount: &PTBArgument) -> Arc { + self.write(|builder| { + builder.send_iota(**recipient, amount); + }); + self + } + + /// Transfer some coins to a recipient address. If multiple coins are + /// provided then they will be merged. + /// + /// The `amount` parameter specifies the quantity in NANOS, where 1 IOTA + /// equals 1_000_000_000 NANOS. + /// If `amount` is provided, that amount is split from the provided coins + /// and sent. + /// If `amount` is `None`, the entire coins are transferred. + /// + /// All provided coins must have the same coin type. Mixing coins of + /// different types will result in an error. + /// + /// If you intend to transfer all provided coins to another address in a + /// single transaction, consider using + /// `TransactionBuilder::transfer_objects()` instead. + #[uniffi::method(default(amount = None))] + pub fn send_coins( + self: Arc, + coins: Vec>, + recipient: &Address, + amount: Option>, + ) -> Arc { + self.write(|builder| { + builder.send_coins::<_, &PTBArgument>(coins, **recipient, amount.as_deref()); + }); + self + } + + /// Transfer a list of objects to the given address, without producing any + /// result. + pub fn transfer_objects( + self: Arc, + recipient: &Address, + objects: Vec>, + ) -> Arc { + self.write(|builder| { + builder.transfer_objects(**recipient, objects); + }); + self + } + + /// Split a coin into many. + #[uniffi::method(default(names = []))] + pub fn split_coins( + self: Arc, + coin: &PTBArgument, + amounts: Vec>, + names: Vec, + ) -> Arc { + self.write(|builder| { + builder.split_coins(coin, amounts).name(names); + }); + self + } + + /// Merge multiple coins into one. + /// + /// This method combines the balances of multiple coins of the same coin + /// type into a single coin. The `primary_coin` will receive the balances + /// from all `consumed_coins`. After merging, the `consumed_coins` will + /// be consumed and no longer exist. + pub fn merge_coins( + self: Arc, + primary_coin: &PTBArgument, + consumed_coins: Vec>, + ) -> Arc { + self.write(|builder| { + builder.merge_coins(primary_coin, consumed_coins); + }); + self + } + + /// Make a move vector from a list of elements. The elements must all be of + /// the type indicated by `type_tag`. + pub fn make_move_vec( + self: Arc, + elements: Vec>, + type_tag: &TypeTag, + name: String, + ) -> Arc { + use iota_sdk::transaction_builder::unresolved::{Command, MakeMoveVector}; + self.write(|builder| { + let cmd = Command::MakeMoveVector(MakeMoveVector { + type_: Some(type_tag.0.clone()), + elements: elements + .iter() + .map(|e| builder.apply_argument(e.as_ref())) + .collect(), + }); + builder.named_command(cmd, name); + }); + self + } + + /// Publish a list of modules with the given dependencies. The result + /// assigned to `upgrade_cap_name` is the `0x2::package::UpgradeCap` + /// Move type. Note that the upgrade capability needs to be handled + /// after this call: + /// - transfer it to the transaction sender or another address + /// - burn it + /// - wrap it for access control + /// - discard the it to make a package immutable + /// + /// The arguments required for this command are: + /// - `modules`: is the modules' bytecode to be published + /// - `dependencies`: is the list of IDs of the transitive dependencies of + /// the package + pub fn publish( + self: Arc, + package_data: &MovePackageData, + upgrade_cap_name: String, + ) -> Arc { + self.write(|builder| { + builder + .publish(package_data.0.clone()) + .upgrade_cap(upgrade_cap_name); + }); + self + } + + /// Upgrade a Move package. + /// + /// - `modules`: is the modules' bytecode for the modules to be published + /// - `dependencies`: is the list of IDs of the transitive dependencies of + /// the package to be upgraded + /// - `package`: is the ID of the current package being upgraded + /// - `ticket`: is the upgrade ticket + /// + /// To get the ticket, you have to call the + /// `0x2::package::authorize_upgrade` function, and pass the package + /// ID, the upgrade policy, and package digest. + #[uniffi::method(default(name = None))] + pub fn upgrade( + self: Arc, + package_id: &ObjectId, + package_data: &MovePackageData, + upgrade_ticket: &PTBArgument, + name: Option, + ) -> Arc { + self.write(|builder| { + builder + .upgrade(**package_id, package_data.0.clone(), upgrade_ticket) + .name(name); + }); + self + } + + /// Add stake to a validator's staking pool. + /// + /// This is a high-level function which will split the provided stake amount + /// from the gas coin and then stake using the resulting coin. + pub fn stake(self: Arc, stake: &PTBArgument, validator_address: &Address) -> Arc { + self.write(|builder| { + builder.stake(stake, **validator_address); + }); + self + } + + /// Withdraw stake from a validator's staking pool. + pub fn unstake(self: Arc, staked_iota: &PTBArgument) -> Arc { + self.write(|builder| { + builder.unstake(staked_iota); + }); + self + } + + /// Convert this builder into a transaction. + pub async fn finish(&self) -> Result { + Ok(Transaction( + self.read(|builder| builder.clone().finish()).await?, + )) + } + + /// Dry run the transaction. + #[uniffi::method(default(skip_checks = false))] + pub async fn dry_run(&self, skip_checks: bool) -> Result { + Ok(self + .read(|builder| builder.clone().dry_run(skip_checks)) + .await? + .into()) + } + + /// Execute the transaction and optionally wait for finalization. + #[uniffi::method(default(wait_for = None))] + pub async fn execute( + &self, + keypair: &SimpleKeypair, + wait_for: Option, + ) -> Result { + Ok(self + .read(|builder| builder.clone().execute(&keypair.0, wait_for)) + .await? + .into()) + } + + /// Execute the transaction and optionally wait for finalization. + #[uniffi::method(default(wait_for = None))] + pub async fn execute_with_sponsor( + &self, + keypair: &SimpleKeypair, + sponsor_keypair: &SimpleKeypair, + wait_for: Option, + ) -> Result { + Ok(self + .read(|builder| { + builder + .clone() + .execute_with_sponsor(&keypair.0, &sponsor_keypair.0, wait_for) + }) + .await? + .into()) + } +} diff --git a/crates/iota-sdk-ffi/src/transaction_builder/mod.rs b/crates/iota-sdk-ffi/src/transaction_builder/mod.rs index 358b8e61a..bfa942c54 100644 --- a/crates/iota-sdk-ffi/src/transaction_builder/mod.rs +++ b/crates/iota-sdk-ffi/src/transaction_builder/mod.rs @@ -1,385 +1,6 @@ // Copyright (c) 2025 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use std::{ - collections::HashMap, - sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard}, - time::Duration, -}; - -use iota_sdk::{graphql_client::WaitForTx, types::Input}; - -use crate::{ - crypto::simple::SimpleKeypair, - error::Result, - graphql::GraphQLClient, - transaction_builder::ptb_arg::{MoveArg, PTBArgument}, - types::{ - address::Address, - graphql::DryRunResult, - move_package::MovePackageData, - object::ObjectId, - struct_tag::Identifier, - transaction::{Argument, Transaction, TransactionEffects}, - type_tag::TypeTag, - }, -}; - +mod builder; +mod client_builder; pub mod ptb_arg; - -/// A builder for creating transactions. Use `finish` to finalize the -/// transaction data. -#[derive(derive_more::From, uniffi::Object)] -pub struct TransactionBuilder( - RwLock>, -); - -impl TransactionBuilder { - fn read(&self, f: F) -> T - where - F: FnOnce( - &iota_sdk::transaction_builder::TransactionBuilder, - ) -> T, - { - let lock = self.0.read().expect("error reading from builder"); - f(&lock) - } - - fn write(&self, f: F) -> T - where - F: FnOnce( - &mut iota_sdk::transaction_builder::TransactionBuilder, - ) -> T, - { - let mut lock = self.0.write().expect("error writing to builder"); - f(&mut lock) - } -} - -#[uniffi::export(async_runtime = "tokio")] -impl TransactionBuilder { - /// Create a new transaction builder and initialize its elements to default. - #[uniffi::constructor(name = "init")] - pub async fn new(sender: &Address, client: &GraphQLClient) -> Self { - Self( - iota_sdk::transaction_builder::TransactionBuilder::new(**sender) - .with_client(client.inner().read().await.clone()) - .into(), - ) - } - - /// Add gas coins that will be consumed. Optional. - pub fn gas(self: Arc, object_ids: Vec>) -> Arc { - self.write(|builder| { - builder.gas(object_ids.iter().map(|id| ***id)); - }); - self - } - - /// Set the gas budget for the transaction. - pub fn gas_budget(self: Arc, budget: u64) -> Arc { - self.write(|builder| { - builder.gas_budget(budget); - }); - self - } - - /// Set the gas price for the transaction. - pub fn gas_price(self: Arc, price: u64) -> Arc { - self.write(|builder| { - builder.gas_price(price); - }); - self - } - - /// Set the sponsor of the transaction. - pub fn sponsor(self: Arc, sponsor: &Address) -> Arc { - self.write(|builder| { - builder.sponsor(**sponsor); - }); - self - } - - /// Set the gas station sponsor. - #[uniffi::method(default(duration = None, headers = None))] - pub fn gas_station_sponsor( - self: Arc, - url: String, - duration: Option, - headers: Option>>, - ) -> Arc { - self.write(|builder| { - let b = builder.gas_station_sponsor(url.parse().expect("invalid URL")); - if let Some(duration) = duration { - b.gas_reservation_duration(duration); - } - if let Some(headers) = headers { - for (name, values) in headers { - for value in values { - b.add_gas_station_header( - name.parse().expect("invalid header name"), - value.parse().expect("invalid header value"), - ); - } - } - } - }); - self - } - - /// Set the expiration of the transaction to be a specific epoch. - pub fn expiration(self: Arc, epoch: u64) -> Arc { - self.write(|builder| { - builder.expiration(epoch); - }); - self - } - - // Commands - - /// Call a Move function with the given arguments. - #[uniffi::method(default(type_args = [], arguments = [], names = []))] - pub fn move_call( - self: Arc, - package: &Address, - module: &Identifier, - function: &Identifier, - arguments: Vec>, - type_args: Vec>, - names: Vec, - ) -> Arc { - self.write(|builder| { - builder - .move_call(**package, &module.as_str(), &function.as_str()) - .arguments(arguments) - .type_tags(type_args.into_iter().map(|v| v.0.clone())) - .name(names); - }); - self - } - - /// Send IOTA to a recipient address. - /// - /// The `amount` parameter specifies the quantity in NANOS, where 1 IOTA - /// equals 1_000_000_000 NANOS. That amount is split from the gas coin and - /// sent. - pub fn send_iota(self: Arc, recipient: &Address, amount: &PTBArgument) -> Arc { - self.write(|builder| { - builder.send_iota(**recipient, amount); - }); - self - } - - /// Transfer some coins to a recipient address. If multiple coins are - /// provided then they will be merged. - /// - /// The `amount` parameter specifies the quantity in NANOS, where 1 IOTA - /// equals 1_000_000_000 NANOS. - /// If `amount` is provided, that amount is split from the provided coins - /// and sent. - /// If `amount` is `None`, the entire coins are transferred. - /// - /// All provided coins must have the same coin type. Mixing coins of - /// different types will result in an error. - /// - /// If you intend to transfer all provided coins to another address in a - /// single transaction, consider using - /// `TransactionBuilder::transfer_objects()` instead. - #[uniffi::method(default(amount = None))] - pub fn send_coins( - self: Arc, - coins: Vec>, - recipient: &Address, - amount: Option>, - ) -> Arc { - self.write(|builder| { - builder.send_coins::<_, &PTBArgument>(coins, **recipient, amount.as_deref()); - }); - self - } - - /// Transfer a list of objects to the given address, without producing any - /// result. - pub fn transfer_objects( - self: Arc, - recipient: &Address, - objects: Vec>, - ) -> Arc { - self.write(|builder| { - builder.transfer_objects(**recipient, objects); - }); - self - } - - /// Split a coin into many. - #[uniffi::method(default(names = []))] - pub fn split_coins( - self: Arc, - coin: &PTBArgument, - amounts: Vec>, - names: Vec, - ) -> Arc { - self.write(|builder| { - builder.split_coins(coin, amounts).name(names); - }); - self - } - - /// Merge multiple coins into one. - /// - /// This method combines the balances of multiple coins of the same coin - /// type into a single coin. The `primary_coin` will receive the balances - /// from all `consumed_coins`. After merging, the `consumed_coins` will - /// be consumed and no longer exist. - pub fn merge_coins( - self: Arc, - primary_coin: &PTBArgument, - consumed_coins: Vec>, - ) -> Arc { - self.write(|builder| { - builder.merge_coins(primary_coin, consumed_coins); - }); - self - } - - /// Make a move vector from a list of elements. The elements must all be of - /// the type indicated by `type_tag`. - pub fn make_move_vec( - self: Arc, - elements: Vec>, - type_tag: &TypeTag, - name: String, - ) -> Arc { - use iota_sdk::transaction_builder::unresolved::{Command, MakeMoveVector}; - self.write(|builder| { - let cmd = Command::MakeMoveVector(MakeMoveVector { - type_: Some(type_tag.0.clone()), - elements: elements - .iter() - .map(|e| builder.apply_argument(e.as_ref())) - .collect(), - }); - builder.named_command(cmd, name); - }); - self - } - - /// Publish a list of modules with the given dependencies. The result - /// assigned to `upgrade_cap_name` is the `0x2::package::UpgradeCap` - /// Move type. Note that the upgrade capability needs to be handled - /// after this call: - /// - transfer it to the transaction sender or another address - /// - burn it - /// - wrap it for access control - /// - discard the it to make a package immutable - /// - /// The arguments required for this command are: - /// - `modules`: is the modules' bytecode to be published - /// - `dependencies`: is the list of IDs of the transitive dependencies of - /// the package - pub fn publish( - self: Arc, - package_data: &MovePackageData, - upgrade_cap_name: String, - ) -> Arc { - self.write(|builder| { - builder - .publish(package_data.0.clone()) - .upgrade_cap(upgrade_cap_name); - }); - self - } - - /// Upgrade a Move package. - /// - /// - `modules`: is the modules' bytecode for the modules to be published - /// - `dependencies`: is the list of IDs of the transitive dependencies of - /// the package to be upgraded - /// - `package`: is the ID of the current package being upgraded - /// - `ticket`: is the upgrade ticket - /// - /// To get the ticket, you have to call the - /// `0x2::package::authorize_upgrade` function, and pass the package - /// ID, the upgrade policy, and package digest. - #[uniffi::method(default(name = None))] - pub fn upgrade( - self: Arc, - package_id: &ObjectId, - package_data: &MovePackageData, - upgrade_ticket: &PTBArgument, - name: Option, - ) -> Arc { - self.write(|builder| { - builder - .upgrade(**package_id, package_data.0.clone(), upgrade_ticket) - .name(name); - }); - self - } - - /// Add stake to a validator's staking pool. - /// - /// This is a high-level function which will split the provided stake amount - /// from the gas coin and then stake using the resulting coin. - pub fn stake(self: Arc, stake: &PTBArgument, validator_address: &Address) -> Arc { - self.write(|builder| { - builder.stake(stake, **validator_address); - }); - self - } - - /// Withdraw stake from a validator's staking pool. - pub fn unstake(self: Arc, staked_iota: &PTBArgument) -> Arc { - self.write(|builder| { - builder.unstake(staked_iota); - }); - self - } - - /// Convert this builder into a transaction. - pub async fn finish(&self) -> Result { - Ok(Transaction( - self.read(|builder| builder.clone().finish()).await?, - )) - } - - /// Dry run the transaction. - #[uniffi::method(default(skip_checks = false))] - pub async fn dry_run(&self, skip_checks: bool) -> Result { - Ok(self - .read(|builder| builder.clone().dry_run(skip_checks)) - .await? - .into()) - } - - /// Execute the transaction and optionally wait for finalization. - #[uniffi::method(default(wait_for = None))] - pub async fn execute( - &self, - keypair: &SimpleKeypair, - wait_for: Option, - ) -> Result { - Ok(self - .read(|builder| builder.clone().execute(&keypair.0, wait_for)) - .await? - .into()) - } - - /// Execute the transaction and optionally wait for finalization. - #[uniffi::method(default(wait_for = None))] - pub async fn execute_with_sponsor( - &self, - keypair: &SimpleKeypair, - sponsor_keypair: &SimpleKeypair, - wait_for: Option, - ) -> Result { - Ok(self - .read(|builder| { - builder - .clone() - .execute_with_sponsor(&keypair.0, &sponsor_keypair.0, wait_for) - }) - .await? - .into()) - } -} diff --git a/crates/iota-sdk-ffi/src/transaction_builder/ptb_arg.rs b/crates/iota-sdk-ffi/src/transaction_builder/ptb_arg.rs index 1146fd421..d319c73f2 100644 --- a/crates/iota-sdk-ffi/src/transaction_builder/ptb_arg.rs +++ b/crates/iota-sdk-ffi/src/transaction_builder/ptb_arg.rs @@ -10,7 +10,11 @@ use primitive_types::U256; use crate::{ error::Result, - types::{address::Address, digest::Digest, object::ObjectId}, + types::{ + address::Address, + digest::Digest, + object::{ObjectId, ObjectReference}, + }, }; #[derive(Clone, uniffi::Object)] @@ -204,6 +208,7 @@ impl iota_sdk::transaction_builder::types::MoveArg for &MoveArg { #[derive(uniffi::Object)] pub enum PTBArgument { ObjectId(iota_sdk::types::ObjectId), + ObjectRef(iota_sdk::types::ObjectReference), Move(MoveArg), Res(Res), Shared(Shared), @@ -224,6 +229,11 @@ impl PTBArgument { Self::ObjectId(**id) } + #[uniffi::constructor] + pub fn object_ref(id: ObjectReference) -> Self { + Self::ObjectRef(id.into()) + } + #[uniffi::constructor] pub fn move_arg(arg: &MoveArg) -> Self { Self::Move(arg.clone()) @@ -403,6 +413,7 @@ impl iota_sdk::transaction_builder::PTBArgument for &PTBArgument { ) -> iota_sdk::transaction_builder::unresolved::Argument { match self { PTBArgument::ObjectId(object_id) => object_id.arg(ptb), + PTBArgument::ObjectRef(obj_ref) => obj_ref.clone().arg(ptb), PTBArgument::Move(arg) => arg.arg(ptb), PTBArgument::Res(res) => res.arg(ptb), PTBArgument::Shared(shared) => shared.arg(ptb), diff --git a/crates/iota-sdk-ffi/src/types/object.rs b/crates/iota-sdk-ffi/src/types/object.rs index 63ac2604b..27acb4d68 100644 --- a/crates/iota-sdk-ffi/src/types/object.rs +++ b/crates/iota-sdk-ffi/src/types/object.rs @@ -167,6 +167,11 @@ impl Object { self.0.object_id().into() } + /// Return this object's reference + pub fn object_ref(&self) -> ObjectReference { + self.0.object_ref().into() + } + /// Return this object's version pub fn version(&self) -> Version { self.0.version() diff --git a/crates/iota-sdk-transaction-builder/src/builder/gas_station.rs b/crates/iota-sdk-transaction-builder/src/builder/gas_station.rs index c52bb927d..f4874e643 100644 --- a/crates/iota-sdk-transaction-builder/src/builder/gas_station.rs +++ b/crates/iota-sdk-transaction-builder/src/builder/gas_station.rs @@ -351,10 +351,40 @@ impl GasStationData { } pub(crate) async fn execute_txn( - mut self, + self, txn: &mut Transaction, keypair: &SimpleKeypair, ) -> Result { + let url = self + .url + .join(GasStationRequestKind::ExecuteTx.as_path()) + .map_err(Error::InvalidUrl)?; + let effects = self.execute_txn_inner(&url, txn, keypair).await?; + + Digest::deserialize(&effects["transactionDigest"]).map_err(|e| Error::GasStationResponse { + message: Some(e.to_string()), + gas_station_url: url, + }) + } + + pub(crate) async fn execute_txn_json( + self, + txn: &mut Transaction, + keypair: &SimpleKeypair, + ) -> Result { + let url = self + .url + .join(GasStationRequestKind::ExecuteTx.as_path()) + .map_err(Error::InvalidUrl)?; + self.execute_txn_inner(&url, txn, keypair).await + } + + async fn execute_txn_inner( + mut self, + url: &Url, + txn: &mut Transaction, + keypair: &SimpleKeypair, + ) -> Result { let client = reqwest::Client::new(); let reservation_id = match txn { Transaction::V1(ref mut inner_txn) => { @@ -380,11 +410,6 @@ impl GasStationData { } }; - let url = self - .url - .join(GasStationRequestKind::ExecuteTx.as_path()) - .map_err(Error::InvalidUrl)?; - let tx_bytes = base64ct::Base64::encode_string(&bcs::to_bytes(&txn).map_err(Error::Bcs)?); let user_sig = keypair @@ -429,10 +454,7 @@ impl GasStationData { }); }; - Digest::deserialize(&effects["transactionDigest"]).map_err(|e| Error::GasStationResponse { - message: Some(e.to_string()), - gas_station_url: url.clone(), - }) + Ok(effects) } } diff --git a/crates/iota-sdk-transaction-builder/src/builder/mod.rs b/crates/iota-sdk-transaction-builder/src/builder/mod.rs index 46b2a425a..179febdc3 100644 --- a/crates/iota-sdk-transaction-builder/src/builder/mod.rs +++ b/crates/iota-sdk-transaction-builder/src/builder/mod.rs @@ -869,6 +869,26 @@ impl TransactionBuilder<(), L> { } .into()) } + + /// Execute the transaction using the gas station and return the JSON + /// transaction effects. This will fail unless data is set with + /// [`Self::gas_station_sponsor`]. + /// + /// NOTE: These effects are not necessarily compatible with + /// [`TransactionEffects`] + pub async fn execute_with_gas_station( + mut self, + keypair: &SimpleKeypair, + ) -> Result { + let gas_station_data = self.data.gas_station_data.take(); + + Ok(if let Some(gas_station_data) = gas_station_data { + let mut txn = self.finish()?; + gas_station_data.execute_txn_json(&mut txn, keypair).await? + } else { + return Err(Error::MissingGasStationData); + }) + } } impl TransactionBuilder { diff --git a/crates/iota-sdk-transaction-builder/src/error.rs b/crates/iota-sdk-transaction-builder/src/error.rs index 66e9460df..6fc42d70e 100644 --- a/crates/iota-sdk-transaction-builder/src/error.rs +++ b/crates/iota-sdk-transaction-builder/src/error.rs @@ -41,6 +41,8 @@ pub enum Error { MissingInitialSharedVersion(ObjectId), #[error("Missing pure value")] MissingPureValue, + #[error("Missing gas station data")] + MissingGasStationData, #[error("Unknown shared object mutability for object {0}")] SharedObjectMutability(ObjectId), #[error("Unsupported literal")]