@runflame/wallet-rn 0.0.1-rc.0 → 0.0.1-rc.2

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.
@@ -2,12 +2,12 @@ Pod::Spec.new do |s|
2
2
  s.name = 'FlameWalletNative'
3
3
  # Swift code imports the bindings as `FlameWallet`.
4
4
  s.module_name = 'FlameWallet'
5
- s.version = '0.0.1-rc.0'
5
+ s.version = '0.0.1-rc.2'
6
6
  s.summary = 'Flame wallet keys and confidential transfers, with UniFFI Swift bindings'
7
7
  s.homepage = 'https://github.com/runflame/flame-lib'
8
8
  s.license = { :type => 'Apache-2.0', :file => 'LICENSE.txt' }
9
9
  s.author = 'Runflame'
10
- s.source = { :git => 'https://github.com/runflame/flame-lib.git', :tag => 'flamewallet-v0.0.1-rc.0' }
10
+ s.source = { :git => 'https://github.com/runflame/flame-lib.git', :tag => 'flamewallet-v0.0.1-rc.2' }
11
11
  s.platforms = { :ios => '15.1' }
12
12
  s.swift_version = '5.9'
13
13
  s.source_files = 'ios/FlameWallet.swift'
@@ -11,7 +11,7 @@ android {
11
11
 
12
12
  defaultConfig {
13
13
  minSdk 24
14
- versionName '0.0.1-rc.0'
14
+ versionName '0.0.1-rc.2'
15
15
  }
16
16
 
17
17
  compileOptions {
@@ -697,6 +697,8 @@ internal object IntegrityCheckingUniffiLib {
697
697
  ): Int
698
698
  external fun uniffi_flamewallet_ffi_checksum_method_wallet_next_index(
699
699
  ): Int
700
+ external fun uniffi_flamewallet_ffi_checksum_method_wallet_open_note(
701
+ ): Int
700
702
  external fun uniffi_flamewallet_ffi_checksum_method_wallet_owns(
701
703
  ): Int
702
704
  external fun uniffi_flamewallet_ffi_checksum_method_wallet_receiving_key(
@@ -743,6 +745,8 @@ internal object UniffiLib {
743
745
  ): RustBuffer.ByValue
744
746
  external fun uniffi_flamewallet_ffi_fn_method_wallet_next_index(`ptr`: Long,uniffi_out_err: UniffiRustCallStatus,
745
747
  ): Int
748
+ external fun uniffi_flamewallet_ffi_fn_method_wallet_open_note(`ptr`: Long,`contract`: RustBuffer.ByValue,`note`: RustBuffer.ByValue,`path`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
749
+ ): RustBuffer.ByValue
746
750
  external fun uniffi_flamewallet_ffi_fn_method_wallet_owns(`ptr`: Long,`predicate`: RustBuffer.ByValue,`gap`: Int,uniffi_out_err: UniffiRustCallStatus,
747
751
  ): RustBuffer.ByValue
748
752
  external fun uniffi_flamewallet_ffi_fn_method_wallet_receiving_key(`ptr`: Long,uniffi_out_err: UniffiRustCallStatus,
@@ -911,6 +915,9 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) {
911
915
  if ((lib.uniffi_flamewallet_ffi_checksum_method_wallet_next_index() and 0xFFFF) != 50043) {
912
916
  throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
913
917
  }
918
+ if ((lib.uniffi_flamewallet_ffi_checksum_method_wallet_open_note() and 0xFFFF) != 45629) {
919
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
920
+ }
914
921
  if ((lib.uniffi_flamewallet_ffi_checksum_method_wallet_owns() and 0xFFFF) != 34274) {
915
922
  throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
916
923
  }
@@ -1390,6 +1397,14 @@ public interface WalletInterface {
1390
1397
  */
1391
1398
  fun `nextIndex`(): kotlin.UInt
1392
1399
 
1400
+ /**
1401
+ * Opens the note that followed `contract` in its log, as a scan serves
1402
+ * the pair; `note` is `None` when the scan served none. `path` is what
1403
+ * [`Wallet::owns`] found for the contract's predicate. The opening it
1404
+ * gives is what a later [`crate::TransferInput`] spends the output with.
1405
+ */
1406
+ fun `openNote`(`contract`: kotlin.ByteArray, `note`: kotlin.ByteArray?, `path`: KeyPath): ReceivedNote
1407
+
1393
1408
  /**
1394
1409
  * Which path below `next_index + gap`, on either branch, owns
1395
1410
  * `predicate`; `None` if none does. The scan re-derives every address
@@ -1628,6 +1643,29 @@ open class Wallet: Disposable, AutoCloseable, WalletInterface
1628
1643
 
1629
1644
 
1630
1645
 
1646
+ /**
1647
+ * Opens the note that followed `contract` in its log, as a scan serves
1648
+ * the pair; `note` is `None` when the scan served none. `path` is what
1649
+ * [`Wallet::owns`] found for the contract's predicate. The opening it
1650
+ * gives is what a later [`crate::TransferInput`] spends the output with.
1651
+ */
1652
+ @Throws(FlameException::class)override fun `openNote`(`contract`: kotlin.ByteArray, `note`: kotlin.ByteArray?, `path`: KeyPath): ReceivedNote {
1653
+ return FfiConverterTypeReceivedNote.lift(
1654
+ callWithHandle {
1655
+ uniffiRustCallWithError(FlameException) { _status ->
1656
+ UniffiLib.uniffi_flamewallet_ffi_fn_method_wallet_open_note(
1657
+ it,
1658
+
1659
+ FfiConverterByteArray.lower(`contract`),
1660
+ FfiConverterOptionalByteArray.lower(`note`),
1661
+ FfiConverterTypeKeyPath.lower(`path`),_status)
1662
+ }
1663
+ }
1664
+ )
1665
+ }
1666
+
1667
+
1668
+
1631
1669
  /**
1632
1670
  * Which path below `next_index + gap`, on either branch, owns
1633
1671
  * `predicate`; `None` if none does. The scan re-derives every address
@@ -1779,7 +1817,7 @@ public object FfiConverterTypeContractInfo: FfiConverterRustBuffer<ContractInfo>
1779
1817
 
1780
1818
 
1781
1819
  /**
1782
- * One contract the transfer creates, in request order.
1820
+ * One contract the transfer creates.
1783
1821
  */
1784
1822
  data class CreatedOutput (
1785
1823
  var `contractId`: kotlin.ByteArray
@@ -1790,10 +1828,11 @@ data class CreatedOutput (
1790
1828
  var `contract`: kotlin.ByteArray
1791
1829
  ,
1792
1830
  /**
1793
- * Delivered to the recipient out of band, or kept for change: the
1794
- * output can be spent from this record and nothing else.
1831
+ * The encrypted note that follows it on chain, as an indexer's scan
1832
+ * serves it. Its recipient opens it with [`crate::Wallet::open_note`];
1833
+ * so does this wallet, for its change.
1795
1834
  */
1796
- var `opening`: Opening
1835
+ var `note`: kotlin.ByteArray
1797
1836
 
1798
1837
  ){
1799
1838
 
@@ -1812,20 +1851,20 @@ public object FfiConverterTypeCreatedOutput: FfiConverterRustBuffer<CreatedOutpu
1812
1851
  return CreatedOutput(
1813
1852
  FfiConverterByteArray.read(buf),
1814
1853
  FfiConverterByteArray.read(buf),
1815
- FfiConverterTypeOpening.read(buf),
1854
+ FfiConverterByteArray.read(buf),
1816
1855
  )
1817
1856
  }
1818
1857
 
1819
1858
  override fun allocationSize(value: CreatedOutput) = (
1820
1859
  FfiConverterByteArray.allocationSize(value.`contractId`) +
1821
1860
  FfiConverterByteArray.allocationSize(value.`contract`) +
1822
- FfiConverterTypeOpening.allocationSize(value.`opening`)
1861
+ FfiConverterByteArray.allocationSize(value.`note`)
1823
1862
  )
1824
1863
 
1825
1864
  override fun write(value: CreatedOutput, buf: ByteBuffer) {
1826
1865
  FfiConverterByteArray.write(value.`contractId`, buf)
1827
1866
  FfiConverterByteArray.write(value.`contract`, buf)
1828
- FfiConverterTypeOpening.write(value.`opening`, buf)
1867
+ FfiConverterByteArray.write(value.`note`, buf)
1829
1868
  }
1830
1869
  }
1831
1870
 
@@ -1978,6 +2017,53 @@ public object FfiConverterTypeOpening: FfiConverterRustBuffer<Opening> {
1978
2017
 
1979
2018
 
1980
2019
 
2020
+ /**
2021
+ * What an opened note gives its recipient.
2022
+ */
2023
+ data class ReceivedNote (
2024
+ /**
2025
+ * What a [`crate::TransferInput`] spends the output with.
2026
+ */
2027
+ var `opening`: Opening
2028
+ ,
2029
+ /**
2030
+ * The memo, as the sender wrote it.
2031
+ */
2032
+ var `memo`: kotlin.ByteArray
2033
+
2034
+ ){
2035
+
2036
+
2037
+
2038
+
2039
+
2040
+ companion object
2041
+ }
2042
+
2043
+ /**
2044
+ * @suppress
2045
+ */
2046
+ public object FfiConverterTypeReceivedNote: FfiConverterRustBuffer<ReceivedNote> {
2047
+ override fun read(buf: ByteBuffer): ReceivedNote {
2048
+ return ReceivedNote(
2049
+ FfiConverterTypeOpening.read(buf),
2050
+ FfiConverterByteArray.read(buf),
2051
+ )
2052
+ }
2053
+
2054
+ override fun allocationSize(value: ReceivedNote) = (
2055
+ FfiConverterTypeOpening.allocationSize(value.`opening`) +
2056
+ FfiConverterByteArray.allocationSize(value.`memo`)
2057
+ )
2058
+
2059
+ override fun write(value: ReceivedNote, buf: ByteBuffer) {
2060
+ FfiConverterTypeOpening.write(value.`opening`, buf)
2061
+ FfiConverterByteArray.write(value.`memo`, buf)
2062
+ }
2063
+ }
2064
+
2065
+
2066
+
1981
2067
  /**
1982
2068
  * A signed transfer, ready to publish.
1983
2069
  */
@@ -1992,6 +2078,11 @@ data class Transfer (
1992
2078
  */
1993
2079
  var `blockTx`: kotlin.ByteArray
1994
2080
  ,
2081
+ /**
2082
+ * In the order they are published, which is not request order: the
2083
+ * builder sorts them so that position says nothing about which one is
2084
+ * the change. Match one to its request by its predicate.
2085
+ */
1995
2086
  var `outputs`: List<CreatedOutput>
1996
2087
 
1997
2088
  ){
@@ -2098,10 +2189,10 @@ public object FfiConverterTypeTransferInput: FfiConverterRustBuffer<TransferInpu
2098
2189
  */
2099
2190
  data class TransferOutput (
2100
2191
  /**
2101
- * The recipient's predicate: [`crate::address_to_predicate`], or
2102
- * [`crate::Wallet::address`] on the change branch.
2192
+ * The recipient's bech32f address, for the wallet's network; for
2193
+ * change, [`crate::Wallet::address`] on the change branch.
2103
2194
  */
2104
- var `predicate`: kotlin.ByteArray
2195
+ var `address`: kotlin.String
2105
2196
  ,
2106
2197
  var `qty`: kotlin.ULong
2107
2198
  ,
@@ -2109,6 +2200,12 @@ data class TransferOutput (
2109
2200
  * `None` for flames.
2110
2201
  */
2111
2202
  var `flavor`: kotlin.ByteArray?
2203
+ ,
2204
+ /**
2205
+ * Sealed into the output's note with the amount; only the recipient
2206
+ * reads it. At most 8102 bytes; empty for none.
2207
+ */
2208
+ var `memo`: kotlin.ByteArray
2112
2209
 
2113
2210
  ){
2114
2211
 
@@ -2125,22 +2222,25 @@ data class TransferOutput (
2125
2222
  public object FfiConverterTypeTransferOutput: FfiConverterRustBuffer<TransferOutput> {
2126
2223
  override fun read(buf: ByteBuffer): TransferOutput {
2127
2224
  return TransferOutput(
2128
- FfiConverterByteArray.read(buf),
2225
+ FfiConverterString.read(buf),
2129
2226
  FfiConverterULong.read(buf),
2130
2227
  FfiConverterOptionalByteArray.read(buf),
2228
+ FfiConverterByteArray.read(buf),
2131
2229
  )
2132
2230
  }
2133
2231
 
2134
2232
  override fun allocationSize(value: TransferOutput) = (
2135
- FfiConverterByteArray.allocationSize(value.`predicate`) +
2233
+ FfiConverterString.allocationSize(value.`address`) +
2136
2234
  FfiConverterULong.allocationSize(value.`qty`) +
2137
- FfiConverterOptionalByteArray.allocationSize(value.`flavor`)
2235
+ FfiConverterOptionalByteArray.allocationSize(value.`flavor`) +
2236
+ FfiConverterByteArray.allocationSize(value.`memo`)
2138
2237
  )
2139
2238
 
2140
2239
  override fun write(value: TransferOutput, buf: ByteBuffer) {
2141
- FfiConverterByteArray.write(value.`predicate`, buf)
2240
+ FfiConverterString.write(value.`address`, buf)
2142
2241
  FfiConverterULong.write(value.`qty`, buf)
2143
2242
  FfiConverterOptionalByteArray.write(value.`flavor`, buf)
2243
+ FfiConverterByteArray.write(value.`memo`, buf)
2144
2244
  }
2145
2245
  }
2146
2246
 
@@ -2390,6 +2490,20 @@ sealed class FlameException: kotlin.Exception() {
2390
2490
  get() = "input=${ `input` }"
2391
2491
  }
2392
2492
 
2493
+ /**
2494
+ * A note did not open; `failure` says how, and so what the wallet does
2495
+ * with the output.
2496
+ */
2497
+ class Note(
2498
+
2499
+ val `failure`: NoteFailure,
2500
+
2501
+ val `reason`: kotlin.String
2502
+ ) : FlameException() {
2503
+ override val message
2504
+ get() = "failure=${ `failure` }, reason=${ `reason` }"
2505
+ }
2506
+
2393
2507
  /**
2394
2508
  * The transfer could not be built or signed.
2395
2509
  */
@@ -2439,7 +2553,11 @@ public object FfiConverterTypeFlameError : FfiConverterRustBuffer<FlameException
2439
2553
  6 -> FlameException.KeyMismatch(
2440
2554
  FfiConverterUInt.read(buf),
2441
2555
  )
2442
- 7 -> FlameException.Transfer(
2556
+ 7 -> FlameException.Note(
2557
+ FfiConverterTypeNoteFailure.read(buf),
2558
+ FfiConverterString.read(buf),
2559
+ )
2560
+ 8 -> FlameException.Transfer(
2443
2561
  FfiConverterString.read(buf),
2444
2562
  )
2445
2563
  else -> throw RuntimeException("invalid error enum value, something is very wrong!!")
@@ -2479,6 +2597,12 @@ public object FfiConverterTypeFlameError : FfiConverterRustBuffer<FlameException
2479
2597
  4UL
2480
2598
  + FfiConverterUInt.allocationSize(value.`input`)
2481
2599
  )
2600
+ is FlameException.Note -> (
2601
+ // Add the size for the Int that specifies the variant plus the size needed for all fields
2602
+ 4UL
2603
+ + FfiConverterTypeNoteFailure.allocationSize(value.`failure`)
2604
+ + FfiConverterString.allocationSize(value.`reason`)
2605
+ )
2482
2606
  is FlameException.Transfer -> (
2483
2607
  // Add the size for the Int that specifies the variant plus the size needed for all fields
2484
2608
  4UL
@@ -2520,8 +2644,14 @@ public object FfiConverterTypeFlameError : FfiConverterRustBuffer<FlameException
2520
2644
  FfiConverterUInt.write(value.`input`, buf)
2521
2645
  Unit
2522
2646
  }
2523
- is FlameException.Transfer -> {
2647
+ is FlameException.Note -> {
2524
2648
  buf.putInt(7)
2649
+ FfiConverterTypeNoteFailure.write(value.`failure`, buf)
2650
+ FfiConverterString.write(value.`reason`, buf)
2651
+ Unit
2652
+ }
2653
+ is FlameException.Transfer -> {
2654
+ buf.putInt(8)
2525
2655
  FfiConverterString.write(value.`reason`, buf)
2526
2656
  Unit
2527
2657
  }
@@ -2569,6 +2699,70 @@ public object FfiConverterTypeNetwork: FfiConverterRustBuffer<Network> {
2569
2699
 
2570
2700
 
2571
2701
 
2702
+ /**
2703
+ * Why a note did not open: the outcomes of `docs/payments.md`
2704
+ * "Receiving", which a wallet treats differently.
2705
+ */
2706
+
2707
+ enum class NoteFailure {
2708
+
2709
+ /**
2710
+ * No note followed the output. The output is ours but unreadable: keep
2711
+ * and list it, and leave it out of the balance.
2712
+ */
2713
+ MISSING,
2714
+ /**
2715
+ * The note is malformed. Treated as [`NoteFailure::Missing`].
2716
+ */
2717
+ MALFORMED,
2718
+ /**
2719
+ * A note version this library does not know; a later one may open it.
2720
+ */
2721
+ UNKNOWN_VERSION,
2722
+ /**
2723
+ * The note does not decrypt under this address. Treated as
2724
+ * [`NoteFailure::Missing`].
2725
+ */
2726
+ UNDECRYPTABLE,
2727
+ /**
2728
+ * The note decrypts but misstates its output: the sender erred or lied.
2729
+ * Keep and flag it; never count it.
2730
+ */
2731
+ OPENING_MISMATCH,
2732
+ /**
2733
+ * The contract is a cleartext token, or not a token: there is no note
2734
+ * to open, and [`crate::decode_contract`] reads its amount.
2735
+ */
2736
+ NOT_CONFIDENTIAL;
2737
+
2738
+
2739
+
2740
+
2741
+ companion object
2742
+ }
2743
+
2744
+
2745
+ /**
2746
+ * @suppress
2747
+ */
2748
+ public object FfiConverterTypeNoteFailure: FfiConverterRustBuffer<NoteFailure> {
2749
+ override fun read(buf: ByteBuffer) = try {
2750
+ NoteFailure.values()[buf.getInt() - 1]
2751
+ } catch (e: IndexOutOfBoundsException) {
2752
+ throw RuntimeException("invalid enum value, something is very wrong!!", e)
2753
+ }
2754
+
2755
+ override fun allocationSize(value: NoteFailure) = 4UL
2756
+
2757
+ override fun write(value: NoteFailure, buf: ByteBuffer) {
2758
+ buf.putInt(value.ordinal + 1)
2759
+ }
2760
+ }
2761
+
2762
+
2763
+
2764
+
2765
+
2572
2766
 
2573
2767
  /**
2574
2768
  * @suppress