@arkade-os/sdk 0.4.27 → 0.4.28

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 (531) hide show
  1. package/README.md +31 -100
  2. package/dist/adapters/asyncStorage.cjs +48 -0
  3. package/dist/adapters/asyncStorage.cjs.map +1 -0
  4. package/dist/adapters/asyncStorage.d.cts +16 -0
  5. package/dist/{types/storage → adapters}/asyncStorage.d.ts +5 -2
  6. package/dist/adapters/asyncStorage.js +46 -0
  7. package/dist/adapters/asyncStorage.js.map +1 -0
  8. package/dist/adapters/expo.cjs +19 -0
  9. package/dist/adapters/expo.cjs.map +1 -0
  10. package/dist/adapters/expo.d.cts +48 -0
  11. package/dist/adapters/expo.d.ts +48 -0
  12. package/dist/adapters/expo.js +6 -0
  13. package/dist/adapters/expo.js.map +1 -0
  14. package/dist/adapters/fileSystem.cjs +116 -0
  15. package/dist/adapters/fileSystem.cjs.map +1 -0
  16. package/dist/adapters/fileSystem.d.cts +17 -0
  17. package/dist/{types/storage → adapters}/fileSystem.d.ts +5 -2
  18. package/dist/adapters/fileSystem.js +93 -0
  19. package/dist/adapters/fileSystem.js.map +1 -0
  20. package/dist/adapters/indexedDB.cjs +103 -0
  21. package/dist/adapters/indexedDB.cjs.map +1 -0
  22. package/dist/adapters/indexedDB.d.cts +18 -0
  23. package/dist/{types/storage → adapters}/indexedDB.d.ts +5 -2
  24. package/dist/adapters/indexedDB.js +101 -0
  25. package/dist/adapters/indexedDB.js.map +1 -0
  26. package/dist/adapters/localStorage.cjs +50 -0
  27. package/dist/adapters/localStorage.cjs.map +1 -0
  28. package/dist/{types/storage/inMemory.d.ts → adapters/localStorage.d.cts} +6 -3
  29. package/dist/{types/storage → adapters}/localStorage.d.ts +5 -2
  30. package/dist/adapters/localStorage.js +48 -0
  31. package/dist/adapters/localStorage.js.map +1 -0
  32. package/dist/ark-TZ1gXAXU.d.cts +3880 -0
  33. package/dist/ark-TZ1gXAXU.d.ts +3880 -0
  34. package/dist/{types/worker/expo/asyncStorageTaskQueue.d.ts → asyncStorageTaskQueue-Cb1F_Z9s.d.ts} +6 -3
  35. package/dist/asyncStorageTaskQueue-EFqSmYTg.d.cts +49 -0
  36. package/dist/chunk-5BLDMQED.cjs +18 -0
  37. package/dist/chunk-5BLDMQED.cjs.map +1 -0
  38. package/dist/chunk-5PG7DV7A.cjs +805 -0
  39. package/dist/chunk-5PG7DV7A.cjs.map +1 -0
  40. package/dist/chunk-A3EMF7RN.js +95 -0
  41. package/dist/chunk-A3EMF7RN.js.map +1 -0
  42. package/dist/chunk-ADV27S4N.cjs +2701 -0
  43. package/dist/chunk-ADV27S4N.cjs.map +1 -0
  44. package/dist/chunk-BQLHADL7.js +13805 -0
  45. package/dist/chunk-BQLHADL7.js.map +1 -0
  46. package/dist/chunk-CFZMTDWI.js +209 -0
  47. package/dist/chunk-CFZMTDWI.js.map +1 -0
  48. package/dist/chunk-FG5ACJJW.cjs +212 -0
  49. package/dist/chunk-FG5ACJJW.cjs.map +1 -0
  50. package/dist/chunk-HW3JJ323.js +768 -0
  51. package/dist/chunk-HW3JJ323.js.map +1 -0
  52. package/dist/chunk-I3DGUUCT.cjs +838 -0
  53. package/dist/chunk-I3DGUUCT.cjs.map +1 -0
  54. package/dist/chunk-IPX2R7FR.cjs +100 -0
  55. package/dist/chunk-IPX2R7FR.cjs.map +1 -0
  56. package/dist/chunk-NSBPE2FW.js +15 -0
  57. package/dist/chunk-NSBPE2FW.js.map +1 -0
  58. package/dist/chunk-T64LAI7L.js +829 -0
  59. package/dist/chunk-T64LAI7L.js.map +1 -0
  60. package/dist/chunk-ZBUDLTBO.js +2671 -0
  61. package/dist/chunk-ZBUDLTBO.js.map +1 -0
  62. package/dist/chunk-ZLO6NETT.cjs +13910 -0
  63. package/dist/chunk-ZLO6NETT.cjs.map +1 -0
  64. package/dist/contracts/handlers/index.cjs +26 -0
  65. package/dist/contracts/handlers/index.cjs.map +1 -0
  66. package/dist/contracts/handlers/index.d.cts +7 -0
  67. package/dist/contracts/handlers/index.d.ts +7 -0
  68. package/dist/contracts/handlers/index.js +5 -0
  69. package/dist/contracts/handlers/index.js.map +1 -0
  70. package/dist/delegate-BFZs69hp.d.cts +84 -0
  71. package/dist/delegate-aaVGfWsV.d.ts +84 -0
  72. package/dist/index-B22cA64m.d.cts +199 -0
  73. package/dist/{types/storage/index.d.ts → index-C0IanN1m.d.cts} +3 -1
  74. package/dist/index-C0IanN1m.d.ts +11 -0
  75. package/dist/index-NDla_UoJ.d.ts +199 -0
  76. package/dist/index.cjs +480 -0
  77. package/dist/index.cjs.map +1 -0
  78. package/dist/index.d.cts +3343 -0
  79. package/dist/index.d.ts +3343 -0
  80. package/dist/index.js +7 -0
  81. package/dist/index.js.map +1 -0
  82. package/dist/repositories/realm/index.cjs +513 -0
  83. package/dist/repositories/realm/index.cjs.map +1 -0
  84. package/dist/repositories/realm/index.d.cts +217 -0
  85. package/dist/{types/repositories/realm/schemas.d.ts → repositories/realm/index.d.ts} +80 -112
  86. package/dist/repositories/realm/index.js +507 -0
  87. package/dist/repositories/realm/index.js.map +1 -0
  88. package/dist/repositories/sqlite/index.cjs +588 -0
  89. package/dist/repositories/sqlite/index.cjs.map +1 -0
  90. package/dist/repositories/sqlite/index.d.cts +118 -0
  91. package/dist/{types/repositories/sqlite/walletRepository.d.ts → repositories/sqlite/index.d.ts} +58 -5
  92. package/dist/repositories/sqlite/index.js +585 -0
  93. package/dist/repositories/sqlite/index.js.map +1 -0
  94. package/dist/taskRunner-C6Ff4OaU.d.cts +114 -0
  95. package/dist/taskRunner-yvPN8Z0K.d.ts +114 -0
  96. package/dist/wallet/expo/background.cjs +93 -0
  97. package/dist/wallet/expo/background.cjs.map +1 -0
  98. package/dist/wallet/expo/background.d.cts +84 -0
  99. package/dist/wallet/expo/background.d.ts +84 -0
  100. package/dist/wallet/expo/background.js +68 -0
  101. package/dist/wallet/expo/background.js.map +1 -0
  102. package/dist/wallet/expo/index.cjs +171 -0
  103. package/dist/wallet/expo/index.cjs.map +1 -0
  104. package/dist/wallet/expo/index.d.cts +122 -0
  105. package/dist/{types/wallet/expo/wallet.d.ts → wallet/expo/index.d.ts} +45 -22
  106. package/dist/wallet/expo/index.js +169 -0
  107. package/dist/wallet/expo/index.js.map +1 -0
  108. package/dist/wallet-AF-p-OWj.d.cts +774 -0
  109. package/dist/wallet-D9NBRqvC.d.ts +774 -0
  110. package/dist/worker/expo/index.cjs +140 -0
  111. package/dist/worker/expo/index.cjs.map +1 -0
  112. package/dist/worker/expo/index.d.cts +29 -0
  113. package/dist/worker/expo/index.d.ts +29 -0
  114. package/dist/worker/expo/index.js +121 -0
  115. package/dist/worker/expo/index.js.map +1 -0
  116. package/package.json +110 -76
  117. package/dist/cjs/adapters/asyncStorage.js +0 -5
  118. package/dist/cjs/adapters/expo.js +0 -8
  119. package/dist/cjs/adapters/fileSystem.js +0 -5
  120. package/dist/cjs/adapters/indexedDB.js +0 -5
  121. package/dist/cjs/adapters/localStorage.js +0 -5
  122. package/dist/cjs/arkfee/celenv.js +0 -43
  123. package/dist/cjs/arkfee/estimator.js +0 -143
  124. package/dist/cjs/arkfee/index.js +0 -5
  125. package/dist/cjs/arkfee/types.js +0 -26
  126. package/dist/cjs/arknote/index.js +0 -128
  127. package/dist/cjs/bip322/index.js +0 -270
  128. package/dist/cjs/contracts/arkcontract.js +0 -147
  129. package/dist/cjs/contracts/contractManager.js +0 -649
  130. package/dist/cjs/contracts/contractWatcher.js +0 -598
  131. package/dist/cjs/contracts/handlers/default.js +0 -93
  132. package/dist/cjs/contracts/handlers/delegate.js +0 -90
  133. package/dist/cjs/contracts/handlers/helpers.js +0 -115
  134. package/dist/cjs/contracts/handlers/index.js +0 -19
  135. package/dist/cjs/contracts/handlers/registry.js +0 -89
  136. package/dist/cjs/contracts/handlers/vhtlc.js +0 -194
  137. package/dist/cjs/contracts/index.js +0 -41
  138. package/dist/cjs/contracts/types.js +0 -2
  139. package/dist/cjs/contracts/vtxoOwnership.js +0 -78
  140. package/dist/cjs/extension/asset/assetGroup.js +0 -228
  141. package/dist/cjs/extension/asset/assetId.js +0 -152
  142. package/dist/cjs/extension/asset/assetInput.js +0 -222
  143. package/dist/cjs/extension/asset/assetOutput.js +0 -174
  144. package/dist/cjs/extension/asset/assetRef.js +0 -148
  145. package/dist/cjs/extension/asset/index.js +0 -23
  146. package/dist/cjs/extension/asset/metadata.js +0 -187
  147. package/dist/cjs/extension/asset/packet.js +0 -114
  148. package/dist/cjs/extension/asset/types.js +0 -22
  149. package/dist/cjs/extension/asset/utils.js +0 -105
  150. package/dist/cjs/extension/index.js +0 -254
  151. package/dist/cjs/extension/packet.js +0 -20
  152. package/dist/cjs/forfeit.js +0 -45
  153. package/dist/cjs/identity/descriptor.js +0 -169
  154. package/dist/cjs/identity/descriptorProvider.js +0 -2
  155. package/dist/cjs/identity/hdCapableIdentity.js +0 -20
  156. package/dist/cjs/identity/index.js +0 -40
  157. package/dist/cjs/identity/seedIdentity.js +0 -477
  158. package/dist/cjs/identity/serialize.js +0 -171
  159. package/dist/cjs/identity/singleKey.js +0 -126
  160. package/dist/cjs/identity/staticDescriptorProvider.js +0 -65
  161. package/dist/cjs/index.js +0 -202
  162. package/dist/cjs/intent/index.js +0 -259
  163. package/dist/cjs/musig2/index.js +0 -11
  164. package/dist/cjs/musig2/keys.js +0 -57
  165. package/dist/cjs/musig2/nonces.js +0 -48
  166. package/dist/cjs/musig2/sign.js +0 -102
  167. package/dist/cjs/networks.js +0 -26
  168. package/dist/cjs/package.json +0 -3
  169. package/dist/cjs/providers/ark.js +0 -577
  170. package/dist/cjs/providers/delegator.js +0 -85
  171. package/dist/cjs/providers/electrum.js +0 -869
  172. package/dist/cjs/providers/errors.js +0 -59
  173. package/dist/cjs/providers/expoArk.js +0 -82
  174. package/dist/cjs/providers/expoIndexer.js +0 -111
  175. package/dist/cjs/providers/expoUtils.js +0 -124
  176. package/dist/cjs/providers/indexer.js +0 -630
  177. package/dist/cjs/providers/onchain.js +0 -262
  178. package/dist/cjs/providers/utils.js +0 -121
  179. package/dist/cjs/repositories/contractRepository.js +0 -2
  180. package/dist/cjs/repositories/inMemory/contractRepository.js +0 -55
  181. package/dist/cjs/repositories/inMemory/walletRepository.js +0 -115
  182. package/dist/cjs/repositories/index.js +0 -34
  183. package/dist/cjs/repositories/indexedDB/contractRepository.js +0 -187
  184. package/dist/cjs/repositories/indexedDB/db.js +0 -19
  185. package/dist/cjs/repositories/indexedDB/manager.js +0 -100
  186. package/dist/cjs/repositories/indexedDB/schema.js +0 -204
  187. package/dist/cjs/repositories/indexedDB/walletRepository.js +0 -474
  188. package/dist/cjs/repositories/indexedDB/websqlAdapter.js +0 -144
  189. package/dist/cjs/repositories/migrations/contractRepositoryImpl.js +0 -127
  190. package/dist/cjs/repositories/migrations/fromStorageAdapter.js +0 -66
  191. package/dist/cjs/repositories/migrations/walletRepositoryImpl.js +0 -184
  192. package/dist/cjs/repositories/realm/contractRepository.js +0 -116
  193. package/dist/cjs/repositories/realm/index.js +0 -11
  194. package/dist/cjs/repositories/realm/schemas.js +0 -157
  195. package/dist/cjs/repositories/realm/types.js +0 -7
  196. package/dist/cjs/repositories/realm/walletRepository.js +0 -305
  197. package/dist/cjs/repositories/scriptFromAddress.js +0 -16
  198. package/dist/cjs/repositories/serialization.js +0 -82
  199. package/dist/cjs/repositories/sqlite/contractRepository.js +0 -135
  200. package/dist/cjs/repositories/sqlite/index.js +0 -7
  201. package/dist/cjs/repositories/sqlite/types.js +0 -2
  202. package/dist/cjs/repositories/sqlite/walletRepository.js +0 -441
  203. package/dist/cjs/repositories/walletRepository.js +0 -2
  204. package/dist/cjs/script/address.js +0 -108
  205. package/dist/cjs/script/base.js +0 -185
  206. package/dist/cjs/script/default.js +0 -57
  207. package/dist/cjs/script/delegate.js +0 -53
  208. package/dist/cjs/script/tapscript.js +0 -619
  209. package/dist/cjs/script/vhtlc.js +0 -170
  210. package/dist/cjs/storage/asyncStorage.js +0 -50
  211. package/dist/cjs/storage/fileSystem.js +0 -141
  212. package/dist/cjs/storage/inMemory.js +0 -24
  213. package/dist/cjs/storage/index.js +0 -2
  214. package/dist/cjs/storage/indexedDB.js +0 -101
  215. package/dist/cjs/storage/localStorage.js +0 -51
  216. package/dist/cjs/tree/signingSession.js +0 -229
  217. package/dist/cjs/tree/txTree.js +0 -192
  218. package/dist/cjs/tree/validation.js +0 -107
  219. package/dist/cjs/utils/anchor.js +0 -35
  220. package/dist/cjs/utils/arkTransaction.js +0 -271
  221. package/dist/cjs/utils/bip21.js +0 -127
  222. package/dist/cjs/utils/syncCursors.js +0 -128
  223. package/dist/cjs/utils/timelock.js +0 -59
  224. package/dist/cjs/utils/transaction.js +0 -28
  225. package/dist/cjs/utils/transactionHistory.js +0 -183
  226. package/dist/cjs/utils/txSizeEstimator.js +0 -132
  227. package/dist/cjs/utils/unknownFields.js +0 -174
  228. package/dist/cjs/wallet/asset-manager.js +0 -330
  229. package/dist/cjs/wallet/asset.js +0 -119
  230. package/dist/cjs/wallet/batch.js +0 -183
  231. package/dist/cjs/wallet/delegator.js +0 -308
  232. package/dist/cjs/wallet/expo/background.js +0 -116
  233. package/dist/cjs/wallet/expo/index.js +0 -9
  234. package/dist/cjs/wallet/expo/wallet.js +0 -230
  235. package/dist/cjs/wallet/hdDescriptorProvider.js +0 -188
  236. package/dist/cjs/wallet/index.js +0 -82
  237. package/dist/cjs/wallet/inputSignerRouter.js +0 -98
  238. package/dist/cjs/wallet/onchain.js +0 -290
  239. package/dist/cjs/wallet/ramps.js +0 -216
  240. package/dist/cjs/wallet/serviceWorker/wallet-message-handler.js +0 -953
  241. package/dist/cjs/wallet/serviceWorker/wallet.js +0 -1174
  242. package/dist/cjs/wallet/signingErrors.js +0 -32
  243. package/dist/cjs/wallet/unroll.js +0 -293
  244. package/dist/cjs/wallet/utils.js +0 -111
  245. package/dist/cjs/wallet/validation.js +0 -154
  246. package/dist/cjs/wallet/vtxo-manager.js +0 -1142
  247. package/dist/cjs/wallet/wallet.js +0 -2195
  248. package/dist/cjs/wallet/walletReceiveRotator.js +0 -547
  249. package/dist/cjs/worker/browser/service-worker-manager.js +0 -183
  250. package/dist/cjs/worker/browser/utils.js +0 -67
  251. package/dist/cjs/worker/errors.js +0 -16
  252. package/dist/cjs/worker/expo/asyncStorageTaskQueue.js +0 -78
  253. package/dist/cjs/worker/expo/index.js +0 -13
  254. package/dist/cjs/worker/expo/processors/contractPollProcessor.js +0 -62
  255. package/dist/cjs/worker/expo/processors/index.js +0 -6
  256. package/dist/cjs/worker/expo/taskQueue.js +0 -41
  257. package/dist/cjs/worker/expo/taskRunner.js +0 -73
  258. package/dist/cjs/worker/messageBus.js +0 -474
  259. package/dist/esm/adapters/asyncStorage.js +0 -1
  260. package/dist/esm/adapters/expo.js +0 -3
  261. package/dist/esm/adapters/fileSystem.js +0 -1
  262. package/dist/esm/adapters/indexedDB.js +0 -1
  263. package/dist/esm/adapters/localStorage.js +0 -1
  264. package/dist/esm/arkfee/celenv.js +0 -40
  265. package/dist/esm/arkfee/estimator.js +0 -139
  266. package/dist/esm/arkfee/index.js +0 -1
  267. package/dist/esm/arkfee/types.js +0 -22
  268. package/dist/esm/arknote/index.js +0 -124
  269. package/dist/esm/bip322/index.js +0 -267
  270. package/dist/esm/contracts/arkcontract.js +0 -140
  271. package/dist/esm/contracts/contractManager.js +0 -645
  272. package/dist/esm/contracts/contractWatcher.js +0 -594
  273. package/dist/esm/contracts/handlers/default.js +0 -90
  274. package/dist/esm/contracts/handlers/delegate.js +0 -87
  275. package/dist/esm/contracts/handlers/helpers.js +0 -110
  276. package/dist/esm/contracts/handlers/index.js +0 -12
  277. package/dist/esm/contracts/handlers/registry.js +0 -86
  278. package/dist/esm/contracts/handlers/vhtlc.js +0 -191
  279. package/dist/esm/contracts/index.js +0 -13
  280. package/dist/esm/contracts/types.js +0 -1
  281. package/dist/esm/contracts/vtxoOwnership.js +0 -69
  282. package/dist/esm/extension/asset/assetGroup.js +0 -224
  283. package/dist/esm/extension/asset/assetId.js +0 -148
  284. package/dist/esm/extension/asset/assetInput.js +0 -217
  285. package/dist/esm/extension/asset/assetOutput.js +0 -169
  286. package/dist/esm/extension/asset/assetRef.js +0 -144
  287. package/dist/esm/extension/asset/index.js +0 -8
  288. package/dist/esm/extension/asset/metadata.js +0 -182
  289. package/dist/esm/extension/asset/packet.js +0 -110
  290. package/dist/esm/extension/asset/types.js +0 -19
  291. package/dist/esm/extension/asset/utils.js +0 -99
  292. package/dist/esm/extension/index.js +0 -248
  293. package/dist/esm/extension/packet.js +0 -16
  294. package/dist/esm/forfeit.js +0 -41
  295. package/dist/esm/identity/descriptor.js +0 -161
  296. package/dist/esm/identity/descriptorProvider.js +0 -1
  297. package/dist/esm/identity/hdCapableIdentity.js +0 -17
  298. package/dist/esm/identity/index.js +0 -13
  299. package/dist/esm/identity/seedIdentity.js +0 -469
  300. package/dist/esm/identity/serialize.js +0 -164
  301. package/dist/esm/identity/singleKey.js +0 -121
  302. package/dist/esm/identity/staticDescriptorProvider.js +0 -61
  303. package/dist/esm/index.js +0 -87
  304. package/dist/esm/intent/index.js +0 -255
  305. package/dist/esm/musig2/index.js +0 -3
  306. package/dist/esm/musig2/keys.js +0 -21
  307. package/dist/esm/musig2/nonces.js +0 -11
  308. package/dist/esm/musig2/sign.js +0 -63
  309. package/dist/esm/networks.js +0 -22
  310. package/dist/esm/package.json +0 -3
  311. package/dist/esm/providers/ark.js +0 -572
  312. package/dist/esm/providers/delegator.js +0 -81
  313. package/dist/esm/providers/electrum.js +0 -864
  314. package/dist/esm/providers/errors.js +0 -54
  315. package/dist/esm/providers/expoArk.js +0 -78
  316. package/dist/esm/providers/expoIndexer.js +0 -107
  317. package/dist/esm/providers/expoUtils.js +0 -87
  318. package/dist/esm/providers/indexer.js +0 -626
  319. package/dist/esm/providers/onchain.js +0 -258
  320. package/dist/esm/providers/utils.js +0 -117
  321. package/dist/esm/repositories/contractRepository.js +0 -1
  322. package/dist/esm/repositories/inMemory/contractRepository.js +0 -51
  323. package/dist/esm/repositories/inMemory/walletRepository.js +0 -111
  324. package/dist/esm/repositories/index.js +0 -10
  325. package/dist/esm/repositories/indexedDB/contractRepository.js +0 -183
  326. package/dist/esm/repositories/indexedDB/db.js +0 -4
  327. package/dist/esm/repositories/indexedDB/manager.js +0 -95
  328. package/dist/esm/repositories/indexedDB/schema.js +0 -199
  329. package/dist/esm/repositories/indexedDB/walletRepository.js +0 -470
  330. package/dist/esm/repositories/indexedDB/websqlAdapter.js +0 -138
  331. package/dist/esm/repositories/migrations/contractRepositoryImpl.js +0 -121
  332. package/dist/esm/repositories/migrations/fromStorageAdapter.js +0 -58
  333. package/dist/esm/repositories/migrations/walletRepositoryImpl.js +0 -180
  334. package/dist/esm/repositories/realm/contractRepository.js +0 -112
  335. package/dist/esm/repositories/realm/index.js +0 -3
  336. package/dist/esm/repositories/realm/schemas.js +0 -153
  337. package/dist/esm/repositories/realm/types.js +0 -6
  338. package/dist/esm/repositories/realm/walletRepository.js +0 -301
  339. package/dist/esm/repositories/scriptFromAddress.js +0 -13
  340. package/dist/esm/repositories/serialization.js +0 -67
  341. package/dist/esm/repositories/sqlite/contractRepository.js +0 -131
  342. package/dist/esm/repositories/sqlite/index.js +0 -2
  343. package/dist/esm/repositories/sqlite/types.js +0 -1
  344. package/dist/esm/repositories/sqlite/walletRepository.js +0 -437
  345. package/dist/esm/repositories/walletRepository.js +0 -1
  346. package/dist/esm/script/address.js +0 -104
  347. package/dist/esm/script/base.js +0 -179
  348. package/dist/esm/script/default.js +0 -54
  349. package/dist/esm/script/delegate.js +0 -50
  350. package/dist/esm/script/tapscript.js +0 -615
  351. package/dist/esm/script/vhtlc.js +0 -167
  352. package/dist/esm/storage/asyncStorage.js +0 -46
  353. package/dist/esm/storage/fileSystem.js +0 -104
  354. package/dist/esm/storage/inMemory.js +0 -20
  355. package/dist/esm/storage/index.js +0 -1
  356. package/dist/esm/storage/indexedDB.js +0 -97
  357. package/dist/esm/storage/localStorage.js +0 -47
  358. package/dist/esm/tree/signingSession.js +0 -191
  359. package/dist/esm/tree/txTree.js +0 -188
  360. package/dist/esm/tree/validation.js +0 -101
  361. package/dist/esm/utils/anchor.js +0 -31
  362. package/dist/esm/utils/arkTransaction.js +0 -264
  363. package/dist/esm/utils/bip21.js +0 -123
  364. package/dist/esm/utils/syncCursors.js +0 -119
  365. package/dist/esm/utils/timelock.js +0 -22
  366. package/dist/esm/utils/transaction.js +0 -24
  367. package/dist/esm/utils/transactionHistory.js +0 -180
  368. package/dist/esm/utils/txSizeEstimator.js +0 -128
  369. package/dist/esm/utils/unknownFields.js +0 -169
  370. package/dist/esm/wallet/asset-manager.js +0 -325
  371. package/dist/esm/wallet/asset.js +0 -113
  372. package/dist/esm/wallet/batch.js +0 -180
  373. package/dist/esm/wallet/delegator.js +0 -303
  374. package/dist/esm/wallet/expo/background.js +0 -111
  375. package/dist/esm/wallet/expo/index.js +0 -2
  376. package/dist/esm/wallet/expo/wallet.js +0 -193
  377. package/dist/esm/wallet/hdDescriptorProvider.js +0 -184
  378. package/dist/esm/wallet/index.js +0 -75
  379. package/dist/esm/wallet/inputSignerRouter.js +0 -94
  380. package/dist/esm/wallet/onchain.js +0 -285
  381. package/dist/esm/wallet/ramps.js +0 -212
  382. package/dist/esm/wallet/serviceWorker/wallet-message-handler.js +0 -946
  383. package/dist/esm/wallet/serviceWorker/wallet.js +0 -1169
  384. package/dist/esm/wallet/signingErrors.js +0 -27
  385. package/dist/esm/wallet/unroll.js +0 -289
  386. package/dist/esm/wallet/utils.js +0 -103
  387. package/dist/esm/wallet/validation.js +0 -142
  388. package/dist/esm/wallet/vtxo-manager.js +0 -1136
  389. package/dist/esm/wallet/wallet.js +0 -2186
  390. package/dist/esm/wallet/walletReceiveRotator.js +0 -540
  391. package/dist/esm/worker/browser/service-worker-manager.js +0 -177
  392. package/dist/esm/worker/browser/utils.js +0 -63
  393. package/dist/esm/worker/errors.js +0 -11
  394. package/dist/esm/worker/expo/asyncStorageTaskQueue.js +0 -74
  395. package/dist/esm/worker/expo/index.js +0 -4
  396. package/dist/esm/worker/expo/processors/contractPollProcessor.js +0 -59
  397. package/dist/esm/worker/expo/processors/index.js +0 -1
  398. package/dist/esm/worker/expo/taskQueue.js +0 -37
  399. package/dist/esm/worker/expo/taskRunner.js +0 -69
  400. package/dist/esm/worker/messageBus.js +0 -470
  401. package/dist/types/adapters/asyncStorage.d.ts +0 -2
  402. package/dist/types/adapters/expo.d.ts +0 -4
  403. package/dist/types/adapters/fileSystem.d.ts +0 -2
  404. package/dist/types/adapters/indexedDB.d.ts +0 -2
  405. package/dist/types/adapters/localStorage.d.ts +0 -2
  406. package/dist/types/arkfee/celenv.d.ts +0 -25
  407. package/dist/types/arkfee/estimator.d.ts +0 -49
  408. package/dist/types/arkfee/index.d.ts +0 -2
  409. package/dist/types/arkfee/types.d.ts +0 -38
  410. package/dist/types/arknote/index.d.ts +0 -84
  411. package/dist/types/bip322/index.d.ts +0 -55
  412. package/dist/types/contracts/arkcontract.d.ts +0 -99
  413. package/dist/types/contracts/contractManager.d.ts +0 -411
  414. package/dist/types/contracts/contractWatcher.d.ts +0 -217
  415. package/dist/types/contracts/handlers/default.d.ts +0 -19
  416. package/dist/types/contracts/handlers/delegate.d.ts +0 -21
  417. package/dist/types/contracts/handlers/helpers.d.ts +0 -19
  418. package/dist/types/contracts/handlers/index.d.ts +0 -7
  419. package/dist/types/contracts/handlers/registry.d.ts +0 -65
  420. package/dist/types/contracts/handlers/vhtlc.d.ts +0 -32
  421. package/dist/types/contracts/index.d.ts +0 -14
  422. package/dist/types/contracts/types.d.ts +0 -250
  423. package/dist/types/contracts/vtxoOwnership.d.ts +0 -33
  424. package/dist/types/extension/asset/assetGroup.d.ts +0 -119
  425. package/dist/types/extension/asset/assetId.d.ts +0 -83
  426. package/dist/types/extension/asset/assetInput.d.ts +0 -64
  427. package/dist/types/extension/asset/assetOutput.d.ts +0 -54
  428. package/dist/types/extension/asset/assetRef.d.ts +0 -91
  429. package/dist/types/extension/asset/index.d.ts +0 -8
  430. package/dist/types/extension/asset/metadata.d.ts +0 -52
  431. package/dist/types/extension/asset/packet.d.ts +0 -41
  432. package/dist/types/extension/asset/types.d.ts +0 -16
  433. package/dist/types/extension/asset/utils.d.ts +0 -21
  434. package/dist/types/extension/index.d.ts +0 -56
  435. package/dist/types/extension/packet.d.ts +0 -21
  436. package/dist/types/forfeit.d.ts +0 -18
  437. package/dist/types/identity/descriptor.d.ts +0 -61
  438. package/dist/types/identity/descriptorProvider.d.ts +0 -42
  439. package/dist/types/identity/hdCapableIdentity.d.ts +0 -71
  440. package/dist/types/identity/index.d.ts +0 -57
  441. package/dist/types/identity/seedIdentity.d.ts +0 -270
  442. package/dist/types/identity/serialize.d.ts +0 -96
  443. package/dist/types/identity/singleKey.d.ts +0 -62
  444. package/dist/types/identity/staticDescriptorProvider.d.ts +0 -18
  445. package/dist/types/index.d.ts +0 -59
  446. package/dist/types/intent/index.d.ts +0 -86
  447. package/dist/types/musig2/index.d.ts +0 -4
  448. package/dist/types/musig2/keys.d.ts +0 -9
  449. package/dist/types/musig2/nonces.d.ts +0 -14
  450. package/dist/types/musig2/sign.d.ts +0 -27
  451. package/dist/types/networks.d.ts +0 -16
  452. package/dist/types/providers/ark.d.ts +0 -369
  453. package/dist/types/providers/delegator.d.ts +0 -82
  454. package/dist/types/providers/electrum.d.ts +0 -312
  455. package/dist/types/providers/errors.d.ts +0 -13
  456. package/dist/types/providers/expoArk.d.ts +0 -22
  457. package/dist/types/providers/expoIndexer.d.ts +0 -18
  458. package/dist/types/providers/expoUtils.d.ts +0 -18
  459. package/dist/types/providers/indexer.d.ts +0 -301
  460. package/dist/types/providers/onchain.d.ts +0 -148
  461. package/dist/types/providers/utils.d.ts +0 -12
  462. package/dist/types/repositories/contractRepository.d.ts +0 -32
  463. package/dist/types/repositories/inMemory/contractRepository.d.ts +0 -17
  464. package/dist/types/repositories/inMemory/walletRepository.d.ts +0 -29
  465. package/dist/types/repositories/index.d.ts +0 -9
  466. package/dist/types/repositories/indexedDB/contractRepository.d.ts +0 -21
  467. package/dist/types/repositories/indexedDB/db.d.ts +0 -4
  468. package/dist/types/repositories/indexedDB/manager.d.ts +0 -25
  469. package/dist/types/repositories/indexedDB/schema.d.ts +0 -9
  470. package/dist/types/repositories/indexedDB/walletRepository.d.ts +0 -28
  471. package/dist/types/repositories/indexedDB/websqlAdapter.d.ts +0 -49
  472. package/dist/types/repositories/migrations/contractRepositoryImpl.d.ts +0 -24
  473. package/dist/types/repositories/migrations/fromStorageAdapter.d.ts +0 -19
  474. package/dist/types/repositories/migrations/walletRepositoryImpl.d.ts +0 -27
  475. package/dist/types/repositories/realm/contractRepository.d.ts +0 -24
  476. package/dist/types/repositories/realm/index.d.ts +0 -4
  477. package/dist/types/repositories/realm/types.d.ts +0 -16
  478. package/dist/types/repositories/realm/walletRepository.d.ts +0 -34
  479. package/dist/types/repositories/scriptFromAddress.d.ts +0 -9
  480. package/dist/types/repositories/serialization.d.ts +0 -65
  481. package/dist/types/repositories/sqlite/contractRepository.d.ts +0 -33
  482. package/dist/types/repositories/sqlite/index.d.ts +0 -3
  483. package/dist/types/repositories/sqlite/types.d.ts +0 -18
  484. package/dist/types/repositories/walletRepository.d.ts +0 -72
  485. package/dist/types/script/address.d.ts +0 -67
  486. package/dist/types/script/base.d.ts +0 -105
  487. package/dist/types/script/default.d.ts +0 -44
  488. package/dist/types/script/delegate.d.ts +0 -40
  489. package/dist/types/script/tapscript.d.ts +0 -169
  490. package/dist/types/script/vhtlc.d.ts +0 -66
  491. package/dist/types/tree/signingSession.d.ts +0 -37
  492. package/dist/types/tree/txTree.d.ts +0 -28
  493. package/dist/types/tree/validation.d.ts +0 -15
  494. package/dist/types/utils/anchor.d.ts +0 -19
  495. package/dist/types/utils/arkTransaction.d.ts +0 -49
  496. package/dist/types/utils/bip21.d.ts +0 -38
  497. package/dist/types/utils/syncCursors.d.ts +0 -60
  498. package/dist/types/utils/timelock.d.ts +0 -9
  499. package/dist/types/utils/transaction.d.ts +0 -13
  500. package/dist/types/utils/transactionHistory.d.ts +0 -15
  501. package/dist/types/utils/txSizeEstimator.d.ts +0 -40
  502. package/dist/types/utils/unknownFields.d.ts +0 -83
  503. package/dist/types/wallet/asset-manager.d.ts +0 -69
  504. package/dist/types/wallet/asset.d.ts +0 -21
  505. package/dist/types/wallet/batch.d.ts +0 -107
  506. package/dist/types/wallet/delegator.d.ts +0 -48
  507. package/dist/types/wallet/expo/background.d.ts +0 -66
  508. package/dist/types/wallet/expo/index.d.ts +0 -4
  509. package/dist/types/wallet/hdDescriptorProvider.d.ts +0 -114
  510. package/dist/types/wallet/index.d.ts +0 -789
  511. package/dist/types/wallet/inputSignerRouter.d.ts +0 -35
  512. package/dist/types/wallet/onchain.d.ts +0 -109
  513. package/dist/types/wallet/ramps.d.ts +0 -64
  514. package/dist/types/wallet/serviceWorker/wallet-message-handler.d.ts +0 -543
  515. package/dist/types/wallet/serviceWorker/wallet.d.ts +0 -248
  516. package/dist/types/wallet/signingErrors.d.ts +0 -19
  517. package/dist/types/wallet/unroll.d.ts +0 -114
  518. package/dist/types/wallet/utils.d.ts +0 -36
  519. package/dist/types/wallet/validation.d.ts +0 -24
  520. package/dist/types/wallet/vtxo-manager.d.ts +0 -476
  521. package/dist/types/wallet/wallet.d.ts +0 -409
  522. package/dist/types/wallet/walletReceiveRotator.d.ts +0 -306
  523. package/dist/types/worker/browser/service-worker-manager.d.ts +0 -32
  524. package/dist/types/worker/browser/utils.d.ts +0 -17
  525. package/dist/types/worker/errors.d.ts +0 -7
  526. package/dist/types/worker/expo/index.d.ts +0 -7
  527. package/dist/types/worker/expo/processors/contractPollProcessor.d.ts +0 -19
  528. package/dist/types/worker/expo/processors/index.d.ts +0 -1
  529. package/dist/types/worker/expo/taskQueue.d.ts +0 -50
  530. package/dist/types/worker/expo/taskRunner.d.ts +0 -66
  531. package/dist/types/worker/messageBus.d.ts +0 -189
