@runflame/wallet-rn 0.0.0-stage → 0.0.1-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. package/FlameWalletNative.podspec +15 -0
  2. package/LICENSE.txt +201 -0
  3. package/android/build.gradle +30 -0
  4. package/android/src/main/java/com/flame/wallet/flamewallet_ffi.kt +3041 -0
  5. package/android/src/main/jniLibs/arm64-v8a/libflamewallet_ffi.so +0 -0
  6. package/android/src/main/jniLibs/armeabi-v7a/libflamewallet_ffi.so +0 -0
  7. package/android/src/main/jniLibs/x86_64/libflamewallet_ffi.so +0 -0
  8. package/expo-module.config.json +3 -0
  9. package/ios/FlameWallet.swift +2453 -0
  10. package/ios/FlameWalletFFI.xcframework/Info.plist +44 -0
  11. package/ios/FlameWalletFFI.xcframework/ios-arm64/FlameWalletFFI.framework/FlameWalletFFI +0 -0
  12. package/ios/FlameWalletFFI.xcframework/ios-arm64/FlameWalletFFI.framework/Headers/FlameWalletFFI.h +698 -0
  13. package/ios/FlameWalletFFI.xcframework/ios-arm64/FlameWalletFFI.framework/Info.plist +16 -0
  14. package/ios/FlameWalletFFI.xcframework/ios-arm64/FlameWalletFFI.framework/Modules/module.modulemap +4 -0
  15. package/ios/FlameWalletFFI.xcframework/ios-arm64_x86_64-simulator/FlameWalletFFI.framework/FlameWalletFFI +0 -0
  16. package/ios/FlameWalletFFI.xcframework/ios-arm64_x86_64-simulator/FlameWalletFFI.framework/Headers/FlameWalletFFI.h +698 -0
  17. package/ios/FlameWalletFFI.xcframework/ios-arm64_x86_64-simulator/FlameWalletFFI.framework/Info.plist +16 -0
  18. package/ios/FlameWalletFFI.xcframework/ios-arm64_x86_64-simulator/FlameWalletFFI.framework/Modules/module.modulemap +4 -0
  19. package/package.json +17 -4
  20. package/sbom.cdx.json +5880 -0
  21. package/README.md +0 -3
