@bsv/expo-wallet-toolbox 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +114 -0
  2. package/README.md +78 -13
  3. package/core/contacts/contactActivity.ts +48 -28
  4. package/core/contacts/contactsStore.ts +2 -2
  5. package/core/context/WalletContext.tsx +166 -219
  6. package/core/demo/demoAssets.ts +8 -10
  7. package/core/demo/demoLedger.ts +32 -38
  8. package/core/demo/demoMandalaRuntime.ts +67 -49
  9. package/core/demo/index.ts +1 -1
  10. package/core/i18n/translations.tsx +72 -0
  11. package/core/index.ts +55 -37
  12. package/core/localpay/build.ts +110 -569
  13. package/core/localpay/codec.ts +190 -93
  14. package/core/localpay/pending.ts +217 -202
  15. package/core/localpay/session.ts +99 -25
  16. package/core/localpay/types.ts +6 -5
  17. package/core/localpay/verify.ts +118 -173
  18. package/core/mandala/abortGuard.ts +97 -120
  19. package/core/mandala/accessPolicy.ts +133 -0
  20. package/core/mandala/assets.ts +370 -0
  21. package/core/mandala/colorGuard.ts +178 -0
  22. package/core/mandala/colorModule.ts +82 -0
  23. package/core/mandala/createRuntime.ts +483 -2392
  24. package/core/mandala/handle.ts +694 -0
  25. package/core/mandala/kvStore.ts +105 -0
  26. package/core/mandala/nearby.ts +185 -0
  27. package/core/mandala/receipt.ts +121 -0
  28. package/core/mandala/runtime.ts +166 -312
  29. package/core/mandala/settle.ts +540 -0
  30. package/core/mandala/transferJournal.ts +395 -0
  31. package/core/mandala/types.ts +61 -311
  32. package/core/networks.ts +5 -5
  33. package/core/offline/cancelParked.ts +80 -63
  34. package/core/offline/payerHold.ts +52 -118
  35. package/core/parsePeerPayURI.ts +25 -12
  36. package/core/pay/rails/handle.ts +15 -14
  37. package/core/pay/rails/index.ts +5 -3
  38. package/core/pay/rails/nearby.ts +25 -87
  39. package/core/profiles/assertProfileEmpty.ts +19 -10
  40. package/core/services/vault/guard.ts +5 -4
  41. package/core/storage/StorageExpoSQLite.ts +93 -229
  42. package/core/storage/methods/processOfflineActions.ts +86 -136
  43. package/core/storage/schema/createTables.ts +9 -184
  44. package/package.json +6 -5
  45. package/ui/components/pay/AssetPicker.tsx +2 -2
  46. package/ui/components/pay/HandleReceive.tsx +4 -4
  47. package/ui/components/pay/NearbyFlow.tsx +324 -239
  48. package/ui/components/pay/RequestHub.tsx +10 -0
  49. package/ui/components/pay/UniversalSend.tsx +31 -28
  50. package/ui/components/pay/useRecipientInput.ts +2 -2
  51. package/ui/components/ui/PermissionSheet.tsx +94 -160
  52. package/ui/components/ui/colorPrompt.ts +236 -0
  53. package/ui/components/wallet/AmountInput.tsx +9 -6
  54. package/ui/components/wallet/AssetAmount.tsx +6 -6
  55. package/ui/components/wallet/AssetSwitcherDropdown.tsx +26 -7
  56. package/ui/components/wallet/Balance.tsx +3 -1
  57. package/ui/components/wallet/ContactActivityList.tsx +10 -13
  58. package/ui/components/wallet/tokenEviction.ts +9 -9
  59. package/ui/hooks/useMandala.ts +6 -6
  60. package/ui/hooks/useSpendableBalance.ts +3 -1
  61. package/ui/importDatabases.ts +1 -1
  62. package/ui/screens/PayScreen.tsx +14 -20
  63. package/ui/screens/SettingsScreen.tsx +3 -1
  64. package/ui/screens/WalletCheckScreen.tsx +7 -2
  65. package/ui/screens/WalletHomeScreen.tsx +40 -14
  66. package/ui/screens/tokenRowTitle.ts +28 -15
  67. package/ui/tokenFormat.ts +133 -69
  68. package/ui/tokenStatus.ts +5 -8
  69. package/core/localpay/settlementAck.ts +0 -155
  70. package/core/mandala/basketMigration.ts +0 -166
  71. package/core/mandala/bundle.ts +0 -244
  72. package/core/mandala/drain.ts +0 -754
  73. package/core/mandala/inboxPrehold.ts +0 -193
  74. package/core/mandala/permissionModule.ts +0 -931
  75. package/core/mandala/resendTransfer.ts +0 -178
  76. package/core/mandala/settlementStore.ts +0 -434
  77. package/core/mandala/token.ts +0 -45
  78. package/core/offline/tokenFrames.ts +0 -197
