@arkade-os/sdk 0.5.7 → 0.5.9
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 +24 -6
- package/dist/adapters/expo.cjs +7 -7
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +4 -4
- package/dist/{asyncStorageTaskQueue-B9byr6ij.d.cts → asyncStorageTaskQueue-B6rFkXzW.d.cts} +1 -1
- package/dist/{asyncStorageTaskQueue-XP4CCdRY.d.ts → asyncStorageTaskQueue-C0irgPwJ.d.ts} +1 -1
- package/dist/{chunk-MWEDDWFU.js → chunk-2657D67V.js} +9 -7
- package/dist/chunk-2657D67V.js.map +1 -0
- package/dist/{chunk-MWMO2ZQP.js → chunk-3KNSMZWD.js} +24 -13
- package/dist/chunk-3KNSMZWD.js.map +1 -0
- package/dist/{chunk-DNFTHG73.js → chunk-4DUTRRXF.js} +8 -6
- package/dist/chunk-4DUTRRXF.js.map +1 -0
- package/dist/{chunk-MQUATTIM.cjs → chunk-4PSM6ZUC.cjs} +55 -57
- package/dist/chunk-4PSM6ZUC.cjs.map +1 -0
- package/dist/{chunk-FDJ734CH.js → chunk-DPFD5KBK.js} +5 -2
- package/dist/chunk-DPFD5KBK.js.map +1 -0
- package/dist/{chunk-OMPDPBT5.cjs → chunk-DY24A73N.cjs} +296 -240
- package/dist/chunk-DY24A73N.cjs.map +1 -0
- package/dist/{chunk-VMVFRTF4.js → chunk-FUCKDTH7.js} +285 -234
- package/dist/chunk-FUCKDTH7.js.map +1 -0
- package/dist/{chunk-4AJRIM44.js → chunk-GUK33TNC.js} +9 -13
- package/dist/chunk-GUK33TNC.js.map +1 -0
- package/dist/{chunk-RLD7DRSZ.js → chunk-HT35HPXR.js} +19365 -18395
- package/dist/chunk-HT35HPXR.js.map +1 -0
- package/dist/{chunk-3NALVGMJ.cjs → chunk-ODLSVJRU.cjs} +38 -27
- package/dist/chunk-ODLSVJRU.cjs.map +1 -0
- package/dist/{chunk-X6ZI53DZ.cjs → chunk-OMZZQTDM.cjs} +28 -35
- package/dist/chunk-OMZZQTDM.cjs.map +1 -0
- package/dist/{chunk-V3ZLL5VY.js → chunk-PXEFYEKL.js} +22 -29
- package/dist/chunk-PXEFYEKL.js.map +1 -0
- package/dist/{chunk-JFJNB7ZH.cjs → chunk-UPIQZRNJ.cjs} +16 -14
- package/dist/chunk-UPIQZRNJ.cjs.map +1 -0
- package/dist/{chunk-V5WRO3P6.cjs → chunk-UPV4W423.cjs} +14 -18
- package/dist/chunk-UPV4W423.cjs.map +1 -0
- package/dist/{chunk-URGVQ5TQ.cjs → chunk-V2EU5QWF.cjs} +4583 -3610
- package/dist/chunk-V2EU5QWF.cjs.map +1 -0
- package/dist/{chunk-FLPWNMX3.cjs → chunk-WIZCF5IX.cjs} +5 -2
- package/dist/chunk-WIZCF5IX.cjs.map +1 -0
- package/dist/{chunk-MXCB6EVM.cjs → chunk-WZJJZGBT.cjs} +22 -20
- package/dist/chunk-WZJJZGBT.cjs.map +1 -0
- package/dist/{chunk-V2DDN4MV.js → chunk-Z6WDOZZI.js} +10 -12
- package/dist/chunk-Z6WDOZZI.js.map +1 -0
- package/dist/compiler.cjs +4 -4
- package/dist/compiler.d.cts +1 -1
- package/dist/compiler.d.ts +1 -1
- package/dist/compiler.js +3 -3
- package/dist/contracts/handlers/index.cjs +11 -11
- package/dist/contracts/handlers/index.d.cts +3 -4
- package/dist/contracts/handlers/index.d.ts +3 -4
- package/dist/contracts/handlers/index.js +4 -4
- package/dist/{index-18cDMayF.d.ts → index-Bq349_ly.d.cts} +2334 -101
- package/dist/{index-Ccfhdfvj.d.cts → index-D4ahI0W6.d.cts} +2 -3
- package/dist/{index-DDJFHfba.d.cts → index-Mn2POBPj.d.ts} +2334 -101
- package/dist/{index-B_kcptF8.d.ts → index-Yh5y9G4E.d.ts} +2 -3
- package/dist/index.cjs +362 -346
- package/dist/index.d.cts +1505 -1374
- package/dist/index.d.ts +1505 -1374
- package/dist/index.js +7 -7
- package/dist/{program-BARSNg3X.d.ts → program-38A2Twvj.d.ts} +4 -2
- package/dist/{program-znrWkxE4.d.cts → program-DPzf5qsk.d.cts} +4 -2
- package/dist/repositories/realm/index.cjs +40 -40
- package/dist/repositories/realm/index.d.cts +2 -2
- package/dist/repositories/realm/index.d.ts +2 -2
- package/dist/repositories/realm/index.js +8 -8
- package/dist/repositories/sqlite/index.cjs +38 -38
- package/dist/repositories/sqlite/index.d.cts +2 -2
- package/dist/repositories/sqlite/index.d.ts +2 -2
- package/dist/repositories/sqlite/index.js +8 -8
- package/dist/{taskRunner-DUafWu0o.d.ts → taskRunner-BYxEgwM5.d.ts} +1 -1
- package/dist/{taskRunner-JYHaLPne.d.cts → taskRunner-Z3LnHfgs.d.cts} +1 -1
- package/dist/wallet/expo/background.cjs +17 -17
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +9 -9
- package/dist/wallet/expo/index.cjs +18 -18
- package/dist/wallet/expo/index.d.cts +3 -5
- package/dist/wallet/expo/index.d.ts +3 -5
- package/dist/wallet/expo/index.js +8 -8
- package/dist/worker/expo/index.cjs +12 -12
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +8 -8
- package/package.json +1 -1
- package/dist/chunk-3NALVGMJ.cjs.map +0 -1
- package/dist/chunk-4AJRIM44.js.map +0 -1
- package/dist/chunk-DNFTHG73.js.map +0 -1
- package/dist/chunk-FDJ734CH.js.map +0 -1
- package/dist/chunk-FLPWNMX3.cjs.map +0 -1
- package/dist/chunk-JFJNB7ZH.cjs.map +0 -1
- package/dist/chunk-MQUATTIM.cjs.map +0 -1
- package/dist/chunk-MWEDDWFU.js.map +0 -1
- package/dist/chunk-MWMO2ZQP.js.map +0 -1
- package/dist/chunk-MXCB6EVM.cjs.map +0 -1
- package/dist/chunk-OMPDPBT5.cjs.map +0 -1
- package/dist/chunk-RLD7DRSZ.js.map +0 -1
- package/dist/chunk-URGVQ5TQ.cjs.map +0 -1
- package/dist/chunk-V2DDN4MV.js.map +0 -1
- package/dist/chunk-V3ZLL5VY.js.map +0 -1
- package/dist/chunk-V5WRO3P6.cjs.map +0 -1
- package/dist/chunk-VMVFRTF4.js.map +0 -1
- package/dist/chunk-X6ZI53DZ.cjs.map +0 -1
- package/dist/delegate-gGkUnYpi.d.cts +0 -92
- package/dist/delegate-iyDum4fw.d.ts +0 -92
- package/dist/keyringDescriptorProvider-DL-jAiRO.d.ts +0 -2082
- package/dist/keyringDescriptorProvider-Dtv0JWrT.d.cts +0 -2082
package/README.md
CHANGED
|
@@ -909,7 +909,7 @@ one output.
|
|
|
909
909
|
|
|
910
910
|
#### Holding VTXOs for your own use
|
|
911
911
|
|
|
912
|
-
`reserveVtxos` keeps VTXOs out of every pick the SDK makes for you — `send`, `settle()`, exits,
|
|
912
|
+
`Wallet.reserveVtxos` keeps VTXOs out of every pick the SDK makes for you — `send`, `settle()`, exits,
|
|
913
913
|
renewal, payment-router rails and swap funding — until you release them. You can still spend them
|
|
914
914
|
by naming them. It works with or without `concurrentSpending`.
|
|
915
915
|
|
|
@@ -927,7 +927,16 @@ Held VTXOs stay in `getVtxos()` and in `getBalance().total`, and move from `avai
|
|
|
927
927
|
already picked a VTXO when you hold it, that spend throws `VtxoReservedError` (`holder: "held"`)
|
|
928
928
|
instead of spending it; exits and renewal pick again or retry on their own.
|
|
929
929
|
|
|
930
|
-
|
|
930
|
+
For `ServiceWorkerWallet`, use `await workerWallet.reserveVtxos(coins, operationId)` after saving
|
|
931
|
+
that operation id durably in your application. The worker persists the hold under its identity
|
|
932
|
+
and operator URL before acknowledging it, and restores holds before automatic spending starts.
|
|
933
|
+
Retry the same id and inputs after a lost reply or restart. These holds also block explicitly
|
|
934
|
+
selected SDK sends and settlements; they are for transactions the application builds externally.
|
|
935
|
+
Await `hold.release()` only after proving settlement or non-submission. An ambiguous submission
|
|
936
|
+
must keep its hold. Acquire and release require a worker supporting scoped reservations; a retained
|
|
937
|
+
handle cannot release a different identity/operator/network's hold after worker reinitialization.
|
|
938
|
+
|
|
939
|
+
Direct wallet limits:
|
|
931
940
|
|
|
932
941
|
- Reservations are in memory, per `Wallet` instance. Two processes or two `Wallet` instances on one
|
|
933
942
|
seed do not see each other's reservations; the operator refuses whichever spend loses.
|
|
@@ -937,8 +946,7 @@ Limits:
|
|
|
937
946
|
long-lived hold before the VTXO expires, or the operator sweeps it and it comes back only through
|
|
938
947
|
recovery.
|
|
939
948
|
- `toReadonly()` views and the service worker's balance reads do not see reservations.
|
|
940
|
-
-
|
|
941
|
-
but do not expose holds yet.
|
|
949
|
+
- Expo wallets accept `concurrentSpending` but do not expose holds yet.
|
|
942
950
|
|
|
943
951
|
If your app keeps its own reserved-outpoint set, call `reserveVtxos` where you add to it and
|
|
944
952
|
`release()` where you remove, then let the SDK pick: plain `send`, router payments without
|
|
@@ -1238,6 +1246,16 @@ const balance = await wallet.getBalance()
|
|
|
1238
1246
|
For watch-only wallets, use `ServiceWorkerReadonlyWallet` with a
|
|
1239
1247
|
`ReadonlySingleKey` identity instead.
|
|
1240
1248
|
|
|
1249
|
+
Deploy the page and worker from the same SDK version. Each proxy stays bound to its original
|
|
1250
|
+
identity, operator URL and network, including reads used to prepare transactions. If another tab
|
|
1251
|
+
reinitializes the worker for a different wallet, the old proxy rejects requests. Pass
|
|
1252
|
+
`expectedNetwork: 'regtest'` (or your configured network) to `setup` or `create` to verify it during
|
|
1253
|
+
bootstrap. Mixed protocol versions reject requests and require a worker update.
|
|
1254
|
+
|
|
1255
|
+
Use `wallet.onWalletUpdate(update => { ... })` to subscribe to contract and coin updates, and call
|
|
1256
|
+
its returned function to unsubscribe. It filters `CONTRACT_EVENT`, `VTXO_UPDATE` and `UTXO_UPDATE`
|
|
1257
|
+
by the same captured wallet binding; raw service-worker message listeners do not provide that check.
|
|
1258
|
+
|
|
1241
1259
|
### Faster startup without changing existing reads
|
|
1242
1260
|
|
|
1243
1261
|
Existing `Wallet` and `ReadonlyWallet` reads (`getVtxos`, `getBalance`, and
|
|
@@ -1579,7 +1597,7 @@ await contract.register({ label: 'Hashlock' })
|
|
|
1579
1597
|
|
|
1580
1598
|
const funded = await contract.on('vtxo_received', async () => {
|
|
1581
1599
|
funded.off()
|
|
1582
|
-
const { txid } = await contract.functions.claim(preimage)
|
|
1600
|
+
const { txid } = await contract.functions.claim({ arkadeScript: [preimage] })
|
|
1583
1601
|
.to(ArkAddress.decode(recipientAddress).pkScript, 10_000n)
|
|
1584
1602
|
.send()
|
|
1585
1603
|
})
|
|
@@ -1592,7 +1610,7 @@ await wallet.send({ address: contract.address, amount: 10_000 })
|
|
|
1592
1610
|
|
|
1593
1611
|
The connected operator supplies `<SERVER_KEY>` (the reserved `server` parameter in normalized Programs) and `<SERVER_EXIT_DELAY>`; conflicting overrides fail, and time-based delays that are not multiples of 512 seconds fail rather than changing the advertised delay. Resolved bindings are persisted, so restoring the contract keeps its script through server key or policy changes. A declared constructor named `user` defaults to the connected identity; other constructor keys remain caller-provided. Pass a struct or array param whole by its source name, such as `{ owners: [{ key }, { key }] }`; the flattened names it binds, such as `owners.0.key`, are also accepted, and a missing, extra or duplicated field fails with its full name. Child-output placeholders remain explicit `bytes32` constructor bindings. Leaf call inputs used as script operands cannot produce a fixed address and are rejected; raw CSV operands must be canonical BIP68 encodings.
|
|
1594
1612
|
|
|
1595
|
-
|
|
1613
|
+
Call arguments are grouped by the script whose witness they fill: `arkadeScript` holds the covenant inputs, which go into the emulator packet, and `tapscript` holds the non-signature leaf inputs, which go into the leaf's `ConditionWitness`, as in `contract.functions.claim({ arkadeScript: [preimage, flag], tapscript: [leafPreimage] })`. Each list follows declaration order with one argument per source parameter, so a struct or array input is passed whole, as in `contract.functions.spend({ arkadeScript: [request, oracles] })`. Omit the key of a segment without inputs, and call a function without inputs with no arguments. Same-named inputs in the two scopes stay independent. Hand-written programs declare inputs on the segment whose `witness` names them (`tapscript.inputs`, `arkadeScript.inputs`). Leaf signatures are PSBT signatures, not condition arguments: `send()` supports the connected identity and infrastructure signers; additional identities and covenant-tweaked leaf keys require explicit PSBT signing via `build()`. Covenant signature arguments remain caller-provided; transaction-bound Arkade `checkSig` signatures require an Arkade-specific digest helper, which is deferred. CSV leaves require aged onchain outputs and cannot use this offchain builder. Typed call validation and these spending limits apply to every normalized Program. The public `SignerRef` union is unchanged; version 1 programs store emulator signer placement in optional `emulatorIndex` metadata.
|
|
1596
1614
|
|
|
1597
1615
|
#### Compiling Arkade source
|
|
1598
1616
|
|
package/dist/adapters/expo.cjs
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
5
|
-
require('../chunk-
|
|
6
|
-
require('../chunk-
|
|
3
|
+
var chunkWZJJZGBT_cjs = require('../chunk-WZJJZGBT.cjs');
|
|
4
|
+
require('../chunk-ODLSVJRU.cjs');
|
|
5
|
+
require('../chunk-DY24A73N.cjs');
|
|
6
|
+
require('../chunk-WIZCF5IX.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
Object.defineProperty(exports, "ExpoArkProvider", {
|
|
11
11
|
enumerable: true,
|
|
12
|
-
get: function () { return
|
|
12
|
+
get: function () { return chunkWZJJZGBT_cjs.ExpoArkProvider; }
|
|
13
13
|
});
|
|
14
14
|
Object.defineProperty(exports, "ExpoIndexerProvider", {
|
|
15
15
|
enumerable: true,
|
|
16
|
-
get: function () { return
|
|
16
|
+
get: function () { return chunkWZJJZGBT_cjs.ExpoIndexerProvider; }
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "ExpoOperatorProvider", {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: function () { return
|
|
20
|
+
get: function () { return chunkWZJJZGBT_cjs.ExpoOperatorProvider; }
|
|
21
21
|
});
|
|
22
22
|
//# sourceMappingURL=expo.cjs.map
|
|
23
23
|
//# sourceMappingURL=expo.cjs.map
|
package/dist/adapters/expo.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { u as RestOperatorProvider, q as SettlementEvent, T as TxNotificationEvent, v as RestIndexerProvider, w as SubscriptionEvent, x as SubscriptionHeartbeat } from '../index-Bq349_ly.cjs';
|
|
2
|
+
export { y as ArkProvider, z as IndexerProvider, B as OperatorProvider } from '../index-Bq349_ly.cjs';
|
|
3
3
|
import '@scure/btc-signer/utils.js';
|
|
4
4
|
import '@scure/btc-signer';
|
|
5
5
|
import '@scure/btc-signer/psbt.js';
|
package/dist/adapters/expo.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { u as RestOperatorProvider, q as SettlementEvent, T as TxNotificationEvent, v as RestIndexerProvider, w as SubscriptionEvent, x as SubscriptionHeartbeat } from '../index-Mn2POBPj.js';
|
|
2
|
+
export { y as ArkProvider, z as IndexerProvider, B as OperatorProvider } from '../index-Mn2POBPj.js';
|
|
3
3
|
import '@scure/btc-signer/utils.js';
|
|
4
4
|
import '@scure/btc-signer';
|
|
5
5
|
import '@scure/btc-signer/psbt.js';
|
package/dist/adapters/expo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { ExpoArkProvider, ExpoIndexerProvider, ExpoOperatorProvider } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-
|
|
1
|
+
export { ExpoArkProvider, ExpoIndexerProvider, ExpoOperatorProvider } from '../chunk-2657D67V.js';
|
|
2
|
+
import '../chunk-3KNSMZWD.js';
|
|
3
|
+
import '../chunk-FUCKDTH7.js';
|
|
4
|
+
import '../chunk-DPFD5KBK.js';
|
|
5
5
|
//# sourceMappingURL=expo.js.map
|
|
6
6
|
//# sourceMappingURL=expo.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { RestIndexerProvider, toSubscriptionMessage } from './chunk-
|
|
2
|
-
import { RestOperatorProvider, ARKADE_VERSION_HEADERS, isFetchTimeoutError, baseFetch, readSseFrames, streamFailureError } from './chunk-
|
|
3
|
-
import { DEFAULT_ARKADE_SERVER_URL } from './chunk-
|
|
1
|
+
import { RestIndexerProvider, toSubscriptionMessage } from './chunk-3KNSMZWD.js';
|
|
2
|
+
import { RestOperatorProvider, ARKADE_VERSION_HEADERS, isFetchTimeoutError, sdkVersionHeaders, baseFetch, HttpResponseError, readSseFrames, streamFailureError } from './chunk-FUCKDTH7.js';
|
|
3
|
+
import { DEFAULT_ARKADE_SERVER_URL } from './chunk-DPFD5KBK.js';
|
|
4
4
|
|
|
5
5
|
// src/providers/expoUtils.ts
|
|
6
6
|
async function getExpoFetch(options) {
|
|
@@ -38,7 +38,9 @@ async function* sseStreamIterator(url, abortSignal, fetchFn, headers, parseData)
|
|
|
38
38
|
signal: fetchController.signal
|
|
39
39
|
});
|
|
40
40
|
if (!response.ok) {
|
|
41
|
-
|
|
41
|
+
await response.body?.cancel().catch(() => {
|
|
42
|
+
});
|
|
43
|
+
throw new HttpResponseError("Unexpected status when fetching SSE stream", response);
|
|
42
44
|
}
|
|
43
45
|
if (!response.body) {
|
|
44
46
|
throw new Error("Response body is null");
|
|
@@ -144,7 +146,7 @@ var ExpoIndexerProvider = class extends RestIndexerProvider {
|
|
|
144
146
|
url,
|
|
145
147
|
abortSignal,
|
|
146
148
|
expoFetch,
|
|
147
|
-
{ "Content-Type": "application/json" },
|
|
149
|
+
{ "Content-Type": "application/json", ...sdkVersionHeaders() },
|
|
148
150
|
toSubscriptionMessage
|
|
149
151
|
);
|
|
150
152
|
} catch (error) {
|
|
@@ -163,5 +165,5 @@ var ExpoIndexerProvider = class extends RestIndexerProvider {
|
|
|
163
165
|
};
|
|
164
166
|
|
|
165
167
|
export { ExpoArkProvider, ExpoIndexerProvider, ExpoOperatorProvider };
|
|
166
|
-
//# sourceMappingURL=chunk-
|
|
167
|
-
//# sourceMappingURL=chunk-
|
|
168
|
+
//# sourceMappingURL=chunk-2657D67V.js.map
|
|
169
|
+
//# sourceMappingURL=chunk-2657D67V.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/providers/expoUtils.ts","../src/providers/expoArk.ts","../src/providers/expoIndexer.ts"],"names":[],"mappings":";;;;;AAaA,eAAsB,aAAa,OAAA,EAA4D;AAC3F,EAAA,MAAM,WAAA,GAAc,SAAS,WAAA,IAAe,KAAA;AAE5C,EAAA,IAAI;AACA,IAAA,MAAM,eAAA,GAAkB,MAAM,OAAO,YAAY,CAAA;AACjD,IAAA,OAAA,CAAQ,MAAM,gCAAgC,CAAA;AAC9C,IAAA,OAAO,eAAA,CAAgB,KAAA;AAAA,EAC3B,SAAS,KAAA,EAAO;AACZ,IAAA,IAAI,WAAA,EAAa;AACb,MAAA,MAAM,IAAI,KAAA;AAAA,QACN;AAAA,OAEJ;AAAA,IACJ;AAEA,IAAA,OAAA,CAAQ,IAAA;AAAA,MACJ,wGAAA;AAAA,MAEA;AAAA,KACJ;AACA,IAAA,OAAO,SAAA;AAAA,EACX;AACJ;AAYA,gBAAuB,iBAAA,CACnB,GAAA,EACA,WAAA,EACA,OAAA,EACA,SACA,SAAA,EACgC;AAChC,EAAA,MAAM,eAAA,GAAkB,IAAI,eAAA,EAAgB;AAC5C,EAAA,MAAM,OAAA,GAAU,MAAM,eAAA,CAAgB,KAAA,EAAM;AAC5C,EAAA,WAAA,EAAa,iBAAiB,OAAA,EAAS,OAAA,EAAS,EAAE,IAAA,EAAM,MAAM,CAAA;AAE9D,EAAA,IAAI;AACA,IAAA,MAAM,QAAA,GAAW,MAAM,OAAA,CAAQ,GAAA,EAAK;AAAA,MAChC,OAAA,EAAS;AAAA,QACL,MAAA,EAAQ,mBAAA;AAAA,QACR,GAAG;AAAA,OACP;AAAA;AAAA;AAAA;AAAA,MAIA,QAAQ,eAA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AM,KAAA;AAAA,IACV,CAAC,CAAA;AAED,IAAA,OAAO,CAAC,YAAY,OAAA,EAAS;AACzB,MAAA,IAAI;AACA,QAAA,OAAO,iBAAA;AAAA,UACH,GAAA;AAAA,UACA,WAAA;AAAA,UACA,SAAA;AAAA,UACA,EAAE,cAAA,EAAgB,kBAAA,EAAoB,GAAG,mBAAkB,EAAE;AAAA,UAC7D;AAAA,SACJ;AAAA,MACJ,SAAS,KAAA,EAAO;AACZ,QAAA,IAAI,KAAA,YAAiB,KAAA,IAAS,KAAA,CAAM,IAAA,KAAS,YAAA,EAAc;AACvD,UAAA;AAAA,QACJ;AAIA,QAAA,IAAI,mBAAA,CAAoB,KAAK,CAAA,EAAG;AAC5B,UAAA,OAAA,CAAQ,MAAM,uBAAuB,CAAA;AACrC,UAAA;AAAA,QACJ;AAEA,QAAA,OAAA,CAAQ,KAAA,CAAM,uBAAuB,KAAK,CAAA;AAC1C,QAAA,MAAM,KAAA;AAAA,MACV;AAAA,IACJ;AAAA,EACJ;AACJ","file":"chunk-2657D67V.js","sourcesContent":["import { baseFetch, fetch } from \"../utils/fetch\";\nimport { HttpResponseError } from \"./errors\";\nimport { readSseFrames } from \"./sseFrames\";\nimport { streamFailureError } from \"./utils\";\n\n/**\n * Dynamically imports expo/fetch, falling back to {@link baseFetch}.\n *\n * Adds no headers of its own: both Expo providers share this function but reach\n * different origins, so each passes its own per request.\n *\n * @returns A fetch function suitable for SSE streaming\n */\nexport async function getExpoFetch(options?: { requireExpo?: boolean }): Promise<typeof fetch> {\n const requireExpo = options?.requireExpo ?? false;\n\n try {\n const expoFetchModule = await import(\"expo/fetch\");\n console.debug(\"Using expo/fetch for streaming\");\n return expoFetchModule.fetch as unknown as typeof fetch;\n } catch (error) {\n if (requireExpo) {\n throw new Error(\n \"expo/fetch is unavailable in this environment. \" +\n \"Please ensure expo/fetch is installed and properly configured.\",\n );\n }\n\n console.warn(\n \"Using standard fetch instead of expo/fetch. \" +\n \"Streaming may not be fully supported in some environments.\",\n error,\n );\n return baseFetch;\n }\n}\n\n/**\n * Generic SSE stream processor using fetch API with ReadableStream.\n * Handles SSE format parsing, buffer management, and abort signals.\n *\n * @param url - The SSE endpoint URL\n * @param abortSignal - Signal to abort the stream\n * @param fetchFn - Fetch function to use (defaults to standard fetch)\n * @param headers - Additional headers to send\n * @param parseData - Function to parse and yield data from SSE events\n */\nexport async function* sseStreamIterator<T>(\n url: string,\n abortSignal: AbortSignal,\n fetchFn: typeof fetch,\n headers: Record<string, string>,\n parseData: (data: any) => T | null,\n): AsyncGenerator<T, void, unknown> {\n const fetchController = new AbortController();\n const cleanup = () => fetchController.abort();\n abortSignal?.addEventListener(\"abort\", cleanup, { once: true });\n\n try {\n const response = await fetchFn(url, {\n headers: {\n Accept: \"text/event-stream\",\n ...headers,\n },\n // Required, not just for cancellation: `getExpoFetch` falls back to\n // `baseFetch`, which bounds any read that brings no signal of its\n // own. Drop this and the stream is truncated at READ_TIMEOUT_MS.\n signal: fetchController.signal,\n });\n\n if (!response.ok) {\n await response.body?.cancel().catch(() => {});\n throw new HttpResponseError(\"Unexpected status when fetching SSE stream\", response);\n }\n\n if (!response.body) {\n throw new Error(\"Response body is null\");\n }\n\n for await (const { event, data } of readSseFrames(response.body)) {\n if (abortSignal?.aborted) break;\n if (event === \"failure\") throw streamFailureError(data);\n if (event !== \"message\" || !data.trim()) continue;\n\n try {\n const parsed = parseData(JSON.parse(data));\n if (parsed !== null) {\n yield parsed;\n }\n } catch (parseError) {\n console.error(\"Failed to parse SSE data:\", parseError);\n throw parseError;\n }\n }\n } finally {\n abortSignal?.removeEventListener(\"abort\", cleanup);\n }\n}\n","import { DEFAULT_ARKADE_SERVER_URL } from \"../networks\";\nimport {\n RestOperatorProvider,\n SettlementEvent,\n TxNotificationEvent,\n isFetchTimeoutError,\n} from \"./ark\";\nimport { getExpoFetch, sseStreamIterator } from \"./expoUtils\";\nimport { ARKADE_VERSION_HEADERS } from \"../utils/fetch\";\n\n/**\n * Expo-compatible operator provider implementation using expo/fetch for SSE support.\n * This provider works specifically in React Native/Expo environments where\n * standard EventSource is not available but expo/fetch provides SSE capabilities.\n *\n * @example\n * ```typescript\n * import { ExpoOperatorProvider } from '@arkade-os/sdk/adapters/expo';\n *\n * const provider = new ExpoOperatorProvider('https://arkade.computer');\n * const info = await provider.getInfo();\n * ```\n */\nexport class ExpoOperatorProvider extends RestOperatorProvider {\n constructor(serverUrl: string = DEFAULT_ARKADE_SERVER_URL) {\n super(serverUrl);\n }\n\n override async *getEventStream(\n signal: AbortSignal,\n topics: string[],\n ): AsyncIterableIterator<SettlementEvent> {\n const expoFetch = await getExpoFetch();\n const url = `${this.serverUrl}/v1/batch/events`;\n const queryParams =\n topics.length > 0\n ? `?${topics.map((topic) => `topics=${encodeURIComponent(topic)}`).join(\"&\")}`\n : \"\";\n\n while (!signal?.aborted) {\n try {\n yield* sseStreamIterator(\n url + queryParams,\n signal,\n expoFetch,\n ARKADE_VERSION_HEADERS,\n (data) => {\n // Handle different response structures\n // v8 mesh API might wrap in {result: ...} or send directly\n const eventData = data.result || data;\n\n // Skip heartbeat messages\n if (eventData.heartbeat !== undefined) {\n return null;\n }\n\n return this.parseSettlementEvent(eventData);\n },\n );\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n break;\n }\n\n // ignore timeout errors, they're expected when the server is not sending anything for 5 min\n // these timeouts are set by expo/fetch function\n if (isFetchTimeoutError(error)) {\n console.debug(\"Timeout error ignored\");\n continue;\n }\n\n console.error(\"Event stream error:\", error);\n throw error;\n }\n }\n }\n\n override async *getTransactionsStream(\n signal: AbortSignal,\n ): AsyncIterableIterator<TxNotificationEvent> {\n const expoFetch = await getExpoFetch();\n const url = `${this.serverUrl}/v1/txs`;\n\n while (!signal?.aborted) {\n try {\n yield* sseStreamIterator(url, signal, expoFetch, ARKADE_VERSION_HEADERS, (data) => {\n return this.parseTransactionNotification(data.result);\n });\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n break;\n }\n\n // ignore timeout errors, they're expected when the server is not sending anything for 5 min\n // these timeouts are set by expo/fetch function\n if (isFetchTimeoutError(error)) {\n console.debug(\"Timeout error ignored\");\n continue;\n }\n\n console.error(\"Transaction stream error:\", error);\n throw error;\n }\n }\n }\n}\n\n/** @deprecated Use {@link ExpoOperatorProvider}. */\nexport const ExpoArkProvider = ExpoOperatorProvider;\n/** @deprecated Use {@link ExpoOperatorProvider}. */\nexport type ExpoArkProvider = ExpoOperatorProvider;\n","import {\n RestIndexerProvider,\n SubscriptionEvent,\n SubscriptionHeartbeat,\n toSubscriptionMessage,\n} from \"./indexer\";\nimport { isFetchTimeoutError } from \"./ark\";\nimport { getExpoFetch, sseStreamIterator } from \"./expoUtils\";\nimport { DEFAULT_ARKADE_SERVER_URL } from \"../networks\";\nimport { sdkVersionHeaders } from \"../utils/sdkVersionHeaders\";\n\n/**\n * Expo-compatible Indexer provider implementation using expo/fetch for streaming support.\n * This provider works specifically in React Native/Expo environments where\n * standard fetch streaming may not work properly but expo/fetch provides streaming capabilities.\n *\n * @example\n * ```typescript\n * import { ExpoIndexerProvider } from '@arkade-os/sdk/adapters/expo';\n *\n * const provider = new ExpoIndexerProvider('https://indexer.example.com');\n * const vtxos = await provider.getVtxos({ scripts: ['script1'] });\n * ```\n */\nexport class ExpoIndexerProvider extends RestIndexerProvider {\n constructor(serverUrl: string = DEFAULT_ARKADE_SERVER_URL) {\n super(serverUrl);\n }\n\n protected override async *subscriptionStream(\n url: string,\n abortSignal: AbortSignal,\n ): AsyncIterableIterator<SubscriptionEvent | SubscriptionHeartbeat> {\n // Detect if we're running in React Native/Expo environment\n const isReactNative =\n typeof navigator !== \"undefined\" && navigator.product === \"ReactNative\";\n\n const expoFetch = await getExpoFetch({ requireExpo: isReactNative }).catch((error) => {\n // In React Native/Expo, expo/fetch is required for proper streaming support\n if (isReactNative) {\n throw new Error(\n \"expo/fetch is unavailable in React Native environment. \" +\n \"Please ensure expo/fetch is installed and properly configured. \" +\n \"Streaming support may not work with standard fetch in React Native.\",\n );\n }\n throw error;\n });\n\n while (!abortSignal.aborted) {\n try {\n yield* sseStreamIterator(\n url,\n abortSignal,\n expoFetch,\n { \"Content-Type\": \"application/json\", ...sdkVersionHeaders() },\n toSubscriptionMessage,\n );\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n break;\n }\n\n // ignore timeout errors, they're expected when the server is not sending anything for 5 min\n // these timeouts are set by expo/fetch function\n if (isFetchTimeoutError(error)) {\n console.debug(\"Timeout error ignored\");\n continue;\n }\n\n console.error(\"Subscription error:\", error);\n throw error;\n }\n }\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { eventSourceIterator, resolveEventSource, isFetchTimeoutError, isEventSourceError, isEventSourceUnavailableError, convertVtxo, rateGate, baseFetch, toProviderUnavailable, ProviderUnavailableError, throwIfHttpUnavailable } from './chunk-
|
|
2
|
-
import { __export, DEFAULT_ARKADE_SERVER_URL } from './chunk-
|
|
1
|
+
import { eventSourceIterator, resolveEventSource, sdkVersionHeaders, isFetchTimeoutError, isEventSourceError, isEventSourceUnavailableError, indexerPages, convertVtxo, rateGate, baseFetch, toProviderUnavailable, ProviderUnavailableError, throwIfHttpUnavailable } from './chunk-FUCKDTH7.js';
|
|
2
|
+
import { __export, DEFAULT_ARKADE_SERVER_URL } from './chunk-DPFD5KBK.js';
|
|
3
3
|
import { hex } from '@scure/base';
|
|
4
4
|
import { schnorr } from '@noble/curves/secp256k1.js';
|
|
5
5
|
import { compareBytes } from '@scure/btc-signer/utils.js';
|
|
@@ -151,6 +151,9 @@ var BufferReader = class {
|
|
|
151
151
|
throw new Error("unexpected end of buffer");
|
|
152
152
|
}
|
|
153
153
|
byte = this.view.getUint8(this.offset++);
|
|
154
|
+
if (shift === 63n && byte > 1) {
|
|
155
|
+
throw new Error("varuint overflows 64 bits");
|
|
156
|
+
}
|
|
154
157
|
result |= BigInt(byte & 127) << shift;
|
|
155
158
|
shift += 7n;
|
|
156
159
|
} while (byte & 128);
|
|
@@ -718,6 +721,7 @@ var AssetOutputs = class _AssetOutputs {
|
|
|
718
721
|
}
|
|
719
722
|
}
|
|
720
723
|
};
|
|
724
|
+
var MAX_METADATA_LIST_COUNT = 1e3;
|
|
721
725
|
var Metadata = class _Metadata {
|
|
722
726
|
constructor(key, value) {
|
|
723
727
|
this.key = key;
|
|
@@ -815,6 +819,11 @@ var MetadataList = class _MetadataList {
|
|
|
815
819
|
/** Decode a metadata list from a buffer reader. */
|
|
816
820
|
static fromReader(reader) {
|
|
817
821
|
const count = Number(reader.readVarUint());
|
|
822
|
+
if (count > MAX_METADATA_LIST_COUNT) {
|
|
823
|
+
throw new Error(
|
|
824
|
+
`invalid asset metadata list count, max=${MAX_METADATA_LIST_COUNT}, got=${count}`
|
|
825
|
+
);
|
|
826
|
+
}
|
|
818
827
|
const items = Array.from({ length: count }, () => Metadata.fromReader(reader));
|
|
819
828
|
return new _MetadataList(items);
|
|
820
829
|
}
|
|
@@ -1314,6 +1323,12 @@ var INDEXER_RETRY_BASE_MS = 250;
|
|
|
1314
1323
|
async function indexerFetch(input, init) {
|
|
1315
1324
|
const method = (init?.method ?? "GET").toUpperCase();
|
|
1316
1325
|
const maxAttempts = method === "GET" || method === "HEAD" ? INDEXER_MAX_ATTEMPTS : 1;
|
|
1326
|
+
const versionHeaders = Object.entries(sdkVersionHeaders());
|
|
1327
|
+
if (versionHeaders.length > 0) {
|
|
1328
|
+
const headers = new Headers(init?.headers);
|
|
1329
|
+
for (const [name, value] of versionHeaders) headers.set(name, value);
|
|
1330
|
+
init = { ...init, headers };
|
|
1331
|
+
}
|
|
1317
1332
|
for (let attempt = 1; ; attempt++) {
|
|
1318
1333
|
const lastAttempt = attempt >= maxAttempts;
|
|
1319
1334
|
let res;
|
|
@@ -1498,7 +1513,7 @@ var RestIndexerProvider = class {
|
|
|
1498
1513
|
while (!abortSignal?.aborted) {
|
|
1499
1514
|
try {
|
|
1500
1515
|
const currentIterator = eventSourceIterator(
|
|
1501
|
-
resolveEventSource(override)(url)
|
|
1516
|
+
resolveEventSource(override)(url, sdkVersionHeaders())
|
|
1502
1517
|
);
|
|
1503
1518
|
iterator = currentIterator;
|
|
1504
1519
|
for await (const event of currentIterator) {
|
|
@@ -1595,18 +1610,14 @@ var RestIndexerProvider = class {
|
|
|
1595
1610
|
}
|
|
1596
1611
|
if (opts?.pageIndex === void 0 && opts?.pageSize === void 0) {
|
|
1597
1612
|
const all = [];
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
const { vtxos, page } = await this.fetchVtxosPage({
|
|
1613
|
+
for await (const { vtxos } of indexerPages(
|
|
1614
|
+
(pageIndex) => this.fetchVtxosPage({
|
|
1601
1615
|
...opts,
|
|
1602
1616
|
pageIndex,
|
|
1603
1617
|
pageSize: DEFAULT_VTXO_PAGE_SIZE
|
|
1604
|
-
})
|
|
1618
|
+
})
|
|
1619
|
+
)) {
|
|
1605
1620
|
all.push(...vtxos);
|
|
1606
|
-
if (!page || page.current >= page.total || vtxos.length < DEFAULT_VTXO_PAGE_SIZE) {
|
|
1607
|
-
break;
|
|
1608
|
-
}
|
|
1609
|
-
pageIndex = page.next;
|
|
1610
1621
|
}
|
|
1611
1622
|
return { vtxos: all };
|
|
1612
1623
|
}
|
|
@@ -1911,5 +1922,5 @@ var Response;
|
|
|
1911
1922
|
})(Response || (Response = {}));
|
|
1912
1923
|
|
|
1913
1924
|
export { AssetGroup, AssetId, AssetInput, AssetOutput, AssetRef, BufferReader, BufferWriter, ChainTxType, DEFAULT_VTXO_PAGE_SIZE, IndexerTxType, IndexerUtxosUnsupportedError, Metadata, Packet, RestIndexerProvider, asset_exports, toSubscriptionMessage };
|
|
1914
|
-
//# sourceMappingURL=chunk-
|
|
1915
|
-
//# sourceMappingURL=chunk-
|
|
1925
|
+
//# sourceMappingURL=chunk-3KNSMZWD.js.map
|
|
1926
|
+
//# sourceMappingURL=chunk-3KNSMZWD.js.map
|