@arkade-os/sdk 0.4.39 → 0.4.41
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 -0
- package/dist/adapters/expo.cjs +5 -5
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +3 -3
- package/dist/adapters/indexedDB.cjs +5 -5
- package/dist/adapters/indexedDB.js +4 -4
- package/dist/{ark-BzUNnkoc.d.cts → ark-CSqMJczW.d.cts} +111 -4
- package/dist/{ark-BzUNnkoc.d.ts → ark-CSqMJczW.d.ts} +111 -4
- package/dist/{asyncStorageTaskQueue-C0kQoY1x.d.cts → asyncStorageTaskQueue-79XdGsdW.d.cts} +1 -1
- package/dist/{asyncStorageTaskQueue-CIYeI6GM.d.ts → asyncStorageTaskQueue-SZPrhw23.d.ts} +1 -1
- package/dist/{chunk-GUTKJMSF.cjs → chunk-32YKLQPS.cjs} +29 -29
- package/dist/{chunk-GUTKJMSF.cjs.map → chunk-32YKLQPS.cjs.map} +1 -1
- package/dist/{chunk-P5FKMIGY.cjs → chunk-3MPXMLP4.cjs} +538 -282
- package/dist/chunk-3MPXMLP4.cjs.map +1 -0
- package/dist/{chunk-D744IES4.js → chunk-5XAYUPK4.js} +15 -6
- package/dist/chunk-5XAYUPK4.js.map +1 -0
- package/dist/{chunk-LJLEFPWD.cjs → chunk-ALISWEQ5.cjs} +20 -11
- package/dist/chunk-ALISWEQ5.cjs.map +1 -0
- package/dist/{chunk-OUVTG72A.js → chunk-BE5MUB7T.js} +5 -3
- package/dist/chunk-BE5MUB7T.js.map +1 -0
- package/dist/{chunk-SYEGCMNV.js → chunk-D5MQYYYF.js} +355 -104
- package/dist/chunk-D5MQYYYF.js.map +1 -0
- package/dist/{chunk-VGXTJ7HR.js → chunk-DDG4RE5F.js} +4 -4
- package/dist/{chunk-VGXTJ7HR.js.map → chunk-DDG4RE5F.js.map} +1 -1
- package/dist/{chunk-CMPJR3HS.cjs → chunk-HXDZ2QTW.cjs} +5 -3
- package/dist/chunk-HXDZ2QTW.cjs.map +1 -0
- package/dist/{chunk-A5RLZCPO.cjs → chunk-KNASU3QI.cjs} +7 -7
- package/dist/{chunk-A5RLZCPO.cjs.map → chunk-KNASU3QI.cjs.map} +1 -1
- package/dist/{chunk-UIFBMKI7.js → chunk-MYI333YH.js} +3 -3
- package/dist/{chunk-UIFBMKI7.js.map → chunk-MYI333YH.js.map} +1 -1
- package/dist/{chunk-N56IDZON.cjs → chunk-WBF3FNS3.cjs} +14 -14
- package/dist/{chunk-N56IDZON.cjs.map → chunk-WBF3FNS3.cjs.map} +1 -1
- package/dist/{chunk-CUSABEUQ.js → chunk-YNEDJTX2.js} +3 -3
- package/dist/{chunk-CUSABEUQ.js.map → chunk-YNEDJTX2.js.map} +1 -1
- package/dist/contracts/handlers/index.cjs +7 -7
- 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 -2
- package/dist/{delegate-BjPbX-MR.d.ts → delegate-BTn9BK8E.d.ts} +1 -1
- package/dist/{delegate-DHAgMIS9.d.cts → delegate-Bqwe-kbj.d.cts} +1 -1
- package/dist/{index-YkMAtSfw.d.cts → index-aYiHTMkX.d.cts} +2 -2
- package/dist/{index-BOQKDCmS.d.ts → index-kITujXlS.d.ts} +2 -2
- package/dist/index.cjs +163 -139
- package/dist/index.d.cts +53 -11
- package/dist/index.d.ts +53 -11
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +13 -13
- package/dist/repositories/realm/index.d.cts +1 -1
- package/dist/repositories/realm/index.d.ts +1 -1
- package/dist/repositories/realm/index.js +4 -4
- package/dist/repositories/sqlite/index.cjs +13 -13
- package/dist/repositories/sqlite/index.d.cts +1 -1
- package/dist/repositories/sqlite/index.d.ts +1 -1
- package/dist/repositories/sqlite/index.js +4 -4
- package/dist/{taskRunner-Dfmt7ZPN.d.ts → taskRunner-BuBAZQwB.d.ts} +1 -1
- package/dist/{taskRunner-CVEgBO6d.d.cts → taskRunner-DRHElPMG.d.cts} +1 -1
- package/dist/wallet/expo/background.cjs +14 -14
- 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 -6
- package/dist/wallet/expo/index.cjs +44 -14
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +14 -4
- package/dist/wallet/expo/index.d.ts +14 -4
- package/dist/wallet/expo/index.js +36 -6
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/{wallet-C4Pide44.d.ts → wallet-BZgRfnAE.d.cts} +15 -2
- package/dist/{wallet-_PTv-lMe.d.cts → wallet-CTEQpKG9.d.ts} +15 -2
- package/dist/worker/expo/index.cjs +9 -9
- 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 -5
- package/package.json +1 -1
- package/dist/chunk-CMPJR3HS.cjs.map +0 -1
- package/dist/chunk-D744IES4.js.map +0 -1
- package/dist/chunk-LJLEFPWD.cjs.map +0 -1
- package/dist/chunk-OUVTG72A.js.map +0 -1
- package/dist/chunk-P5FKMIGY.cjs.map +0 -1
- package/dist/chunk-SYEGCMNV.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { craftToSpendTx, Transaction, OP_RETURN_EMPTY_PKSCRIPT, baseFetch, Intent, getArkPsbtFields, CosignerPublicKey, setArkPsbtField, VtxoTaprootTree, maybeArkError, AssetRef, AssetId, AssetOutput, AssetGroup, AssetInput, Packet, Metadata, isEventSourceError, RestArkProvider, RestIndexerProvider, ArkError, BufferReader } from './chunk-
|
|
2
|
-
import { isMainnetDescriptor, descriptorIsOurs, contractHandlers, DEFAULT_PAGE_SIZE, DelegateVtxo, WALLET_RECEIVE_SOURCE, deriveDescriptorLeafPubKey, DefaultVtxo, BoardingContractHandler } from './chunk-
|
|
3
|
-
import { VtxoScript, timelockToSequence, DEFAULT_NETWORK, DEFAULT_NETWORK_NAME, decodeTapscript, scriptFromTapLeafScript, CLTVMultisigTapscript, ArkAddress, CSVMultisigTapscript, getSequence, getNetwork, MultisigTapscript, networks as networks$1, DEFAULT_ARKADE_SERVER_URL } from './chunk-
|
|
1
|
+
import { craftToSpendTx, Transaction, OP_RETURN_EMPTY_PKSCRIPT, baseFetch, Intent, getArkPsbtFields, CosignerPublicKey, setArkPsbtField, VtxoTaprootTree, maybeArkError, AssetRef, AssetId, AssetOutput, AssetGroup, AssetInput, Packet, Metadata, isEventSourceError, RestArkProvider, RestIndexerProvider, ArkError, BufferReader } from './chunk-5XAYUPK4.js';
|
|
2
|
+
import { isMainnetDescriptor, descriptorIsOurs, contractHandlers, DEFAULT_PAGE_SIZE, DelegateVtxo, WALLET_RECEIVE_SOURCE, deriveDescriptorLeafPubKey, DefaultVtxo, BoardingContractHandler } from './chunk-YNEDJTX2.js';
|
|
3
|
+
import { VtxoScript, timelockToSequence, DEFAULT_NETWORK, DEFAULT_NETWORK_NAME, decodeTapscript, scriptFromTapLeafScript, CLTVMultisigTapscript, ArkAddress, CSVMultisigTapscript, getSequence, getNetwork, MultisigTapscript, networks as networks$1, DEFAULT_ARKADE_SERVER_URL } from './chunk-BE5MUB7T.js';
|
|
4
4
|
import { sha256, hash160, sha256x2, concatBytes, randomPrivateKeyBytes, pubECDSA, pubSchnorr, equalBytes as equalBytes$1 } from '@scure/btc-signer/utils.js';
|
|
5
5
|
import { SigHash, Script, p2tr, RawWitness, Address, OutScript, p2wpkh, TaprootControlBlock, DEFAULT_SEQUENCE, Transaction as Transaction$2 } from '@scure/btc-signer';
|
|
6
6
|
import { hex, base58, base64 } from '@scure/base';
|
|
@@ -1209,7 +1209,9 @@ function isValidBlocksTip(tip) {
|
|
|
1209
1209
|
});
|
|
1210
1210
|
}
|
|
1211
1211
|
var isExplorerTransaction = (tx) => {
|
|
1212
|
-
return typeof tx.txid === "string" && Array.isArray(tx.
|
|
1212
|
+
return typeof tx.txid === "string" && (tx.vin === void 0 || Array.isArray(tx.vin) && tx.vin.every(
|
|
1213
|
+
(vin) => typeof vin.txid === "string" && typeof vin.vout === "number"
|
|
1214
|
+
)) && Array.isArray(tx.vout) && tx.vout.every(
|
|
1213
1215
|
(vout) => typeof vout.scriptpubkey_address === "string" && typeof vout.value === "number"
|
|
1214
1216
|
) && typeof tx.status === "object" && typeof tx.status.confirmed === "boolean";
|
|
1215
1217
|
};
|
|
@@ -1676,6 +1678,122 @@ function validateAssetGroupOutput(packet, outputIndex, assetId, expectedAmount)
|
|
|
1676
1678
|
}
|
|
1677
1679
|
}
|
|
1678
1680
|
|
|
1681
|
+
// src/wallet/activity.ts
|
|
1682
|
+
async function buildActivities(txs, resolvers) {
|
|
1683
|
+
const preparedResolvers = (await Promise.all(
|
|
1684
|
+
resolvers.map(async (r) => {
|
|
1685
|
+
try {
|
|
1686
|
+
await r.prepare?.();
|
|
1687
|
+
return r;
|
|
1688
|
+
} catch {
|
|
1689
|
+
return void 0;
|
|
1690
|
+
}
|
|
1691
|
+
})
|
|
1692
|
+
)).filter((r) => r !== void 0);
|
|
1693
|
+
const keyOf = (tx) => tx.key.arkTxid || tx.key.commitmentTxid || tx.key.boardingTxid;
|
|
1694
|
+
const merge = (a, b) => ({
|
|
1695
|
+
groupId: a.groupId,
|
|
1696
|
+
label: a.label ?? b.label,
|
|
1697
|
+
kind: a.kind ?? b.kind,
|
|
1698
|
+
metadata: { ...b.metadata, ...a.metadata },
|
|
1699
|
+
amount: a.amount ?? b.amount
|
|
1700
|
+
});
|
|
1701
|
+
const isSent = (tx) => tx.type === "SENT" /* TxSent */;
|
|
1702
|
+
const signedAmount = (tx, amount = tx.amount) => {
|
|
1703
|
+
const magnitude = Math.abs(amount);
|
|
1704
|
+
return isSent(tx) ? -magnitude : magnitude;
|
|
1705
|
+
};
|
|
1706
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
1707
|
+
for (const tx of txs) {
|
|
1708
|
+
const perGroup = /* @__PURE__ */ new Map();
|
|
1709
|
+
for (const r of preparedResolvers) {
|
|
1710
|
+
let ms;
|
|
1711
|
+
try {
|
|
1712
|
+
ms = r.resolve(tx);
|
|
1713
|
+
} catch {
|
|
1714
|
+
ms = void 0;
|
|
1715
|
+
}
|
|
1716
|
+
for (const m of ms ?? []) {
|
|
1717
|
+
if (!m.groupId) continue;
|
|
1718
|
+
if (m.amount !== void 0 && !Number.isFinite(m.amount)) continue;
|
|
1719
|
+
const existing = perGroup.get(m.groupId);
|
|
1720
|
+
perGroup.set(m.groupId, existing ? merge(existing, m) : { ...m });
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
if (perGroup.size === 0) {
|
|
1724
|
+
const id = keyOf(tx);
|
|
1725
|
+
const b = buckets.get(id) ?? { members: [] };
|
|
1726
|
+
b.members.push({ tx, amount: signedAmount(tx) });
|
|
1727
|
+
buckets.set(id, b);
|
|
1728
|
+
continue;
|
|
1729
|
+
}
|
|
1730
|
+
for (const m of perGroup.values()) {
|
|
1731
|
+
const b = buckets.get(m.groupId) ?? { members: [] };
|
|
1732
|
+
b.intent = {
|
|
1733
|
+
label: b.intent?.label ?? m.label,
|
|
1734
|
+
kind: b.intent?.kind ?? m.kind,
|
|
1735
|
+
metadata: { ...m.metadata, ...b.intent?.metadata }
|
|
1736
|
+
};
|
|
1737
|
+
b.members.push({ tx, amount: signedAmount(tx, m.amount ?? tx.amount) });
|
|
1738
|
+
buckets.set(m.groupId, b);
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
const netAmount = (members) => {
|
|
1742
|
+
const sentKeys = new Set(members.filter((x) => isSent(x.tx)).map((x) => keyOf(x.tx)));
|
|
1743
|
+
return members.reduce((s, x) => {
|
|
1744
|
+
if (!isSent(x.tx) && sentKeys.has(keyOf(x.tx))) return s;
|
|
1745
|
+
return s + x.amount;
|
|
1746
|
+
}, 0);
|
|
1747
|
+
};
|
|
1748
|
+
const latest = (a) => a.txs[a.txs.length - 1].createdAt;
|
|
1749
|
+
return [...buckets.entries()].map(([id, b]) => {
|
|
1750
|
+
const members = [...b.members].sort((x, y) => x.tx.createdAt - y.tx.createdAt);
|
|
1751
|
+
return {
|
|
1752
|
+
id,
|
|
1753
|
+
intent: b.intent,
|
|
1754
|
+
txs: members.map((x) => x.tx),
|
|
1755
|
+
amount: netAmount(members),
|
|
1756
|
+
createdAt: members[0].tx.createdAt,
|
|
1757
|
+
settled: members.every((x) => x.tx.settled)
|
|
1758
|
+
};
|
|
1759
|
+
}).sort((a, c) => latest(c) - latest(a));
|
|
1760
|
+
}
|
|
1761
|
+
var ActivityRegistry = class {
|
|
1762
|
+
resolvers = /* @__PURE__ */ new Map();
|
|
1763
|
+
/** Add a resolver, or override an existing one with the same id (kept in place). */
|
|
1764
|
+
use(resolver) {
|
|
1765
|
+
this.resolvers.set(resolver.id, resolver);
|
|
1766
|
+
}
|
|
1767
|
+
/** Remove a resolver (built-in or custom) by id. */
|
|
1768
|
+
remove(id) {
|
|
1769
|
+
this.resolvers.delete(id);
|
|
1770
|
+
}
|
|
1771
|
+
/** The registered resolver ids, in registration order. */
|
|
1772
|
+
list() {
|
|
1773
|
+
return [...this.resolvers.keys()];
|
|
1774
|
+
}
|
|
1775
|
+
/** All registered resolvers, in registration (priority) order. */
|
|
1776
|
+
all() {
|
|
1777
|
+
return [...this.resolvers.values()];
|
|
1778
|
+
}
|
|
1779
|
+
};
|
|
1780
|
+
function boardingResolver() {
|
|
1781
|
+
return {
|
|
1782
|
+
id: "boarding",
|
|
1783
|
+
resolve(tx) {
|
|
1784
|
+
if (!tx.key.boardingTxid) return void 0;
|
|
1785
|
+
return [
|
|
1786
|
+
{ groupId: `boarding:${tx.key.boardingTxid}`, label: "Deposit", kind: "boarding" }
|
|
1787
|
+
];
|
|
1788
|
+
}
|
|
1789
|
+
};
|
|
1790
|
+
}
|
|
1791
|
+
function createDefaultActivityRegistry() {
|
|
1792
|
+
const registry = new ActivityRegistry();
|
|
1793
|
+
registry.use(boardingResolver());
|
|
1794
|
+
return registry;
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1679
1797
|
// src/wallet/index.ts
|
|
1680
1798
|
var TxType = /* @__PURE__ */ ((TxType2) => {
|
|
1681
1799
|
TxType2["TxSent"] = "SENT";
|
|
@@ -2247,7 +2365,7 @@ var Estimator = class {
|
|
|
2247
2365
|
* @param onchainOutputs - Array of onchain outputs to evaluate
|
|
2248
2366
|
* @returns The total fee amount
|
|
2249
2367
|
*/
|
|
2250
|
-
|
|
2368
|
+
evaluate(offchainInputs, onchainInputs, offchainOutputs, onchainOutputs) {
|
|
2251
2369
|
let fee = FeeAmount.ZERO;
|
|
2252
2370
|
for (const input of offchainInputs) {
|
|
2253
2371
|
fee = fee.add(this.evalOffchainInput(input));
|
|
@@ -5603,7 +5721,13 @@ async function openDatabase(dbName, dbVersion, initDatabase2) {
|
|
|
5603
5721
|
reject(request.error);
|
|
5604
5722
|
};
|
|
5605
5723
|
request.onsuccess = () => {
|
|
5606
|
-
|
|
5724
|
+
const db = request.result;
|
|
5725
|
+
db.onversionchange = () => {
|
|
5726
|
+
db.close();
|
|
5727
|
+
dbCache.delete(dbName);
|
|
5728
|
+
refCounts.delete(dbName);
|
|
5729
|
+
};
|
|
5730
|
+
resolve(db);
|
|
5607
5731
|
};
|
|
5608
5732
|
request.onupgradeneeded = (event) => {
|
|
5609
5733
|
const db = request.result;
|
|
@@ -8653,6 +8777,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
8653
8777
|
// already on their way out. The set is in-memory only: a process crash
|
|
8654
8778
|
// clears it, and a stale entry only hides a VTXO (never spends one).
|
|
8655
8779
|
_pendingSpendOutpoints = /* @__PURE__ */ new Set();
|
|
8780
|
+
/** Activity resolvers consumed by {@link getActivityHistory}. */
|
|
8781
|
+
activity = createDefaultActivityRegistry();
|
|
8656
8782
|
get assetManager() {
|
|
8657
8783
|
return this._assetManager;
|
|
8658
8784
|
}
|
|
@@ -8858,7 +8984,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
8858
8984
|
type: info.boardingExitDelay < 512n ? "blocks" : "seconds"
|
|
8859
8985
|
};
|
|
8860
8986
|
const serverPubKey = hex.decode(info.signerPubkey).slice(1);
|
|
8861
|
-
const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) => hex.decode(info2.pubkey).slice(1)) : config.delegatorProvider ? await config.delegatorProvider.getDelegateInfo().then((info2) => hex.decode(info2.pubkey).slice(1)) : void 0;
|
|
8987
|
+
const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) => hex.decode(info2.pubkey).slice(1)).catch(() => void 0) : config.delegatorProvider ? await config.delegatorProvider.getDelegateInfo().then((info2) => hex.decode(info2.pubkey).slice(1)).catch(() => void 0) : void 0;
|
|
8862
8988
|
const offchainOptions = {
|
|
8863
8989
|
pubKey,
|
|
8864
8990
|
serverPubKey,
|
|
@@ -9049,6 +9175,13 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
9049
9175
|
const getTxCreatedAt = (txid) => this.indexerProvider.getVtxos({ outpoints: [{ txid, vout: 0 }] }).then((res) => res.vtxos[0]?.createdAt.getTime());
|
|
9050
9176
|
return buildTransactionHistory(allVtxos, boardingTxs, commitmentsToIgnore, getTxCreatedAt);
|
|
9051
9177
|
}
|
|
9178
|
+
/**
|
|
9179
|
+
* Wallet history grouped by registered activity resolvers. With no resolver match,
|
|
9180
|
+
* rows bucket by transaction key so send/change pairs stay together.
|
|
9181
|
+
*/
|
|
9182
|
+
async getActivityHistory() {
|
|
9183
|
+
return buildActivities(await this.getTransactionHistory(), this.activity.all());
|
|
9184
|
+
}
|
|
9052
9185
|
/**
|
|
9053
9186
|
* Clear the global VTXO sync cursor, forcing a full re-bootstrap on next sync.
|
|
9054
9187
|
* Useful for recovery after indexer reprocessing or debugging.
|
|
@@ -9056,6 +9189,17 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
9056
9189
|
async clearSyncCursor() {
|
|
9057
9190
|
await clearSyncCursor(this.walletRepository);
|
|
9058
9191
|
}
|
|
9192
|
+
/**
|
|
9193
|
+
* Wipe all locally persisted wallet data (VTXOs, UTXOs, history, sync
|
|
9194
|
+
* cursor, contracts). Create a fresh wallet instance afterward.
|
|
9195
|
+
*/
|
|
9196
|
+
async clear() {
|
|
9197
|
+
try {
|
|
9198
|
+
await this.dispose();
|
|
9199
|
+
} finally {
|
|
9200
|
+
await Promise.all([this.walletRepository.clear(), this.contractRepository.clear()]);
|
|
9201
|
+
}
|
|
9202
|
+
}
|
|
9059
9203
|
/**
|
|
9060
9204
|
* The on-chain (P2TR) addresses of every boarding tapscript this wallet
|
|
9061
9205
|
* uses — the current address plus any historical rotated boarding
|
|
@@ -9080,6 +9224,12 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
9080
9224
|
const boardingAddress = tapscript.onchainAddress(this.network);
|
|
9081
9225
|
const scriptHex = hex.encode(tapscript.pkScript);
|
|
9082
9226
|
const txs = await this.onchainProvider.getTransactions(boardingAddress);
|
|
9227
|
+
const commitmentByOutpoint = /* @__PURE__ */ new Map();
|
|
9228
|
+
for (const tx of txs) {
|
|
9229
|
+
for (const input of tx.vin ?? []) {
|
|
9230
|
+
commitmentByOutpoint.set(`${input.txid}:${input.vout}`, tx.txid);
|
|
9231
|
+
}
|
|
9232
|
+
}
|
|
9083
9233
|
for (const tx of txs) {
|
|
9084
9234
|
for (let i = 0; i < tx.vout.length; i++) {
|
|
9085
9235
|
const vout = tx.vout[i];
|
|
@@ -9090,8 +9240,10 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
9090
9240
|
outspendCache.set(tx.txid, spentStatuses);
|
|
9091
9241
|
}
|
|
9092
9242
|
const spentStatus = spentStatuses[i];
|
|
9093
|
-
|
|
9094
|
-
|
|
9243
|
+
const commitmentTxid = spentStatus?.txid || commitmentByOutpoint.get(`${tx.txid}:${i}`);
|
|
9244
|
+
const spent = Boolean(spentStatus?.spent) || commitmentTxid !== void 0;
|
|
9245
|
+
if (spent && commitmentTxid) {
|
|
9246
|
+
commitmentsToIgnore.add(commitmentTxid);
|
|
9095
9247
|
}
|
|
9096
9248
|
utxos.push({
|
|
9097
9249
|
txid: tx.txid,
|
|
@@ -9103,8 +9255,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
9103
9255
|
},
|
|
9104
9256
|
isUnrolled: true,
|
|
9105
9257
|
virtualStatus: {
|
|
9106
|
-
state:
|
|
9107
|
-
commitmentTxIds:
|
|
9258
|
+
state: spent ? "spent" : "settled",
|
|
9259
|
+
commitmentTxIds: spent && commitmentTxid ? [commitmentTxid] : void 0
|
|
9108
9260
|
},
|
|
9109
9261
|
createdAt: tx.status.confirmed ? new Date(tx.status.block_time * 1e3) : /* @__PURE__ */ new Date(0),
|
|
9110
9262
|
script: scriptHex
|
|
@@ -10526,6 +10678,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
10526
10678
|
settlementPsbt = await this._signerRouter.sign(settlementPsbt, [
|
|
10527
10679
|
{ index: i, lookupScript: script }
|
|
10528
10680
|
]);
|
|
10681
|
+
if (!settlementPsbt.getInput(i).tapScriptSig?.length) {
|
|
10682
|
+
throw new Error(await this.unsignableBoardingInputError(input, script));
|
|
10683
|
+
}
|
|
10529
10684
|
hasBoardingUtxos = true;
|
|
10530
10685
|
break;
|
|
10531
10686
|
}
|
|
@@ -10590,6 +10745,24 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
10590
10745
|
);
|
|
10591
10746
|
}
|
|
10592
10747
|
}
|
|
10748
|
+
// Best-effort: every enrichment is guarded so a secondary failure can't
|
|
10749
|
+
// mask the original signing error.
|
|
10750
|
+
async unsignableBoardingInputError(input, script) {
|
|
10751
|
+
const scriptHex = hex.encode(script);
|
|
10752
|
+
let unresolvedAddress = "<undecodable>";
|
|
10753
|
+
try {
|
|
10754
|
+
unresolvedAddress = Address(this.network).encode(OutScript.decode(script));
|
|
10755
|
+
} catch {
|
|
10756
|
+
}
|
|
10757
|
+
let recognized = "<unavailable>";
|
|
10758
|
+
try {
|
|
10759
|
+
const current = await this.getBoardingAddress();
|
|
10760
|
+
const all = await this.getBoardingAddresses();
|
|
10761
|
+
recognized = `current=${current}; all=[${all.join(", ")}]`;
|
|
10762
|
+
} catch {
|
|
10763
|
+
}
|
|
10764
|
+
return `failed to sign boarding input ${input.txid}:${input.vout}: signer did not recognize script ${scriptHex} (${unresolvedAddress}); would have reached arkd unsigned and been rejected as "not a wallet script". Recognized boarding addresses: ${recognized}. Likely a rotated boarding address with a missing contract row.`;
|
|
10765
|
+
}
|
|
10593
10766
|
/**
|
|
10594
10767
|
* Create a batch event handler for settlement flows.
|
|
10595
10768
|
*
|
|
@@ -11517,9 +11690,15 @@ async function waitForIncomingFunds(wallet) {
|
|
|
11517
11690
|
|
|
11518
11691
|
// src/worker/errors.ts
|
|
11519
11692
|
var MESSAGE_BUS_NOT_INITIALIZED = "MessageBus not initialized";
|
|
11693
|
+
var MESSAGE_BUS_INITIALIZING = `${MESSAGE_BUS_NOT_INITIALIZED}: initializing`;
|
|
11520
11694
|
var MessageBusNotInitializedError = class extends Error {
|
|
11695
|
+
constructor(message = MESSAGE_BUS_NOT_INITIALIZED) {
|
|
11696
|
+
super(message);
|
|
11697
|
+
}
|
|
11698
|
+
};
|
|
11699
|
+
var MessageBusInitializingError = class extends MessageBusNotInitializedError {
|
|
11521
11700
|
constructor() {
|
|
11522
|
-
super(
|
|
11701
|
+
super(MESSAGE_BUS_INITIALIZING);
|
|
11523
11702
|
}
|
|
11524
11703
|
};
|
|
11525
11704
|
var ServiceWorkerTimeoutError = class extends Error {
|
|
@@ -11561,6 +11740,16 @@ var MessageBus = class {
|
|
|
11561
11740
|
tickInProgress = false;
|
|
11562
11741
|
debug = false;
|
|
11563
11742
|
initialized = false;
|
|
11743
|
+
/**
|
|
11744
|
+
* FIFO chain that serializes `INITIALIZE_MESSAGE_BUS` handling. Each init
|
|
11745
|
+
* runs to completion in enqueue order.
|
|
11746
|
+
*/
|
|
11747
|
+
initChain = Promise.resolve();
|
|
11748
|
+
/**
|
|
11749
|
+
* Number of inits accepted but not yet settled (queued or running). The
|
|
11750
|
+
* bus refuses ordinary wallet messages while this is > 0.
|
|
11751
|
+
*/
|
|
11752
|
+
pendingInitCount = 0;
|
|
11564
11753
|
buildServicesFn;
|
|
11565
11754
|
boundOnMessage = this.onMessage.bind(this);
|
|
11566
11755
|
/** Start the message bus and attach service-worker event listeners. */
|
|
@@ -11606,11 +11795,12 @@ var MessageBus = class {
|
|
|
11606
11795
|
async runTick() {
|
|
11607
11796
|
if (!this.running) return;
|
|
11608
11797
|
if (this.tickInProgress) return;
|
|
11609
|
-
this.tickInProgress = true;
|
|
11610
11798
|
if (this.tickTimeout !== null) {
|
|
11611
11799
|
self.clearTimeout(this.tickTimeout);
|
|
11612
11800
|
this.tickTimeout = null;
|
|
11613
11801
|
}
|
|
11802
|
+
if (this.pendingInitCount > 0) return;
|
|
11803
|
+
this.tickInProgress = true;
|
|
11614
11804
|
try {
|
|
11615
11805
|
const now = Date.now();
|
|
11616
11806
|
for (const updater of this.handlers.values()) {
|
|
@@ -11644,7 +11834,34 @@ var MessageBus = class {
|
|
|
11644
11834
|
this.scheduleNextTick();
|
|
11645
11835
|
}
|
|
11646
11836
|
}
|
|
11647
|
-
|
|
11837
|
+
/**
|
|
11838
|
+
* Serialize init requests on {@link initChain}.
|
|
11839
|
+
* Returns this init's own result.
|
|
11840
|
+
*/
|
|
11841
|
+
waitForInit(config) {
|
|
11842
|
+
this.pendingInitCount += 1;
|
|
11843
|
+
const run = this.initChain.then(
|
|
11844
|
+
() => this.doInit(config),
|
|
11845
|
+
// A rejected init never blocks the next request.
|
|
11846
|
+
() => this.doInit(config)
|
|
11847
|
+
).finally(() => {
|
|
11848
|
+
this.pendingInitCount -= 1;
|
|
11849
|
+
});
|
|
11850
|
+
this.initChain = run.catch(() => void 0);
|
|
11851
|
+
return run;
|
|
11852
|
+
}
|
|
11853
|
+
/**
|
|
11854
|
+
* The bus serves ordinary wallet messages only when it is initialized AND
|
|
11855
|
+
* no init is in flight.
|
|
11856
|
+
*/
|
|
11857
|
+
acceptsWalletMessages() {
|
|
11858
|
+
return this.initialized && this.pendingInitCount === 0;
|
|
11859
|
+
}
|
|
11860
|
+
async doInit(config) {
|
|
11861
|
+
if (this.tickTimeout !== null) {
|
|
11862
|
+
self.clearTimeout(this.tickTimeout);
|
|
11863
|
+
this.tickTimeout = null;
|
|
11864
|
+
}
|
|
11648
11865
|
if (this.initialized) {
|
|
11649
11866
|
this.initialized = false;
|
|
11650
11867
|
await Promise.all(
|
|
@@ -11657,11 +11874,20 @@ var MessageBus = class {
|
|
|
11657
11874
|
...config.messageTimeouts ?? {}
|
|
11658
11875
|
};
|
|
11659
11876
|
const services = await this.buildServicesFn(config);
|
|
11660
|
-
|
|
11661
|
-
|
|
11662
|
-
|
|
11663
|
-
|
|
11664
|
-
|
|
11877
|
+
const started = [];
|
|
11878
|
+
try {
|
|
11879
|
+
for (const updater of this.handlers.values()) {
|
|
11880
|
+
if (this.debug) console.log(`Starting updater: ${updater.messageTag}`);
|
|
11881
|
+
await updater.start(services, {
|
|
11882
|
+
walletRepository: this.walletRepository
|
|
11883
|
+
});
|
|
11884
|
+
started.push(updater);
|
|
11885
|
+
}
|
|
11886
|
+
} catch (err) {
|
|
11887
|
+
await Promise.all(started.map((h) => h.stop().catch(() => {
|
|
11888
|
+
})));
|
|
11889
|
+
this.initialized = false;
|
|
11890
|
+
throw err;
|
|
11665
11891
|
}
|
|
11666
11892
|
this.scheduleNextTick();
|
|
11667
11893
|
this.initialized = true;
|
|
@@ -11720,23 +11946,29 @@ var MessageBus = class {
|
|
|
11720
11946
|
if (this.debug) {
|
|
11721
11947
|
console.log("Init Command received");
|
|
11722
11948
|
}
|
|
11723
|
-
|
|
11724
|
-
|
|
11725
|
-
|
|
11726
|
-
|
|
11949
|
+
try {
|
|
11950
|
+
await this.waitForInit(event.data.config);
|
|
11951
|
+
this.deliverResponse(event.source, { id, tag }, { id, tag });
|
|
11952
|
+
if (this.debug) {
|
|
11953
|
+
console.log("MessageBus initialized");
|
|
11954
|
+
}
|
|
11955
|
+
} catch (error) {
|
|
11956
|
+
if (this.debug) console.error("MessageBus init failed", error);
|
|
11957
|
+
this.deliverResponse(event.source, { id, tag, error: toError(error) }, { id, tag });
|
|
11727
11958
|
}
|
|
11728
11959
|
return;
|
|
11729
11960
|
}
|
|
11730
|
-
if (!this.
|
|
11961
|
+
if (!this.acceptsWalletMessages()) {
|
|
11731
11962
|
if (this.debug)
|
|
11732
|
-
console.warn("Event received
|
|
11963
|
+
console.warn("Event received while bus unavailable, dropping", event.data);
|
|
11733
11964
|
const fallbackTag = tag ?? "unknown";
|
|
11965
|
+
const error = this.pendingInitCount > 0 ? new MessageBusInitializingError() : new MessageBusNotInitializedError();
|
|
11734
11966
|
this.deliverResponse(
|
|
11735
11967
|
event.source,
|
|
11736
11968
|
{
|
|
11737
11969
|
id,
|
|
11738
11970
|
tag: fallbackTag,
|
|
11739
|
-
error
|
|
11971
|
+
error
|
|
11740
11972
|
},
|
|
11741
11973
|
{ id, tag: fallbackTag }
|
|
11742
11974
|
);
|
|
@@ -13119,26 +13351,19 @@ var WalletMessageHandler = class {
|
|
|
13119
13351
|
});
|
|
13120
13352
|
return filteredVtxos;
|
|
13121
13353
|
}
|
|
13354
|
+
/** Tear down handler subscriptions, then delegate the full wipe to the wallet. */
|
|
13122
13355
|
async clear() {
|
|
13123
|
-
|
|
13124
|
-
if (
|
|
13356
|
+
const wallet = this.wallet ?? this.readonlyWallet;
|
|
13357
|
+
if (!wallet) return;
|
|
13358
|
+
if (this.incomingFundsSubscription) {
|
|
13359
|
+
this.incomingFundsSubscription();
|
|
13360
|
+
this.incomingFundsSubscription = void 0;
|
|
13361
|
+
}
|
|
13125
13362
|
if (this.contractEventsSubscription) {
|
|
13126
13363
|
this.contractEventsSubscription();
|
|
13127
13364
|
this.contractEventsSubscription = void 0;
|
|
13128
13365
|
}
|
|
13129
|
-
|
|
13130
|
-
if (this.wallet) {
|
|
13131
|
-
await this.wallet.dispose();
|
|
13132
|
-
} else {
|
|
13133
|
-
await this.readonlyWallet.dispose();
|
|
13134
|
-
}
|
|
13135
|
-
} catch (_) {
|
|
13136
|
-
}
|
|
13137
|
-
try {
|
|
13138
|
-
await this.walletRepository?.clear();
|
|
13139
|
-
} catch (_) {
|
|
13140
|
-
console.warn("Failed to clear vtxos from wallet repository");
|
|
13141
|
-
}
|
|
13366
|
+
await wallet.clear();
|
|
13142
13367
|
this.wallet = void 0;
|
|
13143
13368
|
this.readonlyWallet = void 0;
|
|
13144
13369
|
this.arkProvider = void 0;
|
|
@@ -13246,6 +13471,13 @@ var WalletMessageHandler = class {
|
|
|
13246
13471
|
function isMessageBusNotInitializedError(error) {
|
|
13247
13472
|
return error instanceof Error && error.message.includes(MESSAGE_BUS_NOT_INITIALIZED);
|
|
13248
13473
|
}
|
|
13474
|
+
function isMessageBusInitializingError(error) {
|
|
13475
|
+
return error instanceof Error && error.message.includes(MESSAGE_BUS_INITIALIZING);
|
|
13476
|
+
}
|
|
13477
|
+
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
13478
|
+
var INIT_WAIT_BACKOFF_CAP_MS = 2e3;
|
|
13479
|
+
var MAX_INIT_WAITS = 8;
|
|
13480
|
+
var initWaitBackoffMs = (attempt) => Math.min(100 * 2 ** attempt, INIT_WAIT_BACKOFF_CAP_MS);
|
|
13249
13481
|
var DEFAULT_MESSAGE_TIMEOUTS = {
|
|
13250
13482
|
// Fast reads — fail quickly
|
|
13251
13483
|
GET_ADDRESS: 1e4,
|
|
@@ -13422,6 +13654,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
13422
13654
|
walletRepository;
|
|
13423
13655
|
contractRepository;
|
|
13424
13656
|
identity;
|
|
13657
|
+
activity = createDefaultActivityRegistry();
|
|
13425
13658
|
_readonlyAssetManager;
|
|
13426
13659
|
initConfig = null;
|
|
13427
13660
|
initWalletPayload = null;
|
|
@@ -13514,6 +13747,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
13514
13747
|
wallet.initWalletPayload = initWalletPayload;
|
|
13515
13748
|
wallet.messageBusTimeoutMs = options.messageBusTimeoutMs;
|
|
13516
13749
|
wallet.messageTimeouts = messageTimeouts;
|
|
13750
|
+
await wallet.assertWorkerIdentityMatches();
|
|
13517
13751
|
return wallet;
|
|
13518
13752
|
}
|
|
13519
13753
|
/**
|
|
@@ -13645,7 +13879,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
13645
13879
|
}
|
|
13646
13880
|
// send a message, retrying up to 2 times if the service worker was
|
|
13647
13881
|
// killed and restarted by the OS (mobile browsers do this aggressively)
|
|
13648
|
-
async sendMessageWithRetry(request) {
|
|
13882
|
+
async sendMessageWithRetry(request, withEvents) {
|
|
13649
13883
|
if (this.initConfig) {
|
|
13650
13884
|
try {
|
|
13651
13885
|
await this.pingServiceWorker();
|
|
@@ -13655,32 +13889,23 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
13655
13889
|
}
|
|
13656
13890
|
const timeoutMs = this.getTimeoutForRequest(request);
|
|
13657
13891
|
const maxRetries = 2;
|
|
13658
|
-
for (let attempt = 0; ; attempt++) {
|
|
13892
|
+
for (let attempt = 0, initWaits = 0; ; attempt++) {
|
|
13659
13893
|
try {
|
|
13894
|
+
if (withEvents) {
|
|
13895
|
+
return await this.sendMessageStreaming(
|
|
13896
|
+
request,
|
|
13897
|
+
withEvents.onEvent,
|
|
13898
|
+
withEvents.isComplete
|
|
13899
|
+
);
|
|
13900
|
+
}
|
|
13660
13901
|
return await this.sendMessageDirect(request, timeoutMs);
|
|
13661
13902
|
} catch (error) {
|
|
13662
|
-
if (
|
|
13663
|
-
throw error;
|
|
13903
|
+
if (isMessageBusInitializingError(error)) {
|
|
13904
|
+
if (initWaits >= MAX_INIT_WAITS) throw error;
|
|
13905
|
+
await sleep(initWaitBackoffMs(initWaits++));
|
|
13906
|
+
attempt--;
|
|
13907
|
+
continue;
|
|
13664
13908
|
}
|
|
13665
|
-
await this.reinitialize();
|
|
13666
|
-
}
|
|
13667
|
-
}
|
|
13668
|
-
}
|
|
13669
|
-
// Like sendMessage but for streaming responses — retries with
|
|
13670
|
-
// reinitialize when the service worker has been killed/restarted.
|
|
13671
|
-
async sendMessageWithEvents(request, onEvent, isComplete) {
|
|
13672
|
-
if (this.initConfig) {
|
|
13673
|
-
try {
|
|
13674
|
-
await this.pingServiceWorker();
|
|
13675
|
-
} catch {
|
|
13676
|
-
await this.reinitialize();
|
|
13677
|
-
}
|
|
13678
|
-
}
|
|
13679
|
-
const maxRetries = 2;
|
|
13680
|
-
for (let attempt = 0; ; attempt++) {
|
|
13681
|
-
try {
|
|
13682
|
-
return await this.sendMessageStreaming(request, onEvent, isComplete);
|
|
13683
|
-
} catch (error) {
|
|
13684
13909
|
if (!isMessageBusNotInitializedError(error) || attempt >= maxRetries) {
|
|
13685
13910
|
throw error;
|
|
13686
13911
|
}
|
|
@@ -13753,24 +13978,48 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
13753
13978
|
payload
|
|
13754
13979
|
};
|
|
13755
13980
|
await this.sendMessageDirect(initMessage, this.getTimeoutForRequest(initMessage));
|
|
13981
|
+
await this.assertWorkerIdentityMatches();
|
|
13756
13982
|
})().finally(() => {
|
|
13757
13983
|
this.reinitPromise = null;
|
|
13758
13984
|
});
|
|
13759
13985
|
return this.reinitPromise;
|
|
13760
13986
|
}
|
|
13761
|
-
/**
|
|
13987
|
+
/**
|
|
13988
|
+
* Verify the worker is bound to this wallet's identity before the SDK hands
|
|
13989
|
+
* back (or recovers) a usable wallet object.
|
|
13990
|
+
*
|
|
13991
|
+
* Compares the stable baseline identity key (`identity.xOnlyPublicKey()`) to the one reported
|
|
13992
|
+
* by the worker via GET_STATUS.
|
|
13993
|
+
*/
|
|
13994
|
+
async assertWorkerIdentityMatches() {
|
|
13995
|
+
const expected = hex.encode(await this.identity.xOnlyPublicKey());
|
|
13996
|
+
const message = {
|
|
13997
|
+
id: getRandomId(),
|
|
13998
|
+
tag: this.messageTag,
|
|
13999
|
+
type: "GET_STATUS"
|
|
14000
|
+
};
|
|
14001
|
+
const response = await this.sendMessageDirect(
|
|
14002
|
+
message,
|
|
14003
|
+
this.getTimeoutForRequest(message)
|
|
14004
|
+
);
|
|
14005
|
+
const workerKey = response.payload.xOnlyPublicKey;
|
|
14006
|
+
if (!workerKey) {
|
|
14007
|
+
throw new Error("Service worker identity mismatch: worker did not report an identity");
|
|
14008
|
+
}
|
|
14009
|
+
const actual = hex.encode(workerKey);
|
|
14010
|
+
if (actual !== expected) {
|
|
14011
|
+
throw new Error(
|
|
14012
|
+
`Service worker identity mismatch: expected ${expected}, got ${actual}`
|
|
14013
|
+
);
|
|
14014
|
+
}
|
|
14015
|
+
}
|
|
14016
|
+
/** This tells the service worker to wipe all locally persisted wallet data. */
|
|
13762
14017
|
async clear() {
|
|
13763
14018
|
const message = {
|
|
13764
14019
|
id: getRandomId(),
|
|
13765
14020
|
tag: this.messageTag,
|
|
13766
14021
|
type: "CLEAR"
|
|
13767
14022
|
};
|
|
13768
|
-
try {
|
|
13769
|
-
const address = await this.getAddress();
|
|
13770
|
-
await this.walletRepository.deleteVtxos(address);
|
|
13771
|
-
} catch (_) {
|
|
13772
|
-
console.warn("Failed to clear vtxos from wallet repository");
|
|
13773
|
-
}
|
|
13774
14023
|
await this.sendMessage(message);
|
|
13775
14024
|
}
|
|
13776
14025
|
async getAddress() {
|
|
@@ -13843,6 +14092,9 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
13843
14092
|
throw new Error(`Failed to get status: ${error}`);
|
|
13844
14093
|
}
|
|
13845
14094
|
}
|
|
14095
|
+
async getActivityHistory() {
|
|
14096
|
+
return buildActivities(await this.getTransactionHistory(), this.activity.all());
|
|
14097
|
+
}
|
|
13846
14098
|
async getTransactionHistory() {
|
|
13847
14099
|
const message = {
|
|
13848
14100
|
id: getRandomId(),
|
|
@@ -14178,6 +14430,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
14178
14430
|
wallet.initWalletPayload = initWalletPayload;
|
|
14179
14431
|
wallet.messageBusTimeoutMs = options.messageBusTimeoutMs;
|
|
14180
14432
|
wallet.messageTimeouts = messageTimeouts;
|
|
14433
|
+
await wallet.assertWorkerIdentityMatches();
|
|
14181
14434
|
return wallet;
|
|
14182
14435
|
}
|
|
14183
14436
|
/**
|
|
@@ -14225,11 +14478,10 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
14225
14478
|
payload: { params }
|
|
14226
14479
|
};
|
|
14227
14480
|
try {
|
|
14228
|
-
const response = await this.
|
|
14229
|
-
|
|
14230
|
-
(resp) =>
|
|
14231
|
-
|
|
14232
|
-
);
|
|
14481
|
+
const response = await this.sendMessageWithRetry(message, {
|
|
14482
|
+
onEvent: (resp) => callback?.(resp.payload),
|
|
14483
|
+
isComplete: (resp) => resp.type === "SETTLE_SUCCESS"
|
|
14484
|
+
});
|
|
14233
14485
|
return response.payload.txid;
|
|
14234
14486
|
} catch (error) {
|
|
14235
14487
|
throw new Error(`Settlement failed: ${error}`);
|
|
@@ -14254,12 +14506,11 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
14254
14506
|
payload: opts ?? {}
|
|
14255
14507
|
};
|
|
14256
14508
|
try {
|
|
14257
|
-
await this.
|
|
14258
|
-
|
|
14259
|
-
() => {
|
|
14509
|
+
await this.sendMessageWithRetry(message, {
|
|
14510
|
+
onEvent: () => {
|
|
14260
14511
|
},
|
|
14261
|
-
(resp) => resp.type === "RESTORE_WALLET_SUCCESS"
|
|
14262
|
-
);
|
|
14512
|
+
isComplete: (resp) => resp.type === "RESTORE_WALLET_SUCCESS"
|
|
14513
|
+
});
|
|
14263
14514
|
} catch (error) {
|
|
14264
14515
|
if (isSerializedAggregateError(error)) {
|
|
14265
14516
|
throw deserializeAggregateError(error);
|
|
@@ -14347,11 +14598,10 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
14347
14598
|
id: getRandomId()
|
|
14348
14599
|
};
|
|
14349
14600
|
try {
|
|
14350
|
-
const response = await wallet.
|
|
14351
|
-
|
|
14352
|
-
(resp) =>
|
|
14353
|
-
|
|
14354
|
-
);
|
|
14601
|
+
const response = await wallet.sendMessageWithRetry(message, {
|
|
14602
|
+
onEvent: (resp) => eventCallback?.(resp.payload),
|
|
14603
|
+
isComplete: (resp) => resp.type === "RECOVER_VTXOS_SUCCESS"
|
|
14604
|
+
});
|
|
14355
14605
|
return response.payload.txid;
|
|
14356
14606
|
} catch (e) {
|
|
14357
14607
|
throw new Error(`Failed to recover vtxos: ${e}`);
|
|
@@ -14398,11 +14648,10 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
14398
14648
|
payload: options
|
|
14399
14649
|
};
|
|
14400
14650
|
try {
|
|
14401
|
-
const response = await wallet.
|
|
14402
|
-
|
|
14403
|
-
(resp) =>
|
|
14404
|
-
|
|
14405
|
-
);
|
|
14651
|
+
const response = await wallet.sendMessageWithRetry(message, {
|
|
14652
|
+
onEvent: (resp) => eventCallback?.(resp.payload),
|
|
14653
|
+
isComplete: (resp) => resp.type === "RENEW_VTXOS_SUCCESS"
|
|
14654
|
+
});
|
|
14406
14655
|
return response.payload.txid;
|
|
14407
14656
|
} catch (e) {
|
|
14408
14657
|
throw new Error(`Failed to renew vtxos: ${e}`);
|
|
@@ -14441,13 +14690,12 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
14441
14690
|
id: getRandomId()
|
|
14442
14691
|
};
|
|
14443
14692
|
try {
|
|
14444
|
-
const response = await wallet.
|
|
14445
|
-
|
|
14446
|
-
(resp) => options?.eventCallback?.(
|
|
14693
|
+
const response = await wallet.sendMessageWithRetry(message, {
|
|
14694
|
+
onEvent: (resp) => options?.eventCallback?.(
|
|
14447
14695
|
resp.payload
|
|
14448
14696
|
),
|
|
14449
|
-
(resp) => resp.type === "MIGRATE_DEPRECATED_SIGNER_VTXOS_SUCCESS"
|
|
14450
|
-
);
|
|
14697
|
+
isComplete: (resp) => resp.type === "MIGRATE_DEPRECATED_SIGNER_VTXOS_SUCCESS"
|
|
14698
|
+
});
|
|
14451
14699
|
return deserializeMigrationReport(
|
|
14452
14700
|
response.payload.report
|
|
14453
14701
|
);
|
|
@@ -15383,12 +15631,15 @@ function errorText(err) {
|
|
|
15383
15631
|
}
|
|
15384
15632
|
return "";
|
|
15385
15633
|
}
|
|
15634
|
+
function normalizedErrorText(err) {
|
|
15635
|
+
return errorText(err).toLowerCase().replace(/\s+/g, "");
|
|
15636
|
+
}
|
|
15386
15637
|
function isMissingHeightError(err) {
|
|
15387
|
-
return
|
|
15638
|
+
return normalizedErrorText(err).includes("missingheight");
|
|
15388
15639
|
}
|
|
15389
15640
|
function isTxNotInBlockError(err) {
|
|
15390
|
-
const normalized =
|
|
15391
|
-
return normalized.includes("
|
|
15641
|
+
const normalized = normalizedErrorText(err);
|
|
15642
|
+
return normalized.includes("notyetinablock") || normalized.includes("notinablock") || normalized.includes("notinblock") || normalized.includes("noconfirmedtransaction");
|
|
15392
15643
|
}
|
|
15393
15644
|
function childTxidFromHex(txHex) {
|
|
15394
15645
|
const tx = Transaction$2.fromRaw(hex.decode(txHex), {
|
|
@@ -15659,7 +15910,7 @@ var Unroll;
|
|
|
15659
15910
|
let lastStep;
|
|
15660
15911
|
do {
|
|
15661
15912
|
if (lastStep !== void 0) {
|
|
15662
|
-
await
|
|
15913
|
+
await sleep2(1e3);
|
|
15663
15914
|
}
|
|
15664
15915
|
const step = await this.next();
|
|
15665
15916
|
await step.do();
|
|
@@ -15749,7 +16000,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
15749
16000
|
signedTx.finalize();
|
|
15750
16001
|
return signedTx;
|
|
15751
16002
|
}
|
|
15752
|
-
function
|
|
16003
|
+
function sleep2(ms) {
|
|
15753
16004
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
15754
16005
|
}
|
|
15755
16006
|
function doUnroll(onchainProvider, pkg) {
|
|
@@ -15847,6 +16098,6 @@ function isArkContract(str) {
|
|
|
15847
16098
|
return str.startsWith(ARKCONTRACT_PREFIX + "=");
|
|
15848
16099
|
}
|
|
15849
16100
|
|
|
15850
|
-
export { ArkNote, AssetManager, BIP322, Batch, ContractManager, ContractRepositoryImpl, ContractWatcher, DB_VERSION, DEFAULT_MESSAGE_TIMEOUTS, DelegateManagerImpl, DelegateNotConfiguredError, DelegatorManagerImpl, DelegatorNotConfiguredError, DescriptorSigningProviderMissingError, DustChangeError, ELECTRUM_TCP_HOST, ELECTRUM_WS_URL, ESPLORA_URL, ElectrumOnchainProvider, EsploraProvider, Estimator, HDDescriptorProvider, InMemoryContractRepository, InMemoryWalletRepository, IndexedDBContractRepository, IndexedDBWalletRepository, MESSAGE_BUS_NOT_INITIALIZED, MIGRATION_KEY, MessageBus, MessageBusNotInitializedError, MissingSigningDescriptorError, MnemonicIdentity, OnchainWallet, P2A, Ramps, ReadonlyAssetManager, ReadonlyDescriptorIdentity, ReadonlySingleKey, ReadonlyWallet, ReadonlyWalletError, RestDelegateProvider, RestDelegatorProvider, SeedIdentity, ServiceWorkerReadonlyWallet, ServiceWorkerTimeoutError, ServiceWorkerWallet, SingleKey, TxTree, TxType, TxWeightEstimator, Unroll, VtxoManager, Wallet2 as Wallet, WalletMessageHandler, WalletNotInitializedError, WalletRepositoryImpl, WsElectrumChainSource, buildForfeitTx, buildOffchainTx, classifyAgainstSignerSet, classifyContractSigner, closeDatabase, combineTapscriptSigs, contractFromArkContract, contractFromArkContractWithAddress, decodeArkContract, deserializeAssets, deserializeUtxo, deserializeVtxo, encodeArkContract, extendVirtualCoinForContract, getMigrationStatus, getRandomId, hasBoardingTxExpired, isArkContract, isBatchSignable, isCooperativelyMigratable, isDiscoverable, isExpired, isRecoverable, isSpendable, isSubdust, isValidArkAddress, isVtxoExpiringSoon, isVtxoForScript, migrateWalletRepository, openDatabase, requiresMigration, rollbackMigration, saveVtxosForContract, scriptFromArkAddress, serializeAssets, serializeUtxo, serializeVtxo, setupServiceWorker, signerSetFromInfo, toXOnlySignerHex, validateConnectorsTxGraph, validateVtxoTxGraph, verifyTapscriptSignatures, waitForIncomingFunds, warnAndFilterVtxosForScript };
|
|
15851
|
-
//# sourceMappingURL=chunk-
|
|
15852
|
-
//# sourceMappingURL=chunk-
|
|
16101
|
+
export { ActivityRegistry, ArkNote, AssetManager, BIP322, Batch, ContractManager, ContractRepositoryImpl, ContractWatcher, DB_VERSION, DEFAULT_MESSAGE_TIMEOUTS, DelegateManagerImpl, DelegateNotConfiguredError, DelegatorManagerImpl, DelegatorNotConfiguredError, DescriptorSigningProviderMissingError, DustChangeError, ELECTRUM_TCP_HOST, ELECTRUM_WS_URL, ESPLORA_URL, ElectrumOnchainProvider, EsploraProvider, Estimator, HDDescriptorProvider, InMemoryContractRepository, InMemoryWalletRepository, IndexedDBContractRepository, IndexedDBWalletRepository, MESSAGE_BUS_INITIALIZING, MESSAGE_BUS_NOT_INITIALIZED, MIGRATION_KEY, MessageBus, MessageBusInitializingError, MessageBusNotInitializedError, MissingSigningDescriptorError, MnemonicIdentity, OnchainWallet, P2A, Ramps, ReadonlyAssetManager, ReadonlyDescriptorIdentity, ReadonlySingleKey, ReadonlyWallet, ReadonlyWalletError, RestDelegateProvider, RestDelegatorProvider, SeedIdentity, ServiceWorkerReadonlyWallet, ServiceWorkerTimeoutError, ServiceWorkerWallet, SingleKey, TxTree, TxType, TxWeightEstimator, Unroll, VtxoManager, Wallet2 as Wallet, WalletMessageHandler, WalletNotInitializedError, WalletRepositoryImpl, WsElectrumChainSource, boardingResolver, buildForfeitTx, buildOffchainTx, classifyAgainstSignerSet, classifyContractSigner, closeDatabase, combineTapscriptSigs, contractFromArkContract, contractFromArkContractWithAddress, createDefaultActivityRegistry, decodeArkContract, deserializeAssets, deserializeUtxo, deserializeVtxo, encodeArkContract, extendVirtualCoinForContract, getMigrationStatus, getRandomId, hasBoardingTxExpired, isArkContract, isBatchSignable, isCooperativelyMigratable, isDiscoverable, isExpired, isRecoverable, isSpendable, isSubdust, isValidArkAddress, isVtxoExpiringSoon, isVtxoForScript, migrateWalletRepository, openDatabase, requiresMigration, rollbackMigration, saveVtxosForContract, scriptFromArkAddress, serializeAssets, serializeUtxo, serializeVtxo, setupServiceWorker, signerSetFromInfo, toXOnlySignerHex, validateConnectorsTxGraph, validateVtxoTxGraph, verifyTapscriptSignatures, waitForIncomingFunds, warnAndFilterVtxosForScript };
|
|
16102
|
+
//# sourceMappingURL=chunk-D5MQYYYF.js.map
|
|
16103
|
+
//# sourceMappingURL=chunk-D5MQYYYF.js.map
|