diff --git a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go index 4ae3d2f71..bfdbc524b 100644 --- a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go +++ b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go @@ -1325,7 +1325,7 @@ func uniffiCheckChecksums() { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_coins() }) - if checksum != 50359 { + if checksum != 47450 { // If this happens try cleaning and rebuilding your project panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_graphqlclient_coins: UniFFI API checksum mismatch") } @@ -1421,6 +1421,15 @@ func uniffiCheckChecksums() { } } { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_gas_coins() + }) + if checksum != 24826 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_graphqlclient_gas_coins: UniFFI API checksum mismatch") + } + } + { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_default_name() }) @@ -12049,10 +12058,9 @@ type GraphQlClientInterface interface { 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`, - // which will return all coins. For IOTA coin, pass in the coin type: - // `0x2::coin::Coin<0x2::iota::IOTA>`. - Coins(owner *Address, paginationFilter *PaginationFilter, coinType *string) (CoinPage, error) + // If `coin_type` is not provided, all coins will be returned. For IOTA + // coins, pass in the coin type: `0x2::iota::IOTA`. + Coins(owner *Address, paginationFilter *PaginationFilter, coinType **StructTag) (CoinPage, error) // Dry run a [`Transaction`] and return the transaction effects and dry run // error (if any). // @@ -12122,6 +12130,8 @@ type GraphQlClientInterface interface { Events(filter *EventFilter, paginationFilter *PaginationFilter) (EventPage, error) // Execute a transaction. ExecuteTx(signatures []*UserSignature, tx *Transaction) (**TransactionEffects, error) + // Get the list of gas coins for the specified address. + GasCoins(owner *Address, paginationFilter *PaginationFilter) (CoinPage, error) // Get the default name pointing to this address, if one exists. IotaNamesDefaultName(address *Address, format *NameFormat) (**Name, error) // Return the resolved address for the given name. @@ -12497,10 +12507,9 @@ func (_self *GraphQlClient) 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`, -// which will return all coins. For IOTA coin, pass in the coin type: -// `0x2::coin::Coin<0x2::iota::IOTA>`. -func (_self *GraphQlClient) Coins(owner *Address, paginationFilter *PaginationFilter, coinType *string) (CoinPage, error) { +// If `coin_type` is not provided, all coins will be returned. For IOTA +// coins, pass in the coin type: `0x2::iota::IOTA`. +func (_self *GraphQlClient) Coins(owner *Address, paginationFilter *PaginationFilter, coinType **StructTag) (CoinPage, error) { _pointer := _self.ffiObject.incrementPointer("*GraphQlClient") defer _self.ffiObject.decrementPointer() res, err :=uniffiRustCallAsync[SdkFfiError]( @@ -12517,7 +12526,7 @@ func (_self *GraphQlClient) Coins(owner *Address, paginationFilter *PaginationFi return FfiConverterCoinPageINSTANCE.Lift(ffi) }, C.uniffi_iota_sdk_ffi_fn_method_graphqlclient_coins( - _pointer,FfiConverterAddressINSTANCE.Lower(owner), FfiConverterOptionalPaginationFilterINSTANCE.Lower(paginationFilter), FfiConverterOptionalStringINSTANCE.Lower(coinType)), + _pointer,FfiConverterAddressINSTANCE.Lower(owner), FfiConverterOptionalPaginationFilterINSTANCE.Lower(paginationFilter), FfiConverterOptionalStructTagINSTANCE.Lower(coinType)), // pollFn func (handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { C.ffi_iota_sdk_ffi_rust_future_poll_rust_buffer(handle, continuation, data) @@ -12900,6 +12909,38 @@ func (_self *GraphQlClient) ExecuteTx(signatures []*UserSignature, tx *Transacti return res, err } +// Get the list of gas coins for the specified address. +func (_self *GraphQlClient) GasCoins(owner *Address, paginationFilter *PaginationFilter) (CoinPage, error) { + _pointer := _self.ffiObject.incrementPointer("*GraphQlClient") + defer _self.ffiObject.decrementPointer() + res, err :=uniffiRustCallAsync[SdkFfiError]( + FfiConverterSdkFfiErrorINSTANCE, + // completeFn + func(handle C.uint64_t, status *C.RustCallStatus) RustBufferI { + res := C.ffi_iota_sdk_ffi_rust_future_complete_rust_buffer(handle, status) + return GoRustBuffer { + inner: res, + } + }, + // liftFn + func(ffi RustBufferI) CoinPage { + return FfiConverterCoinPageINSTANCE.Lift(ffi) + }, + C.uniffi_iota_sdk_ffi_fn_method_graphqlclient_gas_coins( + _pointer,FfiConverterAddressINSTANCE.Lower(owner), FfiConverterOptionalPaginationFilterINSTANCE.Lower(paginationFilter)), + // pollFn + func (handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { + C.ffi_iota_sdk_ffi_rust_future_poll_rust_buffer(handle, continuation, data) + }, + // freeFn + func (handle C.uint64_t) { + C.ffi_iota_sdk_ffi_rust_future_free_rust_buffer(handle) + }, + ) + + return res, err +} + // Get the default name pointing to this address, if one exists. func (_self *GraphQlClient) IotaNamesDefaultName(address *Address, format *NameFormat) (**Name, error) { _pointer := _self.ffiObject.incrementPointer("*GraphQlClient") diff --git a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h index 3084d4de9..a64ce6feb 100644 --- a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h +++ b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h @@ -1725,6 +1725,11 @@ uint64_t uniffi_iota_sdk_ffi_fn_method_graphqlclient_events(void* ptr, RustBuffe uint64_t uniffi_iota_sdk_ffi_fn_method_graphqlclient_execute_tx(void* ptr, RustBuffer signatures, void* tx ); #endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_GRAPHQLCLIENT_GAS_COINS +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_GRAPHQLCLIENT_GAS_COINS +uint64_t uniffi_iota_sdk_ffi_fn_method_graphqlclient_gas_coins(void* ptr, void* owner, RustBuffer pagination_filter +); +#endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_GRAPHQLCLIENT_IOTA_NAMES_DEFAULT_NAME #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_GRAPHQLCLIENT_IOTA_NAMES_DEFAULT_NAME uint64_t uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_default_name(void* ptr, void* address, RustBuffer format @@ -6122,6 +6127,12 @@ uint16_t uniffi_iota_sdk_ffi_checksum_method_graphqlclient_events(void #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_GRAPHQLCLIENT_EXECUTE_TX uint16_t uniffi_iota_sdk_ffi_checksum_method_graphqlclient_execute_tx(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_GRAPHQLCLIENT_GAS_COINS +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_GRAPHQLCLIENT_GAS_COINS +uint16_t uniffi_iota_sdk_ffi_checksum_method_graphqlclient_gas_coins(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_GRAPHQLCLIENT_IOTA_NAMES_DEFAULT_NAME diff --git a/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt b/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt index 647c4d864..f4f3c06f3 100644 --- a/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt +++ b/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt @@ -2387,6 +2387,8 @@ internal interface UniffiForeignFutureCompleteVoid : com.sun.jna.Callback { + + @@ -2641,6 +2643,8 @@ fun uniffi_iota_sdk_ffi_checksum_method_graphqlclient_events( ): Short fun uniffi_iota_sdk_ffi_checksum_method_graphqlclient_execute_tx( ): Short +fun uniffi_iota_sdk_ffi_checksum_method_graphqlclient_gas_coins( +): Short fun uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_default_name( ): Short fun uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_lookup( @@ -4444,6 +4448,8 @@ fun uniffi_iota_sdk_ffi_fn_method_graphqlclient_events(`ptr`: Pointer,`filter`: ): Long fun uniffi_iota_sdk_ffi_fn_method_graphqlclient_execute_tx(`ptr`: Pointer,`signatures`: RustBuffer.ByValue,`tx`: Pointer, ): Long +fun uniffi_iota_sdk_ffi_fn_method_graphqlclient_gas_coins(`ptr`: Pointer,`owner`: Pointer,`paginationFilter`: RustBuffer.ByValue, +): Long fun uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_default_name(`ptr`: Pointer,`address`: Pointer,`format`: RustBuffer.ByValue, ): Long fun uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_lookup(`ptr`: Pointer,`name`: RustBuffer.ByValue, @@ -6243,7 +6249,7 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { 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() != 50359.toShort()) { + if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_coins() != 47450.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_dry_run_tx() != 12272.toShort()) { @@ -6276,6 +6282,9 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_execute_tx() != 41079.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_gas_coins() != 24826.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_default_name() != 53764.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -19484,11 +19493,10 @@ public interface GraphQlClientInterface { /** * Get the list of coins for the specified address. * - * If `coin_type` is not provided, it will default to `0x2::coin::Coin`, - * which will return all coins. For IOTA coin, pass in the coin type: - * `0x2::coin::Coin<0x2::iota::IOTA>`. + * If `coin_type` is not provided, all coins will be returned. For IOTA + * coins, pass in the coin type: `0x2::iota::IOTA`. */ - suspend fun `coins`(`owner`: Address, `paginationFilter`: PaginationFilter? = null, `coinType`: kotlin.String? = null): CoinPage + suspend fun `coins`(`owner`: Address, `paginationFilter`: PaginationFilter? = null, `coinType`: StructTag? = null): CoinPage /** * Dry run a [`Transaction`] and return the transaction effects and dry run @@ -19589,6 +19597,11 @@ public interface GraphQlClientInterface { */ suspend fun `executeTx`(`signatures`: List, `tx`: Transaction): TransactionEffects? + /** + * Get the list of gas coins for the specified address. + */ + suspend fun `gasCoins`(`owner`: Address, `paginationFilter`: PaginationFilter? = null): CoinPage + /** * Get the default name pointing to this address, if one exists. */ @@ -20056,18 +20069,17 @@ open class GraphQlClient: Disposable, AutoCloseable, GraphQlClientInterface /** * Get the list of coins for the specified address. * - * If `coin_type` is not provided, it will default to `0x2::coin::Coin`, - * which will return all coins. For IOTA coin, pass in the coin type: - * `0x2::coin::Coin<0x2::iota::IOTA>`. + * If `coin_type` is not provided, all coins will be returned. For IOTA + * coins, pass in the coin type: `0x2::iota::IOTA`. */ @Throws(SdkFfiException::class) @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") - override suspend fun `coins`(`owner`: Address, `paginationFilter`: PaginationFilter?, `coinType`: kotlin.String?) : CoinPage { + override suspend fun `coins`(`owner`: Address, `paginationFilter`: PaginationFilter?, `coinType`: StructTag?) : CoinPage { return uniffiRustCallAsync( callWithPointer { thisPtr -> UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_graphqlclient_coins( thisPtr, - FfiConverterTypeAddress.lower(`owner`),FfiConverterOptionalTypePaginationFilter.lower(`paginationFilter`),FfiConverterOptionalString.lower(`coinType`), + FfiConverterTypeAddress.lower(`owner`),FfiConverterOptionalTypePaginationFilter.lower(`paginationFilter`),FfiConverterOptionalTypeStructTag.lower(`coinType`), ) }, { future, callback, continuation -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_poll_rust_buffer(future, callback, continuation) }, @@ -20370,6 +20382,30 @@ open class GraphQlClient: Disposable, AutoCloseable, GraphQlClientInterface } + /** + * Get the list of gas coins for the specified address. + */ + @Throws(SdkFfiException::class) + @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") + override suspend fun `gasCoins`(`owner`: Address, `paginationFilter`: PaginationFilter?) : CoinPage { + return uniffiRustCallAsync( + callWithPointer { thisPtr -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_graphqlclient_gas_coins( + thisPtr, + FfiConverterTypeAddress.lower(`owner`),FfiConverterOptionalTypePaginationFilter.lower(`paginationFilter`), + ) + }, + { future, callback, continuation -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_poll_rust_buffer(future, callback, continuation) }, + { future, continuation -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_complete_rust_buffer(future, continuation) }, + { future -> UniffiLib.INSTANCE.ffi_iota_sdk_ffi_rust_future_free_rust_buffer(future) }, + // lift function + { FfiConverterTypeCoinPage.lift(it) }, + // Error FFI converter + SdkFfiException.ErrorHandler, + ) + } + + /** * Get the default name pointing to this address, if one exists. */ diff --git a/bindings/python/lib/iota_sdk_ffi.py b/bindings/python/lib/iota_sdk_ffi.py index 93cea885b..65813b446 100644 --- a/bindings/python/lib/iota_sdk_ffi.py +++ b/bindings/python/lib/iota_sdk_ffi.py @@ -675,7 +675,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_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() != 50359: + if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_coins() != 47450: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_dry_run_tx() != 12272: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") @@ -697,6 +697,8 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_execute_tx() != 41079: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_gas_coins() != 24826: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_default_name() != 53764: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_lookup() != 20908: @@ -3396,6 +3398,12 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): ctypes.c_void_p, ) _UniffiLib.uniffi_iota_sdk_ffi_fn_method_graphqlclient_execute_tx.restype = ctypes.c_uint64 +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_graphqlclient_gas_coins.argtypes = ( + ctypes.c_void_p, + ctypes.c_void_p, + _UniffiRustBuffer, +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_graphqlclient_gas_coins.restype = ctypes.c_uint64 _UniffiLib.uniffi_iota_sdk_ffi_fn_method_graphqlclient_iota_names_default_name.argtypes = ( ctypes.c_void_p, ctypes.c_void_p, @@ -7539,6 +7547,9 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_execute_tx.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_execute_tx.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_gas_coins.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_gas_coins.restype = ctypes.c_uint16 _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_default_name.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_iota_names_default_name.restype = ctypes.c_uint16 @@ -27705,13 +27716,12 @@ def coin_metadata(self, coin_type: "str"): """ raise NotImplementedError - def coins(self, owner: "Address",pagination_filter: "typing.Union[object, typing.Optional[PaginationFilter]]" = _DEFAULT,coin_type: "typing.Union[object, typing.Optional[str]]" = _DEFAULT): + def coins(self, owner: "Address",pagination_filter: "typing.Union[object, typing.Optional[PaginationFilter]]" = _DEFAULT,coin_type: "typing.Union[object, typing.Optional[StructTag]]" = _DEFAULT): """ Get the list of coins for the specified address. - If `coin_type` is not provided, it will default to `0x2::coin::Coin`, - which will return all coins. For IOTA coin, pass in the coin type: - `0x2::coin::Coin<0x2::iota::IOTA>`. + If `coin_type` is not provided, all coins will be returned. For IOTA + coins, pass in the coin type: `0x2::iota::IOTA`. """ raise NotImplementedError @@ -27823,6 +27833,12 @@ def execute_tx(self, signatures: "typing.List[UserSignature]",tx: "Transaction") Execute a transaction. """ + raise NotImplementedError + def gas_coins(self, owner: "Address",pagination_filter: "typing.Union[object, typing.Optional[PaginationFilter]]" = _DEFAULT): + """ + Get the list of gas coins for the specified address. + """ + raise NotImplementedError def iota_names_default_name(self, address: "Address",format: "typing.Optional[NameFormat]"): """ @@ -28323,13 +28339,12 @@ async def coin_metadata(self, coin_type: "str") -> "typing.Optional[CoinMetadata - async def coins(self, owner: "Address",pagination_filter: "typing.Union[object, typing.Optional[PaginationFilter]]" = _DEFAULT,coin_type: "typing.Union[object, typing.Optional[str]]" = _DEFAULT) -> "CoinPage": + async def coins(self, owner: "Address",pagination_filter: "typing.Union[object, typing.Optional[PaginationFilter]]" = _DEFAULT,coin_type: "typing.Union[object, typing.Optional[StructTag]]" = _DEFAULT) -> "CoinPage": """ Get the list of coins for the specified address. - If `coin_type` is not provided, it will default to `0x2::coin::Coin`, - which will return all coins. For IOTA coin, pass in the coin type: - `0x2::coin::Coin<0x2::iota::IOTA>`. + If `coin_type` is not provided, all coins will be returned. For IOTA + coins, pass in the coin type: `0x2::iota::IOTA`. """ _UniffiConverterTypeAddress.check_lower(owner) @@ -28340,14 +28355,14 @@ async def coins(self, owner: "Address",pagination_filter: "typing.Union[object, if coin_type is _DEFAULT: coin_type = None - _UniffiConverterOptionalString.check_lower(coin_type) + _UniffiConverterOptionalTypeStructTag.check_lower(coin_type) return await _uniffi_rust_call_async( _UniffiLib.uniffi_iota_sdk_ffi_fn_method_graphqlclient_coins( self._uniffi_clone_pointer(), _UniffiConverterTypeAddress.lower(owner), _UniffiConverterOptionalTypePaginationFilter.lower(pagination_filter), - _UniffiConverterOptionalString.lower(coin_type) + _UniffiConverterOptionalTypeStructTag.lower(coin_type) ), _UniffiLib.ffi_iota_sdk_ffi_rust_future_poll_rust_buffer, _UniffiLib.ffi_iota_sdk_ffi_rust_future_complete_rust_buffer, @@ -28707,6 +28722,36 @@ async def execute_tx(self, signatures: "typing.List[UserSignature]",tx: "Transac + async def gas_coins(self, owner: "Address",pagination_filter: "typing.Union[object, typing.Optional[PaginationFilter]]" = _DEFAULT) -> "CoinPage": + """ + Get the list of gas coins for the specified address. + """ + + _UniffiConverterTypeAddress.check_lower(owner) + + if pagination_filter is _DEFAULT: + pagination_filter = None + _UniffiConverterOptionalTypePaginationFilter.check_lower(pagination_filter) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_iota_sdk_ffi_fn_method_graphqlclient_gas_coins( + self._uniffi_clone_pointer(), + _UniffiConverterTypeAddress.lower(owner), + _UniffiConverterOptionalTypePaginationFilter.lower(pagination_filter) + ), + _UniffiLib.ffi_iota_sdk_ffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_iota_sdk_ffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_iota_sdk_ffi_rust_future_free_rust_buffer, + # lift function + _UniffiConverterTypeCoinPage.lift, + + # Error FFI converter +_UniffiConverterTypeSdkFfiError, + + ) + + + async def iota_names_default_name(self, address: "Address",format: "typing.Optional[NameFormat]") -> "typing.Optional[Name]": """ Get the default name pointing to this address, if one exists. diff --git a/crates/iota-graphql-client/src/lib.rs b/crates/iota-graphql-client/src/lib.rs index 9b0e27c30..4816ec16e 100644 --- a/crates/iota-graphql-client/src/lib.rs +++ b/crates/iota-graphql-client/src/lib.rs @@ -18,8 +18,9 @@ use cynic::{GraphQlResponse, MutationBuilder, Operation, QueryBuilder, serde}; use error::{Error, Kind}; use futures::Stream; use iota_types::{ - Address, CheckpointSequenceNumber, CheckpointSummary, Digest, MovePackage, Object, ObjectId, - SignedTransaction, Transaction, TransactionEffects, TransactionKind, TypeTag, UserSignature, + Address, CheckpointSequenceNumber, CheckpointSummary, Digest, IdentifierRef, MovePackage, + Object, ObjectId, SignedTransaction, StructTag, Transaction, TransactionEffects, + TransactionKind, TypeTag, UserSignature, framework::Coin, iota_names::{NameFormat, NameRegistration, name::Name}, }; @@ -118,13 +119,12 @@ impl Client { /// Get the list of coins for the specified address as a stream. /// - /// If `coin_type` is not provided, it will default to `0x2::coin::Coin`, - /// which will return all coins. For IOTA coin, pass in the coin type: - /// `0x2::coin::Coin<0x2::iota::IOTA>`. - pub async fn coins_stream( + /// If `coin_type` is not provided, all coins will be returned. For IOTA + /// coins, pass in the coin type: `0x2::iota::IOTA`. + pub fn coins_stream( &self, address: Address, - coin_type: impl Into>, + coin_type: impl Into>, streaming_direction: Direction, ) -> impl Stream> + '_ { let coin_type = coin_type.into(); @@ -134,9 +134,21 @@ impl Client { ) } + /// Get the list of gas coins for the specified address as a stream. + pub fn gas_coins_stream( + &self, + address: Address, + streaming_direction: Direction, + ) -> impl Stream> + '_ { + stream_paginated_query( + move |filter| self.gas_coins(address, filter), + streaming_direction, + ) + } + /// Get a stream of [`CheckpointSummary`]. Note that this will fetch all /// checkpoints which may trigger a lot of requests. - pub async fn checkpoints_stream( + pub fn checkpoints_stream( &self, streaming_direction: Direction, ) -> impl Stream> + '_ { @@ -145,7 +157,7 @@ impl Client { /// Get a stream of dynamic fields for the provided address. Note that this /// will also fetch dynamic fields on wrapped objects. - pub async fn dynamic_fields_stream( + pub fn dynamic_fields_stream( &self, address: Address, streaming_direction: Direction, @@ -167,7 +179,7 @@ impl Client { } /// Return a stream of events based on the (optional) event filter. - pub async fn events_stream( + pub fn events_stream( &self, filter: impl Into>, streaming_direction: Direction, @@ -180,7 +192,7 @@ impl Client { } /// Return a stream of objects based on the (optional) object filter. - pub async fn objects_stream( + pub fn objects_stream( &self, filter: impl Into>, streaming_direction: Direction, @@ -292,7 +304,7 @@ impl Client { } /// Get a stream of transactions based on the (optional) transaction filter. - pub async fn transactions_stream( + pub fn transactions_stream( &self, filter: impl Into>, streaming_direction: Direction, @@ -306,7 +318,7 @@ impl Client { /// Get a stream of transactions' effects based on the (optional) /// transaction filter. - pub async fn transactions_effects_stream( + pub fn transactions_effects_stream( &self, filter: impl Into>, streaming_direction: Direction, @@ -610,13 +622,12 @@ impl Client { /// Get the list of coins for the specified address. /// - /// If `coin_type` is not provided, it will default to `0x2::coin::Coin`, - /// which will return all coins. For IOTA coin, pass in the coin type: - /// `0x2::coin::Coin<0x2::iota::IOTA>`. + /// If `coin_type` is not provided, all coins will be returned. For IOTA + /// coins, pass in the coin type: `0x2::iota::IOTA`. pub async fn coins( &self, owner: Address, - coin_type: impl Into>, + coin_type: impl Into>, pagination_filter: PaginationFilter, ) -> Result> { let response = self @@ -625,7 +636,14 @@ impl Client { type_: Some( coin_type .into() - .unwrap_or_else(|| "0x2::coin::Coin".to_owned()), + .map(StructTag::coin) + .unwrap_or_else(|| StructTag { + address: Address::FRAMEWORK, + module: IdentifierRef::const_new("coin").into(), + name: IdentifierRef::const_new("Coin").into(), + type_params: Default::default(), + }) + .to_string(), ), owner: Some(owner), object_ids: None, @@ -644,6 +662,16 @@ impl Client { )) } + /// Get the list of gas coins for the specified address. + pub async fn gas_coins( + &self, + owner: Address, + pagination_filter: PaginationFilter, + ) -> Result> { + self.coins(owner, StructTag::iota(), pagination_filter) + .await + } + /// Get the coin metadata for the coin type. pub async fn coin_metadata(&self, coin_type: &str) -> Result> { let operation = CoinMetadataQuery::build(CoinMetadataArgs { coin_type }); @@ -2189,9 +2217,7 @@ mod tests { let mut num_coins = 0; for attempt in 0..MAX_RETRIES { - let mut stream = client - .coins_stream(address, None, Direction::default()) - .await; + let mut stream = client.coins_stream(address, None, Direction::default()); while let Some(result) = stream.next().await { match result { diff --git a/crates/iota-sdk-ffi/src/graphql.rs b/crates/iota-sdk-ffi/src/graphql.rs index 079e4caeb..68a8c7a20 100644 --- a/crates/iota-sdk-ffi/src/graphql.rs +++ b/crates/iota-sdk-ffi/src/graphql.rs @@ -24,6 +24,7 @@ use crate::{ iota_names::Name, object::{MovePackage, Object, ObjectId}, signature::UserSignature, + struct_tag::StructTag, transaction::{SignedTransaction, Transaction, TransactionEffects, TransactionKind}, type_tag::TypeTag, }, @@ -169,21 +170,41 @@ impl GraphQLClient { /// Get the list of coins for the specified address. /// - /// If `coin_type` is not provided, it will default to `0x2::coin::Coin`, - /// which will return all coins. For IOTA coin, pass in the coin type: - /// `0x2::coin::Coin<0x2::iota::IOTA>`. + /// If `coin_type` is not provided, all coins will be returned. For IOTA + /// coins, pass in the coin type: `0x2::iota::IOTA`. #[uniffi::method(default(pagination_filter = None, coin_type = None))] pub async fn coins( &self, owner: &Address, pagination_filter: Option, - coin_type: Option, + coin_type: Option>, + ) -> Result { + Ok(self + .0 + .read() + .await + .coins( + **owner, + coin_type.map(|t| t.0.clone()), + pagination_filter.unwrap_or_default(), + ) + .await? + .map(Into::into) + .into()) + } + + /// Get the list of gas coins for the specified address. + #[uniffi::method(default(pagination_filter = None))] + pub async fn gas_coins( + &self, + owner: &Address, + pagination_filter: Option, ) -> Result { Ok(self .0 .read() .await - .coins(**owner, coin_type, pagination_filter.unwrap_or_default()) + .gas_coins(**owner, pagination_filter.unwrap_or_default()) .await? .map(Into::into) .into()) diff --git a/crates/iota-sdk-types/src/type_tag/mod.rs b/crates/iota-sdk-types/src/type_tag/mod.rs index 4ee67041e..461946821 100644 --- a/crates/iota-sdk-types/src/type_tag/mod.rs +++ b/crates/iota-sdk-types/src/type_tag/mod.rs @@ -402,12 +402,12 @@ pub struct StructTag { } impl StructTag { - pub fn coin(type_tag: TypeTag) -> Self { + pub fn coin(type_tag: impl Into) -> Self { Self { address: Address::FRAMEWORK, - module: Identifier::new("coin").unwrap(), - name: Identifier::new("Coin").unwrap(), - type_params: vec![type_tag], + module: IdentifierRef::const_new("coin").into(), + name: IdentifierRef::const_new("Coin").into(), + type_params: vec![type_tag.into()], } } @@ -436,22 +436,24 @@ impl StructTag { self.coin_type_opt().expect("not a coin") } - pub fn gas_coin() -> Self { - let iota = Self { + pub fn iota() -> Self { + Self { address: Address::FRAMEWORK, - module: Identifier::new("iota").unwrap(), - name: Identifier::new("IOTA").unwrap(), + module: IdentifierRef::const_new("iota").into(), + name: IdentifierRef::const_new("IOTA").into(), type_params: vec![], - }; + } + } - Self::coin(TypeTag::Struct(Box::new(iota))) + pub fn gas_coin() -> Self { + Self::coin(Self::iota()) } pub fn staked_iota() -> Self { Self { address: Address::SYSTEM, - module: Identifier::new("staking_pool").unwrap(), - name: Identifier::new("StakedIota").unwrap(), + module: IdentifierRef::const_new("staking_pool").into(), + name: IdentifierRef::const_new("StakedIota").into(), type_params: vec![], } } @@ -459,8 +461,8 @@ impl StructTag { pub fn timelocked_staked_iota() -> Self { Self { address: Address::SYSTEM, - module: Identifier::new("timelocked_staking").unwrap(), - name: Identifier::new("TimelockedStakedIota").unwrap(), + module: IdentifierRef::const_new("timelocked_staking").into(), + name: IdentifierRef::const_new("TimelockedStakedIota").into(), type_params: vec![], } } diff --git a/crates/iota-graphql-client/examples/prepare_transfer_objects_offline.rs b/crates/iota-sdk/examples/prepare_transfer_objects_offline.rs similarity index 100% rename from crates/iota-graphql-client/examples/prepare_transfer_objects_offline.rs rename to crates/iota-sdk/examples/prepare_transfer_objects_offline.rs