@arkade-os/sdk 0.5.5 → 0.5.7
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 +6 -6
- 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/{asyncStorageTaskQueue-BbH-THYJ.d.cts → asyncStorageTaskQueue-B9byr6ij.d.cts} +1 -1
- package/dist/{asyncStorageTaskQueue-BlvkJyTa.d.ts → asyncStorageTaskQueue-XP4CCdRY.d.ts} +1 -1
- package/dist/{chunk-XWUCNMPN.cjs → chunk-3NALVGMJ.cjs} +16 -16
- package/dist/{chunk-XWUCNMPN.cjs.map → chunk-3NALVGMJ.cjs.map} +1 -1
- package/dist/{chunk-FVVXCDNE.js → chunk-4AJRIM44.js} +4 -4
- package/dist/{chunk-FVVXCDNE.js.map → chunk-4AJRIM44.js.map} +1 -1
- package/dist/{chunk-AMH7Q3DF.cjs → chunk-MQUATTIM.cjs} +8 -8
- package/dist/{chunk-AMH7Q3DF.cjs.map → chunk-MQUATTIM.cjs.map} +1 -1
- package/dist/{chunk-CE46RS6L.js → chunk-MWEDDWFU.js} +4 -4
- package/dist/{chunk-CE46RS6L.js.map → chunk-MWEDDWFU.js.map} +1 -1
- package/dist/{chunk-7GIKLFHC.js → chunk-MWMO2ZQP.js} +3 -3
- package/dist/{chunk-7GIKLFHC.js.map → chunk-MWMO2ZQP.js.map} +1 -1
- package/dist/{chunk-HQQ4NRXI.cjs → chunk-MXCB6EVM.cjs} +15 -15
- package/dist/{chunk-HQQ4NRXI.cjs.map → chunk-MXCB6EVM.cjs.map} +1 -1
- package/dist/{chunk-KCL5AVML.cjs → chunk-OMPDPBT5.cjs} +3 -3
- package/dist/chunk-OMPDPBT5.cjs.map +1 -0
- package/dist/{chunk-OO2KEK64.js → chunk-RLD7DRSZ.js} +381 -54
- package/dist/chunk-RLD7DRSZ.js.map +1 -0
- package/dist/{chunk-T254PXSN.cjs → chunk-URGVQ5TQ.cjs} +795 -462
- package/dist/chunk-URGVQ5TQ.cjs.map +1 -0
- package/dist/{chunk-BCA6D255.js → chunk-V2DDN4MV.js} +3 -3
- package/dist/{chunk-BCA6D255.js.map → chunk-V2DDN4MV.js.map} +1 -1
- package/dist/{chunk-5SYUEVJH.cjs → chunk-V5WRO3P6.cjs} +10 -10
- package/dist/{chunk-5SYUEVJH.cjs.map → chunk-V5WRO3P6.cjs.map} +1 -1
- package/dist/{chunk-4I53THL6.js → chunk-VMVFRTF4.js} +3 -3
- package/dist/chunk-VMVFRTF4.js.map +1 -0
- package/dist/contracts/handlers/index.cjs +9 -9
- package/dist/contracts/handlers/index.d.cts +2 -2
- package/dist/contracts/handlers/index.d.ts +2 -2
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/{index-DCml4QJn.d.ts → index-18cDMayF.d.ts} +25 -25
- package/dist/{index-Bx-iArDs.d.ts → index-B_kcptF8.d.ts} +1 -1
- package/dist/{index-BWwVnJhU.d.cts → index-Ccfhdfvj.d.cts} +1 -1
- package/dist/{index-DkyzIzKL.d.cts → index-DDJFHfba.d.cts} +25 -25
- package/dist/index.cjs +335 -311
- package/dist/index.d.cts +89 -138
- package/dist/index.d.ts +89 -138
- package/dist/index.js +4 -4
- package/dist/{keyringDescriptorProvider-CS4w4PWd.d.ts → keyringDescriptorProvider-DL-jAiRO.d.ts} +158 -10
- package/dist/{keyringDescriptorProvider-CmHXrIXd.d.cts → keyringDescriptorProvider-Dtv0JWrT.d.cts} +158 -10
- package/dist/repositories/realm/index.cjs +37 -37
- package/dist/repositories/realm/index.cjs.map +1 -1
- package/dist/repositories/realm/index.d.cts +6 -6
- package/dist/repositories/realm/index.d.ts +6 -6
- package/dist/repositories/realm/index.js +6 -6
- package/dist/repositories/realm/index.js.map +1 -1
- package/dist/repositories/sqlite/index.cjs +35 -35
- package/dist/repositories/sqlite/index.cjs.map +1 -1
- package/dist/repositories/sqlite/index.d.cts +6 -6
- package/dist/repositories/sqlite/index.d.ts +6 -6
- package/dist/repositories/sqlite/index.js +5 -5
- package/dist/repositories/sqlite/index.js.map +1 -1
- package/dist/{taskRunner-DgMLSk_O.d.ts → taskRunner-DUafWu0o.d.ts} +1 -1
- package/dist/{taskRunner-buh6aFpG.d.cts → taskRunner-JYHaLPne.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 +15 -15
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +6 -6
- package/dist/wallet/expo/index.d.ts +6 -6
- 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 +2 -2
- package/dist/chunk-4I53THL6.js.map +0 -1
- package/dist/chunk-KCL5AVML.cjs.map +0 -1
- package/dist/chunk-OO2KEK64.js.map +0 -1
- package/dist/chunk-T254PXSN.cjs.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { programFromArtifact, isContractArtifact } from './chunk-V3ZLL5VY.js';
|
|
2
|
-
import { Packet, AssetId, AssetGroup, AssetInput, AssetOutput, Metadata, RestIndexerProvider, BufferReader, BufferWriter, IndexerUtxosUnsupportedError, AssetRef } from './chunk-
|
|
3
|
-
import { contractHandlers, speculativeReceiveMetadata, isMainnetDescriptor, descriptorIsOurs, deriveDescriptorLeafPubKey, deriveDescriptorLeafCompressedPubKey, normalizeToDescriptor, extractPubKey, parseHDDescriptor, identityDescriptor, DefaultVtxo, DelegateVtxo, WALLET_RECEIVE_SOURCE, BoardingContractHandler, DefaultContractHandler, exitSequence } from './chunk-
|
|
2
|
+
import { Packet, AssetId, AssetGroup, AssetInput, AssetOutput, Metadata, RestIndexerProvider, BufferReader, BufferWriter, IndexerUtxosUnsupportedError, AssetRef } from './chunk-MWMO2ZQP.js';
|
|
3
|
+
import { contractHandlers, speculativeReceiveMetadata, isMainnetDescriptor, descriptorIsOurs, deriveDescriptorLeafPubKey, deriveDescriptorLeafCompressedPubKey, normalizeToDescriptor, extractPubKey, parseHDDescriptor, identityDescriptor, DefaultVtxo, DelegateVtxo, WALLET_RECEIVE_SOURCE, BoardingContractHandler, DefaultContractHandler, exitSequence } from './chunk-V2DDN4MV.js';
|
|
4
4
|
import { witnessRefToBytes, validateProgram, toASM, stringifyArtifact, serializeArkadeContractParams, resolveAsm, parseArtifact, getOpcodeValue, getOpcodeName, fromASM, deserializeArkadeContractParams, computeArkadeScriptPublicKey, bytesToASM, asmToBytes, arkadeWitnessHash, arkadeScriptHash, UnsupportedProgramVersionError, SUPPORTED_PROGRAM_VERSION, OPCODE_VALUES, OPCODE_NAMES, bignum_exports, ArkadeScript, ArkadeProgramScript, ARKADE_OPS, ARKADE_OPCODE_VALUES, ARKADE_OPCODE_NAMES, ARKADE_OPCODES, ARKADE_OP, toXOnly, staticWitness, validateParamValue } from './chunk-DNFTHG73.js';
|
|
5
|
-
import { Transaction, requiresForfeit, setArkPsbtField, ConditionWitness, toOffchainInputFeeParams, normalizeVtxo, Proof, isVtxoSpent, getNormalizedVtxos, PrevArkTxField, craftToSpendTx, RestOperatorProvider, isVirtualCoin, getArkPsbtFields, CosignerPublicKey, ServerResponseMismatchError, isArkError, ArkErrorName, assertNonNegativeMs, isRetryableProviderError, OUTPOINT_QUERY_CHUNK_SIZE, getAllNormalizedVtxos, DEFAULT_PAGE_SIZE, VtxoTaprootTree, PrevoutTxField, OnchainCosignUnsupportedError, assertAllowedSighashTypes, OP_RETURN_EMPTY_PKSCRIPT, canSweepOnchain, baseFetch, assertTimerMs, isEventSourceError, isEventSourceUnavailableError, isPastExpiry, formatSighash, rateGate, OnchainCosignRejectedError, maybeArkError, canRecoverOnchain, READ_TIMEOUT_MS, OnchainCosignAmbiguousError, ArkError, resolveTimeHeight, canSpendOffchain, INFO_FETCH_TIMEOUT_MS, fetchVtxoCreatedAtByTxid, EXPIRY_MIN_PLAUSIBLE_MS, ProviderUnavailableError, ONCHAIN_COSIGN_REJECTED_PREFIX, ONCHAIN_COSIGN_AMBIGUOUS_PREFIX, ONCHAIN_COSIGN_UNSUPPORTED_PREFIX } from './chunk-
|
|
6
|
-
import { VtxoScript, __export, CSVMultisigTapscript, networks, getNetwork, DEFAULT_NETWORK, resolveEmulatorPubkey, timelockToSequence, decodeTapscript, CLTVMultisigTapscript, ConditionCSVMultisigTapscript, ArkAddress, sequenceToTimelock, DEFAULT_ARKADE_SERVER_URL, DEFAULT_NETWORK_NAME, scriptFromTapLeafScript, proofTapLeafScriptOf, getSequence, MultisigTapscript, DEFAULT_ARKADE_EMULATOR_URL,
|
|
5
|
+
import { Transaction, requiresForfeit, setArkPsbtField, ConditionWitness, toOffchainInputFeeParams, normalizeVtxo, Proof, isVtxoSpent, getNormalizedVtxos, PrevArkTxField, craftToSpendTx, RestOperatorProvider, isVirtualCoin, getArkPsbtFields, CosignerPublicKey, ServerResponseMismatchError, isArkError, ArkErrorName, assertNonNegativeMs, isRetryableProviderError, OUTPOINT_QUERY_CHUNK_SIZE, getAllNormalizedVtxos, DEFAULT_PAGE_SIZE, VtxoTaprootTree, PrevoutTxField, OnchainCosignUnsupportedError, assertAllowedSighashTypes, OP_RETURN_EMPTY_PKSCRIPT, canSweepOnchain, baseFetch, assertTimerMs, isEventSourceError, isEventSourceUnavailableError, isPastExpiry, formatSighash, rateGate, OnchainCosignRejectedError, maybeArkError, canRecoverOnchain, READ_TIMEOUT_MS, OnchainCosignAmbiguousError, ArkError, resolveTimeHeight, canSpendOffchain, INFO_FETCH_TIMEOUT_MS, fetchVtxoCreatedAtByTxid, EXPIRY_MIN_PLAUSIBLE_MS, ProviderUnavailableError, ONCHAIN_COSIGN_REJECTED_PREFIX, ONCHAIN_COSIGN_AMBIGUOUS_PREFIX, ONCHAIN_COSIGN_UNSUPPORTED_PREFIX } from './chunk-VMVFRTF4.js';
|
|
6
|
+
import { VtxoScript, __export, CSVMultisigTapscript, networks, getNetwork, DEFAULT_NETWORK, resolveEmulatorPubkey, timelockToSequence, decodeTapscript, CLTVMultisigTapscript, ConditionCSVMultisigTapscript, ArkAddress, sequenceToTimelock, DEFAULT_ARKADE_SERVER_URL, DEFAULT_NETWORK_NAME, scriptFromTapLeafScript, proofTapLeafScriptOf, getSequence, MultisigTapscript, DEFAULT_ARKADE_EMULATOR_URL, networkFromOperatorInfo, toBIP371TapTree } from './chunk-FDJ734CH.js';
|
|
7
7
|
import { entropyToMnemonic, mnemonicToSeedSync, validateMnemonic } from '@scure/bip39';
|
|
8
8
|
import { wordlist } from '@scure/bip39/wordlists/english.js';
|
|
9
9
|
import * as musig2 from '@scure/btc-signer/musig2.js';
|
|
@@ -1871,7 +1871,7 @@ async function collectPages(read) {
|
|
|
1871
1871
|
}
|
|
1872
1872
|
|
|
1873
1873
|
// src/repositories/intentRepository.ts
|
|
1874
|
-
var
|
|
1874
|
+
var ALL_BATCH_REGISTRATION_STATES = [
|
|
1875
1875
|
"waiting_to_submit",
|
|
1876
1876
|
"waiting_for_batch",
|
|
1877
1877
|
"batch_in_progress",
|
|
@@ -1887,7 +1887,7 @@ var BATCH_REGISTRATION_TERMINAL_STATES = /* @__PURE__ */ new Set([
|
|
|
1887
1887
|
function isTerminalBatchRegistrationState(s) {
|
|
1888
1888
|
return BATCH_REGISTRATION_TERMINAL_STATES.has(s);
|
|
1889
1889
|
}
|
|
1890
|
-
var
|
|
1890
|
+
var collectBatchRegistrations = (repository, filter) => collectPages((page) => repository.getBatchRegistrationsPage(filter, page));
|
|
1891
1891
|
function assertIntentIdUnique(intent, existing) {
|
|
1892
1892
|
if (intent.registrationId === void 0) return;
|
|
1893
1893
|
for (const e of existing) {
|
|
@@ -1919,7 +1919,7 @@ function intentMatchesFilter(i, f) {
|
|
|
1919
1919
|
}
|
|
1920
1920
|
var isTerminalIntentState = isTerminalBatchRegistrationState;
|
|
1921
1921
|
var INTENT_TERMINAL_STATES = BATCH_REGISTRATION_TERMINAL_STATES;
|
|
1922
|
-
var
|
|
1922
|
+
var collectIntents = collectBatchRegistrations;
|
|
1923
1923
|
|
|
1924
1924
|
// src/repositories/contractRepository.ts
|
|
1925
1925
|
function contractFilterMatchesNothing(filter) {
|
|
@@ -2123,14 +2123,22 @@ var EsploraProvider = class {
|
|
|
2123
2123
|
let anchorHeight;
|
|
2124
2124
|
const baseline = (async () => {
|
|
2125
2125
|
const [history, tip] = await Promise.allSettled([getAllTxs(), this.getChainTip()]);
|
|
2126
|
+
let failure;
|
|
2126
2127
|
if (history.status === "fulfilled") {
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2128
|
+
try {
|
|
2129
|
+
const keys = history.value.map(txKey2);
|
|
2130
|
+
for (const key of keys) seen.add(key);
|
|
2131
|
+
baselined = true;
|
|
2132
|
+
return;
|
|
2133
|
+
} catch (error) {
|
|
2134
|
+
failure = error;
|
|
2135
|
+
}
|
|
2136
|
+
} else {
|
|
2137
|
+
failure = history.reason;
|
|
2130
2138
|
}
|
|
2131
2139
|
console.warn(
|
|
2132
2140
|
"Could not baseline watched addresses; the first poll pass will establish it instead:",
|
|
2133
|
-
|
|
2141
|
+
failure
|
|
2134
2142
|
);
|
|
2135
2143
|
if (tip.status === "fulfilled") anchorHeight = tip.value.height;
|
|
2136
2144
|
})();
|
|
@@ -5663,10 +5671,22 @@ var VtxoManager = class _VtxoManager {
|
|
|
5663
5671
|
const arkAddress = await wallet.getAddress();
|
|
5664
5672
|
const totalAmount = deductOffchainOutputFee(subtotal, estimator, arkAddress);
|
|
5665
5673
|
if (totalAmount < dustAmount) return;
|
|
5666
|
-
await wallet.settle({
|
|
5674
|
+
const settledTxid = await wallet.settle({
|
|
5667
5675
|
inputs: batch,
|
|
5668
5676
|
outputs: [{ address: arkAddress, amount: totalAmount }]
|
|
5669
5677
|
});
|
|
5678
|
+
try {
|
|
5679
|
+
await wallet.correlateArkadeCashRecovery?.(
|
|
5680
|
+
contract.script,
|
|
5681
|
+
settledTxid,
|
|
5682
|
+
Number(totalAmount)
|
|
5683
|
+
);
|
|
5684
|
+
} catch (error) {
|
|
5685
|
+
console.error(
|
|
5686
|
+
`Failed to record arkcash recovery ${settledTxid} for ${contract.script}:`,
|
|
5687
|
+
error
|
|
5688
|
+
);
|
|
5689
|
+
}
|
|
5670
5690
|
}
|
|
5671
5691
|
if (vtxos.length === 0) return;
|
|
5672
5692
|
const spent = new Set(batch.map((vtxo) => `${vtxo.txid}:${vtxo.vout}`));
|
|
@@ -7086,16 +7106,100 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
7086
7106
|
return this.vtxoScript.address(addressHrp, this._serverPubKey);
|
|
7087
7107
|
}
|
|
7088
7108
|
};
|
|
7109
|
+
var ArkadeCashTracker = class {
|
|
7110
|
+
records = /* @__PURE__ */ new Map();
|
|
7111
|
+
get(id) {
|
|
7112
|
+
return this.records.get(id);
|
|
7113
|
+
}
|
|
7114
|
+
list() {
|
|
7115
|
+
return [...this.records.values()].sort((a, b) => b.createdAt - a.createdAt);
|
|
7116
|
+
}
|
|
7117
|
+
};
|
|
7118
|
+
function createArkadeCashTracker() {
|
|
7119
|
+
return new ArkadeCashTracker();
|
|
7120
|
+
}
|
|
7121
|
+
var unionByTxid = (a, b) => [
|
|
7122
|
+
...new Map([...a, ...b].map((entry) => [entry.txid, entry])).values()
|
|
7123
|
+
];
|
|
7124
|
+
function mergeArkadeCashRecord(prev, next) {
|
|
7125
|
+
if (!prev) return next;
|
|
7126
|
+
const lead = prev.action === "claimed" && next.action === "issued" ? prev : next;
|
|
7127
|
+
return {
|
|
7128
|
+
id: next.id,
|
|
7129
|
+
action: lead.action,
|
|
7130
|
+
outcome: lead.outcome,
|
|
7131
|
+
createdAt: Math.min(prev.createdAt, next.createdAt),
|
|
7132
|
+
issues: unionByTxid(prev.issues, next.issues),
|
|
7133
|
+
claims: unionByTxid(prev.claims, next.claims)
|
|
7134
|
+
};
|
|
7135
|
+
}
|
|
7136
|
+
function isArkadeCashRecord(value) {
|
|
7137
|
+
if (!value || typeof value !== "object") return false;
|
|
7138
|
+
const v = value;
|
|
7139
|
+
return typeof v.id === "string" && (v.action === "issued" || v.action === "claimed") && typeof v.createdAt === "number" && typeof v.outcome === "string" && Array.isArray(v.issues) && Array.isArray(v.claims);
|
|
7140
|
+
}
|
|
7141
|
+
function addArkadeCashRecord(records, record) {
|
|
7142
|
+
records.records.set(record.id, mergeArkadeCashRecord(records.get(record.id), record));
|
|
7143
|
+
}
|
|
7144
|
+
function arkadeCashId(cash) {
|
|
7145
|
+
return hex.encode(cash.vtxoScript.pkScript);
|
|
7146
|
+
}
|
|
7147
|
+
function arkadeCashResolver(records) {
|
|
7148
|
+
let index;
|
|
7149
|
+
const build = () => {
|
|
7150
|
+
const next = /* @__PURE__ */ new Map();
|
|
7151
|
+
for (const record of records.list()) {
|
|
7152
|
+
for (const { txid } of [...record.issues, ...record.claims]) {
|
|
7153
|
+
const touching = next.get(txid) ?? [];
|
|
7154
|
+
if (touching[touching.length - 1] !== record) touching.push(record);
|
|
7155
|
+
next.set(txid, touching);
|
|
7156
|
+
}
|
|
7157
|
+
}
|
|
7158
|
+
return next;
|
|
7159
|
+
};
|
|
7160
|
+
return {
|
|
7161
|
+
id: "arkade-cash",
|
|
7162
|
+
async prepare() {
|
|
7163
|
+
index = build();
|
|
7164
|
+
},
|
|
7165
|
+
resolve(tx) {
|
|
7166
|
+
if (tx.key.boardingTxid) return [];
|
|
7167
|
+
index ??= build();
|
|
7168
|
+
const txid = tx.key.arkTxid || tx.key.commitmentTxid;
|
|
7169
|
+
const isBatchRow = !tx.key.arkTxid;
|
|
7170
|
+
const direction = tx.type === "SENT" /* TxSent */ ? "issued" : "claimed";
|
|
7171
|
+
return (index.get(txid) ?? []).flatMap((record) => {
|
|
7172
|
+
const entries = direction === "issued" ? record.issues : record.claims;
|
|
7173
|
+
const match = entries.find(
|
|
7174
|
+
(entry) => entry.txid === txid && (!isBatchRow || entry.amount === tx.amount)
|
|
7175
|
+
);
|
|
7176
|
+
if (!match) return [];
|
|
7177
|
+
return [
|
|
7178
|
+
{
|
|
7179
|
+
groupId: `arkade-cash:${record.id}:${direction}`,
|
|
7180
|
+
label: direction === "issued" ? "Cash issued" : "Cash claimed",
|
|
7181
|
+
kind: "arkade-cash",
|
|
7182
|
+
outcome: record.outcome,
|
|
7183
|
+
metadata: { cashId: record.id, direction },
|
|
7184
|
+
amount: match.amount
|
|
7185
|
+
}
|
|
7186
|
+
];
|
|
7187
|
+
});
|
|
7188
|
+
}
|
|
7189
|
+
};
|
|
7190
|
+
}
|
|
7191
|
+
async function arkadeCashActivity(records, txs) {
|
|
7192
|
+
const activities = await buildActivities(txs, [arkadeCashResolver(records)]);
|
|
7193
|
+
return activities.filter((activity) => activity.intent?.kind === "arkade-cash");
|
|
7194
|
+
}
|
|
7089
7195
|
|
|
7090
7196
|
// src/wallet/intentReconciliation.ts
|
|
7091
|
-
var NON_TERMINAL_INTENT_STATES =
|
|
7092
|
-
(s) => !isTerminalIntentState(s)
|
|
7093
|
-
);
|
|
7197
|
+
var NON_TERMINAL_INTENT_STATES = ALL_BATCH_REGISTRATION_STATES.filter((s) => !isTerminalBatchRegistrationState(s));
|
|
7094
7198
|
function isConsumed(vtxo) {
|
|
7095
7199
|
return vtxo !== void 0 && isVtxoSpent(vtxo);
|
|
7096
7200
|
}
|
|
7097
7201
|
async function classifyIntent(intent, vtxosByOutpoint, now) {
|
|
7098
|
-
if (
|
|
7202
|
+
if (isTerminalBatchRegistrationState(intent.state)) return void 0;
|
|
7099
7203
|
const inputs = intent.proofInputs;
|
|
7100
7204
|
const consumed = inputs.map((o) => vtxosByOutpoint.get(outpointKey(o)));
|
|
7101
7205
|
if (inputs.length > 0 && consumed.every(isConsumed)) {
|
|
@@ -7118,7 +7222,7 @@ async function reconcileIntents(deps) {
|
|
|
7118
7222
|
const now = deps.now ?? Date.now;
|
|
7119
7223
|
let intents;
|
|
7120
7224
|
try {
|
|
7121
|
-
intents = await
|
|
7225
|
+
intents = await collectBatchRegistrations(deps.intentRepository, {
|
|
7122
7226
|
states: [...NON_TERMINAL_INTENT_STATES]
|
|
7123
7227
|
});
|
|
7124
7228
|
} catch (e) {
|
|
@@ -7143,7 +7247,7 @@ async function reconcileIntents(deps) {
|
|
|
7143
7247
|
if (isInFlight(intent, deps)) continue;
|
|
7144
7248
|
const next = await classifyIntent(intent, vtxosByOutpoint, nowMs) ?? await releaseFromServer(intent, deps, nowMs);
|
|
7145
7249
|
if (!next) continue;
|
|
7146
|
-
const [fresh] = await
|
|
7250
|
+
const [fresh] = await collectBatchRegistrations(deps.intentRepository, {
|
|
7147
7251
|
proofTxIds: [intent.proofTxId]
|
|
7148
7252
|
});
|
|
7149
7253
|
if (!fresh || fresh.state !== intent.state) continue;
|
|
@@ -7156,7 +7260,7 @@ async function reconcileIntents(deps) {
|
|
|
7156
7260
|
async function releaseIntents(deps) {
|
|
7157
7261
|
let intents;
|
|
7158
7262
|
try {
|
|
7159
|
-
intents = await
|
|
7263
|
+
intents = await collectBatchRegistrations(deps.intentRepository, {
|
|
7160
7264
|
states: [...NON_TERMINAL_INTENT_STATES]
|
|
7161
7265
|
});
|
|
7162
7266
|
} catch (e) {
|
|
@@ -7212,7 +7316,7 @@ function dedupeOutpoints(outpoints) {
|
|
|
7212
7316
|
|
|
7213
7317
|
// src/wallet/intentStateReducer.ts
|
|
7214
7318
|
function reduceIntentState(current, event) {
|
|
7215
|
-
if (
|
|
7319
|
+
if (isTerminalBatchRegistrationState(current)) return current;
|
|
7216
7320
|
switch (event.type) {
|
|
7217
7321
|
case "batch_started" /* BatchStarted */:
|
|
7218
7322
|
return "batch_in_progress";
|
|
@@ -7245,7 +7349,7 @@ async function persistTransition(deps, event) {
|
|
|
7245
7349
|
const repo = deps.intentRepository;
|
|
7246
7350
|
if (!repo) return;
|
|
7247
7351
|
try {
|
|
7248
|
-
const cur = (await
|
|
7352
|
+
const cur = (await collectBatchRegistrations(repo, { proofTxIds: [deps.intentTxId] }))[0];
|
|
7249
7353
|
if (!cur) return;
|
|
7250
7354
|
const next = applySettlementEventToIntent(cur, event);
|
|
7251
7355
|
if (next) await repo.saveBatchRegistration(next);
|
|
@@ -8997,7 +9101,8 @@ var InMemoryBatchRegistrationRepository = class {
|
|
|
8997
9101
|
async getLockedVtxoOutpoints() {
|
|
8998
9102
|
const out = [];
|
|
8999
9103
|
for (const i of this.byId.values())
|
|
9000
|
-
if (!
|
|
9104
|
+
if (!isTerminalBatchRegistrationState(i.state))
|
|
9105
|
+
for (const o of i.proofInputs) out.push({ ...o });
|
|
9001
9106
|
return out;
|
|
9002
9107
|
}
|
|
9003
9108
|
/** @deprecated Use {@link saveBatchRegistration}. */
|
|
@@ -9490,7 +9595,8 @@ var IndexedDBBatchRegistrationRepository = class {
|
|
|
9490
9595
|
const all = await promisifyRequest(store.getAll());
|
|
9491
9596
|
const out = [];
|
|
9492
9597
|
for (const i of all)
|
|
9493
|
-
if (!
|
|
9598
|
+
if (!isTerminalBatchRegistrationState(i.state))
|
|
9599
|
+
for (const o of i.intentVtxos) out.push(o);
|
|
9494
9600
|
return out;
|
|
9495
9601
|
}
|
|
9496
9602
|
/** @deprecated Use {@link saveBatchRegistration}. */
|
|
@@ -14520,7 +14626,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14520
14626
|
* before binding the answer into a covenant to fail closed instead of getting the snapshot.
|
|
14521
14627
|
*
|
|
14522
14628
|
* @returns The operator's info
|
|
14523
|
-
* @see
|
|
14629
|
+
* @see OperatorInfo
|
|
14524
14630
|
*/
|
|
14525
14631
|
async getOperatorInfo(opts) {
|
|
14526
14632
|
const { info, source, lastOnlineAt } = await resolveArkInfo(
|
|
@@ -14623,7 +14729,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14623
14729
|
if (!resolvedService) throw new Error("indexerProvider is unresolved");
|
|
14624
14730
|
indexerProvider = resolvedService.indexerProvider;
|
|
14625
14731
|
}
|
|
14626
|
-
const network =
|
|
14732
|
+
const network = networkFromOperatorInfo(info);
|
|
14627
14733
|
if ("descriptor" in config.identity) {
|
|
14628
14734
|
const descriptor = config.identity.descriptor;
|
|
14629
14735
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -14976,10 +15082,11 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14976
15082
|
* Return wallet transaction history derived from Arkade state and boarding transactions.
|
|
14977
15083
|
*/
|
|
14978
15084
|
async getTransactionHistory() {
|
|
14979
|
-
const [
|
|
15085
|
+
const [fullSnapshot, { boardingTxs, commitmentsToIgnore }] = await Promise.all([
|
|
14980
15086
|
this.contractSnapshot(),
|
|
14981
15087
|
this.getBoardingTxs()
|
|
14982
15088
|
]);
|
|
15089
|
+
const snapshot = fullSnapshot.filter(({ contract }) => !isRecoveryOnlyContract(contract));
|
|
14983
15090
|
const allVtxos = snapshot.flatMap((_) => _.vtxos);
|
|
14984
15091
|
const resolveTxCreatedAt = (txids) => fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
|
|
14985
15092
|
return buildTransactionHistory(
|
|
@@ -15935,7 +16042,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15935
16042
|
}
|
|
15936
16043
|
/**
|
|
15937
16044
|
* @internal Sole write path for `serverUnrollScript`; called by
|
|
15938
|
-
* {@link Wallet._doRotateServerSigner} with the rotating `
|
|
16045
|
+
* {@link Wallet._doRotateServerSigner} with the rotating `OperatorInfo`'s checkpoint script.
|
|
15939
16046
|
*/
|
|
15940
16047
|
setServerUnrollScriptForRotation(script) {
|
|
15941
16048
|
this._serverUnrollScript = script;
|
|
@@ -17300,7 +17407,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17300
17407
|
if (!repo) return;
|
|
17301
17408
|
try {
|
|
17302
17409
|
const now = Date.now();
|
|
17303
|
-
const existing = (await
|
|
17410
|
+
const existing = (await collectBatchRegistrations(repo, { proofTxIds: [intentTxId] }))[0];
|
|
17304
17411
|
if (existing && isTerminalBatchRegistrationState(existing.state)) {
|
|
17305
17412
|
return;
|
|
17306
17413
|
}
|
|
@@ -17836,11 +17943,17 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17836
17943
|
const myPkScript = ArkAddress.decode(await this.getAddress()).pkScript;
|
|
17837
17944
|
let { spendable, recoverable, unclaimed } = this.classifyCashVtxos(vtxos);
|
|
17838
17945
|
let swept = 0;
|
|
17946
|
+
const claims = [];
|
|
17839
17947
|
const drainable = vtxos.filter(
|
|
17840
17948
|
(vtxo) => !isSubdust(vtxo, this.dustAmount) && !vtxo.isUnrolled
|
|
17841
17949
|
);
|
|
17842
17950
|
if (drainable.length > 0) {
|
|
17843
|
-
let drained = {
|
|
17951
|
+
let drained = {
|
|
17952
|
+
count: 0,
|
|
17953
|
+
swept: 0,
|
|
17954
|
+
claimed: /* @__PURE__ */ new Set(),
|
|
17955
|
+
claims: []
|
|
17956
|
+
};
|
|
17844
17957
|
try {
|
|
17845
17958
|
drained = await this.finalizePendingCashTxs(
|
|
17846
17959
|
cash,
|
|
@@ -17851,6 +17964,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17851
17964
|
} catch (error) {
|
|
17852
17965
|
console.error("Failed to drain pending arkadeCash txs:", error);
|
|
17853
17966
|
}
|
|
17967
|
+
claims.push(...drained.claims);
|
|
17854
17968
|
if (drained.count > 0) {
|
|
17855
17969
|
vtxos = await this.fetchAllVtxos(scripts);
|
|
17856
17970
|
({ spendable, recoverable, unclaimed } = this.classifyCashVtxos(vtxos));
|
|
@@ -17868,7 +17982,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17868
17982
|
);
|
|
17869
17983
|
for (const vtxo of spendable) {
|
|
17870
17984
|
try {
|
|
17871
|
-
await signAndSubmitOffchainTx({
|
|
17985
|
+
const registeredTxid = await signAndSubmitOffchainTx({
|
|
17872
17986
|
identity: cash.identity,
|
|
17873
17987
|
provider: this.arkProvider,
|
|
17874
17988
|
inputs: [
|
|
@@ -17884,6 +17998,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17884
17998
|
serverUnrollScript,
|
|
17885
17999
|
oneShot: this.oneShotSubmit
|
|
17886
18000
|
});
|
|
18001
|
+
claims.push({ txid: registeredTxid, amount: vtxo.value });
|
|
17887
18002
|
swept += vtxo.value;
|
|
17888
18003
|
} catch (error) {
|
|
17889
18004
|
console.error(
|
|
@@ -17914,6 +18029,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17914
18029
|
}
|
|
17915
18030
|
}
|
|
17916
18031
|
return {
|
|
18032
|
+
claims,
|
|
17917
18033
|
swept,
|
|
17918
18034
|
recovering: {
|
|
17919
18035
|
amount: recovering.reduce((total, vtxo) => total + vtxo.value, 0),
|
|
@@ -18031,6 +18147,36 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
18031
18147
|
}
|
|
18032
18148
|
await manager.deleteContract(script);
|
|
18033
18149
|
}
|
|
18150
|
+
/**
|
|
18151
|
+
* Correlate an imported voucher's settlement with the voucher record. This
|
|
18152
|
+
* is deliberately kept on wallet state rather than being inferred from the
|
|
18153
|
+
* generic recovery row, which has no safe public correlation key. The
|
|
18154
|
+
* imported contract carries no cash id, so its script is the join key:
|
|
18155
|
+
* the script is the voucher id.
|
|
18156
|
+
*/
|
|
18157
|
+
async correlateArkadeCashRecovery(cashId, txid, amount, outcome = "recovered") {
|
|
18158
|
+
await updateWalletState(this.walletRepository, (state) => {
|
|
18159
|
+
const raw = state.settings?.arkadeCashRecovery;
|
|
18160
|
+
const entries = Array.isArray(raw) ? raw : [];
|
|
18161
|
+
const index = entries.findIndex(
|
|
18162
|
+
(entry) => isArkadeCashRecord(entry) && entry.id === cashId
|
|
18163
|
+
);
|
|
18164
|
+
const previous = index >= 0 ? entries[index] : void 0;
|
|
18165
|
+
if (previous?.claims.some((claim) => claim.txid === txid)) return state;
|
|
18166
|
+
const next = mergeArkadeCashRecord(previous, {
|
|
18167
|
+
id: cashId,
|
|
18168
|
+
action: "claimed",
|
|
18169
|
+
outcome,
|
|
18170
|
+
createdAt: Math.floor(Date.now() / 1e3),
|
|
18171
|
+
issues: [],
|
|
18172
|
+
claims: [{ txid, amount }]
|
|
18173
|
+
});
|
|
18174
|
+
const updated = [...entries];
|
|
18175
|
+
if (index >= 0) updated[index] = next;
|
|
18176
|
+
else updated.push(next);
|
|
18177
|
+
return { ...state, settings: { ...state.settings, arkadeCashRecovery: updated } };
|
|
18178
|
+
});
|
|
18179
|
+
}
|
|
18034
18180
|
/**
|
|
18035
18181
|
* Split the VTXOs at an arkadeCash address into three buckets: the ones the
|
|
18036
18182
|
* thin sweep can move (`spendable`), the operator-swept ones that must go
|
|
@@ -18088,7 +18234,12 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
18088
18234
|
* @returns Txs finalized, sats paid to this wallet, and the outpoints consumed to pay it.
|
|
18089
18235
|
*/
|
|
18090
18236
|
async finalizePendingCashTxs(cash, vtxos, cashScript, myPkScript) {
|
|
18091
|
-
const result = {
|
|
18237
|
+
const result = {
|
|
18238
|
+
count: 0,
|
|
18239
|
+
swept: 0,
|
|
18240
|
+
claimed: /* @__PURE__ */ new Set(),
|
|
18241
|
+
claims: []
|
|
18242
|
+
};
|
|
18092
18243
|
const inputs = vtxos.map((vtxo) => ({
|
|
18093
18244
|
...vtxo,
|
|
18094
18245
|
forfeitTapLeafScript: cashScript.forfeit(),
|
|
@@ -18145,6 +18296,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
18145
18296
|
result.count++;
|
|
18146
18297
|
const paidToMe = this.arkTxAmountPaidTo(pendingTx.finalArkTx, myPkScriptHex);
|
|
18147
18298
|
if (paidToMe === 0) continue;
|
|
18299
|
+
result.claims.push({ txid: pendingTx.arkTxid, amount: paidToMe });
|
|
18148
18300
|
result.swept += paidToMe;
|
|
18149
18301
|
for (const checkpoint of checkpointTxs) {
|
|
18150
18302
|
for (let i = 0; i < checkpoint.inputsLength; i++) {
|
|
@@ -19004,13 +19156,20 @@ async function waitForIncomingFunds(wallet, options) {
|
|
|
19004
19156
|
let settled = false;
|
|
19005
19157
|
let timeoutId;
|
|
19006
19158
|
let onAbort;
|
|
19159
|
+
const stopSafely = (stop) => {
|
|
19160
|
+
try {
|
|
19161
|
+
stop();
|
|
19162
|
+
} catch (e) {
|
|
19163
|
+
console.warn("waitForIncomingFunds teardown failed", e);
|
|
19164
|
+
}
|
|
19165
|
+
};
|
|
19007
19166
|
return new Promise((resolve, reject) => {
|
|
19008
19167
|
const settle = (deliver) => {
|
|
19009
19168
|
if (settled) return;
|
|
19010
19169
|
settled = true;
|
|
19011
19170
|
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
19012
19171
|
if (onAbort) signal?.removeEventListener("abort", onAbort);
|
|
19013
|
-
stopFunc
|
|
19172
|
+
if (stopFunc) stopSafely(stopFunc);
|
|
19014
19173
|
deliver();
|
|
19015
19174
|
};
|
|
19016
19175
|
const cancel = (reason) => settle(() => reject(reason));
|
|
@@ -19024,16 +19183,20 @@ async function waitForIncomingFunds(wallet, options) {
|
|
|
19024
19183
|
timeoutMs
|
|
19025
19184
|
);
|
|
19026
19185
|
}
|
|
19027
|
-
|
|
19028
|
-
|
|
19029
|
-
|
|
19030
|
-
|
|
19031
|
-
|
|
19032
|
-
|
|
19033
|
-
|
|
19034
|
-
|
|
19186
|
+
try {
|
|
19187
|
+
wallet.notifyIncomingFunds((funds) => {
|
|
19188
|
+
const hasFunds = funds.type === "utxo" ? funds.coins.length > 0 : funds.newVtxos.length > 0;
|
|
19189
|
+
if (settled || !hasFunds) return;
|
|
19190
|
+
settle(() => resolve(funds));
|
|
19191
|
+
}).then((stop) => {
|
|
19192
|
+
stopFunc = stop;
|
|
19193
|
+
if (settled) stopSafely(stop);
|
|
19194
|
+
}).catch((error) => {
|
|
19195
|
+
cancel(error);
|
|
19196
|
+
});
|
|
19197
|
+
} catch (error) {
|
|
19035
19198
|
cancel(error);
|
|
19036
|
-
}
|
|
19199
|
+
}
|
|
19037
19200
|
});
|
|
19038
19201
|
}
|
|
19039
19202
|
|
|
@@ -20045,6 +20208,51 @@ var Ramps = class {
|
|
|
20045
20208
|
return { change, changeAddress };
|
|
20046
20209
|
}
|
|
20047
20210
|
};
|
|
20211
|
+
function groupByTxid(coins) {
|
|
20212
|
+
const totals = /* @__PURE__ */ new Map();
|
|
20213
|
+
for (const { txid, value } of coins) totals.set(txid, (totals.get(txid) ?? 0) + value);
|
|
20214
|
+
return [...totals].map(([txid, amount]) => ({ txid, amount }));
|
|
20215
|
+
}
|
|
20216
|
+
async function readArkadeCash(token, indexer, info, onchain) {
|
|
20217
|
+
const cash = ArkadeCash.fromString(token);
|
|
20218
|
+
const signer = classifyAgainstSignerSet(hex.encode(cash.serverPubKey), signerSetFromInfo(info));
|
|
20219
|
+
if (signer.status === "UNKNOWN_SIGNER") {
|
|
20220
|
+
throw new Error("ArkadeCash belongs to another operator");
|
|
20221
|
+
}
|
|
20222
|
+
const coins = await getAllNormalizedVtxos(indexer, [arkadeCashId(cash)]);
|
|
20223
|
+
return classifyArkadeCash(
|
|
20224
|
+
coins,
|
|
20225
|
+
info.dust,
|
|
20226
|
+
await resolveTimeHeight(onchain),
|
|
20227
|
+
signer.status === "EXPIRED"
|
|
20228
|
+
);
|
|
20229
|
+
}
|
|
20230
|
+
function classifyArkadeCash(coins, dust, now, awaitingSweep = false) {
|
|
20231
|
+
const eligible = coins.filter(
|
|
20232
|
+
(coin) => coin.value >= Number(dust) && !(coin.assets && coin.assets.length > 0)
|
|
20233
|
+
);
|
|
20234
|
+
const hasSpent = eligible.some(isVtxoSpent);
|
|
20235
|
+
const hasLive = eligible.some((coin) => !isVtxoSpent(coin) && !coin.isUnrolled);
|
|
20236
|
+
const hasExit = eligible.some((coin) => !isVtxoSpent(coin) && coin.isUnrolled);
|
|
20237
|
+
const recoverable = eligible.some((coin) => !isVtxoSpent(coin) && coin.isSwept);
|
|
20238
|
+
const elapsedBatch = eligible.some(
|
|
20239
|
+
(coin) => !isVtxoSpent(coin) && !coin.isSwept && isPastExpiry(coin, now)
|
|
20240
|
+
);
|
|
20241
|
+
return {
|
|
20242
|
+
status: eligible.length === 0 ? "unissued" : hasExit && !hasLive ? "exited" : hasSpent && !hasLive ? "claimed" : recoverable ? "recovering" : elapsedBatch || awaitingSweep ? "expired" : "available",
|
|
20243
|
+
amount: eligible.reduce((sum, coin) => sum + (isVtxoSpent(coin) ? 0 : coin.value), 0),
|
|
20244
|
+
issues: groupByTxid(eligible),
|
|
20245
|
+
claims: groupByTxid(
|
|
20246
|
+
// `||`: the indexer reports an unset id as an empty string, not as absent.
|
|
20247
|
+
eligible.flatMap((coin) => {
|
|
20248
|
+
const txid = coin.arkTxId || coin.settledBy;
|
|
20249
|
+
return txid ? [{ txid, value: coin.value }] : [];
|
|
20250
|
+
})
|
|
20251
|
+
)
|
|
20252
|
+
};
|
|
20253
|
+
}
|
|
20254
|
+
|
|
20255
|
+
// src/wallet/serviceWorker/wallet-message-handler.ts
|
|
20048
20256
|
var WalletNotInitializedError = class extends Error {
|
|
20049
20257
|
constructor() {
|
|
20050
20258
|
super("Wallet handler not initialized");
|
|
@@ -20079,6 +20287,25 @@ function deserializeAggregateError(payload) {
|
|
|
20079
20287
|
});
|
|
20080
20288
|
return new AggregateError(errs, payload.message);
|
|
20081
20289
|
}
|
|
20290
|
+
function isSerializedArkadeCashCreateError(value) {
|
|
20291
|
+
if (!value || typeof value !== "object") return false;
|
|
20292
|
+
const v = value;
|
|
20293
|
+
return v.name === "ArkadeCashCreateError" && typeof v.message === "string" && typeof v.cash === "string" && !!v.cause && typeof v.cause.name === "string" && typeof v.cause.message === "string";
|
|
20294
|
+
}
|
|
20295
|
+
function serializeArkadeCashCreateError(error) {
|
|
20296
|
+
const cause = error.cause;
|
|
20297
|
+
return {
|
|
20298
|
+
name: "ArkadeCashCreateError",
|
|
20299
|
+
message: error.message,
|
|
20300
|
+
cash: error.cash,
|
|
20301
|
+
cause: cause instanceof Error ? { name: cause.name, message: cause.message } : { name: "Error", message: String(cause) }
|
|
20302
|
+
};
|
|
20303
|
+
}
|
|
20304
|
+
function deserializeArkadeCashCreateError(payload) {
|
|
20305
|
+
const cause = new Error(payload.cause.message);
|
|
20306
|
+
cause.name = payload.cause.name;
|
|
20307
|
+
return new ArkadeCashCreateError(payload.cash, cause);
|
|
20308
|
+
}
|
|
20082
20309
|
var ReadonlyWalletError = class extends Error {
|
|
20083
20310
|
constructor() {
|
|
20084
20311
|
super("Read-only wallet: operation requires signing");
|
|
@@ -20092,6 +20319,7 @@ var DelegateNotConfiguredError = class extends Error {
|
|
|
20092
20319
|
}
|
|
20093
20320
|
};
|
|
20094
20321
|
var DEFAULT_MESSAGE_TAG = "WALLET_UPDATER";
|
|
20322
|
+
var isLongRunningCashAction = (request) => request.action === "create" || request.action === "claim";
|
|
20095
20323
|
function unsupportedByManager(method) {
|
|
20096
20324
|
return new Error(`Contract manager does not support ${method}`);
|
|
20097
20325
|
}
|
|
@@ -20327,7 +20555,10 @@ var WalletMessageHandler = class {
|
|
|
20327
20555
|
message.type === "MIGRATE_DEPRECATED_SIGNER_VTXOS" || // HD restore walks the index range with one indexer round-trip per
|
|
20328
20556
|
// step until it hits gapLimit consecutive unused indices. The bus
|
|
20329
20557
|
// deadline must not race the scan; liveness stays covered by PING.
|
|
20330
|
-
message.type === "RESTORE_WALLET" ||
|
|
20558
|
+
message.type === "RESTORE_WALLET" || // `create` and `claim` run sends and sweeps. A bus deadline would
|
|
20559
|
+
// answer with a timeout error and drop the token or txids that the
|
|
20560
|
+
// finished handler could still deliver.
|
|
20561
|
+
message.type === "ARKADE_CASH" && isLongRunningCashAction(message.payload) || message.type === "COSIGN_ONCHAIN_TX" || message.type === "SEND_ONCHAIN";
|
|
20331
20562
|
}
|
|
20332
20563
|
async handleMessage(message) {
|
|
20333
20564
|
const id = message.id;
|
|
@@ -20370,6 +20601,82 @@ var WalletMessageHandler = class {
|
|
|
20370
20601
|
payload: { address }
|
|
20371
20602
|
});
|
|
20372
20603
|
}
|
|
20604
|
+
case "ARKADE_CASH": {
|
|
20605
|
+
const request = message.payload;
|
|
20606
|
+
switch (request.action) {
|
|
20607
|
+
case "get": {
|
|
20608
|
+
const cash = ArkadeCash.fromString(request.token);
|
|
20609
|
+
const report = await readArkadeCash(
|
|
20610
|
+
request.token,
|
|
20611
|
+
this.readonlyWallet.indexerProvider,
|
|
20612
|
+
await this.readonlyWallet.getArkadeInfo(),
|
|
20613
|
+
this.readonlyWallet.onchainProvider
|
|
20614
|
+
);
|
|
20615
|
+
return this.tagged({
|
|
20616
|
+
id,
|
|
20617
|
+
type: "ARKADE_CASH",
|
|
20618
|
+
payload: { action: "get", cashId: arkadeCashId(cash), ...report }
|
|
20619
|
+
});
|
|
20620
|
+
}
|
|
20621
|
+
case "create": {
|
|
20622
|
+
try {
|
|
20623
|
+
const token = await this.requireWallet().createCash(request.amount);
|
|
20624
|
+
return this.tagged({
|
|
20625
|
+
id,
|
|
20626
|
+
type: "ARKADE_CASH",
|
|
20627
|
+
payload: { action: "create", token }
|
|
20628
|
+
});
|
|
20629
|
+
} catch (error) {
|
|
20630
|
+
if (!(error instanceof ArkadeCashCreateError)) throw error;
|
|
20631
|
+
return this.tagged({
|
|
20632
|
+
id,
|
|
20633
|
+
error: serializeArkadeCashCreateError(
|
|
20634
|
+
error
|
|
20635
|
+
)
|
|
20636
|
+
});
|
|
20637
|
+
}
|
|
20638
|
+
}
|
|
20639
|
+
case "activities": {
|
|
20640
|
+
const records = createArkadeCashTracker();
|
|
20641
|
+
request.records.forEach(
|
|
20642
|
+
(record) => addArkadeCashRecord(records, record)
|
|
20643
|
+
);
|
|
20644
|
+
const state = await this.walletRepository?.getWalletState();
|
|
20645
|
+
const recovered = state?.settings?.arkadeCashRecovery;
|
|
20646
|
+
if (Array.isArray(recovered)) {
|
|
20647
|
+
recovered.filter(isArkadeCashRecord).forEach((record) => addArkadeCashRecord(records, record));
|
|
20648
|
+
}
|
|
20649
|
+
return this.tagged({
|
|
20650
|
+
id,
|
|
20651
|
+
type: "ARKADE_CASH",
|
|
20652
|
+
payload: {
|
|
20653
|
+
action: "activities",
|
|
20654
|
+
activities: await arkadeCashActivity(
|
|
20655
|
+
records,
|
|
20656
|
+
await this.buildTransactionHistoryFromCache() ?? []
|
|
20657
|
+
)
|
|
20658
|
+
}
|
|
20659
|
+
});
|
|
20660
|
+
}
|
|
20661
|
+
case "claim": {
|
|
20662
|
+
const result = await this.requireWallet().claimCash(request.token);
|
|
20663
|
+
return this.tagged({
|
|
20664
|
+
id,
|
|
20665
|
+
type: "ARKADE_CASH",
|
|
20666
|
+
payload: { action: "claim", ...result }
|
|
20667
|
+
});
|
|
20668
|
+
}
|
|
20669
|
+
case "reveal": {
|
|
20670
|
+
const record = ArkadeCash.fromString(request.token);
|
|
20671
|
+
return this.tagged({
|
|
20672
|
+
id,
|
|
20673
|
+
type: "ARKADE_CASH",
|
|
20674
|
+
payload: { action: "reveal", cashId: arkadeCashId(record) }
|
|
20675
|
+
});
|
|
20676
|
+
}
|
|
20677
|
+
}
|
|
20678
|
+
return this.tagged({ id, error: new Error("Unknown Arkade Cash action") });
|
|
20679
|
+
}
|
|
20373
20680
|
case "GET_OPERATOR_INFO":
|
|
20374
20681
|
case "GET_ARKADE_INFO": {
|
|
20375
20682
|
const { payload } = message;
|
|
@@ -21340,9 +21647,8 @@ var WalletMessageHandler = class {
|
|
|
21340
21647
|
* arkcash) are excluded by default, mirroring {@link ReadonlyWallet.getVtxos}:
|
|
21341
21648
|
* they are settled in their own isolated intent and must stay out of the
|
|
21342
21649
|
* wallet's balance / VTXO / coin-selection / pending-tx views that read this.
|
|
21343
|
-
*
|
|
21344
|
-
*
|
|
21345
|
-
* directly and does include them.
|
|
21650
|
+
* Transaction history excludes them too, as does the non-worker
|
|
21651
|
+
* `getTransactionHistory`.
|
|
21346
21652
|
*/
|
|
21347
21653
|
async getVtxosFromRepo(options) {
|
|
21348
21654
|
return (await this.repoSnapshot(options)).vtxos;
|
|
@@ -21360,8 +21666,7 @@ var WalletMessageHandler = class {
|
|
|
21360
21666
|
* what it knows is closed — so the coins of a just-registered escrowed
|
|
21361
21667
|
* contract would count as available until the next poll.
|
|
21362
21668
|
*
|
|
21363
|
-
* Recovery-only contracts are skipped
|
|
21364
|
-
* {@link getVtxosFromRepo}).
|
|
21669
|
+
* Recovery-only contracts are skipped (see {@link getVtxosFromRepo}).
|
|
21365
21670
|
*/
|
|
21366
21671
|
async repoSnapshot(options = {}) {
|
|
21367
21672
|
const repository = this.walletRepository;
|
|
@@ -21385,9 +21690,7 @@ var WalletMessageHandler = class {
|
|
|
21385
21690
|
void addressPromise.catch(() => void 0);
|
|
21386
21691
|
const manager = await wallet.getContractManager();
|
|
21387
21692
|
const contracts = await manager.getContracts();
|
|
21388
|
-
const eligible = contracts.filter(
|
|
21389
|
-
(contract) => options.includeRecoveryOnly || !isRecoveryOnlyContract(contract)
|
|
21390
|
-
);
|
|
21693
|
+
const eligible = contracts.filter((contract) => !isRecoveryOnlyContract(contract));
|
|
21391
21694
|
const listsPromise = Promise.all(
|
|
21392
21695
|
eligible.map((contract) => getVtxosForContract(repository, contract, options))
|
|
21393
21696
|
);
|
|
@@ -21438,7 +21741,7 @@ var WalletMessageHandler = class {
|
|
|
21438
21741
|
async buildTransactionHistoryFromCache() {
|
|
21439
21742
|
if (!this.readonlyWallet) return null;
|
|
21440
21743
|
const [{ snapshot, vtxos }, { boardingTxs, commitmentsToIgnore }] = await Promise.all([
|
|
21441
|
-
this.repoSnapshot(
|
|
21744
|
+
this.repoSnapshot(),
|
|
21442
21745
|
this.readonlyWallet.getBoardingTxs()
|
|
21443
21746
|
]);
|
|
21444
21747
|
const indexerProvider = this.indexerProvider;
|
|
@@ -21553,6 +21856,8 @@ var DEFAULT_MESSAGE_TIMEOUTS = {
|
|
|
21553
21856
|
RECOVER_VTXOS: 5e4,
|
|
21554
21857
|
RENEW_VTXOS: 5e4,
|
|
21555
21858
|
SWEEP_EXPIRED_BOARDING_UTXOS: 5e4,
|
|
21859
|
+
// Only `get`/`activities`/`reveal`: `create` and `claim` stream with no deadline.
|
|
21860
|
+
ARKADE_CASH: 5e4,
|
|
21556
21861
|
COSIGN_ONCHAIN_TX: 5e4,
|
|
21557
21862
|
SEND_ONCHAIN: 5e4,
|
|
21558
21863
|
// Streaming/long-running like RENEW_VTXOS (rotation + settle); the value is
|
|
@@ -21712,6 +22017,28 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
21712
22017
|
}
|
|
21713
22018
|
serviceWorker;
|
|
21714
22019
|
messageTag;
|
|
22020
|
+
arkadeCash = (request) => this.cashRequest(request);
|
|
22021
|
+
async cashRequest(request) {
|
|
22022
|
+
const message = {
|
|
22023
|
+
id: getRandomId(),
|
|
22024
|
+
tag: this.messageTag,
|
|
22025
|
+
type: "ARKADE_CASH",
|
|
22026
|
+
payload: request
|
|
22027
|
+
};
|
|
22028
|
+
try {
|
|
22029
|
+
const response = isLongRunningCashAction(request) ? await this.sendMessageWithRetry(message, {
|
|
22030
|
+
onEvent: () => {
|
|
22031
|
+
},
|
|
22032
|
+
isComplete: (resp) => resp.type === "ARKADE_CASH"
|
|
22033
|
+
}) : await this.sendMessage(message);
|
|
22034
|
+
return response.payload;
|
|
22035
|
+
} catch (error) {
|
|
22036
|
+
if (isSerializedArkadeCashCreateError(error)) {
|
|
22037
|
+
throw deserializeArkadeCashCreateError(error);
|
|
22038
|
+
}
|
|
22039
|
+
throw error;
|
|
22040
|
+
}
|
|
22041
|
+
}
|
|
21715
22042
|
walletRepository;
|
|
21716
22043
|
contractRepository;
|
|
21717
22044
|
identity;
|
|
@@ -27528,6 +27855,6 @@ function createDefaultPaymentRouter(wallet) {
|
|
|
27528
27855
|
}).use(arkRail()).use(arkAssetRail()).use(onchainRail({ feeInfo: walletFeeSource(wallet) }));
|
|
27529
27856
|
}
|
|
27530
27857
|
|
|
27531
|
-
export { ARKADE_MAGIC, ARKADE_SALTED_PREIMAGE_TAG, ARKADE_SWAP_PREIMAGE_TAG, ASSET_CARRIER_SATS, AbortError, ActivityRegistry, AmbiguousRouteError, ArkNote, Arkade, ArkadeCash, ArkadeCashCreateError, ArkadeCashOperatorMismatchError, AssetManager, BATCH_REGISTRATION_TERMINAL_STATES, BIP21, BIP21Error, BIP322, BLOCKED_UPGRADE_TIMEOUT_MS, Batch, CachingArkProvider, CachingOperatorProvider, ChainedTxType, ConnectionDisposedError, ContractManager, ContractWatcher, DEFAULT_MESSAGE_TIMEOUTS, DEFAULT_MIN_BATCH_EXPIRY_SECONDS, DEFAULT_PASSKEY_LABEL, DatabaseUpgradeBlockedError, DelegateManagerImpl, DelegateNotConfiguredError, DescriptorIdentity, DescriptorSigningProviderMissingError, DustChangeError, ELECTRUM_TCP_HOST, ELECTRUM_WS_URL, ESPLORA_URL, ElectrumOnchainProvider, EmulatorPacket, EsploraProvider, Estimator, Extension, ExtensionNotFoundError, ForeignDescriptorError, HDDescriptorProvider, INTENT_TERMINAL_STATES, InMemoryBatchRegistrationRepository, InMemoryContractRepository, InMemoryIntentRepository, InMemoryVirtualTxRepository, InMemoryWalletRepository, IndexedDBBatchRegistrationRepository, IndexedDBContractRepository, IndexedDBIntentRepository, IndexedDBVirtualTxRepository, IndexedDBWalletRepository, KeyringDescriptorProvider, MAX_PAGE_SIZE, MAX_USED_SIGNING_DESCRIPTORS_LOOK_AHEAD, MESSAGE_BUS_INITIALIZING, MESSAGE_BUS_NOT_INITIALIZED, MessageBus, MessageBusInitializingError, MessageBusNotInitializedError, MissingSigningDescriptorError, MnemonicIdentity, OnchainCosignPreflightError, OnchainWallet, OversizedChangeError, P2A, PasskeyCancelled, PasskeyUnconfirmed, PaymentRouter, PrevTxUnavailableError, PrfUnavailable, REGTEST_MIN_BATCH_EXPIRY_SECONDS, Ramps, ReadonlyAssetManager, ReadonlyDescriptorIdentity, ReadonlySingleKey, ReadonlyWallet, ReadonlyWalletError, RestDelegateProvider, RestEmulatorProvider, SeedIdentity, SendDeadlineExceededError, ServiceWorkerReadonlyWallet, ServiceWorkerTimeoutError, ServiceWorkerWallet, SingleKey, StaticDescriptorProvider, TreeSignerSession, TxTree, TxType, TxWeightEstimator, UnannotatableInputError, UnilateralExit, UnknownPacket, Unroll, VtxoManager, VtxoReservedError, Wallet2 as Wallet, WalletCannotAllocateAddressError, WalletCannotSignError, WalletMessageHandler, WalletNotInitializedError, WsElectrumChainSource, adoptContractDescriptor, applyWalletStateUpdate, arkAssetRail, arkRail, arkTarget, arkade_exports, assertFinalCommitmentMatchesValidated, assertHistoryPageFilter, assertIntentIdUnique, assertNoAssets, assertNoSelection, assertPageRequest, assertRecipientArkadeAddress, assertSendDeadline, assertSendableAmount, assertSubmittedArkTxid, assertValidBatchExpiry, assertValidServerUnrollScript, assetMintResolver, assetsOf, attachPrevArkTxs, attachPrevoutTxs, awaitTransaction, boardingResolver, btcTarget, buildForfeitTx, buildOffchainTx, buildPreimageMessage, buildSaltedPreimageMessage, captureSendDeadline, checkSaveVtxosForScript, claimWithPreimageIdentity, classifyAgainstSignerSet, classifyContractSigner, closeDatabase, collabExitResolver, collectBatchRegistrations, collectContracts, collectIntents, collectPages, collectScriptVtxos, collectTransactionHistory, collectUtxos, collectVtxos, combineTapscriptSigs, compareHistoryCursors, contractFilterMatchesNothing, contractFromArkContract, contractFromArkContractWithAddress, contractPreimage, contractSigner, createAssetPacket, createDefaultActivityRegistry, createDefaultPaymentRouter, createExitChainResolver, createManagedConnection, createPrfPasskey, createdAtToIso, decodeArkContract, defaultBatchExpiryPolicy, deleteByIndex, deserializeAssets, deserializeExitPackage, deserializeUtxo, deserializeVtxo, encodeArkContract, evaluatePrf, exitObserverFor, extendVirtualCoinForContract, extractOperatorProviderUrl, gateExclusion, gatedContracts, getAllByIndexValues, getRandomId, hasBoardingTxExpired, hasCandidates, intentMatchesFilter, invoiceTarget, isAddressAllocationCapable, isArkContract, isBatchSignable, isBtcAddress, isContractGenericallySpendable, isContractVtxoEvent, isCooperativelyMigratable, isCosignFallback, isDeterministicSigner, isDiscoverable, isHDAllocationCapable, isHDDeterministicSignCapable, isHDWalletCapable, isLightningInvoice, isLnurl, isMessageBusInitializingError, isMessageBusNotInitializedError, isPerArtifactDescriptor, isSigningIdentity, isSubdust, isTerminalBatchRegistrationState, isTerminalIntentState, isValidArkAddress, isVtxoExpiringSoon, iteratePages, legacyVtxoFacts, logExcludedVtxos, makeHandle, matchServerCheckpoints, mergeChainedTxType, mnemonicFromPrf, notifyExitObserved, onchainRail, openDatabase, outpointExclusion, outpointReasons, pageResult, prfSupport, promisifyRequest, provisionClaimSecret, provisionRefundKey, registerWalletRestoreHook, resolveAssetAmount, resolveBatchExpiryPolicy, resolveDescriptorSigner, resolvePrevTxs, resolveSendAmount, saveVtxosForContract, scopeOf, scriptFromArkAddress, selectCoinsWithAsset, selectVirtualCoins, selectionOf, serializeAssets, serializeExitPackage, serializeUtxo, serializeVtxo, setupServiceWorker, signAndSubmitOffchainTx, signerSetFromInfo, signingDescriptorIndex, strictSigningDescriptorIndex, submitViaEmulator, toXOnlySignerHex, tryResolveSendAmount, utxoEntries, validateBatchRecipients, validateConnectorsTxGraph, validateVtxoTxGraph, verifyTapscriptSignatures, waitForIncomingFunds, walletFeeSource, warnAndFilterVtxosForScript, withPrevTxs };
|
|
27532
|
-
//# sourceMappingURL=chunk-
|
|
27533
|
-
//# sourceMappingURL=chunk-
|
|
27858
|
+
export { ARKADE_MAGIC, ARKADE_SALTED_PREIMAGE_TAG, ARKADE_SWAP_PREIMAGE_TAG, ASSET_CARRIER_SATS, AbortError, ActivityRegistry, AmbiguousRouteError, ArkNote, Arkade, ArkadeCash, ArkadeCashCreateError, ArkadeCashOperatorMismatchError, AssetManager, BATCH_REGISTRATION_TERMINAL_STATES, BIP21, BIP21Error, BIP322, BLOCKED_UPGRADE_TIMEOUT_MS, Batch, CachingArkProvider, CachingOperatorProvider, ChainedTxType, ConnectionDisposedError, ContractManager, ContractWatcher, DEFAULT_MESSAGE_TIMEOUTS, DEFAULT_MIN_BATCH_EXPIRY_SECONDS, DEFAULT_PASSKEY_LABEL, DatabaseUpgradeBlockedError, DelegateManagerImpl, DelegateNotConfiguredError, DescriptorIdentity, DescriptorSigningProviderMissingError, DustChangeError, ELECTRUM_TCP_HOST, ELECTRUM_WS_URL, ESPLORA_URL, ElectrumOnchainProvider, EmulatorPacket, EsploraProvider, Estimator, Extension, ExtensionNotFoundError, ForeignDescriptorError, HDDescriptorProvider, INTENT_TERMINAL_STATES, InMemoryBatchRegistrationRepository, InMemoryContractRepository, InMemoryIntentRepository, InMemoryVirtualTxRepository, InMemoryWalletRepository, IndexedDBBatchRegistrationRepository, IndexedDBContractRepository, IndexedDBIntentRepository, IndexedDBVirtualTxRepository, IndexedDBWalletRepository, KeyringDescriptorProvider, MAX_PAGE_SIZE, MAX_USED_SIGNING_DESCRIPTORS_LOOK_AHEAD, MESSAGE_BUS_INITIALIZING, MESSAGE_BUS_NOT_INITIALIZED, MessageBus, MessageBusInitializingError, MessageBusNotInitializedError, MissingSigningDescriptorError, MnemonicIdentity, OnchainCosignPreflightError, OnchainWallet, OversizedChangeError, P2A, PasskeyCancelled, PasskeyUnconfirmed, PaymentRouter, PrevTxUnavailableError, PrfUnavailable, REGTEST_MIN_BATCH_EXPIRY_SECONDS, Ramps, ReadonlyAssetManager, ReadonlyDescriptorIdentity, ReadonlySingleKey, ReadonlyWallet, ReadonlyWalletError, RestDelegateProvider, RestEmulatorProvider, SeedIdentity, SendDeadlineExceededError, ServiceWorkerReadonlyWallet, ServiceWorkerTimeoutError, ServiceWorkerWallet, SingleKey, StaticDescriptorProvider, TreeSignerSession, TxTree, TxType, TxWeightEstimator, UnannotatableInputError, UnilateralExit, UnknownPacket, Unroll, VtxoManager, VtxoReservedError, Wallet2 as Wallet, WalletCannotAllocateAddressError, WalletCannotSignError, WalletMessageHandler, WalletNotInitializedError, WsElectrumChainSource, addArkadeCashRecord, adoptContractDescriptor, applyWalletStateUpdate, arkAssetRail, arkRail, arkTarget, arkadeCashId, arkadeCashResolver, arkade_exports, assertFinalCommitmentMatchesValidated, assertHistoryPageFilter, assertIntentIdUnique, assertNoAssets, assertNoSelection, assertPageRequest, assertRecipientArkadeAddress, assertSendDeadline, assertSendableAmount, assertSubmittedArkTxid, assertValidBatchExpiry, assertValidServerUnrollScript, assetMintResolver, assetsOf, attachPrevArkTxs, attachPrevoutTxs, awaitTransaction, boardingResolver, btcTarget, buildForfeitTx, buildOffchainTx, buildPreimageMessage, buildSaltedPreimageMessage, captureSendDeadline, checkSaveVtxosForScript, claimWithPreimageIdentity, classifyAgainstSignerSet, classifyContractSigner, closeDatabase, collabExitResolver, collectBatchRegistrations, collectContracts, collectIntents, collectPages, collectScriptVtxos, collectTransactionHistory, collectUtxos, collectVtxos, combineTapscriptSigs, compareHistoryCursors, contractFilterMatchesNothing, contractFromArkContract, contractFromArkContractWithAddress, contractPreimage, contractSigner, createArkadeCashTracker, createAssetPacket, createDefaultActivityRegistry, createDefaultPaymentRouter, createExitChainResolver, createManagedConnection, createPrfPasskey, createdAtToIso, decodeArkContract, defaultBatchExpiryPolicy, deleteByIndex, deserializeAssets, deserializeExitPackage, deserializeUtxo, deserializeVtxo, encodeArkContract, evaluatePrf, exitObserverFor, extendVirtualCoinForContract, extractOperatorProviderUrl, gateExclusion, gatedContracts, getAllByIndexValues, getRandomId, hasBoardingTxExpired, hasCandidates, intentMatchesFilter, invoiceTarget, isAddressAllocationCapable, isArkContract, isBatchSignable, isBtcAddress, isContractGenericallySpendable, isContractVtxoEvent, isCooperativelyMigratable, isCosignFallback, isDeterministicSigner, isDiscoverable, isHDAllocationCapable, isHDDeterministicSignCapable, isHDWalletCapable, isLightningInvoice, isLnurl, isMessageBusInitializingError, isMessageBusNotInitializedError, isPerArtifactDescriptor, isSigningIdentity, isSubdust, isTerminalBatchRegistrationState, isTerminalIntentState, isValidArkAddress, isVtxoExpiringSoon, iteratePages, legacyVtxoFacts, logExcludedVtxos, makeHandle, matchServerCheckpoints, mergeArkadeCashRecord, mergeChainedTxType, mnemonicFromPrf, notifyExitObserved, onchainRail, openDatabase, outpointExclusion, outpointReasons, pageResult, prfSupport, promisifyRequest, provisionClaimSecret, provisionRefundKey, readArkadeCash, registerWalletRestoreHook, resolveAssetAmount, resolveBatchExpiryPolicy, resolveDescriptorSigner, resolvePrevTxs, resolveSendAmount, saveVtxosForContract, scopeOf, scriptFromArkAddress, selectCoinsWithAsset, selectVirtualCoins, selectionOf, serializeAssets, serializeExitPackage, serializeUtxo, serializeVtxo, setupServiceWorker, signAndSubmitOffchainTx, signerSetFromInfo, signingDescriptorIndex, strictSigningDescriptorIndex, submitViaEmulator, toXOnlySignerHex, tryResolveSendAmount, utxoEntries, validateBatchRecipients, validateConnectorsTxGraph, validateVtxoTxGraph, verifyTapscriptSignatures, waitForIncomingFunds, walletFeeSource, warnAndFilterVtxosForScript, withPrevTxs };
|
|
27859
|
+
//# sourceMappingURL=chunk-RLD7DRSZ.js.map
|
|
27860
|
+
//# sourceMappingURL=chunk-RLD7DRSZ.js.map
|