@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.
@@ -643,6 +643,14 @@ public protocol WalletProtocol: AnyObject, Sendable {
643
643
  */
644
644
  func nextIndex() -> UInt32
645
645
 
646
+ /**
647
+ * Opens the note that followed `contract` in its log, as a scan serves
648
+ * the pair; `note` is `None` when the scan served none. `path` is what
649
+ * [`Wallet::owns`] found for the contract's predicate. The opening it
650
+ * gives is what a later [`crate::TransferInput`] spends the output with.
651
+ */
652
+ func openNote(contract: Data, note: Data?, path: KeyPath) throws -> ReceivedNote
653
+
646
654
  /**
647
655
  * Which path below `next_index + gap`, on either branch, owns
648
656
  * `predicate`; `None` if none does. The scan re-derives every address
@@ -821,6 +829,24 @@ open func nextIndex() -> UInt32 {
821
829
  self.uniffiCloneHandle(),uniffiCallStatus
822
830
  )
823
831
  })
832
+ }
833
+
834
+ /**
835
+ * Opens the note that followed `contract` in its log, as a scan serves
836
+ * the pair; `note` is `None` when the scan served none. `path` is what
837
+ * [`Wallet::owns`] found for the contract's predicate. The opening it
838
+ * gives is what a later [`crate::TransferInput`] spends the output with.
839
+ */
840
+ open func openNote(contract: Data, note: Data?, path: KeyPath)throws -> ReceivedNote {
841
+ return try FfiConverterTypeReceivedNote_lift(try rustCallWithError(FfiConverterTypeFlameError_lift) {
842
+ uniffiCallStatus in
843
+ uniffi_flamewallet_ffi_fn_method_wallet_open_note(
844
+ self.uniffiCloneHandle(),
845
+ FfiConverterData.lower(contract),
846
+ FfiConverterOptionData.lower(note),
847
+ FfiConverterTypeKeyPath_lower(path),uniffiCallStatus
848
+ )
849
+ })
824
850
  }
825
851
 
826
852
  /**
@@ -978,7 +1004,7 @@ public func FfiConverterTypeContractInfo_lower(_ value: ContractInfo) -> RustBuf
978
1004
 
979
1005
 
980
1006
  /**
981
- * One contract the transfer creates, in request order.
1007
+ * One contract the transfer creates.
982
1008
  */
983
1009
  public struct CreatedOutput: Equatable, Hashable {
984
1010
  public var contractId: Data
@@ -987,10 +1013,11 @@ public struct CreatedOutput: Equatable, Hashable {
987
1013
  */
988
1014
  public var contract: Data
989
1015
  /**
990
- * Delivered to the recipient out of band, or kept for change: the
991
- * output can be spent from this record and nothing else.
1016
+ * The encrypted note that follows it on chain, as an indexer's scan
1017
+ * serves it. Its recipient opens it with [`crate::Wallet::open_note`];
1018
+ * so does this wallet, for its change.
992
1019
  */
993
- public var opening: Opening
1020
+ public var note: Data
994
1021
 
995
1022
  // Default memberwise initializers are never public by default, so we
996
1023
  // declare one manually.
@@ -999,12 +1026,13 @@ public struct CreatedOutput: Equatable, Hashable {
999
1026
  * Its published bytes, as an indexer will serve them once confirmed.
1000
1027
  */contract: Data,
1001
1028
  /**
1002
- * Delivered to the recipient out of band, or kept for change: the
1003
- * output can be spent from this record and nothing else.
1004
- */opening: Opening) {
1029
+ * The encrypted note that follows it on chain, as an indexer's scan
1030
+ * serves it. Its recipient opens it with [`crate::Wallet::open_note`];
1031
+ * so does this wallet, for its change.
1032
+ */note: Data) {
1005
1033
  self.contractId = contractId
1006
1034
  self.contract = contract
1007
- self.opening = opening
1035
+ self.note = note
1008
1036
  }
1009
1037
 
1010
1038
 
@@ -1025,14 +1053,14 @@ public struct FfiConverterTypeCreatedOutput: FfiConverterRustBuffer {
1025
1053
  try CreatedOutput(
1026
1054
  contractId: FfiConverterData.read(from: &buf),
1027
1055
  contract: FfiConverterData.read(from: &buf),
1028
- opening: FfiConverterTypeOpening.read(from: &buf)
1056
+ note: FfiConverterData.read(from: &buf)
1029
1057
  )
1030
1058
  }
1031
1059
 
1032
1060
  public static func write(_ value: CreatedOutput, into buf: inout [UInt8]) {
1033
1061
  FfiConverterData.write(value.contractId, into: &buf)
1034
1062
  FfiConverterData.write(value.contract, into: &buf)
1035
- FfiConverterTypeOpening.write(value.opening, into: &buf)
1063
+ FfiConverterData.write(value.note, into: &buf)
1036
1064
  }
1037
1065
  }
1038
1066
 
@@ -1250,6 +1278,75 @@ public func FfiConverterTypeOpening_lower(_ value: Opening) -> RustBuffer {
1250
1278
  }
1251
1279
 
1252
1280
 
1281
+ /**
1282
+ * What an opened note gives its recipient.
1283
+ */
1284
+ public struct ReceivedNote: Equatable, Hashable {
1285
+ /**
1286
+ * What a [`crate::TransferInput`] spends the output with.
1287
+ */
1288
+ public var opening: Opening
1289
+ /**
1290
+ * The memo, as the sender wrote it.
1291
+ */
1292
+ public var memo: Data
1293
+
1294
+ // Default memberwise initializers are never public by default, so we
1295
+ // declare one manually.
1296
+ public init(
1297
+ /**
1298
+ * What a [`crate::TransferInput`] spends the output with.
1299
+ */opening: Opening,
1300
+ /**
1301
+ * The memo, as the sender wrote it.
1302
+ */memo: Data) {
1303
+ self.opening = opening
1304
+ self.memo = memo
1305
+ }
1306
+
1307
+
1308
+
1309
+
1310
+ }
1311
+
1312
+ #if compiler(>=6)
1313
+ extension ReceivedNote: Sendable {}
1314
+ #endif
1315
+
1316
+ #if swift(>=5.8)
1317
+ @_documentation(visibility: private)
1318
+ #endif
1319
+ public struct FfiConverterTypeReceivedNote: FfiConverterRustBuffer {
1320
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ReceivedNote {
1321
+ return
1322
+ try ReceivedNote(
1323
+ opening: FfiConverterTypeOpening.read(from: &buf),
1324
+ memo: FfiConverterData.read(from: &buf)
1325
+ )
1326
+ }
1327
+
1328
+ public static func write(_ value: ReceivedNote, into buf: inout [UInt8]) {
1329
+ FfiConverterTypeOpening.write(value.opening, into: &buf)
1330
+ FfiConverterData.write(value.memo, into: &buf)
1331
+ }
1332
+ }
1333
+
1334
+
1335
+ #if swift(>=5.8)
1336
+ @_documentation(visibility: private)
1337
+ #endif
1338
+ public func FfiConverterTypeReceivedNote_lift(_ buf: RustBuffer) throws -> ReceivedNote {
1339
+ return try FfiConverterTypeReceivedNote.lift(buf)
1340
+ }
1341
+
1342
+ #if swift(>=5.8)
1343
+ @_documentation(visibility: private)
1344
+ #endif
1345
+ public func FfiConverterTypeReceivedNote_lower(_ value: ReceivedNote) -> RustBuffer {
1346
+ return FfiConverterTypeReceivedNote.lower(value)
1347
+ }
1348
+
1349
+
1253
1350
  /**
1254
1351
  * A signed transfer, ready to publish.
1255
1352
  */
@@ -1262,6 +1359,11 @@ public struct Transfer: Equatable, Hashable {
1262
1359
  * `BlockTx::to_bytes`: what a node's `submit_tx` takes.
1263
1360
  */
1264
1361
  public var blockTx: Data
1362
+ /**
1363
+ * In the order they are published, which is not request order: the
1364
+ * builder sorts them so that position says nothing about which one is
1365
+ * the change. Match one to its request by its predicate.
1366
+ */
1265
1367
  public var outputs: [CreatedOutput]
1266
1368
 
1267
1369
  // Default memberwise initializers are never public by default, so we
@@ -1272,7 +1374,12 @@ public struct Transfer: Equatable, Hashable {
1272
1374
  */txid: Data,
1273
1375
  /**
1274
1376
  * `BlockTx::to_bytes`: what a node's `submit_tx` takes.
1275
- */blockTx: Data, outputs: [CreatedOutput]) {
1377
+ */blockTx: Data,
1378
+ /**
1379
+ * In the order they are published, which is not request order: the
1380
+ * builder sorts them so that position says nothing about which one is
1381
+ * the change. Match one to its request by its predicate.
1382
+ */outputs: [CreatedOutput]) {
1276
1383
  self.txid = txid
1277
1384
  self.blockTx = blockTx
1278
1385
  self.outputs = outputs
@@ -1417,29 +1524,39 @@ public func FfiConverterTypeTransferInput_lower(_ value: TransferInput) -> RustB
1417
1524
  */
1418
1525
  public struct TransferOutput: Equatable, Hashable {
1419
1526
  /**
1420
- * The recipient's predicate: [`crate::address_to_predicate`], or
1421
- * [`crate::Wallet::address`] on the change branch.
1527
+ * The recipient's bech32f address, for the wallet's network; for
1528
+ * change, [`crate::Wallet::address`] on the change branch.
1422
1529
  */
1423
- public var predicate: Data
1530
+ public var address: String
1424
1531
  public var qty: UInt64
1425
1532
  /**
1426
1533
  * `None` for flames.
1427
1534
  */
1428
1535
  public var flavor: Data?
1536
+ /**
1537
+ * Sealed into the output's note with the amount; only the recipient
1538
+ * reads it. At most 8102 bytes; empty for none.
1539
+ */
1540
+ public var memo: Data
1429
1541
 
1430
1542
  // Default memberwise initializers are never public by default, so we
1431
1543
  // declare one manually.
1432
1544
  public init(
1433
1545
  /**
1434
- * The recipient's predicate: [`crate::address_to_predicate`], or
1435
- * [`crate::Wallet::address`] on the change branch.
1436
- */predicate: Data, qty: UInt64,
1546
+ * The recipient's bech32f address, for the wallet's network; for
1547
+ * change, [`crate::Wallet::address`] on the change branch.
1548
+ */address: String, qty: UInt64,
1437
1549
  /**
1438
1550
  * `None` for flames.
1439
- */flavor: Data?) {
1440
- self.predicate = predicate
1551
+ */flavor: Data?,
1552
+ /**
1553
+ * Sealed into the output's note with the amount; only the recipient
1554
+ * reads it. At most 8102 bytes; empty for none.
1555
+ */memo: Data) {
1556
+ self.address = address
1441
1557
  self.qty = qty
1442
1558
  self.flavor = flavor
1559
+ self.memo = memo
1443
1560
  }
1444
1561
 
1445
1562
 
@@ -1458,16 +1575,18 @@ public struct FfiConverterTypeTransferOutput: FfiConverterRustBuffer {
1458
1575
  public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TransferOutput {
1459
1576
  return
1460
1577
  try TransferOutput(
1461
- predicate: FfiConverterData.read(from: &buf),
1578
+ address: FfiConverterString.read(from: &buf),
1462
1579
  qty: FfiConverterUInt64.read(from: &buf),
1463
- flavor: FfiConverterOptionData.read(from: &buf)
1580
+ flavor: FfiConverterOptionData.read(from: &buf),
1581
+ memo: FfiConverterData.read(from: &buf)
1464
1582
  )
1465
1583
  }
1466
1584
 
1467
1585
  public static func write(_ value: TransferOutput, into buf: inout [UInt8]) {
1468
- FfiConverterData.write(value.predicate, into: &buf)
1586
+ FfiConverterString.write(value.address, into: &buf)
1469
1587
  FfiConverterUInt64.write(value.qty, into: &buf)
1470
1588
  FfiConverterOptionData.write(value.flavor, into: &buf)
1589
+ FfiConverterData.write(value.memo, into: &buf)
1471
1590
  }
1472
1591
  }
1473
1592
 
@@ -1702,6 +1821,12 @@ enum FlameError: Swift.Error, Equatable, Hashable, Foundation.LocalizedError {
1702
1821
  */
1703
1822
  case KeyMismatch(input: UInt32
1704
1823
  )
1824
+ /**
1825
+ * A note did not open; `failure` says how, and so what the wallet does
1826
+ * with the output.
1827
+ */
1828
+ case Note(failure: NoteFailure, reason: String
1829
+ )
1705
1830
  /**
1706
1831
  * The transfer could not be built or signed.
1707
1832
  */
@@ -1755,7 +1880,11 @@ public struct FfiConverterTypeFlameError: FfiConverterRustBuffer {
1755
1880
  case 6: return .KeyMismatch(
1756
1881
  input: try FfiConverterUInt32.read(from: &buf)
1757
1882
  )
1758
- case 7: return .Transfer(
1883
+ case 7: return .Note(
1884
+ failure: try FfiConverterTypeNoteFailure.read(from: &buf),
1885
+ reason: try FfiConverterString.read(from: &buf)
1886
+ )
1887
+ case 8: return .Transfer(
1759
1888
  reason: try FfiConverterString.read(from: &buf)
1760
1889
  )
1761
1890
 
@@ -1801,8 +1930,14 @@ public struct FfiConverterTypeFlameError: FfiConverterRustBuffer {
1801
1930
  FfiConverterUInt32.write(input, into: &buf)
1802
1931
 
1803
1932
 
1804
- case let .Transfer(reason):
1933
+ case let .Note(failure,reason):
1805
1934
  writeInt(&buf, Int32(7))
1935
+ FfiConverterTypeNoteFailure.write(failure, into: &buf)
1936
+ FfiConverterString.write(reason, into: &buf)
1937
+
1938
+
1939
+ case let .Transfer(reason):
1940
+ writeInt(&buf, Int32(8))
1806
1941
  FfiConverterString.write(reason, into: &buf)
1807
1942
 
1808
1943
  }
@@ -1893,6 +2028,126 @@ public func FfiConverterTypeNetwork_lower(_ value: Network) -> RustBuffer {
1893
2028
  }
1894
2029
 
1895
2030
 
2031
+
2032
+ /**
2033
+ * Why a note did not open: the outcomes of `docs/payments.md`
2034
+ * "Receiving", which a wallet treats differently.
2035
+ */
2036
+
2037
+ public enum NoteFailure: Equatable, Hashable {
2038
+
2039
+ /**
2040
+ * No note followed the output. The output is ours but unreadable: keep
2041
+ * and list it, and leave it out of the balance.
2042
+ */
2043
+ case missing
2044
+ /**
2045
+ * The note is malformed. Treated as [`NoteFailure::Missing`].
2046
+ */
2047
+ case malformed
2048
+ /**
2049
+ * A note version this library does not know; a later one may open it.
2050
+ */
2051
+ case unknownVersion
2052
+ /**
2053
+ * The note does not decrypt under this address. Treated as
2054
+ * [`NoteFailure::Missing`].
2055
+ */
2056
+ case undecryptable
2057
+ /**
2058
+ * The note decrypts but misstates its output: the sender erred or lied.
2059
+ * Keep and flag it; never count it.
2060
+ */
2061
+ case openingMismatch
2062
+ /**
2063
+ * The contract is a cleartext token, or not a token: there is no note
2064
+ * to open, and [`crate::decode_contract`] reads its amount.
2065
+ */
2066
+ case notConfidential
2067
+
2068
+
2069
+
2070
+
2071
+
2072
+ }
2073
+
2074
+ #if compiler(>=6)
2075
+ extension NoteFailure: Sendable {}
2076
+ #endif
2077
+
2078
+ #if swift(>=5.8)
2079
+ @_documentation(visibility: private)
2080
+ #endif
2081
+ public struct FfiConverterTypeNoteFailure: FfiConverterRustBuffer {
2082
+ typealias SwiftType = NoteFailure
2083
+
2084
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NoteFailure {
2085
+ let variant: Int32 = try readInt(&buf)
2086
+ switch variant {
2087
+
2088
+ case 1: return .missing
2089
+
2090
+ case 2: return .malformed
2091
+
2092
+ case 3: return .unknownVersion
2093
+
2094
+ case 4: return .undecryptable
2095
+
2096
+ case 5: return .openingMismatch
2097
+
2098
+ case 6: return .notConfidential
2099
+
2100
+ default: throw UniffiInternalError.unexpectedEnumCase
2101
+ }
2102
+ }
2103
+
2104
+ public static func write(_ value: NoteFailure, into buf: inout [UInt8]) {
2105
+ switch value {
2106
+
2107
+
2108
+ case .missing:
2109
+ writeInt(&buf, Int32(1))
2110
+
2111
+
2112
+ case .malformed:
2113
+ writeInt(&buf, Int32(2))
2114
+
2115
+
2116
+ case .unknownVersion:
2117
+ writeInt(&buf, Int32(3))
2118
+
2119
+
2120
+ case .undecryptable:
2121
+ writeInt(&buf, Int32(4))
2122
+
2123
+
2124
+ case .openingMismatch:
2125
+ writeInt(&buf, Int32(5))
2126
+
2127
+
2128
+ case .notConfidential:
2129
+ writeInt(&buf, Int32(6))
2130
+
2131
+ }
2132
+ }
2133
+ }
2134
+
2135
+
2136
+ #if swift(>=5.8)
2137
+ @_documentation(visibility: private)
2138
+ #endif
2139
+ public func FfiConverterTypeNoteFailure_lift(_ buf: RustBuffer) throws -> NoteFailure {
2140
+ return try FfiConverterTypeNoteFailure.lift(buf)
2141
+ }
2142
+
2143
+ #if swift(>=5.8)
2144
+ @_documentation(visibility: private)
2145
+ #endif
2146
+ public func FfiConverterTypeNoteFailure_lower(_ value: NoteFailure) -> RustBuffer {
2147
+ return FfiConverterTypeNoteFailure.lower(value)
2148
+ }
2149
+
2150
+
1896
2151
  #if swift(>=5.8)
1897
2152
  @_documentation(visibility: private)
1898
2153
  #endif
@@ -2163,6 +2418,9 @@ private let initializationResult: InitializationResult = {
2163
2418
  if (uniffi_flamewallet_ffi_checksum_method_wallet_next_index() != 50043) {
2164
2419
  return InitializationResult.apiChecksumMismatch
2165
2420
  }
2421
+ if (uniffi_flamewallet_ffi_checksum_method_wallet_open_note() != 45629) {
2422
+ return InitializationResult.apiChecksumMismatch
2423
+ }
2166
2424
  if (uniffi_flamewallet_ffi_checksum_method_wallet_owns() != 34274) {
2167
2425
  return InitializationResult.apiChecksumMismatch
2168
2426
  }
@@ -288,6 +288,11 @@ RustBuffer uniffi_flamewallet_ffi_fn_method_wallet_next_address(uint64_t ptr, Ru
288
288
  uint32_t uniffi_flamewallet_ffi_fn_method_wallet_next_index(uint64_t ptr, RustCallStatus *_Nonnull out_status
289
289
  );
290
290
  #endif
291
+ #ifndef UNIFFI_FFIDEF_UNIFFI_FLAMEWALLET_FFI_FN_METHOD_WALLET_OPEN_NOTE
292
+ #define UNIFFI_FFIDEF_UNIFFI_FLAMEWALLET_FFI_FN_METHOD_WALLET_OPEN_NOTE
293
+ RustBuffer uniffi_flamewallet_ffi_fn_method_wallet_open_note(uint64_t ptr, RustBuffer contract, RustBuffer note, RustBuffer path, RustCallStatus *_Nonnull out_status
294
+ );
295
+ #endif
291
296
  #ifndef UNIFFI_FFIDEF_UNIFFI_FLAMEWALLET_FFI_FN_METHOD_WALLET_OWNS
292
297
  #define UNIFFI_FFIDEF_UNIFFI_FLAMEWALLET_FFI_FN_METHOD_WALLET_OWNS
293
298
  RustBuffer uniffi_flamewallet_ffi_fn_method_wallet_owns(uint64_t ptr, RustBuffer predicate, uint32_t gap, RustCallStatus *_Nonnull out_status
@@ -652,6 +657,12 @@ uint16_t uniffi_flamewallet_ffi_checksum_method_wallet_next_address(void
652
657
  #define UNIFFI_FFIDEF_UNIFFI_FLAMEWALLET_FFI_CHECKSUM_METHOD_WALLET_NEXT_INDEX
653
658
  uint16_t uniffi_flamewallet_ffi_checksum_method_wallet_next_index(void
654
659
 
660
+ );
661
+ #endif
662
+ #ifndef UNIFFI_FFIDEF_UNIFFI_FLAMEWALLET_FFI_CHECKSUM_METHOD_WALLET_OPEN_NOTE
663
+ #define UNIFFI_FFIDEF_UNIFFI_FLAMEWALLET_FFI_CHECKSUM_METHOD_WALLET_OPEN_NOTE
664
+ uint16_t uniffi_flamewallet_ffi_checksum_method_wallet_open_note(void
665
+
655
666
  );
656
667
  #endif
657
668
  #ifndef UNIFFI_FFIDEF_UNIFFI_FLAMEWALLET_FFI_CHECKSUM_METHOD_WALLET_OWNS
@@ -288,6 +288,11 @@ RustBuffer uniffi_flamewallet_ffi_fn_method_wallet_next_address(uint64_t ptr, Ru
288
288
  uint32_t uniffi_flamewallet_ffi_fn_method_wallet_next_index(uint64_t ptr, RustCallStatus *_Nonnull out_status
289
289
  );
290
290
  #endif
291
+ #ifndef UNIFFI_FFIDEF_UNIFFI_FLAMEWALLET_FFI_FN_METHOD_WALLET_OPEN_NOTE
292
+ #define UNIFFI_FFIDEF_UNIFFI_FLAMEWALLET_FFI_FN_METHOD_WALLET_OPEN_NOTE
293
+ RustBuffer uniffi_flamewallet_ffi_fn_method_wallet_open_note(uint64_t ptr, RustBuffer contract, RustBuffer note, RustBuffer path, RustCallStatus *_Nonnull out_status
294
+ );
295
+ #endif
291
296
  #ifndef UNIFFI_FFIDEF_UNIFFI_FLAMEWALLET_FFI_FN_METHOD_WALLET_OWNS
292
297
  #define UNIFFI_FFIDEF_UNIFFI_FLAMEWALLET_FFI_FN_METHOD_WALLET_OWNS
293
298
  RustBuffer uniffi_flamewallet_ffi_fn_method_wallet_owns(uint64_t ptr, RustBuffer predicate, uint32_t gap, RustCallStatus *_Nonnull out_status
@@ -652,6 +657,12 @@ uint16_t uniffi_flamewallet_ffi_checksum_method_wallet_next_address(void
652
657
  #define UNIFFI_FFIDEF_UNIFFI_FLAMEWALLET_FFI_CHECKSUM_METHOD_WALLET_NEXT_INDEX
653
658
  uint16_t uniffi_flamewallet_ffi_checksum_method_wallet_next_index(void
654
659
 
660
+ );
661
+ #endif
662
+ #ifndef UNIFFI_FFIDEF_UNIFFI_FLAMEWALLET_FFI_CHECKSUM_METHOD_WALLET_OPEN_NOTE
663
+ #define UNIFFI_FFIDEF_UNIFFI_FLAMEWALLET_FFI_CHECKSUM_METHOD_WALLET_OPEN_NOTE
664
+ uint16_t uniffi_flamewallet_ffi_checksum_method_wallet_open_note(void
665
+
655
666
  );
656
667
  #endif
657
668
  #ifndef UNIFFI_FFIDEF_UNIFFI_FLAMEWALLET_FFI_CHECKSUM_METHOD_WALLET_OWNS
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runflame/wallet-rn",
3
- "version": "0.0.1-rc.0",
3
+ "version": "0.0.1-rc.2",
4
4
  "description": "Flame wallet keys and confidential transfers for iOS and Android: prebuilt libraries with UniFFI Swift and Kotlin bindings",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {