@arkade-os/sdk 0.4.76 → 0.4.77
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/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 +3 -5
- package/dist/adapters/indexedDB.cjs.map +1 -1
- package/dist/adapters/indexedDB.d.cts +1 -1
- package/dist/adapters/indexedDB.d.ts +1 -1
- package/dist/adapters/indexedDB.js +3 -5
- package/dist/adapters/indexedDB.js.map +1 -1
- package/dist/{asyncStorageTaskQueue-DrKbfleJ.d.ts → asyncStorageTaskQueue-DTl0WM7E.d.ts} +1 -1
- package/dist/{asyncStorageTaskQueue-D7BU-BdP.d.cts → asyncStorageTaskQueue-MmJyAnu-.d.cts} +1 -1
- package/dist/{chunk-2KFXM3N5.cjs → chunk-4LP6XOMW.cjs} +17 -17
- package/dist/{chunk-2KFXM3N5.cjs.map → chunk-4LP6XOMW.cjs.map} +1 -1
- package/dist/{chunk-F6YOCYWU.js → chunk-52OA3UIC.js} +25 -12
- package/dist/chunk-52OA3UIC.js.map +1 -0
- package/dist/{chunk-7UJLIZQU.js → chunk-ACPANSOX.js} +43 -11
- package/dist/chunk-ACPANSOX.js.map +1 -0
- package/dist/{chunk-P53OHGXY.cjs → chunk-CJN4CUEU.cjs} +25 -11
- package/dist/chunk-CJN4CUEU.cjs.map +1 -0
- package/dist/{chunk-T327OEMV.cjs → chunk-H62OOAS4.cjs} +17 -17
- package/dist/{chunk-T327OEMV.cjs.map → chunk-H62OOAS4.cjs.map} +1 -1
- package/dist/{chunk-54W6QBXL.js → chunk-HKOFYHZP.js} +3 -3
- package/dist/{chunk-54W6QBXL.js.map → chunk-HKOFYHZP.js.map} +1 -1
- package/dist/{chunk-CQNX4BTA.cjs → chunk-LUWSY2QO.cjs} +89 -57
- package/dist/chunk-LUWSY2QO.cjs.map +1 -0
- package/dist/{chunk-WMHELOHH.js → chunk-MLOZHTBN.js} +523 -104
- package/dist/chunk-MLOZHTBN.js.map +1 -0
- package/dist/{chunk-O2BIWLZC.js → chunk-T6MGH4V4.js} +4 -4
- package/dist/{chunk-O2BIWLZC.js.map → chunk-T6MGH4V4.js.map} +1 -1
- package/dist/{chunk-LQM6RHNT.cjs → chunk-Y4YK44IM.cjs} +10 -10
- package/dist/{chunk-LQM6RHNT.cjs.map → chunk-Y4YK44IM.cjs.map} +1 -1
- package/dist/{chunk-LHSVPDFJ.cjs → chunk-YJEWWLOQ.cjs} +959 -541
- package/dist/chunk-YJEWWLOQ.cjs.map +1 -0
- package/dist/{chunk-MUBPGYUE.js → chunk-YKNTUOUG.js} +4 -4
- package/dist/{chunk-MUBPGYUE.js.map → chunk-YKNTUOUG.js.map} +1 -1
- package/dist/contracts/handlers/index.cjs +9 -9
- 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-BAYpqkEx.d.ts → delegate-CjcysR7s.d.ts} +1 -1
- package/dist/{delegate-CR7msIXK.d.cts → delegate-QPCGaD_z.d.cts} +1 -1
- package/dist/{hdWalletCapable-BSF29IjK.d.ts → hdWalletCapable--pMncWbC.d.ts} +6 -4
- package/dist/{hdWalletCapable-BbZxCUeZ.d.cts → hdWalletCapable-Bp_p0WLj.d.cts} +6 -4
- package/dist/{index-4NF3srcg.d.cts → index-BMY272ns.d.cts} +26 -8
- package/dist/{index-B_RYn9rg.d.cts → index-Ie_ak2zY.d.cts} +35 -9
- package/dist/{index-B_RYn9rg.d.ts → index-Ie_ak2zY.d.ts} +35 -9
- package/dist/{index-Dj2yOhQ2.d.ts → index-m-EM-e8D.d.ts} +26 -8
- package/dist/index.cjs +307 -303
- package/dist/index.d.cts +75 -13
- package/dist/index.d.ts +75 -13
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +36 -19
- package/dist/repositories/realm/index.cjs.map +1 -1
- package/dist/repositories/realm/index.d.cts +6 -3
- package/dist/repositories/realm/index.d.ts +6 -3
- package/dist/repositories/realm/index.js +22 -5
- package/dist/repositories/realm/index.js.map +1 -1
- package/dist/repositories/sqlite/index.cjs +42 -18
- package/dist/repositories/sqlite/index.cjs.map +1 -1
- package/dist/repositories/sqlite/index.d.cts +5 -2
- package/dist/repositories/sqlite/index.d.ts +5 -2
- package/dist/repositories/sqlite/index.js +29 -5
- package/dist/repositories/sqlite/index.js.map +1 -1
- package/dist/{taskRunner-DGxde-YU.d.cts → taskRunner-BgRowCqB.d.cts} +1 -1
- package/dist/{taskRunner-TzGUhxP-.d.ts → taskRunner-CqrlrJEt.d.ts} +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 +14 -14
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +5 -5
- package/dist/wallet/expo/index.d.ts +5 -5
- package/dist/wallet/expo/index.js +5 -5
- package/dist/wallet/expo/index.js.map +1 -1
- 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-7UJLIZQU.js.map +0 -1
- package/dist/chunk-CQNX4BTA.cjs.map +0 -1
- package/dist/chunk-F6YOCYWU.js.map +0 -1
- package/dist/chunk-LHSVPDFJ.cjs.map +0 -1
- package/dist/chunk-P53OHGXY.cjs.map +0 -1
- package/dist/chunk-WMHELOHH.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AssetId, AssetGroup, AssetInput, AssetOutput, Metadata, Packet, BufferReader, BufferWriter, AssetRef, RestIndexerProvider } from './chunk-
|
|
2
|
-
import { witnessRefToBytes, validateProgram, toASM, stringifyArtifact, serializeArkadeContractParams, resolveAsm, parseArtifact, getOpcodeValue, getOpcodeName, fromASM, deserializeArkadeContractParams, computeArkadeScriptPublicKey, bytesToASM, asmToBytes, arkadeWitnessHash, arkadeScriptHash, SUPPORTED_PROGRAM_VERSION, OPCODE_VALUES, OPCODE_NAMES, bignum_exports, ArkadeScript, ArkadeProgramScript, ARKADE_OPS, ARKADE_OPCODE_VALUES, ARKADE_OPCODE_NAMES, ARKADE_OPCODES, ARKADE_OP, toXOnly, inputName, contractHandlers, isMainnetDescriptor, descriptorIsOurs, deriveDescriptorLeafPubKey, deriveDescriptorLeafCompressedPubKey, parseHDDescriptor, identityDescriptor, DefaultVtxo, speculativeReceiveMetadata, DelegateVtxo, WALLET_RECEIVE_SOURCE, BoardingContractHandler } from './chunk-
|
|
3
|
-
import { VtxoScript, Transaction, isRecoverable, CSVMultisigTapscript, networks, getNetwork, DEFAULT_NETWORK, resolveEmulatorPubkey,
|
|
1
|
+
import { AssetId, AssetGroup, AssetInput, AssetOutput, Metadata, Packet, BufferReader, BufferWriter, AssetRef, RestIndexerProvider } from './chunk-HKOFYHZP.js';
|
|
2
|
+
import { witnessRefToBytes, validateProgram, toASM, stringifyArtifact, serializeArkadeContractParams, resolveAsm, parseArtifact, getOpcodeValue, getOpcodeName, fromASM, deserializeArkadeContractParams, computeArkadeScriptPublicKey, bytesToASM, asmToBytes, arkadeWitnessHash, arkadeScriptHash, SUPPORTED_PROGRAM_VERSION, OPCODE_VALUES, OPCODE_NAMES, bignum_exports, ArkadeScript, ArkadeProgramScript, ARKADE_OPS, ARKADE_OPCODE_VALUES, ARKADE_OPCODE_NAMES, ARKADE_OPCODES, ARKADE_OP, toXOnly, inputName, contractHandlers, isMainnetDescriptor, descriptorIsOurs, deriveDescriptorLeafPubKey, deriveDescriptorLeafCompressedPubKey, parseHDDescriptor, identityDescriptor, DefaultVtxo, speculativeReceiveMetadata, DelegateVtxo, WALLET_RECEIVE_SOURCE, BoardingContractHandler } from './chunk-ACPANSOX.js';
|
|
3
|
+
import { VtxoScript, Transaction, isRecoverable, CSVMultisigTapscript, networks, getNetwork, DEFAULT_NETWORK, resolveEmulatorPubkey, isVtxoSpent, getNormalizedVtxos, setArkPsbtField, PrevArkTxField, ConditionWitness, craftToSpendTx, ArkAddress, isVirtualCoin, getArkPsbtFields, CosignerPublicKey, ServerResponseMismatchError, OP_RETURN_EMPTY_PKSCRIPT, canSweepOnchain, sequenceToTimelock, decodeTapscript, scriptFromTapLeafScript, CLTVMultisigTapscript, VtxoTaprootTree, timelockToSequence, assertAllowedSighashTypes, baseFetch, Intent, rateGate, DEFAULT_NETWORK_NAME, formatSighash, normalizeVtxo, getSequence, toBatchExpiry, maybeArkError, isArkError, ArkErrorName, toOffchainInputFeeParams, canRecoverOnchain, MultisigTapscript, isEventSourceError, isEventSourceUnavailableError, getAllNormalizedVtxos, isPastExpiry, isRetryableProviderError, DEFAULT_PAGE_SIZE, RestArkProvider, toVirtualStatus, ArkError, TapTreeCoder, resolveTimeHeight, canSpendOffchain, parseLegacyExpiry, isExpired, PrevoutTxField, fetchVtxoCreatedAtByTxid, DEFAULT_ARKADE_SERVER_URL, ProviderUnavailableError } from './chunk-52OA3UIC.js';
|
|
4
4
|
import { __export } from './chunk-NSBPE2FW.js';
|
|
5
5
|
import { sha256 as sha256$1, equalBytes, hash160, sha256x2, concatBytes, randomPrivateKeyBytes, pubECDSA, pubSchnorr } from '@scure/btc-signer/utils.js';
|
|
6
6
|
import { SigHash, Script, OP, OutScript, Address, RawWitness, p2tr, p2wpkh, TaprootControlBlock, DEFAULT_SEQUENCE, Transaction as Transaction$2 } from '@scure/btc-signer';
|
|
@@ -1334,7 +1334,7 @@ async function provisionClaimSecret(wallet, opts = {}) {
|
|
|
1334
1334
|
const descriptor = await provisionDescriptor(wallet);
|
|
1335
1335
|
const signer = await contractSigner(wallet, descriptor);
|
|
1336
1336
|
const pubkey = await signer.xOnlyPublicKey();
|
|
1337
|
-
const
|
|
1337
|
+
const claim2 = async () => {
|
|
1338
1338
|
if (opts.preimage) return { preimage: opts.preimage, mustPersistPreimage: true };
|
|
1339
1339
|
if (isPerArtifactDescriptor(descriptor)) {
|
|
1340
1340
|
return {
|
|
@@ -1356,7 +1356,7 @@ async function provisionClaimSecret(wallet, opts = {}) {
|
|
|
1356
1356
|
return { preimage: randomBytes(32), mustPersistPreimage: true };
|
|
1357
1357
|
}
|
|
1358
1358
|
};
|
|
1359
|
-
const { preimage, preimageSalt, mustPersistPreimage } = await
|
|
1359
|
+
const { preimage, preimageSalt, mustPersistPreimage } = await claim2();
|
|
1360
1360
|
return {
|
|
1361
1361
|
descriptor,
|
|
1362
1362
|
pubkey,
|
|
@@ -4128,7 +4128,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
|
|
|
4128
4128
|
continue;
|
|
4129
4129
|
}
|
|
4130
4130
|
for (const v of vtxos) {
|
|
4131
|
-
if (!
|
|
4131
|
+
if (!isVtxoSpent(v) && !v.isSwept && !v.isUnrolled) {
|
|
4132
4132
|
out.add(`${v.txid}:${v.vout}`);
|
|
4133
4133
|
}
|
|
4134
4134
|
}
|
|
@@ -4655,7 +4655,10 @@ var VtxoManager = class _VtxoManager {
|
|
|
4655
4655
|
if (this.settlementConfig === false && thresholdMs === void 0) {
|
|
4656
4656
|
return [];
|
|
4657
4657
|
}
|
|
4658
|
-
const vtxos = await this.wallet.getSpendableVtxos({
|
|
4658
|
+
const vtxos = await this.wallet.getSpendableVtxos({
|
|
4659
|
+
withRecoverable: true,
|
|
4660
|
+
genericallySpendableOnly: true
|
|
4661
|
+
});
|
|
4659
4662
|
let threshold;
|
|
4660
4663
|
if (thresholdMs !== void 0) {
|
|
4661
4664
|
threshold = thresholdMs;
|
|
@@ -5152,8 +5155,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
5152
5155
|
const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
|
|
5153
5156
|
if (cls.status === "CURRENT") continue;
|
|
5154
5157
|
const live = vtxos.filter((v) => !v.isUnrolled);
|
|
5155
|
-
const recoverable = live.filter((v) => v.isSwept && !
|
|
5156
|
-
const spendable = live.filter((v) => !
|
|
5158
|
+
const recoverable = live.filter((v) => v.isSwept && !isVtxoSpent(v));
|
|
5159
|
+
const spendable = live.filter((v) => !isVtxoSpent(v) && !v.isSwept);
|
|
5157
5160
|
const value = spendable.reduce((sum, v) => sum + v.value, 0);
|
|
5158
5161
|
let recoverableCount = 0;
|
|
5159
5162
|
let recoverableValue = 0;
|
|
@@ -7319,7 +7322,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7319
7322
|
}
|
|
7320
7323
|
const metadata = castMetadata(params.metadata);
|
|
7321
7324
|
const virtualCoins = await this.wallet.getSpendableVtxos({
|
|
7322
|
-
withRecoverable: false
|
|
7325
|
+
withRecoverable: false,
|
|
7326
|
+
genericallySpendableOnly: true
|
|
7323
7327
|
});
|
|
7324
7328
|
const controlAssetRef = params.controlAssetId ? AssetRef.fromId(AssetId.fromString(params.controlAssetId)) : null;
|
|
7325
7329
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
@@ -7408,7 +7412,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7408
7412
|
throw new Error(`Asset ${params.assetId} is not reissuable`);
|
|
7409
7413
|
}
|
|
7410
7414
|
const virtualCoins = await this.wallet.getSpendableVtxos({
|
|
7411
|
-
withRecoverable: false
|
|
7415
|
+
withRecoverable: false,
|
|
7416
|
+
genericallySpendableOnly: true
|
|
7412
7417
|
});
|
|
7413
7418
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
7414
7419
|
const { selected: controlCoins } = selectCoinsWithAsset(virtualCoins, controlAssetId, 1n);
|
|
@@ -7514,7 +7519,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7514
7519
|
throw new Error(`Burn amount must be greater than 0, got ${params.amount}`);
|
|
7515
7520
|
}
|
|
7516
7521
|
const virtualCoins = await this.wallet.getSpendableVtxos({
|
|
7517
|
-
withRecoverable: false
|
|
7522
|
+
withRecoverable: false,
|
|
7523
|
+
genericallySpendableOnly: true
|
|
7518
7524
|
});
|
|
7519
7525
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
7520
7526
|
const { selected: assetCoins } = selectCoinsWithAsset(
|
|
@@ -8203,7 +8209,7 @@ var STORE_INTENTS = "intents";
|
|
|
8203
8209
|
var STORE_VIRTUAL_TXS = "virtualTxs";
|
|
8204
8210
|
var STORE_VTXO_BRANCHES = "vtxoBranches";
|
|
8205
8211
|
var LEGACY_STORE_CONTRACT_COLLECTIONS = "contractsCollections";
|
|
8206
|
-
var DB_VERSION =
|
|
8212
|
+
var DB_VERSION = 4;
|
|
8207
8213
|
var INTENT_DB_VERSION = 5;
|
|
8208
8214
|
function initDatabase(db, oldVersion, transaction) {
|
|
8209
8215
|
if (!db.objectStoreNames.contains(STORE_VTXOS)) {
|
|
@@ -8266,6 +8272,7 @@ function initDatabase(db, oldVersion, transaction) {
|
|
|
8266
8272
|
unique: false
|
|
8267
8273
|
});
|
|
8268
8274
|
}
|
|
8275
|
+
vtxosStore.createIndex("scriptUnspent", ["script", "unspent"], { unique: false });
|
|
8269
8276
|
}
|
|
8270
8277
|
if (!db.objectStoreNames.contains(STORE_UTXOS)) {
|
|
8271
8278
|
const utxosStore = db.createObjectStore(STORE_UTXOS, {
|
|
@@ -8348,14 +8355,18 @@ function initDatabase(db, oldVersion, transaction) {
|
|
|
8348
8355
|
keyPath: "key"
|
|
8349
8356
|
});
|
|
8350
8357
|
}
|
|
8351
|
-
if (oldVersion >= 1 && oldVersion <
|
|
8358
|
+
if (oldVersion >= 1 && oldVersion < 4 && transaction) {
|
|
8352
8359
|
const vtxosStore = transaction.objectStore(STORE_VTXOS);
|
|
8353
8360
|
if (!vtxosStore.indexNames.contains("script")) {
|
|
8354
8361
|
vtxosStore.createIndex("script", "script", { unique: false });
|
|
8355
8362
|
}
|
|
8356
|
-
|
|
8363
|
+
if (!vtxosStore.indexNames.contains("scriptUnspent")) {
|
|
8364
|
+
vtxosStore.createIndex("scriptUnspent", ["script", "unspent"], { unique: false });
|
|
8365
|
+
}
|
|
8366
|
+
backfillVtxoIndexFields(transaction);
|
|
8357
8367
|
}
|
|
8358
8368
|
}
|
|
8369
|
+
var unspentFlag = (vtxo) => isVtxoSpent(vtxo) ? {} : { unspent: 1 };
|
|
8359
8370
|
function initDatabaseWithIntents(db, oldVersion, transaction) {
|
|
8360
8371
|
initDatabase(db, oldVersion, transaction);
|
|
8361
8372
|
if (!db.objectStoreNames.contains(STORE_INTENTS)) {
|
|
@@ -8405,19 +8416,28 @@ function dedupeIntentIds(store, onComplete) {
|
|
|
8405
8416
|
cursor.continue();
|
|
8406
8417
|
};
|
|
8407
8418
|
}
|
|
8408
|
-
function
|
|
8419
|
+
function backfillVtxoIndexFields(transaction) {
|
|
8409
8420
|
const store = transaction.objectStore(STORE_VTXOS);
|
|
8410
|
-
const
|
|
8411
|
-
|
|
8412
|
-
const
|
|
8413
|
-
|
|
8414
|
-
|
|
8415
|
-
|
|
8416
|
-
|
|
8417
|
-
|
|
8418
|
-
|
|
8419
|
-
|
|
8421
|
+
const pageSize = 1e3;
|
|
8422
|
+
const readPage = (after) => {
|
|
8423
|
+
const request = store.getAll(after && IDBKeyRange.lowerBound(after, true), pageSize);
|
|
8424
|
+
request.onsuccess = () => {
|
|
8425
|
+
const rows = request.result;
|
|
8426
|
+
for (const value of rows) {
|
|
8427
|
+
const next = {
|
|
8428
|
+
...value,
|
|
8429
|
+
script: value.script || scriptFromArkAddress(value.address),
|
|
8430
|
+
...unspentFlag(value)
|
|
8431
|
+
};
|
|
8432
|
+
if (next.script !== value.script || next.unspent !== value.unspent) {
|
|
8433
|
+
store.put(next);
|
|
8434
|
+
}
|
|
8435
|
+
}
|
|
8436
|
+
const last = rows.at(-1);
|
|
8437
|
+
if (rows.length === pageSize && last) readPage([last.address, last.txid, last.vout]);
|
|
8438
|
+
};
|
|
8420
8439
|
};
|
|
8440
|
+
readPage();
|
|
8421
8441
|
}
|
|
8422
8442
|
|
|
8423
8443
|
// src/worker/browser/utils.ts
|
|
@@ -8776,15 +8796,21 @@ var InMemoryWalletRepository = class {
|
|
|
8776
8796
|
this.vtxosByAddress.delete(address);
|
|
8777
8797
|
}
|
|
8778
8798
|
async getVtxosForScript(script) {
|
|
8779
|
-
|
|
8799
|
+
return this.getVtxosForScripts([script]);
|
|
8800
|
+
}
|
|
8801
|
+
async getVtxosForScripts(scripts, options) {
|
|
8802
|
+
if (scripts.length === 0) return [];
|
|
8803
|
+
const selected = new Set(scripts);
|
|
8804
|
+
const byOutpoint = /* @__PURE__ */ new Map();
|
|
8780
8805
|
for (const bucket of this.vtxosByAddress.values()) {
|
|
8781
8806
|
for (const vtxo of bucket) {
|
|
8782
|
-
if (
|
|
8783
|
-
|
|
8807
|
+
if (vtxo.script && selected.has(vtxo.script)) {
|
|
8808
|
+
byOutpoint.set(`${vtxo.script}:${vtxo.txid}:${vtxo.vout}`, vtxo);
|
|
8784
8809
|
}
|
|
8785
8810
|
}
|
|
8786
8811
|
}
|
|
8787
|
-
|
|
8812
|
+
const rows = [...byOutpoint.values()];
|
|
8813
|
+
return options?.unspentOnly ? rows.filter((vtxo) => !isVtxoSpent(vtxo)) : rows;
|
|
8788
8814
|
}
|
|
8789
8815
|
async saveVtxosForScript(key, vtxos) {
|
|
8790
8816
|
if (!key.address) {
|
|
@@ -9565,7 +9591,7 @@ var ContractWatcher = class {
|
|
|
9565
9591
|
}
|
|
9566
9592
|
if (target === byWatchedScript && eventType === "vtxo_received") {
|
|
9567
9593
|
const n = normalizeVtxo(vtxo);
|
|
9568
|
-
if (
|
|
9594
|
+
if (isVtxoSpent(n) || n.isSwept || isPastExpiry(n, now)) continue;
|
|
9569
9595
|
}
|
|
9570
9596
|
let bucket = target.get(vtxo.script);
|
|
9571
9597
|
if (!bucket) {
|
|
@@ -9664,7 +9690,7 @@ var NON_TERMINAL_INTENT_STATES = ALL_INTENT_STATES.filter(
|
|
|
9664
9690
|
(s) => !isTerminalIntentState(s)
|
|
9665
9691
|
);
|
|
9666
9692
|
function isConsumed(vtxo) {
|
|
9667
|
-
return vtxo !== void 0 &&
|
|
9693
|
+
return vtxo !== void 0 && isVtxoSpent(vtxo);
|
|
9668
9694
|
}
|
|
9669
9695
|
async function classifyIntent(intent, vtxosByOutpoint, now) {
|
|
9670
9696
|
if (isTerminalIntentState(intent.state)) return void 0;
|
|
@@ -10483,9 +10509,15 @@ var ContractManager = class _ContractManager {
|
|
|
10483
10509
|
const dbFilter = this.buildContractsDbFilter(filter ?? {});
|
|
10484
10510
|
return await this.config.contractRepository.getContracts(dbFilter);
|
|
10485
10511
|
}
|
|
10486
|
-
async getContractsWithVtxos(filter, pageSize) {
|
|
10512
|
+
async getContractsWithVtxos(filter, pageSize, options) {
|
|
10513
|
+
if (options?.maxSyncAgeMs !== void 0 && (!Number.isSafeInteger(options.maxSyncAgeMs) || options.maxSyncAgeMs < 0)) {
|
|
10514
|
+
throw new Error("maxSyncAgeMs must be a non-negative safe integer");
|
|
10515
|
+
}
|
|
10487
10516
|
const contracts = await this.getContracts(filter);
|
|
10488
|
-
if (this.syncedWithin(
|
|
10517
|
+
if (this.syncedWithin(
|
|
10518
|
+
contracts,
|
|
10519
|
+
options?.maxSyncAgeMs ?? (options?.requireSynced ? 0 : this.config.vtxoSyncMaxAgeMs ?? 0)
|
|
10520
|
+
)) {
|
|
10489
10521
|
await this.demoteFundedAwaitingContracts(contracts);
|
|
10490
10522
|
} else {
|
|
10491
10523
|
try {
|
|
@@ -10494,12 +10526,23 @@ var ContractManager = class _ContractManager {
|
|
|
10494
10526
|
} catch (err) {
|
|
10495
10527
|
if (!isRetryableProviderError(err)) throw err;
|
|
10496
10528
|
this.markSyncDegraded(err);
|
|
10529
|
+
if (options?.requireSynced) {
|
|
10530
|
+
throw new Error("Spendable VTXO read requires an online contract sync", {
|
|
10531
|
+
cause: err
|
|
10532
|
+
});
|
|
10533
|
+
}
|
|
10497
10534
|
}
|
|
10498
10535
|
}
|
|
10499
|
-
const vtxos = await this.getVtxosForContracts(contracts);
|
|
10536
|
+
const vtxos = await this.getVtxosForContracts(contracts, options);
|
|
10537
|
+
const vtxosByScript = /* @__PURE__ */ new Map();
|
|
10538
|
+
for (const vtxo of vtxos) {
|
|
10539
|
+
const group = vtxosByScript.get(vtxo.contractScript) ?? [];
|
|
10540
|
+
group.push(vtxo);
|
|
10541
|
+
vtxosByScript.set(vtxo.contractScript, group);
|
|
10542
|
+
}
|
|
10500
10543
|
return contracts.map((contract) => ({
|
|
10501
10544
|
contract,
|
|
10502
|
-
vtxos:
|
|
10545
|
+
vtxos: vtxosByScript.get(contract.script)?.slice() ?? []
|
|
10503
10546
|
}));
|
|
10504
10547
|
}
|
|
10505
10548
|
async annotateVtxos(vtxos, tapscripts) {
|
|
@@ -10929,20 +10972,28 @@ var ContractManager = class _ContractManager {
|
|
|
10929
10972
|
}
|
|
10930
10973
|
this.emitEvent(event);
|
|
10931
10974
|
}
|
|
10932
|
-
async getVtxosForContracts(contracts) {
|
|
10933
|
-
|
|
10934
|
-
|
|
10935
|
-
|
|
10936
|
-
|
|
10937
|
-
|
|
10938
|
-
|
|
10939
|
-
|
|
10940
|
-
|
|
10975
|
+
async getVtxosForContracts(contracts, options) {
|
|
10976
|
+
if (contracts.length === 0) return [];
|
|
10977
|
+
let rows;
|
|
10978
|
+
if (this.config.walletRepository.getVtxosForScripts) {
|
|
10979
|
+
const byScript = new Set(contracts.map((contract) => contract.script));
|
|
10980
|
+
rows = (await this.config.walletRepository.getVtxosForScripts([...byScript], options)).filter((vtxo) => vtxo.script !== void 0 && byScript.has(vtxo.script)).map((vtxo) => ({ ...normalizeVtxo(vtxo), contractScript: vtxo.script }));
|
|
10981
|
+
} else {
|
|
10982
|
+
const res = await Promise.all(
|
|
10983
|
+
contracts.map(
|
|
10984
|
+
(contract) => getVtxosForContract(this.config.walletRepository, contract).then(
|
|
10985
|
+
(vtxos) => vtxos.map(
|
|
10986
|
+
(vtxo) => ({
|
|
10987
|
+
...vtxo,
|
|
10988
|
+
contractScript: contract.script
|
|
10989
|
+
})
|
|
10990
|
+
)
|
|
10941
10991
|
)
|
|
10942
10992
|
)
|
|
10943
|
-
)
|
|
10944
|
-
|
|
10945
|
-
|
|
10993
|
+
);
|
|
10994
|
+
rows = res.flat();
|
|
10995
|
+
}
|
|
10996
|
+
return options?.unspentOnly ? rows.filter((vtxo) => !isVtxoSpent(vtxo)) : rows;
|
|
10946
10997
|
}
|
|
10947
10998
|
/**
|
|
10948
10999
|
* Sync virtual outputs for the given contracts against the indexer.
|
|
@@ -11443,7 +11494,7 @@ var IndexedDBWalletRepository = class {
|
|
|
11443
11494
|
const store = transaction.objectStore(STORE_VTXOS);
|
|
11444
11495
|
for (const vtxo of vtxos) {
|
|
11445
11496
|
const serialized = serializeVtxo(vtxo);
|
|
11446
|
-
store.put({ address, ...serialized });
|
|
11497
|
+
store.put({ address, ...serialized, ...unspentFlag(vtxo) });
|
|
11447
11498
|
}
|
|
11448
11499
|
await awaitTransaction(transaction);
|
|
11449
11500
|
} catch (error) {
|
|
@@ -11463,31 +11514,52 @@ var IndexedDBWalletRepository = class {
|
|
|
11463
11514
|
}
|
|
11464
11515
|
}
|
|
11465
11516
|
async getVtxosForScript(script) {
|
|
11517
|
+
return this.getVtxosForScripts([script]);
|
|
11518
|
+
}
|
|
11519
|
+
async getVtxosForScripts(scripts, options) {
|
|
11520
|
+
const unique = [...new Set(scripts)];
|
|
11521
|
+
if (unique.length === 0) return [];
|
|
11466
11522
|
try {
|
|
11467
11523
|
const db = await this.getDB();
|
|
11468
|
-
const
|
|
11469
|
-
|
|
11470
|
-
|
|
11471
|
-
|
|
11472
|
-
|
|
11524
|
+
const rows = options?.unspentOnly ? await getAllByIndexValues(
|
|
11525
|
+
this.vtxoStore(db),
|
|
11526
|
+
"scriptUnspent",
|
|
11527
|
+
unique.map((script) => [script, 1])
|
|
11528
|
+
) : await getAllByIndexValues(this.vtxoStore(db), "script", unique);
|
|
11529
|
+
const selected = new Set(unique);
|
|
11473
11530
|
const byOutpoint = /* @__PURE__ */ new Map();
|
|
11474
|
-
for (const row of
|
|
11475
|
-
|
|
11476
|
-
const
|
|
11477
|
-
|
|
11478
|
-
|
|
11531
|
+
for (const row of rows) {
|
|
11532
|
+
if (!selected.has(row.script)) continue;
|
|
11533
|
+
const key = `${row.script}:${row.txid}:${row.vout}`;
|
|
11534
|
+
const existing = byOutpoint.get(key);
|
|
11535
|
+
if (!existing || shouldReplaceVtxo(existing, row)) byOutpoint.set(key, row);
|
|
11536
|
+
}
|
|
11537
|
+
if (options?.unspentOnly && byOutpoint.size > 0) {
|
|
11538
|
+
const txids = [...new Set([...byOutpoint.values()].map((row) => row.txid))];
|
|
11539
|
+
const store = this.vtxoStore(db);
|
|
11540
|
+
for (const row of await getAllByIndexValues(store, "txid", txids)) {
|
|
11541
|
+
const key = `${row.script}:${row.txid}:${row.vout}`;
|
|
11542
|
+
const existing = byOutpoint.get(key);
|
|
11543
|
+
if (existing && shouldReplaceVtxo(existing, row)) byOutpoint.set(key, row);
|
|
11544
|
+
}
|
|
11545
|
+
}
|
|
11546
|
+
const result = [];
|
|
11547
|
+
for (const row of byOutpoint.values()) {
|
|
11548
|
+
if (options?.unspentOnly && (row.isSpent || row.spentBy || row.settledBy)) {
|
|
11479
11549
|
continue;
|
|
11480
11550
|
}
|
|
11481
|
-
|
|
11482
|
-
|
|
11483
|
-
}
|
|
11551
|
+
const vtxo = deserializeVtxoWithBackfill(row);
|
|
11552
|
+
if (!options?.unspentOnly || !isVtxoSpent(vtxo)) result.push(vtxo);
|
|
11484
11553
|
}
|
|
11485
|
-
return
|
|
11554
|
+
return result;
|
|
11486
11555
|
} catch (error) {
|
|
11487
|
-
console.error(
|
|
11556
|
+
console.error("Failed to get VTXOs for scripts:", error);
|
|
11488
11557
|
throw error;
|
|
11489
11558
|
}
|
|
11490
11559
|
}
|
|
11560
|
+
vtxoStore(db) {
|
|
11561
|
+
return db.transaction([STORE_VTXOS], "readonly").objectStore(STORE_VTXOS);
|
|
11562
|
+
}
|
|
11491
11563
|
async saveVtxosForScript(key, vtxos) {
|
|
11492
11564
|
if (!key.address) {
|
|
11493
11565
|
throw new Error("IndexedDBWalletRepository requires an address");
|
|
@@ -11618,7 +11690,7 @@ var IndexedDBWalletRepository = class {
|
|
|
11618
11690
|
return this.connection.get();
|
|
11619
11691
|
}
|
|
11620
11692
|
};
|
|
11621
|
-
function deserializeVtxoWithBackfill(o) {
|
|
11693
|
+
function deserializeVtxoWithBackfill({ unspent: _unspent, ...o }) {
|
|
11622
11694
|
if (!o.script) {
|
|
11623
11695
|
o = { ...o, script: scriptFromArkAddress(o.address) };
|
|
11624
11696
|
}
|
|
@@ -12555,7 +12627,7 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
12555
12627
|
}
|
|
12556
12628
|
};
|
|
12557
12629
|
for (const vtxo of vtxos) {
|
|
12558
|
-
if (
|
|
12630
|
+
if (isVtxoSpent(vtxo)) continue;
|
|
12559
12631
|
addAssets(owned, vtxo);
|
|
12560
12632
|
if (vtxo.isUnrolled) {
|
|
12561
12633
|
unrolled += vtxo.value;
|
|
@@ -12827,7 +12899,7 @@ function filterSnapshotVtxos(snapshot, filter, pendingSpendOutpoints) {
|
|
|
12827
12899
|
if (vtxo.isUnrolled) {
|
|
12828
12900
|
return !!f.withUnrolled;
|
|
12829
12901
|
}
|
|
12830
|
-
if (
|
|
12902
|
+
if (isVtxoSpent(vtxo)) {
|
|
12831
12903
|
return false;
|
|
12832
12904
|
}
|
|
12833
12905
|
if (!f.withRecoverable && canRecoverOnchain(vtxo, now)) {
|
|
@@ -13395,7 +13467,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13395
13467
|
}
|
|
13396
13468
|
/** @inheritdoc */
|
|
13397
13469
|
async getSpendableVtxos(filter) {
|
|
13398
|
-
const snapshot = await this.contractSnapshot(
|
|
13470
|
+
const snapshot = await this.contractSnapshot(filter, {
|
|
13471
|
+
unspentOnly: !filter?.withUnrolled
|
|
13472
|
+
});
|
|
13399
13473
|
const vtxos = filterSnapshotVtxos(snapshot, filter, this._pendingSpendOutpoints);
|
|
13400
13474
|
const { gated, pendingRecovery } = this.spendabilityView(snapshot);
|
|
13401
13475
|
const selectable = vtxos.filter(
|
|
@@ -13413,7 +13487,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13413
13487
|
if (!filter?.withUnrolled) {
|
|
13414
13488
|
logExcludedVtxos(
|
|
13415
13489
|
"getSpendableVtxos",
|
|
13416
|
-
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !
|
|
13490
|
+
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !isVtxoSpent(vtxo)),
|
|
13417
13491
|
[() => UNROLLED_REASON]
|
|
13418
13492
|
);
|
|
13419
13493
|
}
|
|
@@ -13487,9 +13561,25 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13487
13561
|
* otherwise the gate and the pending-recovery set answer about two different
|
|
13488
13562
|
* points in time, and each read costs another sync.
|
|
13489
13563
|
*/
|
|
13490
|
-
async contractSnapshot() {
|
|
13564
|
+
async contractSnapshot(filter, options) {
|
|
13491
13565
|
const contractManager = await this.getContractManager();
|
|
13492
|
-
|
|
13566
|
+
const scope = filter?.watchedOnly ? { watch: ["watched", "awaiting-funds"] } : void 0;
|
|
13567
|
+
let query = scope;
|
|
13568
|
+
if (filter?.genericallySpendableOnly) {
|
|
13569
|
+
const scripts = (await contractManager.getContracts(scope)).filter(isContractGenericallySpendable).map((contract) => contract.script);
|
|
13570
|
+
if (scripts.length === 0) {
|
|
13571
|
+
if (filter.requireSynced) {
|
|
13572
|
+
throw new Error("No generically spendable contracts to sync");
|
|
13573
|
+
}
|
|
13574
|
+
return [];
|
|
13575
|
+
}
|
|
13576
|
+
query = { ...scope, script: scripts };
|
|
13577
|
+
}
|
|
13578
|
+
return contractManager.getContractsWithVtxos(query, void 0, {
|
|
13579
|
+
maxSyncAgeMs: filter?.maxSyncAgeMs,
|
|
13580
|
+
unspentOnly: options?.unspentOnly,
|
|
13581
|
+
requireSynced: filter?.requireSynced
|
|
13582
|
+
});
|
|
13493
13583
|
}
|
|
13494
13584
|
/**
|
|
13495
13585
|
* The two exclusion sets the gate is made of, derived from one snapshot so
|
|
@@ -15318,7 +15408,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15318
15408
|
filteredBoardingUtxos.push(utxo);
|
|
15319
15409
|
amount += utxo.value - inputFee.satoshis;
|
|
15320
15410
|
}
|
|
15321
|
-
const vtxos = await this.getSpendableVtxos({
|
|
15411
|
+
const vtxos = await this.getSpendableVtxos({
|
|
15412
|
+
withRecoverable: true,
|
|
15413
|
+
genericallySpendableOnly: true
|
|
15414
|
+
});
|
|
15322
15415
|
const filteredVtxos = [];
|
|
15323
15416
|
for (const vtxo of byValueDescending(vtxos)) {
|
|
15324
15417
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
@@ -16231,7 +16324,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16231
16324
|
const spendable = [];
|
|
16232
16325
|
const unclaimed = [];
|
|
16233
16326
|
for (const vtxo of vtxos) {
|
|
16234
|
-
if (
|
|
16327
|
+
if (isVtxoSpent(vtxo)) {
|
|
16235
16328
|
unclaimed.push(cashReport(vtxo, "already-spent"));
|
|
16236
16329
|
} else if (vtxo.isUnrolled) {
|
|
16237
16330
|
unclaimed.push(cashReport(vtxo, "exited"));
|
|
@@ -16422,7 +16515,8 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16422
16515
|
let virtualCoins = [];
|
|
16423
16516
|
if (!selectedVtxos) {
|
|
16424
16517
|
virtualCoins = await this.getSpendableVtxos({
|
|
16425
|
-
withRecoverable: false
|
|
16518
|
+
withRecoverable: false,
|
|
16519
|
+
genericallySpendableOnly: true
|
|
16426
16520
|
});
|
|
16427
16521
|
}
|
|
16428
16522
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -16454,6 +16548,15 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16454
16548
|
}
|
|
16455
16549
|
}
|
|
16456
16550
|
} else {
|
|
16551
|
+
const coinsByAsset = /* @__PURE__ */ new Map();
|
|
16552
|
+
for (const coin of virtualCoins) {
|
|
16553
|
+
for (const assetId of new Set(coin.assets?.map((asset) => asset.assetId))) {
|
|
16554
|
+
const coins = coinsByAsset.get(assetId) ?? [];
|
|
16555
|
+
coins.push(coin);
|
|
16556
|
+
coinsByAsset.set(assetId, coins);
|
|
16557
|
+
}
|
|
16558
|
+
}
|
|
16559
|
+
const selectedOutpoints2 = /* @__PURE__ */ new Set();
|
|
16457
16560
|
for (const recipient of recipients) {
|
|
16458
16561
|
if (!recipient.assets) {
|
|
16459
16562
|
continue;
|
|
@@ -16472,8 +16575,8 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16472
16575
|
amountToSelect -= existingChange;
|
|
16473
16576
|
assetChanges.delete(receiverAsset.assetId);
|
|
16474
16577
|
}
|
|
16475
|
-
const availableCoins =
|
|
16476
|
-
(
|
|
16578
|
+
const availableCoins = (coinsByAsset.get(receiverAsset.assetId) ?? []).filter(
|
|
16579
|
+
(coin) => !selectedOutpoints2.has(vtxoOutpoint(coin))
|
|
16477
16580
|
);
|
|
16478
16581
|
const { selected, totalAssetAmount } = selectCoinsWithAsset(
|
|
16479
16582
|
availableCoins,
|
|
@@ -16482,6 +16585,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16482
16585
|
);
|
|
16483
16586
|
for (const coin of selected) {
|
|
16484
16587
|
selectedCoins.push(coin);
|
|
16588
|
+
selectedOutpoints2.add(vtxoOutpoint(coin));
|
|
16485
16589
|
btcAmountToSelect -= coin.value;
|
|
16486
16590
|
if (coin.assets) {
|
|
16487
16591
|
for (const a of coin.assets) {
|
|
@@ -16502,7 +16606,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16502
16606
|
}
|
|
16503
16607
|
if (btcAmountToSelect > 0) {
|
|
16504
16608
|
const availableCoins = virtualCoins.filter(
|
|
16505
|
-
(
|
|
16609
|
+
(coin) => !selectedOutpoints2.has(vtxoOutpoint(coin))
|
|
16506
16610
|
);
|
|
16507
16611
|
const { inputs: btcCoins } = selectVirtualCoins(availableCoins, btcAmountToSelect);
|
|
16508
16612
|
for (const coin of btcCoins) {
|
|
@@ -16514,6 +16618,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16514
16618
|
}
|
|
16515
16619
|
}
|
|
16516
16620
|
selectedCoins = [...selectedCoins, ...btcCoins];
|
|
16621
|
+
for (const coin of btcCoins) selectedOutpoints2.add(vtxoOutpoint(coin));
|
|
16517
16622
|
}
|
|
16518
16623
|
}
|
|
16519
16624
|
let totalBtcSelected = selectedCoins.reduce((sum, c) => sum + c.value, 0);
|
|
@@ -16530,19 +16635,58 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16530
16635
|
`send({ selectedVtxos }): inputs total ${totalBtcSelected} sats, outputs need ${totalBtcOutput}`
|
|
16531
16636
|
);
|
|
16532
16637
|
}
|
|
16533
|
-
if (assetChanges.size > 0 && changeAmount < Number(this.dustAmount)) {
|
|
16534
|
-
|
|
16535
|
-
|
|
16536
|
-
|
|
16537
|
-
|
|
16538
|
-
|
|
16539
|
-
|
|
16540
|
-
|
|
16638
|
+
if (selectedVtxos && assetChanges.size > 0 && changeAmount < Number(this.dustAmount)) {
|
|
16639
|
+
throw new Error(
|
|
16640
|
+
`send({ selectedVtxos }): ${changeAmount} sats of change cannot carry ${assetChanges.size} asset change(s), needs ${this.dustAmount}`
|
|
16641
|
+
);
|
|
16642
|
+
}
|
|
16643
|
+
const vtxoMinAmount = changeAmount > 0 || assetChanges.size > 0 ? (await this.arkProvider.getInfo()).vtxoMinAmount ?? 0n : 0n;
|
|
16644
|
+
if (selectedVtxos && changeAmount > 0 && BigInt(changeAmount) < vtxoMinAmount) {
|
|
16645
|
+
throw new Error(
|
|
16646
|
+
`send({ selectedVtxos }): ${changeAmount} sats of change is below the operator minimum of ${vtxoMinAmount} sats`
|
|
16541
16647
|
);
|
|
16542
|
-
|
|
16543
|
-
|
|
16544
|
-
|
|
16648
|
+
}
|
|
16649
|
+
const selectedOutpoints = new Set(selectedCoins.map(vtxoOutpoint));
|
|
16650
|
+
while (!selectedVtxos && (changeAmount > 0 && BigInt(changeAmount) < vtxoMinAmount || assetChanges.size > 0 && BigInt(changeAmount) < this.dustAmount)) {
|
|
16651
|
+
const minimumChange = assetChanges.size > 0 && this.dustAmount > vtxoMinAmount ? this.dustAmount : vtxoMinAmount;
|
|
16652
|
+
const availableCoins = virtualCoins.filter(
|
|
16653
|
+
(coin) => !selectedOutpoints.has(vtxoOutpoint(coin))
|
|
16545
16654
|
);
|
|
16655
|
+
let extraCoins;
|
|
16656
|
+
try {
|
|
16657
|
+
({ inputs: extraCoins } = selectVirtualCoins(
|
|
16658
|
+
availableCoins,
|
|
16659
|
+
Number(minimumChange) - changeAmount
|
|
16660
|
+
));
|
|
16661
|
+
} catch (error) {
|
|
16662
|
+
if (!(error instanceof Error) || error.message !== "Insufficient funds") {
|
|
16663
|
+
throw error;
|
|
16664
|
+
}
|
|
16665
|
+
if (recipients.every((r) => r.assets.length === 0)) {
|
|
16666
|
+
const plainCoins = virtualCoins.filter((coin) => !coin.assets?.length);
|
|
16667
|
+
const exact = plainCoins.find((coin) => coin.value === totalBtcOutput);
|
|
16668
|
+
let exactCoins = exact ? [exact] : void 0;
|
|
16669
|
+
if (!exactCoins) {
|
|
16670
|
+
const byAmount = /* @__PURE__ */ new Map();
|
|
16671
|
+
for (const coin of plainCoins) {
|
|
16672
|
+
const partner = byAmount.get(totalBtcOutput - coin.value);
|
|
16673
|
+
if (partner) {
|
|
16674
|
+
exactCoins = [partner, coin];
|
|
16675
|
+
break;
|
|
16676
|
+
}
|
|
16677
|
+
byAmount.set(coin.value, coin);
|
|
16678
|
+
}
|
|
16679
|
+
}
|
|
16680
|
+
if (exactCoins) {
|
|
16681
|
+
selectedCoins = exactCoins;
|
|
16682
|
+
assetChanges.clear();
|
|
16683
|
+
totalBtcSelected = totalBtcOutput;
|
|
16684
|
+
changeAmount = 0;
|
|
16685
|
+
break;
|
|
16686
|
+
}
|
|
16687
|
+
}
|
|
16688
|
+
throw new Error(`Cannot form minimum change amount of ${minimumChange} sats`);
|
|
16689
|
+
}
|
|
16546
16690
|
for (const coin of extraCoins) {
|
|
16547
16691
|
if (coin.assets) {
|
|
16548
16692
|
for (const asset of coin.assets) {
|
|
@@ -16552,6 +16696,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16552
16696
|
}
|
|
16553
16697
|
}
|
|
16554
16698
|
selectedCoins = [...selectedCoins, ...extraCoins];
|
|
16699
|
+
for (const coin of extraCoins) selectedOutpoints.add(vtxoOutpoint(coin));
|
|
16555
16700
|
totalBtcSelected += extraCoins.reduce((sum, c) => sum + c.value, 0);
|
|
16556
16701
|
changeAmount = totalBtcSelected - totalBtcOutput;
|
|
16557
16702
|
}
|
|
@@ -17938,7 +18083,8 @@ var Ramps = class {
|
|
|
17938
18083
|
if (vtxos) reportUngatedInputs(this.wallet, vtxos);
|
|
17939
18084
|
const spendable = vtxos ?? await this.wallet.getSpendableVtxos({
|
|
17940
18085
|
withRecoverable: true,
|
|
17941
|
-
withUnrolled: false
|
|
18086
|
+
withUnrolled: false,
|
|
18087
|
+
genericallySpendableOnly: true
|
|
17942
18088
|
});
|
|
17943
18089
|
const estimator = new Estimator(feeInfo?.intentFee ?? {});
|
|
17944
18090
|
const { inputs, subtotal } = filterOffboardInputs(spendable, feeInfo, named);
|
|
@@ -17980,7 +18126,8 @@ var Ramps = class {
|
|
|
17980
18126
|
if (vtxos) reportUngatedInputs(this.wallet, vtxos);
|
|
17981
18127
|
const spendable = vtxos ?? await this.wallet.getSpendableVtxos({
|
|
17982
18128
|
withRecoverable: true,
|
|
17983
|
-
withUnrolled: false
|
|
18129
|
+
withUnrolled: false,
|
|
18130
|
+
genericallySpendableOnly: true
|
|
17984
18131
|
});
|
|
17985
18132
|
const estimator = new Estimator(feeInfo?.intentFee ?? {});
|
|
17986
18133
|
const { inputs, subtotal } = filterOffboardInputs(spendable, feeInfo, named);
|
|
@@ -18367,7 +18514,7 @@ var WalletMessageHandler = class {
|
|
|
18367
18514
|
return this.tagged({
|
|
18368
18515
|
id,
|
|
18369
18516
|
type: "SPENDABLE_VTXOS",
|
|
18370
|
-
payload: { vtxos }
|
|
18517
|
+
payload: { vtxos, filterApplied: true }
|
|
18371
18518
|
});
|
|
18372
18519
|
}
|
|
18373
18520
|
case "GET_BOARDING_UTXOS": {
|
|
@@ -18448,11 +18595,15 @@ var WalletMessageHandler = class {
|
|
|
18448
18595
|
}
|
|
18449
18596
|
case "GET_CONTRACTS_WITH_VTXOS": {
|
|
18450
18597
|
const manager = await this.readonlyWallet.getContractManager();
|
|
18451
|
-
const contracts = await manager.getContractsWithVtxos(
|
|
18598
|
+
const contracts = await manager.getContractsWithVtxos(
|
|
18599
|
+
message.payload.filter,
|
|
18600
|
+
void 0,
|
|
18601
|
+
message.payload.options
|
|
18602
|
+
);
|
|
18452
18603
|
return this.tagged({
|
|
18453
18604
|
id,
|
|
18454
18605
|
type: "CONTRACTS_WITH_VTXOS",
|
|
18455
|
-
payload: { contracts }
|
|
18606
|
+
payload: { contracts, filterApplied: true }
|
|
18456
18607
|
});
|
|
18457
18608
|
}
|
|
18458
18609
|
case "WATCH_SCRIPT": {
|
|
@@ -19124,7 +19275,7 @@ var WalletMessageHandler = class {
|
|
|
19124
19275
|
if (v.isUnrolled) {
|
|
19125
19276
|
return withUnrolled;
|
|
19126
19277
|
}
|
|
19127
|
-
if (
|
|
19278
|
+
if (isVtxoSpent(v)) {
|
|
19128
19279
|
return false;
|
|
19129
19280
|
}
|
|
19130
19281
|
if (includeRecoverable) {
|
|
@@ -19977,7 +20128,13 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19977
20128
|
};
|
|
19978
20129
|
try {
|
|
19979
20130
|
const response = await this.sendMessage(message);
|
|
19980
|
-
|
|
20131
|
+
const payload = response.payload;
|
|
20132
|
+
if ((filter?.watchedOnly || filter?.genericallySpendableOnly || filter?.requireSynced) && payload.filterApplied !== true) {
|
|
20133
|
+
throw new Error(
|
|
20134
|
+
"Service worker does not support the requested contract scope or freshness check"
|
|
20135
|
+
);
|
|
20136
|
+
}
|
|
20137
|
+
return payload.vtxos.map(normalizeVtxo);
|
|
19981
20138
|
} catch (error) {
|
|
19982
20139
|
throw new Error(`Failed to get spendable vtxos: ${error}`);
|
|
19983
20140
|
}
|
|
@@ -20062,15 +20219,20 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
20062
20219
|
throw new Error("Failed to get contracts");
|
|
20063
20220
|
}
|
|
20064
20221
|
},
|
|
20065
|
-
async getContractsWithVtxos(filter) {
|
|
20222
|
+
async getContractsWithVtxos(filter, _pageSize, options) {
|
|
20066
20223
|
const message = {
|
|
20067
20224
|
type: "GET_CONTRACTS_WITH_VTXOS",
|
|
20068
20225
|
id: getRandomId(),
|
|
20069
20226
|
tag: messageTag,
|
|
20070
|
-
payload: { filter }
|
|
20227
|
+
payload: { filter, options }
|
|
20071
20228
|
};
|
|
20072
20229
|
try {
|
|
20073
20230
|
const response = await sendContractMessage(message);
|
|
20231
|
+
if (options?.requireSynced && response.payload.filterApplied !== true) {
|
|
20232
|
+
throw new Error(
|
|
20233
|
+
"Service worker does not support the requested freshness check"
|
|
20234
|
+
);
|
|
20235
|
+
}
|
|
20074
20236
|
await refreshSyncState();
|
|
20075
20237
|
return response.payload.contracts;
|
|
20076
20238
|
} catch (e) {
|
|
@@ -23548,7 +23710,9 @@ __export(arkade_exports, {
|
|
|
23548
23710
|
fromASM: () => fromASM,
|
|
23549
23711
|
getOpcodeName: () => getOpcodeName,
|
|
23550
23712
|
getOpcodeValue: () => getOpcodeValue,
|
|
23713
|
+
isContractArtifact: () => isContractArtifact,
|
|
23551
23714
|
parseArtifact: () => parseArtifact,
|
|
23715
|
+
programFromArtifact: () => programFromArtifact,
|
|
23552
23716
|
resolveAsm: () => resolveAsm,
|
|
23553
23717
|
serializeArkadeContractParams: () => serializeArkadeContractParams,
|
|
23554
23718
|
stringifyArtifact: () => stringifyArtifact,
|
|
@@ -23746,6 +23910,263 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23746
23910
|
}
|
|
23747
23911
|
};
|
|
23748
23912
|
}
|
|
23913
|
+
var NATIVE_STRUCTS = {
|
|
23914
|
+
AssetId: [
|
|
23915
|
+
["txid", "bytes32"],
|
|
23916
|
+
["gidx", "int"]
|
|
23917
|
+
],
|
|
23918
|
+
Outpoint: [
|
|
23919
|
+
["txid", "bytes32"],
|
|
23920
|
+
["vout", "int"]
|
|
23921
|
+
],
|
|
23922
|
+
ECPoint: [
|
|
23923
|
+
["x", "int"],
|
|
23924
|
+
["y", "int"]
|
|
23925
|
+
]
|
|
23926
|
+
};
|
|
23927
|
+
var HASH_OPCODES = /* @__PURE__ */ new Set(["OP_SHA256", "OP_HASH160", "OP_HASH256", "OP_RIPEMD160"]);
|
|
23928
|
+
function isRecord(value) {
|
|
23929
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23930
|
+
}
|
|
23931
|
+
function isNamed(value) {
|
|
23932
|
+
return isRecord(value) && typeof value.name === "string" && typeof value.type === "string" && value.type.length > 0;
|
|
23933
|
+
}
|
|
23934
|
+
function isContractArtifact(value) {
|
|
23935
|
+
if (!isRecord(value) || typeof value.contractName !== "string") return false;
|
|
23936
|
+
if (!Array.isArray(value.constructorInputs)) return false;
|
|
23937
|
+
if (value.structs !== void 0 && !Array.isArray(value.structs)) return false;
|
|
23938
|
+
if (!Array.isArray(value.functions) || value.functions.length === 0) return false;
|
|
23939
|
+
return value.functions.every(
|
|
23940
|
+
(group) => isRecord(group) && typeof group.name === "string" && Array.isArray(group.leaves) && group.leaves.length > 0
|
|
23941
|
+
);
|
|
23942
|
+
}
|
|
23943
|
+
function fail(detail) {
|
|
23944
|
+
throw new Error(`programFromArtifact: ${detail}`);
|
|
23945
|
+
}
|
|
23946
|
+
function claim(seen, name, kind) {
|
|
23947
|
+
if (seen.has(name)) fail(`duplicate ${kind} '${name}'`);
|
|
23948
|
+
seen.add(name);
|
|
23949
|
+
}
|
|
23950
|
+
var SCALAR_TYPES = {
|
|
23951
|
+
pubkey: "pubkey",
|
|
23952
|
+
signature: "sig",
|
|
23953
|
+
bytes: "bytes",
|
|
23954
|
+
bytes20: "hash",
|
|
23955
|
+
bytes32: "hash",
|
|
23956
|
+
asset: "hash",
|
|
23957
|
+
int: "int",
|
|
23958
|
+
bool: "int"
|
|
23959
|
+
};
|
|
23960
|
+
function argType(arkType) {
|
|
23961
|
+
if (!Object.hasOwn(SCALAR_TYPES, arkType)) fail(`unknown type '${arkType}'`);
|
|
23962
|
+
return SCALAR_TYPES[arkType];
|
|
23963
|
+
}
|
|
23964
|
+
function arrayParts(type) {
|
|
23965
|
+
const open = type.indexOf("[");
|
|
23966
|
+
if (open < 0 || !type.endsWith("]")) return [type, 0];
|
|
23967
|
+
const length = Number(type.slice(open + 1, -1));
|
|
23968
|
+
return Number.isInteger(length) && length > 0 ? [type.slice(0, open), length] : [type, 0];
|
|
23969
|
+
}
|
|
23970
|
+
function flatten(param, structs, stack = []) {
|
|
23971
|
+
if (!isNamed(param)) fail("parameter needs a name and a type");
|
|
23972
|
+
if (Object.hasOwn(NATIVE_STRUCTS, param.type)) {
|
|
23973
|
+
return NATIVE_STRUCTS[param.type].map(([field, type]) => ({
|
|
23974
|
+
name: `${param.name}.${field}`,
|
|
23975
|
+
type: argType(type)
|
|
23976
|
+
}));
|
|
23977
|
+
}
|
|
23978
|
+
const declared = structs.find((struct) => struct?.name === param.type);
|
|
23979
|
+
if (declared) {
|
|
23980
|
+
if (stack.includes(param.type)) fail(`recursive struct layout '${param.type}'`);
|
|
23981
|
+
return declared.fields.flatMap(
|
|
23982
|
+
(field) => flatten({ name: `${param.name}.${field.name}`, type: field.type }, structs, [
|
|
23983
|
+
...stack,
|
|
23984
|
+
param.type
|
|
23985
|
+
])
|
|
23986
|
+
);
|
|
23987
|
+
}
|
|
23988
|
+
const [element, length] = arrayParts(param.type);
|
|
23989
|
+
if (length === 0) {
|
|
23990
|
+
if (param.type.includes("[") || param.type.includes("]")) {
|
|
23991
|
+
fail(`invalid array type '${param.type}'`);
|
|
23992
|
+
}
|
|
23993
|
+
return [{ name: param.name, type: argType(param.type) }];
|
|
23994
|
+
}
|
|
23995
|
+
if (Object.hasOwn(NATIVE_STRUCTS, element) || structs.some((struct) => struct.name === element)) {
|
|
23996
|
+
fail(`arrays of structs are not supported: '${param.type}'`);
|
|
23997
|
+
}
|
|
23998
|
+
return Array.from({ length }, (_, index) => ({
|
|
23999
|
+
name: `${param.name}.${index}`,
|
|
24000
|
+
type: argType(element)
|
|
24001
|
+
}));
|
|
24002
|
+
}
|
|
24003
|
+
function opcodeToken(token) {
|
|
24004
|
+
const base = token.slice(3);
|
|
24005
|
+
const name = base === "0" || /^([1-9]|1[0-6])$/.test(base) ? token : base;
|
|
24006
|
+
if (!Object.hasOwn(ARKADE_OPS, name)) {
|
|
24007
|
+
fail(`opcode '${token}' is not in this SDK's table`);
|
|
24008
|
+
}
|
|
24009
|
+
return name;
|
|
24010
|
+
}
|
|
24011
|
+
function instantiationParam(body) {
|
|
24012
|
+
return `contract_${body.replace(/[^A-Za-z0-9]+/g, "_")}`.replace(/_+$/, "");
|
|
24013
|
+
}
|
|
24014
|
+
function asmToken(token, instantiations) {
|
|
24015
|
+
if (token.startsWith("OP_")) return opcodeToken(token);
|
|
24016
|
+
if (token.startsWith("<") && token.endsWith(">")) {
|
|
24017
|
+
const inner = token.slice(1, -1);
|
|
24018
|
+
if (inner.startsWith("CONTRACT:")) {
|
|
24019
|
+
const body = inner.slice("CONTRACT:".length);
|
|
24020
|
+
const name = instantiationParam(body);
|
|
24021
|
+
const seen = instantiations.get(name);
|
|
24022
|
+
if (seen !== void 0 && seen !== body) {
|
|
24023
|
+
fail(`instantiations '${seen}' and '${body}' both map to parameter '${name}'`);
|
|
24024
|
+
}
|
|
24025
|
+
instantiations.set(name, body);
|
|
24026
|
+
return `$${name}`;
|
|
24027
|
+
}
|
|
24028
|
+
if (inner.startsWith("VTXO:")) {
|
|
24029
|
+
fail(`'${token}' is not a placeholder; the compiler emits <CONTRACT:\u2026>`);
|
|
24030
|
+
}
|
|
24031
|
+
if (inner === "SERVER_KEY" || inner.startsWith("EMULATOR_KEY:")) {
|
|
24032
|
+
fail(`${token} is a signer role and cannot appear in a covenant`);
|
|
24033
|
+
}
|
|
24034
|
+
return `$${inner}`;
|
|
24035
|
+
}
|
|
24036
|
+
if (token.startsWith("0x")) return hex.decode(token.slice(2));
|
|
24037
|
+
try {
|
|
24038
|
+
return BigInt(token);
|
|
24039
|
+
} catch {
|
|
24040
|
+
fail(`unrecognized assembly token '${token}'`);
|
|
24041
|
+
}
|
|
24042
|
+
}
|
|
24043
|
+
function providedWitness(witness) {
|
|
24044
|
+
if (witness === void 0) return [];
|
|
24045
|
+
if (!Array.isArray(witness)) fail("leaf witness must be an array");
|
|
24046
|
+
return witness.filter((item) => {
|
|
24047
|
+
if (!isNamed(item)) fail("witness item needs a name and a type");
|
|
24048
|
+
return !item.injected && item.type !== "signature";
|
|
24049
|
+
});
|
|
24050
|
+
}
|
|
24051
|
+
function parseLeaf(leaf, hasCovenant, instantiations, extras) {
|
|
24052
|
+
const asm = leaf.asm;
|
|
24053
|
+
let index = 0;
|
|
24054
|
+
let condition;
|
|
24055
|
+
if (asm.length >= 4 && HASH_OPCODES.has(asm[0]) && asm[2] === "OP_EQUAL") {
|
|
24056
|
+
if (asm[3] !== "OP_VERIFY")
|
|
24057
|
+
fail(`leaf '${leaf.name}': hash condition must end in OP_VERIFY`);
|
|
24058
|
+
condition = asm.slice(0, 3).map((token) => asmToken(token, instantiations));
|
|
24059
|
+
index = 4;
|
|
24060
|
+
}
|
|
24061
|
+
let csv;
|
|
24062
|
+
let cltv;
|
|
24063
|
+
if (asm.length >= index + 3 && asm[index + 2] === "OP_DROP") {
|
|
24064
|
+
const operand = asm[index].startsWith("<") && asm[index].endsWith(">") ? `$${asm[index].slice(1, -1)}` : BigInt(asm[index]);
|
|
24065
|
+
if (asm[index + 1] === "OP_CHECKSEQUENCEVERIFY") csv = { type: "blocks", value: operand };
|
|
24066
|
+
else if (asm[index + 1] === "OP_CHECKLOCKTIMEVERIFY") cltv = operand;
|
|
24067
|
+
else fail(`leaf '${leaf.name}': unexpected timelock opcode ${asm[index + 1]}`);
|
|
24068
|
+
index += 3;
|
|
24069
|
+
}
|
|
24070
|
+
const signers = [];
|
|
24071
|
+
let emulator;
|
|
24072
|
+
while (index < asm.length) {
|
|
24073
|
+
const key = asm[index];
|
|
24074
|
+
const terminator = asm[index + 1];
|
|
24075
|
+
const last = terminator === "OP_CHECKSIG";
|
|
24076
|
+
if (!last && terminator !== "OP_CHECKSIGVERIFY") {
|
|
24077
|
+
fail(`leaf '${leaf.name}': expected CHECKSIG after '${key}', found '${terminator}'`);
|
|
24078
|
+
}
|
|
24079
|
+
if (!key.startsWith("<") || !key.endsWith(">")) {
|
|
24080
|
+
fail(`leaf '${leaf.name}': unsupported key operand '${key}'`);
|
|
24081
|
+
}
|
|
24082
|
+
const inner = key.slice(1, -1);
|
|
24083
|
+
if (inner === "SERVER_KEY") signers.push("$server");
|
|
24084
|
+
else if (inner.startsWith("TWEAK:")) {
|
|
24085
|
+
const [, base, fn] = inner.match(/^TWEAK:([^:]+):([^:]+)$/) ?? [];
|
|
24086
|
+
if (!base || !fn) fail(`leaf '${leaf.name}': malformed tweak '${key}'`);
|
|
24087
|
+
signers.push({ tweak: `$${base}`, fn });
|
|
24088
|
+
} else if (inner.startsWith("EMULATOR_KEY:")) {
|
|
24089
|
+
if (!hasCovenant) fail(`leaf '${leaf.name}': ${key} needs a covenant`);
|
|
24090
|
+
if (!last) fail(`leaf '${leaf.name}': ${key} must be the last signer`);
|
|
24091
|
+
emulator = inner.slice("EMULATOR_KEY:".length);
|
|
24092
|
+
} else signers.push(`$${inner}`);
|
|
24093
|
+
index += 2;
|
|
24094
|
+
}
|
|
24095
|
+
const constructorTweak = signers.some((signer) => typeof signer !== "string");
|
|
24096
|
+
if (hasCovenant && emulator === void 0 && !constructorTweak) {
|
|
24097
|
+
fail(
|
|
24098
|
+
`leaf '${leaf.name}': covenant leaf must sign with the emulator or a tweaked constructor key`
|
|
24099
|
+
);
|
|
24100
|
+
}
|
|
24101
|
+
if (signers.length === 0) fail(`leaf '${leaf.name}': at least one named signer is required`);
|
|
24102
|
+
return {
|
|
24103
|
+
signers,
|
|
24104
|
+
...emulator !== void 0 ? { emulator } : hasCovenant ? { emulator: null } : {},
|
|
24105
|
+
...condition ? { asm: condition } : {},
|
|
24106
|
+
...csv ? { csv } : {},
|
|
24107
|
+
...cltv !== void 0 ? { cltv } : {},
|
|
24108
|
+
...extras.length > 0 ? { witness: extras.map((item) => item.name) } : {}
|
|
24109
|
+
};
|
|
24110
|
+
}
|
|
24111
|
+
function programFromArtifact(artifact) {
|
|
24112
|
+
if (!isContractArtifact(artifact)) {
|
|
24113
|
+
fail(
|
|
24114
|
+
"expected a complete arkadec artifact with contractName, constructorInputs, and non-empty functions"
|
|
24115
|
+
);
|
|
24116
|
+
}
|
|
24117
|
+
const structs = artifact.structs ?? [];
|
|
24118
|
+
const structNames = /* @__PURE__ */ new Set();
|
|
24119
|
+
for (const struct of structs) {
|
|
24120
|
+
if (!isRecord(struct) || typeof struct.name !== "string") continue;
|
|
24121
|
+
if (Object.hasOwn(SCALAR_TYPES, struct.name) || Object.hasOwn(NATIVE_STRUCTS, struct.name)) {
|
|
24122
|
+
fail(`struct name '${struct.name}' shadows a built-in type`);
|
|
24123
|
+
}
|
|
24124
|
+
claim(structNames, struct.name, "struct");
|
|
24125
|
+
}
|
|
24126
|
+
const instantiations = /* @__PURE__ */ new Map();
|
|
24127
|
+
const functions = {};
|
|
24128
|
+
const groups = /* @__PURE__ */ new Set();
|
|
24129
|
+
const leafNames = /* @__PURE__ */ new Set();
|
|
24130
|
+
for (const group of artifact.functions) {
|
|
24131
|
+
claim(groups, group.name, "spend group");
|
|
24132
|
+
const covenantInputs = (group.arkade?.inputs ?? []).flatMap(
|
|
24133
|
+
(input) => flatten(input, structs)
|
|
24134
|
+
);
|
|
24135
|
+
const arkadeScript = group.arkade ? {
|
|
24136
|
+
asm: group.arkade.asm.map((token) => asmToken(token, instantiations)),
|
|
24137
|
+
// Covenant witness is reverse declaration order.
|
|
24138
|
+
witness: covenantInputs.map((field) => field.name).reverse()
|
|
24139
|
+
} : void 0;
|
|
24140
|
+
for (const [index, leaf] of group.leaves.entries()) {
|
|
24141
|
+
const name = index === 0 ? group.name : `${group.name}/${index}:${leaf.name}`;
|
|
24142
|
+
claim(leafNames, name, "function name");
|
|
24143
|
+
const extras = providedWitness(leaf.witness);
|
|
24144
|
+
const tapscript = parseLeaf(leaf, group.arkade !== void 0, instantiations, extras);
|
|
24145
|
+
const inputs = [
|
|
24146
|
+
...covenantInputs,
|
|
24147
|
+
...extras.map((item) => ({ name: item.name, type: argType(item.type) }))
|
|
24148
|
+
];
|
|
24149
|
+
functions[name] = {
|
|
24150
|
+
...inputs.length > 0 ? { inputs } : {},
|
|
24151
|
+
tapscript,
|
|
24152
|
+
...arkadeScript ? { arkadeScript } : {}
|
|
24153
|
+
};
|
|
24154
|
+
}
|
|
24155
|
+
}
|
|
24156
|
+
const params = [
|
|
24157
|
+
...artifact.constructorInputs.flatMap((input) => flatten(input, structs)),
|
|
24158
|
+
{ name: "server", type: "pubkey" },
|
|
24159
|
+
...[...instantiations.keys()].map((name) => ({ name, type: "hash" }))
|
|
24160
|
+
];
|
|
24161
|
+
const paramNames = /* @__PURE__ */ new Set();
|
|
24162
|
+
for (const param of params) claim(paramNames, param.name, "program parameter");
|
|
24163
|
+
return {
|
|
24164
|
+
version: SUPPORTED_PROGRAM_VERSION,
|
|
24165
|
+
name: artifact.contractName,
|
|
24166
|
+
params,
|
|
24167
|
+
functions
|
|
24168
|
+
};
|
|
24169
|
+
}
|
|
23749
24170
|
var Arkade = class _Arkade {
|
|
23750
24171
|
arkProvider;
|
|
23751
24172
|
/** The co-signing service, or undefined for emulator-less (pure tapscript) usage. */
|
|
@@ -23958,9 +24379,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
23958
24379
|
const [registered] = await manager.getContracts({ script: scriptHex });
|
|
23959
24380
|
if (registered) {
|
|
23960
24381
|
const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
|
|
23961
|
-
return (withVtxos?.vtxos ?? []).filter(
|
|
23962
|
-
(v) => !hasTerminalSpend(v) && !v.isUnrolled
|
|
23963
|
-
);
|
|
24382
|
+
return (withVtxos?.vtxos ?? []).filter((v) => !isVtxoSpent(v) && !v.isUnrolled);
|
|
23964
24383
|
}
|
|
23965
24384
|
}
|
|
23966
24385
|
if (!this.client.indexer) {
|
|
@@ -23970,7 +24389,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
23970
24389
|
scripts: [scriptHex],
|
|
23971
24390
|
spendableOnly: true
|
|
23972
24391
|
});
|
|
23973
|
-
return vtxos.filter((v) => !
|
|
24392
|
+
return vtxos.filter((v) => !isVtxoSpent(v) && !v.isUnrolled);
|
|
23974
24393
|
}
|
|
23975
24394
|
/** Total spendable balance (requires an indexer). */
|
|
23976
24395
|
async getBalance() {
|
|
@@ -24694,6 +25113,6 @@ function createDefaultPaymentRouter(wallet) {
|
|
|
24694
25113
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
24695
25114
|
*/
|
|
24696
25115
|
|
|
24697
|
-
export { ARKADE_MAGIC, ARKADE_SALTED_PREIMAGE_TAG, ARKADE_SWAP_PREIMAGE_TAG, ASSET_CARRIER_SATS, AbortError, ActivityRegistry, AmbiguousRouteError, ArkNote, ArkadeCash, ArkadeCashCreateError, AssetManager, BIP21, BIP21Error, BIP322, BLOCKED_UPGRADE_TIMEOUT_MS, Batch, CachingArkProvider, ChainedTxType, ConnectionDisposedError, ContractManager, ContractRepositoryImpl, ContractWatcher,
|
|
24698
|
-
//# sourceMappingURL=chunk-
|
|
24699
|
-
//# sourceMappingURL=chunk-
|
|
25116
|
+
export { ARKADE_MAGIC, ARKADE_SALTED_PREIMAGE_TAG, ARKADE_SWAP_PREIMAGE_TAG, ASSET_CARRIER_SATS, AbortError, ActivityRegistry, AmbiguousRouteError, ArkNote, ArkadeCash, ArkadeCashCreateError, AssetManager, BIP21, BIP21Error, BIP322, BLOCKED_UPGRADE_TIMEOUT_MS, Batch, CachingArkProvider, ChainedTxType, ConnectionDisposedError, ContractManager, ContractRepositoryImpl, ContractWatcher, DEFAULT_MESSAGE_TIMEOUTS, DEFAULT_MIN_BATCH_EXPIRY_SECONDS, DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, DatabaseUpgradeBlockedError, DelegateManagerImpl, DelegateNotConfiguredError, DelegatorManagerImpl, DelegatorNotConfiguredError, DescriptorIdentity, DescriptorSigningProviderMissingError, DustChangeError, ELECTRUM_TCP_HOST, ELECTRUM_WS_URL, ESPLORA_URL, ElectrumOnchainProvider, EmulatorPacket, EsploraProvider, Estimator, Extension, ExtensionNotFoundError, ForeignDescriptorError, HDDescriptorProvider, INTENT_TERMINAL_STATES, InMemoryContractRepository, InMemoryIntentRepository, InMemoryVirtualTxRepository, InMemoryWalletRepository, IndexedDBContractRepository, IndexedDBIntentRepository, IndexedDBVirtualTxRepository, IndexedDBWalletRepository, MAX_USED_SIGNING_DESCRIPTORS_LOOK_AHEAD, MESSAGE_BUS_INITIALIZING, MESSAGE_BUS_NOT_INITIALIZED, MIGRATION_KEY, MUTINYNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, MessageBus, MessageBusInitializingError, MessageBusNotInitializedError, MissingSigningDescriptorError, MnemonicIdentity, OnchainWallet, OversizedChangeError, P2A, PaymentRouter, PrevTxUnavailableError, REGTEST_MIN_BATCH_EXPIRY_SECONDS, REGTEST_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, Ramps, ReadonlyAssetManager, ReadonlyDescriptorIdentity, ReadonlySingleKey, ReadonlyWallet, ReadonlyWalletError, RestDelegateProvider, RestDelegatorProvider, RestEmulatorProvider, SIGNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, SeedIdentity, ServiceWorkerReadonlyWallet, ServiceWorkerTimeoutError, ServiceWorkerWallet, SingleKey, TxTree, TxType, TxWeightEstimator, UnannotatableInputError, UnilateralExit, UnknownPacket, Unroll, VtxoManager, Wallet2 as Wallet, WalletCannotAllocateAddressError, WalletCannotSignError, WalletMessageHandler, WalletNotInitializedError, WalletRepositoryImpl, WsElectrumChainSource, adoptContractDescriptor, arkAssetRail, arkRail, arkTarget, arkade_exports, assertFinalCommitmentMatchesValidated, assertIntentIdUnique, assertNoAssets, assertNoSelection, assertSendableAmount, assertSubmittedArkTxid, assertValidBatchExpiry, assertValidServerUnrollScript, assetMintResolver, assetsOf, attachPrevArkTxs, attachPrevoutTxs, awaitTransaction, boardingResolver, btcTarget, buildForfeitTx, buildOffchainTx, buildPreimageMessage, buildSaltedPreimageMessage, claimWithPreimageIdentity, classifyAgainstSignerSet, classifyContractSigner, closeDatabase, collabExitResolver, combineTapscriptSigs, contractFromArkContract, contractFromArkContractWithAddress, contractPreimage, contractSigner, createAssetPacket, createDefaultActivityRegistry, createDefaultPaymentRouter, createExitChainResolver, createManagedConnection, decodeArkContract, defaultBatchExpiryPolicy, defaultCheckpointExitDelayPolicy, deleteByIndex, deserializeAssets, deserializeExitPackage, deserializeUtxo, deserializeVtxo, encodeArkContract, exitObserverFor, extendVirtualCoinForContract, extractArkProviderUrl, gateExclusion, gatedContracts, getAllByIndexValues, getMigrationStatus, getRandomId, hasBoardingTxExpired, hasCandidates, intentMatchesFilter, intentPageBounds, invoiceTarget, isAddressAllocationCapable, isArkContract, isBatchSignable, isBtcAddress, isContractGenericallySpendable, isContractVtxoEvent, isCooperativelyMigratable, isDeterministicSigner, isDiscoverable, isHDAllocationCapable, isHDDeterministicSignCapable, isHDWalletCapable, isLightningInvoice, isLnurl, isMessageBusInitializingError, isMessageBusNotInitializedError, isPerArtifactDescriptor, isSigningIdentity, isSubdust, isTerminalIntentState, isValidArkAddress, isVtxoExpiringSoon, isVtxoForScript, isWatchedContract, logExcludedVtxos, makeHandle, matchServerCheckpoints, mergeChainedTxType, migrateWalletRepository, notifyExitObserved, onchainRail, openDatabase, outpointExclusion, outpointReasons, promisifyRequest, provisionClaimSecret, provisionRefundKey, registerWalletRestoreHook, requiresMigration, resolveAssetAmount, resolveBatchExpiryPolicy, resolveCheckpointExitDelayPolicy, resolveDescriptorSigner, resolvePrevTxs, resolveSendAmount, rollbackMigration, saveVtxosForContract, scriptFromArkAddress, selectCoinsWithAsset, selectVirtualCoins, selectionOf, serializeAssets, serializeExitPackage, serializeUtxo, serializeVtxo, setupServiceWorker, signAndSubmitOffchainTx, signerSetFromInfo, signingDescriptorIndex, strictSigningDescriptorIndex, toXOnlySignerHex, tryResolveSendAmount, validateBatchRecipients, validateConnectorsTxGraph, validateVtxoTxGraph, verifyTapscriptSignatures, waitForIncomingFunds, walletFeeSource, warnAndFilterVtxosForScript, withPrevTxs };
|
|
25117
|
+
//# sourceMappingURL=chunk-MLOZHTBN.js.map
|
|
25118
|
+
//# sourceMappingURL=chunk-MLOZHTBN.js.map
|