diff --git a/bindings/go/examples/dev_inspect/main.go b/bindings/go/examples/dev_inspect/main.go index 630653e56..deb34d7e4 100644 --- a/bindings/go/examples/dev_inspect/main.go +++ b/bindings/go/examples/dev_inspect/main.go @@ -13,13 +13,13 @@ import ( func main() { client := sdk.GraphQlClientNewDevnet() - sender, _ := sdk.AddressFromHex("0x0") + sender := sdk.AddressZero() iotaNamesPackageAddress, _ := sdk.AddressFromHex("0xb9d617f24c84826bf660a2f4031951678cc80c264aebc4413459fb2a95ada9ba") iotaNamesObjectId, _ := sdk.ObjectIdFromHex("0x07c59b37bd7d036bf78fa30561a2ab9f7a970837487656ec29466e817f879342") - stdlibAddress, _ := sdk.AddressFromHex("0x1") + stdlibAddress := sdk.AddressStdLib() name := "name.iota" fmt.Printf("Looking up name: %s\n", name) diff --git a/bindings/go/examples/gas_sponsor/main.go b/bindings/go/examples/gas_sponsor/main.go index 3d0df37d2..5c883b9d8 100644 --- a/bindings/go/examples/gas_sponsor/main.go +++ b/bindings/go/examples/gas_sponsor/main.go @@ -17,7 +17,7 @@ func main() { builder := sdk.TransactionBuilderInit(sender, client) - packageAddr, _ := sdk.AddressFromHex("0x1") + packageAddr := sdk.AddressStdLib() moduleName, _ := sdk.NewIdentifier("u8") functionName, _ := sdk.NewIdentifier("max") diff --git a/bindings/go/examples/gas_station/main.go b/bindings/go/examples/gas_station/main.go index 33017bd73..e0d51a609 100644 --- a/bindings/go/examples/gas_station/main.go +++ b/bindings/go/examples/gas_station/main.go @@ -19,7 +19,7 @@ func main() { builder := sdk.TransactionBuilderInit(sender, client) - package_id, _ := sdk.AddressFromHex("0x1") + package_id := sdk.AddressStdLib() module_name, _ := sdk.NewIdentifier("u64") function_name, _ := sdk.NewIdentifier("sqrt") diff --git a/bindings/go/examples/generic_move_function/main.go b/bindings/go/examples/generic_move_function/main.go index 699e51cc9..cd1729ff2 100644 --- a/bindings/go/examples/generic_move_function/main.go +++ b/bindings/go/examples/generic_move_function/main.go @@ -20,7 +20,7 @@ func main() { addr1, _ := sdk.AddressFromHex("0xde49ea53fbadee67d3e35a097cdbea210b659676fc680a0b0c5f11d0763d375e") addr2, _ := sdk.AddressFromHex("0xe512234aa4ef6184c52663f09612b68f040dd0c45de037d96190a071ca5525b3") - package_id, _ := sdk.AddressFromHex("0x2") + package_id := sdk.AddressFramework() module_name, _ := sdk.NewIdentifier("vec_map") function_name, _ := sdk.NewIdentifier("from_keys_values") diff --git a/bindings/go/examples/owned_objects/main.go b/bindings/go/examples/owned_objects/main.go index b728e0d4f..24791677c 100644 --- a/bindings/go/examples/owned_objects/main.go +++ b/bindings/go/examples/owned_objects/main.go @@ -13,10 +13,7 @@ import ( func main() { client := sdk.GraphQlClientNewDevnet() - address, err := sdk.AddressFromHex("0x0") - if err != nil { - log.Fatalf("Failed to parse address: %v", err) - } + address := sdk.AddressZero() objectFilter := sdk.ObjectFilter{ Owner: &address, diff --git a/bindings/go/examples/stake/main.go b/bindings/go/examples/stake/main.go index a659d31c0..5be24bc63 100644 --- a/bindings/go/examples/stake/main.go +++ b/bindings/go/examples/stake/main.go @@ -34,9 +34,9 @@ func main() { coinObjId, _ := sdk.ObjectIdFromHex("0xd04077fe3b6fad13b3d4ed0d535b7ca92afcac8f0f2a0e0925fb9f4f0b30c699") - iotaSystemAddress, _ := sdk.AddressFromHex("0x3") + iotaSystemAddress := sdk.AddressSystem() - iotaSystemId, _ := sdk.ObjectIdFromHex("0x5") + iotaSystemId := sdk.ObjectIdSystem() iotaSystemModule, _ := sdk.NewIdentifier("iota_system") diff --git a/bindings/go/examples/unstake/main.go b/bindings/go/examples/unstake/main.go index 0119d7413..007a45141 100644 --- a/bindings/go/examples/unstake/main.go +++ b/bindings/go/examples/unstake/main.go @@ -22,9 +22,9 @@ func main() { } stakedIota := stakedIotas.Data[0] - iotaSystemAddress, _ := sdk.AddressFromHex("0x3") + iotaSystemAddress := sdk.AddressSystem() - iotaSystemId, _ := sdk.ObjectIdFromHex("0x5") + iotaSystemId := sdk.ObjectIdSystem() iotaSystemModule, _ := sdk.NewIdentifier("iota_system") diff --git a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go index dd9cf44fc..4ae3d2f71 100644 --- a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go +++ b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go @@ -1352,7 +1352,7 @@ func uniffiCheckChecksums() { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_dynamic_field() }) - if checksum != 29988 { + if checksum != 17199 { // If this happens try cleaning and rebuilding your project panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_graphqlclient_dynamic_field: UniFFI API checksum mismatch") } @@ -4508,6 +4508,15 @@ func uniffiCheckChecksums() { } } { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_constructor_address_framework() + }) + if checksum != 52951 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_address_framework: UniFFI API checksum mismatch") + } + } + { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_constructor_address_from_bytes() }) @@ -4535,6 +4544,33 @@ func uniffiCheckChecksums() { } } { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_constructor_address_std_lib() + }) + if checksum != 35825 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_address_std_lib: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_constructor_address_system() + }) + if checksum != 4297 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_address_system: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_constructor_address_zero() + }) + if checksum != 46553 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_address_zero: UniFFI API checksum mismatch") + } + } + { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_constructor_argument_new_gas() }) @@ -5615,6 +5651,15 @@ func uniffiCheckChecksums() { } } { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_constructor_objectid_clock() + }) + if checksum != 14732 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_objectid_clock: UniFFI API checksum mismatch") + } + } + { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_constructor_objectid_derive_id() }) @@ -5642,6 +5687,24 @@ func uniffiCheckChecksums() { } } { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_constructor_objectid_system() + }) + if checksum != 9600 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_objectid_system: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_constructor_objectid_zero() + }) + if checksum != 40526 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_objectid_zero: UniFFI API checksum mismatch") + } + } + { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_constructor_objecttype_new_package() }) @@ -7363,6 +7426,12 @@ type Address struct { } +func AddressFramework() *Address { + return FfiConverterAddressINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_address_framework(_uniffiStatus) + })) +} + func AddressFromBytes(bytes []byte) (*Address, error) { _uniffiRV, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { return C.uniffi_iota_sdk_ffi_fn_constructor_address_from_bytes(FfiConverterBytesINSTANCE.Lower(bytes),_uniffiStatus) @@ -7393,6 +7462,24 @@ func AddressGenerate() *Address { })) } +func AddressStdLib() *Address { + return FfiConverterAddressINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_address_std_lib(_uniffiStatus) + })) +} + +func AddressSystem() *Address { + return FfiConverterAddressINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_address_system(_uniffiStatus) + })) +} + +func AddressZero() *Address { + return FfiConverterAddressINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_address_zero(_uniffiStatus) + })) +} + func (_self *Address) ToBytes() []byte { @@ -11997,7 +12084,7 @@ type GraphQlClientInterface interface { // ```rust,ignore // // let client = iota_graphql_client::Client::new_devnet(); - // let address = Address::from_str("0x5").unwrap(); + // let address = ObjectId::SYSTEM.into(); // let df = client.dynamic_field_with_name(address, "u64", 2u64).await.unwrap(); // // # alternatively, pass in the bcs bytes @@ -12535,7 +12622,7 @@ func (_self *GraphQlClient) DryRunTxKind(txKind *TransactionKind, txMeta Transac // ```rust,ignore // // let client = iota_graphql_client::Client::new_devnet(); -// let address = Address::from_str("0x5").unwrap(); +// let address = ObjectId::SYSTEM.into(); // let df = client.dynamic_field_with_name(address, "u64", 2u64).await.unwrap(); // // # alternatively, pass in the bcs bytes @@ -17016,6 +17103,12 @@ type ObjectId struct { } +func ObjectIdClock() *ObjectId { + return FfiConverterObjectIdINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_objectid_clock(_uniffiStatus) + })) +} + // Create an ObjectId from a transaction digest and the number of objects // that have been created during a transactions. func ObjectIdDeriveId(digest *Digest, count uint64) *ObjectId { @@ -17048,6 +17141,18 @@ func ObjectIdFromHex(hex string) (*ObjectId, error) { } } +func ObjectIdSystem() *ObjectId { + return FfiConverterObjectIdINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_objectid_system(_uniffiStatus) + })) +} + +func ObjectIdZero() *ObjectId { + return FfiConverterObjectIdINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_objectid_zero(_uniffiStatus) + })) +} + // Derive an ObjectId for a Dynamic Child Object. diff --git a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h index deefe3769..3084d4de9 100644 --- a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h +++ b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h @@ -386,6 +386,12 @@ void* uniffi_iota_sdk_ffi_fn_clone_address(void* ptr, RustCallStatus *out_status #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_FREE_ADDRESS #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_FREE_ADDRESS void uniffi_iota_sdk_ffi_fn_free_address(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_ADDRESS_FRAMEWORK +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_ADDRESS_FRAMEWORK +void* uniffi_iota_sdk_ffi_fn_constructor_address_framework(RustCallStatus *out_status + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_ADDRESS_FROM_BYTES @@ -402,6 +408,24 @@ void* uniffi_iota_sdk_ffi_fn_constructor_address_from_hex(RustBuffer hex, RustCa #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_ADDRESS_GENERATE void* uniffi_iota_sdk_ffi_fn_constructor_address_generate(RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_ADDRESS_STD_LIB +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_ADDRESS_STD_LIB +void* uniffi_iota_sdk_ffi_fn_constructor_address_std_lib(RustCallStatus *out_status + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_ADDRESS_SYSTEM +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_ADDRESS_SYSTEM +void* uniffi_iota_sdk_ffi_fn_constructor_address_system(RustCallStatus *out_status + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_ADDRESS_ZERO +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_ADDRESS_ZERO +void* uniffi_iota_sdk_ffi_fn_constructor_address_zero(RustCallStatus *out_status + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_ADDRESS_TO_BYTES @@ -2735,6 +2759,12 @@ void* uniffi_iota_sdk_ffi_fn_clone_objectid(void* ptr, RustCallStatus *out_statu #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_FREE_OBJECTID #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_FREE_OBJECTID void uniffi_iota_sdk_ffi_fn_free_objectid(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_OBJECTID_CLOCK +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_OBJECTID_CLOCK +void* uniffi_iota_sdk_ffi_fn_constructor_objectid_clock(RustCallStatus *out_status + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_OBJECTID_DERIVE_ID @@ -2750,6 +2780,18 @@ void* uniffi_iota_sdk_ffi_fn_constructor_objectid_from_bytes(RustBuffer bytes, R #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_OBJECTID_FROM_HEX #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_OBJECTID_FROM_HEX void* uniffi_iota_sdk_ffi_fn_constructor_objectid_from_hex(RustBuffer hex, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_OBJECTID_SYSTEM +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_OBJECTID_SYSTEM +void* uniffi_iota_sdk_ffi_fn_constructor_objectid_system(RustCallStatus *out_status + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_OBJECTID_ZERO +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_OBJECTID_ZERO +void* uniffi_iota_sdk_ffi_fn_constructor_objectid_zero(RustCallStatus *out_status + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_OBJECTID_DERIVE_DYNAMIC_CHILD_ID @@ -8138,6 +8180,12 @@ uint16_t uniffi_iota_sdk_ffi_checksum_method_zkloginverifier_verify(void #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_ZKLOGINVERIFIER_WITH_JWKS uint16_t uniffi_iota_sdk_ffi_checksum_method_zkloginverifier_with_jwks(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_ADDRESS_FRAMEWORK +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_ADDRESS_FRAMEWORK +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_address_framework(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_ADDRESS_FROM_BYTES @@ -8156,6 +8204,24 @@ uint16_t uniffi_iota_sdk_ffi_checksum_constructor_address_from_hex(void #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_ADDRESS_GENERATE uint16_t uniffi_iota_sdk_ffi_checksum_constructor_address_generate(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_ADDRESS_STD_LIB +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_ADDRESS_STD_LIB +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_address_std_lib(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_ADDRESS_SYSTEM +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_ADDRESS_SYSTEM +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_address_system(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_ADDRESS_ZERO +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_ADDRESS_ZERO +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_address_zero(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_ARGUMENT_NEW_GAS @@ -8876,6 +8942,12 @@ uint16_t uniffi_iota_sdk_ffi_checksum_constructor_objectdata_new_move_package(vo #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_OBJECTDATA_NEW_MOVE_STRUCT uint16_t uniffi_iota_sdk_ffi_checksum_constructor_objectdata_new_move_struct(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_OBJECTID_CLOCK +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_OBJECTID_CLOCK +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_objectid_clock(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_OBJECTID_DERIVE_ID @@ -8894,6 +8966,18 @@ uint16_t uniffi_iota_sdk_ffi_checksum_constructor_objectid_from_bytes(void #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_OBJECTID_FROM_HEX uint16_t uniffi_iota_sdk_ffi_checksum_constructor_objectid_from_hex(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_OBJECTID_SYSTEM +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_OBJECTID_SYSTEM +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_objectid_system(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_OBJECTID_ZERO +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_OBJECTID_ZERO +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_objectid_zero(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_OBJECTTYPE_NEW_PACKAGE diff --git a/bindings/kotlin/examples/DevInspect.kt b/bindings/kotlin/examples/DevInspect.kt index 6f32ad925..ba22d0c75 100644 --- a/bindings/kotlin/examples/DevInspect.kt +++ b/bindings/kotlin/examples/DevInspect.kt @@ -16,7 +16,7 @@ fun main() = runBlocking { try { val client = GraphQlClient.newDevnet() - val sender = Address.fromHex("0x0") + val sender = Address.zero() val iotaNamesPackageAddress = Address.fromHex( @@ -26,7 +26,7 @@ fun main() = runBlocking { ObjectId.fromHex( "0x07c59b37bd7d036bf78fa30561a2ab9f7a970837487656ec29466e817f879342" ) - val stdlibAddress = Address.fromHex("0x1") + val stdlibAddress = Address.stdLib() val name = "name.iota" println("Looking up name: $name") diff --git a/bindings/kotlin/examples/GasSponsor.kt b/bindings/kotlin/examples/GasSponsor.kt index 34ace0fd8..12016d2da 100644 --- a/bindings/kotlin/examples/GasSponsor.kt +++ b/bindings/kotlin/examples/GasSponsor.kt @@ -5,50 +5,50 @@ import iota_sdk.* import kotlinx.coroutines.runBlocking fun main() = runBlocking { - try { - val client = GraphQlClient.newDevnet() - - val sender = - Address.fromHex( - "0x0000a4984bd495d4346fa208ddff4f5d5e5ad48c21dec631ddebc99809f16900" - ) - val sponsor = - Address.fromHex( - "0x611830d3641a68f94a690dcc25d1f4b0dac948325ac18f6dd32564371735f32c" - ) - - val builder = TransactionBuilder.init(sender, client) - - val packageAddr = Address.fromHex("0x1") - val moduleName = Identifier("u8") - val functionName = Identifier("max") - - builder.moveCall( - packageAddr, - moduleName, - functionName, - listOf(PtbArgument.u8(0u), PtbArgument.u8(1u)), + try { + val client = GraphQlClient.newDevnet() + + val sender = + Address.fromHex( + "0x0000a4984bd495d4346fa208ddff4f5d5e5ad48c21dec631ddebc99809f16900" + ) + val sponsor = + Address.fromHex( + "0x611830d3641a68f94a690dcc25d1f4b0dac948325ac18f6dd32564371735f32c" ) - val gasObjId = - ObjectId.fromHex( - "0x0b0270ee9d27da0db09651e5f7338dfa32c7ee6441ccefa1f6e305735bcfc7ab" - ) - builder.gas(gasObjId).sponsor(sponsor) + val builder = TransactionBuilder.init(sender, client) + + val packageAddr = Address.stdLib() + val moduleName = Identifier("u8") + val functionName = Identifier("max") - val txn = builder.finish() + builder.moveCall( + packageAddr, + moduleName, + functionName, + listOf(PtbArgument.u8(0u), PtbArgument.u8(1u)), + ) - println("Signing Digest: ${hexEncode(txn.signingDigest())}") - println("Txn Bytes: ${base64Encode(txn.bcsSerialize())}") + val gasObjId = + ObjectId.fromHex( + "0x0b0270ee9d27da0db09651e5f7338dfa32c7ee6441ccefa1f6e305735bcfc7ab" + ) + builder.gas(gasObjId).sponsor(sponsor) + + val txn = builder.finish() - val res = client.dryRunTx(txn, false) + println("Signing Digest: ${hexEncode(txn.signingDigest())}") + println("Txn Bytes: ${base64Encode(txn.bcsSerialize())}") - if (res.error != null) { - throw Exception("Failed to send gas sponsor tx: ${res.error}") - } + val res = client.dryRunTx(txn, false) - println("Gas sponsor tx dry run was successful!") - } catch (e: Exception) { - e.printStackTrace() + if (res.error != null) { + throw Exception("Failed to send gas sponsor tx: ${res.error}") } + + println("Gas sponsor tx dry run was successful!") + } catch (e: Exception) { + e.printStackTrace() + } } diff --git a/bindings/kotlin/examples/GasStation.kt b/bindings/kotlin/examples/GasStation.kt index 18e688b2b..dd55a52eb 100644 --- a/bindings/kotlin/examples/GasStation.kt +++ b/bindings/kotlin/examples/GasStation.kt @@ -22,7 +22,7 @@ fun main() = runBlocking { val builder = TransactionBuilder.init(sender, client) builder.moveCall( - Address.fromHex("0x1"), + Address.stdLib(), Identifier("u64"), Identifier("sqrt"), listOf( diff --git a/bindings/kotlin/examples/GenericMoveFunction.kt b/bindings/kotlin/examples/GenericMoveFunction.kt index 74e0a23d5..b5bebcd74 100644 --- a/bindings/kotlin/examples/GenericMoveFunction.kt +++ b/bindings/kotlin/examples/GenericMoveFunction.kt @@ -30,7 +30,7 @@ fun main() = runBlocking { "0xe512234aa4ef6184c52663f09612b68f040dd0c45de037d96190a071ca5525b3" ) - val package_addr = Address.fromHex("0x2") + val package_addr = Address.framework() val module_name = Identifier("vec_map") val function_name = Identifier("from_keys_values") diff --git a/bindings/kotlin/examples/OwnedObjects.kt b/bindings/kotlin/examples/OwnedObjects.kt index c3a50c5b4..1847cd63e 100644 --- a/bindings/kotlin/examples/OwnedObjects.kt +++ b/bindings/kotlin/examples/OwnedObjects.kt @@ -9,7 +9,7 @@ import kotlinx.coroutines.runBlocking fun main() = runBlocking { try { val client = GraphQlClient.newDevnet() - val address = Address.fromHex("0x0") + val address = Address.zero() val objectFilter = ObjectFilter(owner = address) val objectsPage = client.objects(objectFilter) println("Owned objects (${objectsPage.data.size}):") diff --git a/bindings/kotlin/examples/Stake.kt b/bindings/kotlin/examples/Stake.kt index 9a602e906..d9e8ea0f9 100644 --- a/bindings/kotlin/examples/Stake.kt +++ b/bindings/kotlin/examples/Stake.kt @@ -34,11 +34,11 @@ fun main() = runBlocking { val builder = TransactionBuilder.init(myAddress, client) builder.moveCall( - Address.fromHex("0x3"), + Address.system(), Identifier("iota_system"), Identifier("request_add_stake"), listOf( - PtbArgument.sharedMut(ObjectId.fromHex("0x5")), + PtbArgument.sharedMut(ObjectId.system()), PtbArgument.objectId(coinId), PtbArgument.address(validator.address) ), diff --git a/bindings/kotlin/examples/Unstake.kt b/bindings/kotlin/examples/Unstake.kt index 41ef7f80e..6be7b3983 100644 --- a/bindings/kotlin/examples/Unstake.kt +++ b/bindings/kotlin/examples/Unstake.kt @@ -23,11 +23,11 @@ fun main() = runBlocking { val builder = TransactionBuilder.init(stakedIota.owner().asAddress(), client) builder.moveCall( - Address.fromHex("0x3"), + Address.system(), Identifier("iota_system"), Identifier("request_withdraw_stake"), listOf( - PtbArgument.sharedMut(ObjectId.fromHex("0x5")), + PtbArgument.sharedMut(ObjectId.system()), 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 2a427ce75..647c4d864 100644 --- a/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt +++ b/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt @@ -2361,6 +2361,20 @@ internal interface UniffiForeignFutureCompleteVoid : com.sun.jna.Callback { + + + + + + + + + + + + + + @@ -3313,12 +3327,20 @@ fun uniffi_iota_sdk_ffi_checksum_method_zkloginverifier_verify( ): Short fun uniffi_iota_sdk_ffi_checksum_method_zkloginverifier_with_jwks( ): Short +fun uniffi_iota_sdk_ffi_checksum_constructor_address_framework( +): Short fun uniffi_iota_sdk_ffi_checksum_constructor_address_from_bytes( ): Short fun uniffi_iota_sdk_ffi_checksum_constructor_address_from_hex( ): Short fun uniffi_iota_sdk_ffi_checksum_constructor_address_generate( ): Short +fun uniffi_iota_sdk_ffi_checksum_constructor_address_std_lib( +): Short +fun uniffi_iota_sdk_ffi_checksum_constructor_address_system( +): Short +fun uniffi_iota_sdk_ffi_checksum_constructor_address_zero( +): Short fun uniffi_iota_sdk_ffi_checksum_constructor_argument_new_gas( ): Short fun uniffi_iota_sdk_ffi_checksum_constructor_argument_new_input( @@ -3559,12 +3581,18 @@ fun uniffi_iota_sdk_ffi_checksum_constructor_objectdata_new_move_package( ): Short fun uniffi_iota_sdk_ffi_checksum_constructor_objectdata_new_move_struct( ): Short +fun uniffi_iota_sdk_ffi_checksum_constructor_objectid_clock( +): Short fun uniffi_iota_sdk_ffi_checksum_constructor_objectid_derive_id( ): Short fun uniffi_iota_sdk_ffi_checksum_constructor_objectid_from_bytes( ): Short fun uniffi_iota_sdk_ffi_checksum_constructor_objectid_from_hex( ): Short +fun uniffi_iota_sdk_ffi_checksum_constructor_objectid_system( +): Short +fun uniffi_iota_sdk_ffi_checksum_constructor_objectid_zero( +): Short fun uniffi_iota_sdk_ffi_checksum_constructor_objecttype_new_package( ): Short fun uniffi_iota_sdk_ffi_checksum_constructor_objecttype_new_struct( @@ -3892,12 +3920,20 @@ internal interface UniffiLib : Library { ): Pointer fun uniffi_iota_sdk_ffi_fn_free_address(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Unit +fun uniffi_iota_sdk_ffi_fn_constructor_address_framework(uniffi_out_err: UniffiRustCallStatus, +): Pointer fun uniffi_iota_sdk_ffi_fn_constructor_address_from_bytes(`bytes`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_iota_sdk_ffi_fn_constructor_address_from_hex(`hex`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_iota_sdk_ffi_fn_constructor_address_generate(uniffi_out_err: UniffiRustCallStatus, ): Pointer +fun uniffi_iota_sdk_ffi_fn_constructor_address_std_lib(uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_constructor_address_system(uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_constructor_address_zero(uniffi_out_err: UniffiRustCallStatus, +): Pointer fun uniffi_iota_sdk_ffi_fn_method_address_to_bytes(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): RustBuffer.ByValue fun uniffi_iota_sdk_ffi_fn_method_address_to_hex(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, @@ -4822,12 +4858,18 @@ fun uniffi_iota_sdk_ffi_fn_clone_objectid(`ptr`: Pointer,uniffi_out_err: UniffiR ): Pointer fun uniffi_iota_sdk_ffi_fn_free_objectid(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Unit +fun uniffi_iota_sdk_ffi_fn_constructor_objectid_clock(uniffi_out_err: UniffiRustCallStatus, +): Pointer fun uniffi_iota_sdk_ffi_fn_constructor_objectid_derive_id(`digest`: Pointer,`count`: Long,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_iota_sdk_ffi_fn_constructor_objectid_from_bytes(`bytes`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_iota_sdk_ffi_fn_constructor_objectid_from_hex(`hex`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Pointer +fun uniffi_iota_sdk_ffi_fn_constructor_objectid_system(uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_constructor_objectid_zero(uniffi_out_err: UniffiRustCallStatus, +): Pointer fun uniffi_iota_sdk_ffi_fn_method_objectid_derive_dynamic_child_id(`ptr`: Pointer,`keyTypeTag`: Pointer,`keyBytes`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_iota_sdk_ffi_fn_method_objectid_to_address(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, @@ -6210,7 +6252,7 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_dry_run_tx_kind() != 40594.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_dynamic_field() != 29988.toShort()) { + if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_dynamic_field() != 17199.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_dynamic_fields() != 6963.toShort()) { @@ -7263,6 +7305,9 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_method_zkloginverifier_with_jwks() != 49665.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_address_framework() != 52951.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_iota_sdk_ffi_checksum_constructor_address_from_bytes() != 58901.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -7272,6 +7317,15 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_constructor_address_generate() != 48865.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_address_std_lib() != 35825.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_address_system() != 4297.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_address_zero() != 46553.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_iota_sdk_ffi_checksum_constructor_argument_new_gas() != 14489.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -7632,6 +7686,9 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_constructor_objectdata_new_move_struct() != 1861.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_objectid_clock() != 14732.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_iota_sdk_ffi_checksum_constructor_objectid_derive_id() != 16970.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -7641,6 +7698,12 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_constructor_objectid_from_hex() != 30954.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_objectid_system() != 9600.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_objectid_zero() != 40526.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_iota_sdk_ffi_checksum_constructor_objecttype_new_package() != 63533.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -8841,6 +8904,16 @@ open class Address: Disposable, AutoCloseable, AddressInterface companion object { + fun `framework`(): Address { + return FfiConverterTypeAddress.lift( + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_address_framework( + _status) +} + ) + } + + @Throws(SdkFfiException::class) fun `fromBytes`(`bytes`: kotlin.ByteArray): Address { return FfiConverterTypeAddress.lift( @@ -8873,6 +8946,36 @@ open class Address: Disposable, AutoCloseable, AddressInterface } + fun `stdLib`(): Address { + return FfiConverterTypeAddress.lift( + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_address_std_lib( + _status) +} + ) + } + + + fun `system`(): Address { + return FfiConverterTypeAddress.lift( + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_address_system( + _status) +} + ) + } + + + fun `zero`(): Address { + return FfiConverterTypeAddress.lift( + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_address_zero( + _status) +} + ) + } + + } @@ -19425,7 +19528,7 @@ public interface GraphQlClientInterface { * ```rust,ignore * * let client = iota_graphql_client::Client::new_devnet(); - * let address = Address::from_str("0x5").unwrap(); + * let address = ObjectId::SYSTEM.into(); * let df = client.dynamic_field_with_name(address, "u64", 2u64).await.unwrap(); * * # alternatively, pass in the bcs bytes @@ -20054,7 +20157,7 @@ open class GraphQlClient: Disposable, AutoCloseable, GraphQlClientInterface * ```rust,ignore * * let client = iota_graphql_client::Client::new_devnet(); - * let address = Address::from_str("0x5").unwrap(); + * let address = ObjectId::SYSTEM.into(); * let df = client.dynamic_field_with_name(address, "u64", 2u64).await.unwrap(); * * # alternatively, pass in the bcs bytes @@ -28215,6 +28318,16 @@ open class ObjectId: Disposable, AutoCloseable, ObjectIdInterface companion object { + fun `clock`(): ObjectId { + return FfiConverterTypeObjectId.lift( + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_objectid_clock( + _status) +} + ) + } + + /** * Create an ObjectId from a transaction digest and the number of objects @@ -28251,6 +28364,26 @@ open class ObjectId: Disposable, AutoCloseable, ObjectIdInterface } + fun `system`(): ObjectId { + return FfiConverterTypeObjectId.lift( + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_objectid_system( + _status) +} + ) + } + + + fun `zero`(): ObjectId { + return FfiConverterTypeObjectId.lift( + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_objectid_zero( + _status) +} + ) + } + + } diff --git a/bindings/python/examples/dev_inspect.py b/bindings/python/examples/dev_inspect.py index 285e56388..4303dd4a3 100644 --- a/bindings/python/examples/dev_inspect.py +++ b/bindings/python/examples/dev_inspect.py @@ -9,7 +9,7 @@ async def main(): try: client = GraphQlClient.new_devnet() - sender = Address.from_hex("0x0") + sender = Address.zero() iota_names_package_address = Address.from_hex( "0xb9d617f24c84826bf660a2f4031951678cc80c264aebc4413459fb2a95ada9ba" @@ -17,7 +17,7 @@ async def main(): iota_names_object_id = ObjectId.from_hex( "0x07c59b37bd7d036bf78fa30561a2ab9f7a970837487656ec29466e817f879342" ) - stdlib_address = Address.from_hex("0x1") + stdlib_address = Address.std_lib() name = "name.iota" print(f"Looking up name: {name}") diff --git a/bindings/python/examples/gas_sponsor.py b/bindings/python/examples/gas_sponsor.py index 07337fd2b..0842df94b 100644 --- a/bindings/python/examples/gas_sponsor.py +++ b/bindings/python/examples/gas_sponsor.py @@ -19,7 +19,7 @@ async def main(): builder = await TransactionBuilder.init(sender, client) - package_addr = Address.from_hex("0x1") + package_addr = Address.std_lib() module_name = Identifier("u8") function_name = Identifier("max") diff --git a/bindings/python/examples/gas_station.py b/bindings/python/examples/gas_station.py index eff13c892..00f032d74 100644 --- a/bindings/python/examples/gas_station.py +++ b/bindings/python/examples/gas_station.py @@ -17,7 +17,7 @@ async def main(): builder = await TransactionBuilder.init(sender, client) builder.move_call( - Address.from_hex("0x1"), + Address.std_lib(), Identifier("u64"), Identifier("sqrt"), [PtbArgument.u64(64)], diff --git a/bindings/python/examples/generic_move_function.py b/bindings/python/examples/generic_move_function.py index 467ba1922..0cd7365e7 100644 --- a/bindings/python/examples/generic_move_function.py +++ b/bindings/python/examples/generic_move_function.py @@ -23,7 +23,7 @@ async def main(): ) builder.move_call( - Address.from_hex("0x2"), + Address.framework(), Identifier("vec_map"), Identifier("from_keys_values"), [ diff --git a/bindings/python/examples/owned_objects.py b/bindings/python/examples/owned_objects.py index 7789737e6..6b47db5af 100644 --- a/bindings/python/examples/owned_objects.py +++ b/bindings/python/examples/owned_objects.py @@ -8,7 +8,7 @@ async def main(): client = GraphQlClient.new_devnet() - address = Address.from_hex("0x0") + address = Address.zero() objects_page = await client.objects(ObjectFilter(owner=address)) print(f"Owned objects({len(objects_page.data)}):") for obj in objects_page.data: diff --git a/bindings/python/examples/stake.py b/bindings/python/examples/stake.py index c88c06081..2d0692a6c 100644 --- a/bindings/python/examples/stake.py +++ b/bindings/python/examples/stake.py @@ -28,11 +28,11 @@ async def main(): builder = await TransactionBuilder.init(my_address, client) builder.move_call( - Address.from_hex("0x3"), + Address.system(), Identifier("iota_system"), Identifier("request_add_stake"), [ - PtbArgument.shared_mut(ObjectId.from_hex("0x5")), + PtbArgument.shared_mut(ObjectId.system()), PtbArgument.object_id(coin_id), PtbArgument.address(validator.address), ], diff --git a/bindings/python/examples/unstake.py b/bindings/python/examples/unstake.py index b379d4a19..e634278cf 100644 --- a/bindings/python/examples/unstake.py +++ b/bindings/python/examples/unstake.py @@ -22,11 +22,11 @@ async def main(): ) builder.move_call( - Address.from_hex("0x3"), + Address.system(), Identifier("iota_system"), Identifier("request_withdraw_stake"), [ - PtbArgument.shared_mut(ObjectId.from_hex("0x5")), + PtbArgument.shared_mut(ObjectId.system()), PtbArgument.object_id(staked_iota.object_id()), ], ) diff --git a/bindings/python/lib/iota_sdk_ffi.py b/bindings/python/lib/iota_sdk_ffi.py index 782636ad5..93cea885b 100644 --- a/bindings/python/lib/iota_sdk_ffi.py +++ b/bindings/python/lib/iota_sdk_ffi.py @@ -681,7 +681,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_graphqlclient_dry_run_tx_kind() != 40594: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_dynamic_field() != 29988: + if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_dynamic_field() != 17199: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_dynamic_fields() != 6963: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") @@ -1383,12 +1383,20 @@ 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_zkloginverifier_with_jwks() != 49665: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_constructor_address_framework() != 52951: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_address_from_bytes() != 58901: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_address_from_hex() != 63442: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_address_generate() != 48865: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_constructor_address_std_lib() != 35825: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_constructor_address_system() != 4297: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_constructor_address_zero() != 46553: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_argument_new_gas() != 14489: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_argument_new_input() != 33966: @@ -1629,12 +1637,18 @@ 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_objectdata_new_move_struct() != 1861: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_constructor_objectid_clock() != 14732: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_objectid_derive_id() != 16970: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_objectid_from_bytes() != 41789: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_objectid_from_hex() != 30954: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_constructor_objectid_system() != 9600: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_constructor_objectid_zero() != 40526: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_objecttype_new_package() != 63533: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_objecttype_new_struct() != 65488: @@ -2025,6 +2039,10 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_iota_sdk_ffi_fn_free_address.restype = None +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_address_framework.argtypes = ( + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_address_framework.restype = ctypes.c_void_p _UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_address_from_bytes.argtypes = ( _UniffiRustBuffer, ctypes.POINTER(_UniffiRustCallStatus), @@ -2039,6 +2057,18 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_address_generate.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_address_std_lib.argtypes = ( + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_address_std_lib.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_address_system.argtypes = ( + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_address_system.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_address_zero.argtypes = ( + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_address_zero.restype = ctypes.c_void_p _UniffiLib.uniffi_iota_sdk_ffi_fn_method_address_to_bytes.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), @@ -4451,6 +4481,10 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_iota_sdk_ffi_fn_free_objectid.restype = None +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_objectid_clock.argtypes = ( + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_objectid_clock.restype = ctypes.c_void_p _UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_objectid_derive_id.argtypes = ( ctypes.c_void_p, ctypes.c_uint64, @@ -4467,6 +4501,14 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_objectid_from_hex.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_objectid_system.argtypes = ( + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_objectid_system.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_objectid_zero.argtypes = ( + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_objectid_zero.restype = ctypes.c_void_p _UniffiLib.uniffi_iota_sdk_ffi_fn_method_objectid_derive_dynamic_child_id.argtypes = ( ctypes.c_void_p, ctypes.c_void_p, @@ -8526,6 +8568,9 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_zkloginverifier_with_jwks.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_zkloginverifier_with_jwks.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_address_framework.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_address_framework.restype = ctypes.c_uint16 _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_address_from_bytes.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_address_from_bytes.restype = ctypes.c_uint16 @@ -8535,6 +8580,15 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_address_generate.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_address_generate.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_address_std_lib.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_address_std_lib.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_address_system.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_address_system.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_address_zero.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_address_zero.restype = ctypes.c_uint16 _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_argument_new_gas.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_argument_new_gas.restype = ctypes.c_uint16 @@ -8895,6 +8949,9 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_objectdata_new_move_struct.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_objectdata_new_move_struct.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_objectid_clock.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_objectid_clock.restype = ctypes.c_uint16 _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_objectid_derive_id.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_objectid_derive_id.restype = ctypes.c_uint16 @@ -8904,6 +8961,12 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_objectid_from_hex.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_objectid_from_hex.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_objectid_system.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_objectid_system.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_objectid_zero.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_objectid_zero.restype = ctypes.c_uint16 _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_objecttype_new_package.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_objecttype_new_package.restype = ctypes.c_uint16 @@ -22686,6 +22749,12 @@ def _make_instance_(cls, pointer): inst._pointer = pointer return inst @classmethod + def framework(cls, ): + # Call the (fallible) function before creating any half-baked object instances. + pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_address_framework,) + return cls._make_instance_(pointer) + + @classmethod def from_bytes(cls, bytes: "bytes"): _UniffiConverterBytes.check_lower(bytes) @@ -22709,6 +22778,24 @@ def generate(cls, ): pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_address_generate,) return cls._make_instance_(pointer) + @classmethod + def std_lib(cls, ): + # Call the (fallible) function before creating any half-baked object instances. + pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_address_std_lib,) + return cls._make_instance_(pointer) + + @classmethod + def system(cls, ): + # Call the (fallible) function before creating any half-baked object instances. + pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_address_system,) + return cls._make_instance_(pointer) + + @classmethod + def zero(cls, ): + # Call the (fallible) function before creating any half-baked object instances. + pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_address_zero,) + return cls._make_instance_(pointer) + def to_bytes(self, ) -> "bytes": @@ -27669,7 +27756,7 @@ def dynamic_field(self, address: "Address",type_tag: "TypeTag",name: "Value"): ```rust,ignore let client = iota_graphql_client::Client::new_devnet(); - let address = Address::from_str("0x5").unwrap(); + let address = ObjectId::SYSTEM.into(); let df = client.dynamic_field_with_name(address, "u64", 2u64).await.unwrap(); # alternatively, pass in the bcs bytes @@ -28367,7 +28454,7 @@ async def dynamic_field(self, address: "Address",type_tag: "TypeTag",name: "Valu ```rust,ignore let client = iota_graphql_client::Client::new_devnet(); - let address = Address::from_str("0x5").unwrap(); + let address = ObjectId::SYSTEM.into(); let df = client.dynamic_field_with_name(address, "u64", 2u64).await.unwrap(); # alternatively, pass in the bcs bytes @@ -33086,6 +33173,12 @@ def _make_instance_(cls, pointer): inst._pointer = pointer return inst @classmethod + def clock(cls, ): + # Call the (fallible) function before creating any half-baked object instances. + pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_objectid_clock,) + return cls._make_instance_(pointer) + + @classmethod def derive_id(cls, digest: "Digest",count: "int"): """ Create an ObjectId from a transaction digest and the number of objects @@ -33120,6 +33213,18 @@ def from_hex(cls, hex: "str"): _UniffiConverterString.lower(hex)) return cls._make_instance_(pointer) + @classmethod + def system(cls, ): + # Call the (fallible) function before creating any half-baked object instances. + pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_objectid_system,) + return cls._make_instance_(pointer) + + @classmethod + def zero(cls, ): + # Call the (fallible) function before creating any half-baked object instances. + pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_objectid_zero,) + return cls._make_instance_(pointer) + def derive_dynamic_child_id(self, key_type_tag: "TypeTag",key_bytes: "bytes") -> "ObjectId": diff --git a/crates/iota-graphql-client/src/lib.rs b/crates/iota-graphql-client/src/lib.rs index 22cf4d25d..9b0e27c30 100644 --- a/crates/iota-graphql-client/src/lib.rs +++ b/crates/iota-graphql-client/src/lib.rs @@ -1584,7 +1584,7 @@ impl Client { /// ```rust,ignore /// /// let client = iota_graphql_client::Client::new_devnet(); - /// let address = Address::from_str("0x5").unwrap(); + /// let address = ObjectId::system().into(); /// let df = client.dynamic_field_with_name(address, "u64", 2u64).await.unwrap(); /// /// # alternatively, pass in the bcs bytes @@ -1807,7 +1807,7 @@ impl Client { mod tests { use base64ct::Encoding; use futures::StreamExt; - use iota_types::{Ed25519PublicKey, TypeTag}; + use iota_types::{Address, Ed25519PublicKey, ObjectId, TypeTag}; use tokio::time; use crate::{ @@ -1847,7 +1847,7 @@ mod tests { async fn test_balance_query() { let client = test_client(); client - .balance("0x1".parse().unwrap(), None) + .balance(Address::STD_LIB, None) .await .map_err(|e| { format!( @@ -2128,7 +2128,7 @@ mod tests { async fn test_object_query() { let client = test_client(); client - .object("0x5".parse().unwrap(), None) + .object(ObjectId::SYSTEM, None) .await .map_err(|e| { format!( @@ -2144,7 +2144,7 @@ mod tests { async fn test_object_bcs_query() { let client = test_client(); client - .object_bcs("0x5".parse().unwrap()) + .object_bcs(ObjectId::SYSTEM) .await .map_err(|e| { format!( @@ -2160,7 +2160,7 @@ mod tests { async fn test_coins_query() { let client = test_client(); client - .coins("0x1".parse().unwrap(), None, PaginationFilter::default()) + .coins(Address::STD_LIB, None, PaginationFilter::default()) .await .map_err(|e| { format!( @@ -2300,7 +2300,7 @@ mod tests { let client = test_client(); let bcs = base64ct::Base64::decode_vec("AgAAAAAAAAA=").unwrap(); client - .dynamic_field("0x5".parse().unwrap(), TypeTag::U64, BcsName(bcs)) + .dynamic_field(ObjectId::SYSTEM.into(), TypeTag::U64, BcsName(bcs)) .await .map_err(|e| { format!( @@ -2311,7 +2311,7 @@ mod tests { .unwrap(); client - .dynamic_field("0x5".parse().unwrap(), TypeTag::U64, 2u64) + .dynamic_field(ObjectId::SYSTEM.into(), TypeTag::U64, 2u64) .await .map_err(|e| { format!( @@ -2326,7 +2326,7 @@ mod tests { async fn test_dynamic_fields_query() { let client = test_client(); client - .dynamic_fields("0x5".parse().unwrap(), PaginationFilter::default()) + .dynamic_fields(ObjectId::SYSTEM.into(), PaginationFilter::default()) .await .map_err(|e| { format!( @@ -2396,7 +2396,7 @@ mod tests { async fn test_package() { let client = test_client(); client - .package("0x2".parse().unwrap(), None) + .package(Address::FRAMEWORK, None) .await .map_err(|e| { format!( @@ -2412,7 +2412,7 @@ mod tests { async fn test_latest_package_query() { let client = test_client(); client - .package_latest("0x2".parse().unwrap()) + .package_latest(Address::FRAMEWORK) .await .map_err(|e| { format!( diff --git a/crates/iota-sdk-ffi/Cargo.toml b/crates/iota-sdk-ffi/Cargo.toml index 884cde6d1..0b8836271 100644 --- a/crates/iota-sdk-ffi/Cargo.toml +++ b/crates/iota-sdk-ffi/Cargo.toml @@ -18,6 +18,7 @@ base64ct = { version = "1.6.0", features = ["alloc", "std"] } bcs = "0.1.6" derive_more = { version = "2.0", features = ["from", "deref", "display"] } hex = "0.4.3" +paste = "1.0" primitive-types = { version = "0.14", features = ["impl-serde"] } rand = "0.8" roaring = { version = "0.11.2", default-features = false } diff --git a/crates/iota-sdk-ffi/src/graphql.rs b/crates/iota-sdk-ffi/src/graphql.rs index ff66727c8..079e4caeb 100644 --- a/crates/iota-sdk-ffi/src/graphql.rs +++ b/crates/iota-sdk-ffi/src/graphql.rs @@ -722,7 +722,7 @@ impl GraphQLClient { /// ```rust,ignore /// /// let client = iota_graphql_client::Client::new_devnet(); - /// let address = Address::from_str("0x5").unwrap(); + /// let address = ObjectId::SYSTEM.into(); /// let df = client.dynamic_field_with_name(address, "u64", 2u64).await.unwrap(); /// /// # alternatively, pass in the bcs bytes diff --git a/crates/iota-sdk-ffi/src/types/address.rs b/crates/iota-sdk-ffi/src/types/address.rs index 8f68700e4..6b4e11bae 100644 --- a/crates/iota-sdk-ffi/src/types/address.rs +++ b/crates/iota-sdk-ffi/src/types/address.rs @@ -85,3 +85,19 @@ impl Address { self.0.to_hex() } } + +macro_rules! named_address { + ($($constant:ident),+ $(,)?) => { + paste::paste! { + #[uniffi::export] + impl Address {$( + #[uniffi::constructor] + pub const fn [< $constant:lower >]() -> Self { + Self(iota_types::Address::$constant) + } + )+} + } + } +} + +named_address!(ZERO, STD_LIB, FRAMEWORK, SYSTEM); diff --git a/crates/iota-sdk-ffi/src/types/object.rs b/crates/iota-sdk-ffi/src/types/object.rs index 53ab6b2e3..3683586c5 100644 --- a/crates/iota-sdk-ffi/src/types/object.rs +++ b/crates/iota-sdk-ffi/src/types/object.rs @@ -83,6 +83,22 @@ impl ObjectId { } } +macro_rules! named_object_id { + ($($constant:ident),+ $(,)?) => { + paste::paste! { + #[uniffi::export] + impl ObjectId {$( + #[uniffi::constructor] + pub const fn [< $constant:lower >]() -> Self { + Self(iota_types::ObjectId::$constant) + } + )+} + } + } +} + +named_object_id!(ZERO, SYSTEM, CLOCK); + /// Reference to an object /// /// Contains sufficient information to uniquely identify a specific object. diff --git a/crates/iota-sdk-types/src/address.rs b/crates/iota-sdk-types/src/address.rs index de2a9d28e..1878b0b52 100644 --- a/crates/iota-sdk-types/src/address.rs +++ b/crates/iota-sdk-types/src/address.rs @@ -72,15 +72,15 @@ pub struct Address( impl Address { pub const LENGTH: usize = 32; pub const ZERO: Self = Self([0u8; Self::LENGTH]); - pub const ONE: Self = Self::from_u8(1); - pub const TWO: Self = Self::from_u8(2); - pub const THREE: Self = Self::from_u8(3); + pub const STD_LIB: Self = Self::from_u8(1); + pub const FRAMEWORK: Self = Self::from_u8(2); + pub const SYSTEM: Self = Self::from_u8(3); pub const fn new(bytes: [u8; Self::LENGTH]) -> Self { Self(bytes) } - const fn from_u8(byte: u8) -> Self { + pub(crate) const fn from_u8(byte: u8) -> Self { let mut address = Self::ZERO; address.0[31] = byte; address @@ -266,7 +266,7 @@ impl schemars::JsonSchema for Address { metadata: Some(Box::new(Metadata { title: Some(Self::schema_name()), description: Some("A 32-byte IOTA address, encoded as a hex string.".to_owned()), - examples: vec![serde_json::to_value(Address::TWO).unwrap()], + examples: vec![serde_json::to_value(Address::FRAMEWORK).unwrap()], ..Default::default() })), instance_type: Some(InstanceType::String.into()), diff --git a/crates/iota-sdk-types/src/object.rs b/crates/iota-sdk-types/src/object.rs index 1bb558738..8b5471fdf 100644 --- a/crates/iota-sdk-types/src/object.rs +++ b/crates/iota-sdk-types/src/object.rs @@ -622,7 +622,7 @@ mod serialization { type_params, } = s_inner.as_ref(); - if address == &Address::TWO + if address == &Address::FRAMEWORK && module == "iota" && name == "IOTA" && type_params.is_empty() @@ -632,7 +632,7 @@ mod serialization { } Self::Coin(coin_type) - } else if address == &Address::THREE + } else if address == &Address::SYSTEM && module == "staking_pool" && name == "StakedIota" && type_params.is_empty() @@ -1040,7 +1040,7 @@ mod serialization { let o = Object { data: ObjectData::Struct(MoveStruct { type_: StructTag { - address: Address::TWO, + address: Address::FRAMEWORK, module: Identifier::new("bar").unwrap(), name: Identifier::new("foo").unwrap(), type_params: Vec::new(), diff --git a/crates/iota-sdk-types/src/object_id.rs b/crates/iota-sdk-types/src/object_id.rs index f8d086fa6..28316f9cb 100644 --- a/crates/iota-sdk-types/src/object_id.rs +++ b/crates/iota-sdk-types/src/object_id.rs @@ -34,6 +34,8 @@ pub struct ObjectId(Address); impl ObjectId { pub const LENGTH: usize = Address::LENGTH; pub const ZERO: Self = Self(Address::ZERO); + pub const SYSTEM: Self = Self(Address::from_u8(5)); + pub const CLOCK: Self = Self(Address::from_u8(6)); /// Generates a new ObjectId from the provided byte array. pub const fn new(bytes: [u8; Self::LENGTH]) -> Self { diff --git a/crates/iota-sdk-types/src/type_tag/mod.rs b/crates/iota-sdk-types/src/type_tag/mod.rs index 39677f761..4ee67041e 100644 --- a/crates/iota-sdk-types/src/type_tag/mod.rs +++ b/crates/iota-sdk-types/src/type_tag/mod.rs @@ -404,7 +404,7 @@ pub struct StructTag { impl StructTag { pub fn coin(type_tag: TypeTag) -> Self { Self { - address: Address::TWO, + address: Address::FRAMEWORK, module: Identifier::new("coin").unwrap(), name: Identifier::new("Coin").unwrap(), type_params: vec![type_tag], @@ -420,7 +420,10 @@ impl StructTag { type_params, } = self; - if address == &Address::TWO && module == "coin" && name == "Coin" && type_params.len() == 1 + if address == &Address::FRAMEWORK + && module == "coin" + && name == "Coin" + && type_params.len() == 1 { type_params.first() } else { @@ -435,7 +438,7 @@ impl StructTag { pub fn gas_coin() -> Self { let iota = Self { - address: Address::TWO, + address: Address::FRAMEWORK, module: Identifier::new("iota").unwrap(), name: Identifier::new("IOTA").unwrap(), type_params: vec![], @@ -446,7 +449,7 @@ impl StructTag { pub fn staked_iota() -> Self { Self { - address: Address::THREE, + address: Address::SYSTEM, module: Identifier::new("staking_pool").unwrap(), name: Identifier::new("StakedIota").unwrap(), type_params: vec![], @@ -455,7 +458,7 @@ impl StructTag { pub fn timelocked_staked_iota() -> Self { Self { - address: Address::THREE, + address: Address::SYSTEM, module: Identifier::new("timelocked_staking").unwrap(), name: Identifier::new("TimelockedStakedIota").unwrap(), type_params: vec![], diff --git a/crates/iota-sdk/examples/dev_inspect.rs b/crates/iota-sdk/examples/dev_inspect.rs index fce471f88..34bb469b1 100644 --- a/crates/iota-sdk/examples/dev_inspect.rs +++ b/crates/iota-sdk/examples/dev_inspect.rs @@ -50,7 +50,7 @@ async fn main() -> Result<()> { // Step 4: Borrow the name record from the option builder - .move_call(Address::ONE, "option", "borrow") + .move_call(Address::STD_LIB, "option", "borrow") .arguments([res("name_record_opt")]) .type_tags([TypeTag::Struct(Box::new(StructTag { address: iota_names_package_address, @@ -69,7 +69,7 @@ async fn main() -> Result<()> { // Step 6: Borrow the address from the option (this returns the resolved // address) builder - .move_call(Address::ONE, "option", "borrow") + .move_call(Address::STD_LIB, "option", "borrow") .arguments([res("target_address_opt")]) .generics::
() .name("target_address"); diff --git a/crates/iota-sdk/examples/gas_sponsor.rs b/crates/iota-sdk/examples/gas_sponsor.rs index 494493e0b..94fa5e04f 100644 --- a/crates/iota-sdk/examples/gas_sponsor.rs +++ b/crates/iota-sdk/examples/gas_sponsor.rs @@ -20,7 +20,7 @@ async fn main() -> Result<()> { let mut builder = TransactionBuilder::new(sender_address).with_client(client.clone()); let tx = builder - .move_call(Address::ONE, "u8", "max") + .move_call(Address::STD_LIB, "u8", "max") .arguments((0u8, 1u8)) .gas(ObjectId::from_str( "0x0b0270ee9d27da0db09651e5f7338dfa32c7ee6441ccefa1f6e305735bcfc7ab", diff --git a/crates/iota-sdk/examples/gas_station.rs b/crates/iota-sdk/examples/gas_station.rs index 02c8b091f..1d2d2c835 100644 --- a/crates/iota-sdk/examples/gas_station.rs +++ b/crates/iota-sdk/examples/gas_station.rs @@ -19,7 +19,7 @@ async fn main() -> Result<()> { let mut builder = TransactionBuilder::new(sender).with_client(client.clone()); builder - .move_call(Address::ONE, "u64", "sqrt") + .move_call(Address::STD_LIB, "u64", "sqrt") .arguments([64_u64]) .gas_station_sponsor(gas_station_url) .add_gas_station_header( diff --git a/crates/iota-sdk/examples/generic_move_function.rs b/crates/iota-sdk/examples/generic_move_function.rs index a83111894..29b6062bb 100644 --- a/crates/iota-sdk/examples/generic_move_function.rs +++ b/crates/iota-sdk/examples/generic_move_function.rs @@ -22,7 +22,7 @@ async fn main() -> Result<()> { Address::from_str("0xe512234aa4ef6184c52663f09612b68f040dd0c45de037d96190a071ca5525b3")?; builder - .move_call(Address::TWO, "vec_map", "from_keys_values") + .move_call(Address::FRAMEWORK, "vec_map", "from_keys_values") .generics::<(Address, u64)>() .arguments((vec![address1, address2], vec![10000000u64, 20000000u64])); diff --git a/crates/iota-sdk/examples/owned_objects.rs b/crates/iota-sdk/examples/owned_objects.rs index 1c865cba8..79601e885 100644 --- a/crates/iota-sdk/examples/owned_objects.rs +++ b/crates/iota-sdk/examples/owned_objects.rs @@ -9,7 +9,7 @@ use iota_types::Address; async fn main() -> Result<()> { let client = Client::new_devnet(); - let address = Address::from_hex("0x0")?; + let address = Address::ZERO; let owned_objects_page = client .objects( Some(ObjectFilter { diff --git a/crates/iota-sdk/examples/stake.rs b/crates/iota-sdk/examples/stake.rs index 1189023fd..017d5008c 100644 --- a/crates/iota-sdk/examples/stake.rs +++ b/crates/iota-sdk/examples/stake.rs @@ -31,9 +31,9 @@ async fn main() -> Result<()> { let mut builder = TransactionBuilder::new(my_address).with_client(client); builder - .move_call(Address::THREE, "iota_system", "request_add_stake") + .move_call(Address::SYSTEM, "iota_system", "request_add_stake") .arguments(( - SharedMut(ObjectId::from_str("0x5")?), + SharedMut(ObjectId::SYSTEM), ObjectId::from_str( "0xd04077fe3b6fad13b3d4ed0d535b7ca92afcac8f0f2a0e0925fb9f4f0b30c699", )?, diff --git a/crates/iota-sdk/examples/unstake.rs b/crates/iota-sdk/examples/unstake.rs index 0dab46775..c094f9fae 100644 --- a/crates/iota-sdk/examples/unstake.rs +++ b/crates/iota-sdk/examples/unstake.rs @@ -1,8 +1,6 @@ // Copyright (c) 2025 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use std::str::FromStr; - use eyre::{OptionExt, Result}; use iota_graphql_client::{Client, query_types::ObjectFilter}; use iota_transaction_builder::{SharedMut, TransactionBuilder}; @@ -30,11 +28,8 @@ async fn main() -> Result<()> { TransactionBuilder::new(*staked_iota.owner().as_address()).with_client(client); builder - .move_call(Address::THREE, "iota_system", "request_withdraw_stake") - .arguments(( - SharedMut(ObjectId::from_str("0x5")?), - staked_iota.object_id(), - )); + .move_call(Address::SYSTEM, "iota_system", "request_withdraw_stake") + .arguments((SharedMut(ObjectId::SYSTEM), staked_iota.object_id())); let res = builder.dry_run(false).await?; diff --git a/crates/iota-transaction-builder/src/builder/mod.rs b/crates/iota-transaction-builder/src/builder/mod.rs index b49d8ba59..0fd3097fa 100644 --- a/crates/iota-transaction-builder/src/builder/mod.rs +++ b/crates/iota-transaction-builder/src/builder/mod.rs @@ -928,7 +928,7 @@ impl TransactionBuilder<(), Publish> { /// commands. pub fn package_id(&mut self, name: impl NamedResult) -> &mut TransactionBuilder { let cap = self.arg(); - self.move_call(Address::TWO, "package", "upgrade_package") + self.move_call(Address::FRAMEWORK, "package", "upgrade_package") .arguments([cap]) .name(name) .reset() @@ -940,7 +940,7 @@ impl TransactionBuilder { /// commands. pub fn package_id(&mut self, name: impl NamedResult) -> &mut TransactionBuilder { let cap = self.arg(); - self.move_call(Address::TWO, "package", "upgrade_package") + self.move_call(Address::FRAMEWORK, "package", "upgrade_package") .arguments([cap]) .name(name) .reset() diff --git a/crates/iota-transaction-builder/src/lib.rs b/crates/iota-transaction-builder/src/lib.rs index 6e1e08abd..ee8c385a5 100644 --- a/crates/iota-transaction-builder/src/lib.rs +++ b/crates/iota-transaction-builder/src/lib.rs @@ -183,7 +183,7 @@ mod tests { // set up the sender, gas object, gas budget, and gas price and return the pk to // sign let (mut tx, _, pk, _) = helper_setup().await; - tx.move_call(Address::ONE, "option", "is_none") + tx.move_call(Address::STD_LIB, "option", "is_none") .generics::() .arguments([Some(1u64)]); @@ -330,7 +330,7 @@ mod tests { let updated_package = move_package_data("package_test_example_v2.json"); // we need this ticket to authorize the upgrade - tx.move_call(Address::TWO, "package", "authorize_upgrade") + tx.move_call(Address::FRAMEWORK, "package", "authorize_upgrade") .arguments(( upgrade_cap.unwrap(), 0u8, @@ -343,7 +343,7 @@ mod tests { .arg(); // commit the upgrade - tx.move_call(Address::TWO, "package", "commit_upgrade") + tx.move_call(Address::FRAMEWORK, "package", "commit_upgrade") .arguments((upgrade_cap.unwrap(), receipt)); tx.gas(coins.last().unwrap().id);