@@ -1,121 +0,0 @@
1
- export const getContractStorageKey = (id, key) => `contract:${id}:${key}`;
2
- export const getCollectionStorageKey = (type) => `collection:${type}`;
3
- /**
4
- * @deprecated This is only to be used in migration from storage V1
5
- */
6
- export class ContractRepositoryImpl {
7
- constructor(storage) {
8
- this.version = 1;
9
- this.storage = storage;
10
- }
11
- async getContractData(contractId, key) {
12
- const stored = await this.storage.getItem(getContractStorageKey(contractId, key));
13
- if (!stored)
14
- return null;
15
- try {
16
- const data = JSON.parse(stored);
17
- return data;
18
- }
19
- catch (error) {
20
- console.error(`Failed to parse contract data for ${contractId}:${key}:`, error);
21
- return null;
22
- }
23
- }
24
- async setContractData(contractId, key, data) {
25
- try {
26
- await this.storage.setItem(getContractStorageKey(contractId, key), JSON.stringify(data));
27
- }
28
- catch (error) {
29
- console.error(`Failed to persist contract data for ${contractId}:${key}:`, error);
30
- throw error; // Rethrow to notify caller of failure
31
- }
32
- }
33
- async deleteContractData(contractId, key) {
34
- try {
35
- await this.storage.removeItem(getContractStorageKey(contractId, key));
36
- }
37
- catch (error) {
38
- console.error(`Failed to remove contract data for ${contractId}:${key}:`, error);
39
- throw error; // Rethrow to notify caller of failure
40
- }
41
- }
42
- async getContractCollection(contractType) {
43
- const stored = await this.storage.getItem(getCollectionStorageKey(contractType));
44
- if (!stored)
45
- return [];
46
- try {
47
- const collection = JSON.parse(stored);
48
- return collection;
49
- }
50
- catch (error) {
51
- console.error(`Failed to parse contract collection ${contractType}:`, error);
52
- return [];
53
- }
54
- }
55
- async saveToContractCollection(contractType, item, idField) {
56
- const collection = await this.getContractCollection(contractType);
57
- // Validate that the item has the required id field
58
- const itemId = item[idField];
59
- if (itemId === undefined || itemId === null) {
60
- throw new Error(`Item is missing required field '${String(idField)}'`);
61
- }
62
- // Find existing item index without mutating the original collection
63
- const existingIndex = collection.findIndex((i) => i[idField] === itemId);
64
- // Build new collection without mutating the cached one
65
- let newCollection;
66
- if (existingIndex !== -1) {
67
- // Replace existing item
68
- newCollection = [
69
- ...collection.slice(0, existingIndex),
70
- item,
71
- ...collection.slice(existingIndex + 1),
72
- ];
73
- }
74
- else {
75
- // Add new item
76
- newCollection = [...collection, item];
77
- }
78
- try {
79
- await this.storage.setItem(getCollectionStorageKey(contractType), JSON.stringify(newCollection));
80
- }
81
- catch (error) {
82
- console.error(`Failed to persist contract collection ${contractType}:`, error);
83
- throw error; // Rethrow to notify caller of failure
84
- }
85
- }
86
- async removeFromContractCollection(contractType, id, idField) {
87
- // Validate input parameters
88
- if (id === undefined || id === null) {
89
- throw new Error(`Invalid id provided for removal: ${String(id)}`);
90
- }
91
- const collection = await this.getContractCollection(contractType);
92
- // Build new collection without the specified item
93
- const filtered = collection.filter((item) => item[idField] !== id);
94
- try {
95
- await this.storage.setItem(getCollectionStorageKey(contractType), JSON.stringify(filtered));
96
- }
97
- catch (error) {
98
- console.error(`Failed to persist contract collection removal for ${contractType}:`, error);
99
- throw error; // Rethrow to notify caller of failure
100
- }
101
- }
102
- // The following methods are implemented for compatibility with the new ContractRepository interface
103
- // but aren't used.
104
- async getContracts(_) {
105
- throw new TypeError("Method not implemented, this is a legacy class and should only be used for migrating data.");
106
- }
107
- async saveContract(_) {
108
- throw new TypeError("Method not implemented, this is a legacy class and should only be used for migrating data.");
109
- }
110
- async deleteContract(_) {
111
- throw new TypeError("Method not implemented, this is a legacy class and should only be used for migrating data.");
112
- }
113
- // used only for tests
114
- async clear() {
115
- await this.storage.clear();
116
- }
117
- async [Symbol.asyncDispose]() {
118
- // deprecated StorageAdapter doesn't have a `close()` method
119
- return;
120
- }
121
- }
@@ -1,58 +0,0 @@
1
- import { WalletRepositoryImpl } from "./walletRepositoryImpl.js";
2
- export const MIGRATION_KEY = (repoType) => `migration-from-storage-adapter-${repoType}`;
3
- export async function getMigrationStatus(repoType, storageAdapter) {
4
- try {
5
- const migration = await storageAdapter.getItem(MIGRATION_KEY(repoType));
6
- if (migration === "done")
7
- return "done";
8
- if (migration === "in-progress")
9
- return "in-progress";
10
- return "pending";
11
- }
12
- catch (e) {
13
- if (e instanceof DOMException && e.name === "NotFoundError")
14
- return "not-needed";
15
- throw e;
16
- }
17
- }
18
- export async function requiresMigration(repoType, storageAdapter) {
19
- const status = await getMigrationStatus(repoType, storageAdapter);
20
- return status === "pending" || status === "in-progress";
21
- }
22
- export async function rollbackMigration(repoType, storageAdapter) {
23
- await storageAdapter.removeItem(MIGRATION_KEY(repoType));
24
- }
25
- /**
26
- * Migrate wallet data from the legacy storage adapter to the new one.
27
- * It accepts both onchain and offchain addresses, make sure to pass both.
28
- *
29
- * @param storageAdapter
30
- * @param fresh
31
- * @param addresses
32
- */
33
- export async function migrateWalletRepository(storageAdapter, fresh, addresses) {
34
- const migrate = await requiresMigration("wallet", storageAdapter);
35
- if (!migrate)
36
- return;
37
- await storageAdapter.setItem(MIGRATION_KEY("wallet"), "in-progress");
38
- const old = new WalletRepositoryImpl(storageAdapter);
39
- const walletData = await old.getWalletState();
40
- const onchainAddrData = await Promise.all(addresses.onchain.map(async (address) => {
41
- const utxos = await old.getUtxos(address);
42
- return { address, utxos };
43
- }));
44
- const offchainAddrData = await Promise.all(addresses.offchain.map(async (address) => {
45
- const vtxos = await old.getVtxos(address);
46
- const txs = await old.getTransactionHistory(address);
47
- return { address, vtxos, txs };
48
- }));
49
- await Promise.all([
50
- walletData && fresh.saveWalletState(walletData),
51
- ...offchainAddrData.map((addressData) => Promise.all([
52
- fresh.saveVtxos(addressData.address, addressData.vtxos),
53
- fresh.saveTransactions(addressData.address, addressData.txs),
54
- ])),
55
- ...onchainAddrData.map((addressData) => fresh.saveUtxos(addressData.address, addressData.utxos)),
56
- ]);
57
- await storageAdapter.setItem(MIGRATION_KEY("wallet"), "done");
58
- }
@@ -1,180 +0,0 @@
1
- import { hex } from "@scure/base";
2
- import { TaprootControlBlock } from "@scure/btc-signer";
3
- import { serializeAssets, deserializeAssets, serializeTransaction, deserializeTransaction, } from "../serialization.js";
4
- const getVtxosStorageKey = (address) => `vtxos:${address}`;
5
- const getUtxosStorageKey = (address) => `utxos:${address}`;
6
- const getTransactionsStorageKey = (address) => `tx:${address}`;
7
- const walletStateStorageKey = "wallet:state";
8
- // Utility functions for (de)serializing complex structures
9
- const serializeVtxo = (v) => ({
10
- ...v,
11
- tapTree: hex.encode(v.tapTree),
12
- forfeitTapLeafScript: serializeTapLeaf(v.forfeitTapLeafScript),
13
- intentTapLeafScript: serializeTapLeaf(v.intentTapLeafScript),
14
- extraWitness: v.extraWitness?.map(hex.encode),
15
- assets: serializeAssets(v.assets),
16
- });
17
- const serializeUtxo = (u) => ({
18
- ...u,
19
- tapTree: hex.encode(u.tapTree),
20
- forfeitTapLeafScript: serializeTapLeaf(u.forfeitTapLeafScript),
21
- intentTapLeafScript: serializeTapLeaf(u.intentTapLeafScript),
22
- extraWitness: u.extraWitness?.map(hex.encode),
23
- });
24
- const deserializeVtxo = (o) => ({
25
- ...o,
26
- createdAt: new Date(o.createdAt),
27
- tapTree: hex.decode(o.tapTree),
28
- forfeitTapLeafScript: deserializeTapLeaf(o.forfeitTapLeafScript),
29
- intentTapLeafScript: deserializeTapLeaf(o.intentTapLeafScript),
30
- extraWitness: o.extraWitness?.map(hex.decode),
31
- assets: deserializeAssets(o.assets),
32
- });
33
- const deserializeUtxo = (o) => ({
34
- ...o,
35
- tapTree: hex.decode(o.tapTree),
36
- forfeitTapLeafScript: deserializeTapLeaf(o.forfeitTapLeafScript),
37
- intentTapLeafScript: deserializeTapLeaf(o.intentTapLeafScript),
38
- extraWitness: o.extraWitness?.map(hex.decode),
39
- });
40
- const serializeTapLeaf = ([cb, s]) => ({
41
- cb: hex.encode(TaprootControlBlock.encode(cb)),
42
- s: hex.encode(s),
43
- });
44
- const deserializeTapLeaf = (t) => {
45
- const cb = TaprootControlBlock.decode(hex.decode(t.cb));
46
- const s = hex.decode(t.s);
47
- return [cb, s];
48
- };
49
- /**
50
- * @deprecated This is only to be used in migration from storage V1
51
- */
52
- export class WalletRepositoryImpl {
53
- constructor(storage) {
54
- this.version = 1;
55
- this.storage = storage;
56
- }
57
- async getVtxos(address) {
58
- const stored = await this.storage.getItem(getVtxosStorageKey(address));
59
- if (!stored)
60
- return [];
61
- try {
62
- const parsed = JSON.parse(stored);
63
- return parsed.map(deserializeVtxo);
64
- }
65
- catch (error) {
66
- console.error(`Failed to parse VTXOs for address ${address}:`, error);
67
- return [];
68
- }
69
- }
70
- async saveVtxos(address, vtxos) {
71
- const storedVtxos = await this.getVtxos(address);
72
- for (const vtxo of vtxos) {
73
- const existing = storedVtxos.findIndex((v) => v.txid === vtxo.txid && v.vout === vtxo.vout);
74
- if (existing !== -1) {
75
- storedVtxos[existing] = vtxo;
76
- }
77
- else {
78
- storedVtxos.push(vtxo);
79
- }
80
- }
81
- await this.storage.setItem(getVtxosStorageKey(address), JSON.stringify(storedVtxos.map(serializeVtxo)));
82
- }
83
- async clearVtxos(address) {
84
- return this.deleteVtxos(address);
85
- }
86
- async deleteVtxos(address) {
87
- await this.storage.removeItem(getVtxosStorageKey(address));
88
- }
89
- async getUtxos(address) {
90
- const stored = await this.storage.getItem(getUtxosStorageKey(address));
91
- if (!stored)
92
- return [];
93
- try {
94
- const parsed = JSON.parse(stored);
95
- return parsed.map(deserializeUtxo);
96
- }
97
- catch (error) {
98
- console.error(`Failed to parse UTXOs for address ${address}:`, error);
99
- return [];
100
- }
101
- }
102
- async saveUtxos(address, utxos) {
103
- const storedUtxos = await this.getUtxos(address);
104
- utxos.forEach((utxo) => {
105
- const existing = storedUtxos.findIndex((u) => u.txid === utxo.txid && u.vout === utxo.vout);
106
- if (existing !== -1) {
107
- storedUtxos[existing] = utxo;
108
- }
109
- else {
110
- storedUtxos.push(utxo);
111
- }
112
- });
113
- await this.storage.setItem(getUtxosStorageKey(address), JSON.stringify(storedUtxos.map(serializeUtxo)));
114
- }
115
- async clearUtxos(address) {
116
- return this.deleteVtxos(address);
117
- }
118
- async deleteUtxos(address) {
119
- await this.storage.removeItem(getUtxosStorageKey(address));
120
- }
121
- async getTransactionHistory(address) {
122
- const storageKey = getTransactionsStorageKey(address);
123
- const stored = await this.storage.getItem(storageKey);
124
- if (!stored)
125
- return [];
126
- try {
127
- const parsed = JSON.parse(stored);
128
- return parsed.map(deserializeTransaction);
129
- }
130
- catch (error) {
131
- console.error(`Failed to parse transactions for address ${address}:`, error);
132
- return [];
133
- }
134
- }
135
- async saveTransactions(address, txs) {
136
- const storedTransactions = await this.getTransactionHistory(address);
137
- for (const tx of txs) {
138
- const existing = storedTransactions.findIndex((t) => t.key.boardingTxid === tx.key.boardingTxid &&
139
- t.key.commitmentTxid === tx.key.commitmentTxid &&
140
- t.key.arkTxid === tx.key.arkTxid);
141
- if (existing !== -1) {
142
- storedTransactions[existing] = tx;
143
- }
144
- else {
145
- storedTransactions.push(tx);
146
- }
147
- }
148
- await this.storage.setItem(getTransactionsStorageKey(address), JSON.stringify(storedTransactions.map(serializeTransaction)));
149
- }
150
- async clearTransactions(address) {
151
- return this.deleteTransactions(address);
152
- }
153
- async deleteTransactions(address) {
154
- await this.storage.removeItem(getTransactionsStorageKey(address));
155
- }
156
- async getWalletState() {
157
- const stored = await this.storage.getItem(walletStateStorageKey);
158
- if (!stored)
159
- return null;
160
- try {
161
- const state = JSON.parse(stored);
162
- return state;
163
- }
164
- catch (error) {
165
- console.error("Failed to parse wallet state:", error);
166
- return null;
167
- }
168
- }
169
- async saveWalletState(state) {
170
- await this.storage.setItem(walletStateStorageKey, JSON.stringify(state));
171
- }
172
- // New method added in V2, not implemented for legacy
173
- async clear() {
174
- throw new Error("Method not implemented.");
175
- }
176
- async [Symbol.asyncDispose]() {
177
- // deprecated StorageAdapter doesn't have a `close()` method
178
- return;
179
- }
180
- }
@@ -1,112 +0,0 @@
1
- /**
2
- * Realm-based implementation of ContractRepository.
3
- *
4
- * Consumers must open Realm with the schemas from `./schemas.ts` and pass
5
- * the instance to the constructor.
6
- *
7
- * Realm handles schema creation on open, so `ensureInit()` is a no-op.
8
- * The consumer owns the Realm lifecycle — `[Symbol.asyncDispose]` is a no-op.
9
- */
10
- export class RealmContractRepository {
11
- constructor(realm) {
12
- this.realm = realm;
13
- this.version = 1;
14
- }
15
- // ── Lifecycle ──────────────────────────────────────────────────────
16
- async ensureInit() {
17
- // Realm handles schema on open — nothing to initialise.
18
- }
19
- async [Symbol.asyncDispose]() {
20
- // no-op — consumer owns the Realm lifecycle
21
- }
22
- // ── Clear ──────────────────────────────────────────────────────────
23
- async clear() {
24
- await this.ensureInit();
25
- this.realm.write(() => {
26
- this.realm.delete(this.realm.objects("ArkContract"));
27
- });
28
- }
29
- // ── Contract management ────────────────────────────────────────────
30
- async getContracts(filter) {
31
- await this.ensureInit();
32
- let results = this.realm.objects("ArkContract");
33
- if (filter) {
34
- const filterParts = [];
35
- const filterArgs = [];
36
- let argIndex = 0;
37
- argIndex = this.addFilterCondition(filterParts, filterArgs, "script", filter.script, argIndex);
38
- argIndex = this.addFilterCondition(filterParts, filterArgs, "state", filter.state, argIndex);
39
- argIndex = this.addFilterCondition(filterParts, filterArgs, "type", filter.type, argIndex);
40
- if (filterParts.length > 0) {
41
- const query = filterParts.join(" AND ");
42
- results = results.filtered(query, ...filterArgs);
43
- }
44
- }
45
- return [...results].map(contractObjectToDomain);
46
- }
47
- async saveContract(contract) {
48
- await this.ensureInit();
49
- this.realm.write(() => {
50
- this.realm.create("ArkContract", {
51
- script: contract.script,
52
- address: contract.address,
53
- type: contract.type,
54
- state: contract.state,
55
- paramsJson: JSON.stringify(contract.params),
56
- createdAt: contract.createdAt,
57
- label: contract.label ?? null,
58
- metadataJson: contract.metadata
59
- ? JSON.stringify(contract.metadata)
60
- : null,
61
- }, "modified");
62
- });
63
- }
64
- async deleteContract(script) {
65
- await this.ensureInit();
66
- this.realm.write(() => {
67
- const toDelete = this.realm
68
- .objects("ArkContract")
69
- .filtered("script == $0", script);
70
- this.realm.delete(toDelete);
71
- });
72
- }
73
- // ── Helpers ─────────────────────────────────────────────────────────
74
- addFilterCondition(parts, args, column, value, argIndex) {
75
- if (value === undefined)
76
- return argIndex;
77
- if (Array.isArray(value)) {
78
- if (value.length === 0)
79
- return argIndex;
80
- const conditions = value.map((_, i) => {
81
- return `${column} == $${argIndex + i}`;
82
- });
83
- parts.push(`(${conditions.join(" OR ")})`);
84
- args.push(...value);
85
- return argIndex + value.length;
86
- }
87
- else {
88
- parts.push(`${column} == $${argIndex}`);
89
- args.push(value);
90
- return argIndex + 1;
91
- }
92
- }
93
- }
94
- // ── Realm object → Domain converter ──────────────────────────────────────
95
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
96
- function contractObjectToDomain(obj) {
97
- const contract = {
98
- script: obj.script,
99
- address: obj.address,
100
- type: obj.type,
101
- state: obj.state,
102
- params: JSON.parse(obj.paramsJson),
103
- createdAt: obj.createdAt,
104
- };
105
- if (obj.label !== null && obj.label !== undefined) {
106
- contract.label = obj.label;
107
- }
108
- if (obj.metadataJson !== null && obj.metadataJson !== undefined) {
109
- contract.metadata = JSON.parse(obj.metadataJson);
110
- }
111
- return contract;
112
- }
@@ -1,3 +0,0 @@
1
- export { RealmWalletRepository } from "./walletRepository.js";
2
- export { RealmContractRepository } from "./contractRepository.js";
3
- export { ArkRealmSchemas, ARK_REALM_SCHEMA_VERSION, runArkRealmMigrations, } from "./schemas.js";
@@ -1,153 +0,0 @@
1
- /**
2
- * Realm object schemas for the Arkade wallet.
3
- *
4
- * All schema names are prefixed with "Ark" to avoid collisions with
5
- * other Realm schemas in the consuming application.
6
- *
7
- * Since `realm` is a peer dependency (not installed in this package),
8
- * schemas are defined as plain JS objects conforming to Realm's
9
- * ObjectSchema shape.
10
- */
11
- import { scriptFromArkAddress } from "../scriptFromAddress.js";
12
- export const ArkVtxoSchema = {
13
- name: "ArkVtxo",
14
- primaryKey: "pk",
15
- properties: {
16
- pk: "string", // composite: `${txid}:${vout}`
17
- address: { type: "string", indexed: true },
18
- txid: "string",
19
- vout: "int",
20
- value: "int",
21
- tapTree: "string", // hex-encoded
22
- forfeitCb: "string",
23
- forfeitS: "string",
24
- intentCb: "string",
25
- intentS: "string",
26
- extraWitnessJson: "string?",
27
- statusJson: "string",
28
- virtualStatusJson: "string",
29
- spentBy: "string?",
30
- settledBy: "string?",
31
- arkTxId: "string?",
32
- createdAt: "string", // ISO 8601
33
- isUnrolled: "bool",
34
- isSpent: "bool?",
35
- assetsJson: "string?",
36
- // scriptPubKey (hex) locking this VTXO, indexed so contract-scoped
37
- // queries can resolve ownership without touching address mapping.
38
- // Required as of schema v2; legacy rows are backfilled from `address`
39
- // during migration (see `runArkRealmMigrations`).
40
- script: { type: "string", indexed: true },
41
- },
42
- };
43
- export const ArkUtxoSchema = {
44
- name: "ArkUtxo",
45
- primaryKey: "pk",
46
- properties: {
47
- pk: "string", // composite: `${txid}:${vout}`
48
- address: { type: "string", indexed: true },
49
- txid: "string",
50
- vout: "int",
51
- value: "int",
52
- tapTree: "string", // hex-encoded
53
- forfeitCb: "string",
54
- forfeitS: "string",
55
- intentCb: "string",
56
- intentS: "string",
57
- extraWitnessJson: "string?",
58
- statusJson: "string",
59
- },
60
- };
61
- export const ArkTransactionSchema = {
62
- name: "ArkTransaction",
63
- primaryKey: "pk",
64
- properties: {
65
- pk: "string", // composite: `${address}:${boardingTxid}:${commitmentTxid}:${arkTxid}`
66
- address: { type: "string", indexed: true },
67
- boardingTxid: "string",
68
- commitmentTxid: "string",
69
- arkTxid: "string",
70
- type: "string",
71
- amount: "int",
72
- settled: "bool",
73
- createdAt: "int",
74
- assetsJson: "string?",
75
- },
76
- };
77
- export const ArkWalletStateSchema = {
78
- name: "ArkWalletState",
79
- primaryKey: "key",
80
- properties: {
81
- key: "string",
82
- lastSyncTime: "int?",
83
- settingsJson: "string?",
84
- },
85
- };
86
- export const ArkContractSchema = {
87
- name: "ArkContract",
88
- primaryKey: "script",
89
- properties: {
90
- script: "string",
91
- address: "string",
92
- type: { type: "string", indexed: true },
93
- state: { type: "string", indexed: true },
94
- paramsJson: "string",
95
- createdAt: "int",
96
- expiresAt: "int?",
97
- label: "string?",
98
- metadataJson: "string?",
99
- },
100
- };
101
- /**
102
- * All Realm schemas needed by the Arkade wallet repositories.
103
- * Pass this array to your Realm configuration's `schema` property.
104
- */
105
- export const ArkRealmSchemas = [
106
- ArkVtxoSchema,
107
- ArkUtxoSchema,
108
- ArkTransactionSchema,
109
- ArkWalletStateSchema,
110
- ArkContractSchema,
111
- ];
112
- /**
113
- * Current Realm schema version for the Arkade wallet.
114
- *
115
- * Consumers opening Realm must pass a `schemaVersion` at least this high so
116
- * legacy databases get migrated; merge it with your own app's version:
117
- *
118
- * ```ts
119
- * await Realm.open({
120
- * schema: [...ArkRealmSchemas, ...yourSchemas],
121
- * schemaVersion: Math.max(ARK_REALM_SCHEMA_VERSION, yourSchemaVersion),
122
- * onMigration: (oldRealm, newRealm) => {
123
- * runArkRealmMigrations(oldRealm, newRealm);
124
- * // your own migrations
125
- * },
126
- * });
127
- * ```
128
- *
129
- * History:
130
- * - v1: initial ArkVtxo/ArkUtxo/... schemas, `script` nullable.
131
- * - v2: ArkVtxo.script becomes required; NULL values are backfilled from
132
- * the owning Ark address during migration.
133
- */
134
- export const ARK_REALM_SCHEMA_VERSION = 2;
135
- /**
136
- * Run every Arkade schema migration applicable to the open Realm.
137
- *
138
- * Designed to be composed with the consumer's own migrations inside a single
139
- * `onMigration` callback. Each migration step does a per-row check so it
140
- * remains idempotent and independent of the app's global `schemaVersion` —
141
- * a consumer whose app is already at version 10 can still trigger the
142
- * Arkade v1→v2 script backfill when the row has never been populated.
143
- */
144
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
145
- export function runArkRealmMigrations(oldRealm, newRealm) {
146
- const newVtxos = newRealm.objects("ArkVtxo");
147
- for (let i = 0; i < newVtxos.length; i++) {
148
- const newVtxo = newVtxos[i];
149
- if (!newVtxo.script) {
150
- newVtxo.script = scriptFromArkAddress(newVtxo.address);
151
- }
152
- }
153
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * Minimal interface for the subset of the Realm API used by the
3
- * Arkade repositories. Consumers pass their real Realm instance and
4
- * the compiler validates it satisfies this shape.
5
- */
6
- export {};