@arkade-os/sdk 0.4.64 → 0.4.65
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.js +3 -3
- package/dist/adapters/indexedDB.cjs +5 -5
- package/dist/adapters/indexedDB.js +4 -4
- package/dist/{chunk-HQ2DDMQN.js → chunk-3G5V564P.js} +141 -3
- package/dist/chunk-3G5V564P.js.map +1 -0
- package/dist/{chunk-WJN2BLEI.js → chunk-5YTSQSLE.js} +226 -353
- package/dist/chunk-5YTSQSLE.js.map +1 -0
- package/dist/{chunk-35YIP6OA.cjs → chunk-7X744EFF.cjs} +10 -10
- package/dist/{chunk-35YIP6OA.cjs.map → chunk-7X744EFF.cjs.map} +1 -1
- package/dist/{chunk-WXCVS6PD.cjs → chunk-BABJ77NG.cjs} +196 -57
- package/dist/chunk-BABJ77NG.cjs.map +1 -0
- package/dist/{chunk-FZFSGOTZ.cjs → chunk-G552MISJ.cjs} +3 -3
- package/dist/{chunk-FZFSGOTZ.cjs.map → chunk-G552MISJ.cjs.map} +1 -1
- package/dist/{chunk-LPEE2H2M.cjs → chunk-GFZNEMGL.cjs} +629 -748
- package/dist/chunk-GFZNEMGL.cjs.map +1 -0
- package/dist/{chunk-USXWE2EJ.js → chunk-RESN6QHP.js} +4 -4
- package/dist/{chunk-USXWE2EJ.js.map → chunk-RESN6QHP.js.map} +1 -1
- package/dist/{chunk-4N45WCSJ.cjs → chunk-SJQM5AVB.cjs} +17 -17
- package/dist/{chunk-4N45WCSJ.cjs.map → chunk-SJQM5AVB.cjs.map} +1 -1
- package/dist/{chunk-XJCBV4AA.js → chunk-TFSVXMTM.js} +3 -3
- package/dist/{chunk-XJCBV4AA.js.map → chunk-TFSVXMTM.js.map} +1 -1
- package/dist/{chunk-ZUEGFM3T.js → chunk-TYTPVPKD.js} +4 -4
- package/dist/{chunk-ZUEGFM3T.js.map → chunk-TYTPVPKD.js.map} +1 -1
- package/dist/{chunk-LN2VZP63.js → chunk-XMOIRDLF.js} +151 -12
- package/dist/chunk-XMOIRDLF.js.map +1 -0
- package/dist/{chunk-RXITDAV4.cjs → chunk-XN55B6EP.cjs} +155 -17
- package/dist/chunk-XN55B6EP.cjs.map +1 -0
- package/dist/contracts/handlers/index.cjs +9 -9
- package/dist/contracts/handlers/index.d.cts +1 -1
- package/dist/contracts/handlers/index.d.ts +1 -1
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/{index-aZycGEsQ.d.cts → index-BtTtQFUX.d.cts} +109 -0
- package/dist/{index-Bxe9kBFs.d.ts → index-fDDiA1-L.d.ts} +109 -0
- package/dist/index.cjs +300 -268
- package/dist/index.d.cts +187 -13
- package/dist/index.d.ts +187 -13
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +19 -19
- package/dist/repositories/realm/index.js +5 -5
- package/dist/repositories/sqlite/index.cjs +18 -18
- package/dist/repositories/sqlite/index.js +5 -5
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/index.cjs +14 -14
- package/dist/wallet/expo/index.js +5 -5
- package/dist/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.js +5 -5
- package/package.json +1 -1
- package/dist/chunk-HQ2DDMQN.js.map +0 -1
- package/dist/chunk-LN2VZP63.js.map +0 -1
- package/dist/chunk-LPEE2H2M.cjs.map +0 -1
- package/dist/chunk-RXITDAV4.cjs.map +0 -1
- package/dist/chunk-WJN2BLEI.js.map +0 -1
- package/dist/chunk-WXCVS6PD.cjs.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, inputName, contractHandlers, isMainnetDescriptor, descriptorIsOurs, deriveDescriptorLeafPubKey, deriveDescriptorLeafCompressedPubKey, parseHDDescriptor, DefaultVtxo, speculativeReceiveMetadata, DelegateVtxo, WALLET_RECEIVE_SOURCE, BoardingContractHandler, identityDescriptor } from './chunk-
|
|
3
|
-
import { VtxoScript, Transaction, isRecoverable, CSVMultisigTapscript, DEFAULT_NETWORK, resolveEmulatorPubkey, hasTerminalSpend, getNormalizedVtxos, setArkPsbtField, PrevArkTxField, ConditionWitness, craftToSpendTx, ArkAddress, isVirtualCoin, getArkPsbtFields, CosignerPublicKey, ServerResponseMismatchError, OP_RETURN_EMPTY_PKSCRIPT, sequenceToTimelock, decodeTapscript, scriptFromTapLeafScript, CLTVMultisigTapscript, VtxoTaprootTree, timelockToSequence, baseFetch, Intent, rateGate, DEFAULT_NETWORK_NAME, normalizeVtxo, getSequence, toBatchExpiry, maybeArkError, isArkError, ArkErrorName, toOffchainInputFeeParams, canRecoverOnchain, getNetwork, MultisigTapscript, isEventSourceError, isEventSourceUnavailableError, isRetryableProviderError, getAllNormalizedVtxos, DEFAULT_PAGE_SIZE, RestArkProvider, toVirtualStatus, ArkError, TapTreeCoder, resolveTimeHeight, canSpendOffchain, parseLegacyExpiry, isExpired, DEFAULT_ARKADE_SERVER_URL, ProviderUnavailableError, networks as networks$1, isPastExpiry, fetchVtxoCreatedAtByTxid } from './chunk-
|
|
1
|
+
import { AssetId, AssetGroup, AssetInput, AssetOutput, Metadata, Packet, BufferReader, BufferWriter, AssetRef, RestIndexerProvider } from './chunk-3G5V564P.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, inputName, contractHandlers, isMainnetDescriptor, descriptorIsOurs, deriveDescriptorLeafPubKey, deriveDescriptorLeafCompressedPubKey, parseHDDescriptor, DefaultVtxo, speculativeReceiveMetadata, DelegateVtxo, WALLET_RECEIVE_SOURCE, BoardingContractHandler, identityDescriptor } from './chunk-XMOIRDLF.js';
|
|
3
|
+
import { VtxoScript, Transaction, isRecoverable, CSVMultisigTapscript, DEFAULT_NETWORK, resolveEmulatorPubkey, hasTerminalSpend, getNormalizedVtxos, setArkPsbtField, PrevArkTxField, ConditionWitness, craftToSpendTx, ArkAddress, isVirtualCoin, getArkPsbtFields, CosignerPublicKey, ServerResponseMismatchError, OP_RETURN_EMPTY_PKSCRIPT, sequenceToTimelock, decodeTapscript, scriptFromTapLeafScript, CLTVMultisigTapscript, VtxoTaprootTree, timelockToSequence, baseFetch, Intent, rateGate, DEFAULT_NETWORK_NAME, normalizeVtxo, getSequence, toBatchExpiry, maybeArkError, isArkError, ArkErrorName, toOffchainInputFeeParams, canRecoverOnchain, getNetwork, MultisigTapscript, isEventSourceError, isEventSourceUnavailableError, isRetryableProviderError, getAllNormalizedVtxos, DEFAULT_PAGE_SIZE, RestArkProvider, toVirtualStatus, ArkError, TapTreeCoder, resolveTimeHeight, canSpendOffchain, parseLegacyExpiry, isExpired, DEFAULT_ARKADE_SERVER_URL, ProviderUnavailableError, networks as networks$1, isPastExpiry, fetchVtxoCreatedAtByTxid } from './chunk-TFSVXMTM.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';
|
|
@@ -7547,6 +7547,22 @@ var awaitTransaction = (transaction) => new Promise((resolve, reject) => {
|
|
|
7547
7547
|
transaction.onerror = () => reject(transaction.error);
|
|
7548
7548
|
transaction.onabort = () => reject(transaction.error ?? new Error("transaction aborted"));
|
|
7549
7549
|
});
|
|
7550
|
+
var deleteByIndex = (store, indexName, value) => {
|
|
7551
|
+
const request = store.index(indexName).openCursor(IDBKeyRange.only(value));
|
|
7552
|
+
request.onsuccess = () => {
|
|
7553
|
+
const cursor = request.result;
|
|
7554
|
+
if (!cursor) return;
|
|
7555
|
+
cursor.delete();
|
|
7556
|
+
cursor.continue();
|
|
7557
|
+
};
|
|
7558
|
+
};
|
|
7559
|
+
var getAllByIndexValues = (store, indexName, values) => {
|
|
7560
|
+
if (values.length === 0) return Promise.resolve([]);
|
|
7561
|
+
const index = store.index(indexName);
|
|
7562
|
+
return Promise.all(values.map((value) => promisifyRequest(index.getAll(value)))).then(
|
|
7563
|
+
(results) => results.flat()
|
|
7564
|
+
);
|
|
7565
|
+
};
|
|
7550
7566
|
|
|
7551
7567
|
// src/repositories/indexedDB/manager.ts
|
|
7552
7568
|
function getGlobalObject() {
|
|
@@ -7561,8 +7577,24 @@ function getGlobalObject() {
|
|
|
7561
7577
|
}
|
|
7562
7578
|
throw new Error("Global object not found");
|
|
7563
7579
|
}
|
|
7580
|
+
var BLOCKED_UPGRADE_TIMEOUT_MS = 1e4;
|
|
7581
|
+
var DatabaseUpgradeBlockedError = class extends Error {
|
|
7582
|
+
constructor(dbName) {
|
|
7583
|
+
super(
|
|
7584
|
+
`database "${dbName}" upgrade blocked by another connection for ${BLOCKED_UPGRADE_TIMEOUT_MS}ms; close other tabs and retry`
|
|
7585
|
+
);
|
|
7586
|
+
this.dbName = dbName;
|
|
7587
|
+
}
|
|
7588
|
+
dbName;
|
|
7589
|
+
name = "DatabaseUpgradeBlockedError";
|
|
7590
|
+
};
|
|
7564
7591
|
var dbCache = /* @__PURE__ */ new Map();
|
|
7565
7592
|
var refCounts = /* @__PURE__ */ new Map();
|
|
7593
|
+
function forget(dbName, promise) {
|
|
7594
|
+
if (dbCache.get(dbName)?.promise !== promise) return;
|
|
7595
|
+
dbCache.delete(dbName);
|
|
7596
|
+
refCounts.delete(dbName);
|
|
7597
|
+
}
|
|
7566
7598
|
async function openDatabase(dbName, dbVersion, initDatabase2) {
|
|
7567
7599
|
const { globalObject } = getGlobalObject();
|
|
7568
7600
|
if (!globalObject.indexedDB) {
|
|
@@ -7580,26 +7612,47 @@ async function openDatabase(dbName, dbVersion, initDatabase2) {
|
|
|
7580
7612
|
}
|
|
7581
7613
|
const dbPromise = new Promise((resolve, reject) => {
|
|
7582
7614
|
const request = globalObject.indexedDB.open(dbName, dbVersion);
|
|
7615
|
+
let settled = false;
|
|
7616
|
+
let blockedTimer;
|
|
7617
|
+
const clearBlockedTimer = () => {
|
|
7618
|
+
if (blockedTimer !== void 0) clearTimeout(blockedTimer);
|
|
7619
|
+
blockedTimer = void 0;
|
|
7620
|
+
};
|
|
7583
7621
|
request.onerror = () => {
|
|
7584
|
-
|
|
7585
|
-
|
|
7622
|
+
clearBlockedTimer();
|
|
7623
|
+
if (settled) return;
|
|
7624
|
+
settled = true;
|
|
7625
|
+
forget(dbName, dbPromise);
|
|
7586
7626
|
reject(request.error);
|
|
7587
7627
|
};
|
|
7588
7628
|
request.onsuccess = () => {
|
|
7629
|
+
clearBlockedTimer();
|
|
7589
7630
|
const db = request.result;
|
|
7631
|
+
if (settled) {
|
|
7632
|
+
db.close();
|
|
7633
|
+
return;
|
|
7634
|
+
}
|
|
7635
|
+
settled = true;
|
|
7590
7636
|
db.onversionchange = () => {
|
|
7591
7637
|
db.close();
|
|
7592
|
-
|
|
7593
|
-
refCounts.delete(dbName);
|
|
7638
|
+
forget(dbName, dbPromise);
|
|
7594
7639
|
};
|
|
7640
|
+
db.addEventListener("close", () => forget(dbName, dbPromise));
|
|
7595
7641
|
resolve(db);
|
|
7596
7642
|
};
|
|
7597
7643
|
request.onupgradeneeded = (event) => {
|
|
7644
|
+
clearBlockedTimer();
|
|
7598
7645
|
const db = request.result;
|
|
7599
7646
|
initDatabase2(db, event.oldVersion, request.transaction);
|
|
7600
7647
|
};
|
|
7601
7648
|
request.onblocked = () => {
|
|
7602
7649
|
console.warn("Database upgrade blocked - close other tabs/connections");
|
|
7650
|
+
blockedTimer = setTimeout(() => {
|
|
7651
|
+
if (settled) return;
|
|
7652
|
+
settled = true;
|
|
7653
|
+
forget(dbName, dbPromise);
|
|
7654
|
+
reject(new DatabaseUpgradeBlockedError(dbName));
|
|
7655
|
+
}, BLOCKED_UPGRADE_TIMEOUT_MS);
|
|
7603
7656
|
};
|
|
7604
7657
|
});
|
|
7605
7658
|
dbCache.set(dbName, { version: dbVersion, promise: dbPromise });
|
|
@@ -7623,6 +7676,46 @@ async function closeDatabase(dbName) {
|
|
|
7623
7676
|
}
|
|
7624
7677
|
return true;
|
|
7625
7678
|
}
|
|
7679
|
+
|
|
7680
|
+
// src/repositories/indexedDB/managedConnection.ts
|
|
7681
|
+
var ConnectionDisposedError = class extends Error {
|
|
7682
|
+
constructor(dbName) {
|
|
7683
|
+
super(`connection to database "${dbName}" was disposed`);
|
|
7684
|
+
this.dbName = dbName;
|
|
7685
|
+
}
|
|
7686
|
+
dbName;
|
|
7687
|
+
name = "ConnectionDisposedError";
|
|
7688
|
+
};
|
|
7689
|
+
function createManagedConnection(dbName, version, initDatabase2) {
|
|
7690
|
+
let current = null;
|
|
7691
|
+
let disposed = false;
|
|
7692
|
+
return {
|
|
7693
|
+
get() {
|
|
7694
|
+
if (disposed) return Promise.reject(new ConnectionDisposedError(dbName));
|
|
7695
|
+
if (current) return current;
|
|
7696
|
+
const opening = openDatabase(dbName, version, initDatabase2).then((db) => {
|
|
7697
|
+
const forget2 = () => {
|
|
7698
|
+
if (current === opening) current = null;
|
|
7699
|
+
};
|
|
7700
|
+
db.addEventListener("versionchange", forget2);
|
|
7701
|
+
db.addEventListener("close", forget2);
|
|
7702
|
+
return db;
|
|
7703
|
+
}).catch((err) => {
|
|
7704
|
+
if (current === opening) current = null;
|
|
7705
|
+
throw err;
|
|
7706
|
+
});
|
|
7707
|
+
current = opening;
|
|
7708
|
+
return opening;
|
|
7709
|
+
},
|
|
7710
|
+
async [Symbol.asyncDispose]() {
|
|
7711
|
+
if (disposed) return;
|
|
7712
|
+
disposed = true;
|
|
7713
|
+
if (!current) return;
|
|
7714
|
+
current = null;
|
|
7715
|
+
await closeDatabase(dbName);
|
|
7716
|
+
}
|
|
7717
|
+
};
|
|
7718
|
+
}
|
|
7626
7719
|
function scriptFromArkAddress(address) {
|
|
7627
7720
|
return hex.encode(ArkAddress.decode(address).pkScript);
|
|
7628
7721
|
}
|
|
@@ -7906,16 +7999,17 @@ async function setupServiceWorker(pathOrOptions) {
|
|
|
7906
7999
|
|
|
7907
8000
|
// src/repositories/indexedDB/virtualTxRepository.ts
|
|
7908
8001
|
var IndexedDBVirtualTxRepository = class {
|
|
8002
|
+
version = 1;
|
|
8003
|
+
connection;
|
|
7909
8004
|
constructor(dbName = DEFAULT_DB_NAME) {
|
|
7910
|
-
this.
|
|
8005
|
+
this.connection = createManagedConnection(
|
|
8006
|
+
dbName,
|
|
8007
|
+
INTENT_DB_VERSION,
|
|
8008
|
+
initDatabaseWithIntents
|
|
8009
|
+
);
|
|
7911
8010
|
}
|
|
7912
|
-
|
|
7913
|
-
|
|
7914
|
-
db = null;
|
|
7915
|
-
async getDB() {
|
|
7916
|
-
if (!this.db)
|
|
7917
|
-
this.db = await openDatabase(this.dbName, INTENT_DB_VERSION, initDatabaseWithIntents);
|
|
7918
|
-
return this.db;
|
|
8011
|
+
getDB() {
|
|
8012
|
+
return this.connection.get();
|
|
7919
8013
|
}
|
|
7920
8014
|
async clear() {
|
|
7921
8015
|
const db = await this.getDB();
|
|
@@ -8028,24 +8122,23 @@ var IndexedDBVirtualTxRepository = class {
|
|
|
8028
8122
|
await awaitTransaction(transaction);
|
|
8029
8123
|
}
|
|
8030
8124
|
async [Symbol.asyncDispose]() {
|
|
8031
|
-
|
|
8032
|
-
await closeDatabase(this.dbName);
|
|
8033
|
-
this.db = null;
|
|
8125
|
+
await this.connection[Symbol.asyncDispose]();
|
|
8034
8126
|
}
|
|
8035
8127
|
};
|
|
8036
8128
|
|
|
8037
8129
|
// src/repositories/indexedDB/intentRepository.ts
|
|
8038
8130
|
var IndexedDBIntentRepository = class {
|
|
8131
|
+
version = 1;
|
|
8132
|
+
connection;
|
|
8039
8133
|
constructor(dbName = DEFAULT_DB_NAME) {
|
|
8040
|
-
this.
|
|
8134
|
+
this.connection = createManagedConnection(
|
|
8135
|
+
dbName,
|
|
8136
|
+
INTENT_DB_VERSION,
|
|
8137
|
+
initDatabaseWithIntents
|
|
8138
|
+
);
|
|
8041
8139
|
}
|
|
8042
|
-
|
|
8043
|
-
|
|
8044
|
-
db = null;
|
|
8045
|
-
async getDB() {
|
|
8046
|
-
if (!this.db)
|
|
8047
|
-
this.db = await openDatabase(this.dbName, INTENT_DB_VERSION, initDatabaseWithIntents);
|
|
8048
|
-
return this.db;
|
|
8140
|
+
getDB() {
|
|
8141
|
+
return this.connection.get();
|
|
8049
8142
|
}
|
|
8050
8143
|
async clear() {
|
|
8051
8144
|
const db = await this.getDB();
|
|
@@ -8078,9 +8171,7 @@ var IndexedDBIntentRepository = class {
|
|
|
8078
8171
|
return out;
|
|
8079
8172
|
}
|
|
8080
8173
|
async [Symbol.asyncDispose]() {
|
|
8081
|
-
|
|
8082
|
-
await closeDatabase(this.dbName);
|
|
8083
|
-
this.db = null;
|
|
8174
|
+
await this.connection[Symbol.asyncDispose]();
|
|
8084
8175
|
}
|
|
8085
8176
|
};
|
|
8086
8177
|
|
|
@@ -10382,33 +10473,17 @@ var deserializeTransaction = (o) => ({
|
|
|
10382
10473
|
|
|
10383
10474
|
// src/repositories/indexedDB/contractRepository.ts
|
|
10384
10475
|
var IndexedDBContractRepository = class {
|
|
10476
|
+
version = 2;
|
|
10477
|
+
connection;
|
|
10385
10478
|
constructor(dbName = DEFAULT_DB_NAME) {
|
|
10386
|
-
this.
|
|
10479
|
+
this.connection = createManagedConnection(dbName, DB_VERSION, initDatabase);
|
|
10387
10480
|
}
|
|
10388
|
-
dbName;
|
|
10389
|
-
version = 2;
|
|
10390
|
-
db = null;
|
|
10391
10481
|
async clear() {
|
|
10392
10482
|
try {
|
|
10393
10483
|
const db = await this.getDB();
|
|
10394
|
-
|
|
10395
|
-
|
|
10396
|
-
|
|
10397
|
-
const contractsStore = transaction.objectStore(STORE_CONTRACTS);
|
|
10398
|
-
const contractDataRequest = contractDataStore.clear();
|
|
10399
|
-
const contractsRequest = contractsStore.clear();
|
|
10400
|
-
let completed = 0;
|
|
10401
|
-
const checkComplete = () => {
|
|
10402
|
-
completed++;
|
|
10403
|
-
if (completed === 2) {
|
|
10404
|
-
resolve();
|
|
10405
|
-
}
|
|
10406
|
-
};
|
|
10407
|
-
contractDataRequest.onsuccess = checkComplete;
|
|
10408
|
-
contractsRequest.onsuccess = checkComplete;
|
|
10409
|
-
contractDataRequest.onerror = () => reject(contractDataRequest.error);
|
|
10410
|
-
contractsRequest.onerror = () => reject(contractsRequest.error);
|
|
10411
|
-
});
|
|
10484
|
+
const transaction = db.transaction([STORE_CONTRACTS], "readwrite");
|
|
10485
|
+
transaction.objectStore(STORE_CONTRACTS).clear();
|
|
10486
|
+
await awaitTransaction(transaction);
|
|
10412
10487
|
} catch (error) {
|
|
10413
10488
|
console.error("Failed to clear contract data:", error);
|
|
10414
10489
|
throw error;
|
|
@@ -10419,28 +10494,20 @@ var IndexedDBContractRepository = class {
|
|
|
10419
10494
|
const db = await this.getDB();
|
|
10420
10495
|
const store = db.transaction([STORE_CONTRACTS], "readonly").objectStore(STORE_CONTRACTS);
|
|
10421
10496
|
if (!filter || Object.keys(filter).length === 0) {
|
|
10422
|
-
return
|
|
10423
|
-
const request = store.getAll();
|
|
10424
|
-
request.onerror = () => reject(request.error);
|
|
10425
|
-
request.onsuccess = () => resolve(request.result ?? []);
|
|
10426
|
-
});
|
|
10497
|
+
return await promisifyRequest(store.getAll()) ?? [];
|
|
10427
10498
|
}
|
|
10428
10499
|
const normalizedFilter = normalizeFilter(filter);
|
|
10429
10500
|
if (normalizedFilter.has("script")) {
|
|
10430
10501
|
const scripts = normalizedFilter.get("script");
|
|
10431
10502
|
const contracts = await Promise.all(
|
|
10432
10503
|
scripts.map(
|
|
10433
|
-
(script) =>
|
|
10434
|
-
const req = store.get(script);
|
|
10435
|
-
req.onerror = () => reject(req.error);
|
|
10436
|
-
req.onsuccess = () => resolve(req.result);
|
|
10437
|
-
})
|
|
10504
|
+
(script) => promisifyRequest(store.get(script))
|
|
10438
10505
|
)
|
|
10439
10506
|
);
|
|
10440
10507
|
return this.applyContractFilter(contracts, normalizedFilter);
|
|
10441
10508
|
}
|
|
10442
10509
|
if (normalizedFilter.has("state")) {
|
|
10443
|
-
const contracts = await
|
|
10510
|
+
const contracts = await getAllByIndexValues(
|
|
10444
10511
|
store,
|
|
10445
10512
|
"state",
|
|
10446
10513
|
normalizedFilter.get("state")
|
|
@@ -10448,18 +10515,14 @@ var IndexedDBContractRepository = class {
|
|
|
10448
10515
|
return this.applyContractFilter(contracts, normalizedFilter);
|
|
10449
10516
|
}
|
|
10450
10517
|
if (normalizedFilter.has("type")) {
|
|
10451
|
-
const contracts = await
|
|
10518
|
+
const contracts = await getAllByIndexValues(
|
|
10452
10519
|
store,
|
|
10453
10520
|
"type",
|
|
10454
10521
|
normalizedFilter.get("type")
|
|
10455
10522
|
);
|
|
10456
10523
|
return this.applyContractFilter(contracts, normalizedFilter);
|
|
10457
10524
|
}
|
|
10458
|
-
const allContracts = await
|
|
10459
|
-
const request = store.getAll();
|
|
10460
|
-
request.onerror = () => reject(request.error);
|
|
10461
|
-
request.onsuccess = () => resolve(request.result ?? []);
|
|
10462
|
-
});
|
|
10525
|
+
const allContracts = await promisifyRequest(store.getAll()) ?? [];
|
|
10463
10526
|
return this.applyContractFilter(allContracts, normalizedFilter);
|
|
10464
10527
|
} catch (error) {
|
|
10465
10528
|
console.error("Failed to get contracts:", error);
|
|
@@ -10469,13 +10532,9 @@ var IndexedDBContractRepository = class {
|
|
|
10469
10532
|
async saveContract(contract) {
|
|
10470
10533
|
try {
|
|
10471
10534
|
const db = await this.getDB();
|
|
10472
|
-
|
|
10473
|
-
|
|
10474
|
-
|
|
10475
|
-
const request = store.put(contract);
|
|
10476
|
-
request.onerror = () => reject(request.error);
|
|
10477
|
-
request.onsuccess = () => resolve();
|
|
10478
|
-
});
|
|
10535
|
+
const transaction = db.transaction([STORE_CONTRACTS], "readwrite");
|
|
10536
|
+
transaction.objectStore(STORE_CONTRACTS).put(contract);
|
|
10537
|
+
await awaitTransaction(transaction);
|
|
10479
10538
|
} catch (error) {
|
|
10480
10539
|
console.error("Failed to save contract:", error);
|
|
10481
10540
|
throw error;
|
|
@@ -10484,34 +10543,14 @@ var IndexedDBContractRepository = class {
|
|
|
10484
10543
|
async deleteContract(script) {
|
|
10485
10544
|
try {
|
|
10486
10545
|
const db = await this.getDB();
|
|
10487
|
-
|
|
10488
|
-
|
|
10489
|
-
|
|
10490
|
-
const getRequest = store.get(script);
|
|
10491
|
-
getRequest.onerror = () => reject(getRequest.error);
|
|
10492
|
-
getRequest.onsuccess = () => {
|
|
10493
|
-
const request = store.delete(script);
|
|
10494
|
-
request.onerror = () => reject(request.error);
|
|
10495
|
-
request.onsuccess = () => resolve();
|
|
10496
|
-
};
|
|
10497
|
-
});
|
|
10546
|
+
const transaction = db.transaction([STORE_CONTRACTS], "readwrite");
|
|
10547
|
+
transaction.objectStore(STORE_CONTRACTS).delete(script);
|
|
10548
|
+
await awaitTransaction(transaction);
|
|
10498
10549
|
} catch (error) {
|
|
10499
10550
|
console.error(`Failed to delete contract ${script}:`, error);
|
|
10500
10551
|
throw error;
|
|
10501
10552
|
}
|
|
10502
10553
|
}
|
|
10503
|
-
getContractsByIndexValues(store, indexName, values) {
|
|
10504
|
-
if (values.length === 0) return Promise.resolve([]);
|
|
10505
|
-
const index = store.index(indexName);
|
|
10506
|
-
const requests = values.map(
|
|
10507
|
-
(value) => new Promise((resolve, reject) => {
|
|
10508
|
-
const request = index.getAll(value);
|
|
10509
|
-
request.onerror = () => reject(request.error);
|
|
10510
|
-
request.onsuccess = () => resolve(request.result ?? []);
|
|
10511
|
-
})
|
|
10512
|
-
);
|
|
10513
|
-
return Promise.all(requests).then((results) => results.flatMap((result) => result));
|
|
10514
|
-
}
|
|
10515
10554
|
applyContractFilter(contracts, filter) {
|
|
10516
10555
|
return contracts.filter((contract) => {
|
|
10517
10556
|
if (contract === void 0) return false;
|
|
@@ -10524,15 +10563,11 @@ var IndexedDBContractRepository = class {
|
|
|
10524
10563
|
return true;
|
|
10525
10564
|
});
|
|
10526
10565
|
}
|
|
10527
|
-
|
|
10528
|
-
|
|
10529
|
-
this.db = await openDatabase(this.dbName, DB_VERSION, initDatabase);
|
|
10530
|
-
return this.db;
|
|
10566
|
+
getDB() {
|
|
10567
|
+
return this.connection.get();
|
|
10531
10568
|
}
|
|
10532
10569
|
async [Symbol.asyncDispose]() {
|
|
10533
|
-
|
|
10534
|
-
await closeDatabase(this.dbName);
|
|
10535
|
-
this.db = null;
|
|
10570
|
+
await this.connection[Symbol.asyncDispose]();
|
|
10536
10571
|
}
|
|
10537
10572
|
};
|
|
10538
10573
|
var FILTER_FIELDS = ["script", "state", "type", "watch"];
|
|
@@ -10551,70 +10586,34 @@ function normalizeFilter(filter) {
|
|
|
10551
10586
|
|
|
10552
10587
|
// src/repositories/indexedDB/walletRepository.ts
|
|
10553
10588
|
var IndexedDBWalletRepository = class {
|
|
10589
|
+
version = 1;
|
|
10590
|
+
connection;
|
|
10554
10591
|
constructor(dbName = DEFAULT_DB_NAME) {
|
|
10555
|
-
this.
|
|
10592
|
+
this.connection = createManagedConnection(dbName, DB_VERSION, initDatabase);
|
|
10556
10593
|
}
|
|
10557
|
-
dbName;
|
|
10558
|
-
version = 1;
|
|
10559
|
-
db = null;
|
|
10560
10594
|
async clear() {
|
|
10561
10595
|
try {
|
|
10562
10596
|
const db = await this.getDB();
|
|
10563
|
-
|
|
10564
|
-
|
|
10565
|
-
|
|
10566
|
-
|
|
10567
|
-
);
|
|
10568
|
-
const vtxosStore = transaction.objectStore(STORE_VTXOS);
|
|
10569
|
-
const utxosStore = transaction.objectStore(STORE_UTXOS);
|
|
10570
|
-
const transactionsStore = transaction.objectStore(STORE_TRANSACTIONS);
|
|
10571
|
-
const walletStateStore = transaction.objectStore(STORE_WALLET_STATE);
|
|
10572
|
-
const requests = [
|
|
10573
|
-
vtxosStore.clear(),
|
|
10574
|
-
utxosStore.clear(),
|
|
10575
|
-
transactionsStore.clear(),
|
|
10576
|
-
walletStateStore.clear()
|
|
10577
|
-
];
|
|
10578
|
-
let completed = 0;
|
|
10579
|
-
const checkComplete = () => {
|
|
10580
|
-
completed++;
|
|
10581
|
-
if (completed === requests.length) {
|
|
10582
|
-
resolve();
|
|
10583
|
-
}
|
|
10584
|
-
};
|
|
10585
|
-
requests.forEach((request) => {
|
|
10586
|
-
request.onsuccess = checkComplete;
|
|
10587
|
-
request.onerror = () => reject(request.error);
|
|
10588
|
-
});
|
|
10589
|
-
});
|
|
10597
|
+
const stores = [STORE_VTXOS, STORE_UTXOS, STORE_TRANSACTIONS, STORE_WALLET_STATE];
|
|
10598
|
+
const transaction = db.transaction(stores, "readwrite");
|
|
10599
|
+
for (const name of stores) transaction.objectStore(name).clear();
|
|
10600
|
+
await awaitTransaction(transaction);
|
|
10590
10601
|
} catch (error) {
|
|
10591
10602
|
console.error("Failed to clear wallet data:", error);
|
|
10592
10603
|
throw error;
|
|
10593
10604
|
}
|
|
10594
10605
|
}
|
|
10595
10606
|
async [Symbol.asyncDispose]() {
|
|
10596
|
-
|
|
10597
|
-
await closeDatabase(this.dbName);
|
|
10598
|
-
this.db = null;
|
|
10607
|
+
await this.connection[Symbol.asyncDispose]();
|
|
10599
10608
|
}
|
|
10600
10609
|
async getVtxos(address) {
|
|
10601
10610
|
try {
|
|
10602
10611
|
const db = await this.getDB();
|
|
10603
|
-
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
|
|
10607
|
-
|
|
10608
|
-
request.onerror = () => reject(request.error);
|
|
10609
|
-
request.onsuccess = () => {
|
|
10610
|
-
const results = request.result || [];
|
|
10611
|
-
try {
|
|
10612
|
-
resolve(results.map(deserializeVtxoWithBackfill));
|
|
10613
|
-
} catch (err) {
|
|
10614
|
-
reject(err);
|
|
10615
|
-
}
|
|
10616
|
-
};
|
|
10617
|
-
});
|
|
10612
|
+
const store = db.transaction([STORE_VTXOS], "readonly").objectStore(STORE_VTXOS);
|
|
10613
|
+
const results = await promisifyRequest(
|
|
10614
|
+
store.index("address").getAll(address)
|
|
10615
|
+
);
|
|
10616
|
+
return (results || []).map(deserializeVtxoWithBackfill);
|
|
10618
10617
|
} catch (error) {
|
|
10619
10618
|
console.error(`Failed to get VTXOs for address ${address}:`, error);
|
|
10620
10619
|
return [];
|
|
@@ -10623,24 +10622,13 @@ var IndexedDBWalletRepository = class {
|
|
|
10623
10622
|
async saveVtxos(address, vtxos) {
|
|
10624
10623
|
try {
|
|
10625
10624
|
const db = await this.getDB();
|
|
10626
|
-
|
|
10627
|
-
|
|
10628
|
-
|
|
10629
|
-
const
|
|
10630
|
-
|
|
10631
|
-
|
|
10632
|
-
|
|
10633
|
-
address,
|
|
10634
|
-
...serialized
|
|
10635
|
-
};
|
|
10636
|
-
const request = store.put(item);
|
|
10637
|
-
request.onerror = () => rejectItem(request.error);
|
|
10638
|
-
request.onsuccess = () => resolveItem();
|
|
10639
|
-
});
|
|
10640
|
-
});
|
|
10641
|
-
Promise.all(promises).then(() => resolve()).catch(reject);
|
|
10642
|
-
transaction.onerror = () => reject(transaction.error);
|
|
10643
|
-
});
|
|
10625
|
+
const transaction = db.transaction([STORE_VTXOS], "readwrite");
|
|
10626
|
+
const store = transaction.objectStore(STORE_VTXOS);
|
|
10627
|
+
for (const vtxo of vtxos) {
|
|
10628
|
+
const serialized = serializeVtxo(vtxo);
|
|
10629
|
+
store.put({ address, ...serialized });
|
|
10630
|
+
}
|
|
10631
|
+
await awaitTransaction(transaction);
|
|
10644
10632
|
} catch (error) {
|
|
10645
10633
|
console.error(`Failed to save VTXOs for address ${address}:`, error);
|
|
10646
10634
|
throw error;
|
|
@@ -10649,22 +10637,9 @@ var IndexedDBWalletRepository = class {
|
|
|
10649
10637
|
async deleteVtxos(address) {
|
|
10650
10638
|
try {
|
|
10651
10639
|
const db = await this.getDB();
|
|
10652
|
-
|
|
10653
|
-
|
|
10654
|
-
|
|
10655
|
-
const index = store.index("address");
|
|
10656
|
-
const request = index.openCursor(IDBKeyRange.only(address));
|
|
10657
|
-
request.onerror = () => reject(request.error);
|
|
10658
|
-
request.onsuccess = () => {
|
|
10659
|
-
const cursor = request.result;
|
|
10660
|
-
if (cursor) {
|
|
10661
|
-
cursor.delete();
|
|
10662
|
-
cursor.continue();
|
|
10663
|
-
} else {
|
|
10664
|
-
resolve();
|
|
10665
|
-
}
|
|
10666
|
-
};
|
|
10667
|
-
});
|
|
10640
|
+
const transaction = db.transaction([STORE_VTXOS], "readwrite");
|
|
10641
|
+
deleteByIndex(transaction.objectStore(STORE_VTXOS), "address", address);
|
|
10642
|
+
await awaitTransaction(transaction);
|
|
10668
10643
|
} catch (error) {
|
|
10669
10644
|
console.error(`Failed to clear VTXOs for address ${address}:`, error);
|
|
10670
10645
|
throw error;
|
|
@@ -10673,34 +10648,24 @@ var IndexedDBWalletRepository = class {
|
|
|
10673
10648
|
async getVtxosForScript(script) {
|
|
10674
10649
|
try {
|
|
10675
10650
|
const db = await this.getDB();
|
|
10676
|
-
|
|
10677
|
-
|
|
10678
|
-
|
|
10679
|
-
|
|
10680
|
-
|
|
10681
|
-
|
|
10682
|
-
|
|
10683
|
-
|
|
10684
|
-
|
|
10685
|
-
|
|
10686
|
-
|
|
10687
|
-
|
|
10688
|
-
|
|
10689
|
-
|
|
10690
|
-
|
|
10691
|
-
|
|
10692
|
-
|
|
10693
|
-
|
|
10694
|
-
if (shouldReplaceVtxo(existing, row)) {
|
|
10695
|
-
byOutpoint.set(outpoint, row);
|
|
10696
|
-
}
|
|
10697
|
-
}
|
|
10698
|
-
resolve(Array.from(byOutpoint.values()).map(deserializeVtxoWithBackfill));
|
|
10699
|
-
} catch (err) {
|
|
10700
|
-
reject(err);
|
|
10701
|
-
}
|
|
10702
|
-
};
|
|
10703
|
-
});
|
|
10651
|
+
const store = db.transaction([STORE_VTXOS], "readonly").objectStore(STORE_VTXOS);
|
|
10652
|
+
const results = await promisifyRequest(
|
|
10653
|
+
store.index("script").getAll(script)
|
|
10654
|
+
);
|
|
10655
|
+
const matching = (results || []).filter((r) => r.script === script);
|
|
10656
|
+
const byOutpoint = /* @__PURE__ */ new Map();
|
|
10657
|
+
for (const row of matching) {
|
|
10658
|
+
const outpoint = `${row.txid}:${row.vout}`;
|
|
10659
|
+
const existing = byOutpoint.get(outpoint);
|
|
10660
|
+
if (!existing) {
|
|
10661
|
+
byOutpoint.set(outpoint, row);
|
|
10662
|
+
continue;
|
|
10663
|
+
}
|
|
10664
|
+
if (shouldReplaceVtxo(existing, row)) {
|
|
10665
|
+
byOutpoint.set(outpoint, row);
|
|
10666
|
+
}
|
|
10667
|
+
}
|
|
10668
|
+
return Array.from(byOutpoint.values()).map(deserializeVtxoWithBackfill);
|
|
10704
10669
|
} catch (error) {
|
|
10705
10670
|
console.error(`Failed to get VTXOs for script ${script}:`, error);
|
|
10706
10671
|
throw error;
|
|
@@ -10722,22 +10687,9 @@ var IndexedDBWalletRepository = class {
|
|
|
10722
10687
|
async deleteVtxosForScript(script) {
|
|
10723
10688
|
try {
|
|
10724
10689
|
const db = await this.getDB();
|
|
10725
|
-
|
|
10726
|
-
|
|
10727
|
-
|
|
10728
|
-
const index = store.index("script");
|
|
10729
|
-
const request = index.openCursor(IDBKeyRange.only(script));
|
|
10730
|
-
request.onerror = () => reject(request.error);
|
|
10731
|
-
request.onsuccess = () => {
|
|
10732
|
-
const cursor = request.result;
|
|
10733
|
-
if (cursor) {
|
|
10734
|
-
cursor.delete();
|
|
10735
|
-
cursor.continue();
|
|
10736
|
-
} else {
|
|
10737
|
-
resolve();
|
|
10738
|
-
}
|
|
10739
|
-
};
|
|
10740
|
-
});
|
|
10690
|
+
const transaction = db.transaction([STORE_VTXOS], "readwrite");
|
|
10691
|
+
deleteByIndex(transaction.objectStore(STORE_VTXOS), "script", script);
|
|
10692
|
+
await awaitTransaction(transaction);
|
|
10741
10693
|
} catch (error) {
|
|
10742
10694
|
console.error(`Failed to clear VTXOs for script ${script}:`, error);
|
|
10743
10695
|
throw error;
|
|
@@ -10746,18 +10698,9 @@ var IndexedDBWalletRepository = class {
|
|
|
10746
10698
|
async getUtxos(address) {
|
|
10747
10699
|
try {
|
|
10748
10700
|
const db = await this.getDB();
|
|
10749
|
-
|
|
10750
|
-
|
|
10751
|
-
|
|
10752
|
-
const index = store.index("address");
|
|
10753
|
-
const request = index.getAll(address);
|
|
10754
|
-
request.onerror = () => reject(request.error);
|
|
10755
|
-
request.onsuccess = () => {
|
|
10756
|
-
const results = request.result || [];
|
|
10757
|
-
const utxos = results.map(deserializeUtxo);
|
|
10758
|
-
resolve(utxos);
|
|
10759
|
-
};
|
|
10760
|
-
});
|
|
10701
|
+
const store = db.transaction([STORE_UTXOS], "readonly").objectStore(STORE_UTXOS);
|
|
10702
|
+
const results = await promisifyRequest(store.index("address").getAll(address));
|
|
10703
|
+
return (results || []).map(deserializeUtxo);
|
|
10761
10704
|
} catch (error) {
|
|
10762
10705
|
console.error(`Failed to get UTXOs for address ${address}:`, error);
|
|
10763
10706
|
return [];
|
|
@@ -10766,24 +10709,10 @@ var IndexedDBWalletRepository = class {
|
|
|
10766
10709
|
async saveUtxos(address, utxos) {
|
|
10767
10710
|
try {
|
|
10768
10711
|
const db = await this.getDB();
|
|
10769
|
-
|
|
10770
|
-
|
|
10771
|
-
|
|
10772
|
-
|
|
10773
|
-
return new Promise((resolveItem, rejectItem) => {
|
|
10774
|
-
const serialized = serializeUtxo(utxo);
|
|
10775
|
-
const item = {
|
|
10776
|
-
address,
|
|
10777
|
-
...serialized
|
|
10778
|
-
};
|
|
10779
|
-
const request = store.put(item);
|
|
10780
|
-
request.onerror = () => rejectItem(request.error);
|
|
10781
|
-
request.onsuccess = () => resolveItem();
|
|
10782
|
-
});
|
|
10783
|
-
});
|
|
10784
|
-
Promise.all(promises).then(() => resolve()).catch(reject);
|
|
10785
|
-
transaction.onerror = () => reject(transaction.error);
|
|
10786
|
-
});
|
|
10712
|
+
const transaction = db.transaction([STORE_UTXOS], "readwrite");
|
|
10713
|
+
const store = transaction.objectStore(STORE_UTXOS);
|
|
10714
|
+
for (const utxo of utxos) store.put({ address, ...serializeUtxo(utxo) });
|
|
10715
|
+
await awaitTransaction(transaction);
|
|
10787
10716
|
} catch (error) {
|
|
10788
10717
|
console.error(`Failed to save UTXOs for address ${address}:`, error);
|
|
10789
10718
|
throw error;
|
|
@@ -10792,22 +10721,9 @@ var IndexedDBWalletRepository = class {
|
|
|
10792
10721
|
async deleteUtxos(address) {
|
|
10793
10722
|
try {
|
|
10794
10723
|
const db = await this.getDB();
|
|
10795
|
-
|
|
10796
|
-
|
|
10797
|
-
|
|
10798
|
-
const index = store.index("address");
|
|
10799
|
-
const request = index.openCursor(IDBKeyRange.only(address));
|
|
10800
|
-
request.onerror = () => reject(request.error);
|
|
10801
|
-
request.onsuccess = () => {
|
|
10802
|
-
const cursor = request.result;
|
|
10803
|
-
if (cursor) {
|
|
10804
|
-
cursor.delete();
|
|
10805
|
-
cursor.continue();
|
|
10806
|
-
} else {
|
|
10807
|
-
resolve();
|
|
10808
|
-
}
|
|
10809
|
-
};
|
|
10810
|
-
});
|
|
10724
|
+
const transaction = db.transaction([STORE_UTXOS], "readwrite");
|
|
10725
|
+
deleteByIndex(transaction.objectStore(STORE_UTXOS), "address", address);
|
|
10726
|
+
await awaitTransaction(transaction);
|
|
10811
10727
|
} catch (error) {
|
|
10812
10728
|
console.error(`Failed to clear UTXOs for address ${address}:`, error);
|
|
10813
10729
|
throw error;
|
|
@@ -10816,17 +10732,11 @@ var IndexedDBWalletRepository = class {
|
|
|
10816
10732
|
async getTransactionHistory(address) {
|
|
10817
10733
|
try {
|
|
10818
10734
|
const db = await this.getDB();
|
|
10819
|
-
|
|
10820
|
-
|
|
10821
|
-
|
|
10822
|
-
|
|
10823
|
-
|
|
10824
|
-
request.onerror = () => reject(request.error);
|
|
10825
|
-
request.onsuccess = () => {
|
|
10826
|
-
const results = request.result || [];
|
|
10827
|
-
resolve(results.sort((a, b) => a.createdAt - b.createdAt));
|
|
10828
|
-
};
|
|
10829
|
-
});
|
|
10735
|
+
const store = db.transaction([STORE_TRANSACTIONS], "readonly").objectStore(STORE_TRANSACTIONS);
|
|
10736
|
+
const results = await promisifyRequest(
|
|
10737
|
+
store.index("address").getAll(address)
|
|
10738
|
+
);
|
|
10739
|
+
return (results || []).sort((a, b) => a.createdAt - b.createdAt);
|
|
10830
10740
|
} catch (error) {
|
|
10831
10741
|
console.error(`Failed to get transaction history for address ${address}:`, error);
|
|
10832
10742
|
return [];
|
|
@@ -10835,23 +10745,18 @@ var IndexedDBWalletRepository = class {
|
|
|
10835
10745
|
async saveTransactions(address, txs) {
|
|
10836
10746
|
try {
|
|
10837
10747
|
const db = await this.getDB();
|
|
10838
|
-
|
|
10839
|
-
|
|
10840
|
-
|
|
10841
|
-
|
|
10842
|
-
|
|
10843
|
-
|
|
10844
|
-
|
|
10845
|
-
|
|
10846
|
-
|
|
10847
|
-
keyArkTxid: tx.key.arkTxid
|
|
10848
|
-
};
|
|
10849
|
-
store.put(item);
|
|
10748
|
+
const transaction = db.transaction([STORE_TRANSACTIONS], "readwrite");
|
|
10749
|
+
const store = transaction.objectStore(STORE_TRANSACTIONS);
|
|
10750
|
+
for (const tx of txs) {
|
|
10751
|
+
store.put({
|
|
10752
|
+
address,
|
|
10753
|
+
...tx,
|
|
10754
|
+
keyBoardingTxid: tx.key.boardingTxid,
|
|
10755
|
+
keyCommitmentTxid: tx.key.commitmentTxid,
|
|
10756
|
+
keyArkTxid: tx.key.arkTxid
|
|
10850
10757
|
});
|
|
10851
|
-
|
|
10852
|
-
|
|
10853
|
-
transaction.onabort = () => reject(new Error("Transaction aborted"));
|
|
10854
|
-
});
|
|
10758
|
+
}
|
|
10759
|
+
await awaitTransaction(transaction);
|
|
10855
10760
|
} catch (error) {
|
|
10856
10761
|
console.error(`Failed to save transactions for address ${address}:`, error);
|
|
10857
10762
|
throw error;
|
|
@@ -10860,22 +10765,9 @@ var IndexedDBWalletRepository = class {
|
|
|
10860
10765
|
async deleteTransactions(address) {
|
|
10861
10766
|
try {
|
|
10862
10767
|
const db = await this.getDB();
|
|
10863
|
-
|
|
10864
|
-
|
|
10865
|
-
|
|
10866
|
-
const index = store.index("address");
|
|
10867
|
-
const request = index.openCursor(IDBKeyRange.only(address));
|
|
10868
|
-
request.onerror = () => reject(request.error);
|
|
10869
|
-
request.onsuccess = () => {
|
|
10870
|
-
const cursor = request.result;
|
|
10871
|
-
if (cursor) {
|
|
10872
|
-
cursor.delete();
|
|
10873
|
-
cursor.continue();
|
|
10874
|
-
} else {
|
|
10875
|
-
resolve();
|
|
10876
|
-
}
|
|
10877
|
-
};
|
|
10878
|
-
});
|
|
10768
|
+
const transaction = db.transaction([STORE_TRANSACTIONS], "readwrite");
|
|
10769
|
+
deleteByIndex(transaction.objectStore(STORE_TRANSACTIONS), "address", address);
|
|
10770
|
+
await awaitTransaction(transaction);
|
|
10879
10771
|
} catch (error) {
|
|
10880
10772
|
console.error(`Failed to clear transactions for address ${address}:`, error);
|
|
10881
10773
|
throw error;
|
|
@@ -10884,20 +10776,11 @@ var IndexedDBWalletRepository = class {
|
|
|
10884
10776
|
async getWalletState() {
|
|
10885
10777
|
try {
|
|
10886
10778
|
const db = await this.getDB();
|
|
10887
|
-
|
|
10888
|
-
|
|
10889
|
-
|
|
10890
|
-
|
|
10891
|
-
|
|
10892
|
-
request.onsuccess = () => {
|
|
10893
|
-
const result = request.result;
|
|
10894
|
-
if (result && result.data) {
|
|
10895
|
-
resolve(result.data);
|
|
10896
|
-
} else {
|
|
10897
|
-
resolve(null);
|
|
10898
|
-
}
|
|
10899
|
-
};
|
|
10900
|
-
});
|
|
10779
|
+
const store = db.transaction([STORE_WALLET_STATE], "readonly").objectStore(STORE_WALLET_STATE);
|
|
10780
|
+
const result = await promisifyRequest(
|
|
10781
|
+
store.get("state")
|
|
10782
|
+
);
|
|
10783
|
+
return result?.data ?? null;
|
|
10901
10784
|
} catch (error) {
|
|
10902
10785
|
console.error("Failed to get wallet state:", error);
|
|
10903
10786
|
return null;
|
|
@@ -10906,26 +10789,16 @@ var IndexedDBWalletRepository = class {
|
|
|
10906
10789
|
async saveWalletState(state) {
|
|
10907
10790
|
try {
|
|
10908
10791
|
const db = await this.getDB();
|
|
10909
|
-
|
|
10910
|
-
|
|
10911
|
-
|
|
10912
|
-
const item = {
|
|
10913
|
-
key: "state",
|
|
10914
|
-
data: state
|
|
10915
|
-
};
|
|
10916
|
-
const request = store.put(item);
|
|
10917
|
-
request.onerror = () => reject(request.error);
|
|
10918
|
-
request.onsuccess = () => resolve();
|
|
10919
|
-
});
|
|
10792
|
+
const transaction = db.transaction([STORE_WALLET_STATE], "readwrite");
|
|
10793
|
+
transaction.objectStore(STORE_WALLET_STATE).put({ key: "state", data: state });
|
|
10794
|
+
await awaitTransaction(transaction);
|
|
10920
10795
|
} catch (error) {
|
|
10921
10796
|
console.error("Failed to save wallet state:", error);
|
|
10922
10797
|
throw error;
|
|
10923
10798
|
}
|
|
10924
10799
|
}
|
|
10925
|
-
|
|
10926
|
-
|
|
10927
|
-
this.db = await openDatabase(this.dbName, DB_VERSION, initDatabase);
|
|
10928
|
-
return this.db;
|
|
10800
|
+
getDB() {
|
|
10801
|
+
return this.connection.get();
|
|
10929
10802
|
}
|
|
10930
10803
|
};
|
|
10931
10804
|
function deserializeVtxoWithBackfill(o) {
|
|
@@ -22759,6 +22632,6 @@ function createDefaultPaymentRouter(wallet) {
|
|
|
22759
22632
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
22760
22633
|
*/
|
|
22761
22634
|
|
|
22762
|
-
export { ARKADE_MAGIC, ARKADE_SALTED_PREIMAGE_TAG, ARKADE_SWAP_PREIMAGE_TAG, ActivityRegistry, AmbiguousRouteError, ArkNote, ArkadeCash, ArkadeCashCreateError, AssetManager, BIP21, BIP21Error, BIP322, Batch, ChainedTxType, ContractManager, ContractRepositoryImpl, ContractWatcher, DB_VERSION, DEFAULT_MESSAGE_TIMEOUTS, DEFAULT_MIN_BATCH_EXPIRY_SECONDS, DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, 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, P2A, PaymentRouter, 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, WalletCannotSignError, WalletMessageHandler, WalletNotInitializedError, WalletRepositoryImpl, WsElectrumChainSource, adoptContractDescriptor, arkRail, arkTarget, arkade_exports, assertFinalCommitmentMatchesValidated, assertIntentIdUnique, assertSendableAmount, assertSubmittedArkTxid, assertValidBatchExpiry, assertValidServerUnrollScript, assetMintResolver, boardingResolver, btcTarget, buildForfeitTx, buildOffchainTx, buildPreimageMessage, buildSaltedPreimageMessage, claimWithPreimageIdentity, classifyAgainstSignerSet, classifyContractSigner, closeDatabase, collabExitResolver, combineTapscriptSigs, contractFromArkContract, contractFromArkContractWithAddress, contractPreimage, contractSigner, createAssetPacket, createDefaultActivityRegistry, createDefaultPaymentRouter, createExitChainResolver, decodeArkContract, defaultBatchExpiryPolicy, defaultCheckpointExitDelayPolicy, deserializeAssets, deserializeExitPackage, deserializeUtxo, deserializeVtxo, encodeArkContract, extendVirtualCoinForContract, gateExclusion, gatedContracts, getMigrationStatus, getRandomId, hasBoardingTxExpired, hasCandidates, intentMatchesFilter, intentPageBounds, invoiceTarget, isArkContract, isBatchSignable, isBtcAddress, isContractGenericallySpendable, isCooperativelyMigratable, isDeterministicSigner, isDiscoverable, isHDAllocationCapable, isHDDeterministicSignCapable, isHDWalletCapable, isLightningInvoice, isLnurl, isMessageBusInitializingError, isMessageBusNotInitializedError, isPerArtifactDescriptor, isSigningIdentity, isSubdust, isTerminalIntentState, isValidArkAddress, isVtxoExpiringSoon, isVtxoForScript, isWatchedContract, logExcludedVtxos, makeHandle, matchServerCheckpoints, mergeChainedTxType, migrateWalletRepository, onchainRail, openDatabase, outpointExclusion, outpointReasons, provisionClaimSecret, provisionRefundKey, requiresMigration, resolveBatchExpiryPolicy, resolveCheckpointExitDelayPolicy, resolveDescriptorSigner, resolveSendAmount, rollbackMigration, saveVtxosForContract, scriptFromArkAddress, selectCoinsWithAsset, selectVirtualCoins, serializeAssets, serializeExitPackage, serializeUtxo, serializeVtxo, setupServiceWorker, signAndSubmitOffchainTx, signerSetFromInfo, signingDescriptorIndex, strictSigningDescriptorIndex, toXOnlySignerHex, tryResolveSendAmount, validateBatchRecipients, validateConnectorsTxGraph, validateVtxoTxGraph, verifyTapscriptSignatures, waitForIncomingFunds, warnAndFilterVtxosForScript };
|
|
22763
|
-
//# sourceMappingURL=chunk-
|
|
22764
|
-
//# sourceMappingURL=chunk-
|
|
22635
|
+
export { ARKADE_MAGIC, ARKADE_SALTED_PREIMAGE_TAG, ARKADE_SWAP_PREIMAGE_TAG, ActivityRegistry, AmbiguousRouteError, ArkNote, ArkadeCash, ArkadeCashCreateError, AssetManager, BIP21, BIP21Error, BIP322, BLOCKED_UPGRADE_TIMEOUT_MS, Batch, ChainedTxType, ConnectionDisposedError, ContractManager, ContractRepositoryImpl, ContractWatcher, DB_VERSION, 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, P2A, PaymentRouter, 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, WalletCannotSignError, WalletMessageHandler, WalletNotInitializedError, WalletRepositoryImpl, WsElectrumChainSource, adoptContractDescriptor, arkRail, arkTarget, arkade_exports, assertFinalCommitmentMatchesValidated, assertIntentIdUnique, assertSendableAmount, assertSubmittedArkTxid, assertValidBatchExpiry, assertValidServerUnrollScript, assetMintResolver, 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, extendVirtualCoinForContract, gateExclusion, gatedContracts, getAllByIndexValues, getMigrationStatus, getRandomId, hasBoardingTxExpired, hasCandidates, intentMatchesFilter, intentPageBounds, invoiceTarget, isArkContract, isBatchSignable, isBtcAddress, isContractGenericallySpendable, isCooperativelyMigratable, isDeterministicSigner, isDiscoverable, isHDAllocationCapable, isHDDeterministicSignCapable, isHDWalletCapable, isLightningInvoice, isLnurl, isMessageBusInitializingError, isMessageBusNotInitializedError, isPerArtifactDescriptor, isSigningIdentity, isSubdust, isTerminalIntentState, isValidArkAddress, isVtxoExpiringSoon, isVtxoForScript, isWatchedContract, logExcludedVtxos, makeHandle, matchServerCheckpoints, mergeChainedTxType, migrateWalletRepository, onchainRail, openDatabase, outpointExclusion, outpointReasons, promisifyRequest, provisionClaimSecret, provisionRefundKey, requiresMigration, resolveBatchExpiryPolicy, resolveCheckpointExitDelayPolicy, resolveDescriptorSigner, resolveSendAmount, rollbackMigration, saveVtxosForContract, scriptFromArkAddress, selectCoinsWithAsset, selectVirtualCoins, serializeAssets, serializeExitPackage, serializeUtxo, serializeVtxo, setupServiceWorker, signAndSubmitOffchainTx, signerSetFromInfo, signingDescriptorIndex, strictSigningDescriptorIndex, toXOnlySignerHex, tryResolveSendAmount, validateBatchRecipients, validateConnectorsTxGraph, validateVtxoTxGraph, verifyTapscriptSignatures, waitForIncomingFunds, warnAndFilterVtxosForScript };
|
|
22636
|
+
//# sourceMappingURL=chunk-5YTSQSLE.js.map
|
|
22637
|
+
//# sourceMappingURL=chunk-5YTSQSLE.js.map
|