@@ -0,0 +1,2453 @@
1
+ // This file was autogenerated by some hot garbage in the `uniffi` crate.
2
+ // Trust me, you don't want to mess with it!
3
+
4
+ // swiftlint:disable all
5
+ import Foundation
6
+
7
+ // Depending on the consumer's build setup, the low-level FFI code
8
+ // might be in a separate module, or it might be compiled inline into
9
+ // this module. This is a bit of light hackery to work with both.
10
+ #if canImport(FlameWalletFFI)
11
+ import FlameWalletFFI
12
+ #endif
13
+
14
+ fileprivate extension RustBuffer {
15
+ // Allocate a new buffer, copying the contents of a `UInt8` array.
16
+ init(bytes: [UInt8]) {
17
+ let rbuf = bytes.withUnsafeBufferPointer { ptr in
18
+ RustBuffer.from(ptr)
19
+ }
20
+ self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data)
21
+ }
22
+
23
+ static func empty() -> RustBuffer {
24
+ RustBuffer(capacity: 0, len:0, data: nil)
25
+ }
26
+
27
+ static func from(_ ptr: UnsafeBufferPointer<UInt8>) -> RustBuffer {
28
+ try! rustCall { ffi_flamewallet_ffi_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) }
29
+ }
30
+
31
+ // Frees the buffer in place.
32
+ // The buffer must not be used after this is called.
33
+ func deallocate() {
34
+ try! rustCall { ffi_flamewallet_ffi_rustbuffer_free(self, $0) }
35
+ }
36
+ }
37
+
38
+ fileprivate extension ForeignBytes {
39
+ init(bufferPointer: UnsafeBufferPointer<UInt8>) {
40
+ self.init(len: Int32(bufferPointer.count), data: bufferPointer.baseAddress)
41
+ }
42
+
43
+ init(rawBufferPointer: UnsafeRawBufferPointer) {
44
+ self.init(
45
+ len: Int32(rawBufferPointer.count),
46
+ data: rawBufferPointer.baseAddress?.assumingMemoryBound(to: UInt8.self)
47
+ )
48
+ }
49
+ }
50
+
51
+ // Converter for `&[u8]` / `[ByRef] bytes` arguments.
52
+ //
53
+ // Conforms to `FfiConverter` so the compiler enforces the full converter
54
+ // method set. Only the scope-bound `lower(_:_body:)` overload is sound —
55
+ // zero-copy byte buffers only flow foreign -> Rust, and only in argument
56
+ // position. The four protocol-witness methods (`lift`, `lower`, `read`,
57
+ // `write`) `fatalError` at runtime if anyone reaches them.
58
+ //
59
+ // The scope-bound `lower` takes a closure because the `ForeignBytes`
60
+ // pointer is only guaranteed valid for the duration of
61
+ // `Data.withUnsafeBytes`. Callers must run the full FFI call inside
62
+ // the closure body.
63
+ fileprivate enum FfiConverterByRefBytes: FfiConverter {
64
+ typealias SwiftType = Data
65
+ typealias FfiType = ForeignBytes
66
+
67
+ static func lower<R>(_ value: Data, _ body: (ForeignBytes) throws -> R) rethrows -> R {
68
+ return try value.withUnsafeBytes { rawBuf in
69
+ try body(ForeignBytes(rawBufferPointer: rawBuf))
70
+ }
71
+ }
72
+
73
+ static func lower(_ value: Data) -> ForeignBytes {
74
+ fatalError("ByRef bytes cannot use the plain lower: returning ForeignBytes escapes the Data.withUnsafeBytes scope. Use the scope-bound lower(_:_body:) overload instead.")
75
+ }
76
+
77
+ static func lift(_ value: ForeignBytes) throws -> Data {
78
+ fatalError("ByRef bytes cannot be lifted: zero-copy &[u8] only flows foreign->Rust")
79
+ }
80
+
81
+ static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Data {
82
+ fatalError("ByRef bytes cannot be read from a buffer: zero-copy &[u8] is only supported in argument position, not nested in records/options/etc.")
83
+ }
84
+
85
+ static func write(_ value: Data, into buf: inout [UInt8]) {
86
+ fatalError("ByRef bytes cannot be written to a buffer: zero-copy &[u8] is only supported in argument position, not nested in records/options/etc.")
87
+ }
88
+ }
89
+
90
+ // For every type used in the interface, we provide helper methods for conveniently
91
+ // lifting and lowering that type from C-compatible data, and for reading and writing
92
+ // values of that type in a buffer.
93
+
94
+ // Helper classes/extensions that don't change.
95
+ // Someday, this will be in a library of its own.
96
+
97
+ fileprivate extension Data {
98
+ init(rustBuffer: RustBuffer) {
99
+ self.init(
100
+ bytesNoCopy: rustBuffer.data!,
101
+ count: Int(rustBuffer.len),
102
+ deallocator: .none
103
+ )
104
+ }
105
+ }
106
+
107
+ // Define reader functionality. Normally this would be defined in a class or
108
+ // struct, but we use standalone functions instead in order to make external
109
+ // types work.
110
+ //
111
+ // With external types, one swift source file needs to be able to call the read
112
+ // method on another source file's FfiConverter, but then what visibility
113
+ // should Reader have?
114
+ // - If Reader is fileprivate, then this means the read() must also
115
+ // be fileprivate, which doesn't work with external types.
116
+ // - If Reader is internal/public, we'll get compile errors since both source
117
+ // files will try define the same type.
118
+ //
119
+ // Instead, the read() method and these helper functions input a tuple of data
120
+
121
+ fileprivate func createReader(data: Data) -> (data: Data, offset: Data.Index) {
122
+ (data: data, offset: 0)
123
+ }
124
+
125
+ // Reads an integer at the current offset, in big-endian order, and advances
126
+ // the offset on success. Throws if reading the integer would move the
127
+ // offset past the end of the buffer.
128
+ fileprivate func readInt<T: FixedWidthInteger>(_ reader: inout (data: Data, offset: Data.Index)) throws -> T {
129
+ let range = reader.offset..<reader.offset + MemoryLayout<T>.size
130
+ guard reader.data.count >= range.upperBound else {
131
+ throw UniffiInternalError.bufferOverflow
132
+ }
133
+ if T.self == UInt8.self {
134
+ let value = reader.data[reader.offset]
135
+ reader.offset += 1
136
+ return value as! T
137
+ }
138
+ var value: T = 0
139
+ let _ = withUnsafeMutableBytes(of: &value, { reader.data.copyBytes(to: $0, from: range)})
140
+ reader.offset = range.upperBound
141
+ return value.bigEndian
142
+ }
143
+
144
+ // Reads an arbitrary number of bytes, to be used to read
145
+ // raw bytes, this is useful when lifting strings
146
+ fileprivate func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> Array<UInt8> {
147
+ let range = reader.offset..<(reader.offset+count)
148
+ guard reader.data.count >= range.upperBound else {
149
+ throw UniffiInternalError.bufferOverflow
150
+ }
151
+ var value = [UInt8](repeating: 0, count: count)
152
+ value.withUnsafeMutableBufferPointer({ buffer in
153
+ reader.data.copyBytes(to: buffer, from: range)
154
+ })
155
+ reader.offset = range.upperBound
156
+ return value
157
+ }
158
+
159
+ // Reads a float at the current offset.
160
+ fileprivate func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float {
161
+ return Float(bitPattern: try readInt(&reader))
162
+ }
163
+
164
+ // Reads a float at the current offset.
165
+ fileprivate func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double {
166
+ return Double(bitPattern: try readInt(&reader))
167
+ }
168
+
169
+ // Indicates if the offset has reached the end of the buffer.
170
+ fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool {
171
+ return reader.offset < reader.data.count
172
+ }
173
+
174
+ // Define writer functionality. Normally this would be defined in a class or
175
+ // struct, but we use standalone functions instead in order to make external
176
+ // types work. See the above discussion on Readers for details.
177
+
178
+ fileprivate func createWriter() -> [UInt8] {
179
+ return []
180
+ }
181
+
182
+ fileprivate func writeBytes<S>(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 {
183
+ writer.append(contentsOf: byteArr)
184
+ }
185
+
186
+ // Writes an integer in big-endian order.
187
+ //
188
+ // Warning: make sure what you are trying to write
189
+ // is in the correct type!
190
+ fileprivate func writeInt<T: FixedWidthInteger>(_ writer: inout [UInt8], _ value: T) {
191
+ var value = value.bigEndian
192
+ withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) }
193
+ }
194
+
195
+ fileprivate func writeFloat(_ writer: inout [UInt8], _ value: Float) {
196
+ writeInt(&writer, value.bitPattern)
197
+ }
198
+
199
+ fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) {
200
+ writeInt(&writer, value.bitPattern)
201
+ }
202
+
203
+ // Protocol for types that transfer other types across the FFI. This is
204
+ // analogous to the Rust trait of the same name.
205
+ fileprivate protocol FfiConverter {
206
+ associatedtype FfiType
207
+ associatedtype SwiftType
208
+
209
+ static func lift(_ value: FfiType) throws -> SwiftType
210
+ static func lower(_ value: SwiftType) -> FfiType
211
+ static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType
212
+ static func write(_ value: SwiftType, into buf: inout [UInt8])
213
+ }
214
+
215
+ // Types conforming to `Primitive` pass themselves directly over the FFI.
216
+ fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { }
217
+
218
+ extension FfiConverterPrimitive {
219
+ #if swift(>=5.8)
220
+ @_documentation(visibility: private)
221
+ #endif
222
+ public static func lift(_ value: FfiType) throws -> SwiftType {
223
+ return value
224
+ }
225
+
226
+ #if swift(>=5.8)
227
+ @_documentation(visibility: private)
228
+ #endif
229
+ public static func lower(_ value: SwiftType) -> FfiType {
230
+ return value
231
+ }
232
+ }
233
+
234
+ // Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`.
235
+ // Used for complex types where it's hard to write a custom lift/lower.
236
+ fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {}
237
+
238
+ extension FfiConverterRustBuffer {
239
+ #if swift(>=5.8)
240
+ @_documentation(visibility: private)
241
+ #endif
242
+ public static func lift(_ buf: RustBuffer) throws -> SwiftType {
243
+ var reader = createReader(data: Data(rustBuffer: buf))
244
+ let value = try read(from: &reader)
245
+ if hasRemaining(reader) {
246
+ throw UniffiInternalError.incompleteData
247
+ }
248
+ buf.deallocate()
249
+ return value
250
+ }
251
+
252
+ #if swift(>=5.8)
253
+ @_documentation(visibility: private)
254
+ #endif
255
+ public static func lower(_ value: SwiftType) -> RustBuffer {
256
+ var writer = createWriter()
257
+ write(value, into: &writer)
258
+ return RustBuffer(bytes: writer)
259
+ }
260
+ }
261
+ // An error type for FFI errors. These errors occur at the UniFFI level, not
262
+ // the library level.
263
+ fileprivate enum UniffiInternalError: LocalizedError {
264
+ case bufferOverflow
265
+ case incompleteData
266
+ case unexpectedOptionalTag
267
+ case unexpectedEnumCase
268
+ case unexpectedNullPointer
269
+ case unexpectedRustCallStatusCode
270
+ case unexpectedRustCallError
271
+ case unexpectedStaleHandle
272
+ case rustPanic(_ message: String)
273
+
274
+ public var errorDescription: String? {
275
+ switch self {
276
+ case .bufferOverflow: return "Reading the requested value would read past the end of the buffer"
277
+ case .incompleteData: return "The buffer still has data after lifting its containing value"
278
+ case .unexpectedOptionalTag: return "Unexpected optional tag; should be 0 or 1"
279
+ case .unexpectedEnumCase: return "Raw enum value doesn't match any cases"
280
+ case .unexpectedNullPointer: return "Raw pointer value was null"
281
+ case .unexpectedRustCallStatusCode: return "Unexpected RustCallStatus code"
282
+ case .unexpectedRustCallError: return "CALL_ERROR but no errorClass specified"
283
+ case .unexpectedStaleHandle: return "The object in the handle map has been dropped already"
284
+ case let .rustPanic(message): return message
285
+ }
286
+ }
287
+ }
288
+
289
+ fileprivate extension NSLock {
290
+ func withLock<T>(f: () throws -> T) rethrows -> T {
291
+ self.lock()
292
+ defer { self.unlock() }
293
+ return try f()
294
+ }
295
+ }
296
+
297
+ fileprivate let CALL_SUCCESS: Int8 = 0
298
+ fileprivate let CALL_ERROR: Int8 = 1
299
+ fileprivate let CALL_UNEXPECTED_ERROR: Int8 = 2
300
+ fileprivate let CALL_CANCELLED: Int8 = 3
301
+
302
+ fileprivate extension RustCallStatus {
303
+ init() {
304
+ self.init(
305
+ code: CALL_SUCCESS,
306
+ errorBuf: RustBuffer.init(
307
+ capacity: 0,
308
+ len: 0,
309
+ data: nil
310
+ )
311
+ )
312
+ }
313
+ }
314
+
315
+ private func rustCall<T>(_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T {
316
+ let neverThrow: ((RustBuffer) throws -> Never)? = nil
317
+ return try makeRustCall(callback, errorHandler: neverThrow)
318
+ }
319
+
320
+ private func rustCallWithError<T, E: Swift.Error>(
321
+ _ errorHandler: @escaping (RustBuffer) throws -> E,
322
+ _ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T {
323
+ try makeRustCall(callback, errorHandler: errorHandler)
324
+ }
325
+
326
+ private func makeRustCall<T, E: Swift.Error>(
327
+ _ callback: (UnsafeMutablePointer<RustCallStatus>) -> T,
328
+ errorHandler: ((RustBuffer) throws -> E)?
329
+ ) throws -> T {
330
+ uniffiEnsureFlamewalletFfiInitialized()
331
+ var callStatus = RustCallStatus.init()
332
+ let returnedVal = callback(&callStatus)
333
+ try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler)
334
+ return returnedVal
335
+ }
336
+
337
+ private func uniffiCheckCallStatus<E: Swift.Error>(
338
+ callStatus: RustCallStatus,
339
+ errorHandler: ((RustBuffer) throws -> E)?
340
+ ) throws {
341
+ switch callStatus.code {
342
+ case CALL_SUCCESS:
343
+ return
344
+
345
+ case CALL_ERROR:
346
+ if let errorHandler = errorHandler {
347
+ throw try errorHandler(callStatus.errorBuf)
348
+ } else {
349
+ callStatus.errorBuf.deallocate()
350
+ throw UniffiInternalError.unexpectedRustCallError
351
+ }
352
+
353
+ case CALL_UNEXPECTED_ERROR:
354
+ // When the rust code sees a panic, it tries to construct a RustBuffer
355
+ // with the message. But if that code panics, then it just sends back
356
+ // an empty buffer.
357
+ if callStatus.errorBuf.len > 0 {
358
+ throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf))
359
+ } else {
360
+ callStatus.errorBuf.deallocate()
361
+ throw UniffiInternalError.rustPanic("Rust panic")
362
+ }
363
+
364
+ case CALL_CANCELLED:
365
+ fatalError("Cancellation not supported yet")
366
+
367
+ default:
368
+ throw UniffiInternalError.unexpectedRustCallStatusCode
369
+ }
370
+ }
371
+
372
+ private func uniffiTraitInterfaceCall<T>(
373
+ callStatus: UnsafeMutablePointer<RustCallStatus>,
374
+ makeCall: () throws -> T,
375
+ writeReturn: (T) -> ()
376
+ ) {
377
+ do {
378
+ try writeReturn(makeCall())
379
+ } catch let error {
380
+ callStatus.pointee.code = CALL_UNEXPECTED_ERROR
381
+ callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error))
382
+ }
383
+ }
384
+
385
+ private func uniffiTraitInterfaceCallWithError<T, E>(
386
+ callStatus: UnsafeMutablePointer<RustCallStatus>,
387
+ makeCall: () throws -> T,
388
+ writeReturn: (T) -> (),
389
+ lowerError: (E) -> RustBuffer
390
+ ) {
391
+ do {
392
+ try writeReturn(makeCall())
393
+ } catch let error as E {
394
+ callStatus.pointee.code = CALL_ERROR
395
+ callStatus.pointee.errorBuf = lowerError(error)
396
+ } catch {
397
+ callStatus.pointee.code = CALL_UNEXPECTED_ERROR
398
+ callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error))
399
+ }
400
+ }
401
+ // Initial value and increment amount for handles.
402
+ // These ensure that SWIFT handles always have the lowest bit set
403
+ fileprivate let UNIFFI_HANDLEMAP_INITIAL: UInt64 = 1
404
+ fileprivate let UNIFFI_HANDLEMAP_DELTA: UInt64 = 2
405
+
406
+ fileprivate final class UniffiHandleMap<T>: @unchecked Sendable {
407
+ // All mutation happens with this lock held, which is why we implement @unchecked Sendable.
408
+ private let lock = NSLock()
409
+ private var map: [UInt64: T] = [:]
410
+ private var currentHandle: UInt64 = UNIFFI_HANDLEMAP_INITIAL
411
+
412
+ func insert(obj: T) -> UInt64 {
413
+ lock.withLock {
414
+ return doInsert(obj)
415
+ }
416
+ }
417
+
418
+ // Low-level insert function, this assumes `lock` is held.
419
+ private func doInsert(_ obj: T) -> UInt64 {
420
+ let handle = currentHandle
421
+ currentHandle += UNIFFI_HANDLEMAP_DELTA
422
+ map[handle] = obj
423
+ return handle
424
+ }
425
+
426
+ func get(handle: UInt64) throws -> T {
427
+ try lock.withLock {
428
+ guard let obj = map[handle] else {
429
+ throw UniffiInternalError.unexpectedStaleHandle
430
+ }
431
+ return obj
432
+ }
433
+ }
434
+
435
+ func clone(handle: UInt64) throws -> UInt64 {
436
+ try lock.withLock {
437
+ guard let obj = map[handle] else {
438
+ throw UniffiInternalError.unexpectedStaleHandle
439
+ }
440
+ return doInsert(obj)
441
+ }
442
+ }
443
+
444
+ @discardableResult
445
+ func remove(handle: UInt64) throws -> T {
446
+ try lock.withLock {
447
+ guard let obj = map.removeValue(forKey: handle) else {
448
+ throw UniffiInternalError.unexpectedStaleHandle
449
+ }
450
+ return obj
451
+ }
452
+ }
453
+
454
+ var count: Int {
455
+ get {
456
+ map.count
457
+ }
458
+ }
459
+ }
460
+
461
+
462
+ // Public interface members begin here.
463
+
464
+
465
+ #if swift(>=5.8)
466
+ @_documentation(visibility: private)
467
+ #endif
468
+ fileprivate struct FfiConverterUInt8: FfiConverterPrimitive {
469
+ typealias FfiType = UInt8
470
+ typealias SwiftType = UInt8
471
+
472
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt8 {
473
+ return try lift(readInt(&buf))
474
+ }
475
+
476
+ public static func write(_ value: UInt8, into buf: inout [UInt8]) {
477
+ writeInt(&buf, lower(value))
478
+ }
479
+ }
480
+
481
+ #if swift(>=5.8)
482
+ @_documentation(visibility: private)
483
+ #endif
484
+ fileprivate struct FfiConverterUInt32: FfiConverterPrimitive {
485
+ typealias FfiType = UInt32
486
+ typealias SwiftType = UInt32
487
+
488
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt32 {
489
+ return try lift(readInt(&buf))
490
+ }
491
+
492
+ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
493
+ writeInt(&buf, lower(value))
494
+ }
495
+ }
496
+
497
+ #if swift(>=5.8)
498
+ @_documentation(visibility: private)
499
+ #endif
500
+ fileprivate struct FfiConverterUInt64: FfiConverterPrimitive {
501
+ typealias FfiType = UInt64
502
+ typealias SwiftType = UInt64
503
+
504
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt64 {
505
+ return try lift(readInt(&buf))
506
+ }
507
+
508
+ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
509
+ writeInt(&buf, lower(value))
510
+ }
511
+ }
512
+
513
+ #if swift(>=5.8)
514
+ @_documentation(visibility: private)
515
+ #endif
516
+ fileprivate struct FfiConverterBool : FfiConverter {
517
+ typealias FfiType = Int8
518
+ typealias SwiftType = Bool
519
+
520
+ public static func lift(_ value: Int8) throws -> Bool {
521
+ return value != 0
522
+ }
523
+
524
+ public static func lower(_ value: Bool) -> Int8 {
525
+ return value ? 1 : 0
526
+ }
527
+
528
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Bool {
529
+ return try lift(readInt(&buf))
530
+ }
531
+
532
+ public static func write(_ value: Bool, into buf: inout [UInt8]) {
533
+ writeInt(&buf, lower(value))
534
+ }
535
+ }
536
+
537
+ #if swift(>=5.8)
538
+ @_documentation(visibility: private)
539
+ #endif
540
+ fileprivate struct FfiConverterString: FfiConverter {
541
+ typealias SwiftType = String
542
+ typealias FfiType = RustBuffer
543
+
544
+ public static func lift(_ value: RustBuffer) throws -> String {
545
+ defer {
546
+ value.deallocate()
547
+ }
548
+ if value.data == nil {
549
+ return String()
550
+ }
551
+ let bytes = UnsafeBufferPointer<UInt8>(start: value.data!, count: Int(value.len))
552
+ // Use Swift's native UTF-8 decoder; `String(bytes:encoding:.utf8)` goes
553
+ // through Foundation's NSString and silently strips a leading U+FEFF BOM.
554
+ // Invalid UTF-8 substitutes U+FFFD instead of trapping (unreachable
555
+ // given Rust's `String` invariant).
556
+ return String(decoding: bytes, as: UTF8.self)
557
+ }
558
+
559
+ public static func lower(_ value: String) -> RustBuffer {
560
+ return value.utf8CString.withUnsafeBufferPointer { ptr in
561
+ // The swift string gives us int8_t, we want uint8_t.
562
+ ptr.withMemoryRebound(to: UInt8.self) { ptr in
563
+ // The swift string gives us a trailing null byte, we don't want it.
564
+ let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1))
565
+ return RustBuffer.from(buf)
566
+ }
567
+ }
568
+ }
569
+
570
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String {
571
+ let len: Int32 = try readInt(&buf)
572
+ // See `lift` above for why we avoid Foundation's NSString-backed decoder here.
573
+ return String(decoding: try readBytes(&buf, count: Int(len)), as: UTF8.self)
574
+ }
575
+
576
+ public static func write(_ value: String, into buf: inout [UInt8]) {
577
+ let len = Int32(value.utf8.count)
578
+ writeInt(&buf, len)
579
+ writeBytes(&buf, value.utf8)
580
+ }
581
+ }
582
+
583
+ #if swift(>=5.8)
584
+ @_documentation(visibility: private)
585
+ #endif
586
+ fileprivate struct FfiConverterData: FfiConverterRustBuffer {
587
+ typealias SwiftType = Data
588
+
589
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Data {
590
+ let len: Int32 = try readInt(&buf)
591
+ return Data(try readBytes(&buf, count: Int(len)))
592
+ }
593
+
594
+ public static func write(_ value: Data, into buf: inout [UInt8]) {
595
+ let len = Int32(value.count)
596
+ writeInt(&buf, len)
597
+ writeBytes(&buf, value)
598
+ }
599
+ }
600
+
601
+
602
+
603
+
604
+ /**
605
+ * One account, `m/35263'/network'/0'`, behind an opaque handle.
606
+ *
607
+ * The handle is the only thing that ever holds key material: every
608
+ * spending key is derived inside a call and dropped before it returns. It
609
+ * is safe to share across threads. Calls that read or advance the counter
610
+ * are serialized; [`Wallet::build_transfer`] works on a copy and holds no
611
+ * lock while it proves.
612
+ */
613
+ public protocol WalletProtocol: AnyObject, Sendable {
614
+
615
+ /**
616
+ * The address and predicate at `path`, without issuing anything.
617
+ */
618
+ func address(path: KeyPath) throws -> IssuedAddress
619
+
620
+ /**
621
+ * Builds, proves and signs a transfer. The keys come from the paths
622
+ * the inputs name and never leave this call.
623
+ *
624
+ * Proving takes seconds on a phone, so it runs on a copy of the
625
+ * account with the lock released: other calls on this handle, from a
626
+ * UI thread say, do not wait for it. The build never touches the
627
+ * counter, so nothing the copy does needs writing back.
628
+ */
629
+ func buildTransfer(request: TransferRequest) throws -> Transfer
630
+
631
+ /**
632
+ * The network this wallet's addresses are encoded for.
633
+ */
634
+ func network() -> Network
635
+
636
+ /**
637
+ * Issues the next receiving address and advances the counter.
638
+ */
639
+ func nextAddress() throws -> IssuedAddress
640
+
641
+ /**
642
+ * The next receiving index not yet issued.
643
+ */
644
+ func nextIndex() -> UInt32
645
+
646
+ /**
647
+ * Opens the note that followed `contract` in its log, as a scan serves
648
+ * the pair; `note` is `None` when the scan served none. `path` is what
649
+ * [`Wallet::owns`] found for the contract's predicate. The opening it
650
+ * gives is what a later [`crate::TransferInput`] spends the output with.
651
+ */
652
+ func openNote(contract: Data, note: Data?, path: KeyPath) throws -> ReceivedNote
653
+
654
+ /**
655
+ * Which path below `next_index + gap`, on either branch, owns
656
+ * `predicate`; `None` if none does. The scan re-derives every address
657
+ * it covers, so `gap` is the caller's cost budget.
658
+ */
659
+ func owns(predicate: Data, gap: UInt32) throws -> KeyPath?
660
+
661
+ /**
662
+ * The account's receiving key in bech32f (`recv1…` / `testrecv1…`):
663
+ * what an indexer is given to find this wallet's payments. It derives
664
+ * every address and links their activity, and can neither spend nor
665
+ * read a payment's amount.
666
+ */
667
+ func receivingKey() -> String
668
+
669
+ }
670
+ /**
671
+ * One account, `m/35263'/network'/0'`, behind an opaque handle.
672
+ *
673
+ * The handle is the only thing that ever holds key material: every
674
+ * spending key is derived inside a call and dropped before it returns. It
675
+ * is safe to share across threads. Calls that read or advance the counter
676
+ * are serialized; [`Wallet::build_transfer`] works on a copy and holds no
677
+ * lock while it proves.
678
+ */
679
+ open class Wallet: WalletProtocol, @unchecked Sendable {
680
+ fileprivate let handle: UInt64
681
+
682
+ /// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly.
683
+ #if swift(>=5.8)
684
+ @_documentation(visibility: private)
685
+ #endif
686
+ public struct NoHandle {
687
+ public init() {}
688
+ }
689
+
690
+ // TODO: We'd like this to be `private` but for Swifty reasons,
691
+ // we can't implement `FfiConverter` without making this `required` and we can't
692
+ // make it `required` without making it `public`.
693
+ #if swift(>=5.8)
694
+ @_documentation(visibility: private)
695
+ #endif
696
+ required public init(unsafeFromHandle handle: UInt64) {
697
+ self.handle = handle
698
+ }
699
+
700
+ // This constructor can be used to instantiate a fake object.
701
+ // - Parameter noHandle: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject].
702
+ //
703
+ // - Warning:
704
+ // Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing handle the FFI lower functions will crash.
705
+ #if swift(>=5.8)
706
+ @_documentation(visibility: private)
707
+ #endif
708
+ public init(noHandle: NoHandle) {
709
+ self.handle = 0
710
+ }
711
+
712
+ #if swift(>=5.8)
713
+ @_documentation(visibility: private)
714
+ #endif
715
+ public func uniffiCloneHandle() -> UInt64 {
716
+ return try! rustCall { uniffi_flamewallet_ffi_fn_clone_wallet(self.handle, $0) }
717
+ }
718
+ /**
719
+ * The account below a 64-byte seed, as [`mnemonic_to_seed`] gives it,
720
+ * with `next_index` receiving addresses already issued. The seed holds
721
+ * keys, not history: an app stores [`Wallet::next_index`] after each
722
+ * [`Wallet::next_address`] and passes it back here; a new wallet
723
+ * passes 0.
724
+ */
725
+ public convenience init(seed: Data, network: Network, nextIndex: UInt32)throws {
726
+ let handle =
727
+ try rustCallWithError(FfiConverterTypeFlameError_lift) {
728
+ uniffiCallStatus in
729
+ uniffi_flamewallet_ffi_fn_constructor_wallet_new(
730
+ FfiConverterData.lower(seed),
731
+ FfiConverterTypeNetwork_lower(network),
732
+ FfiConverterUInt32.lower(nextIndex),uniffiCallStatus
733
+ )
734
+ }
735
+ self.init(unsafeFromHandle: handle)
736
+ }
737
+
738
+ deinit {
739
+ if handle == 0 {
740
+ // Mock objects have handle=0 don't try to free them
741
+ return
742
+ }
743
+
744
+ try! rustCall { uniffi_flamewallet_ffi_fn_free_wallet(handle, $0) }
745
+ }
746
+
747
+
748
+ /**
749
+ * The account below `phrase` and `passphrase`, without the caller ever
750
+ * seeing the seed; `next_index` as in [`Wallet::new`].
751
+ */
752
+ public static func fromMnemonic(phrase: String, passphrase: String, network: Network, nextIndex: UInt32)throws -> Wallet {
753
+ return try FfiConverterTypeWallet_lift(try rustCallWithError(FfiConverterTypeFlameError_lift) {
754
+ uniffiCallStatus in
755
+ uniffi_flamewallet_ffi_fn_constructor_wallet_from_mnemonic(
756
+ FfiConverterString.lower(phrase),
757
+ FfiConverterString.lower(passphrase),
758
+ FfiConverterTypeNetwork_lower(network),
759
+ FfiConverterUInt32.lower(nextIndex),uniffiCallStatus
760
+ )
761
+ })
762
+ }
763
+
764
+
765
+
766
+ /**
767
+ * The address and predicate at `path`, without issuing anything.
768
+ */
769
+ open func address(path: KeyPath)throws -> IssuedAddress {
770
+ return try FfiConverterTypeIssuedAddress_lift(try rustCallWithError(FfiConverterTypeFlameError_lift) {
771
+ uniffiCallStatus in
772
+ uniffi_flamewallet_ffi_fn_method_wallet_address(
773
+ self.uniffiCloneHandle(),
774
+ FfiConverterTypeKeyPath_lower(path),uniffiCallStatus
775
+ )
776
+ })
777
+ }
778
+
779
+ /**
780
+ * Builds, proves and signs a transfer. The keys come from the paths
781
+ * the inputs name and never leave this call.
782
+ *
783
+ * Proving takes seconds on a phone, so it runs on a copy of the
784
+ * account with the lock released: other calls on this handle, from a
785
+ * UI thread say, do not wait for it. The build never touches the
786
+ * counter, so nothing the copy does needs writing back.
787
+ */
788
+ open func buildTransfer(request: TransferRequest)throws -> Transfer {
789
+ return try FfiConverterTypeTransfer_lift(try rustCallWithError(FfiConverterTypeFlameError_lift) {
790
+ uniffiCallStatus in
791
+ uniffi_flamewallet_ffi_fn_method_wallet_build_transfer(
792
+ self.uniffiCloneHandle(),
793
+ FfiConverterTypeTransferRequest_lower(request),uniffiCallStatus
794
+ )
795
+ })
796
+ }
797
+
798
+ /**
799
+ * The network this wallet's addresses are encoded for.
800
+ */
801
+ open func network() -> Network {
802
+ return try! FfiConverterTypeNetwork_lift(try! rustCall() {
803
+ uniffiCallStatus in
804
+ uniffi_flamewallet_ffi_fn_method_wallet_network(
805
+ self.uniffiCloneHandle(),uniffiCallStatus
806
+ )
807
+ })
808
+ }
809
+
810
+ /**
811
+ * Issues the next receiving address and advances the counter.
812
+ */
813
+ open func nextAddress()throws -> IssuedAddress {
814
+ return try FfiConverterTypeIssuedAddress_lift(try rustCallWithError(FfiConverterTypeFlameError_lift) {
815
+ uniffiCallStatus in
816
+ uniffi_flamewallet_ffi_fn_method_wallet_next_address(
817
+ self.uniffiCloneHandle(),uniffiCallStatus
818
+ )
819
+ })
820
+ }
821
+
822
+ /**
823
+ * The next receiving index not yet issued.
824
+ */
825
+ open func nextIndex() -> UInt32 {
826
+ return try! FfiConverterUInt32.lift(try! rustCall() {
827
+ uniffiCallStatus in
828
+ uniffi_flamewallet_ffi_fn_method_wallet_next_index(
829
+ self.uniffiCloneHandle(),uniffiCallStatus
830
+ )
831
+ })
832
+ }
833
+
834
+ /**
835
+ * Opens the note that followed `contract` in its log, as a scan serves
836
+ * the pair; `note` is `None` when the scan served none. `path` is what
837
+ * [`Wallet::owns`] found for the contract's predicate. The opening it
838
+ * gives is what a later [`crate::TransferInput`] spends the output with.
839
+ */
840
+ open func openNote(contract: Data, note: Data?, path: KeyPath)throws -> ReceivedNote {
841
+ return try FfiConverterTypeReceivedNote_lift(try rustCallWithError(FfiConverterTypeFlameError_lift) {
842
+ uniffiCallStatus in
843
+ uniffi_flamewallet_ffi_fn_method_wallet_open_note(
844
+ self.uniffiCloneHandle(),
845
+ FfiConverterData.lower(contract),
846
+ FfiConverterOptionData.lower(note),
847
+ FfiConverterTypeKeyPath_lower(path),uniffiCallStatus
848
+ )
849
+ })
850
+ }
851
+
852
+ /**
853
+ * Which path below `next_index + gap`, on either branch, owns
854
+ * `predicate`; `None` if none does. The scan re-derives every address
855
+ * it covers, so `gap` is the caller's cost budget.
856
+ */
857
+ open func owns(predicate: Data, gap: UInt32)throws -> KeyPath? {
858
+ return try FfiConverterOptionTypeKeyPath.lift(try rustCallWithError(FfiConverterTypeFlameError_lift) {
859
+ uniffiCallStatus in
860
+ uniffi_flamewallet_ffi_fn_method_wallet_owns(
861
+ self.uniffiCloneHandle(),
862
+ FfiConverterData.lower(predicate),
863
+ FfiConverterUInt32.lower(gap),uniffiCallStatus
864
+ )
865
+ })
866
+ }
867
+
868
+ /**
869
+ * The account's receiving key in bech32f (`recv1…` / `testrecv1…`):
870
+ * what an indexer is given to find this wallet's payments. It derives
871
+ * every address and links their activity, and can neither spend nor
872
+ * read a payment's amount.
873
+ */
874
+ open func receivingKey() -> String {
875
+ return try! FfiConverterString.lift(try! rustCall() {
876
+ uniffiCallStatus in
877
+ uniffi_flamewallet_ffi_fn_method_wallet_receiving_key(
878
+ self.uniffiCloneHandle(),uniffiCallStatus
879
+ )
880
+ })
881
+ }
882
+
883
+
884
+
885
+ }
886
+
887
+
888
+ #if swift(>=5.8)
889
+ @_documentation(visibility: private)
890
+ #endif
891
+ public struct FfiConverterTypeWallet: FfiConverter {
892
+ typealias FfiType = UInt64
893
+ typealias SwiftType = Wallet
894
+
895
+ public static func lift(_ handle: UInt64) throws -> Wallet {
896
+ return Wallet(unsafeFromHandle: handle)
897
+ }
898
+
899
+ public static func lower(_ value: Wallet) -> UInt64 {
900
+ return value.uniffiCloneHandle()
901
+ }
902
+
903
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Wallet {
904
+ let handle: UInt64 = try readInt(&buf)
905
+ return try lift(handle)
906
+ }
907
+
908
+ public static func write(_ value: Wallet, into buf: inout [UInt8]) {
909
+ writeInt(&buf, lower(value))
910
+ }
911
+ }
912
+
913
+
914
+ #if swift(>=5.8)
915
+ @_documentation(visibility: private)
916
+ #endif
917
+ public func FfiConverterTypeWallet_lift(_ handle: UInt64) throws -> Wallet {
918
+ return try FfiConverterTypeWallet.lift(handle)
919
+ }
920
+
921
+ #if swift(>=5.8)
922
+ @_documentation(visibility: private)
923
+ #endif
924
+ public func FfiConverterTypeWallet_lower(_ value: Wallet) -> UInt64 {
925
+ return FfiConverterTypeWallet.lower(value)
926
+ }
927
+
928
+
929
+
930
+
931
+ /**
932
+ * A published contract, as much of it as a wallet reads.
933
+ */
934
+ public struct ContractInfo: Equatable, Hashable {
935
+ /**
936
+ * The 32-byte contract id.
937
+ */
938
+ public var id: Data
939
+ /**
940
+ * The 32-byte compressed point it is locked with: what
941
+ * [`crate::Wallet::owns`] is asked about.
942
+ */
943
+ public var predicate: Data
944
+ public var value: ContractValue
945
+
946
+ // Default memberwise initializers are never public by default, so we
947
+ // declare one manually.
948
+ public init(
949
+ /**
950
+ * The 32-byte contract id.
951
+ */id: Data,
952
+ /**
953
+ * The 32-byte compressed point it is locked with: what
954
+ * [`crate::Wallet::owns`] is asked about.
955
+ */predicate: Data, value: ContractValue) {
956
+ self.id = id
957
+ self.predicate = predicate
958
+ self.value = value
959
+ }
960
+
961
+
962
+
963
+
964
+ }
965
+
966
+ #if compiler(>=6)
967
+ extension ContractInfo: Sendable {}
968
+ #endif
969
+
970
+ #if swift(>=5.8)
971
+ @_documentation(visibility: private)
972
+ #endif
973
+ public struct FfiConverterTypeContractInfo: FfiConverterRustBuffer {
974
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ContractInfo {
975
+ return
976
+ try ContractInfo(
977
+ id: FfiConverterData.read(from: &buf),
978
+ predicate: FfiConverterData.read(from: &buf),
979
+ value: FfiConverterTypeContractValue.read(from: &buf)
980
+ )
981
+ }
982
+
983
+ public static func write(_ value: ContractInfo, into buf: inout [UInt8]) {
984
+ FfiConverterData.write(value.id, into: &buf)
985
+ FfiConverterData.write(value.predicate, into: &buf)
986
+ FfiConverterTypeContractValue.write(value.value, into: &buf)
987
+ }
988
+ }
989
+
990
+
991
+ #if swift(>=5.8)
992
+ @_documentation(visibility: private)
993
+ #endif
994
+ public func FfiConverterTypeContractInfo_lift(_ buf: RustBuffer) throws -> ContractInfo {
995
+ return try FfiConverterTypeContractInfo.lift(buf)
996
+ }
997
+
998
+ #if swift(>=5.8)
999
+ @_documentation(visibility: private)
1000
+ #endif
1001
+ public func FfiConverterTypeContractInfo_lower(_ value: ContractInfo) -> RustBuffer {
1002
+ return FfiConverterTypeContractInfo.lower(value)
1003
+ }
1004
+
1005
+
1006
+ /**
1007
+ * One contract the transfer creates.
1008
+ */
1009
+ public struct CreatedOutput: Equatable, Hashable {
1010
+ public var contractId: Data
1011
+ /**
1012
+ * Its published bytes, as an indexer will serve them once confirmed.
1013
+ */
1014
+ public var contract: Data
1015
+ /**
1016
+ * The encrypted note that follows it on chain, as an indexer's scan
1017
+ * serves it. Its recipient opens it with [`crate::Wallet::open_note`];
1018
+ * so does this wallet, for its change.
1019
+ */
1020
+ public var note: Data
1021
+
1022
+ // Default memberwise initializers are never public by default, so we
1023
+ // declare one manually.
1024
+ public init(contractId: Data,
1025
+ /**
1026
+ * Its published bytes, as an indexer will serve them once confirmed.
1027
+ */contract: Data,
1028
+ /**
1029
+ * The encrypted note that follows it on chain, as an indexer's scan
1030
+ * serves it. Its recipient opens it with [`crate::Wallet::open_note`];
1031
+ * so does this wallet, for its change.
1032
+ */note: Data) {
1033
+ self.contractId = contractId
1034
+ self.contract = contract
1035
+ self.note = note
1036
+ }
1037
+
1038
+
1039
+
1040
+
1041
+ }
1042
+
1043
+ #if compiler(>=6)
1044
+ extension CreatedOutput: Sendable {}
1045
+ #endif
1046
+
1047
+ #if swift(>=5.8)
1048
+ @_documentation(visibility: private)
1049
+ #endif
1050
+ public struct FfiConverterTypeCreatedOutput: FfiConverterRustBuffer {
1051
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CreatedOutput {
1052
+ return
1053
+ try CreatedOutput(
1054
+ contractId: FfiConverterData.read(from: &buf),
1055
+ contract: FfiConverterData.read(from: &buf),
1056
+ note: FfiConverterData.read(from: &buf)
1057
+ )
1058
+ }
1059
+
1060
+ public static func write(_ value: CreatedOutput, into buf: inout [UInt8]) {
1061
+ FfiConverterData.write(value.contractId, into: &buf)
1062
+ FfiConverterData.write(value.contract, into: &buf)
1063
+ FfiConverterData.write(value.note, into: &buf)
1064
+ }
1065
+ }
1066
+
1067
+
1068
+ #if swift(>=5.8)
1069
+ @_documentation(visibility: private)
1070
+ #endif
1071
+ public func FfiConverterTypeCreatedOutput_lift(_ buf: RustBuffer) throws -> CreatedOutput {
1072
+ return try FfiConverterTypeCreatedOutput.lift(buf)
1073
+ }
1074
+
1075
+ #if swift(>=5.8)
1076
+ @_documentation(visibility: private)
1077
+ #endif
1078
+ public func FfiConverterTypeCreatedOutput_lower(_ value: CreatedOutput) -> RustBuffer {
1079
+ return FfiConverterTypeCreatedOutput.lower(value)
1080
+ }
1081
+
1082
+
1083
+ /**
1084
+ * An address the wallet has handed out, with the predicate an indexer is
1085
+ * asked about.
1086
+ */
1087
+ public struct IssuedAddress: Equatable, Hashable {
1088
+ public var path: KeyPath
1089
+ /**
1090
+ * bech32f: `f1…` on mainnet, `tf1…` on testnet.
1091
+ */
1092
+ public var address: String
1093
+ /**
1094
+ * The 32-byte compressed point that locks payments to this address.
1095
+ */
1096
+ public var predicate: Data
1097
+
1098
+ // Default memberwise initializers are never public by default, so we
1099
+ // declare one manually.
1100
+ public init(path: KeyPath,
1101
+ /**
1102
+ * bech32f: `f1…` on mainnet, `tf1…` on testnet.
1103
+ */address: String,
1104
+ /**
1105
+ * The 32-byte compressed point that locks payments to this address.
1106
+ */predicate: Data) {
1107
+ self.path = path
1108
+ self.address = address
1109
+ self.predicate = predicate
1110
+ }
1111
+
1112
+
1113
+
1114
+
1115
+ }
1116
+
1117
+ #if compiler(>=6)
1118
+ extension IssuedAddress: Sendable {}
1119
+ #endif
1120
+
1121
+ #if swift(>=5.8)
1122
+ @_documentation(visibility: private)
1123
+ #endif
1124
+ public struct FfiConverterTypeIssuedAddress: FfiConverterRustBuffer {
1125
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IssuedAddress {
1126
+ return
1127
+ try IssuedAddress(
1128
+ path: FfiConverterTypeKeyPath.read(from: &buf),
1129
+ address: FfiConverterString.read(from: &buf),
1130
+ predicate: FfiConverterData.read(from: &buf)
1131
+ )
1132
+ }
1133
+
1134
+ public static func write(_ value: IssuedAddress, into buf: inout [UInt8]) {
1135
+ FfiConverterTypeKeyPath.write(value.path, into: &buf)
1136
+ FfiConverterString.write(value.address, into: &buf)
1137
+ FfiConverterData.write(value.predicate, into: &buf)
1138
+ }
1139
+ }
1140
+
1141
+
1142
+ #if swift(>=5.8)
1143
+ @_documentation(visibility: private)
1144
+ #endif
1145
+ public func FfiConverterTypeIssuedAddress_lift(_ buf: RustBuffer) throws -> IssuedAddress {
1146
+ return try FfiConverterTypeIssuedAddress.lift(buf)
1147
+ }
1148
+
1149
+ #if swift(>=5.8)
1150
+ @_documentation(visibility: private)
1151
+ #endif
1152
+ public func FfiConverterTypeIssuedAddress_lower(_ value: IssuedAddress) -> RustBuffer {
1153
+ return FfiConverterTypeIssuedAddress.lower(value)
1154
+ }
1155
+
1156
+
1157
+ /**
1158
+ * A position below the account: `m/35263'/network'/0'/branch/index`.
1159
+ * `branch` is `0` for receiving and `1` for change.
1160
+ */
1161
+ public struct KeyPath: Equatable, Hashable {
1162
+ public var branch: UInt32
1163
+ public var index: UInt32
1164
+
1165
+ // Default memberwise initializers are never public by default, so we
1166
+ // declare one manually.
1167
+ public init(branch: UInt32, index: UInt32) {
1168
+ self.branch = branch
1169
+ self.index = index
1170
+ }
1171
+
1172
+
1173
+
1174
+
1175
+ }
1176
+
1177
+ #if compiler(>=6)
1178
+ extension KeyPath: Sendable {}
1179
+ #endif
1180
+
1181
+ #if swift(>=5.8)
1182
+ @_documentation(visibility: private)
1183
+ #endif
1184
+ public struct FfiConverterTypeKeyPath: FfiConverterRustBuffer {
1185
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> KeyPath {
1186
+ return
1187
+ try KeyPath(
1188
+ branch: FfiConverterUInt32.read(from: &buf),
1189
+ index: FfiConverterUInt32.read(from: &buf)
1190
+ )
1191
+ }
1192
+
1193
+ public static func write(_ value: KeyPath, into buf: inout [UInt8]) {
1194
+ FfiConverterUInt32.write(value.branch, into: &buf)
1195
+ FfiConverterUInt32.write(value.index, into: &buf)
1196
+ }
1197
+ }
1198
+
1199
+
1200
+ #if swift(>=5.8)
1201
+ @_documentation(visibility: private)
1202
+ #endif
1203
+ public func FfiConverterTypeKeyPath_lift(_ buf: RustBuffer) throws -> KeyPath {
1204
+ return try FfiConverterTypeKeyPath.lift(buf)
1205
+ }
1206
+
1207
+ #if swift(>=5.8)
1208
+ @_documentation(visibility: private)
1209
+ #endif
1210
+ public func FfiConverterTypeKeyPath_lower(_ value: KeyPath) -> RustBuffer {
1211
+ return FfiConverterTypeKeyPath.lower(value)
1212
+ }
1213
+
1214
+
1215
+ /**
1216
+ * The secret behind a confidential output: what its recipient needs in
1217
+ * order to spend it. Scalars are 32 canonical little-endian bytes.
1218
+ */
1219
+ public struct Opening: Equatable, Hashable {
1220
+ public var qty: UInt64
1221
+ public var flavor: Data
1222
+ public var qtyBlinding: Data
1223
+ public var flavorBlinding: Data
1224
+
1225
+ // Default memberwise initializers are never public by default, so we
1226
+ // declare one manually.
1227
+ public init(qty: UInt64, flavor: Data, qtyBlinding: Data, flavorBlinding: Data) {
1228
+ self.qty = qty
1229
+ self.flavor = flavor
1230
+ self.qtyBlinding = qtyBlinding
1231
+ self.flavorBlinding = flavorBlinding
1232
+ }
1233
+
1234
+
1235
+
1236
+
1237
+ }
1238
+
1239
+ #if compiler(>=6)
1240
+ extension Opening: Sendable {}
1241
+ #endif
1242
+
1243
+ #if swift(>=5.8)
1244
+ @_documentation(visibility: private)
1245
+ #endif
1246
+ public struct FfiConverterTypeOpening: FfiConverterRustBuffer {
1247
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Opening {
1248
+ return
1249
+ try Opening(
1250
+ qty: FfiConverterUInt64.read(from: &buf),
1251
+ flavor: FfiConverterData.read(from: &buf),
1252
+ qtyBlinding: FfiConverterData.read(from: &buf),
1253
+ flavorBlinding: FfiConverterData.read(from: &buf)
1254
+ )
1255
+ }
1256
+
1257
+ public static func write(_ value: Opening, into buf: inout [UInt8]) {
1258
+ FfiConverterUInt64.write(value.qty, into: &buf)
1259
+ FfiConverterData.write(value.flavor, into: &buf)
1260
+ FfiConverterData.write(value.qtyBlinding, into: &buf)
1261
+ FfiConverterData.write(value.flavorBlinding, into: &buf)
1262
+ }
1263
+ }
1264
+
1265
+
1266
+ #if swift(>=5.8)
1267
+ @_documentation(visibility: private)
1268
+ #endif
1269
+ public func FfiConverterTypeOpening_lift(_ buf: RustBuffer) throws -> Opening {
1270
+ return try FfiConverterTypeOpening.lift(buf)
1271
+ }
1272
+
1273
+ #if swift(>=5.8)
1274
+ @_documentation(visibility: private)
1275
+ #endif
1276
+ public func FfiConverterTypeOpening_lower(_ value: Opening) -> RustBuffer {
1277
+ return FfiConverterTypeOpening.lower(value)
1278
+ }
1279
+
1280
+
1281
+ /**
1282
+ * What an opened note gives its recipient.
1283
+ */
1284
+ public struct ReceivedNote: Equatable, Hashable {
1285
+ /**
1286
+ * What a [`crate::TransferInput`] spends the output with.
1287
+ */
1288
+ public var opening: Opening
1289
+ /**
1290
+ * The memo, as the sender wrote it.
1291
+ */
1292
+ public var memo: Data
1293
+
1294
+ // Default memberwise initializers are never public by default, so we
1295
+ // declare one manually.
1296
+ public init(
1297
+ /**
1298
+ * What a [`crate::TransferInput`] spends the output with.
1299
+ */opening: Opening,
1300
+ /**
1301
+ * The memo, as the sender wrote it.
1302
+ */memo: Data) {
1303
+ self.opening = opening
1304
+ self.memo = memo
1305
+ }
1306
+
1307
+
1308
+
1309
+
1310
+ }
1311
+
1312
+ #if compiler(>=6)
1313
+ extension ReceivedNote: Sendable {}
1314
+ #endif
1315
+
1316
+ #if swift(>=5.8)
1317
+ @_documentation(visibility: private)
1318
+ #endif
1319
+ public struct FfiConverterTypeReceivedNote: FfiConverterRustBuffer {
1320
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ReceivedNote {
1321
+ return
1322
+ try ReceivedNote(
1323
+ opening: FfiConverterTypeOpening.read(from: &buf),
1324
+ memo: FfiConverterData.read(from: &buf)
1325
+ )
1326
+ }
1327
+
1328
+ public static func write(_ value: ReceivedNote, into buf: inout [UInt8]) {
1329
+ FfiConverterTypeOpening.write(value.opening, into: &buf)
1330
+ FfiConverterData.write(value.memo, into: &buf)
1331
+ }
1332
+ }
1333
+
1334
+
1335
+ #if swift(>=5.8)
1336
+ @_documentation(visibility: private)
1337
+ #endif
1338
+ public func FfiConverterTypeReceivedNote_lift(_ buf: RustBuffer) throws -> ReceivedNote {
1339
+ return try FfiConverterTypeReceivedNote.lift(buf)
1340
+ }
1341
+
1342
+ #if swift(>=5.8)
1343
+ @_documentation(visibility: private)
1344
+ #endif
1345
+ public func FfiConverterTypeReceivedNote_lower(_ value: ReceivedNote) -> RustBuffer {
1346
+ return FfiConverterTypeReceivedNote.lower(value)
1347
+ }
1348
+
1349
+
1350
+ /**
1351
+ * A signed transfer, ready to publish.
1352
+ */
1353
+ public struct Transfer: Equatable, Hashable {
1354
+ /**
1355
+ * The 32-byte transaction id.
1356
+ */
1357
+ public var txid: Data
1358
+ /**
1359
+ * `BlockTx::to_bytes`: what a node's `submit_tx` takes.
1360
+ */
1361
+ public var blockTx: Data
1362
+ /**
1363
+ * In the order they are published, which is not request order: the
1364
+ * builder sorts them so that position says nothing about which one is
1365
+ * the change. Match one to its request by its predicate.
1366
+ */
1367
+ public var outputs: [CreatedOutput]
1368
+
1369
+ // Default memberwise initializers are never public by default, so we
1370
+ // declare one manually.
1371
+ public init(
1372
+ /**
1373
+ * The 32-byte transaction id.
1374
+ */txid: Data,
1375
+ /**
1376
+ * `BlockTx::to_bytes`: what a node's `submit_tx` takes.
1377
+ */blockTx: Data,
1378
+ /**
1379
+ * In the order they are published, which is not request order: the
1380
+ * builder sorts them so that position says nothing about which one is
1381
+ * the change. Match one to its request by its predicate.
1382
+ */outputs: [CreatedOutput]) {
1383
+ self.txid = txid
1384
+ self.blockTx = blockTx
1385
+ self.outputs = outputs
1386
+ }
1387
+
1388
+
1389
+
1390
+
1391
+ }
1392
+
1393
+ #if compiler(>=6)
1394
+ extension Transfer: Sendable {}
1395
+ #endif
1396
+
1397
+ #if swift(>=5.8)
1398
+ @_documentation(visibility: private)
1399
+ #endif
1400
+ public struct FfiConverterTypeTransfer: FfiConverterRustBuffer {
1401
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Transfer {
1402
+ return
1403
+ try Transfer(
1404
+ txid: FfiConverterData.read(from: &buf),
1405
+ blockTx: FfiConverterData.read(from: &buf),
1406
+ outputs: FfiConverterSequenceTypeCreatedOutput.read(from: &buf)
1407
+ )
1408
+ }
1409
+
1410
+ public static func write(_ value: Transfer, into buf: inout [UInt8]) {
1411
+ FfiConverterData.write(value.txid, into: &buf)
1412
+ FfiConverterData.write(value.blockTx, into: &buf)
1413
+ FfiConverterSequenceTypeCreatedOutput.write(value.outputs, into: &buf)
1414
+ }
1415
+ }
1416
+
1417
+
1418
+ #if swift(>=5.8)
1419
+ @_documentation(visibility: private)
1420
+ #endif
1421
+ public func FfiConverterTypeTransfer_lift(_ buf: RustBuffer) throws -> Transfer {
1422
+ return try FfiConverterTypeTransfer.lift(buf)
1423
+ }
1424
+
1425
+ #if swift(>=5.8)
1426
+ @_documentation(visibility: private)
1427
+ #endif
1428
+ public func FfiConverterTypeTransfer_lower(_ value: Transfer) -> RustBuffer {
1429
+ return FfiConverterTypeTransfer.lower(value)
1430
+ }
1431
+
1432
+
1433
+ /**
1434
+ * One contract being spent, exactly as the indexer served it.
1435
+ */
1436
+ public struct TransferInput: Equatable, Hashable {
1437
+ /**
1438
+ * The contract's published bytes.
1439
+ */
1440
+ public var contract: Data
1441
+ /**
1442
+ * Its Utreexo membership proof, valid at the tip the transfer targets.
1443
+ */
1444
+ public var proof: Data
1445
+ /**
1446
+ * The path of the key it is locked to.
1447
+ */
1448
+ public var path: KeyPath
1449
+ /**
1450
+ * Required for a confidential contract, refused for a cleartext one.
1451
+ */
1452
+ public var opening: Opening?
1453
+
1454
+ // Default memberwise initializers are never public by default, so we
1455
+ // declare one manually.
1456
+ public init(
1457
+ /**
1458
+ * The contract's published bytes.
1459
+ */contract: Data,
1460
+ /**
1461
+ * Its Utreexo membership proof, valid at the tip the transfer targets.
1462
+ */proof: Data,
1463
+ /**
1464
+ * The path of the key it is locked to.
1465
+ */path: KeyPath,
1466
+ /**
1467
+ * Required for a confidential contract, refused for a cleartext one.
1468
+ */opening: Opening?) {
1469
+ self.contract = contract
1470
+ self.proof = proof
1471
+ self.path = path
1472
+ self.opening = opening
1473
+ }
1474
+
1475
+
1476
+
1477
+
1478
+ }
1479
+
1480
+ #if compiler(>=6)
1481
+ extension TransferInput: Sendable {}
1482
+ #endif
1483
+
1484
+ #if swift(>=5.8)
1485
+ @_documentation(visibility: private)
1486
+ #endif
1487
+ public struct FfiConverterTypeTransferInput: FfiConverterRustBuffer {
1488
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TransferInput {
1489
+ return
1490
+ try TransferInput(
1491
+ contract: FfiConverterData.read(from: &buf),
1492
+ proof: FfiConverterData.read(from: &buf),
1493
+ path: FfiConverterTypeKeyPath.read(from: &buf),
1494
+ opening: FfiConverterOptionTypeOpening.read(from: &buf)
1495
+ )
1496
+ }
1497
+
1498
+ public static func write(_ value: TransferInput, into buf: inout [UInt8]) {
1499
+ FfiConverterData.write(value.contract, into: &buf)
1500
+ FfiConverterData.write(value.proof, into: &buf)
1501
+ FfiConverterTypeKeyPath.write(value.path, into: &buf)
1502
+ FfiConverterOptionTypeOpening.write(value.opening, into: &buf)
1503
+ }
1504
+ }
1505
+
1506
+
1507
+ #if swift(>=5.8)
1508
+ @_documentation(visibility: private)
1509
+ #endif
1510
+ public func FfiConverterTypeTransferInput_lift(_ buf: RustBuffer) throws -> TransferInput {
1511
+ return try FfiConverterTypeTransferInput.lift(buf)
1512
+ }
1513
+
1514
+ #if swift(>=5.8)
1515
+ @_documentation(visibility: private)
1516
+ #endif
1517
+ public func FfiConverterTypeTransferInput_lower(_ value: TransferInput) -> RustBuffer {
1518
+ return FfiConverterTypeTransferInput.lower(value)
1519
+ }
1520
+
1521
+
1522
+ /**
1523
+ * One contract being created.
1524
+ */
1525
+ public struct TransferOutput: Equatable, Hashable {
1526
+ /**
1527
+ * The recipient's bech32f address, for the wallet's network; for
1528
+ * change, [`crate::Wallet::address`] on the change branch.
1529
+ */
1530
+ public var address: String
1531
+ public var qty: UInt64
1532
+ /**
1533
+ * `None` for flames.
1534
+ */
1535
+ public var flavor: Data?
1536
+ /**
1537
+ * Sealed into the output's note with the amount; only the recipient
1538
+ * reads it. At most 8102 bytes; empty for none.
1539
+ */
1540
+ public var memo: Data
1541
+
1542
+ // Default memberwise initializers are never public by default, so we
1543
+ // declare one manually.
1544
+ public init(
1545
+ /**
1546
+ * The recipient's bech32f address, for the wallet's network; for
1547
+ * change, [`crate::Wallet::address`] on the change branch.
1548
+ */address: String, qty: UInt64,
1549
+ /**
1550
+ * `None` for flames.
1551
+ */flavor: Data?,
1552
+ /**
1553
+ * Sealed into the output's note with the amount; only the recipient
1554
+ * reads it. At most 8102 bytes; empty for none.
1555
+ */memo: Data) {
1556
+ self.address = address
1557
+ self.qty = qty
1558
+ self.flavor = flavor
1559
+ self.memo = memo
1560
+ }
1561
+
1562
+
1563
+
1564
+
1565
+ }
1566
+
1567
+ #if compiler(>=6)
1568
+ extension TransferOutput: Sendable {}
1569
+ #endif
1570
+
1571
+ #if swift(>=5.8)
1572
+ @_documentation(visibility: private)
1573
+ #endif
1574
+ public struct FfiConverterTypeTransferOutput: FfiConverterRustBuffer {
1575
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TransferOutput {
1576
+ return
1577
+ try TransferOutput(
1578
+ address: FfiConverterString.read(from: &buf),
1579
+ qty: FfiConverterUInt64.read(from: &buf),
1580
+ flavor: FfiConverterOptionData.read(from: &buf),
1581
+ memo: FfiConverterData.read(from: &buf)
1582
+ )
1583
+ }
1584
+
1585
+ public static func write(_ value: TransferOutput, into buf: inout [UInt8]) {
1586
+ FfiConverterString.write(value.address, into: &buf)
1587
+ FfiConverterUInt64.write(value.qty, into: &buf)
1588
+ FfiConverterOptionData.write(value.flavor, into: &buf)
1589
+ FfiConverterData.write(value.memo, into: &buf)
1590
+ }
1591
+ }
1592
+
1593
+
1594
+ #if swift(>=5.8)
1595
+ @_documentation(visibility: private)
1596
+ #endif
1597
+ public func FfiConverterTypeTransferOutput_lift(_ buf: RustBuffer) throws -> TransferOutput {
1598
+ return try FfiConverterTypeTransferOutput.lift(buf)
1599
+ }
1600
+
1601
+ #if swift(>=5.8)
1602
+ @_documentation(visibility: private)
1603
+ #endif
1604
+ public func FfiConverterTypeTransferOutput_lower(_ value: TransferOutput) -> RustBuffer {
1605
+ return FfiConverterTypeTransferOutput.lower(value)
1606
+ }
1607
+
1608
+
1609
+ public struct TransferRequest: Equatable, Hashable {
1610
+ public var inputs: [TransferInput]
1611
+ public var outputs: [TransferOutput]
1612
+ /**
1613
+ * In sparks. Inputs must equal outputs plus fee, per flavor.
1614
+ */
1615
+ public var fee: UInt64
1616
+ /**
1617
+ * The gas budget; the node refuses more than its block limit allows.
1618
+ */
1619
+ public var gas: UInt64
1620
+ /**
1621
+ * `0` for none; otherwise as in Bitcoin.
1622
+ */
1623
+ public var locktime: UInt32
1624
+
1625
+ // Default memberwise initializers are never public by default, so we
1626
+ // declare one manually.
1627
+ public init(inputs: [TransferInput], outputs: [TransferOutput],
1628
+ /**
1629
+ * In sparks. Inputs must equal outputs plus fee, per flavor.
1630
+ */fee: UInt64,
1631
+ /**
1632
+ * The gas budget; the node refuses more than its block limit allows.
1633
+ */gas: UInt64,
1634
+ /**
1635
+ * `0` for none; otherwise as in Bitcoin.
1636
+ */locktime: UInt32) {
1637
+ self.inputs = inputs
1638
+ self.outputs = outputs
1639
+ self.fee = fee
1640
+ self.gas = gas
1641
+ self.locktime = locktime
1642
+ }
1643
+
1644
+
1645
+
1646
+
1647
+ }
1648
+
1649
+ #if compiler(>=6)
1650
+ extension TransferRequest: Sendable {}
1651
+ #endif
1652
+
1653
+ #if swift(>=5.8)
1654
+ @_documentation(visibility: private)
1655
+ #endif
1656
+ public struct FfiConverterTypeTransferRequest: FfiConverterRustBuffer {
1657
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TransferRequest {
1658
+ return
1659
+ try TransferRequest(
1660
+ inputs: FfiConverterSequenceTypeTransferInput.read(from: &buf),
1661
+ outputs: FfiConverterSequenceTypeTransferOutput.read(from: &buf),
1662
+ fee: FfiConverterUInt64.read(from: &buf),
1663
+ gas: FfiConverterUInt64.read(from: &buf),
1664
+ locktime: FfiConverterUInt32.read(from: &buf)
1665
+ )
1666
+ }
1667
+
1668
+ public static func write(_ value: TransferRequest, into buf: inout [UInt8]) {
1669
+ FfiConverterSequenceTypeTransferInput.write(value.inputs, into: &buf)
1670
+ FfiConverterSequenceTypeTransferOutput.write(value.outputs, into: &buf)
1671
+ FfiConverterUInt64.write(value.fee, into: &buf)
1672
+ FfiConverterUInt64.write(value.gas, into: &buf)
1673
+ FfiConverterUInt32.write(value.locktime, into: &buf)
1674
+ }
1675
+ }
1676
+
1677
+
1678
+ #if swift(>=5.8)
1679
+ @_documentation(visibility: private)
1680
+ #endif
1681
+ public func FfiConverterTypeTransferRequest_lift(_ buf: RustBuffer) throws -> TransferRequest {
1682
+ return try FfiConverterTypeTransferRequest.lift(buf)
1683
+ }
1684
+
1685
+ #if swift(>=5.8)
1686
+ @_documentation(visibility: private)
1687
+ #endif
1688
+ public func FfiConverterTypeTransferRequest_lower(_ value: TransferRequest) -> RustBuffer {
1689
+ return FfiConverterTypeTransferRequest.lower(value)
1690
+ }
1691
+
1692
+
1693
+ /**
1694
+ * What a contract holds.
1695
+ */
1696
+
1697
+ public enum ContractValue: Equatable, Hashable {
1698
+
1699
+ /**
1700
+ * A cleartext token: the amount is public. A devnet genesis allocation
1701
+ * is one.
1702
+ */
1703
+ case clear(qty: UInt64, flavor: Data
1704
+ )
1705
+ /**
1706
+ * A confidential token: the amount is readable only with its opening.
1707
+ */
1708
+ case confidential
1709
+ /**
1710
+ * Anything that is not a bare token; no transfer spends it.
1711
+ */
1712
+ case other
1713
+
1714
+
1715
+
1716
+
1717
+
1718
+ }
1719
+
1720
+ #if compiler(>=6)
1721
+ extension ContractValue: Sendable {}
1722
+ #endif
1723
+
1724
+ #if swift(>=5.8)
1725
+ @_documentation(visibility: private)
1726
+ #endif
1727
+ public struct FfiConverterTypeContractValue: FfiConverterRustBuffer {
1728
+ typealias SwiftType = ContractValue
1729
+
1730
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ContractValue {
1731
+ let variant: Int32 = try readInt(&buf)
1732
+ switch variant {
1733
+
1734
+ case 1: return .clear(qty: try FfiConverterUInt64.read(from: &buf), flavor: try FfiConverterData.read(from: &buf)
1735
+ )
1736
+
1737
+ case 2: return .confidential
1738
+
1739
+ case 3: return .other
1740
+
1741
+ default: throw UniffiInternalError.unexpectedEnumCase
1742
+ }
1743
+ }
1744
+
1745
+ public static func write(_ value: ContractValue, into buf: inout [UInt8]) {
1746
+ switch value {
1747
+
1748
+
1749
+ case let .clear(qty,flavor):
1750
+ writeInt(&buf, Int32(1))
1751
+ FfiConverterUInt64.write(qty, into: &buf)
1752
+ FfiConverterData.write(flavor, into: &buf)
1753
+
1754
+
1755
+ case .confidential:
1756
+ writeInt(&buf, Int32(2))
1757
+
1758
+
1759
+ case .other:
1760
+ writeInt(&buf, Int32(3))
1761
+
1762
+ }
1763
+ }
1764
+ }
1765
+
1766
+
1767
+ #if swift(>=5.8)
1768
+ @_documentation(visibility: private)
1769
+ #endif
1770
+ public func FfiConverterTypeContractValue_lift(_ buf: RustBuffer) throws -> ContractValue {
1771
+ return try FfiConverterTypeContractValue.lift(buf)
1772
+ }
1773
+
1774
+ #if swift(>=5.8)
1775
+ @_documentation(visibility: private)
1776
+ #endif
1777
+ public func FfiConverterTypeContractValue_lower(_ value: ContractValue) -> RustBuffer {
1778
+ return FfiConverterTypeContractValue.lower(value)
1779
+ }
1780
+
1781
+
1782
+
1783
+ /**
1784
+ * Why a call was refused.
1785
+ */
1786
+ public
1787
+ enum FlameError: Swift.Error, Equatable, Hashable, Foundation.LocalizedError {
1788
+
1789
+
1790
+
1791
+ /**
1792
+ * The phrase is not a valid BIP-39 mnemonic in any supported language,
1793
+ * or the word count is not one BIP-39 defines.
1794
+ */
1795
+ case InvalidMnemonic(reason: String
1796
+ )
1797
+ /**
1798
+ * A seed is not 64 bytes, or flamekd refused to derive from it.
1799
+ */
1800
+ case InvalidSeed(reason: String
1801
+ )
1802
+ /**
1803
+ * An address does not parse for the wallet's network.
1804
+ */
1805
+ case InvalidAddress(reason: String
1806
+ )
1807
+ /**
1808
+ * A branch or index is hardened; both must be normal.
1809
+ */
1810
+ case InvalidKeyPath(reason: String
1811
+ )
1812
+ /**
1813
+ * Bytes do not decode into what they claim to be. `what` names the
1814
+ * field: `contract`, `proof`, `predicate`, `flavor`, `blinding`.
1815
+ */
1816
+ case InvalidBytes(what: String, reason: String
1817
+ )
1818
+ /**
1819
+ * Input `input` is not locked to the key at the path it names, so its
1820
+ * signature could never verify.
1821
+ */
1822
+ case KeyMismatch(input: UInt32
1823
+ )
1824
+ /**
1825
+ * A note did not open; `failure` says how, and so what the wallet does
1826
+ * with the output.
1827
+ */
1828
+ case Note(failure: NoteFailure, reason: String
1829
+ )
1830
+ /**
1831
+ * The transfer could not be built or signed.
1832
+ */
1833
+ case Transfer(reason: String
1834
+ )
1835
+
1836
+
1837
+
1838
+
1839
+
1840
+
1841
+ public var errorDescription: String? {
1842
+ String(reflecting: self)
1843
+ }
1844
+
1845
+ }
1846
+
1847
+ #if compiler(>=6)
1848
+ extension FlameError: Sendable {}
1849
+ #endif
1850
+
1851
+ #if swift(>=5.8)
1852
+ @_documentation(visibility: private)
1853
+ #endif
1854
+ public struct FfiConverterTypeFlameError: FfiConverterRustBuffer {
1855
+ typealias SwiftType = FlameError
1856
+
1857
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FlameError {
1858
+ let variant: Int32 = try readInt(&buf)
1859
+ switch variant {
1860
+
1861
+
1862
+
1863
+
1864
+ case 1: return .InvalidMnemonic(
1865
+ reason: try FfiConverterString.read(from: &buf)
1866
+ )
1867
+ case 2: return .InvalidSeed(
1868
+ reason: try FfiConverterString.read(from: &buf)
1869
+ )
1870
+ case 3: return .InvalidAddress(
1871
+ reason: try FfiConverterString.read(from: &buf)
1872
+ )
1873
+ case 4: return .InvalidKeyPath(
1874
+ reason: try FfiConverterString.read(from: &buf)
1875
+ )
1876
+ case 5: return .InvalidBytes(
1877
+ what: try FfiConverterString.read(from: &buf),
1878
+ reason: try FfiConverterString.read(from: &buf)
1879
+ )
1880
+ case 6: return .KeyMismatch(
1881
+ input: try FfiConverterUInt32.read(from: &buf)
1882
+ )
1883
+ case 7: return .Note(
1884
+ failure: try FfiConverterTypeNoteFailure.read(from: &buf),
1885
+ reason: try FfiConverterString.read(from: &buf)
1886
+ )
1887
+ case 8: return .Transfer(
1888
+ reason: try FfiConverterString.read(from: &buf)
1889
+ )
1890
+
1891
+ default: throw UniffiInternalError.unexpectedEnumCase
1892
+ }
1893
+ }
1894
+
1895
+ public static func write(_ value: FlameError, into buf: inout [UInt8]) {
1896
+ switch value {
1897
+
1898
+
1899
+
1900
+
1901
+
1902
+ case let .InvalidMnemonic(reason):
1903
+ writeInt(&buf, Int32(1))
1904
+ FfiConverterString.write(reason, into: &buf)
1905
+
1906
+
1907
+ case let .InvalidSeed(reason):
1908
+ writeInt(&buf, Int32(2))
1909
+ FfiConverterString.write(reason, into: &buf)
1910
+
1911
+
1912
+ case let .InvalidAddress(reason):
1913
+ writeInt(&buf, Int32(3))
1914
+ FfiConverterString.write(reason, into: &buf)
1915
+
1916
+
1917
+ case let .InvalidKeyPath(reason):
1918
+ writeInt(&buf, Int32(4))
1919
+ FfiConverterString.write(reason, into: &buf)
1920
+
1921
+
1922
+ case let .InvalidBytes(what,reason):
1923
+ writeInt(&buf, Int32(5))
1924
+ FfiConverterString.write(what, into: &buf)
1925
+ FfiConverterString.write(reason, into: &buf)
1926
+
1927
+
1928
+ case let .KeyMismatch(input):
1929
+ writeInt(&buf, Int32(6))
1930
+ FfiConverterUInt32.write(input, into: &buf)
1931
+
1932
+
1933
+ case let .Note(failure,reason):
1934
+ writeInt(&buf, Int32(7))
1935
+ FfiConverterTypeNoteFailure.write(failure, into: &buf)
1936
+ FfiConverterString.write(reason, into: &buf)
1937
+
1938
+
1939
+ case let .Transfer(reason):
1940
+ writeInt(&buf, Int32(8))
1941
+ FfiConverterString.write(reason, into: &buf)
1942
+
1943
+ }
1944
+ }
1945
+ }
1946
+
1947
+
1948
+ #if swift(>=5.8)
1949
+ @_documentation(visibility: private)
1950
+ #endif
1951
+ public func FfiConverterTypeFlameError_lift(_ buf: RustBuffer) throws -> FlameError {
1952
+ return try FfiConverterTypeFlameError.lift(buf)
1953
+ }
1954
+
1955
+ #if swift(>=5.8)
1956
+ @_documentation(visibility: private)
1957
+ #endif
1958
+ public func FfiConverterTypeFlameError_lower(_ value: FlameError) -> RustBuffer {
1959
+ return FfiConverterTypeFlameError.lower(value)
1960
+ }
1961
+
1962
+
1963
+ /**
1964
+ * Which network addresses are encoded for: `f1…` or `tf1…`.
1965
+ */
1966
+
1967
+ public enum Network: Equatable, Hashable {
1968
+
1969
+ case mainnet
1970
+ case testnet
1971
+
1972
+
1973
+
1974
+
1975
+
1976
+ }
1977
+
1978
+ #if compiler(>=6)
1979
+ extension Network: Sendable {}
1980
+ #endif
1981
+
1982
+ #if swift(>=5.8)
1983
+ @_documentation(visibility: private)
1984
+ #endif
1985
+ public struct FfiConverterTypeNetwork: FfiConverterRustBuffer {
1986
+ typealias SwiftType = Network
1987
+
1988
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Network {
1989
+ let variant: Int32 = try readInt(&buf)
1990
+ switch variant {
1991
+
1992
+ case 1: return .mainnet
1993
+
1994
+ case 2: return .testnet
1995
+
1996
+ default: throw UniffiInternalError.unexpectedEnumCase
1997
+ }
1998
+ }
1999
+
2000
+ public static func write(_ value: Network, into buf: inout [UInt8]) {
2001
+ switch value {
2002
+
2003
+
2004
+ case .mainnet:
2005
+ writeInt(&buf, Int32(1))
2006
+
2007
+
2008
+ case .testnet:
2009
+ writeInt(&buf, Int32(2))
2010
+
2011
+ }
2012
+ }
2013
+ }
2014
+
2015
+
2016
+ #if swift(>=5.8)
2017
+ @_documentation(visibility: private)
2018
+ #endif
2019
+ public func FfiConverterTypeNetwork_lift(_ buf: RustBuffer) throws -> Network {
2020
+ return try FfiConverterTypeNetwork.lift(buf)
2021
+ }
2022
+
2023
+ #if swift(>=5.8)
2024
+ @_documentation(visibility: private)
2025
+ #endif
2026
+ public func FfiConverterTypeNetwork_lower(_ value: Network) -> RustBuffer {
2027
+ return FfiConverterTypeNetwork.lower(value)
2028
+ }
2029
+
2030
+
2031
+
2032
+ /**
2033
+ * Why a note did not open: the outcomes of `docs/payments.md`
2034
+ * "Receiving", which a wallet treats differently.
2035
+ */
2036
+
2037
+ public enum NoteFailure: Equatable, Hashable {
2038
+
2039
+ /**
2040
+ * No note followed the output. The output is ours but unreadable: keep
2041
+ * and list it, and leave it out of the balance.
2042
+ */
2043
+ case missing
2044
+ /**
2045
+ * The note is malformed. Treated as [`NoteFailure::Missing`].
2046
+ */
2047
+ case malformed
2048
+ /**
2049
+ * A note version this library does not know; a later one may open it.
2050
+ */
2051
+ case unknownVersion
2052
+ /**
2053
+ * The note does not decrypt under this address. Treated as
2054
+ * [`NoteFailure::Missing`].
2055
+ */
2056
+ case undecryptable
2057
+ /**
2058
+ * The note decrypts but misstates its output: the sender erred or lied.
2059
+ * Keep and flag it; never count it.
2060
+ */
2061
+ case openingMismatch
2062
+ /**
2063
+ * The contract is a cleartext token, or not a token: there is no note
2064
+ * to open, and [`crate::decode_contract`] reads its amount.
2065
+ */
2066
+ case notConfidential
2067
+
2068
+
2069
+
2070
+
2071
+
2072
+ }
2073
+
2074
+ #if compiler(>=6)
2075
+ extension NoteFailure: Sendable {}
2076
+ #endif
2077
+
2078
+ #if swift(>=5.8)
2079
+ @_documentation(visibility: private)
2080
+ #endif
2081
+ public struct FfiConverterTypeNoteFailure: FfiConverterRustBuffer {
2082
+ typealias SwiftType = NoteFailure
2083
+
2084
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NoteFailure {
2085
+ let variant: Int32 = try readInt(&buf)
2086
+ switch variant {
2087
+
2088
+ case 1: return .missing
2089
+
2090
+ case 2: return .malformed
2091
+
2092
+ case 3: return .unknownVersion
2093
+
2094
+ case 4: return .undecryptable
2095
+
2096
+ case 5: return .openingMismatch
2097
+
2098
+ case 6: return .notConfidential
2099
+
2100
+ default: throw UniffiInternalError.unexpectedEnumCase
2101
+ }
2102
+ }
2103
+
2104
+ public static func write(_ value: NoteFailure, into buf: inout [UInt8]) {
2105
+ switch value {
2106
+
2107
+
2108
+ case .missing:
2109
+ writeInt(&buf, Int32(1))
2110
+
2111
+
2112
+ case .malformed:
2113
+ writeInt(&buf, Int32(2))
2114
+
2115
+
2116
+ case .unknownVersion:
2117
+ writeInt(&buf, Int32(3))
2118
+
2119
+
2120
+ case .undecryptable:
2121
+ writeInt(&buf, Int32(4))
2122
+
2123
+
2124
+ case .openingMismatch:
2125
+ writeInt(&buf, Int32(5))
2126
+
2127
+
2128
+ case .notConfidential:
2129
+ writeInt(&buf, Int32(6))
2130
+
2131
+ }
2132
+ }
2133
+ }
2134
+
2135
+
2136
+ #if swift(>=5.8)
2137
+ @_documentation(visibility: private)
2138
+ #endif
2139
+ public func FfiConverterTypeNoteFailure_lift(_ buf: RustBuffer) throws -> NoteFailure {
2140
+ return try FfiConverterTypeNoteFailure.lift(buf)
2141
+ }
2142
+
2143
+ #if swift(>=5.8)
2144
+ @_documentation(visibility: private)
2145
+ #endif
2146
+ public func FfiConverterTypeNoteFailure_lower(_ value: NoteFailure) -> RustBuffer {
2147
+ return FfiConverterTypeNoteFailure.lower(value)
2148
+ }
2149
+
2150
+
2151
+ #if swift(>=5.8)
2152
+ @_documentation(visibility: private)
2153
+ #endif
2154
+ fileprivate struct FfiConverterOptionData: FfiConverterRustBuffer {
2155
+ typealias SwiftType = Data?
2156
+
2157
+ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
2158
+ guard let value = value else {
2159
+ writeInt(&buf, Int8(0))
2160
+ return
2161
+ }
2162
+ writeInt(&buf, Int8(1))
2163
+ FfiConverterData.write(value, into: &buf)
2164
+ }
2165
+
2166
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
2167
+ switch try readInt(&buf) as Int8 {
2168
+ case 0: return nil
2169
+ case 1: return try FfiConverterData.read(from: &buf)
2170
+ default: throw UniffiInternalError.unexpectedOptionalTag
2171
+ }
2172
+ }
2173
+ }
2174
+
2175
+ #if swift(>=5.8)
2176
+ @_documentation(visibility: private)
2177
+ #endif
2178
+ fileprivate struct FfiConverterOptionTypeKeyPath: FfiConverterRustBuffer {
2179
+ typealias SwiftType = KeyPath?
2180
+
2181
+ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
2182
+ guard let value = value else {
2183
+ writeInt(&buf, Int8(0))
2184
+ return
2185
+ }
2186
+ writeInt(&buf, Int8(1))
2187
+ FfiConverterTypeKeyPath.write(value, into: &buf)
2188
+ }
2189
+
2190
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
2191
+ switch try readInt(&buf) as Int8 {
2192
+ case 0: return nil
2193
+ case 1: return try FfiConverterTypeKeyPath.read(from: &buf)
2194
+ default: throw UniffiInternalError.unexpectedOptionalTag
2195
+ }
2196
+ }
2197
+ }
2198
+
2199
+ #if swift(>=5.8)
2200
+ @_documentation(visibility: private)
2201
+ #endif
2202
+ fileprivate struct FfiConverterOptionTypeOpening: FfiConverterRustBuffer {
2203
+ typealias SwiftType = Opening?
2204
+
2205
+ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
2206
+ guard let value = value else {
2207
+ writeInt(&buf, Int8(0))
2208
+ return
2209
+ }
2210
+ writeInt(&buf, Int8(1))
2211
+ FfiConverterTypeOpening.write(value, into: &buf)
2212
+ }
2213
+
2214
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
2215
+ switch try readInt(&buf) as Int8 {
2216
+ case 0: return nil
2217
+ case 1: return try FfiConverterTypeOpening.read(from: &buf)
2218
+ default: throw UniffiInternalError.unexpectedOptionalTag
2219
+ }
2220
+ }
2221
+ }
2222
+
2223
+ #if swift(>=5.8)
2224
+ @_documentation(visibility: private)
2225
+ #endif
2226
+ fileprivate struct FfiConverterSequenceTypeCreatedOutput: FfiConverterRustBuffer {
2227
+ typealias SwiftType = [CreatedOutput]
2228
+
2229
+ public static func write(_ value: [CreatedOutput], into buf: inout [UInt8]) {
2230
+ let len = Int32(value.count)
2231
+ writeInt(&buf, len)
2232
+ for item in value {
2233
+ FfiConverterTypeCreatedOutput.write(item, into: &buf)
2234
+ }
2235
+ }
2236
+
2237
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [CreatedOutput] {
2238
+ let len: Int32 = try readInt(&buf)
2239
+ var seq = [CreatedOutput]()
2240
+ seq.reserveCapacity(Int(len))
2241
+ for _ in 0 ..< len {
2242
+ seq.append(try FfiConverterTypeCreatedOutput.read(from: &buf))
2243
+ }
2244
+ return seq
2245
+ }
2246
+ }
2247
+
2248
+ #if swift(>=5.8)
2249
+ @_documentation(visibility: private)
2250
+ #endif
2251
+ fileprivate struct FfiConverterSequenceTypeTransferInput: FfiConverterRustBuffer {
2252
+ typealias SwiftType = [TransferInput]
2253
+
2254
+ public static func write(_ value: [TransferInput], into buf: inout [UInt8]) {
2255
+ let len = Int32(value.count)
2256
+ writeInt(&buf, len)
2257
+ for item in value {
2258
+ FfiConverterTypeTransferInput.write(item, into: &buf)
2259
+ }
2260
+ }
2261
+
2262
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [TransferInput] {
2263
+ let len: Int32 = try readInt(&buf)
2264
+ var seq = [TransferInput]()
2265
+ seq.reserveCapacity(Int(len))
2266
+ for _ in 0 ..< len {
2267
+ seq.append(try FfiConverterTypeTransferInput.read(from: &buf))
2268
+ }
2269
+ return seq
2270
+ }
2271
+ }
2272
+
2273
+ #if swift(>=5.8)
2274
+ @_documentation(visibility: private)
2275
+ #endif
2276
+ fileprivate struct FfiConverterSequenceTypeTransferOutput: FfiConverterRustBuffer {
2277
+ typealias SwiftType = [TransferOutput]
2278
+
2279
+ public static func write(_ value: [TransferOutput], into buf: inout [UInt8]) {
2280
+ let len = Int32(value.count)
2281
+ writeInt(&buf, len)
2282
+ for item in value {
2283
+ FfiConverterTypeTransferOutput.write(item, into: &buf)
2284
+ }
2285
+ }
2286
+
2287
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [TransferOutput] {
2288
+ let len: Int32 = try readInt(&buf)
2289
+ var seq = [TransferOutput]()
2290
+ seq.reserveCapacity(Int(len))
2291
+ for _ in 0 ..< len {
2292
+ seq.append(try FfiConverterTypeTransferOutput.read(from: &buf))
2293
+ }
2294
+ return seq
2295
+ }
2296
+ }
2297
+ /**
2298
+ * Decodes a contract from its published bytes.
2299
+ */
2300
+ public func decodeContract(bytes: Data)throws -> ContractInfo {
2301
+ return try FfiConverterTypeContractInfo_lift(try rustCallWithError(FfiConverterTypeFlameError_lift) {
2302
+ uniffiCallStatus in
2303
+ uniffi_flamewallet_ffi_fn_func_decode_contract(
2304
+ FfiConverterData.lower(bytes),uniffiCallStatus
2305
+ )
2306
+ })
2307
+ }
2308
+ /**
2309
+ * Whether `opening` opens the confidential contract in `bytes`.
2310
+ *
2311
+ * This is how a recipient checks an opening delivered out of band before
2312
+ * counting the payment: the same id comparison
2313
+ * [`crate::Wallet::build_transfer`] makes, run without spending anything.
2314
+ */
2315
+ public func openingMatches(contract: Data, opening: Opening)throws -> Bool {
2316
+ return try FfiConverterBool.lift(try rustCallWithError(FfiConverterTypeFlameError_lift) {
2317
+ uniffiCallStatus in
2318
+ uniffi_flamewallet_ffi_fn_func_opening_matches(
2319
+ FfiConverterData.lower(contract),
2320
+ FfiConverterTypeOpening_lower(opening),uniffiCallStatus
2321
+ )
2322
+ })
2323
+ }
2324
+ /**
2325
+ * The predicate a payment to `address` is locked with: the address's
2326
+ * spending point. Refuses an address encoded for the other network.
2327
+ */
2328
+ public func addressToPredicate(address: String, network: Network)throws -> Data {
2329
+ return try FfiConverterData.lift(try rustCallWithError(FfiConverterTypeFlameError_lift) {
2330
+ uniffiCallStatus in
2331
+ uniffi_flamewallet_ffi_fn_func_address_to_predicate(
2332
+ FfiConverterString.lower(address),
2333
+ FfiConverterTypeNetwork_lower(network),uniffiCallStatus
2334
+ )
2335
+ })
2336
+ }
2337
+ /**
2338
+ * A fresh English mnemonic of `word_count` words: 12, 15, 18, 21 or 24.
2339
+ */
2340
+ public func generateMnemonic(wordCount: UInt8)throws -> String {
2341
+ return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeFlameError_lift) {
2342
+ uniffiCallStatus in
2343
+ uniffi_flamewallet_ffi_fn_func_generate_mnemonic(
2344
+ FfiConverterUInt8.lower(wordCount),uniffiCallStatus
2345
+ )
2346
+ })
2347
+ }
2348
+ /**
2349
+ * The 64-byte BIP-39 seed of `phrase` under `passphrase` (`""` for none).
2350
+ * This seed is what [`Wallet::new`] takes and what an app stores.
2351
+ */
2352
+ public func mnemonicToSeed(phrase: String, passphrase: String)throws -> Data {
2353
+ return try FfiConverterData.lift(try rustCallWithError(FfiConverterTypeFlameError_lift) {
2354
+ uniffiCallStatus in
2355
+ uniffi_flamewallet_ffi_fn_func_mnemonic_to_seed(
2356
+ FfiConverterString.lower(phrase),
2357
+ FfiConverterString.lower(passphrase),uniffiCallStatus
2358
+ )
2359
+ })
2360
+ }
2361
+ /**
2362
+ * Whether `phrase` is a valid mnemonic in any BIP-39 language.
2363
+ */
2364
+ public func validateMnemonic(phrase: String) -> Bool {
2365
+ return try! FfiConverterBool.lift(try! rustCall() {
2366
+ uniffiCallStatus in
2367
+ uniffi_flamewallet_ffi_fn_func_validate_mnemonic(
2368
+ FfiConverterString.lower(phrase),uniffiCallStatus
2369
+ )
2370
+ })
2371
+ }
2372
+
2373
+ private enum InitializationResult {
2374
+ case ok
2375
+ case contractVersionMismatch
2376
+ case apiChecksumMismatch
2377
+ }
2378
+ // Use a global variable to perform the versioning checks. Swift ensures that
2379
+ // the code inside is only computed once.
2380
+ private let initializationResult: InitializationResult = {
2381
+ // Get the bindings contract version from our ComponentInterface
2382
+ let bindings_contract_version = 30
2383
+ // Get the scaffolding contract version by calling the into the dylib
2384
+ let scaffolding_contract_version = ffi_flamewallet_ffi_uniffi_contract_version()
2385
+ if bindings_contract_version != scaffolding_contract_version {
2386
+ return InitializationResult.contractVersionMismatch
2387
+ }
2388
+ if (uniffi_flamewallet_ffi_checksum_func_decode_contract() != 9189) {
2389
+ return InitializationResult.apiChecksumMismatch
2390
+ }
2391
+ if (uniffi_flamewallet_ffi_checksum_func_opening_matches() != 54400) {
2392
+ return InitializationResult.apiChecksumMismatch
2393
+ }
2394
+ if (uniffi_flamewallet_ffi_checksum_func_address_to_predicate() != 27158) {
2395
+ return InitializationResult.apiChecksumMismatch
2396
+ }
2397
+ if (uniffi_flamewallet_ffi_checksum_func_generate_mnemonic() != 49383) {
2398
+ return InitializationResult.apiChecksumMismatch
2399
+ }
2400
+ if (uniffi_flamewallet_ffi_checksum_func_mnemonic_to_seed() != 5184) {
2401
+ return InitializationResult.apiChecksumMismatch
2402
+ }
2403
+ if (uniffi_flamewallet_ffi_checksum_func_validate_mnemonic() != 36978) {
2404
+ return InitializationResult.apiChecksumMismatch
2405
+ }
2406
+ if (uniffi_flamewallet_ffi_checksum_method_wallet_address() != 24772) {
2407
+ return InitializationResult.apiChecksumMismatch
2408
+ }
2409
+ if (uniffi_flamewallet_ffi_checksum_method_wallet_build_transfer() != 41970) {
2410
+ return InitializationResult.apiChecksumMismatch
2411
+ }
2412
+ if (uniffi_flamewallet_ffi_checksum_method_wallet_network() != 6461) {
2413
+ return InitializationResult.apiChecksumMismatch
2414
+ }
2415
+ if (uniffi_flamewallet_ffi_checksum_method_wallet_next_address() != 12667) {
2416
+ return InitializationResult.apiChecksumMismatch
2417
+ }
2418
+ if (uniffi_flamewallet_ffi_checksum_method_wallet_next_index() != 50043) {
2419
+ return InitializationResult.apiChecksumMismatch
2420
+ }
2421
+ if (uniffi_flamewallet_ffi_checksum_method_wallet_open_note() != 45629) {
2422
+ return InitializationResult.apiChecksumMismatch
2423
+ }
2424
+ if (uniffi_flamewallet_ffi_checksum_method_wallet_owns() != 34274) {
2425
+ return InitializationResult.apiChecksumMismatch
2426
+ }
2427
+ if (uniffi_flamewallet_ffi_checksum_method_wallet_receiving_key() != 41950) {
2428
+ return InitializationResult.apiChecksumMismatch
2429
+ }
2430
+ if (uniffi_flamewallet_ffi_checksum_constructor_wallet_from_mnemonic() != 19125) {
2431
+ return InitializationResult.apiChecksumMismatch
2432
+ }
2433
+ if (uniffi_flamewallet_ffi_checksum_constructor_wallet_new() != 9773) {
2434
+ return InitializationResult.apiChecksumMismatch
2435
+ }
2436
+
2437
+ return InitializationResult.ok
2438
+ }()
2439
+
2440
+ // Make the ensure init function public so that other modules which have external type references to
2441
+ // our types can call it.
2442
+ public func uniffiEnsureFlamewalletFfiInitialized() {
2443
+ switch initializationResult {
2444
+ case .ok:
2445
+ break
2446
+ case .contractVersionMismatch:
2447
+ fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project")
2448
+ case .apiChecksumMismatch:
2449
+ fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
2450
+ }
2451
+ }
2452
+
2453
+ // swiftlint:enable all