@keystonehq/react-native-keystone-wallet-core 0.1.0 → 0.1.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.
- package/android/build.gradle +66 -39
- package/android/src/main/java/uniffi/keystone_wallet_core/keystone_wallet_core.kt +2486 -0
- package/android/src/main/jniLibs/arm64-v8a/libkeystone_wallet_core.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libkeystone_wallet_core.so +0 -0
- package/android/src/main/jniLibs/x86/libkeystone_wallet_core.so +0 -0
- package/android/src/main/jniLibs/x86_64/libkeystone_wallet_core.so +0 -0
- package/package.json +1 -1
- package/android/libs/KeystoneWalletCoreWrapper-release.aar +0 -0
|
@@ -0,0 +1,2486 @@
|
|
|
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
|
+
@file:Suppress("NAME_SHADOWING")
|
|
5
|
+
|
|
6
|
+
package uniffi.keystone_wallet_core
|
|
7
|
+
|
|
8
|
+
// Common helper code.
|
|
9
|
+
//
|
|
10
|
+
// Ideally this would live in a separate .kt file where it can be unittested etc
|
|
11
|
+
// in isolation, and perhaps even published as a re-useable package.
|
|
12
|
+
//
|
|
13
|
+
// However, it's important that the details of how this helper code works (e.g. the
|
|
14
|
+
// way that different builtin types are passed across the FFI) exactly match what's
|
|
15
|
+
// expected by the Rust code on the other side of the interface. In practice right
|
|
16
|
+
// now that means coming from the exact some version of `uniffi` that was used to
|
|
17
|
+
// compile the Rust component. The easiest way to ensure this is to bundle the Kotlin
|
|
18
|
+
// helpers directly inline like we're doing here.
|
|
19
|
+
|
|
20
|
+
import com.sun.jna.Callback
|
|
21
|
+
import com.sun.jna.IntegerType
|
|
22
|
+
import com.sun.jna.Library
|
|
23
|
+
import com.sun.jna.Native
|
|
24
|
+
import com.sun.jna.Pointer
|
|
25
|
+
import com.sun.jna.Structure
|
|
26
|
+
import com.sun.jna.ptr.*
|
|
27
|
+
import java.nio.ByteBuffer
|
|
28
|
+
import java.nio.ByteOrder
|
|
29
|
+
import java.nio.CharBuffer
|
|
30
|
+
import java.nio.charset.CodingErrorAction
|
|
31
|
+
import java.util.concurrent.ConcurrentHashMap
|
|
32
|
+
import java.util.concurrent.atomic.AtomicBoolean
|
|
33
|
+
import java.util.concurrent.atomic.AtomicLong
|
|
34
|
+
|
|
35
|
+
// This is a helper for safely working with byte buffers returned from the Rust code.
|
|
36
|
+
// A rust-owned buffer is represented by its capacity, its current length, and a
|
|
37
|
+
// pointer to the underlying data.
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @suppress
|
|
41
|
+
*/
|
|
42
|
+
@Structure.FieldOrder("capacity", "len", "data")
|
|
43
|
+
open class RustBuffer : Structure() {
|
|
44
|
+
// Note: `capacity` and `len` are actually `ULong` values, but JVM only supports signed values.
|
|
45
|
+
// When dealing with these fields, make sure to call `toULong()`.
|
|
46
|
+
@JvmField var capacity: Long = 0
|
|
47
|
+
|
|
48
|
+
@JvmField var len: Long = 0
|
|
49
|
+
|
|
50
|
+
@JvmField var data: Pointer? = null
|
|
51
|
+
|
|
52
|
+
class ByValue :
|
|
53
|
+
RustBuffer(),
|
|
54
|
+
Structure.ByValue
|
|
55
|
+
|
|
56
|
+
class ByReference :
|
|
57
|
+
RustBuffer(),
|
|
58
|
+
Structure.ByReference
|
|
59
|
+
|
|
60
|
+
internal fun setValue(other: RustBuffer) {
|
|
61
|
+
capacity = other.capacity
|
|
62
|
+
len = other.len
|
|
63
|
+
data = other.data
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
companion object {
|
|
67
|
+
internal fun alloc(size: ULong = 0UL) =
|
|
68
|
+
uniffiRustCall { status ->
|
|
69
|
+
// Note: need to convert the size to a `Long` value to make this work with JVM.
|
|
70
|
+
UniffiLib.INSTANCE.ffi_keystone_wallet_core_rustbuffer_alloc(size.toLong(), status)
|
|
71
|
+
}.also {
|
|
72
|
+
if (it.data == null) {
|
|
73
|
+
throw RuntimeException("RustBuffer.alloc() returned null data pointer (size=$size)")
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
internal fun create(
|
|
78
|
+
capacity: ULong,
|
|
79
|
+
len: ULong,
|
|
80
|
+
data: Pointer?,
|
|
81
|
+
): RustBuffer.ByValue {
|
|
82
|
+
var buf = RustBuffer.ByValue()
|
|
83
|
+
buf.capacity = capacity.toLong()
|
|
84
|
+
buf.len = len.toLong()
|
|
85
|
+
buf.data = data
|
|
86
|
+
return buf
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
internal fun free(buf: RustBuffer.ByValue) =
|
|
90
|
+
uniffiRustCall { status ->
|
|
91
|
+
UniffiLib.INSTANCE.ffi_keystone_wallet_core_rustbuffer_free(buf, status)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@Suppress("TooGenericExceptionThrown")
|
|
96
|
+
fun asByteBuffer() =
|
|
97
|
+
this.data?.getByteBuffer(0, this.len.toLong())?.also {
|
|
98
|
+
it.order(ByteOrder.BIG_ENDIAN)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The equivalent of the `*mut RustBuffer` type.
|
|
104
|
+
* Required for callbacks taking in an out pointer.
|
|
105
|
+
*
|
|
106
|
+
* Size is the sum of all values in the struct.
|
|
107
|
+
*
|
|
108
|
+
* @suppress
|
|
109
|
+
*/
|
|
110
|
+
class RustBufferByReference : ByReference(16) {
|
|
111
|
+
/**
|
|
112
|
+
* Set the pointed-to `RustBuffer` to the given value.
|
|
113
|
+
*/
|
|
114
|
+
fun setValue(value: RustBuffer.ByValue) {
|
|
115
|
+
// NOTE: The offsets are as they are in the C-like struct.
|
|
116
|
+
val pointer = getPointer()
|
|
117
|
+
pointer.setLong(0, value.capacity)
|
|
118
|
+
pointer.setLong(8, value.len)
|
|
119
|
+
pointer.setPointer(16, value.data)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Get a `RustBuffer.ByValue` from this reference.
|
|
124
|
+
*/
|
|
125
|
+
fun getValue(): RustBuffer.ByValue {
|
|
126
|
+
val pointer = getPointer()
|
|
127
|
+
val value = RustBuffer.ByValue()
|
|
128
|
+
value.writeField("capacity", pointer.getLong(0))
|
|
129
|
+
value.writeField("len", pointer.getLong(8))
|
|
130
|
+
value.writeField("data", pointer.getLong(16))
|
|
131
|
+
|
|
132
|
+
return value
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// This is a helper for safely passing byte references into the rust code.
|
|
137
|
+
// It's not actually used at the moment, because there aren't many things that you
|
|
138
|
+
// can take a direct pointer to in the JVM, and if we're going to copy something
|
|
139
|
+
// then we might as well copy it into a `RustBuffer`. But it's here for API
|
|
140
|
+
// completeness.
|
|
141
|
+
|
|
142
|
+
@Structure.FieldOrder("len", "data")
|
|
143
|
+
internal open class ForeignBytes : Structure() {
|
|
144
|
+
@JvmField var len: Int = 0
|
|
145
|
+
|
|
146
|
+
@JvmField var data: Pointer? = null
|
|
147
|
+
|
|
148
|
+
class ByValue :
|
|
149
|
+
ForeignBytes(),
|
|
150
|
+
Structure.ByValue
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* The FfiConverter interface handles converter types to and from the FFI
|
|
155
|
+
*
|
|
156
|
+
* All implementing objects should be public to support external types. When a
|
|
157
|
+
* type is external we need to import it's FfiConverter.
|
|
158
|
+
*
|
|
159
|
+
* @suppress
|
|
160
|
+
*/
|
|
161
|
+
public interface FfiConverter<KotlinType, FfiType> {
|
|
162
|
+
// Convert an FFI type to a Kotlin type
|
|
163
|
+
fun lift(value: FfiType): KotlinType
|
|
164
|
+
|
|
165
|
+
// Convert an Kotlin type to an FFI type
|
|
166
|
+
fun lower(value: KotlinType): FfiType
|
|
167
|
+
|
|
168
|
+
// Read a Kotlin type from a `ByteBuffer`
|
|
169
|
+
fun read(buf: ByteBuffer): KotlinType
|
|
170
|
+
|
|
171
|
+
// Calculate bytes to allocate when creating a `RustBuffer`
|
|
172
|
+
//
|
|
173
|
+
// This must return at least as many bytes as the write() function will
|
|
174
|
+
// write. It can return more bytes than needed, for example when writing
|
|
175
|
+
// Strings we can't know the exact bytes needed until we the UTF-8
|
|
176
|
+
// encoding, so we pessimistically allocate the largest size possible (3
|
|
177
|
+
// bytes per codepoint). Allocating extra bytes is not really a big deal
|
|
178
|
+
// because the `RustBuffer` is short-lived.
|
|
179
|
+
fun allocationSize(value: KotlinType): ULong
|
|
180
|
+
|
|
181
|
+
// Write a Kotlin type to a `ByteBuffer`
|
|
182
|
+
fun write(
|
|
183
|
+
value: KotlinType,
|
|
184
|
+
buf: ByteBuffer,
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
// Lower a value into a `RustBuffer`
|
|
188
|
+
//
|
|
189
|
+
// This method lowers a value into a `RustBuffer` rather than the normal
|
|
190
|
+
// FfiType. It's used by the callback interface code. Callback interface
|
|
191
|
+
// returns are always serialized into a `RustBuffer` regardless of their
|
|
192
|
+
// normal FFI type.
|
|
193
|
+
fun lowerIntoRustBuffer(value: KotlinType): RustBuffer.ByValue {
|
|
194
|
+
val rbuf = RustBuffer.alloc(allocationSize(value))
|
|
195
|
+
try {
|
|
196
|
+
val bbuf =
|
|
197
|
+
rbuf.data!!.getByteBuffer(0, rbuf.capacity).also {
|
|
198
|
+
it.order(ByteOrder.BIG_ENDIAN)
|
|
199
|
+
}
|
|
200
|
+
write(value, bbuf)
|
|
201
|
+
rbuf.writeField("len", bbuf.position().toLong())
|
|
202
|
+
return rbuf
|
|
203
|
+
} catch (e: Throwable) {
|
|
204
|
+
RustBuffer.free(rbuf)
|
|
205
|
+
throw e
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Lift a value from a `RustBuffer`.
|
|
210
|
+
//
|
|
211
|
+
// This here mostly because of the symmetry with `lowerIntoRustBuffer()`.
|
|
212
|
+
// It's currently only used by the `FfiConverterRustBuffer` class below.
|
|
213
|
+
fun liftFromRustBuffer(rbuf: RustBuffer.ByValue): KotlinType {
|
|
214
|
+
val byteBuf = rbuf.asByteBuffer()!!
|
|
215
|
+
try {
|
|
216
|
+
val item = read(byteBuf)
|
|
217
|
+
if (byteBuf.hasRemaining()) {
|
|
218
|
+
throw RuntimeException("junk remaining in buffer after lifting, something is very wrong!!")
|
|
219
|
+
}
|
|
220
|
+
return item
|
|
221
|
+
} finally {
|
|
222
|
+
RustBuffer.free(rbuf)
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* FfiConverter that uses `RustBuffer` as the FfiType
|
|
229
|
+
*
|
|
230
|
+
* @suppress
|
|
231
|
+
*/
|
|
232
|
+
public interface FfiConverterRustBuffer<KotlinType> : FfiConverter<KotlinType, RustBuffer.ByValue> {
|
|
233
|
+
override fun lift(value: RustBuffer.ByValue) = liftFromRustBuffer(value)
|
|
234
|
+
|
|
235
|
+
override fun lower(value: KotlinType) = lowerIntoRustBuffer(value)
|
|
236
|
+
}
|
|
237
|
+
// A handful of classes and functions to support the generated data structures.
|
|
238
|
+
// This would be a good candidate for isolating in its own ffi-support lib.
|
|
239
|
+
|
|
240
|
+
internal const val UNIFFI_CALL_SUCCESS = 0.toByte()
|
|
241
|
+
internal const val UNIFFI_CALL_ERROR = 1.toByte()
|
|
242
|
+
internal const val UNIFFI_CALL_UNEXPECTED_ERROR = 2.toByte()
|
|
243
|
+
|
|
244
|
+
@Structure.FieldOrder("code", "error_buf")
|
|
245
|
+
internal open class UniffiRustCallStatus : Structure() {
|
|
246
|
+
@JvmField var code: Byte = 0
|
|
247
|
+
|
|
248
|
+
@JvmField var error_buf: RustBuffer.ByValue = RustBuffer.ByValue()
|
|
249
|
+
|
|
250
|
+
class ByValue :
|
|
251
|
+
UniffiRustCallStatus(),
|
|
252
|
+
Structure.ByValue
|
|
253
|
+
|
|
254
|
+
fun isSuccess(): Boolean = code == UNIFFI_CALL_SUCCESS
|
|
255
|
+
|
|
256
|
+
fun isError(): Boolean = code == UNIFFI_CALL_ERROR
|
|
257
|
+
|
|
258
|
+
fun isPanic(): Boolean = code == UNIFFI_CALL_UNEXPECTED_ERROR
|
|
259
|
+
|
|
260
|
+
companion object {
|
|
261
|
+
fun create(
|
|
262
|
+
code: Byte,
|
|
263
|
+
errorBuf: RustBuffer.ByValue,
|
|
264
|
+
): UniffiRustCallStatus.ByValue {
|
|
265
|
+
val callStatus = UniffiRustCallStatus.ByValue()
|
|
266
|
+
callStatus.code = code
|
|
267
|
+
callStatus.error_buf = errorBuf
|
|
268
|
+
return callStatus
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
class InternalException(
|
|
274
|
+
message: String,
|
|
275
|
+
) : kotlin.Exception(message)
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Each top-level error class has a companion object that can lift the error from the call status's rust buffer
|
|
279
|
+
*
|
|
280
|
+
* @suppress
|
|
281
|
+
*/
|
|
282
|
+
interface UniffiRustCallStatusErrorHandler<E> {
|
|
283
|
+
fun lift(error_buf: RustBuffer.ByValue): E
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// Helpers for calling Rust
|
|
287
|
+
// In practice we usually need to be synchronized to call this safely, so it doesn't
|
|
288
|
+
// synchronize itself
|
|
289
|
+
|
|
290
|
+
// Call a rust function that returns a Result<>. Pass in the Error class companion that corresponds to the Err
|
|
291
|
+
private inline fun <U, E : kotlin.Exception> uniffiRustCallWithError(
|
|
292
|
+
errorHandler: UniffiRustCallStatusErrorHandler<E>,
|
|
293
|
+
callback: (UniffiRustCallStatus) -> U,
|
|
294
|
+
): U {
|
|
295
|
+
var status = UniffiRustCallStatus()
|
|
296
|
+
val return_value = callback(status)
|
|
297
|
+
uniffiCheckCallStatus(errorHandler, status)
|
|
298
|
+
return return_value
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// Check UniffiRustCallStatus and throw an error if the call wasn't successful
|
|
302
|
+
private fun <E : kotlin.Exception> uniffiCheckCallStatus(
|
|
303
|
+
errorHandler: UniffiRustCallStatusErrorHandler<E>,
|
|
304
|
+
status: UniffiRustCallStatus,
|
|
305
|
+
) {
|
|
306
|
+
if (status.isSuccess()) {
|
|
307
|
+
return
|
|
308
|
+
} else if (status.isError()) {
|
|
309
|
+
throw errorHandler.lift(status.error_buf)
|
|
310
|
+
} else if (status.isPanic()) {
|
|
311
|
+
// when the rust code sees a panic, it tries to construct a rustbuffer
|
|
312
|
+
// with the message. but if that code panics, then it just sends back
|
|
313
|
+
// an empty buffer.
|
|
314
|
+
if (status.error_buf.len > 0) {
|
|
315
|
+
throw InternalException(FfiConverterString.lift(status.error_buf))
|
|
316
|
+
} else {
|
|
317
|
+
throw InternalException("Rust panic")
|
|
318
|
+
}
|
|
319
|
+
} else {
|
|
320
|
+
throw InternalException("Unknown rust call status: $status.code")
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* UniffiRustCallStatusErrorHandler implementation for times when we don't expect a CALL_ERROR
|
|
326
|
+
*
|
|
327
|
+
* @suppress
|
|
328
|
+
*/
|
|
329
|
+
object UniffiNullRustCallStatusErrorHandler : UniffiRustCallStatusErrorHandler<InternalException> {
|
|
330
|
+
override fun lift(error_buf: RustBuffer.ByValue): InternalException {
|
|
331
|
+
RustBuffer.free(error_buf)
|
|
332
|
+
return InternalException("Unexpected CALL_ERROR")
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// Call a rust function that returns a plain value
|
|
337
|
+
private inline fun <U> uniffiRustCall(callback: (UniffiRustCallStatus) -> U): U =
|
|
338
|
+
uniffiRustCallWithError(UniffiNullRustCallStatusErrorHandler, callback)
|
|
339
|
+
|
|
340
|
+
internal inline fun <T> uniffiTraitInterfaceCall(
|
|
341
|
+
callStatus: UniffiRustCallStatus,
|
|
342
|
+
makeCall: () -> T,
|
|
343
|
+
writeReturn: (T) -> Unit,
|
|
344
|
+
) {
|
|
345
|
+
try {
|
|
346
|
+
writeReturn(makeCall())
|
|
347
|
+
} catch (e: kotlin.Exception) {
|
|
348
|
+
callStatus.code = UNIFFI_CALL_UNEXPECTED_ERROR
|
|
349
|
+
callStatus.error_buf = FfiConverterString.lower(e.toString())
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
internal inline fun <T, reified E : Throwable> uniffiTraitInterfaceCallWithError(
|
|
354
|
+
callStatus: UniffiRustCallStatus,
|
|
355
|
+
makeCall: () -> T,
|
|
356
|
+
writeReturn: (T) -> Unit,
|
|
357
|
+
lowerError: (E) -> RustBuffer.ByValue,
|
|
358
|
+
) {
|
|
359
|
+
try {
|
|
360
|
+
writeReturn(makeCall())
|
|
361
|
+
} catch (e: kotlin.Exception) {
|
|
362
|
+
if (e is E) {
|
|
363
|
+
callStatus.code = UNIFFI_CALL_ERROR
|
|
364
|
+
callStatus.error_buf = lowerError(e)
|
|
365
|
+
} else {
|
|
366
|
+
callStatus.code = UNIFFI_CALL_UNEXPECTED_ERROR
|
|
367
|
+
callStatus.error_buf = FfiConverterString.lower(e.toString())
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// Map handles to objects
|
|
373
|
+
//
|
|
374
|
+
// This is used pass an opaque 64-bit handle representing a foreign object to the Rust code.
|
|
375
|
+
internal class UniffiHandleMap<T : Any> {
|
|
376
|
+
private val map = ConcurrentHashMap<Long, T>()
|
|
377
|
+
private val counter =
|
|
378
|
+
java.util.concurrent.atomic
|
|
379
|
+
.AtomicLong(0)
|
|
380
|
+
|
|
381
|
+
val size: Int
|
|
382
|
+
get() = map.size
|
|
383
|
+
|
|
384
|
+
// Insert a new object into the handle map and get a handle for it
|
|
385
|
+
fun insert(obj: T): Long {
|
|
386
|
+
val handle = counter.getAndAdd(1)
|
|
387
|
+
map.put(handle, obj)
|
|
388
|
+
return handle
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// Get an object from the handle map
|
|
392
|
+
fun get(handle: Long): T = map.get(handle) ?: throw InternalException("UniffiHandleMap.get: Invalid handle")
|
|
393
|
+
|
|
394
|
+
// Remove an entry from the handlemap and get the Kotlin object back
|
|
395
|
+
fun remove(handle: Long): T = map.remove(handle) ?: throw InternalException("UniffiHandleMap: Invalid handle")
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// Contains loading, initialization code,
|
|
399
|
+
// and the FFI Function declarations in a com.sun.jna.Library.
|
|
400
|
+
@Synchronized
|
|
401
|
+
private fun findLibraryName(componentName: String): String {
|
|
402
|
+
val libOverride = System.getProperty("uniffi.component.$componentName.libraryOverride")
|
|
403
|
+
if (libOverride != null) {
|
|
404
|
+
return libOverride
|
|
405
|
+
}
|
|
406
|
+
return "keystone_wallet_core"
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
private inline fun <reified Lib : Library> loadIndirect(componentName: String): Lib =
|
|
410
|
+
Native.load<Lib>(findLibraryName(componentName), Lib::class.java)
|
|
411
|
+
|
|
412
|
+
// Define FFI callback types
|
|
413
|
+
internal interface UniffiRustFutureContinuationCallback : com.sun.jna.Callback {
|
|
414
|
+
fun callback(
|
|
415
|
+
`data`: Long,
|
|
416
|
+
`pollResult`: Byte,
|
|
417
|
+
)
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
internal interface UniffiForeignFutureFree : com.sun.jna.Callback {
|
|
421
|
+
fun callback(`handle`: Long)
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
internal interface UniffiCallbackInterfaceFree : com.sun.jna.Callback {
|
|
425
|
+
fun callback(`handle`: Long)
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
@Structure.FieldOrder("handle", "free")
|
|
429
|
+
internal open class UniffiForeignFuture(
|
|
430
|
+
@JvmField internal var `handle`: Long = 0.toLong(),
|
|
431
|
+
@JvmField internal var `free`: UniffiForeignFutureFree? = null,
|
|
432
|
+
) : Structure() {
|
|
433
|
+
class UniffiByValue(
|
|
434
|
+
`handle`: Long = 0.toLong(),
|
|
435
|
+
`free`: UniffiForeignFutureFree? = null,
|
|
436
|
+
) : UniffiForeignFuture(`handle`, `free`),
|
|
437
|
+
Structure.ByValue
|
|
438
|
+
|
|
439
|
+
internal fun uniffiSetValue(other: UniffiForeignFuture) {
|
|
440
|
+
`handle` = other.`handle`
|
|
441
|
+
`free` = other.`free`
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
@Structure.FieldOrder("returnValue", "callStatus")
|
|
446
|
+
internal open class UniffiForeignFutureStructU8(
|
|
447
|
+
@JvmField internal var `returnValue`: Byte = 0.toByte(),
|
|
448
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
449
|
+
) : Structure() {
|
|
450
|
+
class UniffiByValue(
|
|
451
|
+
`returnValue`: Byte = 0.toByte(),
|
|
452
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
453
|
+
) : UniffiForeignFutureStructU8(`returnValue`, `callStatus`),
|
|
454
|
+
Structure.ByValue
|
|
455
|
+
|
|
456
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructU8) {
|
|
457
|
+
`returnValue` = other.`returnValue`
|
|
458
|
+
`callStatus` = other.`callStatus`
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
internal interface UniffiForeignFutureCompleteU8 : com.sun.jna.Callback {
|
|
463
|
+
fun callback(
|
|
464
|
+
`callbackData`: Long,
|
|
465
|
+
`result`: UniffiForeignFutureStructU8.UniffiByValue,
|
|
466
|
+
)
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
@Structure.FieldOrder("returnValue", "callStatus")
|
|
470
|
+
internal open class UniffiForeignFutureStructI8(
|
|
471
|
+
@JvmField internal var `returnValue`: Byte = 0.toByte(),
|
|
472
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
473
|
+
) : Structure() {
|
|
474
|
+
class UniffiByValue(
|
|
475
|
+
`returnValue`: Byte = 0.toByte(),
|
|
476
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
477
|
+
) : UniffiForeignFutureStructI8(`returnValue`, `callStatus`),
|
|
478
|
+
Structure.ByValue
|
|
479
|
+
|
|
480
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructI8) {
|
|
481
|
+
`returnValue` = other.`returnValue`
|
|
482
|
+
`callStatus` = other.`callStatus`
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
internal interface UniffiForeignFutureCompleteI8 : com.sun.jna.Callback {
|
|
487
|
+
fun callback(
|
|
488
|
+
`callbackData`: Long,
|
|
489
|
+
`result`: UniffiForeignFutureStructI8.UniffiByValue,
|
|
490
|
+
)
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
@Structure.FieldOrder("returnValue", "callStatus")
|
|
494
|
+
internal open class UniffiForeignFutureStructU16(
|
|
495
|
+
@JvmField internal var `returnValue`: Short = 0.toShort(),
|
|
496
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
497
|
+
) : Structure() {
|
|
498
|
+
class UniffiByValue(
|
|
499
|
+
`returnValue`: Short = 0.toShort(),
|
|
500
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
501
|
+
) : UniffiForeignFutureStructU16(`returnValue`, `callStatus`),
|
|
502
|
+
Structure.ByValue
|
|
503
|
+
|
|
504
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructU16) {
|
|
505
|
+
`returnValue` = other.`returnValue`
|
|
506
|
+
`callStatus` = other.`callStatus`
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
internal interface UniffiForeignFutureCompleteU16 : com.sun.jna.Callback {
|
|
511
|
+
fun callback(
|
|
512
|
+
`callbackData`: Long,
|
|
513
|
+
`result`: UniffiForeignFutureStructU16.UniffiByValue,
|
|
514
|
+
)
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
@Structure.FieldOrder("returnValue", "callStatus")
|
|
518
|
+
internal open class UniffiForeignFutureStructI16(
|
|
519
|
+
@JvmField internal var `returnValue`: Short = 0.toShort(),
|
|
520
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
521
|
+
) : Structure() {
|
|
522
|
+
class UniffiByValue(
|
|
523
|
+
`returnValue`: Short = 0.toShort(),
|
|
524
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
525
|
+
) : UniffiForeignFutureStructI16(`returnValue`, `callStatus`),
|
|
526
|
+
Structure.ByValue
|
|
527
|
+
|
|
528
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructI16) {
|
|
529
|
+
`returnValue` = other.`returnValue`
|
|
530
|
+
`callStatus` = other.`callStatus`
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
internal interface UniffiForeignFutureCompleteI16 : com.sun.jna.Callback {
|
|
535
|
+
fun callback(
|
|
536
|
+
`callbackData`: Long,
|
|
537
|
+
`result`: UniffiForeignFutureStructI16.UniffiByValue,
|
|
538
|
+
)
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
@Structure.FieldOrder("returnValue", "callStatus")
|
|
542
|
+
internal open class UniffiForeignFutureStructU32(
|
|
543
|
+
@JvmField internal var `returnValue`: Int = 0,
|
|
544
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
545
|
+
) : Structure() {
|
|
546
|
+
class UniffiByValue(
|
|
547
|
+
`returnValue`: Int = 0,
|
|
548
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
549
|
+
) : UniffiForeignFutureStructU32(`returnValue`, `callStatus`),
|
|
550
|
+
Structure.ByValue
|
|
551
|
+
|
|
552
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructU32) {
|
|
553
|
+
`returnValue` = other.`returnValue`
|
|
554
|
+
`callStatus` = other.`callStatus`
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
internal interface UniffiForeignFutureCompleteU32 : com.sun.jna.Callback {
|
|
559
|
+
fun callback(
|
|
560
|
+
`callbackData`: Long,
|
|
561
|
+
`result`: UniffiForeignFutureStructU32.UniffiByValue,
|
|
562
|
+
)
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
@Structure.FieldOrder("returnValue", "callStatus")
|
|
566
|
+
internal open class UniffiForeignFutureStructI32(
|
|
567
|
+
@JvmField internal var `returnValue`: Int = 0,
|
|
568
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
569
|
+
) : Structure() {
|
|
570
|
+
class UniffiByValue(
|
|
571
|
+
`returnValue`: Int = 0,
|
|
572
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
573
|
+
) : UniffiForeignFutureStructI32(`returnValue`, `callStatus`),
|
|
574
|
+
Structure.ByValue
|
|
575
|
+
|
|
576
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructI32) {
|
|
577
|
+
`returnValue` = other.`returnValue`
|
|
578
|
+
`callStatus` = other.`callStatus`
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
internal interface UniffiForeignFutureCompleteI32 : com.sun.jna.Callback {
|
|
583
|
+
fun callback(
|
|
584
|
+
`callbackData`: Long,
|
|
585
|
+
`result`: UniffiForeignFutureStructI32.UniffiByValue,
|
|
586
|
+
)
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
@Structure.FieldOrder("returnValue", "callStatus")
|
|
590
|
+
internal open class UniffiForeignFutureStructU64(
|
|
591
|
+
@JvmField internal var `returnValue`: Long = 0.toLong(),
|
|
592
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
593
|
+
) : Structure() {
|
|
594
|
+
class UniffiByValue(
|
|
595
|
+
`returnValue`: Long = 0.toLong(),
|
|
596
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
597
|
+
) : UniffiForeignFutureStructU64(`returnValue`, `callStatus`),
|
|
598
|
+
Structure.ByValue
|
|
599
|
+
|
|
600
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructU64) {
|
|
601
|
+
`returnValue` = other.`returnValue`
|
|
602
|
+
`callStatus` = other.`callStatus`
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
internal interface UniffiForeignFutureCompleteU64 : com.sun.jna.Callback {
|
|
607
|
+
fun callback(
|
|
608
|
+
`callbackData`: Long,
|
|
609
|
+
`result`: UniffiForeignFutureStructU64.UniffiByValue,
|
|
610
|
+
)
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
@Structure.FieldOrder("returnValue", "callStatus")
|
|
614
|
+
internal open class UniffiForeignFutureStructI64(
|
|
615
|
+
@JvmField internal var `returnValue`: Long = 0.toLong(),
|
|
616
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
617
|
+
) : Structure() {
|
|
618
|
+
class UniffiByValue(
|
|
619
|
+
`returnValue`: Long = 0.toLong(),
|
|
620
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
621
|
+
) : UniffiForeignFutureStructI64(`returnValue`, `callStatus`),
|
|
622
|
+
Structure.ByValue
|
|
623
|
+
|
|
624
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructI64) {
|
|
625
|
+
`returnValue` = other.`returnValue`
|
|
626
|
+
`callStatus` = other.`callStatus`
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
internal interface UniffiForeignFutureCompleteI64 : com.sun.jna.Callback {
|
|
631
|
+
fun callback(
|
|
632
|
+
`callbackData`: Long,
|
|
633
|
+
`result`: UniffiForeignFutureStructI64.UniffiByValue,
|
|
634
|
+
)
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
@Structure.FieldOrder("returnValue", "callStatus")
|
|
638
|
+
internal open class UniffiForeignFutureStructF32(
|
|
639
|
+
@JvmField internal var `returnValue`: Float = 0.0f,
|
|
640
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
641
|
+
) : Structure() {
|
|
642
|
+
class UniffiByValue(
|
|
643
|
+
`returnValue`: Float = 0.0f,
|
|
644
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
645
|
+
) : UniffiForeignFutureStructF32(`returnValue`, `callStatus`),
|
|
646
|
+
Structure.ByValue
|
|
647
|
+
|
|
648
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructF32) {
|
|
649
|
+
`returnValue` = other.`returnValue`
|
|
650
|
+
`callStatus` = other.`callStatus`
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
internal interface UniffiForeignFutureCompleteF32 : com.sun.jna.Callback {
|
|
655
|
+
fun callback(
|
|
656
|
+
`callbackData`: Long,
|
|
657
|
+
`result`: UniffiForeignFutureStructF32.UniffiByValue,
|
|
658
|
+
)
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
@Structure.FieldOrder("returnValue", "callStatus")
|
|
662
|
+
internal open class UniffiForeignFutureStructF64(
|
|
663
|
+
@JvmField internal var `returnValue`: Double = 0.0,
|
|
664
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
665
|
+
) : Structure() {
|
|
666
|
+
class UniffiByValue(
|
|
667
|
+
`returnValue`: Double = 0.0,
|
|
668
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
669
|
+
) : UniffiForeignFutureStructF64(`returnValue`, `callStatus`),
|
|
670
|
+
Structure.ByValue
|
|
671
|
+
|
|
672
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructF64) {
|
|
673
|
+
`returnValue` = other.`returnValue`
|
|
674
|
+
`callStatus` = other.`callStatus`
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
internal interface UniffiForeignFutureCompleteF64 : com.sun.jna.Callback {
|
|
679
|
+
fun callback(
|
|
680
|
+
`callbackData`: Long,
|
|
681
|
+
`result`: UniffiForeignFutureStructF64.UniffiByValue,
|
|
682
|
+
)
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
@Structure.FieldOrder("returnValue", "callStatus")
|
|
686
|
+
internal open class UniffiForeignFutureStructPointer(
|
|
687
|
+
@JvmField internal var `returnValue`: Pointer = Pointer.NULL,
|
|
688
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
689
|
+
) : Structure() {
|
|
690
|
+
class UniffiByValue(
|
|
691
|
+
`returnValue`: Pointer = Pointer.NULL,
|
|
692
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
693
|
+
) : UniffiForeignFutureStructPointer(`returnValue`, `callStatus`),
|
|
694
|
+
Structure.ByValue
|
|
695
|
+
|
|
696
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructPointer) {
|
|
697
|
+
`returnValue` = other.`returnValue`
|
|
698
|
+
`callStatus` = other.`callStatus`
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
internal interface UniffiForeignFutureCompletePointer : com.sun.jna.Callback {
|
|
703
|
+
fun callback(
|
|
704
|
+
`callbackData`: Long,
|
|
705
|
+
`result`: UniffiForeignFutureStructPointer.UniffiByValue,
|
|
706
|
+
)
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
@Structure.FieldOrder("returnValue", "callStatus")
|
|
710
|
+
internal open class UniffiForeignFutureStructRustBuffer(
|
|
711
|
+
@JvmField internal var `returnValue`: RustBuffer.ByValue = RustBuffer.ByValue(),
|
|
712
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
713
|
+
) : Structure() {
|
|
714
|
+
class UniffiByValue(
|
|
715
|
+
`returnValue`: RustBuffer.ByValue = RustBuffer.ByValue(),
|
|
716
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
717
|
+
) : UniffiForeignFutureStructRustBuffer(`returnValue`, `callStatus`),
|
|
718
|
+
Structure.ByValue
|
|
719
|
+
|
|
720
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructRustBuffer) {
|
|
721
|
+
`returnValue` = other.`returnValue`
|
|
722
|
+
`callStatus` = other.`callStatus`
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
internal interface UniffiForeignFutureCompleteRustBuffer : com.sun.jna.Callback {
|
|
727
|
+
fun callback(
|
|
728
|
+
`callbackData`: Long,
|
|
729
|
+
`result`: UniffiForeignFutureStructRustBuffer.UniffiByValue,
|
|
730
|
+
)
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
@Structure.FieldOrder("callStatus")
|
|
734
|
+
internal open class UniffiForeignFutureStructVoid(
|
|
735
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
736
|
+
) : Structure() {
|
|
737
|
+
class UniffiByValue(
|
|
738
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
739
|
+
) : UniffiForeignFutureStructVoid(`callStatus`),
|
|
740
|
+
Structure.ByValue
|
|
741
|
+
|
|
742
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructVoid) {
|
|
743
|
+
`callStatus` = other.`callStatus`
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
internal interface UniffiForeignFutureCompleteVoid : com.sun.jna.Callback {
|
|
748
|
+
fun callback(
|
|
749
|
+
`callbackData`: Long,
|
|
750
|
+
`result`: UniffiForeignFutureStructVoid.UniffiByValue,
|
|
751
|
+
)
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
// A JNA Library to expose the extern-C FFI definitions.
|
|
755
|
+
// This is an implementation detail which will be called internally by the public API.
|
|
756
|
+
|
|
757
|
+
internal interface UniffiLib : Library {
|
|
758
|
+
companion object {
|
|
759
|
+
internal val INSTANCE: UniffiLib by lazy {
|
|
760
|
+
loadIndirect<UniffiLib>(componentName = "keystone_wallet_core")
|
|
761
|
+
.also { lib: UniffiLib ->
|
|
762
|
+
uniffiCheckContractApiVersion(lib)
|
|
763
|
+
uniffiCheckApiChecksums(lib)
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
// The Cleaner for the whole library
|
|
768
|
+
internal val CLEANER: UniffiCleaner by lazy {
|
|
769
|
+
UniffiCleaner.create()
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
fun uniffi_keystone_wallet_core_fn_clone_pczt(
|
|
774
|
+
`ptr`: Pointer,
|
|
775
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
776
|
+
): Pointer
|
|
777
|
+
|
|
778
|
+
fun uniffi_keystone_wallet_core_fn_free_pczt(
|
|
779
|
+
`ptr`: Pointer,
|
|
780
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
781
|
+
): Unit
|
|
782
|
+
|
|
783
|
+
fun uniffi_keystone_wallet_core_fn_method_pczt_serialize(
|
|
784
|
+
`ptr`: Pointer,
|
|
785
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
786
|
+
): RustBuffer.ByValue
|
|
787
|
+
|
|
788
|
+
fun uniffi_keystone_wallet_core_fn_func_assemble_transaction_ada(
|
|
789
|
+
`rawTxHex`: RustBuffer.ByValue,
|
|
790
|
+
`witnessSetHex`: RustBuffer.ByValue,
|
|
791
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
792
|
+
): RustBuffer.ByValue
|
|
793
|
+
|
|
794
|
+
fun uniffi_keystone_wallet_core_fn_func_compose_transaction_ada(
|
|
795
|
+
`inputs`: RustBuffer.ByValue,
|
|
796
|
+
`outputs`: RustBuffer.ByValue,
|
|
797
|
+
`changeAddress`: RustBuffer.ByValue,
|
|
798
|
+
`fee`: Long,
|
|
799
|
+
`ttl`: Long,
|
|
800
|
+
`network`: RustBuffer.ByValue,
|
|
801
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
802
|
+
): RustBuffer.ByValue
|
|
803
|
+
|
|
804
|
+
fun uniffi_keystone_wallet_core_fn_func_create_pczt(
|
|
805
|
+
`consensusBranchId`: Int,
|
|
806
|
+
`expiryHeight`: Int,
|
|
807
|
+
`coinType`: Int,
|
|
808
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
809
|
+
): Pointer
|
|
810
|
+
|
|
811
|
+
fun uniffi_keystone_wallet_core_fn_func_create_transparent_pczt(
|
|
812
|
+
`inputs`: RustBuffer.ByValue,
|
|
813
|
+
`outputs`: RustBuffer.ByValue,
|
|
814
|
+
`blockHeight`: Int,
|
|
815
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
816
|
+
): RustBuffer.ByValue
|
|
817
|
+
|
|
818
|
+
fun uniffi_keystone_wallet_core_fn_func_create_transparent_pczt_for_swapkit(
|
|
819
|
+
`pcztHex`: RustBuffer.ByValue,
|
|
820
|
+
`blockHeight`: Int,
|
|
821
|
+
`pubkeyHex`: RustBuffer.ByValue,
|
|
822
|
+
`fingerprintHex`: RustBuffer.ByValue,
|
|
823
|
+
`pathStr`: RustBuffer.ByValue,
|
|
824
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
825
|
+
): RustBuffer.ByValue
|
|
826
|
+
|
|
827
|
+
fun uniffi_keystone_wallet_core_fn_func_derive_address_by_path_ada(
|
|
828
|
+
`accountXpubHex`: RustBuffer.ByValue,
|
|
829
|
+
`path`: RustBuffer.ByValue,
|
|
830
|
+
`network`: RustBuffer.ByValue,
|
|
831
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
832
|
+
): RustBuffer.ByValue
|
|
833
|
+
|
|
834
|
+
fun uniffi_keystone_wallet_core_fn_func_derive_enterprise_address_by_path_ada(
|
|
835
|
+
`accountXpubHex`: RustBuffer.ByValue,
|
|
836
|
+
`path`: RustBuffer.ByValue,
|
|
837
|
+
`network`: RustBuffer.ByValue,
|
|
838
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
839
|
+
): RustBuffer.ByValue
|
|
840
|
+
|
|
841
|
+
fun uniffi_keystone_wallet_core_fn_func_derive_pubkey_by_path_ada(
|
|
842
|
+
`accountXpubHex`: RustBuffer.ByValue,
|
|
843
|
+
`path`: RustBuffer.ByValue,
|
|
844
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
845
|
+
): RustBuffer.ByValue
|
|
846
|
+
|
|
847
|
+
fun uniffi_keystone_wallet_core_fn_func_derive_stake_address_ada(
|
|
848
|
+
`accountXpubHex`: RustBuffer.ByValue,
|
|
849
|
+
`network`: RustBuffer.ByValue,
|
|
850
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
851
|
+
): RustBuffer.ByValue
|
|
852
|
+
|
|
853
|
+
fun uniffi_keystone_wallet_core_fn_func_extract_transaction_inputs_ada(
|
|
854
|
+
`txHex`: RustBuffer.ByValue,
|
|
855
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
856
|
+
): RustBuffer.ByValue
|
|
857
|
+
|
|
858
|
+
fun uniffi_keystone_wallet_core_fn_func_finalize_then_extract_pczt_transaction(
|
|
859
|
+
`pcztHex`: RustBuffer.ByValue,
|
|
860
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
861
|
+
): RustBuffer.ByValue
|
|
862
|
+
|
|
863
|
+
fun ffi_keystone_wallet_core_rustbuffer_alloc(
|
|
864
|
+
`size`: Long,
|
|
865
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
866
|
+
): RustBuffer.ByValue
|
|
867
|
+
|
|
868
|
+
fun ffi_keystone_wallet_core_rustbuffer_from_bytes(
|
|
869
|
+
`bytes`: ForeignBytes.ByValue,
|
|
870
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
871
|
+
): RustBuffer.ByValue
|
|
872
|
+
|
|
873
|
+
fun ffi_keystone_wallet_core_rustbuffer_free(
|
|
874
|
+
`buf`: RustBuffer.ByValue,
|
|
875
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
876
|
+
): Unit
|
|
877
|
+
|
|
878
|
+
fun ffi_keystone_wallet_core_rustbuffer_reserve(
|
|
879
|
+
`buf`: RustBuffer.ByValue,
|
|
880
|
+
`additional`: Long,
|
|
881
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
882
|
+
): RustBuffer.ByValue
|
|
883
|
+
|
|
884
|
+
fun ffi_keystone_wallet_core_rust_future_poll_u8(
|
|
885
|
+
`handle`: Long,
|
|
886
|
+
`callback`: UniffiRustFutureContinuationCallback,
|
|
887
|
+
`callbackData`: Long,
|
|
888
|
+
): Unit
|
|
889
|
+
|
|
890
|
+
fun ffi_keystone_wallet_core_rust_future_cancel_u8(`handle`: Long): Unit
|
|
891
|
+
|
|
892
|
+
fun ffi_keystone_wallet_core_rust_future_free_u8(`handle`: Long): Unit
|
|
893
|
+
|
|
894
|
+
fun ffi_keystone_wallet_core_rust_future_complete_u8(
|
|
895
|
+
`handle`: Long,
|
|
896
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
897
|
+
): Byte
|
|
898
|
+
|
|
899
|
+
fun ffi_keystone_wallet_core_rust_future_poll_i8(
|
|
900
|
+
`handle`: Long,
|
|
901
|
+
`callback`: UniffiRustFutureContinuationCallback,
|
|
902
|
+
`callbackData`: Long,
|
|
903
|
+
): Unit
|
|
904
|
+
|
|
905
|
+
fun ffi_keystone_wallet_core_rust_future_cancel_i8(`handle`: Long): Unit
|
|
906
|
+
|
|
907
|
+
fun ffi_keystone_wallet_core_rust_future_free_i8(`handle`: Long): Unit
|
|
908
|
+
|
|
909
|
+
fun ffi_keystone_wallet_core_rust_future_complete_i8(
|
|
910
|
+
`handle`: Long,
|
|
911
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
912
|
+
): Byte
|
|
913
|
+
|
|
914
|
+
fun ffi_keystone_wallet_core_rust_future_poll_u16(
|
|
915
|
+
`handle`: Long,
|
|
916
|
+
`callback`: UniffiRustFutureContinuationCallback,
|
|
917
|
+
`callbackData`: Long,
|
|
918
|
+
): Unit
|
|
919
|
+
|
|
920
|
+
fun ffi_keystone_wallet_core_rust_future_cancel_u16(`handle`: Long): Unit
|
|
921
|
+
|
|
922
|
+
fun ffi_keystone_wallet_core_rust_future_free_u16(`handle`: Long): Unit
|
|
923
|
+
|
|
924
|
+
fun ffi_keystone_wallet_core_rust_future_complete_u16(
|
|
925
|
+
`handle`: Long,
|
|
926
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
927
|
+
): Short
|
|
928
|
+
|
|
929
|
+
fun ffi_keystone_wallet_core_rust_future_poll_i16(
|
|
930
|
+
`handle`: Long,
|
|
931
|
+
`callback`: UniffiRustFutureContinuationCallback,
|
|
932
|
+
`callbackData`: Long,
|
|
933
|
+
): Unit
|
|
934
|
+
|
|
935
|
+
fun ffi_keystone_wallet_core_rust_future_cancel_i16(`handle`: Long): Unit
|
|
936
|
+
|
|
937
|
+
fun ffi_keystone_wallet_core_rust_future_free_i16(`handle`: Long): Unit
|
|
938
|
+
|
|
939
|
+
fun ffi_keystone_wallet_core_rust_future_complete_i16(
|
|
940
|
+
`handle`: Long,
|
|
941
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
942
|
+
): Short
|
|
943
|
+
|
|
944
|
+
fun ffi_keystone_wallet_core_rust_future_poll_u32(
|
|
945
|
+
`handle`: Long,
|
|
946
|
+
`callback`: UniffiRustFutureContinuationCallback,
|
|
947
|
+
`callbackData`: Long,
|
|
948
|
+
): Unit
|
|
949
|
+
|
|
950
|
+
fun ffi_keystone_wallet_core_rust_future_cancel_u32(`handle`: Long): Unit
|
|
951
|
+
|
|
952
|
+
fun ffi_keystone_wallet_core_rust_future_free_u32(`handle`: Long): Unit
|
|
953
|
+
|
|
954
|
+
fun ffi_keystone_wallet_core_rust_future_complete_u32(
|
|
955
|
+
`handle`: Long,
|
|
956
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
957
|
+
): Int
|
|
958
|
+
|
|
959
|
+
fun ffi_keystone_wallet_core_rust_future_poll_i32(
|
|
960
|
+
`handle`: Long,
|
|
961
|
+
`callback`: UniffiRustFutureContinuationCallback,
|
|
962
|
+
`callbackData`: Long,
|
|
963
|
+
): Unit
|
|
964
|
+
|
|
965
|
+
fun ffi_keystone_wallet_core_rust_future_cancel_i32(`handle`: Long): Unit
|
|
966
|
+
|
|
967
|
+
fun ffi_keystone_wallet_core_rust_future_free_i32(`handle`: Long): Unit
|
|
968
|
+
|
|
969
|
+
fun ffi_keystone_wallet_core_rust_future_complete_i32(
|
|
970
|
+
`handle`: Long,
|
|
971
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
972
|
+
): Int
|
|
973
|
+
|
|
974
|
+
fun ffi_keystone_wallet_core_rust_future_poll_u64(
|
|
975
|
+
`handle`: Long,
|
|
976
|
+
`callback`: UniffiRustFutureContinuationCallback,
|
|
977
|
+
`callbackData`: Long,
|
|
978
|
+
): Unit
|
|
979
|
+
|
|
980
|
+
fun ffi_keystone_wallet_core_rust_future_cancel_u64(`handle`: Long): Unit
|
|
981
|
+
|
|
982
|
+
fun ffi_keystone_wallet_core_rust_future_free_u64(`handle`: Long): Unit
|
|
983
|
+
|
|
984
|
+
fun ffi_keystone_wallet_core_rust_future_complete_u64(
|
|
985
|
+
`handle`: Long,
|
|
986
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
987
|
+
): Long
|
|
988
|
+
|
|
989
|
+
fun ffi_keystone_wallet_core_rust_future_poll_i64(
|
|
990
|
+
`handle`: Long,
|
|
991
|
+
`callback`: UniffiRustFutureContinuationCallback,
|
|
992
|
+
`callbackData`: Long,
|
|
993
|
+
): Unit
|
|
994
|
+
|
|
995
|
+
fun ffi_keystone_wallet_core_rust_future_cancel_i64(`handle`: Long): Unit
|
|
996
|
+
|
|
997
|
+
fun ffi_keystone_wallet_core_rust_future_free_i64(`handle`: Long): Unit
|
|
998
|
+
|
|
999
|
+
fun ffi_keystone_wallet_core_rust_future_complete_i64(
|
|
1000
|
+
`handle`: Long,
|
|
1001
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
1002
|
+
): Long
|
|
1003
|
+
|
|
1004
|
+
fun ffi_keystone_wallet_core_rust_future_poll_f32(
|
|
1005
|
+
`handle`: Long,
|
|
1006
|
+
`callback`: UniffiRustFutureContinuationCallback,
|
|
1007
|
+
`callbackData`: Long,
|
|
1008
|
+
): Unit
|
|
1009
|
+
|
|
1010
|
+
fun ffi_keystone_wallet_core_rust_future_cancel_f32(`handle`: Long): Unit
|
|
1011
|
+
|
|
1012
|
+
fun ffi_keystone_wallet_core_rust_future_free_f32(`handle`: Long): Unit
|
|
1013
|
+
|
|
1014
|
+
fun ffi_keystone_wallet_core_rust_future_complete_f32(
|
|
1015
|
+
`handle`: Long,
|
|
1016
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
1017
|
+
): Float
|
|
1018
|
+
|
|
1019
|
+
fun ffi_keystone_wallet_core_rust_future_poll_f64(
|
|
1020
|
+
`handle`: Long,
|
|
1021
|
+
`callback`: UniffiRustFutureContinuationCallback,
|
|
1022
|
+
`callbackData`: Long,
|
|
1023
|
+
): Unit
|
|
1024
|
+
|
|
1025
|
+
fun ffi_keystone_wallet_core_rust_future_cancel_f64(`handle`: Long): Unit
|
|
1026
|
+
|
|
1027
|
+
fun ffi_keystone_wallet_core_rust_future_free_f64(`handle`: Long): Unit
|
|
1028
|
+
|
|
1029
|
+
fun ffi_keystone_wallet_core_rust_future_complete_f64(
|
|
1030
|
+
`handle`: Long,
|
|
1031
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
1032
|
+
): Double
|
|
1033
|
+
|
|
1034
|
+
fun ffi_keystone_wallet_core_rust_future_poll_pointer(
|
|
1035
|
+
`handle`: Long,
|
|
1036
|
+
`callback`: UniffiRustFutureContinuationCallback,
|
|
1037
|
+
`callbackData`: Long,
|
|
1038
|
+
): Unit
|
|
1039
|
+
|
|
1040
|
+
fun ffi_keystone_wallet_core_rust_future_cancel_pointer(`handle`: Long): Unit
|
|
1041
|
+
|
|
1042
|
+
fun ffi_keystone_wallet_core_rust_future_free_pointer(`handle`: Long): Unit
|
|
1043
|
+
|
|
1044
|
+
fun ffi_keystone_wallet_core_rust_future_complete_pointer(
|
|
1045
|
+
`handle`: Long,
|
|
1046
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
1047
|
+
): Pointer
|
|
1048
|
+
|
|
1049
|
+
fun ffi_keystone_wallet_core_rust_future_poll_rust_buffer(
|
|
1050
|
+
`handle`: Long,
|
|
1051
|
+
`callback`: UniffiRustFutureContinuationCallback,
|
|
1052
|
+
`callbackData`: Long,
|
|
1053
|
+
): Unit
|
|
1054
|
+
|
|
1055
|
+
fun ffi_keystone_wallet_core_rust_future_cancel_rust_buffer(`handle`: Long): Unit
|
|
1056
|
+
|
|
1057
|
+
fun ffi_keystone_wallet_core_rust_future_free_rust_buffer(`handle`: Long): Unit
|
|
1058
|
+
|
|
1059
|
+
fun ffi_keystone_wallet_core_rust_future_complete_rust_buffer(
|
|
1060
|
+
`handle`: Long,
|
|
1061
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
1062
|
+
): RustBuffer.ByValue
|
|
1063
|
+
|
|
1064
|
+
fun ffi_keystone_wallet_core_rust_future_poll_void(
|
|
1065
|
+
`handle`: Long,
|
|
1066
|
+
`callback`: UniffiRustFutureContinuationCallback,
|
|
1067
|
+
`callbackData`: Long,
|
|
1068
|
+
): Unit
|
|
1069
|
+
|
|
1070
|
+
fun ffi_keystone_wallet_core_rust_future_cancel_void(`handle`: Long): Unit
|
|
1071
|
+
|
|
1072
|
+
fun ffi_keystone_wallet_core_rust_future_free_void(`handle`: Long): Unit
|
|
1073
|
+
|
|
1074
|
+
fun ffi_keystone_wallet_core_rust_future_complete_void(
|
|
1075
|
+
`handle`: Long,
|
|
1076
|
+
uniffi_out_err: UniffiRustCallStatus,
|
|
1077
|
+
): Unit
|
|
1078
|
+
|
|
1079
|
+
fun uniffi_keystone_wallet_core_checksum_func_assemble_transaction_ada(): Short
|
|
1080
|
+
|
|
1081
|
+
fun uniffi_keystone_wallet_core_checksum_func_compose_transaction_ada(): Short
|
|
1082
|
+
|
|
1083
|
+
fun uniffi_keystone_wallet_core_checksum_func_create_pczt(): Short
|
|
1084
|
+
|
|
1085
|
+
fun uniffi_keystone_wallet_core_checksum_func_create_transparent_pczt(): Short
|
|
1086
|
+
|
|
1087
|
+
fun uniffi_keystone_wallet_core_checksum_func_create_transparent_pczt_for_swapkit(): Short
|
|
1088
|
+
|
|
1089
|
+
fun uniffi_keystone_wallet_core_checksum_func_derive_address_by_path_ada(): Short
|
|
1090
|
+
|
|
1091
|
+
fun uniffi_keystone_wallet_core_checksum_func_derive_enterprise_address_by_path_ada(): Short
|
|
1092
|
+
|
|
1093
|
+
fun uniffi_keystone_wallet_core_checksum_func_derive_pubkey_by_path_ada(): Short
|
|
1094
|
+
|
|
1095
|
+
fun uniffi_keystone_wallet_core_checksum_func_derive_stake_address_ada(): Short
|
|
1096
|
+
|
|
1097
|
+
fun uniffi_keystone_wallet_core_checksum_func_extract_transaction_inputs_ada(): Short
|
|
1098
|
+
|
|
1099
|
+
fun uniffi_keystone_wallet_core_checksum_func_finalize_then_extract_pczt_transaction(): Short
|
|
1100
|
+
|
|
1101
|
+
fun uniffi_keystone_wallet_core_checksum_method_pczt_serialize(): Short
|
|
1102
|
+
|
|
1103
|
+
fun ffi_keystone_wallet_core_uniffi_contract_version(): Int
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
private fun uniffiCheckContractApiVersion(lib: UniffiLib) {
|
|
1107
|
+
// Get the bindings contract version from our ComponentInterface
|
|
1108
|
+
val bindings_contract_version = 26
|
|
1109
|
+
// Get the scaffolding contract version by calling the into the dylib
|
|
1110
|
+
val scaffolding_contract_version = lib.ffi_keystone_wallet_core_uniffi_contract_version()
|
|
1111
|
+
if (bindings_contract_version != scaffolding_contract_version) {
|
|
1112
|
+
throw RuntimeException("UniFFI contract version mismatch: try cleaning and rebuilding your project")
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
@Suppress("UNUSED_PARAMETER")
|
|
1117
|
+
private fun uniffiCheckApiChecksums(lib: UniffiLib) {
|
|
1118
|
+
if (lib.uniffi_keystone_wallet_core_checksum_func_assemble_transaction_ada() != 22105.toShort()) {
|
|
1119
|
+
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
1120
|
+
}
|
|
1121
|
+
if (lib.uniffi_keystone_wallet_core_checksum_func_compose_transaction_ada() != 48909.toShort()) {
|
|
1122
|
+
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
1123
|
+
}
|
|
1124
|
+
if (lib.uniffi_keystone_wallet_core_checksum_func_create_pczt() != 11746.toShort()) {
|
|
1125
|
+
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
1126
|
+
}
|
|
1127
|
+
if (lib.uniffi_keystone_wallet_core_checksum_func_create_transparent_pczt() != 17127.toShort()) {
|
|
1128
|
+
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
1129
|
+
}
|
|
1130
|
+
if (lib.uniffi_keystone_wallet_core_checksum_func_create_transparent_pczt_for_swapkit() != 2710.toShort()) {
|
|
1131
|
+
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
1132
|
+
}
|
|
1133
|
+
if (lib.uniffi_keystone_wallet_core_checksum_func_derive_address_by_path_ada() != 24523.toShort()) {
|
|
1134
|
+
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
1135
|
+
}
|
|
1136
|
+
if (lib.uniffi_keystone_wallet_core_checksum_func_derive_enterprise_address_by_path_ada() != 54377.toShort()) {
|
|
1137
|
+
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
1138
|
+
}
|
|
1139
|
+
if (lib.uniffi_keystone_wallet_core_checksum_func_derive_pubkey_by_path_ada() != 53793.toShort()) {
|
|
1140
|
+
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
1141
|
+
}
|
|
1142
|
+
if (lib.uniffi_keystone_wallet_core_checksum_func_derive_stake_address_ada() != 22900.toShort()) {
|
|
1143
|
+
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
1144
|
+
}
|
|
1145
|
+
if (lib.uniffi_keystone_wallet_core_checksum_func_extract_transaction_inputs_ada() != 49208.toShort()) {
|
|
1146
|
+
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
1147
|
+
}
|
|
1148
|
+
if (lib.uniffi_keystone_wallet_core_checksum_func_finalize_then_extract_pczt_transaction() != 47467.toShort()) {
|
|
1149
|
+
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
1150
|
+
}
|
|
1151
|
+
if (lib.uniffi_keystone_wallet_core_checksum_method_pczt_serialize() != 18950.toShort()) {
|
|
1152
|
+
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
// Async support
|
|
1157
|
+
|
|
1158
|
+
// Public interface members begin here.
|
|
1159
|
+
|
|
1160
|
+
// Interface implemented by anything that can contain an object reference.
|
|
1161
|
+
//
|
|
1162
|
+
// Such types expose a `destroy()` method that must be called to cleanly
|
|
1163
|
+
// dispose of the contained objects. Failure to call this method may result
|
|
1164
|
+
// in memory leaks.
|
|
1165
|
+
//
|
|
1166
|
+
// The easiest way to ensure this method is called is to use the `.use`
|
|
1167
|
+
// helper method to execute a block and destroy the object at the end.
|
|
1168
|
+
interface Disposable {
|
|
1169
|
+
fun destroy()
|
|
1170
|
+
|
|
1171
|
+
companion object {
|
|
1172
|
+
fun destroy(vararg args: Any?) {
|
|
1173
|
+
args
|
|
1174
|
+
.filterIsInstance<Disposable>()
|
|
1175
|
+
.forEach(Disposable::destroy)
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
/**
|
|
1181
|
+
* @suppress
|
|
1182
|
+
*/
|
|
1183
|
+
inline fun <T : Disposable?, R> T.use(block: (T) -> R) =
|
|
1184
|
+
try {
|
|
1185
|
+
block(this)
|
|
1186
|
+
} finally {
|
|
1187
|
+
try {
|
|
1188
|
+
// N.B. our implementation is on the nullable type `Disposable?`.
|
|
1189
|
+
this?.destroy()
|
|
1190
|
+
} catch (e: Throwable) {
|
|
1191
|
+
// swallow
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
/**
|
|
1196
|
+
* Used to instantiate an interface without an actual pointer, for fakes in tests, mostly.
|
|
1197
|
+
*
|
|
1198
|
+
* @suppress
|
|
1199
|
+
* */
|
|
1200
|
+
object NoPointer
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* @suppress
|
|
1204
|
+
*/
|
|
1205
|
+
public object FfiConverterUByte : FfiConverter<UByte, Byte> {
|
|
1206
|
+
override fun lift(value: Byte): UByte = value.toUByte()
|
|
1207
|
+
|
|
1208
|
+
override fun read(buf: ByteBuffer): UByte = lift(buf.get())
|
|
1209
|
+
|
|
1210
|
+
override fun lower(value: UByte): Byte = value.toByte()
|
|
1211
|
+
|
|
1212
|
+
override fun allocationSize(value: UByte) = 1UL
|
|
1213
|
+
|
|
1214
|
+
override fun write(
|
|
1215
|
+
value: UByte,
|
|
1216
|
+
buf: ByteBuffer,
|
|
1217
|
+
) {
|
|
1218
|
+
buf.put(value.toByte())
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
/**
|
|
1223
|
+
* @suppress
|
|
1224
|
+
*/
|
|
1225
|
+
public object FfiConverterUInt : FfiConverter<UInt, Int> {
|
|
1226
|
+
override fun lift(value: Int): UInt = value.toUInt()
|
|
1227
|
+
|
|
1228
|
+
override fun read(buf: ByteBuffer): UInt = lift(buf.getInt())
|
|
1229
|
+
|
|
1230
|
+
override fun lower(value: UInt): Int = value.toInt()
|
|
1231
|
+
|
|
1232
|
+
override fun allocationSize(value: UInt) = 4UL
|
|
1233
|
+
|
|
1234
|
+
override fun write(
|
|
1235
|
+
value: UInt,
|
|
1236
|
+
buf: ByteBuffer,
|
|
1237
|
+
) {
|
|
1238
|
+
buf.putInt(value.toInt())
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
/**
|
|
1243
|
+
* @suppress
|
|
1244
|
+
*/
|
|
1245
|
+
public object FfiConverterULong : FfiConverter<ULong, Long> {
|
|
1246
|
+
override fun lift(value: Long): ULong = value.toULong()
|
|
1247
|
+
|
|
1248
|
+
override fun read(buf: ByteBuffer): ULong = lift(buf.getLong())
|
|
1249
|
+
|
|
1250
|
+
override fun lower(value: ULong): Long = value.toLong()
|
|
1251
|
+
|
|
1252
|
+
override fun allocationSize(value: ULong) = 8UL
|
|
1253
|
+
|
|
1254
|
+
override fun write(
|
|
1255
|
+
value: ULong,
|
|
1256
|
+
buf: ByteBuffer,
|
|
1257
|
+
) {
|
|
1258
|
+
buf.putLong(value.toLong())
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
/**
|
|
1263
|
+
* @suppress
|
|
1264
|
+
*/
|
|
1265
|
+
public object FfiConverterBoolean : FfiConverter<Boolean, Byte> {
|
|
1266
|
+
override fun lift(value: Byte): Boolean = value.toInt() != 0
|
|
1267
|
+
|
|
1268
|
+
override fun read(buf: ByteBuffer): Boolean = lift(buf.get())
|
|
1269
|
+
|
|
1270
|
+
override fun lower(value: Boolean): Byte = if (value) 1.toByte() else 0.toByte()
|
|
1271
|
+
|
|
1272
|
+
override fun allocationSize(value: Boolean) = 1UL
|
|
1273
|
+
|
|
1274
|
+
override fun write(
|
|
1275
|
+
value: Boolean,
|
|
1276
|
+
buf: ByteBuffer,
|
|
1277
|
+
) {
|
|
1278
|
+
buf.put(lower(value))
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
/**
|
|
1283
|
+
* @suppress
|
|
1284
|
+
*/
|
|
1285
|
+
public object FfiConverterString : FfiConverter<String, RustBuffer.ByValue> {
|
|
1286
|
+
// Note: we don't inherit from FfiConverterRustBuffer, because we use a
|
|
1287
|
+
// special encoding when lowering/lifting. We can use `RustBuffer.len` to
|
|
1288
|
+
// store our length and avoid writing it out to the buffer.
|
|
1289
|
+
override fun lift(value: RustBuffer.ByValue): String {
|
|
1290
|
+
try {
|
|
1291
|
+
val byteArr = ByteArray(value.len.toInt())
|
|
1292
|
+
value.asByteBuffer()!!.get(byteArr)
|
|
1293
|
+
return byteArr.toString(Charsets.UTF_8)
|
|
1294
|
+
} finally {
|
|
1295
|
+
RustBuffer.free(value)
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
override fun read(buf: ByteBuffer): String {
|
|
1300
|
+
val len = buf.getInt()
|
|
1301
|
+
val byteArr = ByteArray(len)
|
|
1302
|
+
buf.get(byteArr)
|
|
1303
|
+
return byteArr.toString(Charsets.UTF_8)
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
fun toUtf8(value: String): ByteBuffer {
|
|
1307
|
+
// Make sure we don't have invalid UTF-16, check for lone surrogates.
|
|
1308
|
+
return Charsets.UTF_8.newEncoder().run {
|
|
1309
|
+
onMalformedInput(CodingErrorAction.REPORT)
|
|
1310
|
+
encode(CharBuffer.wrap(value))
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
override fun lower(value: String): RustBuffer.ByValue {
|
|
1315
|
+
val byteBuf = toUtf8(value)
|
|
1316
|
+
// Ideally we'd pass these bytes to `ffi_bytebuffer_from_bytes`, but doing so would require us
|
|
1317
|
+
// to copy them into a JNA `Memory`. So we might as well directly copy them into a `RustBuffer`.
|
|
1318
|
+
val rbuf = RustBuffer.alloc(byteBuf.limit().toULong())
|
|
1319
|
+
rbuf.asByteBuffer()!!.put(byteBuf)
|
|
1320
|
+
return rbuf
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
// We aren't sure exactly how many bytes our string will be once it's UTF-8
|
|
1324
|
+
// encoded. Allocate 3 bytes per UTF-16 code unit which will always be
|
|
1325
|
+
// enough.
|
|
1326
|
+
override fun allocationSize(value: String): ULong {
|
|
1327
|
+
val sizeForLength = 4UL
|
|
1328
|
+
val sizeForString = value.length.toULong() * 3UL
|
|
1329
|
+
return sizeForLength + sizeForString
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
override fun write(
|
|
1333
|
+
value: String,
|
|
1334
|
+
buf: ByteBuffer,
|
|
1335
|
+
) {
|
|
1336
|
+
val byteBuf = toUtf8(value)
|
|
1337
|
+
buf.putInt(byteBuf.limit())
|
|
1338
|
+
buf.put(byteBuf)
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
// This template implements a class for working with a Rust struct via a Pointer/Arc<T>
|
|
1343
|
+
// to the live Rust struct on the other side of the FFI.
|
|
1344
|
+
//
|
|
1345
|
+
// Each instance implements core operations for working with the Rust `Arc<T>` and the
|
|
1346
|
+
// Kotlin Pointer to work with the live Rust struct on the other side of the FFI.
|
|
1347
|
+
//
|
|
1348
|
+
// There's some subtlety here, because we have to be careful not to operate on a Rust
|
|
1349
|
+
// struct after it has been dropped, and because we must expose a public API for freeing
|
|
1350
|
+
// theq Kotlin wrapper object in lieu of reliable finalizers. The core requirements are:
|
|
1351
|
+
//
|
|
1352
|
+
// * Each instance holds an opaque pointer to the underlying Rust struct.
|
|
1353
|
+
// Method calls need to read this pointer from the object's state and pass it in to
|
|
1354
|
+
// the Rust FFI.
|
|
1355
|
+
//
|
|
1356
|
+
// * When an instance is no longer needed, its pointer should be passed to a
|
|
1357
|
+
// special destructor function provided by the Rust FFI, which will drop the
|
|
1358
|
+
// underlying Rust struct.
|
|
1359
|
+
//
|
|
1360
|
+
// * Given an instance, calling code is expected to call the special
|
|
1361
|
+
// `destroy` method in order to free it after use, either by calling it explicitly
|
|
1362
|
+
// or by using a higher-level helper like the `use` method. Failing to do so risks
|
|
1363
|
+
// leaking the underlying Rust struct.
|
|
1364
|
+
//
|
|
1365
|
+
// * We can't assume that calling code will do the right thing, and must be prepared
|
|
1366
|
+
// to handle Kotlin method calls executing concurrently with or even after a call to
|
|
1367
|
+
// `destroy`, and to handle multiple (possibly concurrent!) calls to `destroy`.
|
|
1368
|
+
//
|
|
1369
|
+
// * We must never allow Rust code to operate on the underlying Rust struct after
|
|
1370
|
+
// the destructor has been called, and must never call the destructor more than once.
|
|
1371
|
+
// Doing so may trigger memory unsafety.
|
|
1372
|
+
//
|
|
1373
|
+
// * To mitigate many of the risks of leaking memory and use-after-free unsafety, a `Cleaner`
|
|
1374
|
+
// is implemented to call the destructor when the Kotlin object becomes unreachable.
|
|
1375
|
+
// This is done in a background thread. This is not a panacea, and client code should be aware that
|
|
1376
|
+
// 1. the thread may starve if some there are objects that have poorly performing
|
|
1377
|
+
// `drop` methods or do significant work in their `drop` methods.
|
|
1378
|
+
// 2. the thread is shared across the whole library. This can be tuned by using `android_cleaner = true`,
|
|
1379
|
+
// or `android = true` in the [`kotlin` section of the `uniffi.toml` file](https://mozilla.github.io/uniffi-rs/kotlin/configuration.html).
|
|
1380
|
+
//
|
|
1381
|
+
// If we try to implement this with mutual exclusion on access to the pointer, there is the
|
|
1382
|
+
// possibility of a race between a method call and a concurrent call to `destroy`:
|
|
1383
|
+
//
|
|
1384
|
+
// * Thread A starts a method call, reads the value of the pointer, but is interrupted
|
|
1385
|
+
// before it can pass the pointer over the FFI to Rust.
|
|
1386
|
+
// * Thread B calls `destroy` and frees the underlying Rust struct.
|
|
1387
|
+
// * Thread A resumes, passing the already-read pointer value to Rust and triggering
|
|
1388
|
+
// a use-after-free.
|
|
1389
|
+
//
|
|
1390
|
+
// One possible solution would be to use a `ReadWriteLock`, with each method call taking
|
|
1391
|
+
// a read lock (and thus allowed to run concurrently) and the special `destroy` method
|
|
1392
|
+
// taking a write lock (and thus blocking on live method calls). However, we aim not to
|
|
1393
|
+
// generate methods with any hidden blocking semantics, and a `destroy` method that might
|
|
1394
|
+
// block if called incorrectly seems to meet that bar.
|
|
1395
|
+
//
|
|
1396
|
+
// So, we achieve our goals by giving each instance an associated `AtomicLong` counter to track
|
|
1397
|
+
// the number of in-flight method calls, and an `AtomicBoolean` flag to indicate whether `destroy`
|
|
1398
|
+
// has been called. These are updated according to the following rules:
|
|
1399
|
+
//
|
|
1400
|
+
// * The initial value of the counter is 1, indicating a live object with no in-flight calls.
|
|
1401
|
+
// The initial value for the flag is false.
|
|
1402
|
+
//
|
|
1403
|
+
// * At the start of each method call, we atomically check the counter.
|
|
1404
|
+
// If it is 0 then the underlying Rust struct has already been destroyed and the call is aborted.
|
|
1405
|
+
// If it is nonzero them we atomically increment it by 1 and proceed with the method call.
|
|
1406
|
+
//
|
|
1407
|
+
// * At the end of each method call, we atomically decrement and check the counter.
|
|
1408
|
+
// If it has reached zero then we destroy the underlying Rust struct.
|
|
1409
|
+
//
|
|
1410
|
+
// * When `destroy` is called, we atomically flip the flag from false to true.
|
|
1411
|
+
// If the flag was already true we silently fail.
|
|
1412
|
+
// Otherwise we atomically decrement and check the counter.
|
|
1413
|
+
// If it has reached zero then we destroy the underlying Rust struct.
|
|
1414
|
+
//
|
|
1415
|
+
// Astute readers may observe that this all sounds very similar to the way that Rust's `Arc<T>` works,
|
|
1416
|
+
// and indeed it is, with the addition of a flag to guard against multiple calls to `destroy`.
|
|
1417
|
+
//
|
|
1418
|
+
// The overall effect is that the underlying Rust struct is destroyed only when `destroy` has been
|
|
1419
|
+
// called *and* all in-flight method calls have completed, avoiding violating any of the expectations
|
|
1420
|
+
// of the underlying Rust code.
|
|
1421
|
+
//
|
|
1422
|
+
// This makes a cleaner a better alternative to _not_ calling `destroy()` as
|
|
1423
|
+
// and when the object is finished with, but the abstraction is not perfect: if the Rust object's `drop`
|
|
1424
|
+
// method is slow, and/or there are many objects to cleanup, and it's on a low end Android device, then the cleaner
|
|
1425
|
+
// thread may be starved, and the app will leak memory.
|
|
1426
|
+
//
|
|
1427
|
+
// In this case, `destroy`ing manually may be a better solution.
|
|
1428
|
+
//
|
|
1429
|
+
// The cleaner can live side by side with the manual calling of `destroy`. In the order of responsiveness, uniffi objects
|
|
1430
|
+
// with Rust peers are reclaimed:
|
|
1431
|
+
//
|
|
1432
|
+
// 1. By calling the `destroy` method of the object, which calls `rustObject.free()`. If that doesn't happen:
|
|
1433
|
+
// 2. When the object becomes unreachable, AND the Cleaner thread gets to call `rustObject.free()`. If the thread is starved then:
|
|
1434
|
+
// 3. The memory is reclaimed when the process terminates.
|
|
1435
|
+
//
|
|
1436
|
+
// [1] https://stackoverflow.com/questions/24376768/can-java-finalize-an-object-when-it-is-still-in-scope/24380219
|
|
1437
|
+
//
|
|
1438
|
+
|
|
1439
|
+
/**
|
|
1440
|
+
* The cleaner interface for Object finalization code to run.
|
|
1441
|
+
* This is the entry point to any implementation that we're using.
|
|
1442
|
+
*
|
|
1443
|
+
* The cleaner registers objects and returns cleanables, so now we are
|
|
1444
|
+
* defining a `UniffiCleaner` with a `UniffiClenaer.Cleanable` to abstract the
|
|
1445
|
+
* different implmentations available at compile time.
|
|
1446
|
+
*
|
|
1447
|
+
* @suppress
|
|
1448
|
+
*/
|
|
1449
|
+
interface UniffiCleaner {
|
|
1450
|
+
interface Cleanable {
|
|
1451
|
+
fun clean()
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
fun register(
|
|
1455
|
+
value: Any,
|
|
1456
|
+
cleanUpTask: Runnable,
|
|
1457
|
+
): UniffiCleaner.Cleanable
|
|
1458
|
+
|
|
1459
|
+
companion object
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
// The fallback Jna cleaner, which is available for both Android, and the JVM.
|
|
1463
|
+
private class UniffiJnaCleaner : UniffiCleaner {
|
|
1464
|
+
private val cleaner =
|
|
1465
|
+
com.sun.jna.internal.Cleaner
|
|
1466
|
+
.getCleaner()
|
|
1467
|
+
|
|
1468
|
+
override fun register(
|
|
1469
|
+
value: Any,
|
|
1470
|
+
cleanUpTask: Runnable,
|
|
1471
|
+
): UniffiCleaner.Cleanable = UniffiJnaCleanable(cleaner.register(value, cleanUpTask))
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
private class UniffiJnaCleanable(
|
|
1475
|
+
private val cleanable: com.sun.jna.internal.Cleaner.Cleanable,
|
|
1476
|
+
) : UniffiCleaner.Cleanable {
|
|
1477
|
+
override fun clean() = cleanable.clean()
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
// We decide at uniffi binding generation time whether we were
|
|
1481
|
+
// using Android or not.
|
|
1482
|
+
// There are further runtime checks to chose the correct implementation
|
|
1483
|
+
// of the cleaner.
|
|
1484
|
+
private fun UniffiCleaner.Companion.create(): UniffiCleaner =
|
|
1485
|
+
try {
|
|
1486
|
+
// For safety's sake: if the library hasn't been run in android_cleaner = true
|
|
1487
|
+
// mode, but is being run on Android, then we still need to think about
|
|
1488
|
+
// Android API versions.
|
|
1489
|
+
// So we check if java.lang.ref.Cleaner is there, and use that…
|
|
1490
|
+
java.lang.Class.forName("java.lang.ref.Cleaner")
|
|
1491
|
+
JavaLangRefCleaner()
|
|
1492
|
+
} catch (e: ClassNotFoundException) {
|
|
1493
|
+
// … otherwise, fallback to the JNA cleaner.
|
|
1494
|
+
UniffiJnaCleaner()
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
private class JavaLangRefCleaner : UniffiCleaner {
|
|
1498
|
+
val cleaner =
|
|
1499
|
+
java.lang.ref.Cleaner
|
|
1500
|
+
.create()
|
|
1501
|
+
|
|
1502
|
+
override fun register(
|
|
1503
|
+
value: Any,
|
|
1504
|
+
cleanUpTask: Runnable,
|
|
1505
|
+
): UniffiCleaner.Cleanable = JavaLangRefCleanable(cleaner.register(value, cleanUpTask))
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
private class JavaLangRefCleanable(
|
|
1509
|
+
val cleanable: java.lang.ref.Cleaner.Cleanable,
|
|
1510
|
+
) : UniffiCleaner.Cleanable {
|
|
1511
|
+
override fun clean() = cleanable.clean()
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
public interface PcztInterface {
|
|
1515
|
+
fun `serialize`(): List<kotlin.UByte>
|
|
1516
|
+
|
|
1517
|
+
companion object
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
open class Pczt :
|
|
1521
|
+
Disposable,
|
|
1522
|
+
AutoCloseable,
|
|
1523
|
+
PcztInterface {
|
|
1524
|
+
constructor(pointer: Pointer) {
|
|
1525
|
+
this.pointer = pointer
|
|
1526
|
+
this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer))
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
/**
|
|
1530
|
+
* This constructor can be used to instantiate a fake object. Only used for tests. Any
|
|
1531
|
+
* attempt to actually use an object constructed this way will fail as there is no
|
|
1532
|
+
* connected Rust object.
|
|
1533
|
+
*/
|
|
1534
|
+
@Suppress("UNUSED_PARAMETER")
|
|
1535
|
+
constructor(noPointer: NoPointer) {
|
|
1536
|
+
this.pointer = null
|
|
1537
|
+
this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer))
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
protected val pointer: Pointer?
|
|
1541
|
+
protected val cleanable: UniffiCleaner.Cleanable
|
|
1542
|
+
|
|
1543
|
+
private val wasDestroyed = AtomicBoolean(false)
|
|
1544
|
+
private val callCounter = AtomicLong(1)
|
|
1545
|
+
|
|
1546
|
+
override fun destroy() {
|
|
1547
|
+
// Only allow a single call to this method.
|
|
1548
|
+
// TODO: maybe we should log a warning if called more than once?
|
|
1549
|
+
if (this.wasDestroyed.compareAndSet(false, true)) {
|
|
1550
|
+
// This decrement always matches the initial count of 1 given at creation time.
|
|
1551
|
+
if (this.callCounter.decrementAndGet() == 0L) {
|
|
1552
|
+
cleanable.clean()
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
@Synchronized
|
|
1558
|
+
override fun close() {
|
|
1559
|
+
this.destroy()
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
internal inline fun <R> callWithPointer(block: (ptr: Pointer) -> R): R {
|
|
1563
|
+
// Check and increment the call counter, to keep the object alive.
|
|
1564
|
+
// This needs a compare-and-set retry loop in case of concurrent updates.
|
|
1565
|
+
do {
|
|
1566
|
+
val c = this.callCounter.get()
|
|
1567
|
+
if (c == 0L) {
|
|
1568
|
+
throw IllegalStateException("${this.javaClass.simpleName} object has already been destroyed")
|
|
1569
|
+
}
|
|
1570
|
+
if (c == Long.MAX_VALUE) {
|
|
1571
|
+
throw IllegalStateException("${this.javaClass.simpleName} call counter would overflow")
|
|
1572
|
+
}
|
|
1573
|
+
} while (!this.callCounter.compareAndSet(c, c + 1L))
|
|
1574
|
+
// Now we can safely do the method call without the pointer being freed concurrently.
|
|
1575
|
+
try {
|
|
1576
|
+
return block(this.uniffiClonePointer())
|
|
1577
|
+
} finally {
|
|
1578
|
+
// This decrement always matches the increment we performed above.
|
|
1579
|
+
if (this.callCounter.decrementAndGet() == 0L) {
|
|
1580
|
+
cleanable.clean()
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
// Use a static inner class instead of a closure so as not to accidentally
|
|
1586
|
+
// capture `this` as part of the cleanable's action.
|
|
1587
|
+
private class UniffiCleanAction(
|
|
1588
|
+
private val pointer: Pointer?,
|
|
1589
|
+
) : Runnable {
|
|
1590
|
+
override fun run() {
|
|
1591
|
+
pointer?.let { ptr ->
|
|
1592
|
+
uniffiRustCall { status ->
|
|
1593
|
+
UniffiLib.INSTANCE.uniffi_keystone_wallet_core_fn_free_pczt(ptr, status)
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
fun uniffiClonePointer(): Pointer =
|
|
1600
|
+
uniffiRustCall { status ->
|
|
1601
|
+
UniffiLib.INSTANCE.uniffi_keystone_wallet_core_fn_clone_pczt(pointer!!, status)
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
override fun `serialize`(): List<kotlin.UByte> =
|
|
1605
|
+
FfiConverterSequenceUByte.lift(
|
|
1606
|
+
callWithPointer {
|
|
1607
|
+
uniffiRustCall { _status ->
|
|
1608
|
+
UniffiLib.INSTANCE.uniffi_keystone_wallet_core_fn_method_pczt_serialize(it, _status)
|
|
1609
|
+
}
|
|
1610
|
+
},
|
|
1611
|
+
)
|
|
1612
|
+
|
|
1613
|
+
companion object
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
/**
|
|
1617
|
+
* @suppress
|
|
1618
|
+
*/
|
|
1619
|
+
public object FfiConverterTypePczt : FfiConverter<Pczt, Pointer> {
|
|
1620
|
+
override fun lower(value: Pczt): Pointer = value.uniffiClonePointer()
|
|
1621
|
+
|
|
1622
|
+
override fun lift(value: Pointer): Pczt = Pczt(value)
|
|
1623
|
+
|
|
1624
|
+
override fun read(buf: ByteBuffer): Pczt {
|
|
1625
|
+
// The Rust code always writes pointers as 8 bytes, and will
|
|
1626
|
+
// fail to compile if they don't fit.
|
|
1627
|
+
return lift(Pointer(buf.getLong()))
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
override fun allocationSize(value: Pczt) = 8UL
|
|
1631
|
+
|
|
1632
|
+
override fun write(
|
|
1633
|
+
value: Pczt,
|
|
1634
|
+
buf: ByteBuffer,
|
|
1635
|
+
) {
|
|
1636
|
+
// The Rust code always expects pointers written as 8 bytes,
|
|
1637
|
+
// and will fail to compile if they don't fit.
|
|
1638
|
+
buf.putLong(Pointer.nativeValue(lower(value)))
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
data class CardanoDecodedTx(
|
|
1643
|
+
var `inputs`: List<CardanoInputRef>,
|
|
1644
|
+
var `outputs`: List<CardanoTxOutput>,
|
|
1645
|
+
var `fee`: kotlin.ULong,
|
|
1646
|
+
var `ttl`: kotlin.UInt,
|
|
1647
|
+
) {
|
|
1648
|
+
companion object
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
/**
|
|
1652
|
+
* @suppress
|
|
1653
|
+
*/
|
|
1654
|
+
public object FfiConverterTypeCardanoDecodedTx : FfiConverterRustBuffer<CardanoDecodedTx> {
|
|
1655
|
+
override fun read(buf: ByteBuffer): CardanoDecodedTx =
|
|
1656
|
+
CardanoDecodedTx(
|
|
1657
|
+
FfiConverterSequenceTypeCardanoInputRef.read(buf),
|
|
1658
|
+
FfiConverterSequenceTypeCardanoTxOutput.read(buf),
|
|
1659
|
+
FfiConverterULong.read(buf),
|
|
1660
|
+
FfiConverterUInt.read(buf),
|
|
1661
|
+
)
|
|
1662
|
+
|
|
1663
|
+
override fun allocationSize(value: CardanoDecodedTx) =
|
|
1664
|
+
(
|
|
1665
|
+
FfiConverterSequenceTypeCardanoInputRef.allocationSize(value.`inputs`) +
|
|
1666
|
+
FfiConverterSequenceTypeCardanoTxOutput.allocationSize(value.`outputs`) +
|
|
1667
|
+
FfiConverterULong.allocationSize(value.`fee`) +
|
|
1668
|
+
FfiConverterUInt.allocationSize(value.`ttl`)
|
|
1669
|
+
)
|
|
1670
|
+
|
|
1671
|
+
override fun write(
|
|
1672
|
+
value: CardanoDecodedTx,
|
|
1673
|
+
buf: ByteBuffer,
|
|
1674
|
+
) {
|
|
1675
|
+
FfiConverterSequenceTypeCardanoInputRef.write(value.`inputs`, buf)
|
|
1676
|
+
FfiConverterSequenceTypeCardanoTxOutput.write(value.`outputs`, buf)
|
|
1677
|
+
FfiConverterULong.write(value.`fee`, buf)
|
|
1678
|
+
FfiConverterUInt.write(value.`ttl`, buf)
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
data class CardanoInputRef(
|
|
1683
|
+
var `txHash`: kotlin.String,
|
|
1684
|
+
var `txIndex`: kotlin.UInt,
|
|
1685
|
+
) {
|
|
1686
|
+
companion object
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
/**
|
|
1690
|
+
* @suppress
|
|
1691
|
+
*/
|
|
1692
|
+
public object FfiConverterTypeCardanoInputRef : FfiConverterRustBuffer<CardanoInputRef> {
|
|
1693
|
+
override fun read(buf: ByteBuffer): CardanoInputRef =
|
|
1694
|
+
CardanoInputRef(
|
|
1695
|
+
FfiConverterString.read(buf),
|
|
1696
|
+
FfiConverterUInt.read(buf),
|
|
1697
|
+
)
|
|
1698
|
+
|
|
1699
|
+
override fun allocationSize(value: CardanoInputRef) =
|
|
1700
|
+
(
|
|
1701
|
+
FfiConverterString.allocationSize(value.`txHash`) +
|
|
1702
|
+
FfiConverterUInt.allocationSize(value.`txIndex`)
|
|
1703
|
+
)
|
|
1704
|
+
|
|
1705
|
+
override fun write(
|
|
1706
|
+
value: CardanoInputRef,
|
|
1707
|
+
buf: ByteBuffer,
|
|
1708
|
+
) {
|
|
1709
|
+
FfiConverterString.write(value.`txHash`, buf)
|
|
1710
|
+
FfiConverterUInt.write(value.`txIndex`, buf)
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
data class CardanoTxInput(
|
|
1715
|
+
var `txHash`: kotlin.String,
|
|
1716
|
+
var `txIndex`: kotlin.UInt,
|
|
1717
|
+
var `amount`: kotlin.ULong,
|
|
1718
|
+
) {
|
|
1719
|
+
companion object
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
/**
|
|
1723
|
+
* @suppress
|
|
1724
|
+
*/
|
|
1725
|
+
public object FfiConverterTypeCardanoTxInput : FfiConverterRustBuffer<CardanoTxInput> {
|
|
1726
|
+
override fun read(buf: ByteBuffer): CardanoTxInput =
|
|
1727
|
+
CardanoTxInput(
|
|
1728
|
+
FfiConverterString.read(buf),
|
|
1729
|
+
FfiConverterUInt.read(buf),
|
|
1730
|
+
FfiConverterULong.read(buf),
|
|
1731
|
+
)
|
|
1732
|
+
|
|
1733
|
+
override fun allocationSize(value: CardanoTxInput) =
|
|
1734
|
+
(
|
|
1735
|
+
FfiConverterString.allocationSize(value.`txHash`) +
|
|
1736
|
+
FfiConverterUInt.allocationSize(value.`txIndex`) +
|
|
1737
|
+
FfiConverterULong.allocationSize(value.`amount`)
|
|
1738
|
+
)
|
|
1739
|
+
|
|
1740
|
+
override fun write(
|
|
1741
|
+
value: CardanoTxInput,
|
|
1742
|
+
buf: ByteBuffer,
|
|
1743
|
+
) {
|
|
1744
|
+
FfiConverterString.write(value.`txHash`, buf)
|
|
1745
|
+
FfiConverterUInt.write(value.`txIndex`, buf)
|
|
1746
|
+
FfiConverterULong.write(value.`amount`, buf)
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
data class CardanoTxOutput(
|
|
1751
|
+
var `address`: kotlin.String,
|
|
1752
|
+
var `amount`: kotlin.ULong,
|
|
1753
|
+
var `isChange`: kotlin.Boolean,
|
|
1754
|
+
) {
|
|
1755
|
+
companion object
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
/**
|
|
1759
|
+
* @suppress
|
|
1760
|
+
*/
|
|
1761
|
+
public object FfiConverterTypeCardanoTxOutput : FfiConverterRustBuffer<CardanoTxOutput> {
|
|
1762
|
+
override fun read(buf: ByteBuffer): CardanoTxOutput =
|
|
1763
|
+
CardanoTxOutput(
|
|
1764
|
+
FfiConverterString.read(buf),
|
|
1765
|
+
FfiConverterULong.read(buf),
|
|
1766
|
+
FfiConverterBoolean.read(buf),
|
|
1767
|
+
)
|
|
1768
|
+
|
|
1769
|
+
override fun allocationSize(value: CardanoTxOutput) =
|
|
1770
|
+
(
|
|
1771
|
+
FfiConverterString.allocationSize(value.`address`) +
|
|
1772
|
+
FfiConverterULong.allocationSize(value.`amount`) +
|
|
1773
|
+
FfiConverterBoolean.allocationSize(value.`isChange`)
|
|
1774
|
+
)
|
|
1775
|
+
|
|
1776
|
+
override fun write(
|
|
1777
|
+
value: CardanoTxOutput,
|
|
1778
|
+
buf: ByteBuffer,
|
|
1779
|
+
) {
|
|
1780
|
+
FfiConverterString.write(value.`address`, buf)
|
|
1781
|
+
FfiConverterULong.write(value.`amount`, buf)
|
|
1782
|
+
FfiConverterBoolean.write(value.`isChange`, buf)
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
data class DerivedKeys(
|
|
1787
|
+
var `paymentPubkeyHex`: kotlin.String,
|
|
1788
|
+
var `stakePubkeyHex`: kotlin.String,
|
|
1789
|
+
) {
|
|
1790
|
+
companion object
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
/**
|
|
1794
|
+
* @suppress
|
|
1795
|
+
*/
|
|
1796
|
+
public object FfiConverterTypeDerivedKeys : FfiConverterRustBuffer<DerivedKeys> {
|
|
1797
|
+
override fun read(buf: ByteBuffer): DerivedKeys =
|
|
1798
|
+
DerivedKeys(
|
|
1799
|
+
FfiConverterString.read(buf),
|
|
1800
|
+
FfiConverterString.read(buf),
|
|
1801
|
+
)
|
|
1802
|
+
|
|
1803
|
+
override fun allocationSize(value: DerivedKeys) =
|
|
1804
|
+
(
|
|
1805
|
+
FfiConverterString.allocationSize(value.`paymentPubkeyHex`) +
|
|
1806
|
+
FfiConverterString.allocationSize(value.`stakePubkeyHex`)
|
|
1807
|
+
)
|
|
1808
|
+
|
|
1809
|
+
override fun write(
|
|
1810
|
+
value: DerivedKeys,
|
|
1811
|
+
buf: ByteBuffer,
|
|
1812
|
+
) {
|
|
1813
|
+
FfiConverterString.write(value.`paymentPubkeyHex`, buf)
|
|
1814
|
+
FfiConverterString.write(value.`stakePubkeyHex`, buf)
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
data class SignedTxResult(
|
|
1819
|
+
var `txId`: kotlin.String,
|
|
1820
|
+
var `txHex`: kotlin.String,
|
|
1821
|
+
) {
|
|
1822
|
+
companion object
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
/**
|
|
1826
|
+
* @suppress
|
|
1827
|
+
*/
|
|
1828
|
+
public object FfiConverterTypeSignedTxResult : FfiConverterRustBuffer<SignedTxResult> {
|
|
1829
|
+
override fun read(buf: ByteBuffer): SignedTxResult =
|
|
1830
|
+
SignedTxResult(
|
|
1831
|
+
FfiConverterString.read(buf),
|
|
1832
|
+
FfiConverterString.read(buf),
|
|
1833
|
+
)
|
|
1834
|
+
|
|
1835
|
+
override fun allocationSize(value: SignedTxResult) =
|
|
1836
|
+
(
|
|
1837
|
+
FfiConverterString.allocationSize(value.`txId`) +
|
|
1838
|
+
FfiConverterString.allocationSize(value.`txHex`)
|
|
1839
|
+
)
|
|
1840
|
+
|
|
1841
|
+
override fun write(
|
|
1842
|
+
value: SignedTxResult,
|
|
1843
|
+
buf: ByteBuffer,
|
|
1844
|
+
) {
|
|
1845
|
+
FfiConverterString.write(value.`txId`, buf)
|
|
1846
|
+
FfiConverterString.write(value.`txHex`, buf)
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
|
|
1850
|
+
data class TransparentInput(
|
|
1851
|
+
var `txid`: kotlin.String,
|
|
1852
|
+
var `vout`: kotlin.UInt,
|
|
1853
|
+
var `amount`: kotlin.ULong,
|
|
1854
|
+
var `address`: kotlin.String,
|
|
1855
|
+
var `seedFingerprint`: kotlin.String,
|
|
1856
|
+
var `derivationPath`: kotlin.String,
|
|
1857
|
+
var `publicKey`: kotlin.String,
|
|
1858
|
+
) {
|
|
1859
|
+
companion object
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
/**
|
|
1863
|
+
* @suppress
|
|
1864
|
+
*/
|
|
1865
|
+
public object FfiConverterTypeTransparentInput : FfiConverterRustBuffer<TransparentInput> {
|
|
1866
|
+
override fun read(buf: ByteBuffer): TransparentInput =
|
|
1867
|
+
TransparentInput(
|
|
1868
|
+
FfiConverterString.read(buf),
|
|
1869
|
+
FfiConverterUInt.read(buf),
|
|
1870
|
+
FfiConverterULong.read(buf),
|
|
1871
|
+
FfiConverterString.read(buf),
|
|
1872
|
+
FfiConverterString.read(buf),
|
|
1873
|
+
FfiConverterString.read(buf),
|
|
1874
|
+
FfiConverterString.read(buf),
|
|
1875
|
+
)
|
|
1876
|
+
|
|
1877
|
+
override fun allocationSize(value: TransparentInput) =
|
|
1878
|
+
(
|
|
1879
|
+
FfiConverterString.allocationSize(value.`txid`) +
|
|
1880
|
+
FfiConverterUInt.allocationSize(value.`vout`) +
|
|
1881
|
+
FfiConverterULong.allocationSize(value.`amount`) +
|
|
1882
|
+
FfiConverterString.allocationSize(value.`address`) +
|
|
1883
|
+
FfiConverterString.allocationSize(value.`seedFingerprint`) +
|
|
1884
|
+
FfiConverterString.allocationSize(value.`derivationPath`) +
|
|
1885
|
+
FfiConverterString.allocationSize(value.`publicKey`)
|
|
1886
|
+
)
|
|
1887
|
+
|
|
1888
|
+
override fun write(
|
|
1889
|
+
value: TransparentInput,
|
|
1890
|
+
buf: ByteBuffer,
|
|
1891
|
+
) {
|
|
1892
|
+
FfiConverterString.write(value.`txid`, buf)
|
|
1893
|
+
FfiConverterUInt.write(value.`vout`, buf)
|
|
1894
|
+
FfiConverterULong.write(value.`amount`, buf)
|
|
1895
|
+
FfiConverterString.write(value.`address`, buf)
|
|
1896
|
+
FfiConverterString.write(value.`seedFingerprint`, buf)
|
|
1897
|
+
FfiConverterString.write(value.`derivationPath`, buf)
|
|
1898
|
+
FfiConverterString.write(value.`publicKey`, buf)
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
data class TransparentOutput(
|
|
1903
|
+
var `address`: kotlin.String,
|
|
1904
|
+
var `amount`: kotlin.ULong,
|
|
1905
|
+
) {
|
|
1906
|
+
companion object
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1909
|
+
/**
|
|
1910
|
+
* @suppress
|
|
1911
|
+
*/
|
|
1912
|
+
public object FfiConverterTypeTransparentOutput : FfiConverterRustBuffer<TransparentOutput> {
|
|
1913
|
+
override fun read(buf: ByteBuffer): TransparentOutput =
|
|
1914
|
+
TransparentOutput(
|
|
1915
|
+
FfiConverterString.read(buf),
|
|
1916
|
+
FfiConverterULong.read(buf),
|
|
1917
|
+
)
|
|
1918
|
+
|
|
1919
|
+
override fun allocationSize(value: TransparentOutput) =
|
|
1920
|
+
(
|
|
1921
|
+
FfiConverterString.allocationSize(value.`address`) +
|
|
1922
|
+
FfiConverterULong.allocationSize(value.`amount`)
|
|
1923
|
+
)
|
|
1924
|
+
|
|
1925
|
+
override fun write(
|
|
1926
|
+
value: TransparentOutput,
|
|
1927
|
+
buf: ByteBuffer,
|
|
1928
|
+
) {
|
|
1929
|
+
FfiConverterString.write(value.`address`, buf)
|
|
1930
|
+
FfiConverterULong.write(value.`amount`, buf)
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
data class ZcashTxResult(
|
|
1935
|
+
var `txId`: kotlin.String,
|
|
1936
|
+
var `txHex`: kotlin.String,
|
|
1937
|
+
) {
|
|
1938
|
+
companion object
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1941
|
+
/**
|
|
1942
|
+
* @suppress
|
|
1943
|
+
*/
|
|
1944
|
+
public object FfiConverterTypeZcashTxResult : FfiConverterRustBuffer<ZcashTxResult> {
|
|
1945
|
+
override fun read(buf: ByteBuffer): ZcashTxResult =
|
|
1946
|
+
ZcashTxResult(
|
|
1947
|
+
FfiConverterString.read(buf),
|
|
1948
|
+
FfiConverterString.read(buf),
|
|
1949
|
+
)
|
|
1950
|
+
|
|
1951
|
+
override fun allocationSize(value: ZcashTxResult) =
|
|
1952
|
+
(
|
|
1953
|
+
FfiConverterString.allocationSize(value.`txId`) +
|
|
1954
|
+
FfiConverterString.allocationSize(value.`txHex`)
|
|
1955
|
+
)
|
|
1956
|
+
|
|
1957
|
+
override fun write(
|
|
1958
|
+
value: ZcashTxResult,
|
|
1959
|
+
buf: ByteBuffer,
|
|
1960
|
+
) {
|
|
1961
|
+
FfiConverterString.write(value.`txId`, buf)
|
|
1962
|
+
FfiConverterString.write(value.`txHex`, buf)
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
enum class CardanoNetwork {
|
|
1967
|
+
MAINNET,
|
|
1968
|
+
TESTNET,
|
|
1969
|
+
;
|
|
1970
|
+
|
|
1971
|
+
companion object
|
|
1972
|
+
}
|
|
1973
|
+
|
|
1974
|
+
/**
|
|
1975
|
+
* @suppress
|
|
1976
|
+
*/
|
|
1977
|
+
public object FfiConverterTypeCardanoNetwork : FfiConverterRustBuffer<CardanoNetwork> {
|
|
1978
|
+
override fun read(buf: ByteBuffer) =
|
|
1979
|
+
try {
|
|
1980
|
+
CardanoNetwork.values()[buf.getInt() - 1]
|
|
1981
|
+
} catch (e: IndexOutOfBoundsException) {
|
|
1982
|
+
throw RuntimeException("invalid enum value, something is very wrong!!", e)
|
|
1983
|
+
}
|
|
1984
|
+
|
|
1985
|
+
override fun allocationSize(value: CardanoNetwork) = 4UL
|
|
1986
|
+
|
|
1987
|
+
override fun write(
|
|
1988
|
+
value: CardanoNetwork,
|
|
1989
|
+
buf: ByteBuffer,
|
|
1990
|
+
) {
|
|
1991
|
+
buf.putInt(value.ordinal + 1)
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1995
|
+
sealed class PcztException(
|
|
1996
|
+
message: String,
|
|
1997
|
+
) : kotlin.Exception(message) {
|
|
1998
|
+
class Io(
|
|
1999
|
+
message: String,
|
|
2000
|
+
) : PcztException(message)
|
|
2001
|
+
|
|
2002
|
+
class Pczt(
|
|
2003
|
+
message: String,
|
|
2004
|
+
) : PcztException(message)
|
|
2005
|
+
|
|
2006
|
+
class InvalidAddress(
|
|
2007
|
+
message: String,
|
|
2008
|
+
) : PcztException(message)
|
|
2009
|
+
|
|
2010
|
+
class InvalidAmount(
|
|
2011
|
+
message: String,
|
|
2012
|
+
) : PcztException(message)
|
|
2013
|
+
|
|
2014
|
+
class InvalidHex(
|
|
2015
|
+
message: String,
|
|
2016
|
+
) : PcztException(message)
|
|
2017
|
+
|
|
2018
|
+
class SigningException(
|
|
2019
|
+
message: String,
|
|
2020
|
+
) : PcztException(message)
|
|
2021
|
+
|
|
2022
|
+
companion object ErrorHandler : UniffiRustCallStatusErrorHandler<PcztException> {
|
|
2023
|
+
override fun lift(error_buf: RustBuffer.ByValue): PcztException = FfiConverterTypePcztError.lift(error_buf)
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
/**
|
|
2028
|
+
* @suppress
|
|
2029
|
+
*/
|
|
2030
|
+
public object FfiConverterTypePcztError : FfiConverterRustBuffer<PcztException> {
|
|
2031
|
+
override fun read(buf: ByteBuffer): PcztException =
|
|
2032
|
+
when (buf.getInt()) {
|
|
2033
|
+
1 -> PcztException.Io(FfiConverterString.read(buf))
|
|
2034
|
+
2 -> PcztException.Pczt(FfiConverterString.read(buf))
|
|
2035
|
+
3 -> PcztException.InvalidAddress(FfiConverterString.read(buf))
|
|
2036
|
+
4 -> PcztException.InvalidAmount(FfiConverterString.read(buf))
|
|
2037
|
+
5 -> PcztException.InvalidHex(FfiConverterString.read(buf))
|
|
2038
|
+
6 -> PcztException.SigningException(FfiConverterString.read(buf))
|
|
2039
|
+
else -> throw RuntimeException("invalid error enum value, something is very wrong!!")
|
|
2040
|
+
}
|
|
2041
|
+
|
|
2042
|
+
override fun allocationSize(value: PcztException): ULong = 4UL
|
|
2043
|
+
|
|
2044
|
+
override fun write(
|
|
2045
|
+
value: PcztException,
|
|
2046
|
+
buf: ByteBuffer,
|
|
2047
|
+
) {
|
|
2048
|
+
when (value) {
|
|
2049
|
+
is PcztException.Io -> {
|
|
2050
|
+
buf.putInt(1)
|
|
2051
|
+
Unit
|
|
2052
|
+
}
|
|
2053
|
+
is PcztException.Pczt -> {
|
|
2054
|
+
buf.putInt(2)
|
|
2055
|
+
Unit
|
|
2056
|
+
}
|
|
2057
|
+
is PcztException.InvalidAddress -> {
|
|
2058
|
+
buf.putInt(3)
|
|
2059
|
+
Unit
|
|
2060
|
+
}
|
|
2061
|
+
is PcztException.InvalidAmount -> {
|
|
2062
|
+
buf.putInt(4)
|
|
2063
|
+
Unit
|
|
2064
|
+
}
|
|
2065
|
+
is PcztException.InvalidHex -> {
|
|
2066
|
+
buf.putInt(5)
|
|
2067
|
+
Unit
|
|
2068
|
+
}
|
|
2069
|
+
is PcztException.SigningException -> {
|
|
2070
|
+
buf.putInt(6)
|
|
2071
|
+
Unit
|
|
2072
|
+
}
|
|
2073
|
+
}.let { /* this makes the `when` an expression, which ensures it is exhaustive */ }
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
sealed class WalletException(
|
|
2078
|
+
message: String,
|
|
2079
|
+
) : kotlin.Exception(message) {
|
|
2080
|
+
class HexException(
|
|
2081
|
+
message: String,
|
|
2082
|
+
) : WalletException(message)
|
|
2083
|
+
|
|
2084
|
+
class InvalidPath(
|
|
2085
|
+
message: String,
|
|
2086
|
+
) : WalletException(message)
|
|
2087
|
+
|
|
2088
|
+
class CslException(
|
|
2089
|
+
message: String,
|
|
2090
|
+
) : WalletException(message)
|
|
2091
|
+
|
|
2092
|
+
class ParseException(
|
|
2093
|
+
message: String,
|
|
2094
|
+
) : WalletException(message)
|
|
2095
|
+
|
|
2096
|
+
companion object ErrorHandler : UniffiRustCallStatusErrorHandler<WalletException> {
|
|
2097
|
+
override fun lift(error_buf: RustBuffer.ByValue): WalletException = FfiConverterTypeWalletError.lift(error_buf)
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
/**
|
|
2102
|
+
* @suppress
|
|
2103
|
+
*/
|
|
2104
|
+
public object FfiConverterTypeWalletError : FfiConverterRustBuffer<WalletException> {
|
|
2105
|
+
override fun read(buf: ByteBuffer): WalletException =
|
|
2106
|
+
when (buf.getInt()) {
|
|
2107
|
+
1 -> WalletException.HexException(FfiConverterString.read(buf))
|
|
2108
|
+
2 -> WalletException.InvalidPath(FfiConverterString.read(buf))
|
|
2109
|
+
3 -> WalletException.CslException(FfiConverterString.read(buf))
|
|
2110
|
+
4 -> WalletException.ParseException(FfiConverterString.read(buf))
|
|
2111
|
+
else -> throw RuntimeException("invalid error enum value, something is very wrong!!")
|
|
2112
|
+
}
|
|
2113
|
+
|
|
2114
|
+
override fun allocationSize(value: WalletException): ULong = 4UL
|
|
2115
|
+
|
|
2116
|
+
override fun write(
|
|
2117
|
+
value: WalletException,
|
|
2118
|
+
buf: ByteBuffer,
|
|
2119
|
+
) {
|
|
2120
|
+
when (value) {
|
|
2121
|
+
is WalletException.HexException -> {
|
|
2122
|
+
buf.putInt(1)
|
|
2123
|
+
Unit
|
|
2124
|
+
}
|
|
2125
|
+
is WalletException.InvalidPath -> {
|
|
2126
|
+
buf.putInt(2)
|
|
2127
|
+
Unit
|
|
2128
|
+
}
|
|
2129
|
+
is WalletException.CslException -> {
|
|
2130
|
+
buf.putInt(3)
|
|
2131
|
+
Unit
|
|
2132
|
+
}
|
|
2133
|
+
is WalletException.ParseException -> {
|
|
2134
|
+
buf.putInt(4)
|
|
2135
|
+
Unit
|
|
2136
|
+
}
|
|
2137
|
+
}.let { /* this makes the `when` an expression, which ensures it is exhaustive */ }
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2141
|
+
/**
|
|
2142
|
+
* @suppress
|
|
2143
|
+
*/
|
|
2144
|
+
public object FfiConverterSequenceUByte : FfiConverterRustBuffer<List<kotlin.UByte>> {
|
|
2145
|
+
override fun read(buf: ByteBuffer): List<kotlin.UByte> {
|
|
2146
|
+
val len = buf.getInt()
|
|
2147
|
+
return List<kotlin.UByte>(len) {
|
|
2148
|
+
FfiConverterUByte.read(buf)
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
override fun allocationSize(value: List<kotlin.UByte>): ULong {
|
|
2153
|
+
val sizeForLength = 4UL
|
|
2154
|
+
val sizeForItems = value.map { FfiConverterUByte.allocationSize(it) }.sum()
|
|
2155
|
+
return sizeForLength + sizeForItems
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
override fun write(
|
|
2159
|
+
value: List<kotlin.UByte>,
|
|
2160
|
+
buf: ByteBuffer,
|
|
2161
|
+
) {
|
|
2162
|
+
buf.putInt(value.size)
|
|
2163
|
+
value.iterator().forEach {
|
|
2164
|
+
FfiConverterUByte.write(it, buf)
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
|
|
2169
|
+
/**
|
|
2170
|
+
* @suppress
|
|
2171
|
+
*/
|
|
2172
|
+
public object FfiConverterSequenceTypeCardanoInputRef : FfiConverterRustBuffer<List<CardanoInputRef>> {
|
|
2173
|
+
override fun read(buf: ByteBuffer): List<CardanoInputRef> {
|
|
2174
|
+
val len = buf.getInt()
|
|
2175
|
+
return List<CardanoInputRef>(len) {
|
|
2176
|
+
FfiConverterTypeCardanoInputRef.read(buf)
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
override fun allocationSize(value: List<CardanoInputRef>): ULong {
|
|
2181
|
+
val sizeForLength = 4UL
|
|
2182
|
+
val sizeForItems = value.map { FfiConverterTypeCardanoInputRef.allocationSize(it) }.sum()
|
|
2183
|
+
return sizeForLength + sizeForItems
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2186
|
+
override fun write(
|
|
2187
|
+
value: List<CardanoInputRef>,
|
|
2188
|
+
buf: ByteBuffer,
|
|
2189
|
+
) {
|
|
2190
|
+
buf.putInt(value.size)
|
|
2191
|
+
value.iterator().forEach {
|
|
2192
|
+
FfiConverterTypeCardanoInputRef.write(it, buf)
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
|
|
2197
|
+
/**
|
|
2198
|
+
* @suppress
|
|
2199
|
+
*/
|
|
2200
|
+
public object FfiConverterSequenceTypeCardanoTxInput : FfiConverterRustBuffer<List<CardanoTxInput>> {
|
|
2201
|
+
override fun read(buf: ByteBuffer): List<CardanoTxInput> {
|
|
2202
|
+
val len = buf.getInt()
|
|
2203
|
+
return List<CardanoTxInput>(len) {
|
|
2204
|
+
FfiConverterTypeCardanoTxInput.read(buf)
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
|
|
2208
|
+
override fun allocationSize(value: List<CardanoTxInput>): ULong {
|
|
2209
|
+
val sizeForLength = 4UL
|
|
2210
|
+
val sizeForItems = value.map { FfiConverterTypeCardanoTxInput.allocationSize(it) }.sum()
|
|
2211
|
+
return sizeForLength + sizeForItems
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
override fun write(
|
|
2215
|
+
value: List<CardanoTxInput>,
|
|
2216
|
+
buf: ByteBuffer,
|
|
2217
|
+
) {
|
|
2218
|
+
buf.putInt(value.size)
|
|
2219
|
+
value.iterator().forEach {
|
|
2220
|
+
FfiConverterTypeCardanoTxInput.write(it, buf)
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
|
|
2225
|
+
/**
|
|
2226
|
+
* @suppress
|
|
2227
|
+
*/
|
|
2228
|
+
public object FfiConverterSequenceTypeCardanoTxOutput : FfiConverterRustBuffer<List<CardanoTxOutput>> {
|
|
2229
|
+
override fun read(buf: ByteBuffer): List<CardanoTxOutput> {
|
|
2230
|
+
val len = buf.getInt()
|
|
2231
|
+
return List<CardanoTxOutput>(len) {
|
|
2232
|
+
FfiConverterTypeCardanoTxOutput.read(buf)
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2236
|
+
override fun allocationSize(value: List<CardanoTxOutput>): ULong {
|
|
2237
|
+
val sizeForLength = 4UL
|
|
2238
|
+
val sizeForItems = value.map { FfiConverterTypeCardanoTxOutput.allocationSize(it) }.sum()
|
|
2239
|
+
return sizeForLength + sizeForItems
|
|
2240
|
+
}
|
|
2241
|
+
|
|
2242
|
+
override fun write(
|
|
2243
|
+
value: List<CardanoTxOutput>,
|
|
2244
|
+
buf: ByteBuffer,
|
|
2245
|
+
) {
|
|
2246
|
+
buf.putInt(value.size)
|
|
2247
|
+
value.iterator().forEach {
|
|
2248
|
+
FfiConverterTypeCardanoTxOutput.write(it, buf)
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
/**
|
|
2254
|
+
* @suppress
|
|
2255
|
+
*/
|
|
2256
|
+
public object FfiConverterSequenceTypeTransparentInput : FfiConverterRustBuffer<List<TransparentInput>> {
|
|
2257
|
+
override fun read(buf: ByteBuffer): List<TransparentInput> {
|
|
2258
|
+
val len = buf.getInt()
|
|
2259
|
+
return List<TransparentInput>(len) {
|
|
2260
|
+
FfiConverterTypeTransparentInput.read(buf)
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
|
|
2264
|
+
override fun allocationSize(value: List<TransparentInput>): ULong {
|
|
2265
|
+
val sizeForLength = 4UL
|
|
2266
|
+
val sizeForItems = value.map { FfiConverterTypeTransparentInput.allocationSize(it) }.sum()
|
|
2267
|
+
return sizeForLength + sizeForItems
|
|
2268
|
+
}
|
|
2269
|
+
|
|
2270
|
+
override fun write(
|
|
2271
|
+
value: List<TransparentInput>,
|
|
2272
|
+
buf: ByteBuffer,
|
|
2273
|
+
) {
|
|
2274
|
+
buf.putInt(value.size)
|
|
2275
|
+
value.iterator().forEach {
|
|
2276
|
+
FfiConverterTypeTransparentInput.write(it, buf)
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
|
|
2281
|
+
/**
|
|
2282
|
+
* @suppress
|
|
2283
|
+
*/
|
|
2284
|
+
public object FfiConverterSequenceTypeTransparentOutput : FfiConverterRustBuffer<List<TransparentOutput>> {
|
|
2285
|
+
override fun read(buf: ByteBuffer): List<TransparentOutput> {
|
|
2286
|
+
val len = buf.getInt()
|
|
2287
|
+
return List<TransparentOutput>(len) {
|
|
2288
|
+
FfiConverterTypeTransparentOutput.read(buf)
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
override fun allocationSize(value: List<TransparentOutput>): ULong {
|
|
2293
|
+
val sizeForLength = 4UL
|
|
2294
|
+
val sizeForItems = value.map { FfiConverterTypeTransparentOutput.allocationSize(it) }.sum()
|
|
2295
|
+
return sizeForLength + sizeForItems
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2298
|
+
override fun write(
|
|
2299
|
+
value: List<TransparentOutput>,
|
|
2300
|
+
buf: ByteBuffer,
|
|
2301
|
+
) {
|
|
2302
|
+
buf.putInt(value.size)
|
|
2303
|
+
value.iterator().forEach {
|
|
2304
|
+
FfiConverterTypeTransparentOutput.write(it, buf)
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
@Throws(WalletException::class)
|
|
2310
|
+
fun `assembleTransactionAda`(
|
|
2311
|
+
`rawTxHex`: kotlin.String,
|
|
2312
|
+
`witnessSetHex`: kotlin.String,
|
|
2313
|
+
): SignedTxResult =
|
|
2314
|
+
FfiConverterTypeSignedTxResult.lift(
|
|
2315
|
+
uniffiRustCallWithError(WalletException) { _status ->
|
|
2316
|
+
UniffiLib.INSTANCE.uniffi_keystone_wallet_core_fn_func_assemble_transaction_ada(
|
|
2317
|
+
FfiConverterString.lower(`rawTxHex`),
|
|
2318
|
+
FfiConverterString.lower(`witnessSetHex`),
|
|
2319
|
+
_status,
|
|
2320
|
+
)
|
|
2321
|
+
},
|
|
2322
|
+
)
|
|
2323
|
+
|
|
2324
|
+
@Throws(WalletException::class)
|
|
2325
|
+
fun `composeTransactionAda`(
|
|
2326
|
+
`inputs`: List<CardanoTxInput>,
|
|
2327
|
+
`outputs`: List<CardanoTxOutput>,
|
|
2328
|
+
`changeAddress`: kotlin.String,
|
|
2329
|
+
`fee`: kotlin.ULong,
|
|
2330
|
+
`ttl`: kotlin.ULong,
|
|
2331
|
+
`network`: CardanoNetwork,
|
|
2332
|
+
): kotlin.String =
|
|
2333
|
+
FfiConverterString.lift(
|
|
2334
|
+
uniffiRustCallWithError(WalletException) { _status ->
|
|
2335
|
+
UniffiLib.INSTANCE.uniffi_keystone_wallet_core_fn_func_compose_transaction_ada(
|
|
2336
|
+
FfiConverterSequenceTypeCardanoTxInput.lower(`inputs`),
|
|
2337
|
+
FfiConverterSequenceTypeCardanoTxOutput.lower(`outputs`),
|
|
2338
|
+
FfiConverterString.lower(`changeAddress`),
|
|
2339
|
+
FfiConverterULong.lower(`fee`),
|
|
2340
|
+
FfiConverterULong.lower(`ttl`),
|
|
2341
|
+
FfiConverterTypeCardanoNetwork.lower(`network`),
|
|
2342
|
+
_status,
|
|
2343
|
+
)
|
|
2344
|
+
},
|
|
2345
|
+
)
|
|
2346
|
+
|
|
2347
|
+
@Throws(PcztException::class)
|
|
2348
|
+
fun `createPczt`(
|
|
2349
|
+
`consensusBranchId`: kotlin.UInt,
|
|
2350
|
+
`expiryHeight`: kotlin.UInt,
|
|
2351
|
+
`coinType`: kotlin.UInt,
|
|
2352
|
+
): Pczt =
|
|
2353
|
+
FfiConverterTypePczt.lift(
|
|
2354
|
+
uniffiRustCallWithError(PcztException) { _status ->
|
|
2355
|
+
UniffiLib.INSTANCE.uniffi_keystone_wallet_core_fn_func_create_pczt(
|
|
2356
|
+
FfiConverterUInt.lower(`consensusBranchId`),
|
|
2357
|
+
FfiConverterUInt.lower(`expiryHeight`),
|
|
2358
|
+
FfiConverterUInt.lower(`coinType`),
|
|
2359
|
+
_status,
|
|
2360
|
+
)
|
|
2361
|
+
},
|
|
2362
|
+
)
|
|
2363
|
+
|
|
2364
|
+
@Throws(PcztException::class)
|
|
2365
|
+
fun `createTransparentPczt`(
|
|
2366
|
+
`inputs`: List<TransparentInput>,
|
|
2367
|
+
`outputs`: List<TransparentOutput>,
|
|
2368
|
+
`blockHeight`: kotlin.UInt,
|
|
2369
|
+
): kotlin.String =
|
|
2370
|
+
FfiConverterString.lift(
|
|
2371
|
+
uniffiRustCallWithError(PcztException) { _status ->
|
|
2372
|
+
UniffiLib.INSTANCE.uniffi_keystone_wallet_core_fn_func_create_transparent_pczt(
|
|
2373
|
+
FfiConverterSequenceTypeTransparentInput.lower(`inputs`),
|
|
2374
|
+
FfiConverterSequenceTypeTransparentOutput.lower(`outputs`),
|
|
2375
|
+
FfiConverterUInt.lower(`blockHeight`),
|
|
2376
|
+
_status,
|
|
2377
|
+
)
|
|
2378
|
+
},
|
|
2379
|
+
)
|
|
2380
|
+
|
|
2381
|
+
@Throws(PcztException::class)
|
|
2382
|
+
fun `createTransparentPcztForSwapkit`(
|
|
2383
|
+
`pcztHex`: kotlin.String,
|
|
2384
|
+
`blockHeight`: kotlin.UInt,
|
|
2385
|
+
`pubkeyHex`: kotlin.String,
|
|
2386
|
+
`fingerprintHex`: kotlin.String,
|
|
2387
|
+
`pathStr`: kotlin.String,
|
|
2388
|
+
): kotlin.String =
|
|
2389
|
+
FfiConverterString.lift(
|
|
2390
|
+
uniffiRustCallWithError(PcztException) { _status ->
|
|
2391
|
+
UniffiLib.INSTANCE.uniffi_keystone_wallet_core_fn_func_create_transparent_pczt_for_swapkit(
|
|
2392
|
+
FfiConverterString.lower(`pcztHex`),
|
|
2393
|
+
FfiConverterUInt.lower(`blockHeight`),
|
|
2394
|
+
FfiConverterString.lower(`pubkeyHex`),
|
|
2395
|
+
FfiConverterString.lower(`fingerprintHex`),
|
|
2396
|
+
FfiConverterString.lower(`pathStr`),
|
|
2397
|
+
_status,
|
|
2398
|
+
)
|
|
2399
|
+
},
|
|
2400
|
+
)
|
|
2401
|
+
|
|
2402
|
+
@Throws(WalletException::class)
|
|
2403
|
+
fun `deriveAddressByPathAda`(
|
|
2404
|
+
`accountXpubHex`: kotlin.String,
|
|
2405
|
+
`path`: kotlin.String,
|
|
2406
|
+
`network`: CardanoNetwork,
|
|
2407
|
+
): kotlin.String =
|
|
2408
|
+
FfiConverterString.lift(
|
|
2409
|
+
uniffiRustCallWithError(WalletException) { _status ->
|
|
2410
|
+
UniffiLib.INSTANCE.uniffi_keystone_wallet_core_fn_func_derive_address_by_path_ada(
|
|
2411
|
+
FfiConverterString.lower(`accountXpubHex`),
|
|
2412
|
+
FfiConverterString.lower(`path`),
|
|
2413
|
+
FfiConverterTypeCardanoNetwork.lower(`network`),
|
|
2414
|
+
_status,
|
|
2415
|
+
)
|
|
2416
|
+
},
|
|
2417
|
+
)
|
|
2418
|
+
|
|
2419
|
+
@Throws(WalletException::class)
|
|
2420
|
+
fun `deriveEnterpriseAddressByPathAda`(
|
|
2421
|
+
`accountXpubHex`: kotlin.String,
|
|
2422
|
+
`path`: kotlin.String,
|
|
2423
|
+
`network`: CardanoNetwork,
|
|
2424
|
+
): kotlin.String =
|
|
2425
|
+
FfiConverterString.lift(
|
|
2426
|
+
uniffiRustCallWithError(WalletException) { _status ->
|
|
2427
|
+
UniffiLib.INSTANCE.uniffi_keystone_wallet_core_fn_func_derive_enterprise_address_by_path_ada(
|
|
2428
|
+
FfiConverterString.lower(`accountXpubHex`),
|
|
2429
|
+
FfiConverterString.lower(`path`),
|
|
2430
|
+
FfiConverterTypeCardanoNetwork.lower(`network`),
|
|
2431
|
+
_status,
|
|
2432
|
+
)
|
|
2433
|
+
},
|
|
2434
|
+
)
|
|
2435
|
+
|
|
2436
|
+
@Throws(WalletException::class)
|
|
2437
|
+
fun `derivePubkeyByPathAda`(
|
|
2438
|
+
`accountXpubHex`: kotlin.String,
|
|
2439
|
+
`path`: kotlin.String,
|
|
2440
|
+
): DerivedKeys =
|
|
2441
|
+
FfiConverterTypeDerivedKeys.lift(
|
|
2442
|
+
uniffiRustCallWithError(WalletException) { _status ->
|
|
2443
|
+
UniffiLib.INSTANCE.uniffi_keystone_wallet_core_fn_func_derive_pubkey_by_path_ada(
|
|
2444
|
+
FfiConverterString.lower(`accountXpubHex`),
|
|
2445
|
+
FfiConverterString.lower(`path`),
|
|
2446
|
+
_status,
|
|
2447
|
+
)
|
|
2448
|
+
},
|
|
2449
|
+
)
|
|
2450
|
+
|
|
2451
|
+
@Throws(WalletException::class)
|
|
2452
|
+
fun `deriveStakeAddressAda`(
|
|
2453
|
+
`accountXpubHex`: kotlin.String,
|
|
2454
|
+
`network`: CardanoNetwork,
|
|
2455
|
+
): kotlin.String =
|
|
2456
|
+
FfiConverterString.lift(
|
|
2457
|
+
uniffiRustCallWithError(WalletException) { _status ->
|
|
2458
|
+
UniffiLib.INSTANCE.uniffi_keystone_wallet_core_fn_func_derive_stake_address_ada(
|
|
2459
|
+
FfiConverterString.lower(`accountXpubHex`),
|
|
2460
|
+
FfiConverterTypeCardanoNetwork.lower(`network`),
|
|
2461
|
+
_status,
|
|
2462
|
+
)
|
|
2463
|
+
},
|
|
2464
|
+
)
|
|
2465
|
+
|
|
2466
|
+
@Throws(WalletException::class)
|
|
2467
|
+
fun `extractTransactionInputsAda`(`txHex`: kotlin.String): CardanoDecodedTx =
|
|
2468
|
+
FfiConverterTypeCardanoDecodedTx.lift(
|
|
2469
|
+
uniffiRustCallWithError(WalletException) { _status ->
|
|
2470
|
+
UniffiLib.INSTANCE.uniffi_keystone_wallet_core_fn_func_extract_transaction_inputs_ada(
|
|
2471
|
+
FfiConverterString.lower(`txHex`),
|
|
2472
|
+
_status,
|
|
2473
|
+
)
|
|
2474
|
+
},
|
|
2475
|
+
)
|
|
2476
|
+
|
|
2477
|
+
@Throws(PcztException::class)
|
|
2478
|
+
fun `finalizeThenExtractPcztTransaction`(`pcztHex`: kotlin.String): ZcashTxResult =
|
|
2479
|
+
FfiConverterTypeZcashTxResult.lift(
|
|
2480
|
+
uniffiRustCallWithError(PcztException) { _status ->
|
|
2481
|
+
UniffiLib.INSTANCE.uniffi_keystone_wallet_core_fn_func_finalize_then_extract_pczt_transaction(
|
|
2482
|
+
FfiConverterString.lower(`pcztHex`),
|
|
2483
|
+
_status,
|
|
2484
|
+
)
|
|
2485
|
+
},
|
|
2486
|
+
)
|