From 1a57d330fbe1ad7acaa6199651553702432dd66b Mon Sep 17 00:00:00 2001 From: Chloe Martin Date: Fri, 29 Aug 2025 14:11:26 +0200 Subject: [PATCH 1/7] feat: Add support for IOTA-Names --- bindings/go/iota_sdk_ffi/iota_sdk_ffi.go | 712 +++++++++ bindings/go/iota_sdk_ffi/iota_sdk_ffi.h | 196 +++ bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt | 1305 +++++++++++++++-- bindings/python/lib/iota_sdk_ffi.py | 766 ++++++++++ crates/iota-graphql-client/src/lib.rs | 104 +- .../src/query_types/iota_names.rs | 134 ++ .../src/query_types/mod.rs | 7 + crates/iota-sdk-ffi/src/graphql.rs | 50 +- crates/iota-sdk-ffi/src/types/iota_names.rs | 99 ++ crates/iota-sdk-ffi/src/types/mod.rs | 1 + crates/iota-sdk-ffi/src/uniffi_helpers.rs | 2 + crates/iota-sdk-types/Cargo.toml | 2 + .../iota-sdk-types/src/iota_names/config.rs | 93 ++ .../src/iota_names/constants.rs | 10 + crates/iota-sdk-types/src/iota_names/error.rs | 32 + crates/iota-sdk-types/src/iota_names/mod.rs | 131 ++ crates/iota-sdk-types/src/iota_names/name.rs | 342 +++++ .../iota-sdk-types/src/iota_names/registry.rs | 195 +++ crates/iota-sdk-types/src/lib.rs | 1 + crates/iota-sdk-types/src/object.rs | 9 + crates/iota-sdk-types/src/type_tag/mod.rs | 114 ++ 21 files changed, 4182 insertions(+), 123 deletions(-) create mode 100644 crates/iota-graphql-client/src/query_types/iota_names.rs create mode 100644 crates/iota-sdk-ffi/src/types/iota_names.rs create mode 100644 crates/iota-sdk-types/src/iota_names/config.rs create mode 100644 crates/iota-sdk-types/src/iota_names/constants.rs create mode 100644 crates/iota-sdk-types/src/iota_names/error.rs create mode 100644 crates/iota-sdk-types/src/iota_names/mod.rs create mode 100644 crates/iota-sdk-types/src/iota_names/name.rs create mode 100644 crates/iota-sdk-types/src/iota_names/registry.rs diff --git a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go index 18703f37c..3378e6885 100644 --- a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go +++ b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go @@ -1349,6 +1349,33 @@ func uniffiCheckChecksums() { } } { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_default_name() + }) + if checksum != 55795 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_default_name: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_lookup() + }) + if checksum != 26177 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_lookup: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_registrations() + }) + if checksum != 58110 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_registrations: UniFFI API checksum mismatch") + } + } + { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_latest_checkpoint_sequence_number() }) @@ -2051,6 +2078,105 @@ func uniffiCheckChecksums() { } } { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_name_format() + }) + if checksum != 66 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_name_format: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_name_is_sln() + }) + if checksum != 9860 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_name_is_sln: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_name_is_subname() + }) + if checksum != 22382 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_name_is_subname: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_name_label() + }) + if checksum != 9695 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_name_label: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_name_labels() + }) + if checksum != 44675 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_name_labels: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_name_num_labels() + }) + if checksum != 62037 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_name_num_labels: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_name_parent() + }) + if checksum != 40819 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_name_parent: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_nameregistration_expiration_timestamp_ms() + }) + if checksum != 13855 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_nameregistration_expiration_timestamp_ms: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_nameregistration_id() + }) + if checksum != 17049 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_nameregistration_id: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_nameregistration_name() + }) + if checksum != 16565 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_nameregistration_name: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_nameregistration_name_str() + }) + if checksum != 19903 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_nameregistration_name_str: UniFFI API checksum mismatch") + } + } + { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_method_object_as_struct() }) @@ -4931,6 +5057,24 @@ func uniffiCheckChecksums() { } } { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_constructor_name_from_str() + }) + if checksum != 30248 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_name_from_str: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_constructor_nameregistration_new() + }) + if checksum != 19327 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_nameregistration_new: UniFFI API checksum mismatch") + } + } + { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_constructor_object_new() }) @@ -11157,6 +11301,9 @@ type GraphQlClientInterface interface { Events(paginationFilter PaginationFilter, filter *EventFilter) (EventPage, error) // Execute a transaction. ExecuteTx(signatures []*UserSignature, tx *Transaction) (**TransactionEffects, error) + IotaNamesDefaultName(address *Address, format *NameFormat) (**Name, error) + IotaNamesLookup(name string) (**Address, error) + IotaNamesRegistrations(address *Address, paginationFilter PaginationFilter) (NameRegistrationPage, error) // Return the sequence number of the latest checkpoint that has been // executed. LatestCheckpointSequenceNumber() (*uint64, error) @@ -11927,6 +12074,99 @@ func (_self *GraphQlClient) ExecuteTx(signatures []*UserSignature, tx *Transacti return res, err } +func (_self *GraphQlClient) IotaNamesDefaultName(address *Address, format *NameFormat) (**Name, error) { + _pointer := _self.ffiObject.incrementPointer("*GraphQlClient") + 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) **Name { + return FfiConverterOptionalNameINSTANCE.Lift(ffi) + }, + C.uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_default_name( + _pointer,FfiConverterAddressINSTANCE.Lower(address), FfiConverterOptionalNameFormatINSTANCE.Lower(format)), + // 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 +} + +func (_self *GraphQlClient) IotaNamesLookup(name string) (**Address, error) { + _pointer := _self.ffiObject.incrementPointer("*GraphQlClient") + 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) **Address { + return FfiConverterOptionalAddressINSTANCE.Lift(ffi) + }, + C.uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_lookup( + _pointer,FfiConverterStringINSTANCE.Lower(name)), + // 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 +} + +func (_self *GraphQlClient) IotaNamesRegistrations(address *Address, paginationFilter PaginationFilter) (NameRegistrationPage, error) { + _pointer := _self.ffiObject.incrementPointer("*GraphQlClient") + 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) NameRegistrationPage { + return FfiConverterNameRegistrationPageINSTANCE.Lift(ffi) + }, + C.uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_registrations( + _pointer,FfiConverterAddressINSTANCE.Lower(address), FfiConverterPaginationFilterINSTANCE.Lower(paginationFilter)), + // 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 +} + // Return the sequence number of the latest checkpoint that has been // executed. func (_self *GraphQlClient) LatestCheckpointSequenceNumber() (*uint64, error) { @@ -14825,6 +15065,283 @@ func (_ FfiDestroyerMultisigVerifier) Destroy(value *MultisigVerifier) { +type NameInterface interface { + // Formats a name into a string based on the available output formats. + // The default separator is `.` + Format(format NameFormat) string + // Returns whether this name is a second-level name (Ex. `test.iota`) + IsSln() bool + // Returns whether this name is a subname (Ex. `sub.test.iota`) + IsSubname() bool + // Get the label at the given index + Label(index uint32) *string + // Get all of the labels. NOTE: These are in reverse order starting with + // the top-level name and proceeding to subnames. + Labels() []string + // Returns the number of labels including TLN. + NumLabels() uint32 + // parents; second-level names return `None`. + Parent() **Name +} +type Name struct { + ffiObject FfiObject +} + + +func NameFromStr(s string) (*Name, error) { + _uniffiRV, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_name_from_str(FfiConverterStringINSTANCE.Lower(s),_uniffiStatus) + }) + if _uniffiErr != nil { + var _uniffiDefaultValue *Name + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterNameINSTANCE.Lift(_uniffiRV), nil + } +} + + + +// Formats a name into a string based on the available output formats. +// The default separator is `.` +func (_self *Name) Format(format NameFormat) string { + _pointer := _self.ffiObject.incrementPointer("*Name") + defer _self.ffiObject.decrementPointer() + return FfiConverterStringINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer { + inner: C.uniffi_iota_sdk_ffi_fn_method_name_format( + _pointer,FfiConverterNameFormatINSTANCE.Lower(format),_uniffiStatus), + } + })) +} + +// Returns whether this name is a second-level name (Ex. `test.iota`) +func (_self *Name) IsSln() bool { + _pointer := _self.ffiObject.incrementPointer("*Name") + defer _self.ffiObject.decrementPointer() + return FfiConverterBoolINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) C.int8_t { + return C.uniffi_iota_sdk_ffi_fn_method_name_is_sln( + _pointer,_uniffiStatus) + })) +} + +// Returns whether this name is a subname (Ex. `sub.test.iota`) +func (_self *Name) IsSubname() bool { + _pointer := _self.ffiObject.incrementPointer("*Name") + defer _self.ffiObject.decrementPointer() + return FfiConverterBoolINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) C.int8_t { + return C.uniffi_iota_sdk_ffi_fn_method_name_is_subname( + _pointer,_uniffiStatus) + })) +} + +// Get the label at the given index +func (_self *Name) Label(index uint32) *string { + _pointer := _self.ffiObject.incrementPointer("*Name") + defer _self.ffiObject.decrementPointer() + return FfiConverterOptionalStringINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer { + inner: C.uniffi_iota_sdk_ffi_fn_method_name_label( + _pointer,FfiConverterUint32INSTANCE.Lower(index),_uniffiStatus), + } + })) +} + +// Get all of the labels. NOTE: These are in reverse order starting with +// the top-level name and proceeding to subnames. +func (_self *Name) Labels() []string { + _pointer := _self.ffiObject.incrementPointer("*Name") + defer _self.ffiObject.decrementPointer() + return FfiConverterSequenceStringINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer { + inner: C.uniffi_iota_sdk_ffi_fn_method_name_labels( + _pointer,_uniffiStatus), + } + })) +} + +// Returns the number of labels including TLN. +func (_self *Name) NumLabels() uint32 { + _pointer := _self.ffiObject.incrementPointer("*Name") + defer _self.ffiObject.decrementPointer() + return FfiConverterUint32INSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint32_t { + return C.uniffi_iota_sdk_ffi_fn_method_name_num_labels( + _pointer,_uniffiStatus) + })) +} + +// parents; second-level names return `None`. +func (_self *Name) Parent() **Name { + _pointer := _self.ffiObject.incrementPointer("*Name") + defer _self.ffiObject.decrementPointer() + return FfiConverterOptionalNameINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer { + inner: C.uniffi_iota_sdk_ffi_fn_method_name_parent( + _pointer,_uniffiStatus), + } + })) +} +func (object *Name) Destroy() { + runtime.SetFinalizer(object, nil) + object.ffiObject.destroy() +} + +type FfiConverterName struct {} + +var FfiConverterNameINSTANCE = FfiConverterName{} + + +func (c FfiConverterName) Lift(pointer unsafe.Pointer) *Name { + result := &Name { + newFfiObject( + pointer, + func(pointer unsafe.Pointer, status *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_clone_name(pointer, status) + }, + func(pointer unsafe.Pointer, status *C.RustCallStatus) { + C.uniffi_iota_sdk_ffi_fn_free_name(pointer, status) + }, + ), + } + runtime.SetFinalizer(result, (*Name).Destroy) + return result +} + +func (c FfiConverterName) Read(reader io.Reader) *Name { + return c.Lift(unsafe.Pointer(uintptr(readUint64(reader)))) +} + +func (c FfiConverterName) Lower(value *Name) 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("*Name") + defer value.ffiObject.decrementPointer() + return pointer + +} + +func (c FfiConverterName) Write(writer io.Writer, value *Name) { + writeUint64(writer, uint64(uintptr(c.Lower(value)))) +} + +type FfiDestroyerName struct {} + +func (_ FfiDestroyerName) Destroy(value *Name) { + value.Destroy() +} + + + +// An object to manage a second-level name (SLN). +type NameRegistrationInterface interface { + ExpirationTimestampMs() uint64 + Id() *ObjectId + Name() *Name + NameStr() string +} +// An object to manage a second-level name (SLN). +type NameRegistration struct { + ffiObject FfiObject +} +func NewNameRegistration(id *ObjectId, name *Name, nameStr string, expirationTimestampMs uint64) *NameRegistration { + return FfiConverterNameRegistrationINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_nameregistration_new(FfiConverterObjectIdINSTANCE.Lower(id), FfiConverterNameINSTANCE.Lower(name), FfiConverterStringINSTANCE.Lower(nameStr), FfiConverterUint64INSTANCE.Lower(expirationTimestampMs),_uniffiStatus) + })) +} + + + + +func (_self *NameRegistration) ExpirationTimestampMs() uint64 { + _pointer := _self.ffiObject.incrementPointer("*NameRegistration") + defer _self.ffiObject.decrementPointer() + return FfiConverterUint64INSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint64_t { + return C.uniffi_iota_sdk_ffi_fn_method_nameregistration_expiration_timestamp_ms( + _pointer,_uniffiStatus) + })) +} + +func (_self *NameRegistration) Id() *ObjectId { + _pointer := _self.ffiObject.incrementPointer("*NameRegistration") + defer _self.ffiObject.decrementPointer() + return FfiConverterObjectIdINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_nameregistration_id( + _pointer,_uniffiStatus) + })) +} + +func (_self *NameRegistration) Name() *Name { + _pointer := _self.ffiObject.incrementPointer("*NameRegistration") + defer _self.ffiObject.decrementPointer() + return FfiConverterNameINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_nameregistration_name( + _pointer,_uniffiStatus) + })) +} + +func (_self *NameRegistration) NameStr() string { + _pointer := _self.ffiObject.incrementPointer("*NameRegistration") + defer _self.ffiObject.decrementPointer() + return FfiConverterStringINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer { + inner: C.uniffi_iota_sdk_ffi_fn_method_nameregistration_name_str( + _pointer,_uniffiStatus), + } + })) +} +func (object *NameRegistration) Destroy() { + runtime.SetFinalizer(object, nil) + object.ffiObject.destroy() +} + +type FfiConverterNameRegistration struct {} + +var FfiConverterNameRegistrationINSTANCE = FfiConverterNameRegistration{} + + +func (c FfiConverterNameRegistration) Lift(pointer unsafe.Pointer) *NameRegistration { + result := &NameRegistration { + newFfiObject( + pointer, + func(pointer unsafe.Pointer, status *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_clone_nameregistration(pointer, status) + }, + func(pointer unsafe.Pointer, status *C.RustCallStatus) { + C.uniffi_iota_sdk_ffi_fn_free_nameregistration(pointer, status) + }, + ), + } + runtime.SetFinalizer(result, (*NameRegistration).Destroy) + return result +} + +func (c FfiConverterNameRegistration) Read(reader io.Reader) *NameRegistration { + return c.Lift(unsafe.Pointer(uintptr(readUint64(reader)))) +} + +func (c FfiConverterNameRegistration) Lower(value *NameRegistration) 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("*NameRegistration") + defer value.ffiObject.decrementPointer() + return pointer + +} + +func (c FfiConverterNameRegistration) Write(writer io.Writer, value *NameRegistration) { + writeUint64(writer, uint64(uintptr(c.Lower(value)))) +} + +type FfiDestroyerNameRegistration struct {} + +func (_ FfiDestroyerNameRegistration) Destroy(value *NameRegistration) { + value.Destroy() +} + + + // An object on the IOTA blockchain // // # BCS @@ -24697,6 +25214,49 @@ type FfiDestroyerMoveStructTypeParameter struct {} func (_ FfiDestroyerMoveStructTypeParameter) Destroy(value MoveStructTypeParameter) { value.Destroy() } +// A page of items returned by the GraphQL server. +type NameRegistrationPage struct { + // Information about the page, such as the cursor and whether there are + // more pages. + PageInfo PageInfo + // The data returned by the server. + Data []*NameRegistration +} + +func (r *NameRegistrationPage) Destroy() { + FfiDestroyerPageInfo{}.Destroy(r.PageInfo); + FfiDestroyerSequenceNameRegistration{}.Destroy(r.Data); +} + +type FfiConverterNameRegistrationPage struct {} + +var FfiConverterNameRegistrationPageINSTANCE = FfiConverterNameRegistrationPage{} + +func (c FfiConverterNameRegistrationPage) Lift(rb RustBufferI) NameRegistrationPage { + return LiftFromRustBuffer[NameRegistrationPage](c, rb) +} + +func (c FfiConverterNameRegistrationPage) Read(reader io.Reader) NameRegistrationPage { + return NameRegistrationPage { + FfiConverterPageInfoINSTANCE.Read(reader), + FfiConverterSequenceNameRegistrationINSTANCE.Read(reader), + } +} + +func (c FfiConverterNameRegistrationPage) Lower(value NameRegistrationPage) C.RustBuffer { + return LowerIntoRustBuffer[NameRegistrationPage](c, value) +} + +func (c FfiConverterNameRegistrationPage) Write(writer io.Writer, value NameRegistrationPage) { + FfiConverterPageInfoINSTANCE.Write(writer, value.PageInfo); + FfiConverterSequenceNameRegistrationINSTANCE.Write(writer, value.Data); +} + +type FfiDestroyerNameRegistrationPage struct {} + +func (_ FfiDestroyerNameRegistrationPage) Destroy(value NameRegistrationPage) { + value.Destroy() +} type ObjectFilter struct { TypeTag *string Owner **Address @@ -27579,6 +28139,41 @@ func (_ FfiDestroyerMoveVisibility) Destroy(value MoveVisibility) { } +// Two different view options for a name. +// `At` -> `test@example` | `Dot` -> `test.example.iota` +type NameFormat uint + +const ( + NameFormatAt NameFormat = 1 + NameFormatDot NameFormat = 2 +) + +type FfiConverterNameFormat struct {} + +var FfiConverterNameFormatINSTANCE = FfiConverterNameFormat{} + +func (c FfiConverterNameFormat) Lift(rb RustBufferI) NameFormat { + return LiftFromRustBuffer[NameFormat](c, rb) +} + +func (c FfiConverterNameFormat) Lower(value NameFormat) C.RustBuffer { + return LowerIntoRustBuffer[NameFormat](c, value) +} +func (FfiConverterNameFormat) Read(reader io.Reader) NameFormat { + id := readInt32(reader) + return NameFormat(id) +} + +func (FfiConverterNameFormat) Write(writer io.Writer, value NameFormat) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerNameFormat struct {} + +func (_ FfiDestroyerNameFormat) Destroy(value NameFormat) { +} + + // State of an object prior to execution // // If an object exists (at root-level) in the store prior to this transaction, @@ -28991,6 +29586,43 @@ func (_ FfiDestroyerOptionalMultisigAggregatedSignature) Destroy(value **Multisi } } +type FfiConverterOptionalName struct{} + +var FfiConverterOptionalNameINSTANCE = FfiConverterOptionalName{} + +func (c FfiConverterOptionalName) Lift(rb RustBufferI) **Name { + return LiftFromRustBuffer[**Name](c, rb) +} + +func (_ FfiConverterOptionalName) Read(reader io.Reader) **Name { + if readInt8(reader) == 0 { + return nil + } + temp := FfiConverterNameINSTANCE.Read(reader) + return &temp +} + +func (c FfiConverterOptionalName) Lower(value **Name) C.RustBuffer { + return LowerIntoRustBuffer[**Name](c, value) +} + +func (_ FfiConverterOptionalName) Write(writer io.Writer, value **Name) { + if value == nil { + writeInt8(writer, 0) + } else { + writeInt8(writer, 1) + FfiConverterNameINSTANCE.Write(writer, *value) + } +} + +type FfiDestroyerOptionalName struct {} + +func (_ FfiDestroyerOptionalName) Destroy(value **Name) { + if value != nil { + FfiDestroyerName{}.Destroy(*value) + } +} + type FfiConverterOptionalObject struct{} var FfiConverterOptionalObjectINSTANCE = FfiConverterOptionalObject{} @@ -30249,6 +30881,43 @@ func (_ FfiDestroyerOptionalMoveVisibility) Destroy(value *MoveVisibility) { } } +type FfiConverterOptionalNameFormat struct{} + +var FfiConverterOptionalNameFormatINSTANCE = FfiConverterOptionalNameFormat{} + +func (c FfiConverterOptionalNameFormat) Lift(rb RustBufferI) *NameFormat { + return LiftFromRustBuffer[*NameFormat](c, rb) +} + +func (_ FfiConverterOptionalNameFormat) Read(reader io.Reader) *NameFormat { + if readInt8(reader) == 0 { + return nil + } + temp := FfiConverterNameFormatINSTANCE.Read(reader) + return &temp +} + +func (c FfiConverterOptionalNameFormat) Lower(value *NameFormat) C.RustBuffer { + return LowerIntoRustBuffer[*NameFormat](c, value) +} + +func (_ FfiConverterOptionalNameFormat) Write(writer io.Writer, value *NameFormat) { + if value == nil { + writeInt8(writer, 0) + } else { + writeInt8(writer, 1) + FfiConverterNameFormatINSTANCE.Write(writer, *value) + } +} + +type FfiDestroyerOptionalNameFormat struct {} + +func (_ FfiDestroyerOptionalNameFormat) Destroy(value *NameFormat) { + if value != nil { + FfiDestroyerNameFormat{}.Destroy(*value) + } +} + type FfiConverterOptionalTransactionBlockKindInput struct{} var FfiConverterOptionalTransactionBlockKindInputINSTANCE = FfiConverterOptionalTransactionBlockKindInput{} @@ -31547,6 +32216,49 @@ func (FfiDestroyerSequenceMultisigMemberSignature) Destroy(sequence []*MultisigM } } +type FfiConverterSequenceNameRegistration struct{} + +var FfiConverterSequenceNameRegistrationINSTANCE = FfiConverterSequenceNameRegistration{} + +func (c FfiConverterSequenceNameRegistration) Lift(rb RustBufferI) []*NameRegistration { + return LiftFromRustBuffer[[]*NameRegistration](c, rb) +} + +func (c FfiConverterSequenceNameRegistration) Read(reader io.Reader) []*NameRegistration { + length := readInt32(reader) + if length == 0 { + return nil + } + result := make([]*NameRegistration, 0, length) + for i := int32(0); i < length; i++ { + result = append(result, FfiConverterNameRegistrationINSTANCE.Read(reader)) + } + return result +} + +func (c FfiConverterSequenceNameRegistration) Lower(value []*NameRegistration) C.RustBuffer { + return LowerIntoRustBuffer[[]*NameRegistration](c, value) +} + +func (c FfiConverterSequenceNameRegistration) Write(writer io.Writer, value []*NameRegistration) { + if len(value) > math.MaxInt32 { + panic("[]*NameRegistration is too large to fit into Int32") + } + + writeInt32(writer, int32(len(value))) + for _, item := range value { + FfiConverterNameRegistrationINSTANCE.Write(writer, item) + } +} + +type FfiDestroyerSequenceNameRegistration struct {} + +func (FfiDestroyerSequenceNameRegistration) Destroy(sequence []*NameRegistration) { + for _, value := range sequence { + FfiDestroyerNameRegistration{}.Destroy(value) + } +} + type FfiConverterSequenceObject struct{} var FfiConverterSequenceObjectINSTANCE = FfiConverterSequenceObject{} diff --git a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h index d6974e026..09d79ba7c 100644 --- a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h +++ b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h @@ -1706,6 +1706,21 @@ uint64_t uniffi_iota_sdk_ffi_fn_method_graphqlclient_events(void* ptr, RustBuffe uint64_t uniffi_iota_sdk_ffi_fn_method_graphqlclient_execute_tx(void* ptr, RustBuffer signatures, void* tx ); #endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_GRAPHQLCLIENT_IOTA_NAMES_DEFAULT_NAME +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_GRAPHQLCLIENT_IOTA_NAMES_DEFAULT_NAME +uint64_t uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_default_name(void* ptr, void* address, RustBuffer format +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_GRAPHQLCLIENT_IOTA_NAMES_LOOKUP +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_GRAPHQLCLIENT_IOTA_NAMES_LOOKUP +uint64_t uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_lookup(void* ptr, RustBuffer name +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_GRAPHQLCLIENT_IOTA_NAMES_REGISTRATIONS +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_GRAPHQLCLIENT_IOTA_NAMES_REGISTRATIONS +uint64_t uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_registrations(void* ptr, void* address, RustBuffer pagination_filter +); +#endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_GRAPHQLCLIENT_LATEST_CHECKPOINT_SEQUENCE_NUMBER #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_GRAPHQLCLIENT_LATEST_CHECKPOINT_SEQUENCE_NUMBER uint64_t uniffi_iota_sdk_ffi_fn_method_graphqlclient_latest_checkpoint_sequence_number(void* ptr @@ -2307,6 +2322,91 @@ void* uniffi_iota_sdk_ffi_fn_method_multisigverifier_with_zklogin_verifier(void* RustBuffer uniffi_iota_sdk_ffi_fn_method_multisigverifier_zklogin_verifier(void* ptr, RustCallStatus *out_status ); #endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_NAME +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_NAME +void* uniffi_iota_sdk_ffi_fn_clone_name(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_FREE_NAME +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_FREE_NAME +void uniffi_iota_sdk_ffi_fn_free_name(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_NAME_FROM_STR +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_NAME_FROM_STR +void* uniffi_iota_sdk_ffi_fn_constructor_name_from_str(RustBuffer s, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_NAME_FORMAT +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_NAME_FORMAT +RustBuffer uniffi_iota_sdk_ffi_fn_method_name_format(void* ptr, RustBuffer format, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_NAME_IS_SLN +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_NAME_IS_SLN +int8_t uniffi_iota_sdk_ffi_fn_method_name_is_sln(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_NAME_IS_SUBNAME +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_NAME_IS_SUBNAME +int8_t uniffi_iota_sdk_ffi_fn_method_name_is_subname(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_NAME_LABEL +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_NAME_LABEL +RustBuffer uniffi_iota_sdk_ffi_fn_method_name_label(void* ptr, uint32_t index, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_NAME_LABELS +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_NAME_LABELS +RustBuffer uniffi_iota_sdk_ffi_fn_method_name_labels(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_NAME_NUM_LABELS +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_NAME_NUM_LABELS +uint32_t uniffi_iota_sdk_ffi_fn_method_name_num_labels(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_NAME_PARENT +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_NAME_PARENT +RustBuffer uniffi_iota_sdk_ffi_fn_method_name_parent(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_NAMEREGISTRATION +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_NAMEREGISTRATION +void* uniffi_iota_sdk_ffi_fn_clone_nameregistration(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_FREE_NAMEREGISTRATION +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_FREE_NAMEREGISTRATION +void uniffi_iota_sdk_ffi_fn_free_nameregistration(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_NAMEREGISTRATION_NEW +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_NAMEREGISTRATION_NEW +void* uniffi_iota_sdk_ffi_fn_constructor_nameregistration_new(void* id, void* name, RustBuffer name_str, uint64_t expiration_timestamp_ms, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_NAMEREGISTRATION_EXPIRATION_TIMESTAMP_MS +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_NAMEREGISTRATION_EXPIRATION_TIMESTAMP_MS +uint64_t uniffi_iota_sdk_ffi_fn_method_nameregistration_expiration_timestamp_ms(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_NAMEREGISTRATION_ID +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_NAMEREGISTRATION_ID +void* uniffi_iota_sdk_ffi_fn_method_nameregistration_id(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_NAMEREGISTRATION_NAME +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_NAMEREGISTRATION_NAME +void* uniffi_iota_sdk_ffi_fn_method_nameregistration_name(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_NAMEREGISTRATION_NAME_STR +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_NAMEREGISTRATION_NAME_STR +RustBuffer uniffi_iota_sdk_ffi_fn_method_nameregistration_name_str(void* ptr, RustCallStatus *out_status +); +#endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_OBJECT #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_OBJECT void* uniffi_iota_sdk_ffi_fn_clone_object(void* ptr, RustCallStatus *out_status @@ -5457,6 +5557,24 @@ uint16_t uniffi_iota_sdk_ffi_checksum_method_graphqlclient_events(void #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_GRAPHQLCLIENT_EXECUTE_TX uint16_t uniffi_iota_sdk_ffi_checksum_method_graphqlclient_execute_tx(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_GRAPHQLCLIENT_IOTA_NAMES_DEFAULT_NAME +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_GRAPHQLCLIENT_IOTA_NAMES_DEFAULT_NAME +uint16_t uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_default_name(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_GRAPHQLCLIENT_IOTA_NAMES_LOOKUP +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_GRAPHQLCLIENT_IOTA_NAMES_LOOKUP +uint16_t uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_lookup(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_GRAPHQLCLIENT_IOTA_NAMES_REGISTRATIONS +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_GRAPHQLCLIENT_IOTA_NAMES_REGISTRATIONS +uint16_t uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_registrations(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_GRAPHQLCLIENT_LATEST_CHECKPOINT_SEQUENCE_NUMBER @@ -5925,6 +6043,72 @@ uint16_t uniffi_iota_sdk_ffi_checksum_method_multisigverifier_with_zklogin_verif #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_MULTISIGVERIFIER_ZKLOGIN_VERIFIER uint16_t uniffi_iota_sdk_ffi_checksum_method_multisigverifier_zklogin_verifier(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_NAME_FORMAT +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_NAME_FORMAT +uint16_t uniffi_iota_sdk_ffi_checksum_method_name_format(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_NAME_IS_SLN +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_NAME_IS_SLN +uint16_t uniffi_iota_sdk_ffi_checksum_method_name_is_sln(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_NAME_IS_SUBNAME +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_NAME_IS_SUBNAME +uint16_t uniffi_iota_sdk_ffi_checksum_method_name_is_subname(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_NAME_LABEL +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_NAME_LABEL +uint16_t uniffi_iota_sdk_ffi_checksum_method_name_label(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_NAME_LABELS +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_NAME_LABELS +uint16_t uniffi_iota_sdk_ffi_checksum_method_name_labels(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_NAME_NUM_LABELS +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_NAME_NUM_LABELS +uint16_t uniffi_iota_sdk_ffi_checksum_method_name_num_labels(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_NAME_PARENT +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_NAME_PARENT +uint16_t uniffi_iota_sdk_ffi_checksum_method_name_parent(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_NAMEREGISTRATION_EXPIRATION_TIMESTAMP_MS +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_NAMEREGISTRATION_EXPIRATION_TIMESTAMP_MS +uint16_t uniffi_iota_sdk_ffi_checksum_method_nameregistration_expiration_timestamp_ms(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_NAMEREGISTRATION_ID +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_NAMEREGISTRATION_ID +uint16_t uniffi_iota_sdk_ffi_checksum_method_nameregistration_id(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_NAMEREGISTRATION_NAME +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_NAMEREGISTRATION_NAME +uint16_t uniffi_iota_sdk_ffi_checksum_method_nameregistration_name(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_NAMEREGISTRATION_NAME_STR +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_NAMEREGISTRATION_NAME_STR +uint16_t uniffi_iota_sdk_ffi_checksum_method_nameregistration_name_str(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_OBJECT_AS_STRUCT @@ -7845,6 +8029,18 @@ uint16_t uniffi_iota_sdk_ffi_checksum_constructor_multisigmember_new(void #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_MULTISIGVERIFIER_NEW uint16_t uniffi_iota_sdk_ffi_checksum_constructor_multisigverifier_new(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_NAME_FROM_STR +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_NAME_FROM_STR +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_name_from_str(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_NAMEREGISTRATION_NEW +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_NAMEREGISTRATION_NEW +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_nameregistration_new(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_OBJECT_NEW diff --git a/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt b/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt index 2c41c7d61..12d06fb6c 100644 --- a/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt +++ b/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt @@ -2132,6 +2132,42 @@ internal interface UniffiForeignFutureCompleteVoid : com.sun.jna.Callback { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2388,6 +2424,12 @@ fun uniffi_iota_sdk_ffi_checksum_method_graphqlclient_events( ): Short fun uniffi_iota_sdk_ffi_checksum_method_graphqlclient_execute_tx( ): Short +fun uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_default_name( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_lookup( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_registrations( +): Short fun uniffi_iota_sdk_ffi_checksum_method_graphqlclient_latest_checkpoint_sequence_number( ): Short fun uniffi_iota_sdk_ffi_checksum_method_graphqlclient_max_page_size( @@ -2544,6 +2586,28 @@ fun uniffi_iota_sdk_ffi_checksum_method_multisigverifier_with_zklogin_verifier( ): Short fun uniffi_iota_sdk_ffi_checksum_method_multisigverifier_zklogin_verifier( ): Short +fun uniffi_iota_sdk_ffi_checksum_method_name_format( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_name_is_sln( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_name_is_subname( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_name_label( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_name_labels( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_name_num_labels( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_name_parent( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_nameregistration_expiration_timestamp_ms( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_nameregistration_id( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_nameregistration_name( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_nameregistration_name_str( +): Short fun uniffi_iota_sdk_ffi_checksum_method_object_as_struct( ): Short fun uniffi_iota_sdk_ffi_checksum_method_object_data( @@ -3184,6 +3248,10 @@ fun uniffi_iota_sdk_ffi_checksum_constructor_multisigmember_new( ): Short fun uniffi_iota_sdk_ffi_checksum_constructor_multisigverifier_new( ): Short +fun uniffi_iota_sdk_ffi_checksum_constructor_name_from_str( +): Short +fun uniffi_iota_sdk_ffi_checksum_constructor_nameregistration_new( +): Short fun uniffi_iota_sdk_ffi_checksum_constructor_object_new( ): Short fun uniffi_iota_sdk_ffi_checksum_constructor_objectdata_new_move_package( @@ -3971,6 +4039,12 @@ fun uniffi_iota_sdk_ffi_fn_method_graphqlclient_events(`ptr`: Pointer,`paginatio ): Long fun uniffi_iota_sdk_ffi_fn_method_graphqlclient_execute_tx(`ptr`: Pointer,`signatures`: RustBuffer.ByValue,`tx`: Pointer, ): Long +fun uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_default_name(`ptr`: Pointer,`address`: Pointer,`format`: RustBuffer.ByValue, +): Long +fun uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_lookup(`ptr`: Pointer,`name`: RustBuffer.ByValue, +): Long +fun uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_registrations(`ptr`: Pointer,`address`: Pointer,`paginationFilter`: RustBuffer.ByValue, +): Long fun uniffi_iota_sdk_ffi_fn_method_graphqlclient_latest_checkpoint_sequence_number(`ptr`: Pointer, ): Long fun uniffi_iota_sdk_ffi_fn_method_graphqlclient_max_page_size(`ptr`: Pointer, @@ -4211,6 +4285,40 @@ fun uniffi_iota_sdk_ffi_fn_method_multisigverifier_with_zklogin_verifier(`ptr`: ): Pointer fun uniffi_iota_sdk_ffi_fn_method_multisigverifier_zklogin_verifier(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): RustBuffer.ByValue +fun uniffi_iota_sdk_ffi_fn_clone_name(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_free_name(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Unit +fun uniffi_iota_sdk_ffi_fn_constructor_name_from_str(`s`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_name_format(`ptr`: Pointer,`format`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +fun uniffi_iota_sdk_ffi_fn_method_name_is_sln(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Byte +fun uniffi_iota_sdk_ffi_fn_method_name_is_subname(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Byte +fun uniffi_iota_sdk_ffi_fn_method_name_label(`ptr`: Pointer,`index`: Int,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +fun uniffi_iota_sdk_ffi_fn_method_name_labels(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +fun uniffi_iota_sdk_ffi_fn_method_name_num_labels(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Int +fun uniffi_iota_sdk_ffi_fn_method_name_parent(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +fun uniffi_iota_sdk_ffi_fn_clone_nameregistration(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_free_nameregistration(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Unit +fun uniffi_iota_sdk_ffi_fn_constructor_nameregistration_new(`id`: Pointer,`name`: Pointer,`nameStr`: RustBuffer.ByValue,`expirationTimestampMs`: Long,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_nameregistration_expiration_timestamp_ms(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Long +fun uniffi_iota_sdk_ffi_fn_method_nameregistration_id(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_nameregistration_name(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_nameregistration_name_str(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue fun uniffi_iota_sdk_ffi_fn_clone_object(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_iota_sdk_ffi_fn_free_object(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, @@ -5541,6 +5649,15 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_execute_tx() != 41079.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_default_name() != 55795.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_lookup() != 26177.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_registrations() != 58110.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_latest_checkpoint_sequence_number() != 40336.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -5775,6 +5892,39 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_method_multisigverifier_zklogin_verifier() != 5971.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_iota_sdk_ffi_checksum_method_name_format() != 66.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_name_is_sln() != 9860.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_name_is_subname() != 22382.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_name_label() != 9695.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_name_labels() != 44675.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_name_num_labels() != 62037.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_name_parent() != 40819.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_nameregistration_expiration_timestamp_ms() != 13855.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_nameregistration_id() != 17049.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_nameregistration_name() != 16565.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_nameregistration_name_str() != 19903.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_iota_sdk_ffi_checksum_method_object_as_struct() != 37303.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -6735,6 +6885,12 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_constructor_multisigverifier_new() != 53197.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_name_from_str() != 30248.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_nameregistration_new() != 19327.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_iota_sdk_ffi_checksum_constructor_object_new() != 41346.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -19051,6 +19207,12 @@ public interface GraphQlClientInterface { */ suspend fun `executeTx`(`signatures`: List, `tx`: Transaction): TransactionEffects? + suspend fun `iotaNamesDefaultName`(`address`: Address, `format`: NameFormat?): Name? + + suspend fun `iotaNamesLookup`(`name`: kotlin.String): Address? + + suspend fun `iotaNamesRegistrations`(`address`: Address, `paginationFilter`: PaginationFilter): NameRegistrationPage + /** * Return the sequence number of the latest checkpoint that has been * executed. @@ -19812,6 +19974,69 @@ open class GraphQlClient: Disposable, AutoCloseable, GraphQlClientInterface } + @Throws(SdkFfiException::class) + @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") + override suspend fun `iotaNamesDefaultName`(`address`: Address, `format`: NameFormat?) : Name? { + return uniffiRustCallAsync( + callWithPointer { thisPtr -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_default_name( + thisPtr, + FfiConverterTypeAddress.lower(`address`),FfiConverterOptionalTypeNameFormat.lower(`format`), + ) + }, + { 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 + { FfiConverterOptionalTypeName.lift(it) }, + // Error FFI converter + SdkFfiException.ErrorHandler, + ) + } + + + @Throws(SdkFfiException::class) + @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") + override suspend fun `iotaNamesLookup`(`name`: kotlin.String) : Address? { + return uniffiRustCallAsync( + callWithPointer { thisPtr -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_lookup( + thisPtr, + FfiConverterString.lower(`name`), + ) + }, + { 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 + { FfiConverterOptionalTypeAddress.lift(it) }, + // Error FFI converter + SdkFfiException.ErrorHandler, + ) + } + + + @Throws(SdkFfiException::class) + @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") + override suspend fun `iotaNamesRegistrations`(`address`: Address, `paginationFilter`: PaginationFilter) : NameRegistrationPage { + return uniffiRustCallAsync( + callWithPointer { thisPtr -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_registrations( + thisPtr, + FfiConverterTypeAddress.lower(`address`),FfiConverterTypePaginationFilter.lower(`paginationFilter`), + ) + }, + { 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 + { FfiConverterTypeNameRegistrationPage.lift(it) }, + // Error FFI converter + SdkFfiException.ErrorHandler, + ) + } + + /** * Return the sequence number of the latest checkpoint that has been * executed. @@ -24500,7 +24725,681 @@ open class MultisigMemberSignature: Disposable, AutoCloseable, MultisigMemberSig override fun run() { pointer?.let { ptr -> uniffiRustCall { status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_free_multisigmembersignature(ptr, status) + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_free_multisigmembersignature(ptr, status) + } + } + } + } + + fun uniffiClonePointer(): Pointer { + return uniffiRustCall() { status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_clone_multisigmembersignature(pointer!!, status) + } + } + + override fun `asEd25519`(): Ed25519Signature { + return FfiConverterTypeEd25519Signature.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigmembersignature_as_ed25519( + it, _status) +} + } + ) + } + + + override fun `asEd25519Opt`(): Ed25519Signature? { + return FfiConverterOptionalTypeEd25519Signature.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigmembersignature_as_ed25519_opt( + it, _status) +} + } + ) + } + + + override fun `asSecp256k1`(): Secp256k1Signature { + return FfiConverterTypeSecp256k1Signature.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigmembersignature_as_secp256k1( + it, _status) +} + } + ) + } + + + override fun `asSecp256k1Opt`(): Secp256k1Signature? { + return FfiConverterOptionalTypeSecp256k1Signature.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigmembersignature_as_secp256k1_opt( + it, _status) +} + } + ) + } + + + override fun `asSecp256r1`(): Secp256r1Signature { + return FfiConverterTypeSecp256r1Signature.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigmembersignature_as_secp256r1( + it, _status) +} + } + ) + } + + + override fun `asSecp256r1Opt`(): Secp256r1Signature? { + return FfiConverterOptionalTypeSecp256r1Signature.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigmembersignature_as_secp256r1_opt( + it, _status) +} + } + ) + } + + + override fun `asZklogin`(): ZkLoginAuthenticator { + return FfiConverterTypeZkLoginAuthenticator.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigmembersignature_as_zklogin( + it, _status) +} + } + ) + } + + + override fun `asZkloginOpt`(): ZkLoginAuthenticator? { + return FfiConverterOptionalTypeZkLoginAuthenticator.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigmembersignature_as_zklogin_opt( + it, _status) +} + } + ) + } + + + override fun `isEd25519`(): kotlin.Boolean { + return FfiConverterBoolean.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigmembersignature_is_ed25519( + it, _status) +} + } + ) + } + + + override fun `isSecp256k1`(): kotlin.Boolean { + return FfiConverterBoolean.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigmembersignature_is_secp256k1( + it, _status) +} + } + ) + } + + + override fun `isSecp256r1`(): kotlin.Boolean { + return FfiConverterBoolean.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigmembersignature_is_secp256r1( + it, _status) +} + } + ) + } + + + override fun `isZklogin`(): kotlin.Boolean { + return FfiConverterBoolean.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigmembersignature_is_zklogin( + it, _status) +} + } + ) + } + + + + + + + companion object + +} + +/** + * @suppress + */ +public object FfiConverterTypeMultisigMemberSignature: FfiConverter { + + override fun lower(value: MultisigMemberSignature): Pointer { + return value.uniffiClonePointer() + } + + override fun lift(value: Pointer): MultisigMemberSignature { + return MultisigMemberSignature(value) + } + + override fun read(buf: ByteBuffer): MultisigMemberSignature { + // 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: MultisigMemberSignature) = 8UL + + override fun write(value: MultisigMemberSignature, 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 MultisigVerifierInterface { + + fun `verify`(`message`: kotlin.ByteArray, `signature`: MultisigAggregatedSignature) + + fun `withZkloginVerifier`(`zkloginVerifier`: ZkloginVerifier): MultisigVerifier + + fun `zkloginVerifier`(): ZkloginVerifier? + + companion object +} + +open class MultisigVerifier: Disposable, AutoCloseable, MultisigVerifierInterface +{ + + 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)) + } + constructor() : + this( + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_multisigverifier_new( + _status) +} + ) + + 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_multisigverifier(ptr, status) + } + } + } + } + + fun uniffiClonePointer(): Pointer { + return uniffiRustCall() { status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_clone_multisigverifier(pointer!!, status) + } + } + + + @Throws(SdkFfiException::class)override fun `verify`(`message`: kotlin.ByteArray, `signature`: MultisigAggregatedSignature) + = + callWithPointer { + uniffiRustCallWithError(SdkFfiException) { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigverifier_verify( + it, FfiConverterByteArray.lower(`message`),FfiConverterTypeMultisigAggregatedSignature.lower(`signature`),_status) +} + } + + + + override fun `withZkloginVerifier`(`zkloginVerifier`: ZkloginVerifier): MultisigVerifier { + return FfiConverterTypeMultisigVerifier.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigverifier_with_zklogin_verifier( + it, FfiConverterTypeZkloginVerifier.lower(`zkloginVerifier`),_status) +} + } + ) + } + + + override fun `zkloginVerifier`(): ZkloginVerifier? { + return FfiConverterOptionalTypeZkloginVerifier.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigverifier_zklogin_verifier( + it, _status) +} + } + ) + } + + + + + + + companion object + +} + +/** + * @suppress + */ +public object FfiConverterTypeMultisigVerifier: FfiConverter { + + override fun lower(value: MultisigVerifier): Pointer { + return value.uniffiClonePointer() + } + + override fun lift(value: Pointer): MultisigVerifier { + return MultisigVerifier(value) + } + + override fun read(buf: ByteBuffer): MultisigVerifier { + // 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: MultisigVerifier) = 8UL + + override fun write(value: MultisigVerifier, 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 NameInterface { + + /** + * Formats a name into a string based on the available output formats. + * The default separator is `.` + */ + fun `format`(`format`: NameFormat): kotlin.String + + /** + * Returns whether this name is a second-level name (Ex. `test.iota`) + */ + fun `isSln`(): kotlin.Boolean + + /** + * Returns whether this name is a subname (Ex. `sub.test.iota`) + */ + fun `isSubname`(): kotlin.Boolean + + /** + * Get the label at the given index + */ + fun `label`(`index`: kotlin.UInt): kotlin.String? + + /** + * Get all of the labels. NOTE: These are in reverse order starting with + * the top-level name and proceeding to subnames. + */ + fun `labels`(): List + + /** + * Returns the number of labels including TLN. + */ + fun `numLabels`(): kotlin.UInt + + /** + * parents; second-level names return `None`. + */ + fun `parent`(): Name? + + companion object +} + +open class Name: Disposable, AutoCloseable, NameInterface +{ + + 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_name(ptr, status) } } } @@ -24508,51 +25407,34 @@ open class MultisigMemberSignature: Disposable, AutoCloseable, MultisigMemberSig fun uniffiClonePointer(): Pointer { return uniffiRustCall() { status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_clone_multisigmembersignature(pointer!!, status) + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_clone_name(pointer!!, status) } } - override fun `asEd25519`(): Ed25519Signature { - return FfiConverterTypeEd25519Signature.lift( - callWithPointer { - uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigmembersignature_as_ed25519( - it, _status) -} - } - ) - } - - override fun `asEd25519Opt`(): Ed25519Signature? { - return FfiConverterOptionalTypeEd25519Signature.lift( + /** + * Formats a name into a string based on the available output formats. + * The default separator is `.` + */override fun `format`(`format`: NameFormat): kotlin.String { + return FfiConverterString.lift( callWithPointer { uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigmembersignature_as_ed25519_opt( - it, _status) + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_name_format( + it, FfiConverterTypeNameFormat.lower(`format`),_status) } } ) } - override fun `asSecp256k1`(): Secp256k1Signature { - return FfiConverterTypeSecp256k1Signature.lift( - callWithPointer { - uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigmembersignature_as_secp256k1( - it, _status) -} - } - ) - } - - override fun `asSecp256k1Opt`(): Secp256k1Signature? { - return FfiConverterOptionalTypeSecp256k1Signature.lift( + /** + * Returns whether this name is a second-level name (Ex. `test.iota`) + */override fun `isSln`(): kotlin.Boolean { + return FfiConverterBoolean.lift( callWithPointer { uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigmembersignature_as_secp256k1_opt( + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_name_is_sln( it, _status) } } @@ -24560,23 +25442,14 @@ open class MultisigMemberSignature: Disposable, AutoCloseable, MultisigMemberSig } - override fun `asSecp256r1`(): Secp256r1Signature { - return FfiConverterTypeSecp256r1Signature.lift( - callWithPointer { - uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigmembersignature_as_secp256r1( - it, _status) -} - } - ) - } - - override fun `asSecp256r1Opt`(): Secp256r1Signature? { - return FfiConverterOptionalTypeSecp256r1Signature.lift( + /** + * Returns whether this name is a subname (Ex. `sub.test.iota`) + */override fun `isSubname`(): kotlin.Boolean { + return FfiConverterBoolean.lift( callWithPointer { uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigmembersignature_as_secp256r1_opt( + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_name_is_subname( it, _status) } } @@ -24584,23 +25457,30 @@ open class MultisigMemberSignature: Disposable, AutoCloseable, MultisigMemberSig } - override fun `asZklogin`(): ZkLoginAuthenticator { - return FfiConverterTypeZkLoginAuthenticator.lift( + + /** + * Get the label at the given index + */override fun `label`(`index`: kotlin.UInt): kotlin.String? { + return FfiConverterOptionalString.lift( callWithPointer { uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigmembersignature_as_zklogin( - it, _status) + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_name_label( + it, FfiConverterUInt.lower(`index`),_status) } } ) } - override fun `asZkloginOpt`(): ZkLoginAuthenticator? { - return FfiConverterOptionalTypeZkLoginAuthenticator.lift( + + /** + * Get all of the labels. NOTE: These are in reverse order starting with + * the top-level name and proceeding to subnames. + */override fun `labels`(): List { + return FfiConverterSequenceString.lift( callWithPointer { uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigmembersignature_as_zklogin_opt( + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_name_labels( it, _status) } } @@ -24608,11 +25488,14 @@ open class MultisigMemberSignature: Disposable, AutoCloseable, MultisigMemberSig } - override fun `isEd25519`(): kotlin.Boolean { - return FfiConverterBoolean.lift( + + /** + * Returns the number of labels including TLN. + */override fun `numLabels`(): kotlin.UInt { + return FfiConverterUInt.lift( callWithPointer { uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigmembersignature_is_ed25519( + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_name_num_labels( it, _status) } } @@ -24620,11 +25503,14 @@ open class MultisigMemberSignature: Disposable, AutoCloseable, MultisigMemberSig } - override fun `isSecp256k1`(): kotlin.Boolean { - return FfiConverterBoolean.lift( + + /** + * parents; second-level names return `None`. + */override fun `parent`(): Name? { + return FfiConverterOptionalTypeName.lift( callWithPointer { uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigmembersignature_is_secp256k1( + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_name_parent( it, _status) } } @@ -24632,60 +25518,48 @@ open class MultisigMemberSignature: Disposable, AutoCloseable, MultisigMemberSig } - override fun `isSecp256r1`(): kotlin.Boolean { - return FfiConverterBoolean.lift( - callWithPointer { - uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigmembersignature_is_secp256r1( - it, _status) -} - } - ) - } - override fun `isZklogin`(): kotlin.Boolean { - return FfiConverterBoolean.lift( - callWithPointer { - uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigmembersignature_is_zklogin( - it, _status) + + companion object { + + @Throws(SdkFfiException::class) fun `fromStr`(`s`: kotlin.String): Name { + return FfiConverterTypeName.lift( + uniffiRustCallWithError(SdkFfiException) { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_name_from_str( + FfiConverterString.lower(`s`),_status) } - } ) } - - - - - companion object + + } } /** * @suppress */ -public object FfiConverterTypeMultisigMemberSignature: FfiConverter { +public object FfiConverterTypeName: FfiConverter { - override fun lower(value: MultisigMemberSignature): Pointer { + override fun lower(value: Name): Pointer { return value.uniffiClonePointer() } - override fun lift(value: Pointer): MultisigMemberSignature { - return MultisigMemberSignature(value) + override fun lift(value: Pointer): Name { + return Name(value) } - override fun read(buf: ByteBuffer): MultisigMemberSignature { + override fun read(buf: ByteBuffer): Name { // 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: MultisigMemberSignature) = 8UL + override fun allocationSize(value: Name) = 8UL - override fun write(value: MultisigMemberSignature, buf: ByteBuffer) { + override fun write(value: Name, 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))) @@ -24791,18 +25665,26 @@ public object FfiConverterTypeMultisigMemberSignature: FfiConverter - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_multisigverifier_new( - _status) + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_nameregistration_new( + FfiConverterTypeObjectId.lower(`id`),FfiConverterTypeName.lower(`name`),FfiConverterString.lower(`nameStr`),FfiConverterULong.lower(`expirationTimestampMs`),_status) } ) @@ -24879,7 +25761,7 @@ open class MultisigVerifier: Disposable, AutoCloseable, MultisigVerifierInterfac override fun run() { pointer?.let { ptr -> uniffiRustCall { status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_free_multisigverifier(ptr, status) + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_free_nameregistration(ptr, status) } } } @@ -24887,39 +25769,51 @@ open class MultisigVerifier: Disposable, AutoCloseable, MultisigVerifierInterfac fun uniffiClonePointer(): Pointer { return uniffiRustCall() { status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_clone_multisigverifier(pointer!!, status) + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_clone_nameregistration(pointer!!, status) } } - - @Throws(SdkFfiException::class)override fun `verify`(`message`: kotlin.ByteArray, `signature`: MultisigAggregatedSignature) - = + override fun `expirationTimestampMs`(): kotlin.ULong { + return FfiConverterULong.lift( callWithPointer { - uniffiRustCallWithError(SdkFfiException) { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigverifier_verify( - it, FfiConverterByteArray.lower(`message`),FfiConverterTypeMultisigAggregatedSignature.lower(`signature`),_status) + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_nameregistration_expiration_timestamp_ms( + it, _status) } } + ) + } + + override fun `id`(): ObjectId { + return FfiConverterTypeObjectId.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_nameregistration_id( + it, _status) +} + } + ) + } - override fun `withZkloginVerifier`(`zkloginVerifier`: ZkloginVerifier): MultisigVerifier { - return FfiConverterTypeMultisigVerifier.lift( + override fun `name`(): Name { + return FfiConverterTypeName.lift( callWithPointer { uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigverifier_with_zklogin_verifier( - it, FfiConverterTypeZkloginVerifier.lower(`zkloginVerifier`),_status) + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_nameregistration_name( + it, _status) } } ) } - override fun `zkloginVerifier`(): ZkloginVerifier? { - return FfiConverterOptionalTypeZkloginVerifier.lift( + override fun `nameStr`(): kotlin.String { + return FfiConverterString.lift( callWithPointer { uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigverifier_zklogin_verifier( + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_nameregistration_name_str( it, _status) } } @@ -24938,25 +25832,25 @@ open class MultisigVerifier: Disposable, AutoCloseable, MultisigVerifierInterfac /** * @suppress */ -public object FfiConverterTypeMultisigVerifier: FfiConverter { +public object FfiConverterTypeNameRegistration: FfiConverter { - override fun lower(value: MultisigVerifier): Pointer { + override fun lower(value: NameRegistration): Pointer { return value.uniffiClonePointer() } - override fun lift(value: Pointer): MultisigVerifier { - return MultisigVerifier(value) + override fun lift(value: Pointer): NameRegistration { + return NameRegistration(value) } - override fun read(buf: ByteBuffer): MultisigVerifier { + override fun read(buf: ByteBuffer): NameRegistration { // 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: MultisigVerifier) = 8UL + override fun allocationSize(value: NameRegistration) = 8UL - override fun write(value: MultisigVerifier, buf: ByteBuffer) { + override fun write(value: NameRegistration, 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))) @@ -44396,6 +45290,57 @@ public object FfiConverterTypeMoveStructTypeParameter: FfiConverterRustBuffer +) : Disposable { + + @Suppress("UNNECESSARY_SAFE_CALL") // codegen is much simpler if we unconditionally emit safe calls here + override fun destroy() { + + Disposable.destroy( + this.`pageInfo`, + this.`data` + ) + } + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeNameRegistrationPage: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): NameRegistrationPage { + return NameRegistrationPage( + FfiConverterTypePageInfo.read(buf), + FfiConverterSequenceTypeNameRegistration.read(buf), + ) + } + + override fun allocationSize(value: NameRegistrationPage) = ( + FfiConverterTypePageInfo.allocationSize(value.`pageInfo`) + + FfiConverterSequenceTypeNameRegistration.allocationSize(value.`data`) + ) + + override fun write(value: NameRegistrationPage, buf: ByteBuffer) { + FfiConverterTypePageInfo.write(value.`pageInfo`, buf) + FfiConverterSequenceTypeNameRegistration.write(value.`data`, buf) + } +} + + + data class ObjectFilter ( var `typeTag`: kotlin.String?, var `owner`: Address?, @@ -48012,6 +48957,40 @@ public object FfiConverterTypeMoveVisibility: FfiConverterRustBuffer `test@example` | `Dot` -> `test.example.iota` + */ + +enum class NameFormat { + + AT, + DOT; + companion object +} + + +/** + * @suppress + */ +public object FfiConverterTypeNameFormat: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + NameFormat.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: NameFormat) = 4UL + + override fun write(value: NameFormat, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + /** * State of an object prior to execution * @@ -49512,6 +50491,38 @@ public object FfiConverterOptionalTypeMultisigAggregatedSignature: FfiConverterR +/** + * @suppress + */ +public object FfiConverterOptionalTypeName: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Name? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterTypeName.read(buf) + } + + override fun allocationSize(value: Name?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterTypeName.allocationSize(value) + } + } + + override fun write(value: Name?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterTypeName.write(value, buf) + } + } +} + + + + /** * @suppress */ @@ -50600,6 +51611,38 @@ public object FfiConverterOptionalTypeMoveVisibility: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): NameFormat? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterTypeNameFormat.read(buf) + } + + override fun allocationSize(value: NameFormat?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterTypeNameFormat.allocationSize(value) + } + } + + override fun write(value: NameFormat?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterTypeNameFormat.write(value, buf) + } + } +} + + + + /** * @suppress */ @@ -51548,6 +52591,34 @@ public object FfiConverterSequenceTypeMultisigMemberSignature: FfiConverterRustB +/** + * @suppress + */ +public object FfiConverterSequenceTypeNameRegistration: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeNameRegistration.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeNameRegistration.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeNameRegistration.write(it, buf) + } + } +} + + + + /** * @suppress */ diff --git a/bindings/python/lib/iota_sdk_ffi.py b/bindings/python/lib/iota_sdk_ffi.py index 9c3a8f378..4efdb2da1 100644 --- a/bindings/python/lib/iota_sdk_ffi.py +++ b/bindings/python/lib/iota_sdk_ffi.py @@ -681,6 +681,12 @@ 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_execute_tx() != 41079: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_default_name() != 55795: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_lookup() != 26177: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_registrations() != 58110: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_latest_checkpoint_sequence_number() != 40336: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_max_page_size() != 44733: @@ -837,6 +843,28 @@ 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_multisigverifier_zklogin_verifier() != 5971: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_name_format() != 66: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_name_is_sln() != 9860: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_name_is_subname() != 22382: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_name_label() != 9695: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_name_labels() != 44675: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_name_num_labels() != 62037: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_name_parent() != 40819: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_nameregistration_expiration_timestamp_ms() != 13855: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_nameregistration_id() != 17049: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_nameregistration_name() != 16565: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_nameregistration_name_str() != 19903: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_object_as_struct() != 37303: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_object_data() != 4330: @@ -1477,6 +1505,10 @@ 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_multisigverifier_new() != 53197: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_constructor_name_from_str() != 30248: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_constructor_nameregistration_new() != 19327: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_object_new() != 41346: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_objectdata_new_move_package() != 5274: @@ -3155,6 +3187,23 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): ctypes.c_void_p, ) _UniffiLib.uniffi_iota_sdk_ffi_fn_method_graphqlclient_execute_tx.restype = ctypes.c_uint64 +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_default_name.argtypes = ( + ctypes.c_void_p, + ctypes.c_void_p, + _UniffiRustBuffer, +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_default_name.restype = ctypes.c_uint64 +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_lookup.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_lookup.restype = ctypes.c_uint64 +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_registrations.argtypes = ( + ctypes.c_void_p, + ctypes.c_void_p, + _UniffiRustBuffer, +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_registrations.restype = ctypes.c_uint64 _UniffiLib.uniffi_iota_sdk_ffi_fn_method_graphqlclient_latest_checkpoint_sequence_number.argtypes = ( ctypes.c_void_p, ) @@ -3795,6 +3844,96 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_iota_sdk_ffi_fn_method_multisigverifier_zklogin_verifier.restype = _UniffiRustBuffer +_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_name.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_name.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_free_name.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_free_name.restype = None +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_name_from_str.argtypes = ( + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_name_from_str.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_name_format.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_name_format.restype = _UniffiRustBuffer +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_name_is_sln.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_name_is_sln.restype = ctypes.c_int8 +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_name_is_subname.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_name_is_subname.restype = ctypes.c_int8 +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_name_label.argtypes = ( + ctypes.c_void_p, + ctypes.c_uint32, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_name_label.restype = _UniffiRustBuffer +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_name_labels.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_name_labels.restype = _UniffiRustBuffer +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_name_num_labels.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_name_num_labels.restype = ctypes.c_uint32 +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_name_parent.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_name_parent.restype = _UniffiRustBuffer +_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_nameregistration.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_nameregistration.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_free_nameregistration.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_free_nameregistration.restype = None +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_nameregistration_new.argtypes = ( + ctypes.c_void_p, + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_nameregistration_new.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_nameregistration_expiration_timestamp_ms.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_nameregistration_expiration_timestamp_ms.restype = ctypes.c_uint64 +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_nameregistration_id.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_nameregistration_id.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_nameregistration_name.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_nameregistration_name.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_nameregistration_name_str.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_nameregistration_name_str.restype = _UniffiRustBuffer _UniffiLib.uniffi_iota_sdk_ffi_fn_clone_object.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), @@ -6670,6 +6809,15 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_execute_tx.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_execute_tx.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_default_name.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_default_name.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_lookup.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_lookup.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_registrations.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_registrations.restype = ctypes.c_uint16 _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_latest_checkpoint_sequence_number.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_latest_checkpoint_sequence_number.restype = ctypes.c_uint16 @@ -6904,6 +7052,39 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_multisigverifier_zklogin_verifier.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_multisigverifier_zklogin_verifier.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_name_format.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_name_format.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_name_is_sln.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_name_is_sln.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_name_is_subname.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_name_is_subname.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_name_label.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_name_label.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_name_labels.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_name_labels.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_name_num_labels.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_name_num_labels.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_name_parent.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_name_parent.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_nameregistration_expiration_timestamp_ms.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_nameregistration_expiration_timestamp_ms.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_nameregistration_id.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_nameregistration_id.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_nameregistration_name.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_nameregistration_name.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_nameregistration_name_str.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_nameregistration_name_str.restype = ctypes.c_uint16 _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_object_as_struct.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_object_as_struct.restype = ctypes.c_uint16 @@ -7864,6 +8045,12 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_multisigverifier_new.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_multisigverifier_new.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_name_from_str.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_name_from_str.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_nameregistration_new.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_nameregistration_new.restype = ctypes.c_uint16 _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_object_new.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_object_new.restype = ctypes.c_uint16 @@ -8571,6 +8758,10 @@ def write(value, buf): + + + + @@ -10931,6 +11122,55 @@ def write(value, buf): _UniffiConverterBool.write(value.is_phantom, buf) +class NameRegistrationPage: + """ + A page of items returned by the GraphQL server. + """ + + page_info: "PageInfo" + """ + Information about the page, such as the cursor and whether there are + more pages. + """ + + data: "typing.List[NameRegistration]" + """ + The data returned by the server. + """ + + def __init__(self, *, page_info: "PageInfo", data: "typing.List[NameRegistration]"): + self.page_info = page_info + self.data = data + + def __str__(self): + return "NameRegistrationPage(page_info={}, data={})".format(self.page_info, self.data) + + def __eq__(self, other): + if self.page_info != other.page_info: + return False + if self.data != other.data: + return False + return True + +class _UniffiConverterTypeNameRegistrationPage(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return NameRegistrationPage( + page_info=_UniffiConverterTypePageInfo.read(buf), + data=_UniffiConverterSequenceTypeNameRegistration.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiConverterTypePageInfo.check_lower(value.page_info) + _UniffiConverterSequenceTypeNameRegistration.check_lower(value.data) + + @staticmethod + def write(value, buf): + _UniffiConverterTypePageInfo.write(value.page_info, buf) + _UniffiConverterSequenceTypeNameRegistration.write(value.data, buf) + + class ObjectFilter: type_tag: "typing.Optional[str]" owner: "typing.Optional[Address]" @@ -15395,6 +15635,49 @@ def write(value, buf): +class NameFormat(enum.Enum): + """ + Two different view options for a name. + `At` -> `test@example` | `Dot` -> `test.example.iota` + """ + + AT = 0 + + DOT = 1 + + + +class _UniffiConverterTypeNameFormat(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return NameFormat.AT + if variant == 2: + return NameFormat.DOT + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value == NameFormat.AT: + return + if value == NameFormat.DOT: + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value == NameFormat.AT: + buf.write_i32(1) + if value == NameFormat.DOT: + buf.write_i32(2) + + + + + + + class ObjectIn: """ State of an object prior to execution @@ -17057,6 +17340,33 @@ def read(cls, buf): +class _UniffiConverterOptionalTypeName(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiConverterTypeName.check_lower(value) + + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return + + buf.write_u8(1) + _UniffiConverterTypeName.write(value, buf) + + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiConverterTypeName.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") + + + class _UniffiConverterOptionalTypeObject(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): @@ -17975,6 +18285,33 @@ def read(cls, buf): +class _UniffiConverterOptionalTypeNameFormat(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiConverterTypeNameFormat.check_lower(value) + + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return + + buf.write_u8(1) + _UniffiConverterTypeNameFormat.write(value, buf) + + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiConverterTypeNameFormat.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") + + + class _UniffiConverterOptionalTypeTransactionBlockKindInput(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): @@ -18801,6 +19138,31 @@ def read(cls, buf): +class _UniffiConverterSequenceTypeNameRegistration(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiConverterTypeNameRegistration.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiConverterTypeNameRegistration.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiConverterTypeNameRegistration.read(buf) for i in range(count) + ] + + + class _UniffiConverterSequenceTypeObject(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): @@ -25073,6 +25435,12 @@ def execute_tx(self, signatures: "typing.List[UserSignature]",tx: "Transaction") Execute a transaction. """ + raise NotImplementedError + def iota_names_default_name(self, address: "Address",format: "typing.Optional[NameFormat]"): + raise NotImplementedError + def iota_names_lookup(self, name: "str"): + raise NotImplementedError + def iota_names_registrations(self, address: "Address",pagination_filter: "PaginationFilter"): raise NotImplementedError def latest_checkpoint_sequence_number(self, ): """ @@ -25923,6 +26291,75 @@ async def execute_tx(self, signatures: "typing.List[UserSignature]",tx: "Transac + async def iota_names_default_name(self, address: "Address",format: "typing.Optional[NameFormat]") -> "typing.Optional[Name]": + _UniffiConverterTypeAddress.check_lower(address) + + _UniffiConverterOptionalTypeNameFormat.check_lower(format) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_default_name( + self._uniffi_clone_pointer(), + _UniffiConverterTypeAddress.lower(address), + _UniffiConverterOptionalTypeNameFormat.lower(format) + ), + _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 + _UniffiConverterOptionalTypeName.lift, + + # Error FFI converter +_UniffiConverterTypeSdkFfiError, + + ) + + + + async def iota_names_lookup(self, name: "str") -> "typing.Optional[Address]": + _UniffiConverterString.check_lower(name) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_lookup( + self._uniffi_clone_pointer(), + _UniffiConverterString.lower(name) + ), + _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 + _UniffiConverterOptionalTypeAddress.lift, + + # Error FFI converter +_UniffiConverterTypeSdkFfiError, + + ) + + + + async def iota_names_registrations(self, address: "Address",pagination_filter: "PaginationFilter") -> "NameRegistrationPage": + _UniffiConverterTypeAddress.check_lower(address) + + _UniffiConverterTypePaginationFilter.check_lower(pagination_filter) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_registrations( + self._uniffi_clone_pointer(), + _UniffiConverterTypeAddress.lower(address), + _UniffiConverterTypePaginationFilter.lower(pagination_filter) + ), + _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 + _UniffiConverterTypeNameRegistrationPage.lift, + + # Error FFI converter +_UniffiConverterTypeSdkFfiError, + + ) + + + async def latest_checkpoint_sequence_number(self, ) -> "typing.Optional[int]": """ Return the sequence number of the latest checkpoint that has been @@ -28876,6 +29313,331 @@ def read(cls, buf: _UniffiRustBuffer): @classmethod def write(cls, value: MultisigVerifierProtocol, buf: _UniffiRustBuffer): buf.write_u64(cls.lower(value)) +class NameProtocol(typing.Protocol): + def format(self, format: "NameFormat"): + """ + Formats a name into a string based on the available output formats. + The default separator is `.` + """ + + raise NotImplementedError + def is_sln(self, ): + """ + Returns whether this name is a second-level name (Ex. `test.iota`) + """ + + raise NotImplementedError + def is_subname(self, ): + """ + Returns whether this name is a subname (Ex. `sub.test.iota`) + """ + + raise NotImplementedError + def label(self, index: "int"): + """ + Get the label at the given index + """ + + raise NotImplementedError + def labels(self, ): + """ + Get all of the labels. NOTE: These are in reverse order starting with + the top-level name and proceeding to subnames. + """ + + raise NotImplementedError + def num_labels(self, ): + """ + Returns the number of labels including TLN. + """ + + raise NotImplementedError + def parent(self, ): + """ + parents; second-level names return `None`. + """ + + raise NotImplementedError +# Name is a Rust-only trait - it's a wrapper around a Rust implementation. +class Name(): + _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_name, pointer) + + def _uniffi_clone_pointer(self): + return _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_name, 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 from_str(cls, s: "str"): + _UniffiConverterString.check_lower(s) + + # 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_name_from_str, + _UniffiConverterString.lower(s)) + return cls._make_instance_(pointer) + + + + def format(self, format: "NameFormat") -> "str": + """ + Formats a name into a string based on the available output formats. + The default separator is `.` + """ + + _UniffiConverterTypeNameFormat.check_lower(format) + + return _UniffiConverterString.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_name_format,self._uniffi_clone_pointer(), + _UniffiConverterTypeNameFormat.lower(format)) + ) + + + + + + def is_sln(self, ) -> "bool": + """ + Returns whether this name is a second-level name (Ex. `test.iota`) + """ + + return _UniffiConverterBool.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_name_is_sln,self._uniffi_clone_pointer(),) + ) + + + + + + def is_subname(self, ) -> "bool": + """ + Returns whether this name is a subname (Ex. `sub.test.iota`) + """ + + return _UniffiConverterBool.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_name_is_subname,self._uniffi_clone_pointer(),) + ) + + + + + + def label(self, index: "int") -> "typing.Optional[str]": + """ + Get the label at the given index + """ + + _UniffiConverterUInt32.check_lower(index) + + return _UniffiConverterOptionalString.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_name_label,self._uniffi_clone_pointer(), + _UniffiConverterUInt32.lower(index)) + ) + + + + + + def labels(self, ) -> "typing.List[str]": + """ + Get all of the labels. NOTE: These are in reverse order starting with + the top-level name and proceeding to subnames. + """ + + return _UniffiConverterSequenceString.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_name_labels,self._uniffi_clone_pointer(),) + ) + + + + + + def num_labels(self, ) -> "int": + """ + Returns the number of labels including TLN. + """ + + return _UniffiConverterUInt32.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_name_num_labels,self._uniffi_clone_pointer(),) + ) + + + + + + def parent(self, ) -> "typing.Optional[Name]": + """ + parents; second-level names return `None`. + """ + + return _UniffiConverterOptionalTypeName.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_name_parent,self._uniffi_clone_pointer(),) + ) + + + + + + +class _UniffiConverterTypeName: + + @staticmethod + def lift(value: int): + return Name._make_instance_(value) + + @staticmethod + def check_lower(value: Name): + if not isinstance(value, Name): + raise TypeError("Expected Name instance, {} found".format(type(value).__name__)) + + @staticmethod + def lower(value: NameProtocol): + if not isinstance(value, Name): + raise TypeError("Expected Name 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: NameProtocol, buf: _UniffiRustBuffer): + buf.write_u64(cls.lower(value)) +class NameRegistrationProtocol(typing.Protocol): + """ + An object to manage a second-level name (SLN). + """ + + def expiration_timestamp_ms(self, ): + raise NotImplementedError + def id(self, ): + raise NotImplementedError + def name(self, ): + raise NotImplementedError + def name_str(self, ): + raise NotImplementedError +# NameRegistration is a Rust-only trait - it's a wrapper around a Rust implementation. +class NameRegistration(): + """ + An object to manage a second-level name (SLN). + """ + + _pointer: ctypes.c_void_p + def __init__(self, id: "ObjectId",name: "Name",name_str: "str",expiration_timestamp_ms: "int"): + _UniffiConverterTypeObjectId.check_lower(id) + + _UniffiConverterTypeName.check_lower(name) + + _UniffiConverterString.check_lower(name_str) + + _UniffiConverterUInt64.check_lower(expiration_timestamp_ms) + + self._pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_nameregistration_new, + _UniffiConverterTypeObjectId.lower(id), + _UniffiConverterTypeName.lower(name), + _UniffiConverterString.lower(name_str), + _UniffiConverterUInt64.lower(expiration_timestamp_ms)) + + 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_nameregistration, pointer) + + def _uniffi_clone_pointer(self): + return _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_nameregistration, 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 + + + def expiration_timestamp_ms(self, ) -> "int": + return _UniffiConverterUInt64.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_nameregistration_expiration_timestamp_ms,self._uniffi_clone_pointer(),) + ) + + + + + + def id(self, ) -> "ObjectId": + return _UniffiConverterTypeObjectId.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_nameregistration_id,self._uniffi_clone_pointer(),) + ) + + + + + + def name(self, ) -> "Name": + return _UniffiConverterTypeName.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_nameregistration_name,self._uniffi_clone_pointer(),) + ) + + + + + + def name_str(self, ) -> "str": + return _UniffiConverterString.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_nameregistration_name_str,self._uniffi_clone_pointer(),) + ) + + + + + + +class _UniffiConverterTypeNameRegistration: + + @staticmethod + def lift(value: int): + return NameRegistration._make_instance_(value) + + @staticmethod + def check_lower(value: NameRegistration): + if not isinstance(value, NameRegistration): + raise TypeError("Expected NameRegistration instance, {} found".format(type(value).__name__)) + + @staticmethod + def lower(value: NameRegistrationProtocol): + if not isinstance(value, NameRegistration): + raise TypeError("Expected NameRegistration 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: NameRegistrationProtocol, buf: _UniffiRustBuffer): + buf.write_u64(cls.lower(value)) class ObjectProtocol(typing.Protocol): """ An object on the IOTA blockchain @@ -37408,6 +38170,7 @@ async def _uniffi_rust_call_async(rust_future, ffi_poll, ffi_complete, ffi_free, "IdOperation", "MoveAbility", "MoveVisibility", + "NameFormat", "ObjectIn", "ObjectOut", "PackageUpgradeError", @@ -37458,6 +38221,7 @@ async def _uniffi_rust_call_async(rust_future, ffi_poll, ffi_complete, ffi_free, "MoveStructConnection", "MoveStructQuery", "MoveStructTypeParameter", + "NameRegistrationPage", "ObjectFilter", "ObjectPage", "ObjectRef", @@ -37539,6 +38303,8 @@ async def _uniffi_rust_call_async(rust_future, ffi_poll, ffi_complete, ffi_free, "MultisigMemberPublicKey", "MultisigMemberSignature", "MultisigVerifier", + "Name", + "NameRegistration", "Object", "ObjectData", "ObjectId", diff --git a/crates/iota-graphql-client/src/lib.rs b/crates/iota-graphql-client/src/lib.rs index 24b4ab0f4..1b9e05eb4 100644 --- a/crates/iota-graphql-client/src/lib.rs +++ b/crates/iota-graphql-client/src/lib.rs @@ -19,7 +19,9 @@ use futures::Stream; use iota_types::{ Address, CheckpointSequenceNumber, CheckpointSummary, Digest, Event, Identifier, MovePackage, Object, ObjectId, SignedTransaction, Transaction, TransactionEffects, TransactionKind, TypeTag, - UserSignature, framework::Coin, + UserSignature, + framework::Coin, + iota_names::{NameFormat, NameRegistration, name::Name}, }; use query_types::{ ActiveValidatorsArgs, ActiveValidatorsQuery, BalanceArgs, BalanceQuery, ChainIdentifierQuery, @@ -46,7 +48,11 @@ use crate::{ error::{Kind, Result}, pagination::{Direction, Page, PaginationFilter, PaginationFilterResponse}, query_types::{ - CheckpointTotalTxQuery, TransactionBlockWithEffectsQuery, TransactionBlocksWithEffectsQuery, + CheckpointTotalTxQuery, IotaNamesAddressDefaultNameQuery, + IotaNamesAddressRegistrationsQuery, IotaNamesDefaultNameArgs, IotaNamesDefaultNameQuery, + IotaNamesRegistrationsArgs, IotaNamesRegistrationsQuery, ResolveIotaNamesAddressArgs, + ResolveIotaNamesAddressQuery, TransactionBlockWithEffectsQuery, + TransactionBlocksWithEffectsQuery, }, }; @@ -1740,6 +1746,100 @@ impl Client { .collect::>>()?, )) } + + pub async fn iota_names_lookup(&self, name: &str) -> Result> { + let operation = ResolveIotaNamesAddressQuery::build(ResolveIotaNamesAddressArgs { + name: name.to_owned(), + }); + let response = self.run_query(&operation).await?; + + if let Some(errors) = response.errors { + return Err(Error::graphql_error(errors)); + } + + let Some(ResolveIotaNamesAddressQuery { + resolve_iota_names_address: Some(address), + }) = response.data + else { + return Ok(None); + }; + + Ok(Some(address.address)) + } + + pub async fn iota_names_registrations( + &self, + address: Address, + pagination_filter: PaginationFilter, + ) -> Result> { + let PaginationFilterResponse { + after, + before, + first, + last, + } = self.pagination_filter(pagination_filter).await; + let operation = IotaNamesAddressRegistrationsQuery::build(IotaNamesRegistrationsArgs { + address, + after, + before, + first, + last, + }); + let response = self.run_query(&operation).await?; + + if let Some(errors) = response.errors { + return Err(Error::graphql_error(errors)); + } + + let Some(IotaNamesAddressRegistrationsQuery { + address: + Some(IotaNamesRegistrationsQuery { + iota_names_registrations, + }), + }) = response.data + else { + return Ok(Page::new_empty()); + }; + + Ok(Page::new( + iota_names_registrations.page_info, + iota_names_registrations + .nodes + .into_iter() + .map(TryInto::try_into) + .collect::>>()?, + )) + } + + pub async fn iota_names_default_name( + &self, + address: Address, + format: impl Into>, + ) -> Result> { + let operation = IotaNamesAddressDefaultNameQuery::build(IotaNamesDefaultNameArgs { + address, + format: format.into().map(Into::into), + }); + let response = self.run_query(&operation).await?; + + if let Some(errors) = response.errors { + return Err(Error::graphql_error(errors)); + } + + let Some(IotaNamesAddressDefaultNameQuery { + address: + Some(IotaNamesDefaultNameQuery { + iota_names_default_name: Some(name), + }), + }) = response.data + else { + return Ok(None); + }; + + Ok(Some(Name::from_str(&name).map_err(|_| { + Error::from_error(Kind::Parse, format!("invalid name: {name}")) + })?)) + } } // This function is used in tests to create a new client instance for the local diff --git a/crates/iota-graphql-client/src/query_types/iota_names.rs b/crates/iota-graphql-client/src/query_types/iota_names.rs new file mode 100644 index 000000000..8cbfb9aa6 --- /dev/null +++ b/crates/iota-graphql-client/src/query_types/iota_names.rs @@ -0,0 +1,134 @@ +// Copyright (c) 2025 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use base64ct::Encoding; + +use crate::{ + error::Error, + query_types::{Address, Base64, GQLAddress, PageInfo, schema}, +}; + +#[derive(cynic::QueryFragment, Debug)] +#[cynic( + schema = "rpc", + graphql_type = "Query", + variables = "ResolveIotaNamesAddressArgs" +)] +pub struct ResolveIotaNamesAddressQuery { + #[arguments(name: $name)] + pub resolve_iota_names_address: Option, +} + +#[derive(cynic::QueryVariables, Debug)] +pub struct ResolveIotaNamesAddressArgs { + pub name: String, +} + +#[derive(cynic::QueryFragment, Debug)] +#[cynic( + schema = "rpc", + graphql_type = "Query", + variables = "IotaNamesRegistrationsArgs" +)] +pub struct IotaNamesAddressRegistrationsQuery { + #[arguments(address: $address)] + pub address: Option, +} + +#[derive(cynic::QueryFragment, Debug)] +#[cynic( + schema = "rpc", + graphql_type = "Query", + variables = "IotaNamesDefaultNameArgs" +)] +pub struct IotaNamesAddressDefaultNameQuery { + #[arguments(address: $address)] + pub address: Option, +} + +#[derive(cynic::QueryFragment, Debug)] +#[cynic( + schema = "rpc", + graphql_type = "Address", + variables = "IotaNamesRegistrationsArgs" +)] +pub struct IotaNamesRegistrationsQuery { + #[arguments(after: $after, before: $before, first: $first, last: $last)] + pub iota_names_registrations: NameRegistrationConnection, +} + +#[derive(cynic::QueryVariables, Debug)] +pub struct IotaNamesRegistrationsArgs { + pub address: Address, + pub after: Option, + pub before: Option, + pub first: Option, + pub last: Option, +} + +#[derive(cynic::QueryFragment, Debug)] +#[cynic( + schema = "rpc", + graphql_type = "Address", + variables = "IotaNamesDefaultNameArgs" +)] +pub struct IotaNamesDefaultNameQuery { + #[arguments(format: $format)] + pub iota_names_default_name: Option, +} + +#[derive(cynic::QueryVariables, Debug)] +pub struct IotaNamesDefaultNameArgs { + pub address: Address, + pub format: Option, +} + +#[derive(cynic::QueryFragment, Debug)] +#[cynic(schema = "rpc", graphql_type = "NameRegistrationConnection")] +pub struct NameRegistrationConnection { + pub page_info: PageInfo, + pub nodes: Vec, +} + +#[derive(cynic::QueryFragment, Debug)] +#[cynic(schema = "rpc", graphql_type = "NameRegistration")] +pub struct NameRegistration { + pub bcs: Option, +} + +impl TryFrom for iota_types::iota_names::NameRegistration { + type Error = Error; + + fn try_from(value: NameRegistration) -> Result { + let bytes = base64ct::Base64::decode_vec( + value + .bcs + .ok_or_else(|| { + Error::from_error(crate::error::Kind::Deserialization, "bcs is missing") + })? + .0 + .as_str(), + )?; + Ok(bcs::from_bytes(&bytes)?) + } +} + +#[derive(cynic::Enum, Debug, Clone, Copy)] +#[cynic( + schema = "rpc", + graphql_type = "NameFormat", + rename_all = "SCREAMING_SNAKE_CASE" +)] +pub enum NameFormat { + At, + Dot, +} + +impl From for NameFormat { + fn from(value: iota_types::iota_names::NameFormat) -> Self { + match value { + iota_types::iota_names::NameFormat::At => NameFormat::At, + iota_types::iota_names::NameFormat::Dot => NameFormat::Dot, + } + } +} diff --git a/crates/iota-graphql-client/src/query_types/mod.rs b/crates/iota-graphql-client/src/query_types/mod.rs index 99e687a6a..9d07c257d 100644 --- a/crates/iota-graphql-client/src/query_types/mod.rs +++ b/crates/iota-graphql-client/src/query_types/mod.rs @@ -12,6 +12,7 @@ mod dynamic_fields; mod epoch; mod events; mod execute_tx; +mod iota_names; mod normalized_move; mod object; mod packages; @@ -39,6 +40,12 @@ pub use dynamic_fields::{ pub use epoch::{Epoch, EpochArgs, EpochQuery, EpochSummaryQuery}; pub use events::{Event, EventConnection, EventFilter, EventsQuery, EventsQueryArgs}; pub use execute_tx::{ExecuteTransactionArgs, ExecuteTransactionQuery, ExecutionResult}; +pub use iota_names::{ + IotaNamesAddressDefaultNameQuery, IotaNamesAddressRegistrationsQuery, IotaNamesDefaultNameArgs, + IotaNamesDefaultNameQuery, IotaNamesRegistrationsArgs, IotaNamesRegistrationsQuery, + NameRegistration, NameRegistrationConnection, ResolveIotaNamesAddressArgs, + ResolveIotaNamesAddressQuery, +}; use iota_types::{Address, ObjectId}; pub use normalized_move::{ MoveAbility, MoveEnum, MoveEnumConnection, MoveEnumVariant, MoveField, MoveFunction, diff --git a/crates/iota-sdk-ffi/src/graphql.rs b/crates/iota-sdk-ffi/src/graphql.rs index d3d7e9649..6fcbaf319 100644 --- a/crates/iota-sdk-ffi/src/graphql.rs +++ b/crates/iota-sdk-ffi/src/graphql.rs @@ -1,13 +1,13 @@ // Copyright (c) 2025 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use std::sync::Arc; +use std::{str::FromStr, sync::Arc}; use iota_graphql_client::{ pagination::PaginationFilter, query_types::{MoveFunction, ProtocolConfigs, ServiceConfig}, }; -use iota_types::CheckpointSequenceNumber; +use iota_types::{CheckpointSequenceNumber, iota_names::NameFormat}; use tokio::sync::RwLock; use crate::{ @@ -20,6 +20,7 @@ use crate::{ CoinMetadata, DryRunResult, DynamicFieldOutput, Epoch, EventFilter, MoveModule, ObjectFilter, TransactionDataEffects, TransactionMetadata, TransactionsFilter, }, + iota_names::Name, object::{MovePackage, Object, ObjectId}, signature::UserSignature, transaction::{SignedTransaction, Transaction, TransactionEffects, TransactionKind}, @@ -27,8 +28,8 @@ use crate::{ }, uniffi_helpers::{ CheckpointSummaryPage, CoinPage, DynamicFieldOutputPage, EpochPage, EventPage, - MovePackagePage, ObjectPage, SignedTransactionPage, TransactionDataEffectsPage, - TransactionEffectsPage, ValidatorPage, + MovePackagePage, NameRegistrationPage, ObjectPage, SignedTransactionPage, + TransactionDataEffectsPage, TransactionEffectsPage, ValidatorPage, }, }; @@ -830,4 +831,45 @@ impl GraphQLClient { ) -> Result> { Ok(self.0.read().await.balance(**address, coin_type).await?) } + + pub async fn iota_names_lookup(&self, name: &str) -> Result>> { + Ok(self + .0 + .read() + .await + .iota_names_lookup(name) + .await? + .map(Into::into) + .map(Arc::new)) + } + + pub async fn iota_names_registrations( + &self, + address: &Address, + pagination_filter: PaginationFilter, + ) -> Result { + Ok(self + .0 + .read() + .await + .iota_names_registrations(**address, pagination_filter) + .await? + .map(Into::into) + .into()) + } + + pub async fn iota_names_default_name( + &self, + address: &Address, + format: Option, + ) -> Result>> { + Ok(self + .0 + .read() + .await + .iota_names_default_name(**address, format) + .await? + .map(Into::into) + .map(Arc::new)) + } } diff --git a/crates/iota-sdk-ffi/src/types/iota_names.rs b/crates/iota-sdk-ffi/src/types/iota_names.rs new file mode 100644 index 000000000..dd8fab1b1 --- /dev/null +++ b/crates/iota-sdk-ffi/src/types/iota_names.rs @@ -0,0 +1,99 @@ +// Copyright (c) 2025 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::{str::FromStr, sync::Arc}; + +use iota_types::iota_names::{IotaNamesNft, NameFormat}; + +use crate::{error::Result, types::object::ObjectId}; + +/// An object to manage a second-level name (SLN). +#[derive(derive_more::From, uniffi::Object)] +pub struct NameRegistration(iota_types::iota_names::NameRegistration); + +#[uniffi::export] +impl NameRegistration { + #[uniffi::constructor] + pub fn new(id: &ObjectId, name: &Name, name_str: String, expiration_timestamp_ms: u64) -> Self { + Self(iota_types::iota_names::NameRegistration::new( + **id, + name.0.clone(), + name_str, + expiration_timestamp_ms, + )) + } + + pub fn id(&self) -> ObjectId { + self.0.id().into() + } + + pub fn name(&self) -> Name { + self.0.name().clone().into() + } + + pub fn name_str(&self) -> String { + self.0.name_str().to_owned() + } + + pub fn expiration_timestamp_ms(&self) -> u64 { + iota_types::iota_names::NameRegistration::MODULE; + self.0.expiration_timestamp_ms() + } +} + +#[derive(derive_more::From, uniffi::Object)] +pub struct Name(iota_types::iota_names::Name); + +#[uniffi::export] +impl Name { + #[uniffi::constructor] + pub fn from_str(s: &str) -> Result { + Ok(iota_types::iota_names::Name::from_str(s)?.into()) + } + + // Derive the parent name for a given name. Only subnames have + /// parents; second-level names return `None`. + pub fn parent(&self) -> Option> { + self.0.parent().map(Into::into).map(Arc::new) + } + + /// Returns whether this name is a second-level name (Ex. `test.iota`) + pub fn is_sln(&self) -> bool { + self.num_labels() == 2 + } + + /// Returns whether this name is a subname (Ex. `sub.test.iota`) + pub fn is_subname(&self) -> bool { + self.num_labels() >= 3 + } + + /// Returns the number of labels including TLN. + pub fn num_labels(&self) -> u32 { + self.0.num_labels() as _ + } + + /// Get the label at the given index + pub fn label(&self, index: u32) -> Option { + self.0.label(index as _).cloned() + } + + /// Get all of the labels. NOTE: These are in reverse order starting with + /// the top-level name and proceeding to subnames. + pub fn labels(&self) -> Vec { + self.0.labels().to_vec() + } + + /// Formats a name into a string based on the available output formats. + /// The default separator is `.` + pub fn format(&self, format: NameFormat) -> String { + self.0.format(format) + } +} + +/// Two different view options for a name. +/// `At` -> `test@example` | `Dot` -> `test.example.iota` +#[uniffi::remote(Enum)] +pub enum NameFormat { + At, + Dot, +} diff --git a/crates/iota-sdk-ffi/src/types/mod.rs b/crates/iota-sdk-ffi/src/types/mod.rs index 74f037fc4..85e40d2fb 100644 --- a/crates/iota-sdk-ffi/src/types/mod.rs +++ b/crates/iota-sdk-ffi/src/types/mod.rs @@ -12,6 +12,7 @@ pub mod events; pub mod execution_status; pub mod gas; pub mod graphql; +pub mod iota_names; pub mod object; pub mod signature; pub mod struct_tag; diff --git a/crates/iota-sdk-ffi/src/uniffi_helpers.rs b/crates/iota-sdk-ffi/src/uniffi_helpers.rs index b26bebc2a..e6ec7c7b7 100644 --- a/crates/iota-sdk-ffi/src/uniffi_helpers.rs +++ b/crates/iota-sdk-ffi/src/uniffi_helpers.rs @@ -9,6 +9,7 @@ use crate::types::{ coin::Coin, events::Event, graphql::{DynamicFieldOutput, Epoch, TransactionDataEffects, Validator}, + iota_names::NameRegistration, object::{MovePackage, Object}, transaction::{SignedTransaction, TransactionEffects}, }; @@ -76,6 +77,7 @@ define_paged_object!(TransactionEffectsPage, TransactionEffects); define_paged_object!(MovePackagePage, MovePackage); define_paged_object!(EpochPage, Epoch); define_paged_object!(CheckpointSummaryPage, CheckpointSummary); +define_paged_object!(NameRegistrationPage, NameRegistration); uniffi::custom_type!(Value, String, { remote, diff --git a/crates/iota-sdk-types/Cargo.toml b/crates/iota-sdk-types/Cargo.toml index a2353ebd6..7e74e1149 100644 --- a/crates/iota-sdk-types/Cargo.toml +++ b/crates/iota-sdk-types/Cargo.toml @@ -40,12 +40,14 @@ hash = ["dep:blake2"] proptest = ["dep:proptest", "dep:test-strategy", "serde"] [dependencies] +anyhow = "1.0" base64ct = { version = "1.6.0", features = ["alloc"] } bnum = "0.12.0" bs58 = "0.5.1" hex = "0.4.3" paste = "1.0" roaring = { version = "0.11.2", default-features = false } +thiserror = "2.0" winnow = "0.7" # Serialization and Deserialization support diff --git a/crates/iota-sdk-types/src/iota_names/config.rs b/crates/iota-sdk-types/src/iota_names/config.rs new file mode 100644 index 000000000..561fce589 --- /dev/null +++ b/crates/iota-sdk-types/src/iota_names/config.rs @@ -0,0 +1,93 @@ +// Copyright (c) 2025 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::str::FromStr; + +use crate::{Address, ObjectId}; + +#[derive(Clone, Debug, Eq, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(serde_derive::Serialize, serde_derive::Deserialize) +)] +#[serde(rename_all = "kebab-case")] +pub struct IotaNamesConfig { + /// Address of the `iota_names` package. + pub package_address: Address, + /// ID of the `IotaNames` object. + pub object_id: ObjectId, + /// Address of the `payments` package. + pub payments_package_address: Address, + /// ID of the registry table. + pub registry_id: ObjectId, + /// ID of the reverse registry table. + pub reverse_registry_id: ObjectId, +} + +impl Default for IotaNamesConfig { + fn default() -> Self { + // TODO change to mainnet https://github.com/iotaledger/iota/issues/6532 + // TODO change to testnet https://github.com/iotaledger/iota/issues/6531 + Self::devnet() + } +} + +impl IotaNamesConfig { + pub fn new( + package_address: Address, + object_id: ObjectId, + payments_package_address: Address, + registry_id: ObjectId, + reverse_registry_id: ObjectId, + ) -> Self { + Self { + package_address, + object_id, + payments_package_address, + registry_id, + reverse_registry_id, + } + } + + pub fn from_env() -> anyhow::Result { + Ok(Self::new( + std::env::var("IOTA_NAMES_PACKAGE_ADDRESS")?.parse()?, + std::env::var("IOTA_NAMES_OBJECT_ID")?.parse()?, + std::env::var("IOTA_NAMES_PAYMENTS_PACKAGE_ADDRESS")?.parse()?, + std::env::var("IOTA_NAMES_REGISTRY_ID")?.parse()?, + std::env::var("IOTA_NAMES_REVERSE_REGISTRY_ID")?.parse()?, + )) + } + + // TODO add mainnet https://github.com/iotaledger/iota/issues/6532 + + // TODO add testnet https://github.com/iotaledger/iota/issues/6531 + + // Create a config based on the package and object ids published on devnet. + pub fn devnet() -> Self { + const PACKAGE_ADDRESS: &str = + "0xb9d617f24c84826bf660a2f4031951678cc80c264aebc4413459fb2a95ada9ba"; + const OBJECT_ID: &str = + "0x07c59b37bd7d036bf78fa30561a2ab9f7a970837487656ec29466e817f879342"; + const PAYMENTS_PACKAGE_ADDRESS: &str = + "0x98b9b33b7c2347a8f4e8b8716fb4c7e6e1af846ec2ea063a47bba81ffe03b440"; + const REGISTRY_ID: &str = + "0xe00b2f2400c33b4dbd3081c4dcf2e289d0544caba23a3d130b264bd756403c07"; + const REVERSE_REGISTRY_ID: &str = + "0x1c1da17843cc453ad4079b05ce55e103b7a8cdd4db6ab42dc367b47ed6d8994d"; + + let package_address = Address::from_str(PACKAGE_ADDRESS).unwrap(); + let object_id = ObjectId::from_str(OBJECT_ID).unwrap(); + let payments_package_address = Address::from_str(PAYMENTS_PACKAGE_ADDRESS).unwrap(); + let registry_id = ObjectId::from_str(REGISTRY_ID).unwrap(); + let reverse_registry_id = ObjectId::from_str(REVERSE_REGISTRY_ID).unwrap(); + + Self::new( + package_address, + object_id, + payments_package_address, + registry_id, + reverse_registry_id, + ) + } +} diff --git a/crates/iota-sdk-types/src/iota_names/constants.rs b/crates/iota-sdk-types/src/iota_names/constants.rs new file mode 100644 index 000000000..8badaa3a0 --- /dev/null +++ b/crates/iota-sdk-types/src/iota_names/constants.rs @@ -0,0 +1,10 @@ +// Copyright (c) 2025 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +pub const IOTA_NAMES_LEAF_EXPIRATION_TIMESTAMP: u64 = 0; +pub const IOTA_NAMES_TLN: &str = "iota"; +pub const IOTA_NAMES_SEPARATOR_DOT: char = '.'; +pub const IOTA_NAMES_SEPARATOR_AT: char = '@'; +pub const IOTA_NAMES_MIN_LABEL_LENGTH: usize = 1; +pub const IOTA_NAMES_MAX_LABEL_LENGTH: usize = 63; +pub const IOTA_NAMES_MAX_NAME_LENGTH: usize = 235; diff --git a/crates/iota-sdk-types/src/iota_names/error.rs b/crates/iota-sdk-types/src/iota_names/error.rs new file mode 100644 index 000000000..bd539c5c6 --- /dev/null +++ b/crates/iota-sdk-types/src/iota_names/error.rs @@ -0,0 +1,32 @@ +// Copyright (c) 2025 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use crate::ObjectId; + +#[derive(thiserror::Error, Debug, Clone, Eq, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(serde_derive::Serialize, serde_derive::Deserialize) +)] +pub enum IotaNamesError { + #[error("Name length {0} exceeds maximum length {1}")] + NameLengthExceeded(usize, usize), + #[error("Label length {0} outside of valid range [{1}, {2}]")] + InvalidLabelLength(usize, usize, usize), + #[error("Hyphens are not allowed as first or last character of a label")] + HyphensAsFirstOrLastLabelChar, + #[error( + "Only lowercase letters, numbers, and hyphens are allowed as label characters. Got \'{0}\' at position {1}" + )] + InvalidLabelChar(char, usize), + #[error("Name must contain at least two labels, TLN and SLN")] + NotEnoughLabels, + #[error("Name must include only one separator")] + InvalidSeparator, + #[error("Name has expired")] + NameExpired, + #[error("Malformed object for {0}")] + MalformedObject(ObjectId), + #[error("Invalid TLN {0}")] + InvalidTln(String), +} diff --git a/crates/iota-sdk-types/src/iota_names/mod.rs b/crates/iota-sdk-types/src/iota_names/mod.rs new file mode 100644 index 000000000..2461de535 --- /dev/null +++ b/crates/iota-sdk-types/src/iota_names/mod.rs @@ -0,0 +1,131 @@ +// Copyright (c) 2025 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +pub mod config; +pub mod constants; +pub mod error; +pub mod name; +pub mod registry; + +use std::time::{Duration, SystemTime, UNIX_EPOCH}; + +pub use self::name::{Name, NameFormat}; +use crate::{Address, ObjectId, StructTag, type_tag::IdentifierRef}; + +/// An object to manage a second-level name (SLN). +#[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(serde_derive::Serialize, serde_derive::Deserialize) +)] +pub struct NameRegistration { + id: ObjectId, + name: Name, + name_str: String, + expiration_timestamp_ms: u64, +} + +impl NameRegistration { + pub fn new(id: ObjectId, name: Name, name_str: String, expiration_timestamp_ms: u64) -> Self { + Self { + id, + name, + name_str, + expiration_timestamp_ms, + } + } +} + +/// An object to manage a subname. +#[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(serde_derive::Serialize, serde_derive::Deserialize) +)] +pub struct SubnameRegistration { + id: ObjectId, + nft: NameRegistration, +} + +impl SubnameRegistration { + pub fn new(id: ObjectId, nft: NameRegistration) -> Self { + Self { id, nft } + } + + pub fn into_inner(self) -> NameRegistration { + self.nft + } +} + +/// Unifying trait for [`NameRegistration`] and [`SubnameRegistration`] +pub trait IotaNamesNft { + const MODULE: &IdentifierRef; + const TYPE_NAME: &IdentifierRef; + + fn type_(package_id: Address) -> StructTag { + StructTag { + address: package_id, + module: Self::MODULE.into(), + name: Self::TYPE_NAME.into(), + type_params: Vec::new(), + } + } + + fn name(&self) -> &Name; + + fn name_str(&self) -> &str; + + fn expiration_timestamp_ms(&self) -> u64; + + fn expiration_time(&self) -> SystemTime { + UNIX_EPOCH + Duration::from_millis(self.expiration_timestamp_ms()) + } + + fn has_expired(&self) -> bool { + self.expiration_time() <= SystemTime::now() + } + + fn id(&self) -> ObjectId; +} + +impl IotaNamesNft for NameRegistration { + const MODULE: &IdentifierRef = IdentifierRef::const_new("name_registration"); + const TYPE_NAME: &IdentifierRef = IdentifierRef::const_new("NameRegistration"); + + fn name(&self) -> &Name { + &self.name + } + + fn name_str(&self) -> &str { + &self.name_str + } + + fn expiration_timestamp_ms(&self) -> u64 { + self.expiration_timestamp_ms + } + + fn id(&self) -> ObjectId { + self.id + } +} + +impl IotaNamesNft for SubnameRegistration { + const MODULE: &IdentifierRef = IdentifierRef::const_new("subname_registration"); + const TYPE_NAME: &IdentifierRef = IdentifierRef::const_new("SubnameRegistration"); + + fn name(&self) -> &Name { + self.nft.name() + } + + fn name_str(&self) -> &str { + self.nft.name_str() + } + + fn expiration_timestamp_ms(&self) -> u64 { + self.nft.expiration_timestamp_ms() + } + + fn id(&self) -> ObjectId { + self.id + } +} diff --git a/crates/iota-sdk-types/src/iota_names/name.rs b/crates/iota-sdk-types/src/iota_names/name.rs new file mode 100644 index 000000000..7b6826f9f --- /dev/null +++ b/crates/iota-sdk-types/src/iota_names/name.rs @@ -0,0 +1,342 @@ +// Copyright (c) 2025 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::str::FromStr; + +use crate::{ + Address, StructTag, + iota_names::{ + constants::{ + IOTA_NAMES_MAX_LABEL_LENGTH, IOTA_NAMES_MAX_NAME_LENGTH, IOTA_NAMES_MIN_LABEL_LENGTH, + IOTA_NAMES_SEPARATOR_AT, IOTA_NAMES_SEPARATOR_DOT, IOTA_NAMES_TLN, + }, + error::IotaNamesError, + }, + type_tag::IdentifierRef, +}; + +#[derive(Debug, Clone, Eq, Hash, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(serde_derive::Serialize, serde_derive::Deserialize) +)] +pub struct Name { + // Labels of the name, in reverse order + labels: Vec, +} + +impl FromStr for Name { + type Err = IotaNamesError; + + fn from_str(s: &str) -> Result { + if s.len() > IOTA_NAMES_MAX_NAME_LENGTH { + return Err(IotaNamesError::NameLengthExceeded( + s.len(), + IOTA_NAMES_MAX_NAME_LENGTH, + )); + } + + let formatted_string = convert_from_at_format(s, &IOTA_NAMES_SEPARATOR_DOT)?; + + let labels = formatted_string + .split(IOTA_NAMES_SEPARATOR_DOT) + .rev() + .map(validate_label) + .collect::, Self::Err>>()?; + + // A valid name in our system has at least a TLN and an SLN (len == 2). + if labels.len() < 2 { + return Err(IotaNamesError::NotEnoughLabels); + } + + if labels[0] != IOTA_NAMES_TLN { + return Err(IotaNamesError::InvalidTln(labels[0].to_string())); + } + + let labels = labels.into_iter().map(ToOwned::to_owned).collect(); + + Ok(Name { labels }) + } +} + +impl std::fmt::Display for Name { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + // We use to_string() to check on-chain state and parse on-chain data + // so we should always default to DOT format. + let output = self.format(NameFormat::Dot); + f.write_str(&output)?; + + Ok(()) + } +} + +impl Name { + pub fn type_(package_address: Address) -> StructTag { + const IOTA_NAMES_NAME_MODULE: &IdentifierRef = IdentifierRef::const_new("name"); + const IOTA_NAMES_NAME_STRUCT: &IdentifierRef = IdentifierRef::const_new("Name"); + + StructTag { + address: package_address, + module: IOTA_NAMES_NAME_MODULE.to_owned(), + name: IOTA_NAMES_NAME_STRUCT.to_owned(), + type_params: vec![], + } + } + + /// Derive the parent name for a given name. Only subnames have + /// parents; second-level names return `None`. + /// + /// ``` + /// # use std::str::FromStr; + /// # use iota_sdk_types::iota_names::Name; + /// assert_eq!( + /// Name::from_str("test.example.iota").unwrap().parent(), + /// Some(Name::from_str("example.iota").unwrap()) + /// ); + /// assert_eq!( + /// Name::from_str("sub.test.example.iota").unwrap().parent(), + /// Some(Name::from_str("test.example.iota").unwrap()) + /// ); + /// assert_eq!(Name::from_str("example.iota").unwrap().parent(), None); + /// ``` + pub fn parent(&self) -> Option { + if self.is_subname() { + Some(Self { + labels: self + .labels + .iter() + .take(self.num_labels() - 1) + .cloned() + .collect(), + }) + } else { + None + } + } + + /// Returns whether this name is a second-level name (Ex. `test.iota`) + pub fn is_sln(&self) -> bool { + self.num_labels() == 2 + } + + /// Returns whether this name is a subname (Ex. `sub.test.iota`) + pub fn is_subname(&self) -> bool { + self.num_labels() >= 3 + } + + /// Returns the number of labels including TLN. + /// + /// ``` + /// # use std::str::FromStr; + /// # use iota_sdk_types::iota_names::Name; + /// assert_eq!(Name::from_str("test.example.iota").unwrap().num_labels(), 3) + /// ``` + pub fn num_labels(&self) -> usize { + self.labels.len() + } + + /// Get the label at the given index + pub fn label(&self, index: usize) -> Option<&String> { + self.labels.get(index) + } + + /// Get all of the labels. NOTE: These are in reverse order starting with + /// the top-level name and proceeding to subnames. + pub fn labels(&self) -> &[String] { + &self.labels + } + + /// Formats a name into a string based on the available output formats. + /// The default separator is `.` + pub fn format(&self, format: NameFormat) -> String { + let mut labels = self.labels.clone(); + let sep = &IOTA_NAMES_SEPARATOR_DOT.to_string(); + labels.reverse(); + + if format == NameFormat::Dot { + // DOT format, all labels joined together with dots, including the TLN. + labels.join(sep) + } else { + // SAFETY: This is a safe operation because we only allow a + // name's label vector size to be >= 2 (see `Name::from_str`) + let _tln = labels.pop(); + let sln = labels.pop().unwrap(); + + // AT format, labels minus SLN joined together with dots, then joined to SLN + // with @, no TLN. + format!("{}{IOTA_NAMES_SEPARATOR_AT}{sln}", labels.join(sep)) + } + } +} + +/// Two different view options for a name. +/// `At` -> `test@example` | `Dot` -> `test.example.iota` +#[derive(Clone, Eq, PartialEq, Debug)] +pub enum NameFormat { + At, + Dot, +} + +/// Converts @label ending to label{separator}iota ending. +/// +/// E.g. `@example` -> `example.iota` | `test@example` -> `test.example.iota` +fn convert_from_at_format(s: &str, separator: &char) -> Result { + let mut splits = s.split(IOTA_NAMES_SEPARATOR_AT); + + let Some(before) = splits.next() else { + return Err(IotaNamesError::InvalidSeparator); + }; + + let Some(after) = splits.next() else { + return Ok(before.to_string()); + }; + + if splits.next().is_some() || after.contains(*separator) || after.is_empty() { + return Err(IotaNamesError::InvalidSeparator); + } + + let mut parts = vec![]; + + if !before.is_empty() { + parts.push(before); + } + + parts.push(after); + parts.push(IOTA_NAMES_TLN); + + Ok(parts.join(&separator.to_string())) +} + +/// Checks the validity of a label according to these rules: +/// - length must be in +/// [IOTA_NAMES_MIN_LABEL_LENGTH..IOTA_NAMES_MAX_LABEL_LENGTH] +/// - must contain only '0'..'9', 'a'..'z' and '-' +/// - must not start or end with '-' +pub fn validate_label(label: &str) -> Result<&str, IotaNamesError> { + let bytes = label.as_bytes(); + let len = bytes.len(); + + if !(IOTA_NAMES_MIN_LABEL_LENGTH..=IOTA_NAMES_MAX_LABEL_LENGTH).contains(&len) { + return Err(IotaNamesError::InvalidLabelLength( + len, + IOTA_NAMES_MIN_LABEL_LENGTH, + IOTA_NAMES_MAX_LABEL_LENGTH, + )); + } + + for (i, character) in bytes.iter().enumerate() { + match character { + b'a'..=b'z' | b'0'..=b'9' => continue, + b'-' => { + if i == 0 || i == len - 1 { + return Err(IotaNamesError::HyphensAsFirstOrLastLabelChar); + } + } + _ => return Err(IotaNamesError::InvalidLabelChar((*character) as char, i)), + }; + } + + Ok(label) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parent_extraction() { + let name = Name::from_str("leaf.node.test.iota") + .unwrap() + .parent() + .unwrap(); + + assert_eq!(name.to_string(), "node.test.iota"); + + let name = name.parent().unwrap(); + + assert_eq!(name.to_string(), "test.iota"); + + assert!(name.parent().is_none()); + } + + #[test] + fn name_service_outputs() { + assert_eq!("@test".parse::().unwrap().to_string(), "test.iota"); + assert_eq!( + "test.iota".parse::().unwrap().to_string(), + "test.iota" + ); + assert_eq!( + "test@sln".parse::().unwrap().to_string(), + "test.sln.iota" + ); + assert_eq!( + "test.test@example".parse::().unwrap().to_string(), + "test.test.example.iota" + ); + assert_eq!( + "test.test-with-hyphen@example-hyphen" + .parse::() + .unwrap() + .to_string(), + "test.test-with-hyphen.example-hyphen.iota" + ); + assert_eq!( + "iota@iota".parse::().unwrap().to_string(), + "iota.iota.iota" + ); + assert_eq!("@iota".parse::().unwrap().to_string(), "iota.iota"); + assert_eq!( + "test.test.iota".parse::().unwrap().to_string(), + "test.test.iota" + ); + assert_eq!( + "test.test.test.iota".parse::().unwrap().to_string(), + "test.test.test.iota" + ); + assert_eq!( + "test.test-with-hyphen.test-with-hyphen.iota" + .parse::() + .unwrap() + .to_string(), + "test.test-with-hyphen.test-with-hyphen.iota" + ); + } + + #[test] + fn invalid_inputs() { + assert!(".".parse::().is_err()); + assert!("@".parse::().is_err()); + assert!("@inner.iota".parse::().is_err()); + assert!("test@".parse::().is_err()); + assert!("iota".parse::().is_err()); + assert!("test.test@example.iota".parse::().is_err()); + assert!("test@test@example".parse::().is_err()); + assert!("test.atoi".parse::().is_err()); + assert!("test.test@example-".parse::().is_err()); + assert!("test.test@-example".parse::().is_err()); + assert!("test.test-@example".parse::().is_err()); + assert!("test.-test@example".parse::().is_err()); + assert!("test.test-.iota".parse::().is_err()); + assert!("test.-test.iota".parse::().is_err()); + } + + #[test] + fn outputs() { + let mut name = "test.iota".parse::().unwrap(); + assert!(name.format(NameFormat::Dot) == "test.iota"); + assert!(name.format(NameFormat::At) == "@test"); + + name = "test.test.iota".parse::().unwrap(); + assert!(name.format(NameFormat::Dot) == "test.test.iota"); + assert!(name.format(NameFormat::At) == "test@test"); + + name = "test.test.test.iota".parse::().unwrap(); + assert!(name.format(NameFormat::Dot) == "test.test.test.iota"); + assert!(name.format(NameFormat::At) == "test.test@test"); + + name = "test.test.test.test.iota".parse::().unwrap(); + assert!(name.format(NameFormat::Dot) == "test.test.test.test.iota"); + assert!(name.format(NameFormat::At) == "test.test.test@test"); + } +} diff --git a/crates/iota-sdk-types/src/iota_names/registry.rs b/crates/iota-sdk-types/src/iota_names/registry.rs new file mode 100644 index 000000000..8278bd9d7 --- /dev/null +++ b/crates/iota-sdk-types/src/iota_names/registry.rs @@ -0,0 +1,195 @@ +// Copyright (c) 2025 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::{ + collections::HashMap, + time::{Duration, SystemTime, UNIX_EPOCH}, +}; + +use crate::{ + Address, Object, ObjectId, + iota_names::{ + constants::IOTA_NAMES_LEAF_EXPIRATION_TIMESTAMP, error::IotaNamesError, name::Name, + }, +}; + +/// Rust version of the Move `iota::table::Table` type. +#[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(serde_derive::Serialize, serde_derive::Deserialize) +)] +pub struct Table { + pub id: ObjectId, + pub size: u64, +} + +#[derive(Debug, Clone)] +#[cfg_attr( + feature = "serde", + derive(serde_derive::Serialize, serde_derive::Deserialize) +)] +pub struct Registry { + /// The `registry` table maps `Name` to `NameRecord`. + /// Added / replaced in the `add_record` function. + registry: Table, + /// The `reverse_registry` table maps `Address` to `Name`. + /// Updated in the `set_reverse_lookup` function. + reverse_registry: Table, +} + +#[derive(Debug)] +#[cfg_attr( + feature = "serde", + derive(serde_derive::Serialize, serde_derive::Deserialize) +)] +pub struct RegistryEntry { + pub id: ObjectId, + pub name: Name, + pub name_record: NameRecord, +} + +#[derive(Debug)] +#[cfg_attr( + feature = "serde", + derive(serde_derive::Serialize, serde_derive::Deserialize) +)] +pub struct ReverseRegistryEntry { + pub id: ObjectId, + pub address: Address, + pub name: Name, +} + +/// A single record in the registry. +#[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(serde_derive::Serialize, serde_derive::Deserialize) +)] +pub struct NameRecord { + /// The ID of the registration NFT assigned to this record. + /// + /// The owner of the corresponding registration NFT has the rights to be + /// able to change and adjust the `target_address` of this name. + /// + /// It is possible that the ID changes if the record expires and is + /// purchased by someone else. + pub nft_id: ObjectId, + /// Timestamp in milliseconds when the record expires. + pub expiration_timestamp_ms: u64, + /// The target address that this name points to. + pub target_address: Option
, + /// Additional data which may be stored in a record. + #[cfg_attr(feature = "serde", serde(with = "serde_vecmap"))] + pub data: HashMap, +} + +#[cfg(feature = "serde")] +mod serde_vecmap { + use std::collections::HashMap; + + use serde::{Deserialize, Deserializer, Serialize, Serializer}; + + #[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)] + pub struct VecMap { + pub contents: Vec>, + } + + #[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)] + pub struct Entry { + pub key: K, + pub value: V, + } + + pub fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> + where + D: Deserializer<'de>, + { + let map = VecMap::deserialize(deserializer)?; + Ok(map.contents.into_iter().map(|e| (e.key, e.value)).collect()) + } + + pub fn serialize(value: &HashMap, serializer: S) -> Result + where + S: Serializer, + { + VecMap { + contents: value + .iter() + .map(|(key, value)| Entry { + key: key.clone(), + value: value.clone(), + }) + .collect(), + } + .serialize(serializer) + } +} + +#[cfg(feature = "serde")] +impl TryFrom for NameRecord { + type Error = IotaNamesError; + + fn try_from(object: Object) -> Result { + #[derive(Clone, serde::Serialize, serde::Deserialize, Debug)] + pub struct Field { + pub id: ObjectId, + pub name: N, + pub value: V, + } + + object + .to_rust::>() + .map(|record| record.value) + .map_err(|_| IotaNamesError::MalformedObject(object.object_id())) + } +} + +impl NameRecord { + /// Leaf records expire when their parent expires. + /// The `expiration_timestamp_ms` is set to `0` (on-chain) to indicate this. + pub fn is_leaf_record(&self) -> bool { + self.expiration_timestamp_ms == IOTA_NAMES_LEAF_EXPIRATION_TIMESTAMP + } + + /// Validates that a `NameRecord` is a valid parent of a child `NameRecord`. + /// + /// WARNING: This only applies for `leaf` records. + pub fn is_valid_leaf_parent(&self, child: &NameRecord) -> bool { + self.nft_id == child.nft_id + } + + /// Checks if a `node` name record has expired. + /// Expects the latest checkpoint's timestamp. + pub fn is_node_expired(&self, checkpoint_timestamp_ms: u64) -> bool { + self.expiration_timestamp_ms < checkpoint_timestamp_ms + } + + /// Gets the expiration time as a [`SystemTime`]. + pub fn expiration_time(&self) -> SystemTime { + UNIX_EPOCH + Duration::from_millis(self.expiration_timestamp_ms) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn expirations() { + let system_time: u64 = 100; + + let mut name = NameRecord { + nft_id: ObjectId::ZERO, + data: Default::default(), + target_address: Some(Address::ZERO), + expiration_timestamp_ms: system_time + 10, + }; + + assert!(!name.is_node_expired(system_time)); + + name.expiration_timestamp_ms = system_time - 10; + + assert!(name.is_node_expired(system_time)); + } +} diff --git a/crates/iota-sdk-types/src/lib.rs b/crates/iota-sdk-types/src/lib.rs index 65f74a1b9..d0611b98b 100644 --- a/crates/iota-sdk-types/src/lib.rs +++ b/crates/iota-sdk-types/src/lib.rs @@ -119,6 +119,7 @@ mod events; mod execution_status; pub mod framework; mod gas; +pub mod iota_names; mod object; mod object_id; mod transaction; diff --git a/crates/iota-sdk-types/src/object.rs b/crates/iota-sdk-types/src/object.rs index f0f4f2238..73ac971df 100644 --- a/crates/iota-sdk-types/src/object.rs +++ b/crates/iota-sdk-types/src/object.rs @@ -421,6 +421,15 @@ impl Object { pub fn storage_rebate(&self) -> u64 { self.storage_rebate } + + #[cfg(feature = "serde")] + pub fn to_rust(&self) -> anyhow::Result { + use anyhow::Context; + + Ok(bcs::from_bytes::( + &self.as_struct().context("not a struct")?.contents, + )?) + } } fn id_opt(contents: &[u8]) -> Option { diff --git a/crates/iota-sdk-types/src/type_tag/mod.rs b/crates/iota-sdk-types/src/type_tag/mod.rs index 839e90b1b..e2ef3ee49 100644 --- a/crates/iota-sdk-types/src/type_tag/mod.rs +++ b/crates/iota-sdk-types/src/type_tag/mod.rs @@ -243,6 +243,41 @@ impl Identifier { pub fn as_str(&self) -> &str { &self.0 } + + pub const fn is_valid(s: &str) -> bool { + /// Returns `true` if all bytes in `b` after the offset `start_offset` + /// are valid ASCII identifier characters. + const fn all_bytes_valid(b: &[u8], start_offset: usize) -> bool { + let mut i = start_offset; + while i < b.len() { + if !Identifier::is_valid_char(b[i] as char) { + return false; + } + i += 1; + } + true + } + + // Rust const fn's don't currently support slicing or indexing &str's, so we + // have to operate on the underlying byte slice. This is not a problem as + // valid identifiers are (currently) ASCII-only. + let b = s.as_bytes(); + match b { + b"" => true, + [b'a'..=b'z', ..] | [b'A'..=b'Z', ..] => all_bytes_valid(b, 1), + [b'_', ..] if b.len() > 1 => all_bytes_valid(b, 1), + _ => false, + } + } + + /// Return true if this character can appear in a Move identifier. + /// + /// Note: there are stricter restrictions on whether a character can begin a + /// Move identifier--only alphabetic characters are allowed here. + #[inline] + pub const fn is_valid_char(c: char) -> bool { + matches!(c, '_' | 'a'..='z' | 'A'..='Z' | '0'..='9') + } } impl std::fmt::Display for Identifier { @@ -267,6 +302,85 @@ impl PartialEq for Identifier { } } +impl std::ops::Deref for Identifier { + type Target = IdentifierRef; + + fn deref(&self) -> &IdentifierRef { + unsafe { std::mem::transmute::<&str, &IdentifierRef>(self.0.as_ref()) } + } +} + +impl std::borrow::Borrow for Identifier { + fn borrow(&self) -> &IdentifierRef { + self + } +} + +#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +#[repr(transparent)] +pub struct IdentifierRef(str); + +impl IdentifierRef { + pub const fn const_new(s: &'static str) -> &'static Self { + if !Identifier::is_valid(s) { + panic!("String is not a valid Move identifier"); + } + + // SAFETY: the following transmute is safe because + // (1) it's equivalent to the unsafe-reborrow inside IdentStr::ref_cast() + // (which we can't use b/c it's not const). + // (2) we've just asserted that IdentStr impls RefCast, which + // already guarantees the transmute is safe (RefCast checks that + // IdentStr(str) is #[repr(transparent)]). + // (3) both in and out lifetimes are 'static, so we're not widening the + // lifetime. (4) we've just asserted that the IdentStr passes the + // is_valid check. + unsafe { std::mem::transmute::<&'static str, &'static Self>(s) } + } + + /// Returns true if this string is a valid identifier. + pub fn is_valid(s: &str) -> bool { + Identifier::is_valid(s) + } + + /// Returns the length of `self` in bytes. + pub fn len(&self) -> usize { + self.0.len() + } + + /// Returns `true` if `self` has a length of zero bytes. + pub fn is_empty(&self) -> bool { + self.0.is_empty() + } + + /// Converts `self` to a `&str`. + /// + /// This is not implemented as a `From` trait to discourage automatic + /// conversions -- these conversions should not typically happen. + pub fn as_str(&self) -> &str { + &self.0 + } + + /// Converts `self` to a byte slice. + pub fn as_bytes(&self) -> &[u8] { + self.0.as_bytes() + } +} + +impl From<&IdentifierRef> for Identifier { + fn from(value: &IdentifierRef) -> Self { + value.to_owned() + } +} + +impl ToOwned for IdentifierRef { + type Owned = Identifier; + + fn to_owned(&self) -> Identifier { + Identifier(self.0.into()) + } +} + /// Type information for a move struct /// /// # BCS From 7b2243ab983d34a0f96c0e699ad85c9e505c99f3 Mon Sep 17 00:00:00 2001 From: Chloe Martin Date: Fri, 29 Aug 2025 14:37:10 +0200 Subject: [PATCH 2/7] clippy --- .../iota-sdk-types/src/iota_names/config.rs | 4 ++-- .../iota-sdk-types/src/iota_names/registry.rs | 20 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/iota-sdk-types/src/iota_names/config.rs b/crates/iota-sdk-types/src/iota_names/config.rs index 561fce589..85b6db913 100644 --- a/crates/iota-sdk-types/src/iota_names/config.rs +++ b/crates/iota-sdk-types/src/iota_names/config.rs @@ -8,9 +8,9 @@ use crate::{Address, ObjectId}; #[derive(Clone, Debug, Eq, PartialEq)] #[cfg_attr( feature = "serde", - derive(serde_derive::Serialize, serde_derive::Deserialize) + derive(serde_derive::Serialize, serde_derive::Deserialize), + serde(rename_all = "kebab-case") )] -#[serde(rename_all = "kebab-case")] pub struct IotaNamesConfig { /// Address of the `iota_names` package. pub package_address: Address, diff --git a/crates/iota-sdk-types/src/iota_names/registry.rs b/crates/iota-sdk-types/src/iota_names/registry.rs index 8278bd9d7..d8a3d6032 100644 --- a/crates/iota-sdk-types/src/iota_names/registry.rs +++ b/crates/iota-sdk-types/src/iota_names/registry.rs @@ -7,10 +7,8 @@ use std::{ }; use crate::{ - Address, Object, ObjectId, - iota_names::{ - constants::IOTA_NAMES_LEAF_EXPIRATION_TIMESTAMP, error::IotaNamesError, name::Name, - }, + Address, ObjectId, + iota_names::{constants::IOTA_NAMES_LEAF_EXPIRATION_TIMESTAMP, name::Name}, }; /// Rust version of the Move `iota::table::Table` type. @@ -32,10 +30,10 @@ pub struct Table { pub struct Registry { /// The `registry` table maps `Name` to `NameRecord`. /// Added / replaced in the `add_record` function. - registry: Table, + pub registry: Table, /// The `reverse_registry` table maps `Address` to `Name`. /// Updated in the `set_reverse_lookup` function. - reverse_registry: Table, + pub reverse_registry: Table, } #[derive(Debug)] @@ -127,10 +125,10 @@ mod serde_vecmap { } #[cfg(feature = "serde")] -impl TryFrom for NameRecord { - type Error = IotaNamesError; +impl TryFrom for NameRecord { + type Error = crate::iota_names::error::IotaNamesError; - fn try_from(object: Object) -> Result { + fn try_from(object: crate::Object) -> Result { #[derive(Clone, serde::Serialize, serde::Deserialize, Debug)] pub struct Field { pub id: ObjectId, @@ -141,7 +139,9 @@ impl TryFrom for NameRecord { object .to_rust::>() .map(|record| record.value) - .map_err(|_| IotaNamesError::MalformedObject(object.object_id())) + .map_err(|_| { + crate::iota_names::error::IotaNamesError::MalformedObject(object.object_id()) + }) } } From 471a89c4f438139bd9e24f610348f7ec96a45f86 Mon Sep 17 00:00:00 2001 From: Chloe Martin Date: Fri, 29 Aug 2025 14:55:19 +0200 Subject: [PATCH 3/7] doc comments --- bindings/go/iota_sdk_ffi/iota_sdk_ffi.go | 12 ++++++-- bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt | 24 ++++++++++++++-- bindings/python/lib/iota_sdk_ffi.py | 30 ++++++++++++++++++-- crates/iota-graphql-client/src/lib.rs | 3 ++ crates/iota-sdk-ffi/src/graphql.rs | 3 ++ 5 files changed, 63 insertions(+), 9 deletions(-) diff --git a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go index 3378e6885..dc2bc1b5d 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_iota_names_default_name() }) - if checksum != 55795 { + if checksum != 53764 { // If this happens try cleaning and rebuilding your project panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_default_name: UniFFI API checksum mismatch") } @@ -1361,7 +1361,7 @@ func uniffiCheckChecksums() { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_lookup() }) - if checksum != 26177 { + if checksum != 20908 { // If this happens try cleaning and rebuilding your project panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_lookup: UniFFI API checksum mismatch") } @@ -1370,7 +1370,7 @@ func uniffiCheckChecksums() { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_registrations() }) - if checksum != 58110 { + if checksum != 44467 { // If this happens try cleaning and rebuilding your project panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_registrations: UniFFI API checksum mismatch") } @@ -11301,8 +11301,11 @@ type GraphQlClientInterface interface { Events(paginationFilter PaginationFilter, filter *EventFilter) (EventPage, error) // Execute a transaction. ExecuteTx(signatures []*UserSignature, tx *Transaction) (**TransactionEffects, error) + // Get the default name pointing to this address, if one exists. IotaNamesDefaultName(address *Address, format *NameFormat) (**Name, error) + // Return the resolved address for the given name. IotaNamesLookup(name string) (**Address, error) + // Find all registration NFTs for the given address. IotaNamesRegistrations(address *Address, paginationFilter PaginationFilter) (NameRegistrationPage, error) // Return the sequence number of the latest checkpoint that has been // executed. @@ -12074,6 +12077,7 @@ func (_self *GraphQlClient) ExecuteTx(signatures []*UserSignature, tx *Transacti return res, err } +// Get the default name pointing to this address, if one exists. func (_self *GraphQlClient) IotaNamesDefaultName(address *Address, format *NameFormat) (**Name, error) { _pointer := _self.ffiObject.incrementPointer("*GraphQlClient") defer _self.ffiObject.decrementPointer() @@ -12105,6 +12109,7 @@ func (_self *GraphQlClient) IotaNamesDefaultName(address *Address, format *NameF return res, err } +// Return the resolved address for the given name. func (_self *GraphQlClient) IotaNamesLookup(name string) (**Address, error) { _pointer := _self.ffiObject.incrementPointer("*GraphQlClient") defer _self.ffiObject.decrementPointer() @@ -12136,6 +12141,7 @@ func (_self *GraphQlClient) IotaNamesLookup(name string) (**Address, error) { return res, err } +// Find all registration NFTs for the given address. func (_self *GraphQlClient) IotaNamesRegistrations(address *Address, paginationFilter PaginationFilter) (NameRegistrationPage, error) { _pointer := _self.ffiObject.incrementPointer("*GraphQlClient") defer _self.ffiObject.decrementPointer() diff --git a/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt b/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt index 12d06fb6c..6d8536686 100644 --- a/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt +++ b/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt @@ -5649,13 +5649,13 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_execute_tx() != 41079.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_default_name() != 55795.toShort()) { + if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_default_name() != 53764.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_lookup() != 26177.toShort()) { + if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_lookup() != 20908.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_registrations() != 58110.toShort()) { + if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_registrations() != 44467.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_latest_checkpoint_sequence_number() != 40336.toShort()) { @@ -19207,10 +19207,19 @@ public interface GraphQlClientInterface { */ suspend fun `executeTx`(`signatures`: List, `tx`: Transaction): TransactionEffects? + /** + * Get the default name pointing to this address, if one exists. + */ suspend fun `iotaNamesDefaultName`(`address`: Address, `format`: NameFormat?): Name? + /** + * Return the resolved address for the given name. + */ suspend fun `iotaNamesLookup`(`name`: kotlin.String): Address? + /** + * Find all registration NFTs for the given address. + */ suspend fun `iotaNamesRegistrations`(`address`: Address, `paginationFilter`: PaginationFilter): NameRegistrationPage /** @@ -19974,6 +19983,9 @@ open class GraphQlClient: Disposable, AutoCloseable, GraphQlClientInterface } + /** + * Get the default name pointing to this address, if one exists. + */ @Throws(SdkFfiException::class) @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") override suspend fun `iotaNamesDefaultName`(`address`: Address, `format`: NameFormat?) : Name? { @@ -19995,6 +20007,9 @@ open class GraphQlClient: Disposable, AutoCloseable, GraphQlClientInterface } + /** + * Return the resolved address for the given name. + */ @Throws(SdkFfiException::class) @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") override suspend fun `iotaNamesLookup`(`name`: kotlin.String) : Address? { @@ -20016,6 +20031,9 @@ open class GraphQlClient: Disposable, AutoCloseable, GraphQlClientInterface } + /** + * Find all registration NFTs for the given address. + */ @Throws(SdkFfiException::class) @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") override suspend fun `iotaNamesRegistrations`(`address`: Address, `paginationFilter`: PaginationFilter) : NameRegistrationPage { diff --git a/bindings/python/lib/iota_sdk_ffi.py b/bindings/python/lib/iota_sdk_ffi.py index 4efdb2da1..f1249097a 100644 --- a/bindings/python/lib/iota_sdk_ffi.py +++ b/bindings/python/lib/iota_sdk_ffi.py @@ -681,11 +681,11 @@ 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_execute_tx() != 41079: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_default_name() != 55795: + if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_default_name() != 53764: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_lookup() != 26177: + if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_lookup() != 20908: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_registrations() != 58110: + if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_registrations() != 44467: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_latest_checkpoint_sequence_number() != 40336: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") @@ -25437,10 +25437,22 @@ def execute_tx(self, signatures: "typing.List[UserSignature]",tx: "Transaction") raise NotImplementedError def iota_names_default_name(self, address: "Address",format: "typing.Optional[NameFormat]"): + """ + Get the default name pointing to this address, if one exists. + """ + raise NotImplementedError def iota_names_lookup(self, name: "str"): + """ + Return the resolved address for the given name. + """ + raise NotImplementedError def iota_names_registrations(self, address: "Address",pagination_filter: "PaginationFilter"): + """ + Find all registration NFTs for the given address. + """ + raise NotImplementedError def latest_checkpoint_sequence_number(self, ): """ @@ -26292,6 +26304,10 @@ async def execute_tx(self, signatures: "typing.List[UserSignature]",tx: "Transac async def iota_names_default_name(self, address: "Address",format: "typing.Optional[NameFormat]") -> "typing.Optional[Name]": + """ + Get the default name pointing to this address, if one exists. + """ + _UniffiConverterTypeAddress.check_lower(address) _UniffiConverterOptionalTypeNameFormat.check_lower(format) @@ -26316,6 +26332,10 @@ async def iota_names_default_name(self, address: "Address",format: "typing.Optio async def iota_names_lookup(self, name: "str") -> "typing.Optional[Address]": + """ + Return the resolved address for the given name. + """ + _UniffiConverterString.check_lower(name) return await _uniffi_rust_call_async( @@ -26337,6 +26357,10 @@ async def iota_names_lookup(self, name: "str") -> "typing.Optional[Address]": async def iota_names_registrations(self, address: "Address",pagination_filter: "PaginationFilter") -> "NameRegistrationPage": + """ + Find all registration NFTs for the given address. + """ + _UniffiConverterTypeAddress.check_lower(address) _UniffiConverterTypePaginationFilter.check_lower(pagination_filter) diff --git a/crates/iota-graphql-client/src/lib.rs b/crates/iota-graphql-client/src/lib.rs index 1b9e05eb4..92f2540a9 100644 --- a/crates/iota-graphql-client/src/lib.rs +++ b/crates/iota-graphql-client/src/lib.rs @@ -1747,6 +1747,7 @@ impl Client { )) } + /// Return the resolved address for the given name. pub async fn iota_names_lookup(&self, name: &str) -> Result> { let operation = ResolveIotaNamesAddressQuery::build(ResolveIotaNamesAddressArgs { name: name.to_owned(), @@ -1767,6 +1768,7 @@ impl Client { Ok(Some(address.address)) } + /// Find all registration NFTs for the given address. pub async fn iota_names_registrations( &self, address: Address, @@ -1811,6 +1813,7 @@ impl Client { )) } + /// Get the default name pointing to this address, if one exists. pub async fn iota_names_default_name( &self, address: Address, diff --git a/crates/iota-sdk-ffi/src/graphql.rs b/crates/iota-sdk-ffi/src/graphql.rs index 6fcbaf319..4d08e487e 100644 --- a/crates/iota-sdk-ffi/src/graphql.rs +++ b/crates/iota-sdk-ffi/src/graphql.rs @@ -832,6 +832,7 @@ impl GraphQLClient { Ok(self.0.read().await.balance(**address, coin_type).await?) } + /// Return the resolved address for the given name. pub async fn iota_names_lookup(&self, name: &str) -> Result>> { Ok(self .0 @@ -843,6 +844,7 @@ impl GraphQLClient { .map(Arc::new)) } + /// Find all registration NFTs for the given address. pub async fn iota_names_registrations( &self, address: &Address, @@ -858,6 +860,7 @@ impl GraphQLClient { .into()) } + /// Get the default name pointing to this address, if one exists. pub async fn iota_names_default_name( &self, address: &Address, From eb88b92f6ad397923fe29cf6e220c2fde84e6043 Mon Sep 17 00:00:00 2001 From: Chloe Martin Date: Tue, 2 Sep 2025 11:03:52 +0200 Subject: [PATCH 4/7] update for testnet --- .../iota-sdk-types/src/iota_names/config.rs | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/crates/iota-sdk-types/src/iota_names/config.rs b/crates/iota-sdk-types/src/iota_names/config.rs index 85b6db913..30808f87f 100644 --- a/crates/iota-sdk-types/src/iota_names/config.rs +++ b/crates/iota-sdk-types/src/iota_names/config.rs @@ -27,8 +27,7 @@ pub struct IotaNamesConfig { impl Default for IotaNamesConfig { fn default() -> Self { // TODO change to mainnet https://github.com/iotaledger/iota/issues/6532 - // TODO change to testnet https://github.com/iotaledger/iota/issues/6531 - Self::devnet() + Self::testnet() } } @@ -61,8 +60,6 @@ impl IotaNamesConfig { // TODO add mainnet https://github.com/iotaledger/iota/issues/6532 - // TODO add testnet https://github.com/iotaledger/iota/issues/6531 - // Create a config based on the package and object ids published on devnet. pub fn devnet() -> Self { const PACKAGE_ADDRESS: &str = @@ -90,4 +87,32 @@ impl IotaNamesConfig { reverse_registry_id, ) } + + // Create a config based on the package and object ids published on testnet. + pub fn testnet() -> Self { + const PACKAGE_ADDRESS: &str = + "0x7fff6e95f385349bec98d17121ab2bfa3e134f2f0b1ccefc270313415f7835ea"; + const OBJECT_ID: &str = + "0x7cab491740d51e0d75b26bf9984e49ba2e32a2d0694cabcee605543ed13c7dec"; + const PAYMENTS_PACKAGE_ADDRESS: &str = + "0x6b1b01f4c72786a893191d5c6e73d3012f7529f86fdee3bc8c163323cee08441"; + const REGISTRY_ID: &str = + "0x2dfc6f6d46ba55217425643a59dc85fe4d8ed273a9f74077bd0ee280dbb4f590"; + const REVERSE_REGISTRY_ID: &str = + "0x3550bcacb793ef8b776264665e7c99fa3d897695ed664656aac693cf9cf9b76b"; + + let package_address = Address::from_str(PACKAGE_ADDRESS).unwrap(); + let object_id = ObjectId::from_str(OBJECT_ID).unwrap(); + let payments_package_address = Address::from_str(PAYMENTS_PACKAGE_ADDRESS).unwrap(); + let registry_id = ObjectId::from_str(REGISTRY_ID).unwrap(); + let reverse_registry_id = ObjectId::from_str(REVERSE_REGISTRY_ID).unwrap(); + + Self::new( + package_address, + object_id, + payments_package_address, + registry_id, + reverse_registry_id, + ) + } } From e9fa39f22bc5fec4c413253f8eee1301079f1c76 Mon Sep 17 00:00:00 2001 From: Chloe Martin Date: Tue, 2 Sep 2025 12:05:21 +0200 Subject: [PATCH 5/7] fix name registration deserialization --- crates/iota-graphql-client/src/query_types/iota_names.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/iota-graphql-client/src/query_types/iota_names.rs b/crates/iota-graphql-client/src/query_types/iota_names.rs index 8cbfb9aa6..acd07ca22 100644 --- a/crates/iota-graphql-client/src/query_types/iota_names.rs +++ b/crates/iota-graphql-client/src/query_types/iota_names.rs @@ -109,7 +109,9 @@ impl TryFrom for iota_types::iota_names::NameRegistration { .0 .as_str(), )?; - Ok(bcs::from_bytes(&bytes)?) + Ok(bcs::from_bytes::(&bytes)? + .to_rust() + .map_err(|e| Error::from_error(crate::error::Kind::Deserialization, e))?) } } From 2b71c722eca1d29b24ba4a1c53a46d680b10c317 Mon Sep 17 00:00:00 2001 From: Chloe Martin Date: Tue, 2 Sep 2025 12:11:41 +0200 Subject: [PATCH 6/7] clippy --- crates/iota-graphql-client/src/query_types/iota_names.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/iota-graphql-client/src/query_types/iota_names.rs b/crates/iota-graphql-client/src/query_types/iota_names.rs index acd07ca22..9e888ed81 100644 --- a/crates/iota-graphql-client/src/query_types/iota_names.rs +++ b/crates/iota-graphql-client/src/query_types/iota_names.rs @@ -109,9 +109,9 @@ impl TryFrom for iota_types::iota_names::NameRegistration { .0 .as_str(), )?; - Ok(bcs::from_bytes::(&bytes)? + bcs::from_bytes::(&bytes)? .to_rust() - .map_err(|e| Error::from_error(crate::error::Kind::Deserialization, e))?) + .map_err(|e| Error::from_error(crate::error::Kind::Deserialization, e)) } } From 692fad59bb96d0adc282fd5189f6245ec42f0e31 Mon Sep 17 00:00:00 2001 From: Chloe Martin Date: Tue, 30 Sep 2025 16:02:12 +0200 Subject: [PATCH 7/7] clarify err --- crates/iota-sdk-types/src/iota_names/error.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/iota-sdk-types/src/iota_names/error.rs b/crates/iota-sdk-types/src/iota_names/error.rs index bd539c5c6..60b712e52 100644 --- a/crates/iota-sdk-types/src/iota_names/error.rs +++ b/crates/iota-sdk-types/src/iota_names/error.rs @@ -21,7 +21,7 @@ pub enum IotaNamesError { InvalidLabelChar(char, usize), #[error("Name must contain at least two labels, TLN and SLN")] NotEnoughLabels, - #[error("Name must include only one separator")] + #[error("Name must include only one @ separator")] InvalidSeparator, #[error("Name has expired")] NameExpired,