From eb39d1ed7fa04d9dd87cc62e82939abdab6bdce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zoe=20Faltib=C3=A0?= Date: Fri, 23 Aug 2024 10:53:46 +0200 Subject: [PATCH] update rgb-lib to 0.3.0-alpha.6 + bump to 0.3.0-alpha.6 --- Package.swift | 4 +- README.md | 8 +- Sources/RgbLib/RgbLib.swift | 261 +++++++++++++++++++----------------- generate.sh | 28 ++-- rgb-lib | 2 +- 5 files changed, 159 insertions(+), 144 deletions(-) diff --git a/Package.swift b/Package.swift index a5eb928..635cbb7 100644 --- a/Package.swift +++ b/Package.swift @@ -25,8 +25,8 @@ let package = Package( // .binaryTarget(name: "rgb_libFFI", path: "./rgb_libFFI.xcframework"), .binaryTarget( name: "rgb_libFFI", - url: "https://github.com/RGB-Tools/rgb-lib-swift/releases/download/0.3.0-alpha.4/rgb_libFFI.xcframework.zip", - checksum: "2c27a25e6bf1d34fdcddd680c6272346bbd03df48e5895f3cae9311c2def68e7"), + url: "https://github.com/RGB-Tools/rgb-lib-swift/releases/download/0.3.0-alpha.6/rgb_libFFI.xcframework.zip", + checksum: "e0892841c456cfc5f69b7c7e42889f1a51e71ae96d57a67ec5e999f7914ac245"), .target( name: "RgbLib", dependencies: ["rgb_libFFI"]), diff --git a/README.md b/README.md index 2a0aa43..56c33a2 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This project builds a Swift library, `RgbLib`, for the [rgb-lib] Rust library, which is included as a git submodule. The bindings are created by -the [rgb-lib-ffi] project, which is located inside the rgb-lib submodule. +the [rgb-lib-uniffi] project, which is located inside the rgb-lib submodule. ## Usage @@ -33,8 +33,8 @@ For example: ```swift .binaryTarget( name: "rgb_libFFI", - url: "https://github.com/RGB-Tools/rgb-lib-swift/releases/download/0.3.0-alpha.4/rgb_libFFI.xcframework.zip", - checksum: "2c27a25e6bf1d34fdcddd680c6272346bbd03df48e5895f3cae9311c2def68e7"), + url: "https://github.com/RGB-Tools/rgb-lib-swift/releases/download/0.3.0-alpha.6/rgb_libFFI.xcframework.zip", + checksum: "e0892841c456cfc5f69b7c7e42889f1a51e71ae96d57a67ec5e999f7914ac245"), ``` Commit the changed `Package.swift` file, then tag the commit with the new @@ -49,4 +49,4 @@ If you get an error you might need to reset the Xcode package caches: [rgb-lib]: https://github.com/RGB-Tools/rgb-lib -[rgb-lib-ffi]: https://github.com/RGB-Tools/rgb-lib/tree/master/rgb-lib-ffi +[rgb-lib-uniffi]: https://github.com/RGB-Tools/rgb-lib/tree/master/bindings/uniffi diff --git a/Sources/RgbLib/RgbLib.swift b/Sources/RgbLib/RgbLib.swift index e041ade..6185a27 100644 --- a/Sources/RgbLib/RgbLib.swift +++ b/Sources/RgbLib/RgbLib.swift @@ -25,13 +25,13 @@ fileprivate extension RustBuffer { } static func from(_ ptr: UnsafeBufferPointer) -> RustBuffer { - try! rustCall { ffi_rgblibffi_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) } + try! rustCall { ffi_rgblibuniffi_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) } } // Frees the buffer in place. // The buffer must not be used after this is called. func deallocate() { - try! rustCall { ffi_rgblibffi_rustbuffer_free(self, $0) } + try! rustCall { ffi_rgblibuniffi_rustbuffer_free(self, $0) } } } @@ -153,7 +153,7 @@ fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) { } // Protocol for types that transfer other types across the FFI. This is -// analogous go the Rust trait of the same name. +// analogous to the Rust trait of the same name. fileprivate protocol FfiConverter { associatedtype FfiType associatedtype SwiftType @@ -253,18 +253,19 @@ fileprivate extension RustCallStatus { } private func rustCall(_ callback: (UnsafeMutablePointer) -> T) throws -> T { - try makeRustCall(callback, errorHandler: nil) + let neverThrow: ((RustBuffer) throws -> Never)? = nil + return try makeRustCall(callback, errorHandler: neverThrow) } -private func rustCallWithError( - _ errorHandler: @escaping (RustBuffer) throws -> Error, +private func rustCallWithError( + _ errorHandler: @escaping (RustBuffer) throws -> E, _ callback: (UnsafeMutablePointer) -> T) throws -> T { try makeRustCall(callback, errorHandler: errorHandler) } -private func makeRustCall( +private func makeRustCall( _ callback: (UnsafeMutablePointer) -> T, - errorHandler: ((RustBuffer) throws -> Error)? + errorHandler: ((RustBuffer) throws -> E)? ) throws -> T { uniffiEnsureInitialized() var callStatus = RustCallStatus.init() @@ -273,9 +274,9 @@ private func makeRustCall( return returnedVal } -private func uniffiCheckCallStatus( +private func uniffiCheckCallStatus( callStatus: RustCallStatus, - errorHandler: ((RustBuffer) throws -> Error)? + errorHandler: ((RustBuffer) throws -> E)? ) throws { switch callStatus.code { case CALL_SUCCESS: @@ -555,12 +556,12 @@ open class Invoice: } public func uniffiClonePointer() -> UnsafeMutableRawPointer { - return try! rustCall { uniffi_rgblibffi_fn_clone_invoice(self.pointer, $0) } + return try! rustCall { uniffi_rgblibuniffi_fn_clone_invoice(self.pointer, $0) } } public convenience init(invoiceString: String)throws { let pointer = try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_constructor_invoice_new( + uniffi_rgblibuniffi_fn_constructor_invoice_new( FfiConverterString.lower(invoiceString),$0 ) } @@ -572,13 +573,13 @@ public convenience init(invoiceString: String)throws { return } - try! rustCall { uniffi_rgblibffi_fn_free_invoice(pointer, $0) } + try! rustCall { uniffi_rgblibuniffi_fn_free_invoice(pointer, $0) } } public static func fromInvoiceData(invoiceData: InvoiceData)throws -> Invoice { return try FfiConverterTypeInvoice.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_constructor_invoice_from_invoice_data( + uniffi_rgblibuniffi_fn_constructor_invoice_from_invoice_data( FfiConverterTypeInvoiceData.lower(invoiceData),$0 ) }) @@ -588,14 +589,14 @@ public static func fromInvoiceData(invoiceData: InvoiceData)throws -> Invoice { open func invoiceData() -> InvoiceData { return try! FfiConverterTypeInvoiceData.lift(try! rustCall() { - uniffi_rgblibffi_fn_method_invoice_invoice_data(self.uniffiClonePointer(),$0 + uniffi_rgblibuniffi_fn_method_invoice_invoice_data(self.uniffiClonePointer(),$0 ) }) } open func invoiceString() -> String { return try! FfiConverterString.lift(try! rustCall() { - uniffi_rgblibffi_fn_method_invoice_invoice_string(self.uniffiClonePointer(),$0 + uniffi_rgblibuniffi_fn_method_invoice_invoice_string(self.uniffiClonePointer(),$0 ) }) } @@ -682,12 +683,12 @@ open class RecipientInfo: } public func uniffiClonePointer() -> UnsafeMutableRawPointer { - return try! rustCall { uniffi_rgblibffi_fn_clone_recipientinfo(self.pointer, $0) } + return try! rustCall { uniffi_rgblibuniffi_fn_clone_recipientinfo(self.pointer, $0) } } public convenience init(recipientId: String)throws { let pointer = try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_constructor_recipientinfo_new( + uniffi_rgblibuniffi_fn_constructor_recipientinfo_new( FfiConverterString.lower(recipientId),$0 ) } @@ -699,7 +700,7 @@ public convenience init(recipientId: String)throws { return } - try! rustCall { uniffi_rgblibffi_fn_free_recipientinfo(pointer, $0) } + try! rustCall { uniffi_rgblibuniffi_fn_free_recipientinfo(pointer, $0) } } @@ -707,14 +708,14 @@ public convenience init(recipientId: String)throws { open func network() -> BitcoinNetwork { return try! FfiConverterTypeBitcoinNetwork.lift(try! rustCall() { - uniffi_rgblibffi_fn_method_recipientinfo_network(self.uniffiClonePointer(),$0 + uniffi_rgblibuniffi_fn_method_recipientinfo_network(self.uniffiClonePointer(),$0 ) }) } open func recipientType() -> RecipientType { return try! FfiConverterTypeRecipientType.lift(try! rustCall() { - uniffi_rgblibffi_fn_method_recipientinfo_recipient_type(self.uniffiClonePointer(),$0 + uniffi_rgblibuniffi_fn_method_recipientinfo_recipient_type(self.uniffiClonePointer(),$0 ) }) } @@ -799,12 +800,12 @@ open class TransportEndpoint: } public func uniffiClonePointer() -> UnsafeMutableRawPointer { - return try! rustCall { uniffi_rgblibffi_fn_clone_transportendpoint(self.pointer, $0) } + return try! rustCall { uniffi_rgblibuniffi_fn_clone_transportendpoint(self.pointer, $0) } } public convenience init(transportEndpoint: String)throws { let pointer = try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_constructor_transportendpoint_new( + uniffi_rgblibuniffi_fn_constructor_transportendpoint_new( FfiConverterString.lower(transportEndpoint),$0 ) } @@ -816,7 +817,7 @@ public convenience init(transportEndpoint: String)throws { return } - try! rustCall { uniffi_rgblibffi_fn_free_transportendpoint(pointer, $0) } + try! rustCall { uniffi_rgblibuniffi_fn_free_transportendpoint(pointer, $0) } } @@ -824,7 +825,7 @@ public convenience init(transportEndpoint: String)throws { open func transportType() -> TransportType { return try! FfiConverterTypeTransportType.lift(try! rustCall() { - uniffi_rgblibffi_fn_method_transportendpoint_transport_type(self.uniffiClonePointer(),$0 + uniffi_rgblibuniffi_fn_method_transportendpoint_transport_type(self.uniffiClonePointer(),$0 ) }) } @@ -977,12 +978,12 @@ open class Wallet: } public func uniffiClonePointer() -> UnsafeMutableRawPointer { - return try! rustCall { uniffi_rgblibffi_fn_clone_wallet(self.pointer, $0) } + return try! rustCall { uniffi_rgblibuniffi_fn_clone_wallet(self.pointer, $0) } } public convenience init(walletData: WalletData)throws { let pointer = try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_constructor_wallet_new( + uniffi_rgblibuniffi_fn_constructor_wallet_new( FfiConverterTypeWalletData.lower(walletData),$0 ) } @@ -994,14 +995,14 @@ public convenience init(walletData: WalletData)throws { return } - try! rustCall { uniffi_rgblibffi_fn_free_wallet(pointer, $0) } + try! rustCall { uniffi_rgblibuniffi_fn_free_wallet(pointer, $0) } } open func backup(backupPath: String, password: String)throws {try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_backup(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_backup(self.uniffiClonePointer(), FfiConverterString.lower(backupPath), FfiConverterString.lower(password),$0 ) @@ -1010,14 +1011,14 @@ open func backup(backupPath: String, password: String)throws {try rustCallWithE open func backupInfo()throws -> Bool { return try FfiConverterBool.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_backup_info(self.uniffiClonePointer(),$0 + uniffi_rgblibuniffi_fn_method_wallet_backup_info(self.uniffiClonePointer(),$0 ) }) } open func blindReceive(assetId: String?, amount: UInt64?, durationSeconds: UInt32?, transportEndpoints: [String], minConfirmations: UInt8)throws -> ReceiveData { return try FfiConverterTypeReceiveData.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_blind_receive(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_blind_receive(self.uniffiClonePointer(), FfiConverterOptionString.lower(assetId), FfiConverterOptionUInt64.lower(amount), FfiConverterOptionUInt32.lower(durationSeconds), @@ -1029,7 +1030,7 @@ open func blindReceive(assetId: String?, amount: UInt64?, durationSeconds: UInt3 open func createUtxos(online: Online, upTo: Bool, num: UInt8?, size: UInt32?, feeRate: Float)throws -> UInt8 { return try FfiConverterUInt8.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_create_utxos(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_create_utxos(self.uniffiClonePointer(), FfiConverterTypeOnline.lower(online), FfiConverterBool.lower(upTo), FfiConverterOptionUInt8.lower(num), @@ -1041,7 +1042,7 @@ open func createUtxos(online: Online, upTo: Bool, num: UInt8?, size: UInt32?, fe open func createUtxosBegin(online: Online, upTo: Bool, num: UInt8?, size: UInt32?, feeRate: Float)throws -> String { return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_create_utxos_begin(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_create_utxos_begin(self.uniffiClonePointer(), FfiConverterTypeOnline.lower(online), FfiConverterBool.lower(upTo), FfiConverterOptionUInt8.lower(num), @@ -1053,7 +1054,7 @@ open func createUtxosBegin(online: Online, upTo: Bool, num: UInt8?, size: UInt32 open func createUtxosEnd(online: Online, signedPsbt: String)throws -> UInt8 { return try FfiConverterUInt8.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_create_utxos_end(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_create_utxos_end(self.uniffiClonePointer(), FfiConverterTypeOnline.lower(online), FfiConverterString.lower(signedPsbt),$0 ) @@ -1062,7 +1063,7 @@ open func createUtxosEnd(online: Online, signedPsbt: String)throws -> UInt8 { open func deleteTransfers(batchTransferIdx: Int32?, noAssetOnly: Bool)throws -> Bool { return try FfiConverterBool.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_delete_transfers(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_delete_transfers(self.uniffiClonePointer(), FfiConverterOptionInt32.lower(batchTransferIdx), FfiConverterBool.lower(noAssetOnly),$0 ) @@ -1071,7 +1072,7 @@ open func deleteTransfers(batchTransferIdx: Int32?, noAssetOnly: Bool)throws -> open func drainTo(online: Online, address: String, destroyAssets: Bool, feeRate: Float)throws -> String { return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_drain_to(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_drain_to(self.uniffiClonePointer(), FfiConverterTypeOnline.lower(online), FfiConverterString.lower(address), FfiConverterBool.lower(destroyAssets), @@ -1082,7 +1083,7 @@ open func drainTo(online: Online, address: String, destroyAssets: Bool, feeRate: open func drainToBegin(online: Online, address: String, destroyAssets: Bool, feeRate: Float)throws -> String { return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_drain_to_begin(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_drain_to_begin(self.uniffiClonePointer(), FfiConverterTypeOnline.lower(online), FfiConverterString.lower(address), FfiConverterBool.lower(destroyAssets), @@ -1093,7 +1094,7 @@ open func drainToBegin(online: Online, address: String, destroyAssets: Bool, fee open func drainToEnd(online: Online, signedPsbt: String)throws -> String { return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_drain_to_end(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_drain_to_end(self.uniffiClonePointer(), FfiConverterTypeOnline.lower(online), FfiConverterString.lower(signedPsbt),$0 ) @@ -1102,7 +1103,7 @@ open func drainToEnd(online: Online, signedPsbt: String)throws -> String { open func failTransfers(online: Online, batchTransferIdx: Int32?, noAssetOnly: Bool)throws -> Bool { return try FfiConverterBool.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_fail_transfers(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_fail_transfers(self.uniffiClonePointer(), FfiConverterTypeOnline.lower(online), FfiConverterOptionInt32.lower(batchTransferIdx), FfiConverterBool.lower(noAssetOnly),$0 @@ -1112,14 +1113,14 @@ open func failTransfers(online: Online, batchTransferIdx: Int32?, noAssetOnly: B open func getAddress()throws -> String { return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_get_address(self.uniffiClonePointer(),$0 + uniffi_rgblibuniffi_fn_method_wallet_get_address(self.uniffiClonePointer(),$0 ) }) } open func getAssetBalance(assetId: String)throws -> Balance { return try FfiConverterTypeBalance.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_get_asset_balance(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_get_asset_balance(self.uniffiClonePointer(), FfiConverterString.lower(assetId),$0 ) }) @@ -1127,7 +1128,7 @@ open func getAssetBalance(assetId: String)throws -> Balance { open func getAssetMetadata(assetId: String)throws -> Metadata { return try FfiConverterTypeMetadata.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_get_asset_metadata(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_get_asset_metadata(self.uniffiClonePointer(), FfiConverterString.lower(assetId),$0 ) }) @@ -1135,7 +1136,7 @@ open func getAssetMetadata(assetId: String)throws -> Metadata { open func getBtcBalance(online: Online)throws -> BtcBalance { return try FfiConverterTypeBtcBalance.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_get_btc_balance(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_get_btc_balance(self.uniffiClonePointer(), FfiConverterTypeOnline.lower(online),$0 ) }) @@ -1143,28 +1144,28 @@ open func getBtcBalance(online: Online)throws -> BtcBalance { open func getMediaDir() -> String { return try! FfiConverterString.lift(try! rustCall() { - uniffi_rgblibffi_fn_method_wallet_get_media_dir(self.uniffiClonePointer(),$0 + uniffi_rgblibuniffi_fn_method_wallet_get_media_dir(self.uniffiClonePointer(),$0 ) }) } open func getWalletData() -> WalletData { return try! FfiConverterTypeWalletData.lift(try! rustCall() { - uniffi_rgblibffi_fn_method_wallet_get_wallet_data(self.uniffiClonePointer(),$0 + uniffi_rgblibuniffi_fn_method_wallet_get_wallet_data(self.uniffiClonePointer(),$0 ) }) } open func getWalletDir() -> String { return try! FfiConverterString.lift(try! rustCall() { - uniffi_rgblibffi_fn_method_wallet_get_wallet_dir(self.uniffiClonePointer(),$0 + uniffi_rgblibuniffi_fn_method_wallet_get_wallet_dir(self.uniffiClonePointer(),$0 ) }) } open func goOnline(skipConsistencyCheck: Bool, indexerUrl: String)throws -> Online { return try FfiConverterTypeOnline.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_go_online(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_go_online(self.uniffiClonePointer(), FfiConverterBool.lower(skipConsistencyCheck), FfiConverterString.lower(indexerUrl),$0 ) @@ -1173,7 +1174,7 @@ open func goOnline(skipConsistencyCheck: Bool, indexerUrl: String)throws -> Onl open func issueAssetCfa(online: Online, name: String, details: String?, precision: UInt8, amounts: [UInt64], filePath: String?)throws -> AssetCfa { return try FfiConverterTypeAssetCFA.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_issue_asset_cfa(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_issue_asset_cfa(self.uniffiClonePointer(), FfiConverterTypeOnline.lower(online), FfiConverterString.lower(name), FfiConverterOptionString.lower(details), @@ -1186,7 +1187,7 @@ open func issueAssetCfa(online: Online, name: String, details: String?, precisio open func issueAssetNia(online: Online, ticker: String, name: String, precision: UInt8, amounts: [UInt64])throws -> AssetNia { return try FfiConverterTypeAssetNIA.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_issue_asset_nia(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_issue_asset_nia(self.uniffiClonePointer(), FfiConverterTypeOnline.lower(online), FfiConverterString.lower(ticker), FfiConverterString.lower(name), @@ -1198,7 +1199,7 @@ open func issueAssetNia(online: Online, ticker: String, name: String, precision: open func issueAssetUda(online: Online, ticker: String, name: String, details: String?, precision: UInt8, mediaFilePath: String?, attachmentsFilePaths: [String])throws -> AssetUda { return try FfiConverterTypeAssetUDA.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_issue_asset_uda(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_issue_asset_uda(self.uniffiClonePointer(), FfiConverterTypeOnline.lower(online), FfiConverterString.lower(ticker), FfiConverterString.lower(name), @@ -1212,7 +1213,7 @@ open func issueAssetUda(online: Online, ticker: String, name: String, details: S open func listAssets(filterAssetSchemas: [AssetSchema])throws -> Assets { return try FfiConverterTypeAssets.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_list_assets(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_list_assets(self.uniffiClonePointer(), FfiConverterSequenceTypeAssetSchema.lower(filterAssetSchemas),$0 ) }) @@ -1220,7 +1221,7 @@ open func listAssets(filterAssetSchemas: [AssetSchema])throws -> Assets { open func listTransactions(online: Online?)throws -> [Transaction] { return try FfiConverterSequenceTypeTransaction.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_list_transactions(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_list_transactions(self.uniffiClonePointer(), FfiConverterOptionTypeOnline.lower(online),$0 ) }) @@ -1228,7 +1229,7 @@ open func listTransactions(online: Online?)throws -> [Transaction] { open func listTransfers(assetId: String?)throws -> [Transfer] { return try FfiConverterSequenceTypeTransfer.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_list_transfers(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_list_transfers(self.uniffiClonePointer(), FfiConverterOptionString.lower(assetId),$0 ) }) @@ -1236,7 +1237,7 @@ open func listTransfers(assetId: String?)throws -> [Transfer] { open func listUnspents(online: Online?, settledOnly: Bool)throws -> [Unspent] { return try FfiConverterSequenceTypeUnspent.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_list_unspents(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_list_unspents(self.uniffiClonePointer(), FfiConverterOptionTypeOnline.lower(online), FfiConverterBool.lower(settledOnly),$0 ) @@ -1245,7 +1246,7 @@ open func listUnspents(online: Online?, settledOnly: Bool)throws -> [Unspent] { open func refresh(online: Online, assetId: String?, filter: [RefreshFilter])throws -> [Int32: RefreshedTransfer] { return try FfiConverterDictionaryInt32TypeRefreshedTransfer.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_refresh(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_refresh(self.uniffiClonePointer(), FfiConverterTypeOnline.lower(online), FfiConverterOptionString.lower(assetId), FfiConverterSequenceTypeRefreshFilter.lower(filter),$0 @@ -1255,7 +1256,7 @@ open func refresh(online: Online, assetId: String?, filter: [RefreshFilter])thro open func send(online: Online, recipientMap: [String: [Recipient]], donation: Bool, feeRate: Float, minConfirmations: UInt8)throws -> SendResult { return try FfiConverterTypeSendResult.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_send(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_send(self.uniffiClonePointer(), FfiConverterTypeOnline.lower(online), FfiConverterDictionaryStringSequenceTypeRecipient.lower(recipientMap), FfiConverterBool.lower(donation), @@ -1267,7 +1268,7 @@ open func send(online: Online, recipientMap: [String: [Recipient]], donation: Bo open func sendBegin(online: Online, recipientMap: [String: [Recipient]], donation: Bool, feeRate: Float, minConfirmations: UInt8)throws -> String { return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_send_begin(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_send_begin(self.uniffiClonePointer(), FfiConverterTypeOnline.lower(online), FfiConverterDictionaryStringSequenceTypeRecipient.lower(recipientMap), FfiConverterBool.lower(donation), @@ -1279,7 +1280,7 @@ open func sendBegin(online: Online, recipientMap: [String: [Recipient]], donatio open func sendBtc(online: Online, address: String, amount: UInt64, feeRate: Float)throws -> String { return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_send_btc(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_send_btc(self.uniffiClonePointer(), FfiConverterTypeOnline.lower(online), FfiConverterString.lower(address), FfiConverterUInt64.lower(amount), @@ -1290,7 +1291,7 @@ open func sendBtc(online: Online, address: String, amount: UInt64, feeRate: Floa open func sendBtcBegin(online: Online, address: String, amount: UInt64, feeRate: Float)throws -> String { return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_send_btc_begin(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_send_btc_begin(self.uniffiClonePointer(), FfiConverterTypeOnline.lower(online), FfiConverterString.lower(address), FfiConverterUInt64.lower(amount), @@ -1301,7 +1302,7 @@ open func sendBtcBegin(online: Online, address: String, amount: UInt64, feeRate: open func sendBtcEnd(online: Online, signedPsbt: String)throws -> String { return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_send_btc_end(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_send_btc_end(self.uniffiClonePointer(), FfiConverterTypeOnline.lower(online), FfiConverterString.lower(signedPsbt),$0 ) @@ -1310,7 +1311,7 @@ open func sendBtcEnd(online: Online, signedPsbt: String)throws -> String { open func sendEnd(online: Online, signedPsbt: String)throws -> SendResult { return try FfiConverterTypeSendResult.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_send_end(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_send_end(self.uniffiClonePointer(), FfiConverterTypeOnline.lower(online), FfiConverterString.lower(signedPsbt),$0 ) @@ -1319,7 +1320,7 @@ open func sendEnd(online: Online, signedPsbt: String)throws -> SendResult { open func signPsbt(unsignedPsbt: String)throws -> String { return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_sign_psbt(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_sign_psbt(self.uniffiClonePointer(), FfiConverterString.lower(unsignedPsbt),$0 ) }) @@ -1327,7 +1328,7 @@ open func signPsbt(unsignedPsbt: String)throws -> String { open func witnessReceive(assetId: String?, amount: UInt64?, durationSeconds: UInt32?, transportEndpoints: [String], minConfirmations: UInt8)throws -> ReceiveData { return try FfiConverterTypeReceiveData.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_method_wallet_witness_receive(self.uniffiClonePointer(), + uniffi_rgblibuniffi_fn_method_wallet_witness_receive(self.uniffiClonePointer(), FfiConverterOptionString.lower(assetId), FfiConverterOptionUInt64.lower(amount), FfiConverterOptionUInt32.lower(durationSeconds), @@ -4217,6 +4218,8 @@ public enum RgbLibError { case UnsupportedLayer1(layer1: String ) case UnsupportedTransportType + case WalletDirAlreadyExists(path: String + ) case WatchOnly case WrongPassword } @@ -4379,8 +4382,11 @@ public struct FfiConverterTypeRgbLibError: FfiConverterRustBuffer { layer1: try FfiConverterString.read(from: &buf) ) case 64: return .UnsupportedTransportType - case 65: return .WatchOnly - case 66: return .WrongPassword + case 65: return .WalletDirAlreadyExists( + path: try FfiConverterString.read(from: &buf) + ) + case 66: return .WatchOnly + case 67: return .WrongPassword default: throw UniffiInternalError.unexpectedEnumCase } @@ -4691,12 +4697,17 @@ public struct FfiConverterTypeRgbLibError: FfiConverterRustBuffer { writeInt(&buf, Int32(64)) - case .WatchOnly: + case let .WalletDirAlreadyExists(path): writeInt(&buf, Int32(65)) + FfiConverterString.write(path, into: &buf) + + + case .WatchOnly: + writeInt(&buf, Int32(66)) case .WrongPassword: - writeInt(&buf, Int32(66)) + writeInt(&buf, Int32(67)) } } @@ -4705,7 +4716,11 @@ public struct FfiConverterTypeRgbLibError: FfiConverterRustBuffer { extension RgbLibError: Equatable, Hashable {} -extension RgbLibError: Error { } +extension RgbLibError: Foundation.LocalizedError { + public var errorDescription: String? { + String(reflecting: self) + } +} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. @@ -5781,13 +5796,13 @@ fileprivate struct FfiConverterDictionaryStringSequenceTypeRecipient: FfiConvert } public func generateKeys(bitcoinNetwork: BitcoinNetwork) -> Keys { return try! FfiConverterTypeKeys.lift(try! rustCall() { - uniffi_rgblibffi_fn_func_generate_keys( + uniffi_rgblibuniffi_fn_func_generate_keys( FfiConverterTypeBitcoinNetwork.lower(bitcoinNetwork),$0 ) }) } public func restoreBackup(backupPath: String, password: String, dataDir: String)throws {try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_func_restore_backup( + uniffi_rgblibuniffi_fn_func_restore_backup( FfiConverterString.lower(backupPath), FfiConverterString.lower(password), FfiConverterString.lower(dataDir),$0 @@ -5796,7 +5811,7 @@ public func restoreBackup(backupPath: String, password: String, dataDir: String) } public func restoreKeys(bitcoinNetwork: BitcoinNetwork, mnemonic: String)throws -> Keys { return try FfiConverterTypeKeys.lift(try rustCallWithError(FfiConverterTypeRgbLibError.lift) { - uniffi_rgblibffi_fn_func_restore_keys( + uniffi_rgblibuniffi_fn_func_restore_keys( FfiConverterTypeBitcoinNetwork.lower(bitcoinNetwork), FfiConverterString.lower(mnemonic),$0 ) @@ -5808,163 +5823,163 @@ private enum InitializationResult { case contractVersionMismatch case apiChecksumMismatch } -// Use a global variables to perform the versioning checks. Swift ensures that +// Use a global variable to perform the versioning checks. Swift ensures that // the code inside is only computed once. -private var initializationResult: InitializationResult { +private var initializationResult: InitializationResult = { // Get the bindings contract version from our ComponentInterface let bindings_contract_version = 26 // Get the scaffolding contract version by calling the into the dylib - let scaffolding_contract_version = ffi_rgblibffi_uniffi_contract_version() + let scaffolding_contract_version = ffi_rgblibuniffi_uniffi_contract_version() if bindings_contract_version != scaffolding_contract_version { return InitializationResult.contractVersionMismatch } - if (uniffi_rgblibffi_checksum_func_generate_keys() != 64259) { + if (uniffi_rgblibuniffi_checksum_func_generate_keys() != 50781) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_func_restore_backup() != 15101) { + if (uniffi_rgblibuniffi_checksum_func_restore_backup() != 4743) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_func_restore_keys() != 42405) { + if (uniffi_rgblibuniffi_checksum_func_restore_keys() != 38408) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_invoice_invoice_data() != 11706) { + if (uniffi_rgblibuniffi_checksum_method_invoice_invoice_data() != 31294) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_invoice_invoice_string() != 49576) { + if (uniffi_rgblibuniffi_checksum_method_invoice_invoice_string() != 25144) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_recipientinfo_network() != 1106) { + if (uniffi_rgblibuniffi_checksum_method_recipientinfo_network() != 22005) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_recipientinfo_recipient_type() != 53534) { + if (uniffi_rgblibuniffi_checksum_method_recipientinfo_recipient_type() != 3457) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_transportendpoint_transport_type() != 52347) { + if (uniffi_rgblibuniffi_checksum_method_transportendpoint_transport_type() != 33510) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_backup() != 60293) { + if (uniffi_rgblibuniffi_checksum_method_wallet_backup() != 41851) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_backup_info() != 938) { + if (uniffi_rgblibuniffi_checksum_method_wallet_backup_info() != 7253) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_blind_receive() != 34365) { + if (uniffi_rgblibuniffi_checksum_method_wallet_blind_receive() != 26641) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_create_utxos() != 59455) { + if (uniffi_rgblibuniffi_checksum_method_wallet_create_utxos() != 58778) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_create_utxos_begin() != 58076) { + if (uniffi_rgblibuniffi_checksum_method_wallet_create_utxos_begin() != 18787) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_create_utxos_end() != 37296) { + if (uniffi_rgblibuniffi_checksum_method_wallet_create_utxos_end() != 43077) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_delete_transfers() != 55560) { + if (uniffi_rgblibuniffi_checksum_method_wallet_delete_transfers() != 43847) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_drain_to() != 28781) { + if (uniffi_rgblibuniffi_checksum_method_wallet_drain_to() != 26199) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_drain_to_begin() != 37910) { + if (uniffi_rgblibuniffi_checksum_method_wallet_drain_to_begin() != 18017) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_drain_to_end() != 19119) { + if (uniffi_rgblibuniffi_checksum_method_wallet_drain_to_end() != 62328) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_fail_transfers() != 24813) { + if (uniffi_rgblibuniffi_checksum_method_wallet_fail_transfers() != 54189) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_get_address() != 51506) { + if (uniffi_rgblibuniffi_checksum_method_wallet_get_address() != 23668) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_get_asset_balance() != 34628) { + if (uniffi_rgblibuniffi_checksum_method_wallet_get_asset_balance() != 19662) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_get_asset_metadata() != 33881) { + if (uniffi_rgblibuniffi_checksum_method_wallet_get_asset_metadata() != 58573) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_get_btc_balance() != 29947) { + if (uniffi_rgblibuniffi_checksum_method_wallet_get_btc_balance() != 48437) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_get_media_dir() != 42269) { + if (uniffi_rgblibuniffi_checksum_method_wallet_get_media_dir() != 64429) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_get_wallet_data() != 14427) { + if (uniffi_rgblibuniffi_checksum_method_wallet_get_wallet_data() != 18071) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_get_wallet_dir() != 56411) { + if (uniffi_rgblibuniffi_checksum_method_wallet_get_wallet_dir() != 8726) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_go_online() != 36143) { + if (uniffi_rgblibuniffi_checksum_method_wallet_go_online() != 46399) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_issue_asset_cfa() != 10376) { + if (uniffi_rgblibuniffi_checksum_method_wallet_issue_asset_cfa() != 32318) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_issue_asset_nia() != 17069) { + if (uniffi_rgblibuniffi_checksum_method_wallet_issue_asset_nia() != 45243) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_issue_asset_uda() != 56590) { + if (uniffi_rgblibuniffi_checksum_method_wallet_issue_asset_uda() != 52344) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_list_assets() != 46965) { + if (uniffi_rgblibuniffi_checksum_method_wallet_list_assets() != 18027) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_list_transactions() != 56257) { + if (uniffi_rgblibuniffi_checksum_method_wallet_list_transactions() != 24012) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_list_transfers() != 36467) { + if (uniffi_rgblibuniffi_checksum_method_wallet_list_transfers() != 36530) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_list_unspents() != 4224) { + if (uniffi_rgblibuniffi_checksum_method_wallet_list_unspents() != 3915) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_refresh() != 41719) { + if (uniffi_rgblibuniffi_checksum_method_wallet_refresh() != 61710) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_send() != 54460) { + if (uniffi_rgblibuniffi_checksum_method_wallet_send() != 10938) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_send_begin() != 21520) { + if (uniffi_rgblibuniffi_checksum_method_wallet_send_begin() != 896) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_send_btc() != 47940) { + if (uniffi_rgblibuniffi_checksum_method_wallet_send_btc() != 45183) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_send_btc_begin() != 31034) { + if (uniffi_rgblibuniffi_checksum_method_wallet_send_btc_begin() != 49369) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_send_btc_end() != 58866) { + if (uniffi_rgblibuniffi_checksum_method_wallet_send_btc_end() != 1792) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_send_end() != 34331) { + if (uniffi_rgblibuniffi_checksum_method_wallet_send_end() != 37107) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_sign_psbt() != 29982) { + if (uniffi_rgblibuniffi_checksum_method_wallet_sign_psbt() != 10485) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_method_wallet_witness_receive() != 47965) { + if (uniffi_rgblibuniffi_checksum_method_wallet_witness_receive() != 62755) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_constructor_invoice_from_invoice_data() != 43541) { + if (uniffi_rgblibuniffi_checksum_constructor_invoice_from_invoice_data() != 55197) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_constructor_invoice_new() != 56538) { + if (uniffi_rgblibuniffi_checksum_constructor_invoice_new() != 37528) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_constructor_recipientinfo_new() != 42681) { + if (uniffi_rgblibuniffi_checksum_constructor_recipientinfo_new() != 13462) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_constructor_transportendpoint_new() != 1325) { + if (uniffi_rgblibuniffi_checksum_constructor_transportendpoint_new() != 59385) { return InitializationResult.apiChecksumMismatch } - if (uniffi_rgblibffi_checksum_constructor_wallet_new() != 55128) { + if (uniffi_rgblibuniffi_checksum_constructor_wallet_new() != 49006) { return InitializationResult.apiChecksumMismatch } return InitializationResult.ok -} +}() private func uniffiEnsureInitialized() { switch initializationResult { diff --git a/generate.sh b/generate.sh index 9e6e603..3a9e7e9 100755 --- a/generate.sh +++ b/generate.sh @@ -2,7 +2,7 @@ set -euo pipefail -RGBLIBFFI_PATH="./rgb-lib/rgb-lib-ffi" +RGBLIBFFI_PATH="./rgb-lib/bindings/uniffi" MANIFEST_PATH=(--manifest-path "$RGBLIBFFI_PATH/Cargo.toml") XCFRAMEWORK_PATH="rgb_libFFI.xcframework" @@ -17,14 +17,14 @@ rustup target add aarch64-apple-darwin x86_64-apple-darwin echo "Generating Swift bindings..." cargo run "${MANIFEST_PATH[@]}" \ - --bin rgb-lib-ffi-bindgen generate $RGBLIBFFI_PATH/src/rgb-lib.udl \ + --bin rgb-lib-uniffi-bindgen generate $RGBLIBFFI_PATH/src/rgb-lib.udl \ --language swift --out-dir ./Sources/RgbLib mv Sources/RgbLib/rgb_lib.swift Sources/RgbLib/RgbLib.swift -echo "Building rgb-lib-ffi libs for Apple targets..." +echo "Building rgb-lib uniffi libs for Apple targets..." TARGET_TRIPLES=("x86_64-apple-darwin" "aarch64-apple-darwin" "x86_64-apple-ios" "aarch64-apple-ios") for target in "${TARGET_TRIPLES[@]}"; do - echo "Build rgb-lib-ffi lib for target $target" + echo "Build rgb-lib uniffi lib for target $target" cargo build "${MANIFEST_PATH[@]}" --target "$target" done # special build for M1 ios simulator @@ -33,15 +33,15 @@ cargo +nightly build -Z build-std \ echo "Create lipo static libs for ios-sim to support M1" mkdir -p $RGBLIBFFI_PATH/target/lipo-ios-sim/debug -lipo $RGBLIBFFI_PATH/target/aarch64-apple-ios-sim/debug/librgblibffi.a \ - $RGBLIBFFI_PATH/target/x86_64-apple-ios/debug/librgblibffi.a -create \ - -output $RGBLIBFFI_PATH/target/lipo-ios-sim/debug/librgblibffi.a +lipo $RGBLIBFFI_PATH/target/aarch64-apple-ios-sim/debug/librgblibuniffi.a \ + $RGBLIBFFI_PATH/target/x86_64-apple-ios/debug/librgblibuniffi.a -create \ + -output $RGBLIBFFI_PATH/target/lipo-ios-sim/debug/librgblibuniffi.a echo "Create lipo static libs for macos to support M1" mkdir -p $RGBLIBFFI_PATH/target/lipo-macos/debug -lipo $RGBLIBFFI_PATH/target/aarch64-apple-darwin/debug/librgblibffi.a \ - $RGBLIBFFI_PATH/target/x86_64-apple-darwin/debug/librgblibffi.a -create \ - -output $RGBLIBFFI_PATH/target/lipo-macos/debug/librgblibffi.a +lipo $RGBLIBFFI_PATH/target/aarch64-apple-darwin/debug/librgblibuniffi.a \ + $RGBLIBFFI_PATH/target/x86_64-apple-darwin/debug/librgblibuniffi.a -create \ + -output $RGBLIBFFI_PATH/target/lipo-macos/debug/librgblibuniffi.a XCFRAMEWORK_LIBS=("ios-arm64" "ios-arm64_x86_64-simulator" "macos-arm64_x86_64") for lib in "${XCFRAMEWORK_LIBS[@]}"; do @@ -69,10 +69,10 @@ EOF done -echo "Copy librgblibffi.a files to $XCFRAMEWORK_PATH/rgb_libFFI" -cp $RGBLIBFFI_PATH/target/aarch64-apple-ios/debug/librgblibffi.a $XCFRAMEWORK_PATH/ios-arm64/rgb_libFFI.framework/rgb_libFFI -cp $RGBLIBFFI_PATH/target/lipo-ios-sim/debug/librgblibffi.a $XCFRAMEWORK_PATH/ios-arm64_x86_64-simulator/rgb_libFFI.framework/rgb_libFFI -cp $RGBLIBFFI_PATH/target/lipo-macos/debug/librgblibffi.a $XCFRAMEWORK_PATH/macos-arm64_x86_64/rgb_libFFI.framework/rgb_libFFI +echo "Copy librgblibuniffi.a files to $XCFRAMEWORK_PATH/rgb_libFFI" +cp $RGBLIBFFI_PATH/target/aarch64-apple-ios/debug/librgblibuniffi.a $XCFRAMEWORK_PATH/ios-arm64/rgb_libFFI.framework/rgb_libFFI +cp $RGBLIBFFI_PATH/target/lipo-ios-sim/debug/librgblibuniffi.a $XCFRAMEWORK_PATH/ios-arm64_x86_64-simulator/rgb_libFFI.framework/rgb_libFFI +cp $RGBLIBFFI_PATH/target/lipo-macos/debug/librgblibuniffi.a $XCFRAMEWORK_PATH/macos-arm64_x86_64/rgb_libFFI.framework/rgb_libFFI # remove unneed .h and .modulemap files rm Sources/RgbLib/rgb_libFFI.h diff --git a/rgb-lib b/rgb-lib index bfb159b..ae66c7b 160000 --- a/rgb-lib +++ b/rgb-lib @@ -1 +1 @@ -Subproject commit bfb159b842a1ca45987578904cdf75206d7686ad +Subproject commit ae66c7b7c0859dcafbf77db1d3dad26c5379bba3