package/core/index.ts CHANGED
@@ -146,7 +146,6 @@ export * from './offline/hold'
146
146
  export * from './offline/order'
147
147
  export * from './offline/plan'
148
148
  export * from './offline/payerHold'
149
- export * from './offline/tokenFrames'
150
149
  export {
151
150
  cancelParkedPayment,
152
151
  chainAlreadyKnows,
@@ -156,79 +155,98 @@ export {
156
155
  type CancelParkedSettlementDeps
157
156
  } from './offline/cancelParked'
158
157
 
159
- // Mandala token settlement — the four evidence tables, and the
160
- // submit-before-broadcast drain over them.
158
+ // 1Color transfers — the journal types, the `color_transfers` journal (the
159
+ // one key for the broadcast hold and the abort refusal), and the one-time
160
+ // migration off the Mandala settlement tables.
161
161
  export * from './mandala/types'
162
- export { createSettlementStore, type SettlementDb, type SqlSettlementStore } from './mandala/settlementStore'
162
+ export {
163
+ createTransferJournal,
164
+ migrateMandalaToColor,
165
+ COLOR_MIGRATION_MARKER,
166
+ type JournalDb,
167
+ type TransferJournal
168
+ } from './mandala/transferJournal'
163
169
  // Guard #4: an abortAction may not release the inputs of a token payment the
164
170
  // overlay already has (the 2026-09-15 incident).
165
171
  export {
166
172
  abortIsBlockedBy,
167
173
  wrapAbortActionForSettlements,
168
- ABORT_BLOCKED_SETTLEMENT_STATES,
174
+ ABORT_BLOCKED_TRANSFER_STATES,
169
175
  type AbortableManager,
170
- type SettlementStoreLookup
176
+ type TransferJournalLookup,
177
+ type TokenSettlementPossible
171
178
  } from './mandala/abortGuard'
172
- export {
173
- deriveTokenEdges,
174
- isRetriableInternalizeFailure,
175
- listStuckSettlements,
176
- populateEvidenceFromFrame,
177
- postTokenStep,
178
- reconcileSettlements,
179
- NON_TERMINAL_SETTLEMENT_STATES,
180
- TERMINAL_SETTLEMENT_STATES,
181
- type EvidenceFrame,
182
- type EvidencePopulated,
183
- type EvidenceTokenBlock,
184
- type EvidenceTrustAnchor,
185
- type TokenFrameSource,
186
- type TokenStepDeps
187
- } from './mandala/drain'
188
179
  // The runtime the UI consumes: its pure interface, and its one construction
189
180
  // site. `useMandala()` reads `useWallet().mandala`; nothing above this line in
190
181
  // an app may import `@bsv/mandala` itself.
191
182
  export type {
192
183
  MandalaRuntime,
184
+ NearbyTokenDeps,
193
185
  TokenActivityRow,
194
186
  TokenActivityStatus,
195
187
  TokenAssetInfo,
188
+ TokenAssetStatus,
196
189
  TokenBalance,
197
- TokenSendResult
190
+ TokenHoldingsReview,
191
+ TokenSendResult,
192
+ TokenSettleState
198
193
  } from './mandala/runtime'
194
+ export {
195
+ createAssetMetadata,
196
+ offlineUnitsOf,
197
+ readAvailable,
198
+ readInventory,
199
+ readPending,
200
+ shortAssetId,
201
+ type InventoryRecord
202
+ } from './mandala/assets'
199
203
  export {
200
204
  activityStatusOf,
201
205
  bindOriginator,
202
206
  createMandalaKvStorage,
203
207
  createMandalaRuntime,
204
- verdictFromError,
205
208
  type CreateMandalaRuntimeArgs,
206
209
  type MandalaKvStorage,
207
210
  type MandalaMessageBox
208
211
  } from './mandala/createRuntime'
212
+ // The BRC-207 color module as WalletContext registers it
213
+ // (`permissionModules.color`): the module with the Mandala issuer-v1 profile
214
+ // and the host ledger it credits from (B7), its `ColorModuleStore` over
215
+ // `key_value_store`, and the host consent policy. A host that builds its own
216
+ // permissions manager needs all of them to give `createMandalaRuntime` a
217
+ // module, a provider and a ledger.
218
+ export { buildColorModule, type BuildColorModuleArgs, type BuiltColorModule } from './mandala/colorModule'
219
+ export { createColorModuleStore, type WalletKv } from './mandala/kvStore'
220
+ export {
221
+ createColorAccessPolicy,
222
+ colorPromptType,
223
+ COLOR_PROMPT_TYPES,
224
+ type ColorAccessPolicyOptions,
225
+ type ColorPromptType
226
+ } from './mandala/accessPolicy'
227
+ // A nearby token frame as the v4 hand-over body (B7, IC §7.3), and how a
228
+ // failed receipt is classified.
209
229
  export {
210
- assembleBundle,
211
- coverFromFrame,
212
- tokenParentsOf,
213
- type AdmissionBundle,
214
- type BundleStore,
215
- type CoverBundle,
216
- type CoverTip,
217
- type CoverVerifier
218
- } from './mandala/bundle'
230
+ bodyFromFrame,
231
+ isRetriableReceiptFailure,
232
+ isTransportReceiptFailure,
233
+ receiptFailureCode,
234
+ tokenPaymentOfHandover
235
+ } from './mandala/receipt'
236
+ export { createHandoverBodies, handoverBodyKey, type HandoverBodies } from './mandala/handle'
219
237
 
