diff --git a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go index c6d8007d7..48b26eb99 100644 --- a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go +++ b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go @@ -640,7 +640,7 @@ func uniffiCheckChecksums() { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_coin_metadata() }) - if checksum != 34454 { + if checksum != 10872 { // If this happens try cleaning and rebuilding your project panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_graphqlclient_coin_metadata: UniFFI API checksum mismatch") } @@ -883,7 +883,7 @@ func uniffiCheckChecksums() { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_service_config() }) - if checksum != 24210 { + if checksum != 11931 { // If this happens try cleaning and rebuilding your project panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_graphqlclient_service_config: UniFFI API checksum mismatch") } @@ -5186,66 +5186,6 @@ func (_ FfiDestroyerCoin) Destroy(value *Coin) { -type CoinMetadataInterface interface { -} -type CoinMetadata struct { - ffiObject FfiObject -} - - - -func (object *CoinMetadata) Destroy() { - runtime.SetFinalizer(object, nil) - object.ffiObject.destroy() -} - -type FfiConverterCoinMetadata struct {} - -var FfiConverterCoinMetadataINSTANCE = FfiConverterCoinMetadata{} - - -func (c FfiConverterCoinMetadata) Lift(pointer unsafe.Pointer) *CoinMetadata { - result := &CoinMetadata { - newFfiObject( - pointer, - func(pointer unsafe.Pointer, status *C.RustCallStatus) unsafe.Pointer { - return C.uniffi_iota_sdk_ffi_fn_clone_coinmetadata(pointer, status) - }, - func(pointer unsafe.Pointer, status *C.RustCallStatus) { - C.uniffi_iota_sdk_ffi_fn_free_coinmetadata(pointer, status) - }, - ), - } - runtime.SetFinalizer(result, (*CoinMetadata).Destroy) - return result -} - -func (c FfiConverterCoinMetadata) Read(reader io.Reader) *CoinMetadata { - return c.Lift(unsafe.Pointer(uintptr(readUint64(reader)))) -} - -func (c FfiConverterCoinMetadata) Lower(value *CoinMetadata) 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("*CoinMetadata") - defer value.ffiObject.decrementPointer() - return pointer - -} - -func (c FfiConverterCoinMetadata) Write(writer io.Writer, value *CoinMetadata) { - writeUint64(writer, uint64(uintptr(c.Lower(value)))) -} - -type FfiDestroyerCoinMetadata struct {} - -func (_ FfiDestroyerCoinMetadata) Destroy(value *CoinMetadata) { - value.Destroy() -} - - - type ConsensusCommitDigestInterface interface { ToBase58() string ToBytes() []byte @@ -6523,7 +6463,7 @@ type GraphQlClientInterface interface { // Get a page of [`CheckpointSummary`] for the provided parameters. Checkpoints(paginationFilter PaginationFilter) (CheckpointSummaryPage, error) // Get the coin metadata for the coin type. - CoinMetadata(coinType string) (**CoinMetadata, error) + CoinMetadata(coinType string) (*CoinMetadata, error) // Get the list of coins for the specified address. // // If `coin_type` is not provided, it will default to `0x2::coin::Coin`, @@ -6685,7 +6625,7 @@ type GraphQlClientInterface interface { ReferenceGasPrice(epoch *uint64) (*uint64, error) // Get the GraphQL service configuration, including complexity limits, read // and mutation limits, supported versions, and others. - ServiceConfig() (*ServiceConfig, error) + ServiceConfig() (ServiceConfig, error) // Set the server address for the GraphQL GraphQL client. It should be a // valid URL with a host and optionally a port number. SetRpcServer(server string) error @@ -6932,7 +6872,7 @@ func (_self *GraphQlClient) Checkpoints(paginationFilter PaginationFilter) (Chec } // Get the coin metadata for the coin type. -func (_self *GraphQlClient) CoinMetadata(coinType string) (**CoinMetadata, error) { +func (_self *GraphQlClient) CoinMetadata(coinType string) (*CoinMetadata, error) { _pointer := _self.ffiObject.incrementPointer("*GraphQlClient") defer _self.ffiObject.decrementPointer() res, err :=uniffiRustCallAsync[SdkFfiError]( @@ -6945,7 +6885,7 @@ func (_self *GraphQlClient) CoinMetadata(coinType string) (**CoinMetadata, error } }, // liftFn - func(ffi RustBufferI) **CoinMetadata { + func(ffi RustBufferI) *CoinMetadata { return FfiConverterOptionalCoinMetadataINSTANCE.Lift(ffi) }, C.uniffi_iota_sdk_ffi_fn_method_graphqlclient_coin_metadata( @@ -7902,29 +7842,31 @@ func (_self *GraphQlClient) ReferenceGasPrice(epoch *uint64) (*uint64, error) { // Get the GraphQL service configuration, including complexity limits, read // and mutation limits, supported versions, and others. -func (_self *GraphQlClient) ServiceConfig() (*ServiceConfig, error) { +func (_self *GraphQlClient) ServiceConfig() (ServiceConfig, error) { _pointer := _self.ffiObject.incrementPointer("*GraphQlClient") defer _self.ffiObject.decrementPointer() res, err :=uniffiRustCallAsync[SdkFfiError]( FfiConverterSdkFfiErrorINSTANCE, // completeFn - func(handle C.uint64_t, status *C.RustCallStatus) unsafe.Pointer { - res := C.ffi_iota_sdk_ffi_rust_future_complete_pointer(handle, status) - return res + 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 unsafe.Pointer) *ServiceConfig { + func(ffi RustBufferI) ServiceConfig { return FfiConverterServiceConfigINSTANCE.Lift(ffi) }, C.uniffi_iota_sdk_ffi_fn_method_graphqlclient_service_config( _pointer,), // pollFn func (handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { - C.ffi_iota_sdk_ffi_rust_future_poll_pointer(handle, continuation, data) + 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_pointer(handle) + C.ffi_iota_sdk_ffi_rust_future_free_rust_buffer(handle) }, ) @@ -11112,66 +11054,6 @@ func (_ FfiDestroyerSecp256r1Signature) Destroy(value *Secp256r1Signature) { -type ServiceConfigInterface interface { -} -type ServiceConfig struct { - ffiObject FfiObject -} - - - -func (object *ServiceConfig) Destroy() { - runtime.SetFinalizer(object, nil) - object.ffiObject.destroy() -} - -type FfiConverterServiceConfig struct {} - -var FfiConverterServiceConfigINSTANCE = FfiConverterServiceConfig{} - - -func (c FfiConverterServiceConfig) Lift(pointer unsafe.Pointer) *ServiceConfig { - result := &ServiceConfig { - newFfiObject( - pointer, - func(pointer unsafe.Pointer, status *C.RustCallStatus) unsafe.Pointer { - return C.uniffi_iota_sdk_ffi_fn_clone_serviceconfig(pointer, status) - }, - func(pointer unsafe.Pointer, status *C.RustCallStatus) { - C.uniffi_iota_sdk_ffi_fn_free_serviceconfig(pointer, status) - }, - ), - } - runtime.SetFinalizer(result, (*ServiceConfig).Destroy) - return result -} - -func (c FfiConverterServiceConfig) Read(reader io.Reader) *ServiceConfig { - return c.Lift(unsafe.Pointer(uintptr(readUint64(reader)))) -} - -func (c FfiConverterServiceConfig) Lower(value *ServiceConfig) 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("*ServiceConfig") - defer value.ffiObject.decrementPointer() - return pointer - -} - -func (c FfiConverterServiceConfig) Write(writer io.Writer, value *ServiceConfig) { - writeUint64(writer, uint64(uintptr(c.Lower(value)))) -} - -type FfiDestroyerServiceConfig struct {} - -func (_ FfiDestroyerServiceConfig) Destroy(value *ServiceConfig) { - value.Destroy() -} - - - // A basic signature // // This enumeration defines the set of simple or basic signature schemes @@ -13504,41 +13386,6 @@ func (_ FfiDestroyerZkLoginPublicIdentifier) Destroy(value *ZkLoginPublicIdentif -type BigInt struct { - Value string -} - -func (r *BigInt) Destroy() { - FfiDestroyerString{}.Destroy(r.Value); -} - -type FfiConverterBigInt struct {} - -var FfiConverterBigIntINSTANCE = FfiConverterBigInt{} - -func (c FfiConverterBigInt) Lift(rb RustBufferI) BigInt { - return LiftFromRustBuffer[BigInt](c, rb) -} - -func (c FfiConverterBigInt) Read(reader io.Reader) BigInt { - return BigInt { - FfiConverterStringINSTANCE.Read(reader), - } -} - -func (c FfiConverterBigInt) Lower(value BigInt) C.RustBuffer { - return LowerIntoRustBuffer[BigInt](c, value) -} - -func (c FfiConverterBigInt) Write(writer io.Writer, value BigInt) { - FfiConverterStringINSTANCE.Write(writer, value.Value); -} - -type FfiDestroyerBigInt struct {} - -func (_ FfiDestroyerBigInt) Destroy(value BigInt) { - value.Destroy() -} // Input/output state of an object that was changed during execution // // # BCS @@ -13775,6 +13622,73 @@ type FfiDestroyerCheckpointSummaryPage struct {} func (_ FfiDestroyerCheckpointSummaryPage) Destroy(value CheckpointSummaryPage) { value.Destroy() } +// The coin metadata associated with the given coin type. +type CoinMetadata struct { + // The number of decimal places used to represent the token. + Decimals *int32 + // Optional description of the token, provided by the creator of the token. + Description *string + // Icon URL of the coin. + IconUrl *string + // Full, official name of the token. + Name *string + // The token's identifying abbreviation. + Symbol *string + // The overall quantity of tokens that will be issued. + Supply *BigInt + // Version of the token. + Version uint64 +} + +func (r *CoinMetadata) Destroy() { + FfiDestroyerOptionalInt32{}.Destroy(r.Decimals); + FfiDestroyerOptionalString{}.Destroy(r.Description); + FfiDestroyerOptionalString{}.Destroy(r.IconUrl); + FfiDestroyerOptionalString{}.Destroy(r.Name); + FfiDestroyerOptionalString{}.Destroy(r.Symbol); + FfiDestroyerOptionalTypeBigInt{}.Destroy(r.Supply); + FfiDestroyerUint64{}.Destroy(r.Version); +} + +type FfiConverterCoinMetadata struct {} + +var FfiConverterCoinMetadataINSTANCE = FfiConverterCoinMetadata{} + +func (c FfiConverterCoinMetadata) Lift(rb RustBufferI) CoinMetadata { + return LiftFromRustBuffer[CoinMetadata](c, rb) +} + +func (c FfiConverterCoinMetadata) Read(reader io.Reader) CoinMetadata { + return CoinMetadata { + FfiConverterOptionalInt32INSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + FfiConverterOptionalTypeBigIntINSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + } +} + +func (c FfiConverterCoinMetadata) Lower(value CoinMetadata) C.RustBuffer { + return LowerIntoRustBuffer[CoinMetadata](c, value) +} + +func (c FfiConverterCoinMetadata) Write(writer io.Writer, value CoinMetadata) { + FfiConverterOptionalInt32INSTANCE.Write(writer, value.Decimals); + FfiConverterOptionalStringINSTANCE.Write(writer, value.Description); + FfiConverterOptionalStringINSTANCE.Write(writer, value.IconUrl); + FfiConverterOptionalStringINSTANCE.Write(writer, value.Name); + FfiConverterOptionalStringINSTANCE.Write(writer, value.Symbol); + FfiConverterOptionalTypeBigIntINSTANCE.Write(writer, value.Supply); + FfiConverterUint64INSTANCE.Write(writer, value.Version); +} + +type FfiDestroyerCoinMetadata struct {} + +func (_ FfiDestroyerCoinMetadata) Destroy(value CoinMetadata) { + value.Destroy() +} // A page of items returned by the GraphQL server. type CoinPage struct { // Information about the page, such as the cursor and whether there are @@ -13818,41 +13732,6 @@ type FfiDestroyerCoinPage struct {} func (_ FfiDestroyerCoinPage) Destroy(value CoinPage) { value.Destroy() } -type DateTime struct { - Value string -} - -func (r *DateTime) Destroy() { - FfiDestroyerString{}.Destroy(r.Value); -} - -type FfiConverterDateTime struct {} - -var FfiConverterDateTimeINSTANCE = FfiConverterDateTime{} - -func (c FfiConverterDateTime) Lift(rb RustBufferI) DateTime { - return LiftFromRustBuffer[DateTime](c, rb) -} - -func (c FfiConverterDateTime) Read(reader io.Reader) DateTime { - return DateTime { - FfiConverterStringINSTANCE.Read(reader), - } -} - -func (c FfiConverterDateTime) Lower(value DateTime) C.RustBuffer { - return LowerIntoRustBuffer[DateTime](c, value) -} - -func (c FfiConverterDateTime) Write(writer io.Writer, value DateTime) { - FfiConverterStringINSTANCE.Write(writer, value.Value); -} - -type FfiDestroyerDateTime struct {} - -func (_ FfiDestroyerDateTime) Destroy(value DateTime) { - value.Destroy() -} // The result of a dry run, which includes the effects of the transaction and // any errors that may have occurred. type DryRunResult struct { @@ -14955,11 +14834,11 @@ func (_ FfiDestroyerMoveModuleQuery) Destroy(value MoveModuleQuery) { value.Destroy() } type MoveObject struct { - Bcs *string + Bcs *Base64 } func (r *MoveObject) Destroy() { - FfiDestroyerOptionalString{}.Destroy(r.Bcs); + FfiDestroyerOptionalTypeBase64{}.Destroy(r.Bcs); } type FfiConverterMoveObject struct {} @@ -14972,7 +14851,7 @@ func (c FfiConverterMoveObject) Lift(rb RustBufferI) MoveObject { func (c FfiConverterMoveObject) Read(reader io.Reader) MoveObject { return MoveObject { - FfiConverterOptionalStringINSTANCE.Read(reader), + FfiConverterOptionalTypeBase64INSTANCE.Read(reader), } } @@ -14981,7 +14860,7 @@ func (c FfiConverterMoveObject) Lower(value MoveObject) C.RustBuffer { } func (c FfiConverterMoveObject) Write(writer io.Writer, value MoveObject) { - FfiConverterOptionalStringINSTANCE.Write(writer, value.Bcs); + FfiConverterOptionalTypeBase64INSTANCE.Write(writer, value.Bcs); } type FfiDestroyerMoveObject struct {} @@ -15535,7 +15414,9 @@ func (_ FfiDestroyerPageInfo) Destroy(value PageInfo) { // Pagination options for querying the GraphQL server. It defaults to forward // pagination with the GraphQL server's max page size. type PaginationFilter struct { + // The direction of pagination. Direction Direction + // An opaque cursor used for pagination. Cursor *string // The maximum number of items to return. If this is omitted, it will // lazily query the service configuration for the max page size. @@ -15579,6 +15460,124 @@ type FfiDestroyerPaginationFilter struct {} func (_ FfiDestroyerPaginationFilter) Destroy(value PaginationFilter) { value.Destroy() } +type ServiceConfig struct { + // Default number of elements allowed on a single page of a connection. + DefaultPageSize int32 + // List of all features that are enabled on this RPC service. + EnabledFeatures []Feature + // Maximum estimated cost of a database query used to serve a GraphQL + // request. This is measured in the same units that the database uses + // in EXPLAIN queries. + // Maximum nesting allowed in struct fields when calculating the layout of + // a single Move Type. + MaxMoveValueDepth int32 + // The maximum number of output nodes in a GraphQL response. + // Non-connection nodes have a count of 1, while connection nodes are + // counted as the specified 'first' or 'last' number of items, or the + // default_page_size as set by the server if those arguments are not + // set. Counts accumulate multiplicatively down the query tree. For + // example, if a query starts with a connection of first: 10 and has a + // field to a connection with last: 20, the count at the second level + // would be 200 nodes. This is then summed to the count of 10 nodes + // at the first level, for a total of 210 nodes. + MaxOutputNodes int32 + // Maximum number of elements allowed on a single page of a connection. + MaxPageSize int32 + // The maximum depth a GraphQL query can be to be accepted by this service. + MaxQueryDepth int32 + // The maximum number of nodes (field names) the service will accept in a + // single query. + MaxQueryNodes int32 + // Maximum length of a query payload string. + MaxQueryPayloadSize int32 + // Maximum nesting allowed in type arguments in Move Types resolved by this + // service. + MaxTypeArgumentDepth int32 + // Maximum number of type arguments passed into a generic instantiation of + // a Move Type resolved by this service. + MaxTypeArgumentWidth int32 + // Maximum number of structs that need to be processed when calculating the + // layout of a single Move Type. + MaxTypeNodes int32 + // Maximum time in milliseconds spent waiting for a response from fullnode + // after issuing a a transaction to execute. Note that the transaction + // may still succeed even in the case of a timeout. Transactions are + // idempotent, so a transaction that times out should be resubmitted + // until the network returns a definite response (success or failure, not + // timeout). + MutationTimeoutMs int32 + // Maximum time in milliseconds that will be spent to serve one query + // request. + RequestTimeoutMs int32 +} + +func (r *ServiceConfig) Destroy() { + FfiDestroyerInt32{}.Destroy(r.DefaultPageSize); + FfiDestroyerSequenceFeature{}.Destroy(r.EnabledFeatures); + FfiDestroyerInt32{}.Destroy(r.MaxMoveValueDepth); + FfiDestroyerInt32{}.Destroy(r.MaxOutputNodes); + FfiDestroyerInt32{}.Destroy(r.MaxPageSize); + FfiDestroyerInt32{}.Destroy(r.MaxQueryDepth); + FfiDestroyerInt32{}.Destroy(r.MaxQueryNodes); + FfiDestroyerInt32{}.Destroy(r.MaxQueryPayloadSize); + FfiDestroyerInt32{}.Destroy(r.MaxTypeArgumentDepth); + FfiDestroyerInt32{}.Destroy(r.MaxTypeArgumentWidth); + FfiDestroyerInt32{}.Destroy(r.MaxTypeNodes); + FfiDestroyerInt32{}.Destroy(r.MutationTimeoutMs); + FfiDestroyerInt32{}.Destroy(r.RequestTimeoutMs); +} + +type FfiConverterServiceConfig struct {} + +var FfiConverterServiceConfigINSTANCE = FfiConverterServiceConfig{} + +func (c FfiConverterServiceConfig) Lift(rb RustBufferI) ServiceConfig { + return LiftFromRustBuffer[ServiceConfig](c, rb) +} + +func (c FfiConverterServiceConfig) Read(reader io.Reader) ServiceConfig { + return ServiceConfig { + FfiConverterInt32INSTANCE.Read(reader), + FfiConverterSequenceFeatureINSTANCE.Read(reader), + FfiConverterInt32INSTANCE.Read(reader), + FfiConverterInt32INSTANCE.Read(reader), + FfiConverterInt32INSTANCE.Read(reader), + FfiConverterInt32INSTANCE.Read(reader), + FfiConverterInt32INSTANCE.Read(reader), + FfiConverterInt32INSTANCE.Read(reader), + FfiConverterInt32INSTANCE.Read(reader), + FfiConverterInt32INSTANCE.Read(reader), + FfiConverterInt32INSTANCE.Read(reader), + FfiConverterInt32INSTANCE.Read(reader), + FfiConverterInt32INSTANCE.Read(reader), + } +} + +func (c FfiConverterServiceConfig) Lower(value ServiceConfig) C.RustBuffer { + return LowerIntoRustBuffer[ServiceConfig](c, value) +} + +func (c FfiConverterServiceConfig) Write(writer io.Writer, value ServiceConfig) { + FfiConverterInt32INSTANCE.Write(writer, value.DefaultPageSize); + FfiConverterSequenceFeatureINSTANCE.Write(writer, value.EnabledFeatures); + FfiConverterInt32INSTANCE.Write(writer, value.MaxMoveValueDepth); + FfiConverterInt32INSTANCE.Write(writer, value.MaxOutputNodes); + FfiConverterInt32INSTANCE.Write(writer, value.MaxPageSize); + FfiConverterInt32INSTANCE.Write(writer, value.MaxQueryDepth); + FfiConverterInt32INSTANCE.Write(writer, value.MaxQueryNodes); + FfiConverterInt32INSTANCE.Write(writer, value.MaxQueryPayloadSize); + FfiConverterInt32INSTANCE.Write(writer, value.MaxTypeArgumentDepth); + FfiConverterInt32INSTANCE.Write(writer, value.MaxTypeArgumentWidth); + FfiConverterInt32INSTANCE.Write(writer, value.MaxTypeNodes); + FfiConverterInt32INSTANCE.Write(writer, value.MutationTimeoutMs); + FfiConverterInt32INSTANCE.Write(writer, value.RequestTimeoutMs); +} + +type FfiDestroyerServiceConfig struct {} + +func (_ FfiDestroyerServiceConfig) Destroy(value ServiceConfig) { + value.Destroy() +} type SignedTransaction struct { Transaction *Transaction Signatures []*UserSignature @@ -17563,6 +17562,42 @@ func (_ FfiDestroyerExecutionStatus) Destroy(value ExecutionStatus) { } +type Feature uint + +const ( + FeatureAnalytics Feature = 1 + FeatureCoins Feature = 2 + FeatureDynamicFields Feature = 3 + FeatureSubscriptions Feature = 4 + FeatureSystemState Feature = 5 +) + +type FfiConverterFeature struct {} + +var FfiConverterFeatureINSTANCE = FfiConverterFeature{} + +func (c FfiConverterFeature) Lift(rb RustBufferI) Feature { + return LiftFromRustBuffer[Feature](c, rb) +} + +func (c FfiConverterFeature) Lower(value Feature) C.RustBuffer { + return LowerIntoRustBuffer[Feature](c, value) +} +func (FfiConverterFeature) Read(reader io.Reader) Feature { + id := readInt32(reader) + return Feature(id) +} + +func (FfiConverterFeature) Write(writer io.Writer, value Feature) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerFeature struct {} + +func (_ FfiDestroyerFeature) Destroy(value Feature) { +} + + type IdOperation uint const ( @@ -18776,43 +18811,6 @@ func (_ FfiDestroyerOptionalCheckpointDigest) Destroy(value **CheckpointDigest) } } -type FfiConverterOptionalCoinMetadata struct{} - -var FfiConverterOptionalCoinMetadataINSTANCE = FfiConverterOptionalCoinMetadata{} - -func (c FfiConverterOptionalCoinMetadata) Lift(rb RustBufferI) **CoinMetadata { - return LiftFromRustBuffer[**CoinMetadata](c, rb) -} - -func (_ FfiConverterOptionalCoinMetadata) Read(reader io.Reader) **CoinMetadata { - if readInt8(reader) == 0 { - return nil - } - temp := FfiConverterCoinMetadataINSTANCE.Read(reader) - return &temp -} - -func (c FfiConverterOptionalCoinMetadata) Lower(value **CoinMetadata) C.RustBuffer { - return LowerIntoRustBuffer[**CoinMetadata](c, value) -} - -func (_ FfiConverterOptionalCoinMetadata) Write(writer io.Writer, value **CoinMetadata) { - if value == nil { - writeInt8(writer, 0) - } else { - writeInt8(writer, 1) - FfiConverterCoinMetadataINSTANCE.Write(writer, *value) - } -} - -type FfiDestroyerOptionalCoinMetadata struct {} - -func (_ FfiDestroyerOptionalCoinMetadata) Destroy(value **CoinMetadata) { - if value != nil { - FfiDestroyerCoinMetadata{}.Destroy(*value) - } -} - type FfiConverterOptionalEd25519PublicKey struct{} var FfiConverterOptionalEd25519PublicKeyINSTANCE = FfiConverterOptionalEd25519PublicKey{} @@ -19664,6 +19662,43 @@ func (_ FfiDestroyerOptionalCheckpointSummary) Destroy(value *CheckpointSummary) } } +type FfiConverterOptionalCoinMetadata struct{} + +var FfiConverterOptionalCoinMetadataINSTANCE = FfiConverterOptionalCoinMetadata{} + +func (c FfiConverterOptionalCoinMetadata) Lift(rb RustBufferI) *CoinMetadata { + return LiftFromRustBuffer[*CoinMetadata](c, rb) +} + +func (_ FfiConverterOptionalCoinMetadata) Read(reader io.Reader) *CoinMetadata { + if readInt8(reader) == 0 { + return nil + } + temp := FfiConverterCoinMetadataINSTANCE.Read(reader) + return &temp +} + +func (c FfiConverterOptionalCoinMetadata) Lower(value *CoinMetadata) C.RustBuffer { + return LowerIntoRustBuffer[*CoinMetadata](c, value) +} + +func (_ FfiConverterOptionalCoinMetadata) Write(writer io.Writer, value *CoinMetadata) { + if value == nil { + writeInt8(writer, 0) + } else { + writeInt8(writer, 1) + FfiConverterCoinMetadataINSTANCE.Write(writer, *value) + } +} + +type FfiDestroyerOptionalCoinMetadata struct {} + +func (_ FfiDestroyerOptionalCoinMetadata) Destroy(value *CoinMetadata) { + if value != nil { + FfiDestroyerCoinMetadata{}.Destroy(*value) + } +} + type FfiConverterOptionalDynamicFieldOutput struct{} var FfiConverterOptionalDynamicFieldOutputINSTANCE = FfiConverterOptionalDynamicFieldOutput{} @@ -20737,6 +20772,43 @@ func (_ FfiDestroyerOptionalTypeBase64) Destroy(value *Base64) { } } +type FfiConverterOptionalTypeBigInt struct{} + +var FfiConverterOptionalTypeBigIntINSTANCE = FfiConverterOptionalTypeBigInt{} + +func (c FfiConverterOptionalTypeBigInt) Lift(rb RustBufferI) *BigInt { + return LiftFromRustBuffer[*BigInt](c, rb) +} + +func (_ FfiConverterOptionalTypeBigInt) Read(reader io.Reader) *BigInt { + if readInt8(reader) == 0 { + return nil + } + temp := FfiConverterTypeBigIntINSTANCE.Read(reader) + return &temp +} + +func (c FfiConverterOptionalTypeBigInt) Lower(value *BigInt) C.RustBuffer { + return LowerIntoRustBuffer[*BigInt](c, value) +} + +func (_ FfiConverterOptionalTypeBigInt) Write(writer io.Writer, value *BigInt) { + if value == nil { + writeInt8(writer, 0) + } else { + writeInt8(writer, 1) + FfiConverterTypeBigIntINSTANCE.Write(writer, *value) + } +} + +type FfiDestroyerOptionalTypeBigInt struct {} + +func (_ FfiDestroyerOptionalTypeBigInt) Destroy(value *BigInt) { + if value != nil { + FfiDestroyerTypeBigInt{}.Destroy(*value) + } +} + type FfiConverterOptionalTypeValue struct{} var FfiConverterOptionalTypeValueINSTANCE = FfiConverterOptionalTypeValue{} @@ -22279,6 +22351,49 @@ func (FfiDestroyerSequenceValidatorCommitteeMember) Destroy(sequence []Validator } } +type FfiConverterSequenceFeature struct{} + +var FfiConverterSequenceFeatureINSTANCE = FfiConverterSequenceFeature{} + +func (c FfiConverterSequenceFeature) Lift(rb RustBufferI) []Feature { + return LiftFromRustBuffer[[]Feature](c, rb) +} + +func (c FfiConverterSequenceFeature) Read(reader io.Reader) []Feature { + length := readInt32(reader) + if length == 0 { + return nil + } + result := make([]Feature, 0, length) + for i := int32(0); i < length; i++ { + result = append(result, FfiConverterFeatureINSTANCE.Read(reader)) + } + return result +} + +func (c FfiConverterSequenceFeature) Lower(value []Feature) C.RustBuffer { + return LowerIntoRustBuffer[[]Feature](c, value) +} + +func (c FfiConverterSequenceFeature) Write(writer io.Writer, value []Feature) { + if len(value) > math.MaxInt32 { + panic("[]Feature is too large to fit into Int32") + } + + writeInt32(writer, int32(len(value))) + for _, item := range value { + FfiConverterFeatureINSTANCE.Write(writer, item) + } +} + +type FfiDestroyerSequenceFeature struct {} + +func (FfiDestroyerSequenceFeature) Destroy(sequence []Feature) { + for _, value := range sequence { + FfiDestroyerFeature{}.Destroy(value) + } +} + type FfiConverterSequenceMoveAbility struct{} var FfiConverterSequenceMoveAbilityINSTANCE = FfiConverterSequenceMoveAbility{} @@ -22418,6 +22533,15 @@ type Base64 = string type FfiConverterTypeBase64 = FfiConverterString type FfiDestroyerTypeBase64 = FfiDestroyerString var FfiConverterTypeBase64INSTANCE = FfiConverterString{} +/** + * Typealias from the type name used in the UDL file to the builtin type. This + * is needed because the UDL type name is used in function/method signatures. + * It's also what we have an external type that references a custom type. + */ +type BigInt = string +type FfiConverterTypeBigInt = FfiConverterString +type FfiDestroyerTypeBigInt = FfiDestroyerString +var FfiConverterTypeBigIntINSTANCE = FfiConverterString{} /** * Typealias from the type name used in the UDL file to the builtin type. This * is needed because the UDL type name is used in function/method signatures. diff --git a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h index f0c2b14bd..d38afedd4 100644 --- a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h +++ b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h @@ -713,16 +713,6 @@ void* uniffi_iota_sdk_ffi_fn_method_coin_coin_type(void* ptr, RustCallStatus *ou void* uniffi_iota_sdk_ffi_fn_method_coin_id(void* ptr, RustCallStatus *out_status ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_COINMETADATA -#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_COINMETADATA -void* uniffi_iota_sdk_ffi_fn_clone_coinmetadata(void* ptr, RustCallStatus *out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_FREE_COINMETADATA -#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_FREE_COINMETADATA -void uniffi_iota_sdk_ffi_fn_free_coinmetadata(void* ptr, RustCallStatus *out_status -); -#endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_CONSENSUSCOMMITDIGEST #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_CONSENSUSCOMMITDIGEST void* uniffi_iota_sdk_ffi_fn_clone_consensuscommitdigest(void* ptr, RustCallStatus *out_status @@ -1998,16 +1988,6 @@ void* uniffi_iota_sdk_ffi_fn_constructor_secp256r1signature_generate(RustCallSta RustBuffer uniffi_iota_sdk_ffi_fn_method_secp256r1signature_to_bytes(void* ptr, RustCallStatus *out_status ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_SERVICECONFIG -#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_SERVICECONFIG -void* uniffi_iota_sdk_ffi_fn_clone_serviceconfig(void* ptr, RustCallStatus *out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_FREE_SERVICECONFIG -#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_FREE_SERVICECONFIG -void uniffi_iota_sdk_ffi_fn_free_serviceconfig(void* ptr, RustCallStatus *out_status -); -#endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_SIMPLESIGNATURE #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_SIMPLESIGNATURE void* uniffi_iota_sdk_ffi_fn_clone_simplesignature(void* ptr, RustCallStatus *out_status diff --git a/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt b/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt index d340091ac..b949332ce 100644 --- a/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt +++ b/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt @@ -1502,10 +1502,6 @@ internal interface UniffiForeignFutureCompleteVoid : com.sun.jna.Callback { - - - - @@ -2369,10 +2365,6 @@ fun uniffi_iota_sdk_ffi_fn_method_coin_coin_type(`ptr`: Pointer,uniffi_out_err: ): Pointer fun uniffi_iota_sdk_ffi_fn_method_coin_id(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Pointer -fun uniffi_iota_sdk_ffi_fn_clone_coinmetadata(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, -): Pointer -fun uniffi_iota_sdk_ffi_fn_free_coinmetadata(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, -): Unit fun uniffi_iota_sdk_ffi_fn_clone_consensuscommitdigest(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_iota_sdk_ffi_fn_free_consensuscommitdigest(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, @@ -2875,10 +2867,6 @@ fun uniffi_iota_sdk_ffi_fn_constructor_secp256r1signature_generate(uniffi_out_er ): Pointer fun uniffi_iota_sdk_ffi_fn_method_secp256r1signature_to_bytes(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): RustBuffer.ByValue -fun uniffi_iota_sdk_ffi_fn_clone_serviceconfig(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, -): Pointer -fun uniffi_iota_sdk_ffi_fn_free_serviceconfig(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, -): Unit fun uniffi_iota_sdk_ffi_fn_clone_simplesignature(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_iota_sdk_ffi_fn_free_simplesignature(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, @@ -3378,7 +3366,7 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_checkpoints() != 8422.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_coin_metadata() != 34454.toShort()) { + if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_coin_metadata() != 10872.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_coins() != 48442.toShort()) { @@ -3459,7 +3447,7 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_reference_gas_price() != 39065.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_service_config() != 24210.toShort()) { + if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_service_config() != 11931.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_set_rpc_server() != 31958.toShort()) { @@ -8822,228 +8810,6 @@ public object FfiConverterTypeCoin: FfiConverter { // -public interface CoinMetadataInterface { - - companion object -} - -open class CoinMetadata: Disposable, AutoCloseable, CoinMetadataInterface -{ - - 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_coinmetadata(ptr, status) - } - } - } - } - - fun uniffiClonePointer(): Pointer { - return uniffiRustCall() { status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_clone_coinmetadata(pointer!!, status) - } - } - - - - - - companion object - -} - -/** - * @suppress - */ -public object FfiConverterTypeCoinMetadata: FfiConverter { - - override fun lower(value: CoinMetadata): Pointer { - return value.uniffiClonePointer() - } - - override fun lift(value: Pointer): CoinMetadata { - return CoinMetadata(value) - } - - override fun read(buf: ByteBuffer): CoinMetadata { - // 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: CoinMetadata) = 8UL - - override fun write(value: CoinMetadata, 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 ConsensusCommitDigestInterface { fun `toBase58`(): kotlin.String @@ -13651,9 +13417,9 @@ open class GraphQlClient: Disposable, AutoCloseable, GraphQlClientInterface ) }, - { future, callback, continuation -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_poll_pointer(future, callback, continuation) }, - { future, continuation -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_complete_pointer(future, continuation) }, - { future -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_free_pointer(future) }, + { 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 { FfiConverterTypeServiceConfig.lift(it) }, // Error FFI converter @@ -20725,228 +20491,6 @@ public object FfiConverterTypeSecp256r1Signature: FfiConverter 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_serviceconfig(ptr, status) - } - } - } - } - - fun uniffiClonePointer(): Pointer { - return uniffiRustCall() { status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_clone_serviceconfig(pointer!!, status) - } - } - - - - - - companion object - -} - -/** - * @suppress - */ -public object FfiConverterTypeServiceConfig: FfiConverter { - - override fun lower(value: ServiceConfig): Pointer { - return value.uniffiClonePointer() - } - - override fun lift(value: Pointer): ServiceConfig { - return ServiceConfig(value) - } - - override fun read(buf: ByteBuffer): ServiceConfig { - // 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: ServiceConfig) = 8UL - - override fun write(value: ServiceConfig, 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 -// - - /** * A basic signature * @@ -25840,34 +25384,6 @@ public object FfiConverterTypeZkLoginPublicIdentifier: FfiConverter { - override fun read(buf: ByteBuffer): BigInt { - return BigInt( - FfiConverterString.read(buf), - ) - } - - override fun allocationSize(value: BigInt) = ( - FfiConverterString.allocationSize(value.`value`) - ) - - override fun write(value: BigInt, buf: ByteBuffer) { - FfiConverterString.write(value.`value`, buf) - } -} - - - /** * Input/output state of an object that was changed during execution * @@ -26158,6 +25674,82 @@ public object FfiConverterTypeCheckpointSummaryPage: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): CoinMetadata { + return CoinMetadata( + FfiConverterOptionalInt.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterOptionalTypeBigInt.read(buf), + FfiConverterULong.read(buf), + ) + } + + override fun allocationSize(value: CoinMetadata) = ( + FfiConverterOptionalInt.allocationSize(value.`decimals`) + + FfiConverterOptionalString.allocationSize(value.`description`) + + FfiConverterOptionalString.allocationSize(value.`iconUrl`) + + FfiConverterOptionalString.allocationSize(value.`name`) + + FfiConverterOptionalString.allocationSize(value.`symbol`) + + FfiConverterOptionalTypeBigInt.allocationSize(value.`supply`) + + FfiConverterULong.allocationSize(value.`version`) + ) + + override fun write(value: CoinMetadata, buf: ByteBuffer) { + FfiConverterOptionalInt.write(value.`decimals`, buf) + FfiConverterOptionalString.write(value.`description`, buf) + FfiConverterOptionalString.write(value.`iconUrl`, buf) + FfiConverterOptionalString.write(value.`name`, buf) + FfiConverterOptionalString.write(value.`symbol`, buf) + FfiConverterOptionalTypeBigInt.write(value.`supply`, buf) + FfiConverterULong.write(value.`version`, buf) + } +} + + + /** * A page of items returned by the GraphQL server. */ @@ -26209,34 +25801,6 @@ public object FfiConverterTypeCoinPage: FfiConverterRustBuffer { -data class DateTime ( - var `value`: kotlin.String -) { - - companion object -} - -/** - * @suppress - */ -public object FfiConverterTypeDateTime: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): DateTime { - return DateTime( - FfiConverterString.read(buf), - ) - } - - override fun allocationSize(value: DateTime) = ( - FfiConverterString.allocationSize(value.`value`) - ) - - override fun write(value: DateTime, buf: ByteBuffer) { - FfiConverterString.write(value.`value`, buf) - } -} - - - /** * The result of a dry run, which includes the effects of the transaction and * any errors that may have occurred. @@ -27395,7 +26959,7 @@ public object FfiConverterTypeMoveModuleQuery: FfiConverterRustBuffer { override fun read(buf: ByteBuffer): MoveObject { return MoveObject( - FfiConverterOptionalString.read(buf), + FfiConverterOptionalTypeBase64.read(buf), ) } override fun allocationSize(value: MoveObject) = ( - FfiConverterOptionalString.allocationSize(value.`bcs`) + FfiConverterOptionalTypeBase64.allocationSize(value.`bcs`) ) override fun write(value: MoveObject, buf: ByteBuffer) { - FfiConverterOptionalString.write(value.`bcs`, buf) + FfiConverterOptionalTypeBase64.write(value.`bcs`, buf) } } @@ -27985,7 +27549,13 @@ public object FfiConverterTypePageInfo: FfiConverterRustBuffer { * pagination with the GraphQL server's max page size. */ data class PaginationFilter ( + /** + * The direction of pagination. + */ var `direction`: Direction, + /** + * An opaque cursor used for pagination. + */ var `cursor`: kotlin.String? = null, /** * The maximum number of items to return. If this is omitted, it will @@ -28024,6 +27594,143 @@ public object FfiConverterTypePaginationFilter: FfiConverterRustBuffer, + /** + * Maximum estimated cost of a database query used to serve a GraphQL + * request. This is measured in the same units that the database uses + * in EXPLAIN queries. + * Maximum nesting allowed in struct fields when calculating the layout of + * a single Move Type. + */ + var `maxMoveValueDepth`: kotlin.Int, + /** + * The maximum number of output nodes in a GraphQL response. + * Non-connection nodes have a count of 1, while connection nodes are + * counted as the specified 'first' or 'last' number of items, or the + * default_page_size as set by the server if those arguments are not + * set. Counts accumulate multiplicatively down the query tree. For + * example, if a query starts with a connection of first: 10 and has a + * field to a connection with last: 20, the count at the second level + * would be 200 nodes. This is then summed to the count of 10 nodes + * at the first level, for a total of 210 nodes. + */ + var `maxOutputNodes`: kotlin.Int, + /** + * Maximum number of elements allowed on a single page of a connection. + */ + var `maxPageSize`: kotlin.Int, + /** + * The maximum depth a GraphQL query can be to be accepted by this service. + */ + var `maxQueryDepth`: kotlin.Int, + /** + * The maximum number of nodes (field names) the service will accept in a + * single query. + */ + var `maxQueryNodes`: kotlin.Int, + /** + * Maximum length of a query payload string. + */ + var `maxQueryPayloadSize`: kotlin.Int, + /** + * Maximum nesting allowed in type arguments in Move Types resolved by this + * service. + */ + var `maxTypeArgumentDepth`: kotlin.Int, + /** + * Maximum number of type arguments passed into a generic instantiation of + * a Move Type resolved by this service. + */ + var `maxTypeArgumentWidth`: kotlin.Int, + /** + * Maximum number of structs that need to be processed when calculating the + * layout of a single Move Type. + */ + var `maxTypeNodes`: kotlin.Int, + /** + * Maximum time in milliseconds spent waiting for a response from fullnode + * after issuing a a transaction to execute. Note that the transaction + * may still succeed even in the case of a timeout. Transactions are + * idempotent, so a transaction that times out should be resubmitted + * until the network returns a definite response (success or failure, not + * timeout). + */ + var `mutationTimeoutMs`: kotlin.Int, + /** + * Maximum time in milliseconds that will be spent to serve one query + * request. + */ + var `requestTimeoutMs`: kotlin.Int +) { + + companion object +} + +/** + * @suppress + */ +public object FfiConverterTypeServiceConfig: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): ServiceConfig { + return ServiceConfig( + FfiConverterInt.read(buf), + FfiConverterSequenceTypeFeature.read(buf), + FfiConverterInt.read(buf), + FfiConverterInt.read(buf), + FfiConverterInt.read(buf), + FfiConverterInt.read(buf), + FfiConverterInt.read(buf), + FfiConverterInt.read(buf), + FfiConverterInt.read(buf), + FfiConverterInt.read(buf), + FfiConverterInt.read(buf), + FfiConverterInt.read(buf), + FfiConverterInt.read(buf), + ) + } + + override fun allocationSize(value: ServiceConfig) = ( + FfiConverterInt.allocationSize(value.`defaultPageSize`) + + FfiConverterSequenceTypeFeature.allocationSize(value.`enabledFeatures`) + + FfiConverterInt.allocationSize(value.`maxMoveValueDepth`) + + FfiConverterInt.allocationSize(value.`maxOutputNodes`) + + FfiConverterInt.allocationSize(value.`maxPageSize`) + + FfiConverterInt.allocationSize(value.`maxQueryDepth`) + + FfiConverterInt.allocationSize(value.`maxQueryNodes`) + + FfiConverterInt.allocationSize(value.`maxQueryPayloadSize`) + + FfiConverterInt.allocationSize(value.`maxTypeArgumentDepth`) + + FfiConverterInt.allocationSize(value.`maxTypeArgumentWidth`) + + FfiConverterInt.allocationSize(value.`maxTypeNodes`) + + FfiConverterInt.allocationSize(value.`mutationTimeoutMs`) + + FfiConverterInt.allocationSize(value.`requestTimeoutMs`) + ) + + override fun write(value: ServiceConfig, buf: ByteBuffer) { + FfiConverterInt.write(value.`defaultPageSize`, buf) + FfiConverterSequenceTypeFeature.write(value.`enabledFeatures`, buf) + FfiConverterInt.write(value.`maxMoveValueDepth`, buf) + FfiConverterInt.write(value.`maxOutputNodes`, buf) + FfiConverterInt.write(value.`maxPageSize`, buf) + FfiConverterInt.write(value.`maxQueryDepth`, buf) + FfiConverterInt.write(value.`maxQueryNodes`, buf) + FfiConverterInt.write(value.`maxQueryPayloadSize`, buf) + FfiConverterInt.write(value.`maxTypeArgumentDepth`, buf) + FfiConverterInt.write(value.`maxTypeArgumentWidth`, buf) + FfiConverterInt.write(value.`maxTypeNodes`, buf) + FfiConverterInt.write(value.`mutationTimeoutMs`, buf) + FfiConverterInt.write(value.`requestTimeoutMs`, buf) + } +} + + + data class SignedTransaction ( var `transaction`: Transaction, var `signatures`: List @@ -30690,6 +30397,39 @@ public object FfiConverterTypeExecutionStatus : FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + Feature.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: Feature) = 4UL + + override fun write(value: Feature, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + + enum class IdOperation { NONE, @@ -32002,38 +31742,6 @@ public object FfiConverterOptionalTypeCheckpointDigest: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): CoinMetadata? { - if (buf.get().toInt() == 0) { - return null - } - return FfiConverterTypeCoinMetadata.read(buf) - } - - override fun allocationSize(value: CoinMetadata?): ULong { - if (value == null) { - return 1UL - } else { - return 1UL + FfiConverterTypeCoinMetadata.allocationSize(value) - } - } - - override fun write(value: CoinMetadata?, buf: ByteBuffer) { - if (value == null) { - buf.put(0) - } else { - buf.put(1) - FfiConverterTypeCoinMetadata.write(value, buf) - } - } -} - - - - /** * @suppress */ @@ -32770,6 +32478,38 @@ public object FfiConverterOptionalTypeCheckpointSummary: FfiConverterRustBuffer< +/** + * @suppress + */ +public object FfiConverterOptionalTypeCoinMetadata: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): CoinMetadata? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterTypeCoinMetadata.read(buf) + } + + override fun allocationSize(value: CoinMetadata?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterTypeCoinMetadata.allocationSize(value) + } + } + + override fun write(value: CoinMetadata?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterTypeCoinMetadata.write(value, buf) + } + } +} + + + + /** * @suppress */ @@ -33698,6 +33438,38 @@ public object FfiConverterOptionalTypeBase64: FfiConverterRustBuffer { +/** + * @suppress + */ +public object FfiConverterOptionalTypeBigInt: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): BigInt? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterTypeBigInt.read(buf) + } + + override fun allocationSize(value: BigInt?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterTypeBigInt.allocationSize(value) + } + } + + override fun write(value: BigInt?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterTypeBigInt.write(value, buf) + } + } +} + + + + /** * @suppress */ @@ -34710,6 +34482,34 @@ public object FfiConverterSequenceTypeValidatorCommitteeMember: FfiConverterRust +/** + * @suppress + */ +public object FfiConverterSequenceTypeFeature: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeFeature.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.map { FfiConverterTypeFeature.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeFeature.write(it, buf) + } + } +} + + + + /** * @suppress */ @@ -34825,6 +34625,16 @@ public typealias FfiConverterTypeBase64 = FfiConverterString +/** + * Typealias from the type name used in the UDL file to the builtin type. This + * is needed because the UDL type name is used in function/method signatures. + * It's also what we have an external type that references a custom type. + */ +public typealias BigInt = kotlin.String +public typealias FfiConverterTypeBigInt = FfiConverterString + + + /** * Typealias from the type name used in the UDL file to the builtin type. This * is needed because the UDL type name is used in function/method signatures. diff --git a/bindings/python/lib/iota_sdk_ffi.py b/bindings/python/lib/iota_sdk_ffi.py index 27b5915bb..8ead9350a 100644 --- a/bindings/python/lib/iota_sdk_ffi.py +++ b/bindings/python/lib/iota_sdk_ffi.py @@ -523,7 +523,7 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_checkpoints() != 8422: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_coin_metadata() != 34454: + if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_coin_metadata() != 10872: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_coins() != 48442: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") @@ -577,7 +577,7 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_reference_gas_price() != 39065: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_service_config() != 24210: + if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_service_config() != 11931: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_set_rpc_server() != 31958: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") @@ -1561,16 +1561,6 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_iota_sdk_ffi_fn_method_coin_id.restype = ctypes.c_void_p -_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_coinmetadata.argtypes = ( - ctypes.c_void_p, - ctypes.POINTER(_UniffiRustCallStatus), -) -_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_coinmetadata.restype = ctypes.c_void_p -_UniffiLib.uniffi_iota_sdk_ffi_fn_free_coinmetadata.argtypes = ( - ctypes.c_void_p, - ctypes.POINTER(_UniffiRustCallStatus), -) -_UniffiLib.uniffi_iota_sdk_ffi_fn_free_coinmetadata.restype = None _UniffiLib.uniffi_iota_sdk_ffi_fn_clone_consensuscommitdigest.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), @@ -2849,16 +2839,6 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256r1signature_to_bytes.restype = _UniffiRustBuffer -_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_serviceconfig.argtypes = ( - ctypes.c_void_p, - ctypes.POINTER(_UniffiRustCallStatus), -) -_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_serviceconfig.restype = ctypes.c_void_p -_UniffiLib.uniffi_iota_sdk_ffi_fn_free_serviceconfig.argtypes = ( - ctypes.c_void_p, - ctypes.POINTER(_UniffiRustCallStatus), -) -_UniffiLib.uniffi_iota_sdk_ffi_fn_free_serviceconfig.restype = None _UniffiLib.uniffi_iota_sdk_ffi_fn_clone_simplesignature.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), @@ -5106,39 +5086,6 @@ def write(value, buf): - - - - - - -class BigInt: - value: "str" - def __init__(self, *, value: "str"): - self.value = value - - def __str__(self): - return "BigInt(value={})".format(self.value) - - def __eq__(self, other): - if self.value != other.value: - return False - return True - -class _UniffiConverterTypeBigInt(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return BigInt( - value=_UniffiConverterString.read(buf), - ) - - @staticmethod - def check_lower(value): - _UniffiConverterString.check_lower(value.value) - - @staticmethod - def write(value, buf): - _UniffiConverterString.write(value.value, buf) class ChangedObject: @@ -5455,6 +5402,127 @@ def write(value, buf): _UniffiConverterSequenceTypeCheckpointSummary.write(value.data, buf) +class CoinMetadata: + """ + The coin metadata associated with the given coin type. + """ + + decimals: "typing.Optional[int]" + """ + The number of decimal places used to represent the token. + """ + + description: "typing.Optional[str]" + """ + Optional description of the token, provided by the creator of the token. + """ + + icon_url: "typing.Optional[str]" + """ + Icon URL of the coin. + """ + + name: "typing.Optional[str]" + """ + Full, official name of the token. + """ + + symbol: "typing.Optional[str]" + """ + The token's identifying abbreviation. + """ + + supply: "typing.Optional[BigInt]" + """ + The overall quantity of tokens that will be issued. + """ + + version: "int" + """ + Version of the token. + """ + + def __init__(self, *, decimals: "typing.Optional[int]" = _DEFAULT, description: "typing.Optional[str]" = _DEFAULT, icon_url: "typing.Optional[str]" = _DEFAULT, name: "typing.Optional[str]" = _DEFAULT, symbol: "typing.Optional[str]" = _DEFAULT, supply: "typing.Optional[BigInt]" = _DEFAULT, version: "int"): + if decimals is _DEFAULT: + self.decimals = None + else: + self.decimals = decimals + if description is _DEFAULT: + self.description = None + else: + self.description = description + if icon_url is _DEFAULT: + self.icon_url = None + else: + self.icon_url = icon_url + if name is _DEFAULT: + self.name = None + else: + self.name = name + if symbol is _DEFAULT: + self.symbol = None + else: + self.symbol = symbol + if supply is _DEFAULT: + self.supply = None + else: + self.supply = supply + self.version = version + + def __str__(self): + return "CoinMetadata(decimals={}, description={}, icon_url={}, name={}, symbol={}, supply={}, version={})".format(self.decimals, self.description, self.icon_url, self.name, self.symbol, self.supply, self.version) + + def __eq__(self, other): + if self.decimals != other.decimals: + return False + if self.description != other.description: + return False + if self.icon_url != other.icon_url: + return False + if self.name != other.name: + return False + if self.symbol != other.symbol: + return False + if self.supply != other.supply: + return False + if self.version != other.version: + return False + return True + +class _UniffiConverterTypeCoinMetadata(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return CoinMetadata( + decimals=_UniffiConverterOptionalInt32.read(buf), + description=_UniffiConverterOptionalString.read(buf), + icon_url=_UniffiConverterOptionalString.read(buf), + name=_UniffiConverterOptionalString.read(buf), + symbol=_UniffiConverterOptionalString.read(buf), + supply=_UniffiConverterOptionalTypeBigInt.read(buf), + version=_UniffiConverterUInt64.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiConverterOptionalInt32.check_lower(value.decimals) + _UniffiConverterOptionalString.check_lower(value.description) + _UniffiConverterOptionalString.check_lower(value.icon_url) + _UniffiConverterOptionalString.check_lower(value.name) + _UniffiConverterOptionalString.check_lower(value.symbol) + _UniffiConverterOptionalTypeBigInt.check_lower(value.supply) + _UniffiConverterUInt64.check_lower(value.version) + + @staticmethod + def write(value, buf): + _UniffiConverterOptionalInt32.write(value.decimals, buf) + _UniffiConverterOptionalString.write(value.description, buf) + _UniffiConverterOptionalString.write(value.icon_url, buf) + _UniffiConverterOptionalString.write(value.name, buf) + _UniffiConverterOptionalString.write(value.symbol, buf) + _UniffiConverterOptionalTypeBigInt.write(value.supply, buf) + _UniffiConverterUInt64.write(value.version, buf) + + class CoinPage: """ A page of items returned by the GraphQL server. @@ -5504,35 +5572,6 @@ def write(value, buf): _UniffiConverterSequenceTypeCoin.write(value.data, buf) -class DateTime: - value: "str" - def __init__(self, *, value: "str"): - self.value = value - - def __str__(self): - return "DateTime(value={})".format(self.value) - - def __eq__(self, other): - if self.value != other.value: - return False - return True - -class _UniffiConverterTypeDateTime(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return DateTime( - value=_UniffiConverterString.read(buf), - ) - - @staticmethod - def check_lower(value): - _UniffiConverterString.check_lower(value.value) - - @staticmethod - def write(value, buf): - _UniffiConverterString.write(value.value, buf) - - class DryRunResult: """ The result of a dry run, which includes the effects of the transaction and @@ -6776,8 +6815,8 @@ def write(value, buf): class MoveObject: - bcs: "typing.Optional[str]" - def __init__(self, *, bcs: "typing.Optional[str]" = _DEFAULT): + bcs: "typing.Optional[Base64]" + def __init__(self, *, bcs: "typing.Optional[Base64]" = _DEFAULT): if bcs is _DEFAULT: self.bcs = None else: @@ -6795,16 +6834,16 @@ class _UniffiConverterTypeMoveObject(_UniffiConverterRustBuffer): @staticmethod def read(buf): return MoveObject( - bcs=_UniffiConverterOptionalString.read(buf), + bcs=_UniffiConverterOptionalTypeBase64.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterOptionalString.check_lower(value.bcs) + _UniffiConverterOptionalTypeBase64.check_lower(value.bcs) @staticmethod def write(value, buf): - _UniffiConverterOptionalString.write(value.bcs, buf) + _UniffiConverterOptionalTypeBase64.write(value.bcs, buf) class MovePackagePage: @@ -7396,7 +7435,15 @@ class PaginationFilter: """ direction: "Direction" + """ + The direction of pagination. + """ + cursor: "typing.Optional[str]" + """ + An opaque cursor used for pagination. + """ + limit: "typing.Optional[int]" """ The maximum number of items to return. If this is omitted, it will @@ -7448,6 +7495,193 @@ def write(value, buf): _UniffiConverterOptionalInt32.write(value.limit, buf) +class ServiceConfig: + default_page_size: "int" + """ + Default number of elements allowed on a single page of a connection. + """ + + enabled_features: "typing.List[Feature]" + """ + List of all features that are enabled on this RPC service. + """ + + max_move_value_depth: "int" + """ + Maximum estimated cost of a database query used to serve a GraphQL + request. This is measured in the same units that the database uses + in EXPLAIN queries. + Maximum nesting allowed in struct fields when calculating the layout of + a single Move Type. + """ + + max_output_nodes: "int" + """ + The maximum number of output nodes in a GraphQL response. + Non-connection nodes have a count of 1, while connection nodes are + counted as the specified 'first' or 'last' number of items, or the + default_page_size as set by the server if those arguments are not + set. Counts accumulate multiplicatively down the query tree. For + example, if a query starts with a connection of first: 10 and has a + field to a connection with last: 20, the count at the second level + would be 200 nodes. This is then summed to the count of 10 nodes + at the first level, for a total of 210 nodes. + """ + + max_page_size: "int" + """ + Maximum number of elements allowed on a single page of a connection. + """ + + max_query_depth: "int" + """ + The maximum depth a GraphQL query can be to be accepted by this service. + """ + + max_query_nodes: "int" + """ + The maximum number of nodes (field names) the service will accept in a + single query. + """ + + max_query_payload_size: "int" + """ + Maximum length of a query payload string. + """ + + max_type_argument_depth: "int" + """ + Maximum nesting allowed in type arguments in Move Types resolved by this + service. + """ + + max_type_argument_width: "int" + """ + Maximum number of type arguments passed into a generic instantiation of + a Move Type resolved by this service. + """ + + max_type_nodes: "int" + """ + Maximum number of structs that need to be processed when calculating the + layout of a single Move Type. + """ + + mutation_timeout_ms: "int" + """ + Maximum time in milliseconds spent waiting for a response from fullnode + after issuing a a transaction to execute. Note that the transaction + may still succeed even in the case of a timeout. Transactions are + idempotent, so a transaction that times out should be resubmitted + until the network returns a definite response (success or failure, not + timeout). + """ + + request_timeout_ms: "int" + """ + Maximum time in milliseconds that will be spent to serve one query + request. + """ + + def __init__(self, *, default_page_size: "int", enabled_features: "typing.List[Feature]", max_move_value_depth: "int", max_output_nodes: "int", max_page_size: "int", max_query_depth: "int", max_query_nodes: "int", max_query_payload_size: "int", max_type_argument_depth: "int", max_type_argument_width: "int", max_type_nodes: "int", mutation_timeout_ms: "int", request_timeout_ms: "int"): + self.default_page_size = default_page_size + self.enabled_features = enabled_features + self.max_move_value_depth = max_move_value_depth + self.max_output_nodes = max_output_nodes + self.max_page_size = max_page_size + self.max_query_depth = max_query_depth + self.max_query_nodes = max_query_nodes + self.max_query_payload_size = max_query_payload_size + self.max_type_argument_depth = max_type_argument_depth + self.max_type_argument_width = max_type_argument_width + self.max_type_nodes = max_type_nodes + self.mutation_timeout_ms = mutation_timeout_ms + self.request_timeout_ms = request_timeout_ms + + def __str__(self): + return "ServiceConfig(default_page_size={}, enabled_features={}, max_move_value_depth={}, max_output_nodes={}, max_page_size={}, max_query_depth={}, max_query_nodes={}, max_query_payload_size={}, max_type_argument_depth={}, max_type_argument_width={}, max_type_nodes={}, mutation_timeout_ms={}, request_timeout_ms={})".format(self.default_page_size, self.enabled_features, self.max_move_value_depth, self.max_output_nodes, self.max_page_size, self.max_query_depth, self.max_query_nodes, self.max_query_payload_size, self.max_type_argument_depth, self.max_type_argument_width, self.max_type_nodes, self.mutation_timeout_ms, self.request_timeout_ms) + + def __eq__(self, other): + if self.default_page_size != other.default_page_size: + return False + if self.enabled_features != other.enabled_features: + return False + if self.max_move_value_depth != other.max_move_value_depth: + return False + if self.max_output_nodes != other.max_output_nodes: + return False + if self.max_page_size != other.max_page_size: + return False + if self.max_query_depth != other.max_query_depth: + return False + if self.max_query_nodes != other.max_query_nodes: + return False + if self.max_query_payload_size != other.max_query_payload_size: + return False + if self.max_type_argument_depth != other.max_type_argument_depth: + return False + if self.max_type_argument_width != other.max_type_argument_width: + return False + if self.max_type_nodes != other.max_type_nodes: + return False + if self.mutation_timeout_ms != other.mutation_timeout_ms: + return False + if self.request_timeout_ms != other.request_timeout_ms: + return False + return True + +class _UniffiConverterTypeServiceConfig(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return ServiceConfig( + default_page_size=_UniffiConverterInt32.read(buf), + enabled_features=_UniffiConverterSequenceTypeFeature.read(buf), + max_move_value_depth=_UniffiConverterInt32.read(buf), + max_output_nodes=_UniffiConverterInt32.read(buf), + max_page_size=_UniffiConverterInt32.read(buf), + max_query_depth=_UniffiConverterInt32.read(buf), + max_query_nodes=_UniffiConverterInt32.read(buf), + max_query_payload_size=_UniffiConverterInt32.read(buf), + max_type_argument_depth=_UniffiConverterInt32.read(buf), + max_type_argument_width=_UniffiConverterInt32.read(buf), + max_type_nodes=_UniffiConverterInt32.read(buf), + mutation_timeout_ms=_UniffiConverterInt32.read(buf), + request_timeout_ms=_UniffiConverterInt32.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiConverterInt32.check_lower(value.default_page_size) + _UniffiConverterSequenceTypeFeature.check_lower(value.enabled_features) + _UniffiConverterInt32.check_lower(value.max_move_value_depth) + _UniffiConverterInt32.check_lower(value.max_output_nodes) + _UniffiConverterInt32.check_lower(value.max_page_size) + _UniffiConverterInt32.check_lower(value.max_query_depth) + _UniffiConverterInt32.check_lower(value.max_query_nodes) + _UniffiConverterInt32.check_lower(value.max_query_payload_size) + _UniffiConverterInt32.check_lower(value.max_type_argument_depth) + _UniffiConverterInt32.check_lower(value.max_type_argument_width) + _UniffiConverterInt32.check_lower(value.max_type_nodes) + _UniffiConverterInt32.check_lower(value.mutation_timeout_ms) + _UniffiConverterInt32.check_lower(value.request_timeout_ms) + + @staticmethod + def write(value, buf): + _UniffiConverterInt32.write(value.default_page_size, buf) + _UniffiConverterSequenceTypeFeature.write(value.enabled_features, buf) + _UniffiConverterInt32.write(value.max_move_value_depth, buf) + _UniffiConverterInt32.write(value.max_output_nodes, buf) + _UniffiConverterInt32.write(value.max_page_size, buf) + _UniffiConverterInt32.write(value.max_query_depth, buf) + _UniffiConverterInt32.write(value.max_query_nodes, buf) + _UniffiConverterInt32.write(value.max_query_payload_size, buf) + _UniffiConverterInt32.write(value.max_type_argument_depth, buf) + _UniffiConverterInt32.write(value.max_type_argument_width, buf) + _UniffiConverterInt32.write(value.max_type_nodes, buf) + _UniffiConverterInt32.write(value.mutation_timeout_ms, buf) + _UniffiConverterInt32.write(value.request_timeout_ms, buf) + + class SignedTransaction: transaction: "Transaction" signatures: "typing.List[UserSignature]" @@ -10753,6 +10987,68 @@ def write(value, buf): +class Feature(enum.Enum): + ANALYTICS = 0 + + COINS = 1 + + DYNAMIC_FIELDS = 2 + + SUBSCRIPTIONS = 3 + + SYSTEM_STATE = 4 + + + +class _UniffiConverterTypeFeature(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return Feature.ANALYTICS + if variant == 2: + return Feature.COINS + if variant == 3: + return Feature.DYNAMIC_FIELDS + if variant == 4: + return Feature.SUBSCRIPTIONS + if variant == 5: + return Feature.SYSTEM_STATE + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value == Feature.ANALYTICS: + return + if value == Feature.COINS: + return + if value == Feature.DYNAMIC_FIELDS: + return + if value == Feature.SUBSCRIPTIONS: + return + if value == Feature.SYSTEM_STATE: + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value == Feature.ANALYTICS: + buf.write_i32(1) + if value == Feature.COINS: + buf.write_i32(2) + if value == Feature.DYNAMIC_FIELDS: + buf.write_i32(3) + if value == Feature.SUBSCRIPTIONS: + buf.write_i32(4) + if value == Feature.SYSTEM_STATE: + buf.write_i32(5) + + + + + + + class IdOperation(enum.Enum): NONE = 0 @@ -12308,33 +12604,6 @@ def read(cls, buf): -class _UniffiConverterOptionalTypeCoinMetadata(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - if value is not None: - _UniffiConverterTypeCoinMetadata.check_lower(value) - - @classmethod - def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterTypeCoinMetadata.write(value, buf) - - @classmethod - def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterTypeCoinMetadata.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") - - - class _UniffiConverterOptionalTypeEd25519PublicKey(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): @@ -12956,6 +13225,33 @@ def read(cls, buf): +class _UniffiConverterOptionalTypeCoinMetadata(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiConverterTypeCoinMetadata.check_lower(value) + + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return + + buf.write_u8(1) + _UniffiConverterTypeCoinMetadata.write(value, buf) + + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiConverterTypeCoinMetadata.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") + + + class _UniffiConverterOptionalTypeDynamicFieldOutput(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): @@ -13739,6 +14035,33 @@ def read(cls, buf): +class _UniffiConverterOptionalTypeBigInt(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiConverterTypeBigInt.check_lower(value) + + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return + + buf.write_u8(1) + _UniffiConverterTypeBigInt.write(value, buf) + + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiConverterTypeBigInt.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") + + + class _UniffiConverterOptionalTypeValue(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): @@ -14641,6 +14964,31 @@ def read(cls, buf): +class _UniffiConverterSequenceTypeFeature(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiConverterTypeFeature.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiConverterTypeFeature.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiConverterTypeFeature.read(buf) for i in range(count) + ] + + + class _UniffiConverterSequenceTypeMoveAbility(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): @@ -14753,6 +15101,28 @@ def lower(value): return _UniffiConverterString.lower(value) +class _UniffiConverterTypeBigInt: + @staticmethod + def write(value, buf): + _UniffiConverterString.write(value, buf) + + @staticmethod + def read(buf): + return _UniffiConverterString.read(buf) + + @staticmethod + def lift(value): + return _UniffiConverterString.lift(value) + + @staticmethod + def check_lower(value): + return _UniffiConverterString.check_lower(value) + + @staticmethod + def lower(value): + return _UniffiConverterString.lower(value) + + class _UniffiConverterTypeValue: @staticmethod def write(value, buf): @@ -16225,62 +16595,6 @@ def read(cls, buf: _UniffiRustBuffer): @classmethod def write(cls, value: CoinProtocol, buf: _UniffiRustBuffer): buf.write_u64(cls.lower(value)) -class CoinMetadataProtocol(typing.Protocol): - pass -# CoinMetadata is a Rust-only trait - it's a wrapper around a Rust implementation. -class CoinMetadata(): - _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_coinmetadata, pointer) - - def _uniffi_clone_pointer(self): - return _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_coinmetadata, 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 - - - -class _UniffiConverterTypeCoinMetadata: - - @staticmethod - def lift(value: int): - return CoinMetadata._make_instance_(value) - - @staticmethod - def check_lower(value: CoinMetadata): - if not isinstance(value, CoinMetadata): - raise TypeError("Expected CoinMetadata instance, {} found".format(type(value).__name__)) - - @staticmethod - def lower(value: CoinMetadataProtocol): - if not isinstance(value, CoinMetadata): - raise TypeError("Expected CoinMetadata 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: CoinMetadataProtocol, buf: _UniffiRustBuffer): - buf.write_u64(cls.lower(value)) class ConsensusCommitDigestProtocol(typing.Protocol): def to_base58(self, ): raise NotImplementedError @@ -19004,9 +19318,9 @@ async def service_config(self, ) -> "ServiceConfig": _UniffiLib.uniffi_iota_sdk_ffi_fn_method_graphqlclient_service_config( self._uniffi_clone_pointer(), ), - _UniffiLib.ffi_iota_sdk_ffi_rust_future_poll_pointer, - _UniffiLib.ffi_iota_sdk_ffi_rust_future_complete_pointer, - _UniffiLib.ffi_iota_sdk_ffi_rust_future_free_pointer, + _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 _UniffiConverterTypeServiceConfig.lift, @@ -22247,62 +22561,6 @@ def read(cls, buf: _UniffiRustBuffer): @classmethod def write(cls, value: Secp256r1SignatureProtocol, buf: _UniffiRustBuffer): buf.write_u64(cls.lower(value)) -class ServiceConfigProtocol(typing.Protocol): - pass -# ServiceConfig is a Rust-only trait - it's a wrapper around a Rust implementation. -class ServiceConfig(): - _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_serviceconfig, pointer) - - def _uniffi_clone_pointer(self): - return _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_serviceconfig, 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 - - - -class _UniffiConverterTypeServiceConfig: - - @staticmethod - def lift(value: int): - return ServiceConfig._make_instance_(value) - - @staticmethod - def check_lower(value: ServiceConfig): - if not isinstance(value, ServiceConfig): - raise TypeError("Expected ServiceConfig instance, {} found".format(type(value).__name__)) - - @staticmethod - def lower(value: ServiceConfigProtocol): - if not isinstance(value, ServiceConfig): - raise TypeError("Expected ServiceConfig 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: ServiceConfigProtocol, buf: _UniffiRustBuffer): - buf.write_u64(cls.lower(value)) class SimpleSignatureProtocol(typing.Protocol): """ A basic signature @@ -24683,6 +24941,7 @@ def read(cls, buf: _UniffiRustBuffer): def write(cls, value: ZkLoginPublicIdentifierProtocol, buf: _UniffiRustBuffer): buf.write_u64(cls.lower(value)) Base64 = str +BigInt = str Value = str # Async support# RustFuturePoll values @@ -24755,6 +25014,7 @@ async def _uniffi_rust_call_async(rust_future, ffi_poll, ffi_complete, ffi_free, "Direction", "ExecutionError", "ExecutionStatus", + "Feature", "IdOperation", "MoveAbility", "MoveVisibility", @@ -24767,12 +25027,11 @@ async def _uniffi_rust_call_async(rust_future, ffi_poll, ffi_complete, ffi_free, "TransactionExpiration", "TypeArgumentError", "UnchangedSharedKind", - "BigInt", "ChangedObject", "CheckpointSummary", "CheckpointSummaryPage", + "CoinMetadata", "CoinPage", - "DateTime", "DryRunResult", "DynamicFieldName", "DynamicFieldOutput", @@ -24811,6 +25070,7 @@ async def _uniffi_rust_call_async(rust_future, ffi_poll, ffi_complete, ffi_free, "OpenMoveType", "PageInfo", "PaginationFilter", + "ServiceConfig", "SignedTransaction", "SignedTransactionPage", "TransactionDataEffects", @@ -24844,7 +25104,6 @@ async def _uniffi_rust_call_async(rust_future, ffi_poll, ffi_complete, ffi_free, "CircomG1", "CircomG2", "Coin", - "CoinMetadata", "ConsensusCommitDigest", "ConsensusCommitPrologueV1", "Digest", @@ -24879,7 +25138,6 @@ async def _uniffi_rust_call_async(rust_future, ffi_poll, ffi_complete, ffi_free, "Secp256k1Signature", "Secp256r1PublicKey", "Secp256r1Signature", - "ServiceConfig", "SimpleSignature", "StructTag", "Transaction", diff --git a/bindings/python/test.py b/bindings/python/test.py index 7da0b7fca..11d60bbf5 100644 --- a/bindings/python/test.py +++ b/bindings/python/test.py @@ -41,6 +41,32 @@ async def main(): print("Scheme: ", sig.scheme(), sig.scheme().value) print("Sender: ", txn.transaction.sender().to_hex()) + service_config = ServiceConfig( + default_page_size=2, + enabled_features=[], + max_move_value_depth=0, + max_output_nodes=0, + max_page_size=0, + max_query_depth=0, + max_query_nodes=0, + max_query_payload_size=0, + max_type_argument_depth=0, + max_type_argument_width=0, + max_type_nodes=0, + mutation_timeout_ms=0, + request_timeout_ms=0, + ) + + coin_metadata = CoinMetadata( + decimals=2, + description="test", + icon_url=None, + name="test", + symbol=None, + supply="1000", + version=0, + ) + move_struct = MoveStruct( struct_type=StructTag.coin(TypeTag.vector(TypeTag.u8())), version=1, diff --git a/crates/iota-sdk-ffi/src/graphql.rs b/crates/iota-sdk-ffi/src/graphql.rs index 0b8ead2aa..06bb09ff8 100644 --- a/crates/iota-sdk-ffi/src/graphql.rs +++ b/crates/iota-sdk-ffi/src/graphql.rs @@ -3,7 +3,10 @@ use std::sync::Arc; -use iota_graphql_client::{pagination::PaginationFilter, query_types::MoveFunction}; +use iota_graphql_client::{ + pagination::PaginationFilter, + query_types::{CoinMetadata, MoveFunction, ServiceConfig}, +}; use iota_types::CheckpointSequenceNumber; use tokio::sync::RwLock; @@ -14,9 +17,8 @@ use crate::{ checkpoint::CheckpointSummary, digest::{CheckpointContentsDigest, CheckpointDigest, TransactionDigest}, graphql::{ - CoinMetadata, DryRunResult, DynamicFieldOutput, Epoch, EventFilter, MoveModule, - ObjectFilter, ProtocolConfigs, ServiceConfig, TransactionDataEffects, - TransactionMetadata, TransactionsFilter, + DryRunResult, DynamicFieldOutput, Epoch, EventFilter, MoveModule, ObjectFilter, + ProtocolConfigs, TransactionDataEffects, TransactionMetadata, TransactionsFilter, }, object::{MovePackage, Object, ObjectId}, signature::UserSignature, @@ -192,15 +194,8 @@ impl GraphQLClient { } /// Get the coin metadata for the coin type. - pub async fn coin_metadata(&self, coin_type: &str) -> Result>> { - Ok(self - .0 - .read() - .await - .coin_metadata(coin_type) - .await? - .map(Into::into) - .map(Arc::new)) + pub async fn coin_metadata(&self, coin_type: &str) -> Result> { + Ok(self.0.read().await.coin_metadata(coin_type).await?) } /// Get total supply for the coin type. @@ -774,7 +769,7 @@ impl GraphQLClient { /// Get the GraphQL service configuration, including complexity limits, read /// and mutation limits, supported versions, and others. pub async fn service_config(&self) -> Result { - Ok(self.0.read().await.service_config().await?.clone().into()) + Ok(self.0.read().await.service_config().await?.clone()) } // =========================================================================== diff --git a/crates/iota-sdk-ffi/src/types/graphql.rs b/crates/iota-sdk-ffi/src/types/graphql.rs index 4db02267d..f83a14ffc 100644 --- a/crates/iota-sdk-ffi/src/types/graphql.rs +++ b/crates/iota-sdk-ffi/src/types/graphql.rs @@ -7,9 +7,10 @@ use base64ct::Encoding; use iota_graphql_client::{ pagination::{Direction, PaginationFilter}, query_types::{ - Base64, MoveAbility, MoveEnum, MoveEnumConnection, MoveEnumVariant, MoveField, - MoveFunction, MoveFunctionConnection, MoveFunctionTypeParameter, MoveStructConnection, - MoveStructQuery, MoveStructTypeParameter, MoveVisibility, OpenMoveType, PageInfo, + Base64, BigInt, CoinMetadata, Feature, MoveAbility, MoveEnum, MoveEnumConnection, + MoveEnumVariant, MoveField, MoveFunction, MoveFunctionConnection, + MoveFunctionTypeParameter, MoveObject, MoveStructConnection, MoveStructQuery, + MoveStructTypeParameter, MoveVisibility, OpenMoveType, PageInfo, ServiceConfig, TransactionBlockKindInput, ValidatorCredentials, }, }; @@ -532,11 +533,8 @@ impl From for iota_graphql_client::query_types::Validator { next_epoch_credentials: value.next_epoch_credentials, next_epoch_gas_price: value.next_epoch_gas_price.map(|v| v.to_string().into()), next_epoch_stake: value.next_epoch_stake.map(|v| v.to_string().into()), - operation_cap: value.operation_cap.map(|o| { - MoveObject { - bcs: Some(base64ct::Base64::encode_string(&o)), - } - .into() + operation_cap: value.operation_cap.map(|o| MoveObject { + bcs: Some(Base64(base64ct::Base64::encode_string(&o))), }), pending_pool_token_withdraw: value .pending_pool_token_withdraw @@ -580,40 +578,6 @@ pub enum TransactionBlockKindInput { EndOfEpochTx, } -#[derive(Clone, Debug, uniffi::Record)] -pub struct BigInt { - pub value: String, -} - -impl From for BigInt { - fn from(value: iota_graphql_client::query_types::BigInt) -> Self { - BigInt { value: value.0 } - } -} - -impl From for iota_graphql_client::query_types::BigInt { - fn from(value: BigInt) -> Self { - iota_graphql_client::query_types::BigInt(value.value) - } -} - -#[derive(Clone, Debug, uniffi::Record)] -pub struct DateTime { - pub value: String, -} - -impl From for DateTime { - fn from(value: iota_graphql_client::query_types::DateTime) -> Self { - DateTime { value: value.0 } - } -} - -impl From for iota_graphql_client::query_types::DateTime { - fn from(value: DateTime) -> Self { - iota_graphql_client::query_types::DateTime(value.value) - } -} - /// Information about pagination in a connection. #[uniffi::remote(Record)] pub struct PageInfo { @@ -633,7 +597,9 @@ pub struct PageInfo { /// pagination with the GraphQL server's max page size. #[uniffi::remote(Record)] pub struct PaginationFilter { + /// The direction of pagination. pub direction: Direction, + /// An opaque cursor used for pagination. #[uniffi(default = None)] pub cursor: Option, /// The maximum number of items to return. If this is omitted, it will @@ -716,33 +682,39 @@ impl From for iota_graphql_client::query_types::GQLAddress { } } -#[derive(Clone, Debug, uniffi::Record)] +#[uniffi::remote(Record)] pub struct MoveObject { #[uniffi(default = None)] - pub bcs: Option, -} - -impl From for MoveObject { - fn from(value: iota_graphql_client::query_types::MoveObject) -> Self { - MoveObject { - bcs: value.bcs.map(|v| v.0), - } - } -} - -impl From for iota_graphql_client::query_types::MoveObject { - fn from(value: MoveObject) -> Self { - iota_graphql_client::query_types::MoveObject { - bcs: value.bcs.map(iota_graphql_client::query_types::Base64), - } - } + pub bcs: Option, } #[derive(Clone, Debug, derive_more::From, uniffi::Object)] pub struct ProtocolConfigs(pub iota_graphql_client::query_types::ProtocolConfigs); -#[derive(Clone, Debug, derive_more::From, uniffi::Object)] -pub struct CoinMetadata(pub iota_graphql_client::query_types::CoinMetadata); +/// The coin metadata associated with the given coin type. +#[uniffi::remote(Record)] +pub struct CoinMetadata { + /// The number of decimal places used to represent the token. + #[uniffi(default = None)] + pub decimals: Option, + /// Optional description of the token, provided by the creator of the token. + #[uniffi(default = None)] + pub description: Option, + /// Icon URL of the coin. + #[uniffi(default = None)] + pub icon_url: Option, + /// Full, official name of the token. + #[uniffi(default = None)] + pub name: Option, + /// The token's identifying abbreviation. + #[uniffi(default = None)] + pub symbol: Option, + /// The overall quantity of tokens that will be issued. + #[uniffi(default = None)] + pub supply: Option, + /// Version of the token. + pub version: u64, +} #[uniffi::remote(Record)] pub struct MoveFunction { @@ -948,5 +920,66 @@ pub struct MoveEnum { pub variants: Option>, } -#[derive(Clone, Debug, derive_more::From, uniffi::Object)] -pub struct ServiceConfig(pub iota_graphql_client::query_types::ServiceConfig); +// Information about the configuration of the GraphQL service. +#[uniffi::remote(Record)] +pub struct ServiceConfig { + /// Default number of elements allowed on a single page of a connection. + pub default_page_size: i32, + /// List of all features that are enabled on this RPC service. + pub enabled_features: Vec, + // TODO This field is retrieved as a string, instead of i32 + /// Maximum estimated cost of a database query used to serve a GraphQL + /// request. This is measured in the same units that the database uses + /// in EXPLAIN queries. + // pub max_db_query_cost: i32, + /// Maximum nesting allowed in struct fields when calculating the layout of + /// a single Move Type. + pub max_move_value_depth: i32, + /// The maximum number of output nodes in a GraphQL response. + /// Non-connection nodes have a count of 1, while connection nodes are + /// counted as the specified 'first' or 'last' number of items, or the + /// default_page_size as set by the server if those arguments are not + /// set. Counts accumulate multiplicatively down the query tree. For + /// example, if a query starts with a connection of first: 10 and has a + /// field to a connection with last: 20, the count at the second level + /// would be 200 nodes. This is then summed to the count of 10 nodes + /// at the first level, for a total of 210 nodes. + pub max_output_nodes: i32, + /// Maximum number of elements allowed on a single page of a connection. + pub max_page_size: i32, + /// The maximum depth a GraphQL query can be to be accepted by this service. + pub max_query_depth: i32, + /// The maximum number of nodes (field names) the service will accept in a + /// single query. + pub max_query_nodes: i32, + /// Maximum length of a query payload string. + pub max_query_payload_size: i32, + /// Maximum nesting allowed in type arguments in Move Types resolved by this + /// service. + pub max_type_argument_depth: i32, + /// Maximum number of type arguments passed into a generic instantiation of + /// a Move Type resolved by this service. + pub max_type_argument_width: i32, + /// Maximum number of structs that need to be processed when calculating the + /// layout of a single Move Type. + pub max_type_nodes: i32, + /// Maximum time in milliseconds spent waiting for a response from fullnode + /// after issuing a a transaction to execute. Note that the transaction + /// may still succeed even in the case of a timeout. Transactions are + /// idempotent, so a transaction that times out should be resubmitted + /// until the network returns a definite response (success or failure, not + /// timeout). + pub mutation_timeout_ms: i32, + /// Maximum time in milliseconds that will be spent to serve one query + /// request. + pub request_timeout_ms: i32, +} + +#[uniffi::remote(Enum)] +pub enum Feature { + Analytics, + Coins, + DynamicFields, + Subscriptions, + SystemState, +} diff --git a/crates/iota-sdk-ffi/src/uniffi_helpers.rs b/crates/iota-sdk-ffi/src/uniffi_helpers.rs index 9029ea835..9af0ca464 100644 --- a/crates/iota-sdk-ffi/src/uniffi_helpers.rs +++ b/crates/iota-sdk-ffi/src/uniffi_helpers.rs @@ -1,7 +1,7 @@ // Copyright (c) 2025 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use iota_graphql_client::query_types::{Base64, PageInfo}; +use iota_graphql_client::query_types::{Base64, BigInt, PageInfo}; use serde_json::Value; use crate::types::{ @@ -87,3 +87,9 @@ uniffi::custom_type!(Base64, String, { lower: |val| val.0, try_lift: |s| Ok(Base64(s)), }); + +uniffi::custom_type!(BigInt, String, { + remote, + lower: |val| val.0, + try_lift: |s| Ok(BigInt(s)), +});