@arkade-os/sdk 0.5.0-rc.1 → 0.5.0-rc.10
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 +41 -67
- package/dist/adapters/expo.cjs +5 -6
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +3 -4
- package/dist/{asyncStorageTaskQueue-DAs_n1xr.d.ts → asyncStorageTaskQueue-BNvkUO09.d.ts} +2 -2
- package/dist/{asyncStorageTaskQueue-DqGRG66E.d.cts → asyncStorageTaskQueue-CcOeZy9Y.d.cts} +2 -2
- package/dist/{chunk-6COJWPBO.js → chunk-4AO4SYFM.js} +55 -68
- package/dist/chunk-4AO4SYFM.js.map +1 -0
- package/dist/{chunk-RZ2NGS6A.cjs → chunk-7NWWFC7O.cjs} +57 -73
- package/dist/chunk-7NWWFC7O.cjs.map +1 -0
- package/dist/{chunk-LPK4UBNJ.js → chunk-7NZTSBVR.js} +4 -4
- package/dist/{chunk-LPK4UBNJ.js.map → chunk-7NZTSBVR.js.map} +1 -1
- package/dist/{chunk-YEUXBECG.cjs → chunk-AGKVSRBX.cjs} +1643 -1341
- package/dist/chunk-AGKVSRBX.cjs.map +1 -0
- package/dist/{chunk-SG4XYCS7.js → chunk-D7XQK6VK.js} +37 -12
- package/dist/chunk-D7XQK6VK.js.map +1 -0
- package/dist/{chunk-MXY23OPP.cjs → chunk-MHMFI2Q3.cjs} +10 -10
- package/dist/{chunk-MXY23OPP.cjs.map → chunk-MHMFI2Q3.cjs.map} +1 -1
- package/dist/{chunk-Q5WQ4Y2I.cjs → chunk-NCSSQITM.cjs} +70 -87
- package/dist/chunk-NCSSQITM.cjs.map +1 -0
- package/dist/{chunk-WQIWUTYS.cjs → chunk-NKJ6BSSM.cjs} +52 -27
- package/dist/chunk-NKJ6BSSM.cjs.map +1 -0
- package/dist/{chunk-ZPSUBAWQ.js → chunk-OQTQPHW3.js} +23 -40
- package/dist/chunk-OQTQPHW3.js.map +1 -0
- package/dist/{chunk-MEJSBJVH.js → chunk-P3IY7EVL.js} +22 -19
- package/dist/chunk-P3IY7EVL.js.map +1 -0
- package/dist/{chunk-VTE3NYVD.js → chunk-W7E44EAT.js} +1233 -932
- package/dist/chunk-W7E44EAT.js.map +1 -0
- package/dist/{chunk-KB7OP3FG.cjs → chunk-ZJTTNDRG.cjs} +32 -29
- package/dist/chunk-ZJTTNDRG.cjs.map +1 -0
- package/dist/contracts/handlers/index.cjs +9 -10
- package/dist/contracts/handlers/index.d.cts +3 -3
- package/dist/contracts/handlers/index.d.ts +3 -3
- package/dist/contracts/handlers/index.js +2 -3
- package/dist/{delegate-B9Bmrns7.d.ts → delegate-DzEPFKb6.d.ts} +1 -1
- package/dist/{delegate-CZzIduW4.d.cts → delegate-Nm_rbfti.d.cts} +1 -1
- package/dist/{hdWalletCapable-Cr5nGpK5.d.ts → hdWalletCapable-KFhu6_49.d.ts} +8 -34
- package/dist/{hdWalletCapable-BIl3yLVM.d.cts → hdWalletCapable-vpYZROpY.d.cts} +8 -34
- package/dist/{index-DQ1Hb2w_.d.ts → index-4xd-xYf7.d.ts} +3 -3
- package/dist/{index-Ci5MmNnK.d.cts → index-CHCtOzAa.d.cts} +3 -3
- package/dist/{index-DnNIOqHS.d.ts → index-DQYGp3A1.d.cts} +184 -224
- package/dist/{index-DnNIOqHS.d.cts → index-DQYGp3A1.d.ts} +184 -224
- package/dist/index.cjs +328 -333
- package/dist/index.d.cts +270 -243
- package/dist/index.d.ts +270 -243
- package/dist/index.js +4 -5
- package/dist/repositories/realm/index.cjs +57 -24
- package/dist/repositories/realm/index.cjs.map +1 -1
- package/dist/repositories/realm/index.d.cts +12 -4
- package/dist/repositories/realm/index.d.ts +12 -4
- package/dist/repositories/realm/index.js +43 -10
- package/dist/repositories/realm/index.js.map +1 -1
- package/dist/repositories/sqlite/index.cjs +103 -33
- package/dist/repositories/sqlite/index.cjs.map +1 -1
- package/dist/repositories/sqlite/index.d.cts +12 -2
- package/dist/repositories/sqlite/index.d.ts +12 -2
- package/dist/repositories/sqlite/index.js +90 -20
- package/dist/repositories/sqlite/index.js.map +1 -1
- package/dist/{taskRunner-BDb5Ee2J.d.cts → taskRunner-DGTvO-ne.d.cts} +2 -2
- package/dist/{taskRunner-F7wNJcF3.d.ts → taskRunner-DxG06PKN.d.ts} +2 -2
- package/dist/wallet/expo/background.cjs +14 -15
- package/dist/wallet/expo/background.cjs.map +1 -1
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +6 -7
- package/dist/wallet/expo/background.js.map +1 -1
- package/dist/wallet/expo/index.cjs +15 -23
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +4 -7
- package/dist/wallet/expo/index.d.ts +4 -7
- package/dist/wallet/expo/index.js +7 -15
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/worker/expo/index.cjs +9 -10
- package/dist/worker/expo/index.cjs.map +1 -1
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +5 -6
- package/dist/worker/expo/index.js.map +1 -1
- package/package.json +4 -42
- package/dist/adapters/asyncStorage.cjs +0 -48
- package/dist/adapters/asyncStorage.cjs.map +0 -1
- package/dist/adapters/asyncStorage.d.cts +0 -16
- package/dist/adapters/asyncStorage.d.ts +0 -16
- package/dist/adapters/asyncStorage.js +0 -46
- package/dist/adapters/asyncStorage.js.map +0 -1
- package/dist/adapters/fileSystem.cjs +0 -116
- package/dist/adapters/fileSystem.cjs.map +0 -1
- package/dist/adapters/fileSystem.d.cts +0 -17
- package/dist/adapters/fileSystem.d.ts +0 -17
- package/dist/adapters/fileSystem.js +0 -93
- package/dist/adapters/fileSystem.js.map +0 -1
- package/dist/adapters/indexedDB.cjs +0 -103
- package/dist/adapters/indexedDB.cjs.map +0 -1
- package/dist/adapters/indexedDB.d.cts +0 -18
- package/dist/adapters/indexedDB.d.ts +0 -18
- package/dist/adapters/indexedDB.js +0 -101
- package/dist/adapters/indexedDB.js.map +0 -1
- package/dist/adapters/localStorage.cjs +0 -50
- package/dist/adapters/localStorage.cjs.map +0 -1
- package/dist/adapters/localStorage.d.cts +0 -14
- package/dist/adapters/localStorage.d.ts +0 -14
- package/dist/adapters/localStorage.js +0 -48
- package/dist/adapters/localStorage.js.map +0 -1
- package/dist/chunk-5BLDMQED.cjs +0 -18
- package/dist/chunk-5BLDMQED.cjs.map +0 -1
- package/dist/chunk-6COJWPBO.js.map +0 -1
- package/dist/chunk-KB7OP3FG.cjs.map +0 -1
- package/dist/chunk-MEJSBJVH.js.map +0 -1
- package/dist/chunk-NSBPE2FW.js +0 -15
- package/dist/chunk-NSBPE2FW.js.map +0 -1
- package/dist/chunk-Q5WQ4Y2I.cjs.map +0 -1
- package/dist/chunk-RZ2NGS6A.cjs.map +0 -1
- package/dist/chunk-SG4XYCS7.js.map +0 -1
- package/dist/chunk-VTE3NYVD.js.map +0 -1
- package/dist/chunk-WQIWUTYS.cjs.map +0 -1
- package/dist/chunk-YEUXBECG.cjs.map +0 -1
- package/dist/chunk-ZPSUBAWQ.js.map +0 -1
- package/dist/index-C0IanN1m.d.cts +0 -11
- package/dist/index-C0IanN1m.d.ts +0 -11
package/README.md
CHANGED
|
@@ -591,7 +591,6 @@ Access the `VtxoManager` from the wallet after configuring `settlementConfig`:
|
|
|
591
591
|
const manager = await wallet.getVtxoManager()
|
|
592
592
|
```
|
|
593
593
|
|
|
594
|
-
> **Migration from `renewalConfig`:** Directly initializing a `VtxoManager` with `renewalConfig` is still supported but deprecated. Prefer `settlementConfig` where `vtxoThreshold` is expressed in **seconds** instead of milliseconds.
|
|
595
594
|
|
|
596
595
|
#### Renewal: Prevent Expiration
|
|
597
596
|
|
|
@@ -1109,72 +1108,17 @@ examples.
|
|
|
1109
1108
|
|
|
1110
1109
|
### Repositories (Storage)
|
|
1111
1110
|
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
#### Migration from v1 StorageAdapter
|
|
1115
|
-
|
|
1116
|
-
> [!WARNING]
|
|
1117
|
-
> If you previously used the v1 `StorageAdapter`-based repositories, migrate
|
|
1118
|
-
> data into the new IndexedDB repositories before use:
|
|
1119
|
-
>
|
|
1120
|
-
> ```typescript
|
|
1121
|
-
> import {
|
|
1122
|
-
> IndexedDBWalletRepository,
|
|
1123
|
-
> IndexedDBContractRepository,
|
|
1124
|
-
> getMigrationStatus,
|
|
1125
|
-
> migrateWalletRepository,
|
|
1126
|
-
> rollbackMigration,
|
|
1127
|
-
> } from '@arkade-os/sdk'
|
|
1128
|
-
> import { IndexedDBStorageAdapter } from '@arkade-os/sdk/adapters/indexedDB'
|
|
1129
|
-
>
|
|
1130
|
-
> const oldStorage = new IndexedDBStorageAdapter('legacy-wallet', 1)
|
|
1131
|
-
> const newDbName = 'my-app-db'
|
|
1132
|
-
> const walletRepository = new IndexedDBWalletRepository(newDbName)
|
|
1133
|
-
>
|
|
1134
|
-
> // Check migration status before running
|
|
1135
|
-
> const status = await getMigrationStatus('wallet', oldStorage)
|
|
1136
|
-
> // status: "not-needed" | "pending" | "in-progress" | "done"
|
|
1137
|
-
>
|
|
1138
|
-
> if (status === 'pending' || status === 'in-progress') {
|
|
1139
|
-
> try {
|
|
1140
|
-
> await migrateWalletRepository(oldStorage, walletRepository, {
|
|
1141
|
-
> onchain: [ 'address-1', 'address-2' ],
|
|
1142
|
-
> offchain: [ 'onboarding-address-1' ],
|
|
1143
|
-
> })
|
|
1144
|
-
> } catch (err) {
|
|
1145
|
-
> // Reset migration flag so the next attempt starts clean
|
|
1146
|
-
> await rollbackMigration('wallet', oldStorage)
|
|
1147
|
-
> throw err
|
|
1148
|
-
> }
|
|
1149
|
-
> }
|
|
1150
|
-
> ```
|
|
1151
|
-
>
|
|
1152
|
-
> **Migration status helpers:**
|
|
1153
|
-
>
|
|
1154
|
-
> | Helper | Description |
|
|
1155
|
-
> |--------|-------------|
|
|
1156
|
-
> | `getMigrationStatus(repoType, adapter)` | Returns `"not-needed"` (no legacy DB), `"pending"`, `"in-progress"` (interrupted), or `"done"` |
|
|
1157
|
-
> | `requiresMigration(repoType, adapter)` | Returns `true` if status is `"pending"` or `"in-progress"` |
|
|
1158
|
-
> | `rollbackMigration(repoType, adapter)` | Removes the migration flag so migration can re-run from scratch |
|
|
1159
|
-
> | `MIGRATION_KEY(repoType)` | Returns the storage key used for the migration flag |
|
|
1160
|
-
>
|
|
1161
|
-
> `migrateWalletRepository` sets an `"in-progress"` flag before copying data.
|
|
1162
|
-
> If the process crashes mid-way, the flag remains as `"in-progress"` so the
|
|
1163
|
-
> next call to `getMigrationStatus` can detect the partial migration. Old data
|
|
1164
|
-
> is never deleted — re-running migration after a rollback is safe.
|
|
1165
|
-
>
|
|
1166
|
-
> Anything related to contract repository migration must be handled by the
|
|
1167
|
-
> package that created the contracts. The SDK doesn't manage external contracts
|
|
1168
|
-
> in V1; data persisted by other packages remains untouched in its original
|
|
1169
|
-
> location.
|
|
1111
|
+
Use repository implementations via `StorageConfig`. If you omit `storage`, the
|
|
1112
|
+
SDK uses IndexedDB repositories with the default database name.
|
|
1170
1113
|
|
|
1171
1114
|
#### Repository Versioning
|
|
1172
1115
|
|
|
1173
|
-
`WalletRepository`, `ContractRepository`,
|
|
1174
|
-
`@arkade-os/swap`) each
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1116
|
+
`WalletRepository`, `ContractRepository`, `IntentRepository`,
|
|
1117
|
+
`VirtualTxRepository`, and `AssetSwapRepository` (in `@arkade-os/swap`) each
|
|
1118
|
+
declare a `readonly version` field with a literal type. All built-in
|
|
1119
|
+
implementations set this to the current version. If you maintain a custom
|
|
1120
|
+
repository implementation, TypeScript will produce a compile error when the
|
|
1121
|
+
version is bumped, signaling that a semantic update is required:
|
|
1178
1122
|
|
|
1179
1123
|
```typescript
|
|
1180
1124
|
import { WalletRepository } from '@arkade-os/sdk'
|
|
@@ -1283,6 +1227,7 @@ const wallet = await Wallet.create({
|
|
|
1283
1227
|
})
|
|
1284
1228
|
```
|
|
1285
1229
|
|
|
1230
|
+
### Using with Node.js
|
|
1286
1231
|
### Using with Node.js
|
|
1287
1232
|
|
|
1288
1233
|
Node.js does not provide a global `EventSource` implementation (24.x has one behind `--experimental-eventsource`). The SDK relies on `EventSource` for Server-Sent Events during settlement (onboarding/offboarding) and contract watching, so tell it which one to use:
|
|
@@ -1406,7 +1351,7 @@ When you call `wallet.notifyIncomingFunds()` or use `waitForIncomingFunds()`, it
|
|
|
1406
1351
|
|
|
1407
1352
|
HD wallets (`walletMode: 'hd'`, or an explicit HD `DescriptorProvider`) also watch a band of *unused* offchain receive scripts around their allocation watermark, so a payment to an address that some other party issued from the same seed — a merchant backend such as BTCPay Server, or the .NET SDK driving the same wallet — arrives without the user calling `restore()`. `lookAheadWindow` (default `20`) is the per-side width of that band: the wallet watches `[watermark - N, watermark + N]`. Speculative entries are subscription-only; they become contract rows, and enter balances, only once funded.
|
|
1408
1353
|
|
|
1409
|
-
The issuer, not the wallet, picks the contract shape, so each index is watched at *every* variant the wallet could own there: `default` and `delegate`, crossed with the unilateral-exit timelock matrix and the operator's
|
|
1354
|
+
The issuer, not the wallet, picks the contract shape, so each index is watched at *every* variant the wallet could own there: `default` and `delegate`, crossed with the unilateral-exit timelock matrix and the operator's active plus retired signers. That is the candidate set `restore()` probes too, so watching and restoring cover identical scripts.
|
|
1410
1355
|
|
|
1411
1356
|
```typescript
|
|
1412
1357
|
const wallet = await Wallet.create({
|
|
@@ -1426,6 +1371,35 @@ const swWallet = await ServiceWorkerWallet.setup({
|
|
|
1426
1371
|
|
|
1427
1372
|
Raise it when the external issuer is expected to burn more than `N` consecutive addresses without any of them being paid — every index in such a run is a miss, and the funded one sits past the band. When that happens the funds are invisible until a `restore()` whose `gapLimit` is large enough to cross the run (`wallet.restore({ gapLimit: 200 })`); a default restore closes its gap window before reaching the funded index. Keep the value modest: the band adds up to `2N + 1` indices × the candidate matrix (typically 1-4 scripts each) to the wallet's subscription.
|
|
1428
1373
|
|
|
1374
|
+
#### Restoring plugin state
|
|
1375
|
+
|
|
1376
|
+
`wallet.restore()` is the explicit imported-wallet recovery boundary. It first restores the
|
|
1377
|
+
wallet's own addresses, contracts, history, and balances, then runs every restore hook registered
|
|
1378
|
+
for that wallet instance. `Wallet` and `ServiceWorkerWallet` both follow this ordering, and
|
|
1379
|
+
concurrent calls coalesce until the hooks finish.
|
|
1380
|
+
|
|
1381
|
+
```typescript
|
|
1382
|
+
import { registerWalletRestoreHook } from '@arkade-os/sdk'
|
|
1383
|
+
|
|
1384
|
+
const unregister = registerWalletRestoreHook(wallet, {
|
|
1385
|
+
id: 'my-plugin',
|
|
1386
|
+
restore: async (restoredWallet) => {
|
|
1387
|
+
await rebuildPluginState(await restoredWallet.getTransactionHistory())
|
|
1388
|
+
},
|
|
1389
|
+
})
|
|
1390
|
+
|
|
1391
|
+
await wallet.restore()
|
|
1392
|
+
```
|
|
1393
|
+
|
|
1394
|
+
Registering the same `id` again replaces that hook without changing its position. A run uses a
|
|
1395
|
+
stable snapshot, attempts every hook in registration order, and throws an `AggregateError` after
|
|
1396
|
+
all failures have been collected. If core recovery fails, hooks do not run. The returned function
|
|
1397
|
+
removes only that exact registration and is safe to call more than once.
|
|
1398
|
+
|
|
1399
|
+
Hooks do not run during `Wallet.create()`, `ServiceWorkerWallet.setup()`, or ordinary startup. A
|
|
1400
|
+
plugin should register before an application calls `restore()` and keep its normal incremental
|
|
1401
|
+
reconciliation for state that arrives later.
|
|
1402
|
+
|
|
1429
1403
|
For advanced use cases, you can access the ContractManager directly to register external contracts:
|
|
1430
1404
|
|
|
1431
1405
|
```typescript
|
|
@@ -1471,7 +1445,7 @@ const paths = manager.getSpendablePaths({
|
|
|
1471
1445
|
contractScript: contract.script,
|
|
1472
1446
|
vtxo,
|
|
1473
1447
|
collaborative: true,
|
|
1474
|
-
|
|
1448
|
+
walletDescriptor: myDescriptor,
|
|
1475
1449
|
})
|
|
1476
1450
|
if (paths.length > 0) {
|
|
1477
1451
|
console.log('Contract is spendable via:', paths[0].leaf)
|
|
@@ -1481,7 +1455,7 @@ if (paths.length > 0) {
|
|
|
1481
1455
|
const allPaths = await manager.getAllSpendingPaths({
|
|
1482
1456
|
contractScript: contract.script,
|
|
1483
1457
|
collaborative: true,
|
|
1484
|
-
|
|
1458
|
+
walletDescriptor: myDescriptor,
|
|
1485
1459
|
})
|
|
1486
1460
|
|
|
1487
1461
|
// Fetch contracts together with their current virtual outputs
|
package/dist/adapters/expo.cjs
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
5
|
-
require('../chunk-
|
|
6
|
-
require('../chunk-5BLDMQED.cjs');
|
|
3
|
+
var chunkZJTTNDRG_cjs = require('../chunk-ZJTTNDRG.cjs');
|
|
4
|
+
require('../chunk-NKJ6BSSM.cjs');
|
|
5
|
+
require('../chunk-7NWWFC7O.cjs');
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
Object.defineProperty(exports, "ExpoArkProvider", {
|
|
11
10
|
enumerable: true,
|
|
12
|
-
get: function () { return
|
|
11
|
+
get: function () { return chunkZJTTNDRG_cjs.ExpoArkProvider; }
|
|
13
12
|
});
|
|
14
13
|
Object.defineProperty(exports, "ExpoIndexerProvider", {
|
|
15
14
|
enumerable: true,
|
|
16
|
-
get: function () { return
|
|
15
|
+
get: function () { return chunkZJTTNDRG_cjs.ExpoIndexerProvider; }
|
|
17
16
|
});
|
|
18
17
|
//# sourceMappingURL=expo.cjs.map
|
|
19
18
|
//# sourceMappingURL=expo.cjs.map
|
package/dist/adapters/expo.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { q as RestArkProvider, n as SettlementEvent, T as TxNotificationEvent, r as RestIndexerProvider, s as SubscriptionResponse } from '../index-DQYGp3A1.cjs';
|
|
2
|
+
export { t as ArkProvider, u as IndexerProvider } from '../index-DQYGp3A1.cjs';
|
|
3
3
|
import '@scure/btc-signer/utils.js';
|
|
4
4
|
import '@scure/btc-signer/transaction.js';
|
|
5
5
|
import '@scure/btc-signer';
|
package/dist/adapters/expo.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { q as RestArkProvider, n as SettlementEvent, T as TxNotificationEvent, r as RestIndexerProvider, s as SubscriptionResponse } from '../index-DQYGp3A1.js';
|
|
2
|
+
export { t as ArkProvider, u as IndexerProvider } from '../index-DQYGp3A1.js';
|
|
3
3
|
import '@scure/btc-signer/utils.js';
|
|
4
4
|
import '@scure/btc-signer/transaction.js';
|
|
5
5
|
import '@scure/btc-signer';
|
package/dist/adapters/expo.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { ExpoArkProvider, ExpoIndexerProvider } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-NSBPE2FW.js';
|
|
1
|
+
export { ExpoArkProvider, ExpoIndexerProvider } from '../chunk-P3IY7EVL.js';
|
|
2
|
+
import '../chunk-D7XQK6VK.js';
|
|
3
|
+
import '../chunk-4AO4SYFM.js';
|
|
5
4
|
//# sourceMappingURL=expo.js.map
|
|
6
5
|
//# sourceMappingURL=expo.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as TaskQueue, c as TaskItem, d as TaskResult } from './taskRunner-DxG06PKN.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Minimal async key-value storage interface.
|
|
@@ -46,4 +46,4 @@ declare class AsyncStorageTaskQueue implements TaskQueue {
|
|
|
46
46
|
private writeList;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export {
|
|
49
|
+
export { AsyncStorageTaskQueue as A, type AsyncStorageLike as a };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as TaskQueue, c as TaskItem, d as TaskResult } from './taskRunner-DGTvO-ne.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Minimal async key-value storage interface.
|
|
@@ -46,4 +46,4 @@ declare class AsyncStorageTaskQueue implements TaskQueue {
|
|
|
46
46
|
private writeList;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export {
|
|
49
|
+
export { AsyncStorageTaskQueue as A, type AsyncStorageLike as a };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ScriptNum, OP, p2tr_ms, Script,
|
|
1
|
+
import { ScriptNum, OP, p2tr_ms, Script, SigHash, p2tr, TAPROOT_UNSPENDABLE_KEY, Address, RawWitness, Transaction as Transaction$1 } from '@scure/btc-signer';
|
|
2
2
|
import * as bip68 from 'bip68';
|
|
3
3
|
import { TEST_NETWORK, NETWORK } from '@scure/btc-signer/utils.js';
|
|
4
4
|
import { hex, bech32m } from '@scure/base';
|
|
@@ -7,7 +7,11 @@ import { TAP_LEAF_VERSION } from '@scure/btc-signer/payment.js';
|
|
|
7
7
|
import { PSBTOutput } from '@scure/btc-signer/psbt.js';
|
|
8
8
|
import { schnorr } from '@noble/curves/secp256k1.js';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
11
15
|
var Transaction = class extends Transaction$1 {
|
|
12
16
|
static ARK_TX_OPTS = {
|
|
13
17
|
allowUnknown: true,
|
|
@@ -1023,11 +1027,15 @@ function resolveEventSource(override) {
|
|
|
1023
1027
|
}
|
|
1024
1028
|
|
|
1025
1029
|
// package.json
|
|
1026
|
-
var version = "0.5.0-rc.
|
|
1030
|
+
var version = "0.5.0-rc.10";
|
|
1027
1031
|
|
|
1028
1032
|
// src/utils/fetch.ts
|
|
1029
1033
|
var buildVersion = "0.9.9";
|
|
1030
1034
|
var sdkVersion = `ts-sdk/${version}`;
|
|
1035
|
+
var ARKADE_VERSION_HEADERS = {
|
|
1036
|
+
"X-Build-Version": buildVersion,
|
|
1037
|
+
"X-SDK-VERSION": sdkVersion
|
|
1038
|
+
};
|
|
1031
1039
|
var FetchError = class extends Error {
|
|
1032
1040
|
/** The request URL that failed, when derivable from the `fetch` input. */
|
|
1033
1041
|
url;
|
|
@@ -1040,11 +1048,36 @@ var FetchError = class extends Error {
|
|
|
1040
1048
|
this.method = options.method;
|
|
1041
1049
|
}
|
|
1042
1050
|
};
|
|
1051
|
+
var READ_TIMEOUT_MS = 3e4;
|
|
1052
|
+
var warnedNoTimeoutSupport = false;
|
|
1053
|
+
function readDeadline(input, init) {
|
|
1054
|
+
if (init?.signal || input instanceof Request) return void 0;
|
|
1055
|
+
const { method } = describeRequest(input, init);
|
|
1056
|
+
const verb = method.toUpperCase();
|
|
1057
|
+
if (verb !== "GET" && verb !== "HEAD") return void 0;
|
|
1058
|
+
if (typeof AbortSignal !== "undefined" && typeof AbortSignal.timeout === "function") {
|
|
1059
|
+
return AbortSignal.timeout(READ_TIMEOUT_MS);
|
|
1060
|
+
}
|
|
1061
|
+
if (typeof AbortController === "function") {
|
|
1062
|
+
const controller = new AbortController();
|
|
1063
|
+
const timer = setTimeout(() => controller.abort(), READ_TIMEOUT_MS);
|
|
1064
|
+
timer?.unref?.();
|
|
1065
|
+
return controller.signal;
|
|
1066
|
+
}
|
|
1067
|
+
if (!warnedNoTimeoutSupport) {
|
|
1068
|
+
warnedNoTimeoutSupport = true;
|
|
1069
|
+
console.warn(
|
|
1070
|
+
"Neither AbortSignal.timeout nor AbortController is available in this runtime: provider reads are UNBOUNDED and READ_TIMEOUT_MS is not being applied."
|
|
1071
|
+
);
|
|
1072
|
+
}
|
|
1073
|
+
return void 0;
|
|
1074
|
+
}
|
|
1043
1075
|
function baseFetch(input, init) {
|
|
1044
1076
|
if (typeof globalThis.fetch !== "function") {
|
|
1045
1077
|
throw new Error("Fetch API is not available in this environment.");
|
|
1046
1078
|
}
|
|
1047
|
-
|
|
1079
|
+
const signal = readDeadline(input, init);
|
|
1080
|
+
return globalThis.fetch(input, signal ? { ...init, signal } : init).catch((cause) => {
|
|
1048
1081
|
const { url, method } = describeRequest(input, init);
|
|
1049
1082
|
throw new FetchError(`Network request failed: ${method} ${url}`, { url, method, cause });
|
|
1050
1083
|
});
|
|
@@ -2267,60 +2300,23 @@ function parseWireExpiry(raw) {
|
|
|
2267
2300
|
if (ms >= EXPIRY_MIN_PLAUSIBLE_MS) return { expiresAt: new Date(ms) };
|
|
2268
2301
|
return { expiresAtHeight: n };
|
|
2269
2302
|
}
|
|
2270
|
-
function toBatchExpiry(c) {
|
|
2271
|
-
if (c.expiresAt !== void 0) return c.expiresAt.getTime();
|
|
2272
|
-
if (c.expiresAtHeight !== void 0) return c.expiresAtHeight * 1e3;
|
|
2273
|
-
return void 0;
|
|
2274
|
-
}
|
|
2275
|
-
function parseLegacyExpiry(batchExpiry) {
|
|
2276
|
-
if (batchExpiry === void 0 || batchExpiry <= 0) return {};
|
|
2277
|
-
if (batchExpiry >= EXPIRY_MIN_PLAUSIBLE_MS) return { expiresAt: new Date(batchExpiry) };
|
|
2278
|
-
return { expiresAtHeight: batchExpiry / 1e3 };
|
|
2279
|
-
}
|
|
2280
|
-
function toVirtualStatus(c) {
|
|
2281
|
-
return {
|
|
2282
|
-
// Precedence is load-bearing: consumers bucket on this label, so any other order silently
|
|
2283
|
-
// moves VTXOs between buckets.
|
|
2284
|
-
state: c.isSpent ? "spent" : c.isSwept ? "swept" : c.isPreconfirmed ? "preconfirmed" : "settled",
|
|
2285
|
-
commitmentTxIds: c.commitmentTxIds,
|
|
2286
|
-
batchExpiry: toBatchExpiry(c)
|
|
2287
|
-
};
|
|
2288
|
-
}
|
|
2289
2303
|
function normalizeVtxo(v) {
|
|
2290
|
-
const
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
// as `Date` but returns NaN from `.getTime()` — comparing false against everything.
|
|
2295
|
-
{
|
|
2296
|
-
expiresAt: v.expiresAt === void 0 ? void 0 : new Date(v.expiresAt),
|
|
2297
|
-
expiresAtHeight: v.expiresAtHeight
|
|
2298
|
-
}
|
|
2299
|
-
) : parseLegacyExpiry(v.virtualStatus?.batchExpiry);
|
|
2300
|
-
const isSpent = v.isSpent ?? state === "spent";
|
|
2301
|
-
const isSwept = v.isSwept ?? state === "swept";
|
|
2302
|
-
const isPreconfirmed = v.isPreconfirmed ?? state === "preconfirmed";
|
|
2303
|
-
const commitmentTxIds = v.commitmentTxIds ?? v.virtualStatus?.commitmentTxIds ?? [];
|
|
2304
|
+
const expiry = {
|
|
2305
|
+
expiresAt: v.expiresAt === void 0 ? void 0 : new Date(v.expiresAt),
|
|
2306
|
+
expiresAtHeight: v.expiresAtHeight
|
|
2307
|
+
};
|
|
2304
2308
|
return {
|
|
2305
2309
|
...v,
|
|
2306
|
-
isSpent,
|
|
2307
|
-
isSwept,
|
|
2308
|
-
isPreconfirmed,
|
|
2310
|
+
isSpent: v.isSpent ?? false,
|
|
2311
|
+
isSwept: v.isSwept ?? false,
|
|
2312
|
+
isPreconfirmed: v.isPreconfirmed ?? false,
|
|
2309
2313
|
spentBy: v.spentBy ?? "",
|
|
2310
|
-
commitmentTxIds,
|
|
2311
|
-
...expiry
|
|
2312
|
-
virtualStatus: v.virtualStatus ?? toVirtualStatus({ isSpent, isSwept, isPreconfirmed, commitmentTxIds, ...expiry })
|
|
2314
|
+
commitmentTxIds: v.commitmentTxIds ?? [],
|
|
2315
|
+
...expiry
|
|
2313
2316
|
};
|
|
2314
2317
|
}
|
|
2315
2318
|
function convertVtxo(vtxo) {
|
|
2316
2319
|
const expiry = parseWireExpiry(vtxo.expiresAt);
|
|
2317
|
-
const facts = {
|
|
2318
|
-
isSpent: vtxo.isSpent,
|
|
2319
|
-
isSwept: vtxo.isSwept,
|
|
2320
|
-
isPreconfirmed: vtxo.isPreconfirmed,
|
|
2321
|
-
commitmentTxIds: vtxo.commitmentTxids,
|
|
2322
|
-
...expiry
|
|
2323
|
-
};
|
|
2324
2320
|
return {
|
|
2325
2321
|
txid: vtxo.outpoint.txid,
|
|
2326
2322
|
vout: vtxo.outpoint.vout,
|
|
@@ -2329,8 +2325,11 @@ function convertVtxo(vtxo) {
|
|
|
2329
2325
|
confirmed: !vtxo.isSwept && !vtxo.isPreconfirmed,
|
|
2330
2326
|
isLeaf: !vtxo.isPreconfirmed
|
|
2331
2327
|
},
|
|
2332
|
-
|
|
2333
|
-
|
|
2328
|
+
isSpent: vtxo.isSpent,
|
|
2329
|
+
isSwept: vtxo.isSwept,
|
|
2330
|
+
isPreconfirmed: vtxo.isPreconfirmed,
|
|
2331
|
+
commitmentTxIds: vtxo.commitmentTxids,
|
|
2332
|
+
...expiry,
|
|
2334
2333
|
spentBy: vtxo.spentBy ?? "",
|
|
2335
2334
|
settledBy: vtxo.settledBy,
|
|
2336
2335
|
arkTxId: vtxo.arkTxid,
|
|
@@ -2410,30 +2409,18 @@ function canSweepOnchain(vtxo) {
|
|
|
2410
2409
|
return !hasTerminalSpend(n) && !!n.isUnrolled;
|
|
2411
2410
|
}
|
|
2412
2411
|
function toOffchainInputFeeParams(vtxo) {
|
|
2413
|
-
const batchExpiry = toBatchExpiry(vtxo);
|
|
2414
2412
|
return {
|
|
2415
2413
|
amount: BigInt(vtxo.value),
|
|
2416
2414
|
type: vtxo.isSwept ? "recoverable" : "vtxo",
|
|
2417
2415
|
weight: 0,
|
|
2418
2416
|
birth: vtxo.createdAt,
|
|
2419
|
-
expiry:
|
|
2417
|
+
expiry: vtxo.expiresAt
|
|
2420
2418
|
};
|
|
2421
2419
|
}
|
|
2422
2420
|
function isVirtualCoin(input) {
|
|
2423
2421
|
return typeof input === "object" && input !== null && typeof input.script === "string";
|
|
2424
2422
|
}
|
|
2425
|
-
function isSpendable(vtxo) {
|
|
2426
|
-
return !hasTerminalSpend(vtxo);
|
|
2427
|
-
}
|
|
2428
|
-
function isRecoverable(vtxo) {
|
|
2429
|
-
const n = normalizeVtxo(vtxo);
|
|
2430
|
-
return n.isSwept && !hasTerminalSpend(n);
|
|
2431
|
-
}
|
|
2432
|
-
function isExpired(vtxo) {
|
|
2433
|
-
const n = normalizeVtxo(vtxo);
|
|
2434
|
-
return n.isSwept || n.expiresAt !== void 0 && n.expiresAt.getTime() <= Date.now();
|
|
2435
|
-
}
|
|
2436
2423
|
|
|
2437
|
-
export { ArkAddress, ArkError, ArkErrorName, ArkPsbtFieldKey, ArkPsbtFieldKeyType, BITCOIN_EMULATOR_PUBKEY, CLTVMultisigTapscript, CSVMultisigTapscript, ConditionCSVMultisigTapscript, ConditionMultisigTapscript, ConditionWitness, CosignerPublicKey, DEFAULT_ARKADE_SERVER_URL, DEFAULT_NETWORK, DEFAULT_NETWORK_NAME, DEFAULT_PAGE_SIZE, DigestMismatchError, EventSourceUnavailableError, FetchError, INFO_FETCH_TIMEOUT_MS, Intent, MUTINYNET_EMULATOR_PUBKEY, MultisigTapscript, OP_RETURN_EMPTY_PKSCRIPT, PrevArkTxField, PrevoutTxField, ProviderUnavailableError, REGTEST_EMULATOR_PUBKEY, RestArkProvider, SCRIPT_QUERY_CHUNK_SIZE, ServerResponseMismatchError, SettlementEventType, TapTreeCoder, Transaction, VtxoScript, VtxoTaprootTree, VtxoTreeExpiry, assembleBtcdTaprootTree, assertAllowedSighashTypes, baseFetch, buildVersion, canRecoverOnchain, canSpendOffchain, canSweepOnchain, configureEventSource, convertVtxo, craftToSpendTx, decodeTapscript, defaultEmulatorPubkey, eventSourceIterator,
|
|
2438
|
-
//# sourceMappingURL=chunk-
|
|
2439
|
-
//# sourceMappingURL=chunk-
|
|
2424
|
+
export { ARKADE_VERSION_HEADERS, ArkAddress, ArkError, ArkErrorName, ArkPsbtFieldKey, ArkPsbtFieldKeyType, BITCOIN_EMULATOR_PUBKEY, CLTVMultisigTapscript, CSVMultisigTapscript, ConditionCSVMultisigTapscript, ConditionMultisigTapscript, ConditionWitness, CosignerPublicKey, DEFAULT_ARKADE_SERVER_URL, DEFAULT_NETWORK, DEFAULT_NETWORK_NAME, DEFAULT_PAGE_SIZE, DigestMismatchError, EXPIRY_MIN_PLAUSIBLE_MS, EventSourceUnavailableError, FetchError, INFO_FETCH_TIMEOUT_MS, Intent, MUTINYNET_EMULATOR_PUBKEY, MultisigTapscript, OP_RETURN_EMPTY_PKSCRIPT, PrevArkTxField, PrevoutTxField, ProviderUnavailableError, READ_TIMEOUT_MS, REGTEST_EMULATOR_PUBKEY, RestArkProvider, SCRIPT_QUERY_CHUNK_SIZE, ServerResponseMismatchError, SettlementEventType, TapTreeCoder, Transaction, VtxoScript, VtxoTaprootTree, VtxoTreeExpiry, __export, assembleBtcdTaprootTree, assertAllowedSighashTypes, baseFetch, buildVersion, canRecoverOnchain, canSpendOffchain, canSweepOnchain, configureEventSource, convertVtxo, craftToSpendTx, decodeTapscript, defaultEmulatorPubkey, eventSourceIterator, fetchVtxoCreatedAtByTxid, formatSighash, getAllNormalizedVtxos, getArkPsbtFields, getConfiguredEventSource, getNetwork, getNormalizedVtxos, getSequence, hasTerminalSpend, isArkError, isEventSourceError, isEventSourceUnavailableError, isFetchTimeoutError, isPastExpiry, isRetryableProviderError, isVirtualCoin, maybeArkError, networkFromArkadeInfo, networks, normalizeVtxo, rateGate, resolveEmulatorPubkey, resolveEventSource, resolveTimeHeight, scriptFromTapLeafScript, sdkVersion, sequenceToTimelock, setArkPsbtField, throwIfHttpUnavailable, timelockToSequence, toOffchainInputFeeParams, toProviderUnavailable };
|
|
2425
|
+
//# sourceMappingURL=chunk-4AO4SYFM.js.map
|
|
2426
|
+
//# sourceMappingURL=chunk-4AO4SYFM.js.map
|