220
238
  // Contacts
221
239
  export { mergeContactCache, type ContactCache } from './contacts/contactCache'
222
240
 
223
241
  // Local SQLite storage layer
224
242
  export { StorageExpoSQLite } from './storage/StorageExpoSQLite'
225
- export type { StorageExpoSQLiteOptions, TokenTransactionRepair } from './storage/StorageExpoSQLite'
226
- export { createTables, ensureOfflineActionsColumns, ensureTokenSettlementColumns } from './storage/schema/createTables'
243
+ export type { StorageExpoSQLiteOptions } from './storage/StorageExpoSQLite'
244
+ export { createTables, ensureOfflineActionsColumns } from './storage/schema/createTables'
227
245
  export { findOfflineActions, findOfflineActionByTxid, updateOfflineAction } from './storage/methods/offlineActions'
228
246
  export type { OfflineActionRow, OfflineActionStatus, BindValue } from './storage/methods/offlineActions'
229
247
  export { readWalletBalance } from './storage/methods/walletBalanceSql'
230
- export { processOfflineActions, type OfflineTokenDeps } from './storage/methods/processOfflineActions'
231
- export { createMandalaSettlementTables } from './storage/schema/createTables'
248
+ export { processOfflineActions } from './storage/methods/processOfflineActions'
249
+ export { colorHeldTxids, txHasColorOutput } from './mandala/colorGuard'
232
250
  export * from './storage/skipQueuedAncestors'
233
251
  export { prepareSqliteImageForDeserialize } from './storage/dbImage'
234
252