@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.
- package/README.md +31 -100
- package/dist/adapters/asyncStorage.cjs +48 -0
- package/dist/adapters/asyncStorage.cjs.map +1 -0
- package/dist/adapters/asyncStorage.d.cts +16 -0
- package/dist/{types/storage → adapters}/asyncStorage.d.ts +5 -2
- package/dist/adapters/asyncStorage.js +46 -0
- package/dist/adapters/asyncStorage.js.map +1 -0
- package/dist/adapters/expo.cjs +19 -0
- package/dist/adapters/expo.cjs.map +1 -0
- package/dist/adapters/expo.d.cts +48 -0
- package/dist/adapters/expo.d.ts +48 -0
- package/dist/adapters/expo.js +6 -0
- package/dist/adapters/expo.js.map +1 -0
- package/dist/adapters/fileSystem.cjs +116 -0
- package/dist/adapters/fileSystem.cjs.map +1 -0
- package/dist/adapters/fileSystem.d.cts +17 -0
- package/dist/{types/storage → adapters}/fileSystem.d.ts +5 -2
- package/dist/adapters/fileSystem.js +93 -0
- package/dist/adapters/fileSystem.js.map +1 -0
- package/dist/adapters/indexedDB.cjs +103 -0
- package/dist/adapters/indexedDB.cjs.map +1 -0
- package/dist/adapters/indexedDB.d.cts +18 -0
- package/dist/{types/storage → adapters}/indexedDB.d.ts +5 -2
- package/dist/adapters/indexedDB.js +101 -0
- package/dist/adapters/indexedDB.js.map +1 -0
- package/dist/adapters/localStorage.cjs +50 -0
- package/dist/adapters/localStorage.cjs.map +1 -0
- package/dist/{types/storage/inMemory.d.ts → adapters/localStorage.d.cts} +6 -3
- package/dist/{types/storage → adapters}/localStorage.d.ts +5 -2
- package/dist/adapters/localStorage.js +48 -0
- package/dist/adapters/localStorage.js.map +1 -0
- package/dist/ark-TZ1gXAXU.d.cts +3880 -0
- package/dist/ark-TZ1gXAXU.d.ts +3880 -0
- package/dist/{types/worker/expo/asyncStorageTaskQueue.d.ts → asyncStorageTaskQueue-Cb1F_Z9s.d.ts} +6 -3
- package/dist/asyncStorageTaskQueue-EFqSmYTg.d.cts +49 -0
- package/dist/chunk-5BLDMQED.cjs +18 -0
- package/dist/chunk-5BLDMQED.cjs.map +1 -0
- package/dist/chunk-5PG7DV7A.cjs +805 -0
- package/dist/chunk-5PG7DV7A.cjs.map +1 -0
- package/dist/chunk-A3EMF7RN.js +95 -0
- package/dist/chunk-A3EMF7RN.js.map +1 -0
- package/dist/chunk-ADV27S4N.cjs +2701 -0
- package/dist/chunk-ADV27S4N.cjs.map +1 -0
- package/dist/chunk-BQLHADL7.js +13805 -0
- package/dist/chunk-BQLHADL7.js.map +1 -0
- package/dist/chunk-CFZMTDWI.js +209 -0
- package/dist/chunk-CFZMTDWI.js.map +1 -0
- package/dist/chunk-FG5ACJJW.cjs +212 -0
- package/dist/chunk-FG5ACJJW.cjs.map +1 -0
- package/dist/chunk-HW3JJ323.js +768 -0
- package/dist/chunk-HW3JJ323.js.map +1 -0
- package/dist/chunk-I3DGUUCT.cjs +838 -0
- package/dist/chunk-I3DGUUCT.cjs.map +1 -0
- package/dist/chunk-IPX2R7FR.cjs +100 -0
- package/dist/chunk-IPX2R7FR.cjs.map +1 -0
- package/dist/chunk-NSBPE2FW.js +15 -0
- package/dist/chunk-NSBPE2FW.js.map +1 -0
- package/dist/chunk-T64LAI7L.js +829 -0
- package/dist/chunk-T64LAI7L.js.map +1 -0
- package/dist/chunk-ZBUDLTBO.js +2671 -0
- package/dist/chunk-ZBUDLTBO.js.map +1 -0
- package/dist/chunk-ZLO6NETT.cjs +13910 -0
- package/dist/chunk-ZLO6NETT.cjs.map +1 -0
- package/dist/contracts/handlers/index.cjs +26 -0
- package/dist/contracts/handlers/index.cjs.map +1 -0
- package/dist/contracts/handlers/index.d.cts +7 -0
- package/dist/contracts/handlers/index.d.ts +7 -0
- package/dist/contracts/handlers/index.js +5 -0
- package/dist/contracts/handlers/index.js.map +1 -0
- package/dist/delegate-BFZs69hp.d.cts +84 -0
- package/dist/delegate-aaVGfWsV.d.ts +84 -0
- package/dist/index-B22cA64m.d.cts +199 -0
- package/dist/{types/storage/index.d.ts → index-C0IanN1m.d.cts} +3 -1
- package/dist/index-C0IanN1m.d.ts +11 -0
- package/dist/index-NDla_UoJ.d.ts +199 -0
- package/dist/index.cjs +480 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +3343 -0
- package/dist/index.d.ts +3343 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/repositories/realm/index.cjs +513 -0
- package/dist/repositories/realm/index.cjs.map +1 -0
- package/dist/repositories/realm/index.d.cts +217 -0
- package/dist/{types/repositories/realm/schemas.d.ts → repositories/realm/index.d.ts} +80 -112
- package/dist/repositories/realm/index.js +507 -0
- package/dist/repositories/realm/index.js.map +1 -0
- package/dist/repositories/sqlite/index.cjs +588 -0
- package/dist/repositories/sqlite/index.cjs.map +1 -0
- package/dist/repositories/sqlite/index.d.cts +118 -0
- package/dist/{types/repositories/sqlite/walletRepository.d.ts → repositories/sqlite/index.d.ts} +58 -5
- package/dist/repositories/sqlite/index.js +585 -0
- package/dist/repositories/sqlite/index.js.map +1 -0
- package/dist/taskRunner-C6Ff4OaU.d.cts +114 -0
- package/dist/taskRunner-yvPN8Z0K.d.ts +114 -0
- package/dist/wallet/expo/background.cjs +93 -0
- package/dist/wallet/expo/background.cjs.map +1 -0
- package/dist/wallet/expo/background.d.cts +84 -0
- package/dist/wallet/expo/background.d.ts +84 -0
- package/dist/wallet/expo/background.js +68 -0
- package/dist/wallet/expo/background.js.map +1 -0
- package/dist/wallet/expo/index.cjs +171 -0
- package/dist/wallet/expo/index.cjs.map +1 -0
- package/dist/wallet/expo/index.d.cts +122 -0
- package/dist/{types/wallet/expo/wallet.d.ts → wallet/expo/index.d.ts} +45 -22
- package/dist/wallet/expo/index.js +169 -0
- package/dist/wallet/expo/index.js.map +1 -0
- package/dist/wallet-AF-p-OWj.d.cts +774 -0
- package/dist/wallet-D9NBRqvC.d.ts +774 -0
- package/dist/worker/expo/index.cjs +140 -0
- package/dist/worker/expo/index.cjs.map +1 -0
- package/dist/worker/expo/index.d.cts +29 -0
- package/dist/worker/expo/index.d.ts +29 -0
- package/dist/worker/expo/index.js +121 -0
- package/dist/worker/expo/index.js.map +1 -0
- package/package.json +110 -76
- package/dist/cjs/adapters/asyncStorage.js +0 -5
- package/dist/cjs/adapters/expo.js +0 -8
- package/dist/cjs/adapters/fileSystem.js +0 -5
- package/dist/cjs/adapters/indexedDB.js +0 -5
- package/dist/cjs/adapters/localStorage.js +0 -5
- package/dist/cjs/arkfee/celenv.js +0 -43
- package/dist/cjs/arkfee/estimator.js +0 -143
- package/dist/cjs/arkfee/index.js +0 -5
- package/dist/cjs/arkfee/types.js +0 -26
- package/dist/cjs/arknote/index.js +0 -128
- package/dist/cjs/bip322/index.js +0 -270
- package/dist/cjs/contracts/arkcontract.js +0 -147
- package/dist/cjs/contracts/contractManager.js +0 -649
- package/dist/cjs/contracts/contractWatcher.js +0 -598
- package/dist/cjs/contracts/handlers/default.js +0 -93
- package/dist/cjs/contracts/handlers/delegate.js +0 -90
- package/dist/cjs/contracts/handlers/helpers.js +0 -115
- package/dist/cjs/contracts/handlers/index.js +0 -19
- package/dist/cjs/contracts/handlers/registry.js +0 -89
- package/dist/cjs/contracts/handlers/vhtlc.js +0 -194
- package/dist/cjs/contracts/index.js +0 -41
- package/dist/cjs/contracts/types.js +0 -2
- package/dist/cjs/contracts/vtxoOwnership.js +0 -78
- package/dist/cjs/extension/asset/assetGroup.js +0 -228
- package/dist/cjs/extension/asset/assetId.js +0 -152
- package/dist/cjs/extension/asset/assetInput.js +0 -222
- package/dist/cjs/extension/asset/assetOutput.js +0 -174
- package/dist/cjs/extension/asset/assetRef.js +0 -148
- package/dist/cjs/extension/asset/index.js +0 -23
- package/dist/cjs/extension/asset/metadata.js +0 -187
- package/dist/cjs/extension/asset/packet.js +0 -114
- package/dist/cjs/extension/asset/types.js +0 -22
- package/dist/cjs/extension/asset/utils.js +0 -105
- package/dist/cjs/extension/index.js +0 -254
- package/dist/cjs/extension/packet.js +0 -20
- package/dist/cjs/forfeit.js +0 -45
- package/dist/cjs/identity/descriptor.js +0 -169
- package/dist/cjs/identity/descriptorProvider.js +0 -2
- package/dist/cjs/identity/hdCapableIdentity.js +0 -20
- package/dist/cjs/identity/index.js +0 -40
- package/dist/cjs/identity/seedIdentity.js +0 -477
- package/dist/cjs/identity/serialize.js +0 -171
- package/dist/cjs/identity/singleKey.js +0 -126
- package/dist/cjs/identity/staticDescriptorProvider.js +0 -65
- package/dist/cjs/index.js +0 -202
- package/dist/cjs/intent/index.js +0 -259
- package/dist/cjs/musig2/index.js +0 -11
- package/dist/cjs/musig2/keys.js +0 -57
- package/dist/cjs/musig2/nonces.js +0 -48
- package/dist/cjs/musig2/sign.js +0 -102
- package/dist/cjs/networks.js +0 -26
- package/dist/cjs/package.json +0 -3
- package/dist/cjs/providers/ark.js +0 -577
- package/dist/cjs/providers/delegator.js +0 -85
- package/dist/cjs/providers/electrum.js +0 -869
- package/dist/cjs/providers/errors.js +0 -59
- package/dist/cjs/providers/expoArk.js +0 -82
- package/dist/cjs/providers/expoIndexer.js +0 -111
- package/dist/cjs/providers/expoUtils.js +0 -124
- package/dist/cjs/providers/indexer.js +0 -630
- package/dist/cjs/providers/onchain.js +0 -262
- package/dist/cjs/providers/utils.js +0 -121
- package/dist/cjs/repositories/contractRepository.js +0 -2
- package/dist/cjs/repositories/inMemory/contractRepository.js +0 -55
- package/dist/cjs/repositories/inMemory/walletRepository.js +0 -115
- package/dist/cjs/repositories/index.js +0 -34
- package/dist/cjs/repositories/indexedDB/contractRepository.js +0 -187
- package/dist/cjs/repositories/indexedDB/db.js +0 -19
- package/dist/cjs/repositories/indexedDB/manager.js +0 -100
- package/dist/cjs/repositories/indexedDB/schema.js +0 -204
- package/dist/cjs/repositories/indexedDB/walletRepository.js +0 -474
- package/dist/cjs/repositories/indexedDB/websqlAdapter.js +0 -144
- package/dist/cjs/repositories/migrations/contractRepositoryImpl.js +0 -127
- package/dist/cjs/repositories/migrations/fromStorageAdapter.js +0 -66
- package/dist/cjs/repositories/migrations/walletRepositoryImpl.js +0 -184
- package/dist/cjs/repositories/realm/contractRepository.js +0 -116
- package/dist/cjs/repositories/realm/index.js +0 -11
- package/dist/cjs/repositories/realm/schemas.js +0 -157
- package/dist/cjs/repositories/realm/types.js +0 -7
- package/dist/cjs/repositories/realm/walletRepository.js +0 -305
- package/dist/cjs/repositories/scriptFromAddress.js +0 -16
- package/dist/cjs/repositories/serialization.js +0 -82
- package/dist/cjs/repositories/sqlite/contractRepository.js +0 -135
- package/dist/cjs/repositories/sqlite/index.js +0 -7
- package/dist/cjs/repositories/sqlite/types.js +0 -2
- package/dist/cjs/repositories/sqlite/walletRepository.js +0 -441
- package/dist/cjs/repositories/walletRepository.js +0 -2
- package/dist/cjs/script/address.js +0 -108
- package/dist/cjs/script/base.js +0 -185
- package/dist/cjs/script/default.js +0 -57
- package/dist/cjs/script/delegate.js +0 -53
- package/dist/cjs/script/tapscript.js +0 -619
- package/dist/cjs/script/vhtlc.js +0 -170
- package/dist/cjs/storage/asyncStorage.js +0 -50
- package/dist/cjs/storage/fileSystem.js +0 -141
- package/dist/cjs/storage/inMemory.js +0 -24
- package/dist/cjs/storage/index.js +0 -2
- package/dist/cjs/storage/indexedDB.js +0 -101
- package/dist/cjs/storage/localStorage.js +0 -51
- package/dist/cjs/tree/signingSession.js +0 -229
- package/dist/cjs/tree/txTree.js +0 -192
- package/dist/cjs/tree/validation.js +0 -107
- package/dist/cjs/utils/anchor.js +0 -35
- package/dist/cjs/utils/arkTransaction.js +0 -271
- package/dist/cjs/utils/bip21.js +0 -127
- package/dist/cjs/utils/syncCursors.js +0 -128
- package/dist/cjs/utils/timelock.js +0 -59
- package/dist/cjs/utils/transaction.js +0 -28
- package/dist/cjs/utils/transactionHistory.js +0 -183
- package/dist/cjs/utils/txSizeEstimator.js +0 -132
- package/dist/cjs/utils/unknownFields.js +0 -174
- package/dist/cjs/wallet/asset-manager.js +0 -330
- package/dist/cjs/wallet/asset.js +0 -119
- package/dist/cjs/wallet/batch.js +0 -183
- package/dist/cjs/wallet/delegator.js +0 -308
- package/dist/cjs/wallet/expo/background.js +0 -116
- package/dist/cjs/wallet/expo/index.js +0 -9
- package/dist/cjs/wallet/expo/wallet.js +0 -230
- package/dist/cjs/wallet/hdDescriptorProvider.js +0 -188
- package/dist/cjs/wallet/index.js +0 -82
- package/dist/cjs/wallet/inputSignerRouter.js +0 -98
- package/dist/cjs/wallet/onchain.js +0 -290
- package/dist/cjs/wallet/ramps.js +0 -216
- package/dist/cjs/wallet/serviceWorker/wallet-message-handler.js +0 -953
- package/dist/cjs/wallet/serviceWorker/wallet.js +0 -1174
- package/dist/cjs/wallet/signingErrors.js +0 -32
- package/dist/cjs/wallet/unroll.js +0 -293
- package/dist/cjs/wallet/utils.js +0 -111
- package/dist/cjs/wallet/validation.js +0 -154
- package/dist/cjs/wallet/vtxo-manager.js +0 -1142
- package/dist/cjs/wallet/wallet.js +0 -2195
- package/dist/cjs/wallet/walletReceiveRotator.js +0 -547
- package/dist/cjs/worker/browser/service-worker-manager.js +0 -183
- package/dist/cjs/worker/browser/utils.js +0 -67
- package/dist/cjs/worker/errors.js +0 -16
- package/dist/cjs/worker/expo/asyncStorageTaskQueue.js +0 -78
- package/dist/cjs/worker/expo/index.js +0 -13
- package/dist/cjs/worker/expo/processors/contractPollProcessor.js +0 -62
- package/dist/cjs/worker/expo/processors/index.js +0 -6
- package/dist/cjs/worker/expo/taskQueue.js +0 -41
- package/dist/cjs/worker/expo/taskRunner.js +0 -73
- package/dist/cjs/worker/messageBus.js +0 -474
- package/dist/esm/adapters/asyncStorage.js +0 -1
- package/dist/esm/adapters/expo.js +0 -3
- package/dist/esm/adapters/fileSystem.js +0 -1
- package/dist/esm/adapters/indexedDB.js +0 -1
- package/dist/esm/adapters/localStorage.js +0 -1
- package/dist/esm/arkfee/celenv.js +0 -40
- package/dist/esm/arkfee/estimator.js +0 -139
- package/dist/esm/arkfee/index.js +0 -1
- package/dist/esm/arkfee/types.js +0 -22
- package/dist/esm/arknote/index.js +0 -124
- package/dist/esm/bip322/index.js +0 -267
- package/dist/esm/contracts/arkcontract.js +0 -140
- package/dist/esm/contracts/contractManager.js +0 -645
- package/dist/esm/contracts/contractWatcher.js +0 -594
- package/dist/esm/contracts/handlers/default.js +0 -90
- package/dist/esm/contracts/handlers/delegate.js +0 -87
- package/dist/esm/contracts/handlers/helpers.js +0 -110
- package/dist/esm/contracts/handlers/index.js +0 -12
- package/dist/esm/contracts/handlers/registry.js +0 -86
- package/dist/esm/contracts/handlers/vhtlc.js +0 -191
- package/dist/esm/contracts/index.js +0 -13
- package/dist/esm/contracts/types.js +0 -1
- package/dist/esm/contracts/vtxoOwnership.js +0 -69
- package/dist/esm/extension/asset/assetGroup.js +0 -224
- package/dist/esm/extension/asset/assetId.js +0 -148
- package/dist/esm/extension/asset/assetInput.js +0 -217
- package/dist/esm/extension/asset/assetOutput.js +0 -169
- package/dist/esm/extension/asset/assetRef.js +0 -144
- package/dist/esm/extension/asset/index.js +0 -8
- package/dist/esm/extension/asset/metadata.js +0 -182
- package/dist/esm/extension/asset/packet.js +0 -110
- package/dist/esm/extension/asset/types.js +0 -19
- package/dist/esm/extension/asset/utils.js +0 -99
- package/dist/esm/extension/index.js +0 -248
- package/dist/esm/extension/packet.js +0 -16
- package/dist/esm/forfeit.js +0 -41
- package/dist/esm/identity/descriptor.js +0 -161
- package/dist/esm/identity/descriptorProvider.js +0 -1
- package/dist/esm/identity/hdCapableIdentity.js +0 -17
- package/dist/esm/identity/index.js +0 -13
- package/dist/esm/identity/seedIdentity.js +0 -469
- package/dist/esm/identity/serialize.js +0 -164
- package/dist/esm/identity/singleKey.js +0 -121
- package/dist/esm/identity/staticDescriptorProvider.js +0 -61
- package/dist/esm/index.js +0 -87
- package/dist/esm/intent/index.js +0 -255
- package/dist/esm/musig2/index.js +0 -3
- package/dist/esm/musig2/keys.js +0 -21
- package/dist/esm/musig2/nonces.js +0 -11
- package/dist/esm/musig2/sign.js +0 -63
- package/dist/esm/networks.js +0 -22
- package/dist/esm/package.json +0 -3
- package/dist/esm/providers/ark.js +0 -572
- package/dist/esm/providers/delegator.js +0 -81
- package/dist/esm/providers/electrum.js +0 -864
- package/dist/esm/providers/errors.js +0 -54
- package/dist/esm/providers/expoArk.js +0 -78
- package/dist/esm/providers/expoIndexer.js +0 -107
- package/dist/esm/providers/expoUtils.js +0 -87
- package/dist/esm/providers/indexer.js +0 -626
- package/dist/esm/providers/onchain.js +0 -258
- package/dist/esm/providers/utils.js +0 -117
- package/dist/esm/repositories/contractRepository.js +0 -1
- package/dist/esm/repositories/inMemory/contractRepository.js +0 -51
- package/dist/esm/repositories/inMemory/walletRepository.js +0 -111
- package/dist/esm/repositories/index.js +0 -10
- package/dist/esm/repositories/indexedDB/contractRepository.js +0 -183
- package/dist/esm/repositories/indexedDB/db.js +0 -4
- package/dist/esm/repositories/indexedDB/manager.js +0 -95
- package/dist/esm/repositories/indexedDB/schema.js +0 -199
- package/dist/esm/repositories/indexedDB/walletRepository.js +0 -470
- package/dist/esm/repositories/indexedDB/websqlAdapter.js +0 -138
- package/dist/esm/repositories/migrations/contractRepositoryImpl.js +0 -121
- package/dist/esm/repositories/migrations/fromStorageAdapter.js +0 -58
- package/dist/esm/repositories/migrations/walletRepositoryImpl.js +0 -180
- package/dist/esm/repositories/realm/contractRepository.js +0 -112
- package/dist/esm/repositories/realm/index.js +0 -3
- package/dist/esm/repositories/realm/schemas.js +0 -153
- package/dist/esm/repositories/realm/types.js +0 -6
- package/dist/esm/repositories/realm/walletRepository.js +0 -301
- package/dist/esm/repositories/scriptFromAddress.js +0 -13
- package/dist/esm/repositories/serialization.js +0 -67
- package/dist/esm/repositories/sqlite/contractRepository.js +0 -131
- package/dist/esm/repositories/sqlite/index.js +0 -2
- package/dist/esm/repositories/sqlite/types.js +0 -1
- package/dist/esm/repositories/sqlite/walletRepository.js +0 -437
- package/dist/esm/repositories/walletRepository.js +0 -1
- package/dist/esm/script/address.js +0 -104
- package/dist/esm/script/base.js +0 -179
- package/dist/esm/script/default.js +0 -54
- package/dist/esm/script/delegate.js +0 -50
- package/dist/esm/script/tapscript.js +0 -615
- package/dist/esm/script/vhtlc.js +0 -167
- package/dist/esm/storage/asyncStorage.js +0 -46
- package/dist/esm/storage/fileSystem.js +0 -104
- package/dist/esm/storage/inMemory.js +0 -20
- package/dist/esm/storage/index.js +0 -1
- package/dist/esm/storage/indexedDB.js +0 -97
- package/dist/esm/storage/localStorage.js +0 -47
- package/dist/esm/tree/signingSession.js +0 -191
- package/dist/esm/tree/txTree.js +0 -188
- package/dist/esm/tree/validation.js +0 -101
- package/dist/esm/utils/anchor.js +0 -31
- package/dist/esm/utils/arkTransaction.js +0 -264
- package/dist/esm/utils/bip21.js +0 -123
- package/dist/esm/utils/syncCursors.js +0 -119
- package/dist/esm/utils/timelock.js +0 -22
- package/dist/esm/utils/transaction.js +0 -24
- package/dist/esm/utils/transactionHistory.js +0 -180
- package/dist/esm/utils/txSizeEstimator.js +0 -128
- package/dist/esm/utils/unknownFields.js +0 -169
- package/dist/esm/wallet/asset-manager.js +0 -325
- package/dist/esm/wallet/asset.js +0 -113
- package/dist/esm/wallet/batch.js +0 -180
- package/dist/esm/wallet/delegator.js +0 -303
- package/dist/esm/wallet/expo/background.js +0 -111
- package/dist/esm/wallet/expo/index.js +0 -2
- package/dist/esm/wallet/expo/wallet.js +0 -193
- package/dist/esm/wallet/hdDescriptorProvider.js +0 -184
- package/dist/esm/wallet/index.js +0 -75
- package/dist/esm/wallet/inputSignerRouter.js +0 -94
- package/dist/esm/wallet/onchain.js +0 -285
- package/dist/esm/wallet/ramps.js +0 -212
- package/dist/esm/wallet/serviceWorker/wallet-message-handler.js +0 -946
- package/dist/esm/wallet/serviceWorker/wallet.js +0 -1169
- package/dist/esm/wallet/signingErrors.js +0 -27
- package/dist/esm/wallet/unroll.js +0 -289
- package/dist/esm/wallet/utils.js +0 -103
- package/dist/esm/wallet/validation.js +0 -142
- package/dist/esm/wallet/vtxo-manager.js +0 -1136
- package/dist/esm/wallet/wallet.js +0 -2186
- package/dist/esm/wallet/walletReceiveRotator.js +0 -540
- package/dist/esm/worker/browser/service-worker-manager.js +0 -177
- package/dist/esm/worker/browser/utils.js +0 -63
- package/dist/esm/worker/errors.js +0 -11
- package/dist/esm/worker/expo/asyncStorageTaskQueue.js +0 -74
- package/dist/esm/worker/expo/index.js +0 -4
- package/dist/esm/worker/expo/processors/contractPollProcessor.js +0 -59
- package/dist/esm/worker/expo/processors/index.js +0 -1
- package/dist/esm/worker/expo/taskQueue.js +0 -37
- package/dist/esm/worker/expo/taskRunner.js +0 -69
- package/dist/esm/worker/messageBus.js +0 -470
- package/dist/types/adapters/asyncStorage.d.ts +0 -2
- package/dist/types/adapters/expo.d.ts +0 -4
- package/dist/types/adapters/fileSystem.d.ts +0 -2
- package/dist/types/adapters/indexedDB.d.ts +0 -2
- package/dist/types/adapters/localStorage.d.ts +0 -2
- package/dist/types/arkfee/celenv.d.ts +0 -25
- package/dist/types/arkfee/estimator.d.ts +0 -49
- package/dist/types/arkfee/index.d.ts +0 -2
- package/dist/types/arkfee/types.d.ts +0 -38
- package/dist/types/arknote/index.d.ts +0 -84
- package/dist/types/bip322/index.d.ts +0 -55
- package/dist/types/contracts/arkcontract.d.ts +0 -99
- package/dist/types/contracts/contractManager.d.ts +0 -411
- package/dist/types/contracts/contractWatcher.d.ts +0 -217
- package/dist/types/contracts/handlers/default.d.ts +0 -19
- package/dist/types/contracts/handlers/delegate.d.ts +0 -21
- package/dist/types/contracts/handlers/helpers.d.ts +0 -19
- package/dist/types/contracts/handlers/index.d.ts +0 -7
- package/dist/types/contracts/handlers/registry.d.ts +0 -65
- package/dist/types/contracts/handlers/vhtlc.d.ts +0 -32
- package/dist/types/contracts/index.d.ts +0 -14
- package/dist/types/contracts/types.d.ts +0 -250
- package/dist/types/contracts/vtxoOwnership.d.ts +0 -33
- package/dist/types/extension/asset/assetGroup.d.ts +0 -119
- package/dist/types/extension/asset/assetId.d.ts +0 -83
- package/dist/types/extension/asset/assetInput.d.ts +0 -64
- package/dist/types/extension/asset/assetOutput.d.ts +0 -54
- package/dist/types/extension/asset/assetRef.d.ts +0 -91
- package/dist/types/extension/asset/index.d.ts +0 -8
- package/dist/types/extension/asset/metadata.d.ts +0 -52
- package/dist/types/extension/asset/packet.d.ts +0 -41
- package/dist/types/extension/asset/types.d.ts +0 -16
- package/dist/types/extension/asset/utils.d.ts +0 -21
- package/dist/types/extension/index.d.ts +0 -56
- package/dist/types/extension/packet.d.ts +0 -21
- package/dist/types/forfeit.d.ts +0 -18
- package/dist/types/identity/descriptor.d.ts +0 -61
- package/dist/types/identity/descriptorProvider.d.ts +0 -42
- package/dist/types/identity/hdCapableIdentity.d.ts +0 -71
- package/dist/types/identity/index.d.ts +0 -57
- package/dist/types/identity/seedIdentity.d.ts +0 -270
- package/dist/types/identity/serialize.d.ts +0 -96
- package/dist/types/identity/singleKey.d.ts +0 -62
- package/dist/types/identity/staticDescriptorProvider.d.ts +0 -18
- package/dist/types/index.d.ts +0 -59
- package/dist/types/intent/index.d.ts +0 -86
- package/dist/types/musig2/index.d.ts +0 -4
- package/dist/types/musig2/keys.d.ts +0 -9
- package/dist/types/musig2/nonces.d.ts +0 -14
- package/dist/types/musig2/sign.d.ts +0 -27
- package/dist/types/networks.d.ts +0 -16
- package/dist/types/providers/ark.d.ts +0 -369
- package/dist/types/providers/delegator.d.ts +0 -82
- package/dist/types/providers/electrum.d.ts +0 -312
- package/dist/types/providers/errors.d.ts +0 -13
- package/dist/types/providers/expoArk.d.ts +0 -22
- package/dist/types/providers/expoIndexer.d.ts +0 -18
- package/dist/types/providers/expoUtils.d.ts +0 -18
- package/dist/types/providers/indexer.d.ts +0 -301
- package/dist/types/providers/onchain.d.ts +0 -148
- package/dist/types/providers/utils.d.ts +0 -12
- package/dist/types/repositories/contractRepository.d.ts +0 -32
- package/dist/types/repositories/inMemory/contractRepository.d.ts +0 -17
- package/dist/types/repositories/inMemory/walletRepository.d.ts +0 -29
- package/dist/types/repositories/index.d.ts +0 -9
- package/dist/types/repositories/indexedDB/contractRepository.d.ts +0 -21
- package/dist/types/repositories/indexedDB/db.d.ts +0 -4
- package/dist/types/repositories/indexedDB/manager.d.ts +0 -25
- package/dist/types/repositories/indexedDB/schema.d.ts +0 -9
- package/dist/types/repositories/indexedDB/walletRepository.d.ts +0 -28
- package/dist/types/repositories/indexedDB/websqlAdapter.d.ts +0 -49
- package/dist/types/repositories/migrations/contractRepositoryImpl.d.ts +0 -24
- package/dist/types/repositories/migrations/fromStorageAdapter.d.ts +0 -19
- package/dist/types/repositories/migrations/walletRepositoryImpl.d.ts +0 -27
- package/dist/types/repositories/realm/contractRepository.d.ts +0 -24
- package/dist/types/repositories/realm/index.d.ts +0 -4
- package/dist/types/repositories/realm/types.d.ts +0 -16
- package/dist/types/repositories/realm/walletRepository.d.ts +0 -34
- package/dist/types/repositories/scriptFromAddress.d.ts +0 -9
- package/dist/types/repositories/serialization.d.ts +0 -65
- package/dist/types/repositories/sqlite/contractRepository.d.ts +0 -33
- package/dist/types/repositories/sqlite/index.d.ts +0 -3
- package/dist/types/repositories/sqlite/types.d.ts +0 -18
- package/dist/types/repositories/walletRepository.d.ts +0 -72
- package/dist/types/script/address.d.ts +0 -67
- package/dist/types/script/base.d.ts +0 -105
- package/dist/types/script/default.d.ts +0 -44
- package/dist/types/script/delegate.d.ts +0 -40
- package/dist/types/script/tapscript.d.ts +0 -169
- package/dist/types/script/vhtlc.d.ts +0 -66
- package/dist/types/tree/signingSession.d.ts +0 -37
- package/dist/types/tree/txTree.d.ts +0 -28
- package/dist/types/tree/validation.d.ts +0 -15
- package/dist/types/utils/anchor.d.ts +0 -19
- package/dist/types/utils/arkTransaction.d.ts +0 -49
- package/dist/types/utils/bip21.d.ts +0 -38
- package/dist/types/utils/syncCursors.d.ts +0 -60
- package/dist/types/utils/timelock.d.ts +0 -9
- package/dist/types/utils/transaction.d.ts +0 -13
- package/dist/types/utils/transactionHistory.d.ts +0 -15
- package/dist/types/utils/txSizeEstimator.d.ts +0 -40
- package/dist/types/utils/unknownFields.d.ts +0 -83
- package/dist/types/wallet/asset-manager.d.ts +0 -69
- package/dist/types/wallet/asset.d.ts +0 -21
- package/dist/types/wallet/batch.d.ts +0 -107
- package/dist/types/wallet/delegator.d.ts +0 -48
- package/dist/types/wallet/expo/background.d.ts +0 -66
- package/dist/types/wallet/expo/index.d.ts +0 -4
- package/dist/types/wallet/hdDescriptorProvider.d.ts +0 -114
- package/dist/types/wallet/index.d.ts +0 -789
- package/dist/types/wallet/inputSignerRouter.d.ts +0 -35
- package/dist/types/wallet/onchain.d.ts +0 -109
- package/dist/types/wallet/ramps.d.ts +0 -64
- package/dist/types/wallet/serviceWorker/wallet-message-handler.d.ts +0 -543
- package/dist/types/wallet/serviceWorker/wallet.d.ts +0 -248
- package/dist/types/wallet/signingErrors.d.ts +0 -19
- package/dist/types/wallet/unroll.d.ts +0 -114
- package/dist/types/wallet/utils.d.ts +0 -36
- package/dist/types/wallet/validation.d.ts +0 -24
- package/dist/types/wallet/vtxo-manager.d.ts +0 -476
- package/dist/types/wallet/wallet.d.ts +0 -409
- package/dist/types/wallet/walletReceiveRotator.d.ts +0 -306
- package/dist/types/worker/browser/service-worker-manager.d.ts +0 -32
- package/dist/types/worker/browser/utils.d.ts +0 -17
- package/dist/types/worker/errors.d.ts +0 -7
- package/dist/types/worker/expo/index.d.ts +0 -7
- package/dist/types/worker/expo/processors/contractPollProcessor.d.ts +0 -19
- package/dist/types/worker/expo/processors/index.d.ts +0 -1
- package/dist/types/worker/expo/taskQueue.d.ts +0 -50
- package/dist/types/worker/expo/taskRunner.d.ts +0 -66
- package/dist/types/worker/messageBus.d.ts +0 -189
|
@@ -1,470 +0,0 @@
|
|
|
1
|
-
import { STORE_VTXOS, STORE_UTXOS, STORE_TRANSACTIONS, STORE_WALLET_STATE, serializeVtxo, serializeUtxo, deserializeVtxo, deserializeUtxo, DB_VERSION, } from "./db.js";
|
|
2
|
-
import { closeDatabase, openDatabase } from "./manager.js";
|
|
3
|
-
import { initDatabase } from "./schema.js";
|
|
4
|
-
import { scriptFromArkAddress } from "../scriptFromAddress.js";
|
|
5
|
-
import { DEFAULT_DB_NAME } from "../../worker/browser/utils.js";
|
|
6
|
-
import { isVtxoForScript } from "../../contracts/vtxoOwnership.js";
|
|
7
|
-
/**
|
|
8
|
-
* IndexedDB-based implementation of WalletRepository.
|
|
9
|
-
*/
|
|
10
|
-
export class IndexedDBWalletRepository {
|
|
11
|
-
constructor(dbName = DEFAULT_DB_NAME) {
|
|
12
|
-
this.dbName = dbName;
|
|
13
|
-
this.version = 1;
|
|
14
|
-
this.db = null;
|
|
15
|
-
}
|
|
16
|
-
async clear() {
|
|
17
|
-
try {
|
|
18
|
-
const db = await this.getDB();
|
|
19
|
-
return new Promise((resolve, reject) => {
|
|
20
|
-
const transaction = db.transaction([
|
|
21
|
-
STORE_VTXOS,
|
|
22
|
-
STORE_UTXOS,
|
|
23
|
-
STORE_TRANSACTIONS,
|
|
24
|
-
STORE_WALLET_STATE,
|
|
25
|
-
], "readwrite");
|
|
26
|
-
const vtxosStore = transaction.objectStore(STORE_VTXOS);
|
|
27
|
-
const utxosStore = transaction.objectStore(STORE_UTXOS);
|
|
28
|
-
const transactionsStore = transaction.objectStore(STORE_TRANSACTIONS);
|
|
29
|
-
const walletStateStore = transaction.objectStore(STORE_WALLET_STATE);
|
|
30
|
-
const requests = [
|
|
31
|
-
vtxosStore.clear(),
|
|
32
|
-
utxosStore.clear(),
|
|
33
|
-
transactionsStore.clear(),
|
|
34
|
-
walletStateStore.clear(),
|
|
35
|
-
];
|
|
36
|
-
let completed = 0;
|
|
37
|
-
const checkComplete = () => {
|
|
38
|
-
completed++;
|
|
39
|
-
if (completed === requests.length) {
|
|
40
|
-
resolve();
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
requests.forEach((request) => {
|
|
44
|
-
request.onsuccess = checkComplete;
|
|
45
|
-
request.onerror = () => reject(request.error);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
console.error("Failed to clear wallet data:", error);
|
|
51
|
-
throw error;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
async [Symbol.asyncDispose]() {
|
|
55
|
-
if (!this.db)
|
|
56
|
-
return;
|
|
57
|
-
await closeDatabase(this.dbName);
|
|
58
|
-
this.db = null;
|
|
59
|
-
}
|
|
60
|
-
async getVtxos(address) {
|
|
61
|
-
try {
|
|
62
|
-
const db = await this.getDB();
|
|
63
|
-
return new Promise((resolve, reject) => {
|
|
64
|
-
const transaction = db.transaction([STORE_VTXOS], "readonly");
|
|
65
|
-
const store = transaction.objectStore(STORE_VTXOS);
|
|
66
|
-
const index = store.index("address");
|
|
67
|
-
const request = index.getAll(address);
|
|
68
|
-
request.onerror = () => reject(request.error);
|
|
69
|
-
request.onsuccess = () => {
|
|
70
|
-
const results = request.result || [];
|
|
71
|
-
// Wrap `.map` in try/catch so a bad row (e.g. a legacy
|
|
72
|
-
// VTXO whose address can't be decoded during backfill)
|
|
73
|
-
// rejects the promise instead of silently throwing
|
|
74
|
-
// inside the IDB event handler, which would otherwise
|
|
75
|
-
// hang the caller.
|
|
76
|
-
try {
|
|
77
|
-
resolve(results.map(deserializeVtxoWithBackfill));
|
|
78
|
-
}
|
|
79
|
-
catch (err) {
|
|
80
|
-
reject(err);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
console.error(`Failed to get VTXOs for address ${address}:`, error);
|
|
87
|
-
return [];
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
async saveVtxos(address, vtxos) {
|
|
91
|
-
try {
|
|
92
|
-
const db = await this.getDB();
|
|
93
|
-
return new Promise((resolve, reject) => {
|
|
94
|
-
const transaction = db.transaction([STORE_VTXOS], "readwrite");
|
|
95
|
-
const store = transaction.objectStore(STORE_VTXOS);
|
|
96
|
-
const promises = vtxos.map((vtxo) => {
|
|
97
|
-
return new Promise((resolveItem, rejectItem) => {
|
|
98
|
-
const serialized = serializeVtxo(vtxo);
|
|
99
|
-
const item = {
|
|
100
|
-
address,
|
|
101
|
-
...serialized,
|
|
102
|
-
};
|
|
103
|
-
const request = store.put(item);
|
|
104
|
-
request.onerror = () => rejectItem(request.error);
|
|
105
|
-
request.onsuccess = () => resolveItem();
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
Promise.all(promises)
|
|
109
|
-
.then(() => resolve())
|
|
110
|
-
.catch(reject);
|
|
111
|
-
transaction.onerror = () => reject(transaction.error);
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
catch (error) {
|
|
115
|
-
console.error(`Failed to save VTXOs for address ${address}:`, error);
|
|
116
|
-
throw error;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
async deleteVtxos(address) {
|
|
120
|
-
try {
|
|
121
|
-
const db = await this.getDB();
|
|
122
|
-
return new Promise((resolve, reject) => {
|
|
123
|
-
const transaction = db.transaction([STORE_VTXOS], "readwrite");
|
|
124
|
-
const store = transaction.objectStore(STORE_VTXOS);
|
|
125
|
-
const index = store.index("address");
|
|
126
|
-
const request = index.openCursor(IDBKeyRange.only(address));
|
|
127
|
-
request.onerror = () => reject(request.error);
|
|
128
|
-
request.onsuccess = () => {
|
|
129
|
-
const cursor = request.result;
|
|
130
|
-
if (cursor) {
|
|
131
|
-
cursor.delete();
|
|
132
|
-
cursor.continue();
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
resolve();
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
catch (error) {
|
|
141
|
-
console.error(`Failed to clear VTXOs for address ${address}:`, error);
|
|
142
|
-
throw error;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
async getVtxosForScript(script) {
|
|
146
|
-
try {
|
|
147
|
-
const db = await this.getDB();
|
|
148
|
-
return new Promise((resolve, reject) => {
|
|
149
|
-
const transaction = db.transaction([STORE_VTXOS], "readonly");
|
|
150
|
-
const store = transaction.objectStore(STORE_VTXOS);
|
|
151
|
-
const index = store.index("script");
|
|
152
|
-
const request = index.getAll(script);
|
|
153
|
-
request.onerror = () => reject(request.error);
|
|
154
|
-
request.onsuccess = () => {
|
|
155
|
-
const results = request.result || [];
|
|
156
|
-
try {
|
|
157
|
-
// Defensive filter: only rows whose script matches.
|
|
158
|
-
const matching = results.filter((r) => r.script === script);
|
|
159
|
-
// Dedup same outpoint rows across address buckets.
|
|
160
|
-
// Work on raw rows so the address field is available
|
|
161
|
-
// for the canonicality tiebreaker.
|
|
162
|
-
const byOutpoint = new Map();
|
|
163
|
-
for (const row of matching) {
|
|
164
|
-
const outpoint = `${row.txid}:${row.vout}`;
|
|
165
|
-
const existing = byOutpoint.get(outpoint);
|
|
166
|
-
if (!existing) {
|
|
167
|
-
byOutpoint.set(outpoint, row);
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
if (shouldReplaceVtxo(existing, row)) {
|
|
171
|
-
byOutpoint.set(outpoint, row);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
resolve(Array.from(byOutpoint.values()).map(deserializeVtxoWithBackfill));
|
|
175
|
-
}
|
|
176
|
-
catch (err) {
|
|
177
|
-
reject(err);
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
catch (error) {
|
|
183
|
-
console.error(`Failed to get VTXOs for script ${script}:`, error);
|
|
184
|
-
throw error;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
async saveVtxosForScript(key, vtxos) {
|
|
188
|
-
if (!key.address) {
|
|
189
|
-
throw new Error("IndexedDBWalletRepository requires an address");
|
|
190
|
-
}
|
|
191
|
-
for (const vtxo of vtxos) {
|
|
192
|
-
if (!isVtxoForScript(vtxo, key.script)) {
|
|
193
|
-
throw new Error(`VTXO ${vtxo.txid}:${vtxo.vout} script mismatch: expected ${key.script}, got ${vtxo.script}`);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return this.saveVtxos(key.address, vtxos);
|
|
197
|
-
}
|
|
198
|
-
async deleteVtxosForScript(script) {
|
|
199
|
-
try {
|
|
200
|
-
const db = await this.getDB();
|
|
201
|
-
return new Promise((resolve, reject) => {
|
|
202
|
-
const transaction = db.transaction([STORE_VTXOS], "readwrite");
|
|
203
|
-
const store = transaction.objectStore(STORE_VTXOS);
|
|
204
|
-
const index = store.index("script");
|
|
205
|
-
const request = index.openCursor(IDBKeyRange.only(script));
|
|
206
|
-
request.onerror = () => reject(request.error);
|
|
207
|
-
request.onsuccess = () => {
|
|
208
|
-
const cursor = request.result;
|
|
209
|
-
if (cursor) {
|
|
210
|
-
cursor.delete();
|
|
211
|
-
cursor.continue();
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
resolve();
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
catch (error) {
|
|
220
|
-
console.error(`Failed to clear VTXOs for script ${script}:`, error);
|
|
221
|
-
throw error;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
async getUtxos(address) {
|
|
225
|
-
try {
|
|
226
|
-
const db = await this.getDB();
|
|
227
|
-
return new Promise((resolve, reject) => {
|
|
228
|
-
const transaction = db.transaction([STORE_UTXOS], "readonly");
|
|
229
|
-
const store = transaction.objectStore(STORE_UTXOS);
|
|
230
|
-
const index = store.index("address");
|
|
231
|
-
const request = index.getAll(address);
|
|
232
|
-
request.onerror = () => reject(request.error);
|
|
233
|
-
request.onsuccess = () => {
|
|
234
|
-
const results = request.result || [];
|
|
235
|
-
const utxos = results.map(deserializeUtxo);
|
|
236
|
-
resolve(utxos);
|
|
237
|
-
};
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
catch (error) {
|
|
241
|
-
console.error(`Failed to get UTXOs for address ${address}:`, error);
|
|
242
|
-
return [];
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
async saveUtxos(address, utxos) {
|
|
246
|
-
try {
|
|
247
|
-
const db = await this.getDB();
|
|
248
|
-
return new Promise((resolve, reject) => {
|
|
249
|
-
const transaction = db.transaction([STORE_UTXOS], "readwrite");
|
|
250
|
-
const store = transaction.objectStore(STORE_UTXOS);
|
|
251
|
-
const promises = utxos.map((utxo) => {
|
|
252
|
-
return new Promise((resolveItem, rejectItem) => {
|
|
253
|
-
const serialized = serializeUtxo(utxo);
|
|
254
|
-
const item = {
|
|
255
|
-
address,
|
|
256
|
-
...serialized,
|
|
257
|
-
};
|
|
258
|
-
const request = store.put(item);
|
|
259
|
-
request.onerror = () => rejectItem(request.error);
|
|
260
|
-
request.onsuccess = () => resolveItem();
|
|
261
|
-
});
|
|
262
|
-
});
|
|
263
|
-
Promise.all(promises)
|
|
264
|
-
.then(() => resolve())
|
|
265
|
-
.catch(reject);
|
|
266
|
-
transaction.onerror = () => reject(transaction.error);
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
catch (error) {
|
|
270
|
-
console.error(`Failed to save UTXOs for address ${address}:`, error);
|
|
271
|
-
throw error;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
async deleteUtxos(address) {
|
|
275
|
-
try {
|
|
276
|
-
const db = await this.getDB();
|
|
277
|
-
return new Promise((resolve, reject) => {
|
|
278
|
-
const transaction = db.transaction([STORE_UTXOS], "readwrite");
|
|
279
|
-
const store = transaction.objectStore(STORE_UTXOS);
|
|
280
|
-
const index = store.index("address");
|
|
281
|
-
const request = index.openCursor(IDBKeyRange.only(address));
|
|
282
|
-
request.onerror = () => reject(request.error);
|
|
283
|
-
request.onsuccess = () => {
|
|
284
|
-
const cursor = request.result;
|
|
285
|
-
if (cursor) {
|
|
286
|
-
cursor.delete();
|
|
287
|
-
cursor.continue();
|
|
288
|
-
}
|
|
289
|
-
else {
|
|
290
|
-
resolve();
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
catch (error) {
|
|
296
|
-
console.error(`Failed to clear UTXOs for address ${address}:`, error);
|
|
297
|
-
throw error;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
async getTransactionHistory(address) {
|
|
301
|
-
try {
|
|
302
|
-
const db = await this.getDB();
|
|
303
|
-
return new Promise((resolve, reject) => {
|
|
304
|
-
const transaction = db.transaction([STORE_TRANSACTIONS], "readonly");
|
|
305
|
-
const store = transaction.objectStore(STORE_TRANSACTIONS);
|
|
306
|
-
const index = store.index("address");
|
|
307
|
-
const request = index.getAll(address);
|
|
308
|
-
request.onerror = () => reject(request.error);
|
|
309
|
-
request.onsuccess = () => {
|
|
310
|
-
const results = request.result || [];
|
|
311
|
-
resolve(results.sort((a, b) => a.createdAt - b.createdAt));
|
|
312
|
-
};
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
catch (error) {
|
|
316
|
-
console.error(`Failed to get transaction history for address ${address}:`, error);
|
|
317
|
-
return [];
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
async saveTransactions(address, txs) {
|
|
321
|
-
try {
|
|
322
|
-
const db = await this.getDB();
|
|
323
|
-
return new Promise((resolve, reject) => {
|
|
324
|
-
const transaction = db.transaction([STORE_TRANSACTIONS], "readwrite");
|
|
325
|
-
const store = transaction.objectStore(STORE_TRANSACTIONS);
|
|
326
|
-
// Queue all put operations
|
|
327
|
-
txs.forEach((tx) => {
|
|
328
|
-
const item = {
|
|
329
|
-
address,
|
|
330
|
-
...tx,
|
|
331
|
-
keyBoardingTxid: tx.key.boardingTxid,
|
|
332
|
-
keyCommitmentTxid: tx.key.commitmentTxid,
|
|
333
|
-
keyArkTxid: tx.key.arkTxid,
|
|
334
|
-
};
|
|
335
|
-
store.put(item);
|
|
336
|
-
});
|
|
337
|
-
// Handle transaction completion
|
|
338
|
-
transaction.oncomplete = () => resolve();
|
|
339
|
-
transaction.onerror = () => reject(transaction.error);
|
|
340
|
-
transaction.onabort = () => reject(new Error("Transaction aborted"));
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
catch (error) {
|
|
344
|
-
console.error(`Failed to save transactions for address ${address}:`, error);
|
|
345
|
-
throw error;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
async deleteTransactions(address) {
|
|
349
|
-
try {
|
|
350
|
-
const db = await this.getDB();
|
|
351
|
-
return new Promise((resolve, reject) => {
|
|
352
|
-
const transaction = db.transaction([STORE_TRANSACTIONS], "readwrite");
|
|
353
|
-
const store = transaction.objectStore(STORE_TRANSACTIONS);
|
|
354
|
-
const index = store.index("address");
|
|
355
|
-
const request = index.openCursor(IDBKeyRange.only(address));
|
|
356
|
-
request.onerror = () => reject(request.error);
|
|
357
|
-
request.onsuccess = () => {
|
|
358
|
-
const cursor = request.result;
|
|
359
|
-
if (cursor) {
|
|
360
|
-
cursor.delete();
|
|
361
|
-
cursor.continue();
|
|
362
|
-
}
|
|
363
|
-
else {
|
|
364
|
-
resolve();
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
catch (error) {
|
|
370
|
-
console.error(`Failed to clear transactions for address ${address}:`, error);
|
|
371
|
-
throw error;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
async getWalletState() {
|
|
375
|
-
try {
|
|
376
|
-
const db = await this.getDB();
|
|
377
|
-
return new Promise((resolve, reject) => {
|
|
378
|
-
const transaction = db.transaction([STORE_WALLET_STATE], "readonly");
|
|
379
|
-
const store = transaction.objectStore(STORE_WALLET_STATE);
|
|
380
|
-
const request = store.get("state");
|
|
381
|
-
request.onerror = () => reject(request.error);
|
|
382
|
-
request.onsuccess = () => {
|
|
383
|
-
const result = request.result;
|
|
384
|
-
if (result && result.data) {
|
|
385
|
-
resolve(result.data);
|
|
386
|
-
}
|
|
387
|
-
else {
|
|
388
|
-
resolve(null);
|
|
389
|
-
}
|
|
390
|
-
};
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
catch (error) {
|
|
394
|
-
console.error("Failed to get wallet state:", error);
|
|
395
|
-
return null;
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
async saveWalletState(state) {
|
|
399
|
-
try {
|
|
400
|
-
const db = await this.getDB();
|
|
401
|
-
return new Promise((resolve, reject) => {
|
|
402
|
-
const transaction = db.transaction([STORE_WALLET_STATE], "readwrite");
|
|
403
|
-
const store = transaction.objectStore(STORE_WALLET_STATE);
|
|
404
|
-
const item = {
|
|
405
|
-
key: "state",
|
|
406
|
-
data: state,
|
|
407
|
-
};
|
|
408
|
-
const request = store.put(item);
|
|
409
|
-
request.onerror = () => reject(request.error);
|
|
410
|
-
request.onsuccess = () => resolve();
|
|
411
|
-
});
|
|
412
|
-
}
|
|
413
|
-
catch (error) {
|
|
414
|
-
console.error("Failed to save wallet state:", error);
|
|
415
|
-
throw error;
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
async getDB() {
|
|
419
|
-
if (this.db)
|
|
420
|
-
return this.db;
|
|
421
|
-
this.db = await openDatabase(this.dbName, DB_VERSION, initDatabase);
|
|
422
|
-
return this.db;
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
// Post-migration every row has `script`, but the backfill is idempotent: if a
|
|
426
|
-
// legacy row is ever read before the upgrade-path completes, derive `script`
|
|
427
|
-
// from `address` the same way the indexer would have populated it.
|
|
428
|
-
function deserializeVtxoWithBackfill(o) {
|
|
429
|
-
if (!o.script) {
|
|
430
|
-
o = { ...o, script: scriptFromArkAddress(o.address) };
|
|
431
|
-
}
|
|
432
|
-
return deserializeVtxo(o);
|
|
433
|
-
}
|
|
434
|
-
function isCanonicalRow(row) {
|
|
435
|
-
try {
|
|
436
|
-
return scriptFromArkAddress(row.address) === row.script;
|
|
437
|
-
}
|
|
438
|
-
catch {
|
|
439
|
-
return false;
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
function shouldReplaceVtxo(existing, incoming) {
|
|
443
|
-
const existingCanonical = isCanonicalRow(existing);
|
|
444
|
-
const incomingCanonical = isCanonicalRow(incoming);
|
|
445
|
-
if (incomingCanonical && !existingCanonical)
|
|
446
|
-
return true;
|
|
447
|
-
if (existingCanonical && !incomingCanonical)
|
|
448
|
-
return false;
|
|
449
|
-
// Tie on canonicality, check lifecycle completeness
|
|
450
|
-
const existingWeight = getLifecycleWeight(existing);
|
|
451
|
-
const incomingWeight = getLifecycleWeight(incoming);
|
|
452
|
-
if (incomingWeight > existingWeight)
|
|
453
|
-
return true;
|
|
454
|
-
if (existingWeight > incomingWeight)
|
|
455
|
-
return false;
|
|
456
|
-
// Tie on weight, stable sort by address
|
|
457
|
-
return incoming.address < existing.address;
|
|
458
|
-
}
|
|
459
|
-
function getLifecycleWeight(v) {
|
|
460
|
-
let weight = 0;
|
|
461
|
-
if (v.isSpent !== undefined)
|
|
462
|
-
weight += 1;
|
|
463
|
-
if (v.spentBy)
|
|
464
|
-
weight += 2;
|
|
465
|
-
if (v.settledBy)
|
|
466
|
-
weight += 2;
|
|
467
|
-
if (v.arkTxId)
|
|
468
|
-
weight += 2;
|
|
469
|
-
return weight;
|
|
470
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WebSQL adapter over expo-sqlite.
|
|
3
|
-
*
|
|
4
|
-
* Bridges the WebSQL API surface that indexeddbshim expects to the
|
|
5
|
-
* synchronous expo-sqlite driver. Only the subset actually called by
|
|
6
|
-
* the shim is implemented:
|
|
7
|
-
*
|
|
8
|
-
* openDatabase(name, version, displayName, estimatedSize) → WebSQLDatabase
|
|
9
|
-
* db.transaction(cb, errCb?, successCb?)
|
|
10
|
-
* tx.executeSql(sql, args?, successCb?, errorCb?)
|
|
11
|
-
* resultSet = { insertId, rowsAffected, rows: { length, item(i) } }
|
|
12
|
-
*/
|
|
13
|
-
import { openDatabaseSync } from "expo-sqlite";
|
|
14
|
-
// ── Database cache ───────────────────────────────────────────────────
|
|
15
|
-
const dbCache = new Map();
|
|
16
|
-
function getSqliteDb(name) {
|
|
17
|
-
let db = dbCache.get(name);
|
|
18
|
-
if (db)
|
|
19
|
-
return { db, created: false };
|
|
20
|
-
db = openDatabaseSync(name);
|
|
21
|
-
dbCache.set(name, db);
|
|
22
|
-
return { db, created: true };
|
|
23
|
-
}
|
|
24
|
-
// ── WebSQLTransaction ────────────────────────────────────────────────
|
|
25
|
-
export class WebSQLTransaction {
|
|
26
|
-
constructor() {
|
|
27
|
-
/** @internal */
|
|
28
|
-
this._queue = [];
|
|
29
|
-
}
|
|
30
|
-
executeSql(sql, args, successCb, errorCb) {
|
|
31
|
-
this._queue.push({ sql, args: args ?? [], successCb, errorCb });
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
// ── Helpers ──────────────────────────────────────────────────────────
|
|
35
|
-
function isRead(sql) {
|
|
36
|
-
const trimmed = sql.trimStart().toUpperCase();
|
|
37
|
-
return trimmed.startsWith("SELECT") || trimmed.startsWith("PRAGMA");
|
|
38
|
-
}
|
|
39
|
-
function buildResultSet(db, sql, args) {
|
|
40
|
-
if (isRead(sql)) {
|
|
41
|
-
const rows = db.getAllSync(sql, args);
|
|
42
|
-
return {
|
|
43
|
-
insertId: 0,
|
|
44
|
-
rowsAffected: 0,
|
|
45
|
-
rows: {
|
|
46
|
-
length: rows.length,
|
|
47
|
-
item(i) {
|
|
48
|
-
return rows[i];
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
const result = db.runSync(sql, args);
|
|
54
|
-
return {
|
|
55
|
-
insertId: result.lastInsertRowId,
|
|
56
|
-
rowsAffected: result.changes,
|
|
57
|
-
rows: {
|
|
58
|
-
length: 0,
|
|
59
|
-
item(_i) {
|
|
60
|
-
return undefined;
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
function drainQueue(db, tx) {
|
|
66
|
-
// Process until the queue is empty. Success callbacks may enqueue
|
|
67
|
-
// more statements, so we loop rather than iterate a snapshot.
|
|
68
|
-
while (tx._queue.length > 0) {
|
|
69
|
-
const stmt = tx._queue.shift();
|
|
70
|
-
try {
|
|
71
|
-
const rs = buildResultSet(db, stmt.sql, stmt.args);
|
|
72
|
-
if (stmt.successCb) {
|
|
73
|
-
stmt.successCb(tx, rs);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
catch (err) {
|
|
77
|
-
const sqlError = {
|
|
78
|
-
code: 0,
|
|
79
|
-
message: err?.message ?? String(err),
|
|
80
|
-
};
|
|
81
|
-
if (stmt.errorCb) {
|
|
82
|
-
const shouldContinue = stmt.errorCb(tx, sqlError);
|
|
83
|
-
if (shouldContinue === true) {
|
|
84
|
-
// Error handler returned true → swallow error and continue
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
// Abort the transaction
|
|
89
|
-
throw err;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
// ── WebSQLDatabase ───────────────────────────────────────────────────
|
|
94
|
-
export class WebSQLDatabase {
|
|
95
|
-
constructor(db, version) {
|
|
96
|
-
this._db = db;
|
|
97
|
-
this.version = version;
|
|
98
|
-
}
|
|
99
|
-
transaction(callback, errorCb, successCb) {
|
|
100
|
-
// WebSQL is async/callback-based. Schedule via macrotask so the
|
|
101
|
-
// caller's subsequent code runs first (matches browser behavior).
|
|
102
|
-
setTimeout(() => {
|
|
103
|
-
const tx = new WebSQLTransaction();
|
|
104
|
-
try {
|
|
105
|
-
// Let the caller enqueue statements
|
|
106
|
-
callback(tx);
|
|
107
|
-
// Execute everything inside a real SQLite transaction
|
|
108
|
-
this._db.withTransactionSync(() => {
|
|
109
|
-
drainQueue(this._db, tx);
|
|
110
|
-
});
|
|
111
|
-
if (successCb)
|
|
112
|
-
successCb();
|
|
113
|
-
}
|
|
114
|
-
catch (err) {
|
|
115
|
-
const sqlError = {
|
|
116
|
-
code: 0,
|
|
117
|
-
message: err?.message ?? String(err),
|
|
118
|
-
};
|
|
119
|
-
if (errorCb) {
|
|
120
|
-
errorCb(sqlError);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}, 0);
|
|
124
|
-
}
|
|
125
|
-
readTransaction(callback, errorCb, successCb) {
|
|
126
|
-
// Reads go through the same path — SQLite handles concurrency.
|
|
127
|
-
this.transaction(callback, errorCb, successCb);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
// ── openDatabase (WebSQL entry point) ────────────────────────────────
|
|
131
|
-
export function openDatabase(name, version, _displayName, _estimatedSize, _creationCallback) {
|
|
132
|
-
const { db: sqliteDb, created } = getSqliteDb(name);
|
|
133
|
-
const wsdb = new WebSQLDatabase(sqliteDb, version);
|
|
134
|
-
if (created && _creationCallback) {
|
|
135
|
-
_creationCallback(wsdb);
|
|
136
|
-
}
|
|
137
|
-
return wsdb;
|
|
138
|
-
}
|