@arkade-os/sdk 0.3.13 → 0.4.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +586 -54
- package/dist/cjs/asset/assetGroup.js +141 -0
- package/dist/cjs/asset/assetId.js +88 -0
- package/dist/cjs/asset/assetInput.js +204 -0
- package/dist/cjs/asset/assetOutput.js +159 -0
- package/dist/cjs/asset/assetRef.js +82 -0
- package/dist/cjs/asset/index.js +24 -0
- package/dist/cjs/asset/metadata.js +172 -0
- package/dist/cjs/asset/packet.js +164 -0
- package/dist/cjs/asset/types.js +25 -0
- package/dist/cjs/asset/utils.js +105 -0
- package/dist/cjs/bip322/index.js +270 -0
- package/dist/cjs/contracts/arkcontract.js +148 -0
- package/dist/cjs/contracts/contractManager.js +436 -0
- package/dist/cjs/contracts/contractWatcher.js +567 -0
- package/dist/cjs/contracts/handlers/default.js +85 -0
- package/dist/cjs/contracts/handlers/delegate.js +89 -0
- package/dist/cjs/contracts/handlers/helpers.js +105 -0
- package/dist/cjs/contracts/handlers/index.js +19 -0
- package/dist/cjs/contracts/handlers/registry.js +89 -0
- package/dist/cjs/contracts/handlers/vhtlc.js +193 -0
- package/dist/cjs/contracts/index.js +41 -0
- package/dist/cjs/contracts/types.js +2 -0
- package/dist/cjs/forfeit.js +12 -8
- package/dist/cjs/identity/index.js +1 -0
- package/dist/cjs/identity/seedIdentity.js +255 -0
- package/dist/cjs/index.js +72 -14
- package/dist/cjs/intent/index.js +47 -11
- package/dist/cjs/providers/ark.js +7 -0
- package/dist/cjs/providers/delegator.js +66 -0
- package/dist/cjs/providers/expoIndexer.js +5 -0
- package/dist/cjs/providers/indexer.js +68 -1
- package/dist/cjs/providers/utils.js +1 -0
- package/dist/cjs/repositories/contractRepository.js +0 -103
- package/dist/cjs/repositories/inMemory/contractRepository.js +55 -0
- package/dist/cjs/repositories/inMemory/walletRepository.js +80 -0
- package/dist/cjs/repositories/index.js +16 -0
- package/dist/cjs/repositories/indexedDB/contractRepository.js +187 -0
- package/dist/cjs/repositories/indexedDB/db.js +19 -0
- package/dist/cjs/repositories/indexedDB/manager.js +97 -0
- package/dist/cjs/repositories/indexedDB/schema.js +159 -0
- package/dist/cjs/repositories/indexedDB/walletRepository.js +338 -0
- package/dist/cjs/repositories/indexedDB/websqlAdapter.js +144 -0
- package/dist/cjs/repositories/migrations/contractRepositoryImpl.js +127 -0
- package/dist/cjs/repositories/migrations/fromStorageAdapter.js +66 -0
- package/dist/cjs/repositories/migrations/walletRepositoryImpl.js +180 -0
- package/dist/cjs/repositories/realm/contractRepository.js +120 -0
- package/dist/cjs/repositories/realm/index.js +9 -0
- package/dist/cjs/repositories/realm/schemas.js +108 -0
- package/dist/cjs/repositories/realm/types.js +7 -0
- package/dist/cjs/repositories/realm/walletRepository.js +273 -0
- package/dist/cjs/repositories/serialization.js +49 -0
- package/dist/cjs/repositories/sqlite/contractRepository.js +139 -0
- package/dist/cjs/repositories/sqlite/index.js +7 -0
- package/dist/cjs/repositories/sqlite/types.js +2 -0
- package/dist/cjs/repositories/sqlite/walletRepository.js +328 -0
- package/dist/cjs/repositories/walletRepository.js +0 -169
- package/dist/cjs/script/base.js +54 -0
- package/dist/cjs/script/delegate.js +49 -0
- package/dist/cjs/storage/asyncStorage.js +4 -1
- package/dist/cjs/storage/fileSystem.js +3 -0
- package/dist/cjs/storage/inMemory.js +3 -0
- package/dist/cjs/storage/indexedDB.js +5 -1
- package/dist/cjs/storage/localStorage.js +3 -0
- package/dist/cjs/utils/arkTransaction.js +16 -0
- package/dist/cjs/utils/transactionHistory.js +50 -0
- package/dist/cjs/wallet/asset-manager.js +338 -0
- package/dist/cjs/wallet/asset.js +117 -0
- package/dist/cjs/wallet/batch.js +1 -1
- package/dist/cjs/wallet/delegator.js +235 -0
- package/dist/cjs/wallet/expo/background.js +133 -0
- package/dist/cjs/wallet/expo/index.js +9 -0
- package/dist/cjs/wallet/expo/wallet.js +231 -0
- package/dist/cjs/wallet/serviceWorker/wallet-message-handler.js +568 -0
- package/dist/cjs/wallet/serviceWorker/wallet.js +383 -102
- package/dist/cjs/wallet/utils.js +58 -0
- package/dist/cjs/wallet/validation.js +151 -0
- package/dist/cjs/wallet/vtxo-manager.js +8 -1
- package/dist/cjs/wallet/wallet.js +702 -260
- package/dist/cjs/worker/browser/service-worker-manager.js +82 -0
- package/dist/cjs/{wallet/serviceWorker → worker/browser}/utils.js +2 -1
- package/dist/cjs/worker/expo/asyncStorageTaskQueue.js +78 -0
- package/dist/cjs/worker/expo/index.js +12 -0
- package/dist/cjs/worker/expo/processors/contractPollProcessor.js +61 -0
- package/dist/cjs/worker/expo/processors/index.js +6 -0
- package/dist/cjs/worker/expo/taskQueue.js +41 -0
- package/dist/cjs/worker/expo/taskRunner.js +57 -0
- package/dist/cjs/worker/messageBus.js +252 -0
- package/dist/esm/asset/assetGroup.js +137 -0
- package/dist/esm/asset/assetId.js +84 -0
- package/dist/esm/asset/assetInput.js +199 -0
- package/dist/esm/asset/assetOutput.js +154 -0
- package/dist/esm/asset/assetRef.js +78 -0
- package/dist/esm/asset/index.js +8 -0
- package/dist/esm/asset/metadata.js +167 -0
- package/dist/esm/asset/packet.js +159 -0
- package/dist/esm/asset/types.js +22 -0
- package/dist/esm/asset/utils.js +99 -0
- package/dist/esm/bip322/index.js +267 -0
- package/dist/esm/contracts/arkcontract.js +141 -0
- package/dist/esm/contracts/contractManager.js +432 -0
- package/dist/esm/contracts/contractWatcher.js +563 -0
- package/dist/esm/contracts/handlers/default.js +82 -0
- package/dist/esm/contracts/handlers/delegate.js +86 -0
- package/dist/esm/contracts/handlers/helpers.js +66 -0
- package/dist/esm/contracts/handlers/index.js +12 -0
- package/dist/esm/contracts/handlers/registry.js +86 -0
- package/dist/esm/contracts/handlers/vhtlc.js +190 -0
- package/dist/esm/contracts/index.js +13 -0
- package/dist/esm/contracts/types.js +1 -0
- package/dist/esm/forfeit.js +11 -8
- package/dist/esm/identity/index.js +1 -0
- package/dist/esm/identity/seedIdentity.js +249 -0
- package/dist/esm/index.js +28 -15
- package/dist/esm/intent/index.js +44 -9
- package/dist/esm/providers/ark.js +7 -0
- package/dist/esm/providers/delegator.js +62 -0
- package/dist/esm/providers/expoIndexer.js +5 -0
- package/dist/esm/providers/indexer.js +68 -1
- package/dist/esm/providers/utils.js +1 -0
- package/dist/esm/repositories/contractRepository.js +1 -101
- package/dist/esm/repositories/inMemory/contractRepository.js +51 -0
- package/dist/esm/repositories/inMemory/walletRepository.js +76 -0
- package/dist/esm/repositories/index.js +8 -0
- package/dist/esm/repositories/indexedDB/contractRepository.js +183 -0
- package/dist/esm/repositories/indexedDB/db.js +4 -0
- package/dist/esm/repositories/indexedDB/manager.js +92 -0
- package/dist/esm/repositories/indexedDB/schema.js +155 -0
- package/dist/esm/repositories/indexedDB/walletRepository.js +334 -0
- package/dist/esm/repositories/indexedDB/websqlAdapter.js +138 -0
- package/dist/esm/repositories/migrations/contractRepositoryImpl.js +121 -0
- package/dist/esm/repositories/migrations/fromStorageAdapter.js +58 -0
- package/dist/esm/repositories/migrations/walletRepositoryImpl.js +176 -0
- package/dist/esm/repositories/realm/contractRepository.js +116 -0
- package/dist/esm/repositories/realm/index.js +3 -0
- package/dist/esm/repositories/realm/schemas.js +105 -0
- package/dist/esm/repositories/realm/types.js +6 -0
- package/dist/esm/repositories/realm/walletRepository.js +269 -0
- package/dist/esm/repositories/serialization.js +40 -0
- package/dist/esm/repositories/sqlite/contractRepository.js +135 -0
- package/dist/esm/repositories/sqlite/index.js +2 -0
- package/dist/esm/repositories/sqlite/types.js +1 -0
- package/dist/esm/repositories/sqlite/walletRepository.js +324 -0
- package/dist/esm/repositories/walletRepository.js +1 -167
- package/dist/esm/script/base.js +21 -1
- package/dist/esm/script/delegate.js +46 -0
- package/dist/esm/storage/asyncStorage.js +4 -1
- package/dist/esm/storage/fileSystem.js +3 -0
- package/dist/esm/storage/inMemory.js +3 -0
- package/dist/esm/storage/indexedDB.js +5 -1
- package/dist/esm/storage/localStorage.js +3 -0
- package/dist/esm/utils/arkTransaction.js +15 -0
- package/dist/esm/utils/transactionHistory.js +50 -0
- package/dist/esm/wallet/asset-manager.js +333 -0
- package/dist/esm/wallet/asset.js +111 -0
- package/dist/esm/wallet/batch.js +1 -1
- package/dist/esm/wallet/delegator.js +231 -0
- package/dist/esm/wallet/expo/background.js +128 -0
- package/dist/esm/wallet/expo/index.js +2 -0
- package/dist/esm/wallet/expo/wallet.js +194 -0
- package/dist/esm/wallet/serviceWorker/wallet-message-handler.js +564 -0
- package/dist/esm/wallet/serviceWorker/wallet.js +382 -101
- package/dist/esm/wallet/utils.js +54 -0
- package/dist/esm/wallet/validation.js +139 -0
- package/dist/esm/wallet/vtxo-manager.js +8 -1
- package/dist/esm/wallet/wallet.js +704 -229
- package/dist/esm/worker/browser/service-worker-manager.js +76 -0
- package/dist/esm/{wallet/serviceWorker → worker/browser}/utils.js +2 -1
- package/dist/esm/worker/expo/asyncStorageTaskQueue.js +74 -0
- package/dist/esm/worker/expo/index.js +4 -0
- package/dist/esm/worker/expo/processors/contractPollProcessor.js +58 -0
- package/dist/esm/worker/expo/processors/index.js +1 -0
- package/dist/esm/worker/expo/taskQueue.js +37 -0
- package/dist/esm/worker/expo/taskRunner.js +54 -0
- package/dist/esm/worker/messageBus.js +248 -0
- package/dist/types/asset/assetGroup.d.ts +28 -0
- package/dist/types/asset/assetId.d.ts +19 -0
- package/dist/types/asset/assetInput.d.ts +46 -0
- package/dist/types/asset/assetOutput.d.ts +39 -0
- package/dist/types/asset/assetRef.d.ts +25 -0
- package/dist/types/asset/index.d.ts +8 -0
- package/dist/types/asset/metadata.d.ts +37 -0
- package/dist/types/asset/packet.d.ts +27 -0
- package/dist/types/asset/types.d.ts +18 -0
- package/dist/types/asset/utils.d.ts +21 -0
- package/dist/types/bip322/index.d.ts +55 -0
- package/dist/types/contracts/arkcontract.d.ts +101 -0
- package/dist/types/contracts/contractManager.d.ts +331 -0
- package/dist/types/contracts/contractWatcher.d.ts +192 -0
- package/dist/types/contracts/handlers/default.d.ts +19 -0
- package/dist/types/contracts/handlers/delegate.d.ts +21 -0
- package/dist/types/contracts/handlers/helpers.d.ts +18 -0
- package/dist/types/contracts/handlers/index.d.ts +7 -0
- package/dist/types/contracts/handlers/registry.d.ts +65 -0
- package/dist/types/contracts/handlers/vhtlc.d.ts +32 -0
- package/dist/types/contracts/index.d.ts +14 -0
- package/dist/types/contracts/types.d.ts +222 -0
- package/dist/types/forfeit.d.ts +2 -1
- package/dist/types/identity/index.d.ts +1 -0
- package/dist/types/identity/seedIdentity.d.ts +128 -0
- package/dist/types/index.d.ts +22 -12
- package/dist/types/intent/index.d.ts +15 -1
- package/dist/types/providers/ark.d.ts +11 -2
- package/dist/types/providers/delegator.d.ts +29 -0
- package/dist/types/providers/indexer.d.ts +11 -1
- package/dist/types/repositories/contractRepository.d.ts +30 -19
- package/dist/types/repositories/inMemory/contractRepository.d.ts +17 -0
- package/dist/types/repositories/inMemory/walletRepository.d.ts +26 -0
- package/dist/types/repositories/index.d.ts +7 -0
- package/dist/types/repositories/indexedDB/contractRepository.d.ts +21 -0
- package/dist/types/repositories/indexedDB/db.d.ts +4 -0
- package/dist/types/repositories/indexedDB/manager.d.ts +22 -0
- package/dist/types/repositories/indexedDB/schema.d.ts +8 -0
- package/dist/types/repositories/indexedDB/walletRepository.d.ts +25 -0
- package/dist/types/repositories/indexedDB/websqlAdapter.d.ts +49 -0
- package/dist/types/repositories/migrations/contractRepositoryImpl.d.ts +24 -0
- package/dist/types/repositories/migrations/fromStorageAdapter.d.ts +19 -0
- package/dist/types/repositories/migrations/walletRepositoryImpl.d.ts +27 -0
- package/dist/types/repositories/realm/contractRepository.d.ts +24 -0
- package/dist/types/repositories/realm/index.d.ts +4 -0
- package/dist/types/repositories/realm/schemas.d.ts +208 -0
- package/dist/types/repositories/realm/types.d.ts +16 -0
- package/dist/types/repositories/realm/walletRepository.d.ts +31 -0
- package/dist/types/repositories/serialization.d.ts +40 -0
- package/dist/types/repositories/sqlite/contractRepository.d.ts +33 -0
- package/dist/types/repositories/sqlite/index.d.ts +3 -0
- package/dist/types/repositories/sqlite/types.d.ts +18 -0
- package/dist/types/repositories/sqlite/walletRepository.d.ts +40 -0
- package/dist/types/repositories/walletRepository.d.ts +13 -24
- package/dist/types/script/base.d.ts +1 -0
- package/dist/types/script/delegate.d.ts +36 -0
- package/dist/types/storage/asyncStorage.d.ts +4 -0
- package/dist/types/storage/fileSystem.d.ts +3 -0
- package/dist/types/storage/inMemory.d.ts +3 -0
- package/dist/types/storage/index.d.ts +3 -0
- package/dist/types/storage/indexedDB.d.ts +3 -0
- package/dist/types/storage/localStorage.d.ts +3 -0
- package/dist/types/utils/arkTransaction.d.ts +6 -0
- package/dist/types/wallet/asset-manager.d.ts +78 -0
- package/dist/types/wallet/asset.d.ts +21 -0
- package/dist/types/wallet/batch.d.ts +1 -1
- package/dist/types/wallet/delegator.d.ts +24 -0
- package/dist/types/wallet/expo/background.d.ts +66 -0
- package/dist/types/wallet/expo/index.d.ts +4 -0
- package/dist/types/wallet/expo/wallet.d.ts +97 -0
- package/dist/types/wallet/index.d.ts +75 -2
- package/dist/types/wallet/serviceWorker/wallet-message-handler.d.ts +366 -0
- package/dist/types/wallet/serviceWorker/wallet.d.ts +20 -11
- package/dist/types/wallet/utils.d.ts +12 -1
- package/dist/types/wallet/validation.d.ts +24 -0
- package/dist/types/wallet/wallet.d.ts +111 -17
- package/dist/types/worker/browser/service-worker-manager.d.ts +21 -0
- package/dist/types/{wallet/serviceWorker → worker/browser}/utils.d.ts +2 -1
- package/dist/types/worker/expo/asyncStorageTaskQueue.d.ts +46 -0
- package/dist/types/worker/expo/index.d.ts +7 -0
- package/dist/types/worker/expo/processors/contractPollProcessor.d.ts +14 -0
- package/dist/types/worker/expo/processors/index.d.ts +1 -0
- package/dist/types/worker/expo/taskQueue.d.ts +50 -0
- package/dist/types/worker/expo/taskRunner.d.ts +42 -0
- package/dist/types/worker/messageBus.d.ts +109 -0
- package/package.json +69 -11
- package/dist/cjs/wallet/serviceWorker/request.js +0 -78
- package/dist/cjs/wallet/serviceWorker/response.js +0 -222
- package/dist/cjs/wallet/serviceWorker/worker.js +0 -655
- package/dist/esm/wallet/serviceWorker/request.js +0 -75
- package/dist/esm/wallet/serviceWorker/response.js +0 -219
- package/dist/esm/wallet/serviceWorker/worker.js +0 -651
- package/dist/types/wallet/serviceWorker/request.d.ts +0 -74
- package/dist/types/wallet/serviceWorker/response.d.ts +0 -123
- package/dist/types/wallet/serviceWorker/worker.d.ts +0 -53
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Identity, ReadonlyIdentity } from ".";
|
|
2
|
+
import { Transaction } from "../utils/transaction";
|
|
3
|
+
import { SignerSession } from "../tree/signingSession";
|
|
4
|
+
/** Use default BIP86 derivation with network selection. */
|
|
5
|
+
export interface NetworkOptions {
|
|
6
|
+
/** Mainnet (coin type 0) or testnet (coin type 1). */
|
|
7
|
+
isMainnet: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** Use a custom output descriptor for derivation. */
|
|
10
|
+
export interface DescriptorOptions {
|
|
11
|
+
/** Custom output descriptor that determines the derivation path. */
|
|
12
|
+
descriptor: string;
|
|
13
|
+
}
|
|
14
|
+
/** Either default BIP86 derivation (with optional network) or a custom descriptor. */
|
|
15
|
+
export type SeedIdentityOptions = NetworkOptions | DescriptorOptions;
|
|
16
|
+
export type MnemonicOptions = SeedIdentityOptions & {
|
|
17
|
+
/** Optional BIP39 passphrase for additional seed entropy. */
|
|
18
|
+
passphrase?: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Seed-based identity derived from a raw seed and an output descriptor.
|
|
22
|
+
*
|
|
23
|
+
* This is the recommended identity type for most applications. It uses
|
|
24
|
+
* standard BIP86 (Taproot) derivation by default and stores an output
|
|
25
|
+
* descriptor for interoperability with other wallets. The descriptor
|
|
26
|
+
* format is HD-ready, allowing future support for multiple addresses
|
|
27
|
+
* and change derivation.
|
|
28
|
+
*
|
|
29
|
+
* Prefer this (or {@link MnemonicIdentity}) over `SingleKey` for new
|
|
30
|
+
* integrations — `SingleKey` exists for backward compatibility with
|
|
31
|
+
* raw nsec-style keys.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const seed = mnemonicToSeedSync(mnemonic);
|
|
36
|
+
*
|
|
37
|
+
* // Testnet (BIP86 path m/86'/1'/0'/0/0)
|
|
38
|
+
* const identity = SeedIdentity.fromSeed(seed, { isMainnet: false });
|
|
39
|
+
*
|
|
40
|
+
* // Mainnet (BIP86 path m/86'/0'/0'/0/0)
|
|
41
|
+
* const identity = SeedIdentity.fromSeed(seed, { isMainnet: true });
|
|
42
|
+
*
|
|
43
|
+
* // Custom descriptor
|
|
44
|
+
* const identity = SeedIdentity.fromSeed(seed, { descriptor });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare class SeedIdentity implements Identity {
|
|
48
|
+
protected readonly seed: Uint8Array;
|
|
49
|
+
private readonly derivedKey;
|
|
50
|
+
readonly descriptor: string;
|
|
51
|
+
constructor(seed: Uint8Array, descriptor: string);
|
|
52
|
+
/**
|
|
53
|
+
* Creates a SeedIdentity from a raw 64-byte seed.
|
|
54
|
+
*
|
|
55
|
+
* Pass `{ isMainnet }` for default BIP86 derivation, or
|
|
56
|
+
* `{ descriptor }` for a custom derivation path.
|
|
57
|
+
*
|
|
58
|
+
* @param seed - 64-byte seed (typically from mnemonicToSeedSync)
|
|
59
|
+
* @param opts - Network selection or custom descriptor.
|
|
60
|
+
*/
|
|
61
|
+
static fromSeed(seed: Uint8Array, opts: SeedIdentityOptions): SeedIdentity;
|
|
62
|
+
xOnlyPublicKey(): Promise<Uint8Array>;
|
|
63
|
+
compressedPublicKey(): Promise<Uint8Array>;
|
|
64
|
+
sign(tx: Transaction, inputIndexes?: number[]): Promise<Transaction>;
|
|
65
|
+
signMessage(message: Uint8Array, signatureType?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
|
|
66
|
+
signerSession(): SignerSession;
|
|
67
|
+
/**
|
|
68
|
+
* Converts to a watch-only identity that cannot sign.
|
|
69
|
+
*/
|
|
70
|
+
toReadonly(): Promise<ReadonlyDescriptorIdentity>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Mnemonic-based identity derived from a BIP39 phrase.
|
|
74
|
+
*
|
|
75
|
+
* This is the most user-friendly identity type — recommended for wallet
|
|
76
|
+
* applications where users manage their own backup phrase. Extends
|
|
77
|
+
* {@link SeedIdentity} with mnemonic validation and optional passphrase
|
|
78
|
+
* support.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* const identity = MnemonicIdentity.fromMnemonic(
|
|
83
|
+
* 'abandon abandon abandon ...',
|
|
84
|
+
* { isMainnet: true, passphrase: 'secret' }
|
|
85
|
+
* );
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export declare class MnemonicIdentity extends SeedIdentity {
|
|
89
|
+
private constructor();
|
|
90
|
+
/**
|
|
91
|
+
* Creates a MnemonicIdentity from a BIP39 mnemonic phrase.
|
|
92
|
+
*
|
|
93
|
+
* Pass `{ isMainnet }` for default BIP86 derivation, or
|
|
94
|
+
* `{ descriptor }` for a custom derivation path.
|
|
95
|
+
*
|
|
96
|
+
* @param phrase - BIP39 mnemonic phrase (12 or 24 words)
|
|
97
|
+
* @param opts - Network selection or custom descriptor, plus optional passphrase
|
|
98
|
+
*/
|
|
99
|
+
static fromMnemonic(phrase: string, opts: MnemonicOptions): MnemonicIdentity;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Watch-only identity from an output descriptor.
|
|
103
|
+
*
|
|
104
|
+
* Can derive public keys but cannot sign transactions. Use this for
|
|
105
|
+
* watch-only wallets or when sharing identity information without
|
|
106
|
+
* exposing private keys.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const descriptor = "tr([fingerprint/86'/0'/0']xpub.../0/0)";
|
|
111
|
+
* const readonly = ReadonlyDescriptorIdentity.fromDescriptor(descriptor);
|
|
112
|
+
* const pubKey = await readonly.xOnlyPublicKey();
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
export declare class ReadonlyDescriptorIdentity implements ReadonlyIdentity {
|
|
116
|
+
readonly descriptor: string;
|
|
117
|
+
private readonly xOnlyPubKey;
|
|
118
|
+
private readonly compressedPubKey;
|
|
119
|
+
private constructor();
|
|
120
|
+
/**
|
|
121
|
+
* Creates a ReadonlyDescriptorIdentity from an output descriptor.
|
|
122
|
+
*
|
|
123
|
+
* @param descriptor - Taproot descriptor: tr([fingerprint/path']xpub.../child/path)
|
|
124
|
+
*/
|
|
125
|
+
static fromDescriptor(descriptor: string): ReadonlyDescriptorIdentity;
|
|
126
|
+
xOnlyPublicKey(): Promise<Uint8Array>;
|
|
127
|
+
compressedPublicKey(): Promise<Uint8Array>;
|
|
128
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
import { Transaction } from "./utils/transaction";
|
|
2
2
|
import { SingleKey, ReadonlySingleKey } from "./identity/singleKey";
|
|
3
|
+
import { SeedIdentity, MnemonicIdentity, ReadonlyDescriptorIdentity } from "./identity/seedIdentity";
|
|
4
|
+
import type { SeedIdentityOptions, MnemonicOptions, NetworkOptions, DescriptorOptions } from "./identity/seedIdentity";
|
|
3
5
|
import { Identity, ReadonlyIdentity } from "./identity";
|
|
4
6
|
import { ArkAddress } from "./script/address";
|
|
5
7
|
import { VHTLC } from "./script/vhtlc";
|
|
6
8
|
import { DefaultVtxo } from "./script/default";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
+
import { DelegateVtxo } from "./script/delegate";
|
|
10
|
+
import { MessageHandler, RequestEnvelope, ResponseEnvelope, MessageBus } from "./worker/messageBus";
|
|
11
|
+
import { VtxoScript, EncodedVtxoScript, TapLeafScript, TapTreeCoder, getSequence } from "./script/base";
|
|
12
|
+
import { TxType, IWallet, IReadonlyWallet, BaseWalletConfig, WalletConfig, ReadonlyWalletConfig, ProviderClass, ArkTransaction, Coin, ExtendedCoin, ExtendedVirtualCoin, WalletBalance, SendBitcoinParams, SettleParams, Status, VirtualStatus, Outpoint, VirtualCoin, TxKey, GetVtxosFilter, TapLeaves, StorageConfig, isSpendable, isSubdust, isRecoverable, isExpired, Asset, Recipient, IssuanceParams, IssuanceResult, ReissuanceParams, BurnParams, AssetDetails, AssetMetadata, KnownMetadata } from "./wallet";
|
|
9
13
|
import { Batch } from "./wallet/batch";
|
|
10
|
-
import { Wallet, ReadonlyWallet, waitForIncomingFunds, IncomingFunds
|
|
14
|
+
import { Wallet, ReadonlyWallet, waitForIncomingFunds, IncomingFunds } from "./wallet/wallet";
|
|
11
15
|
import { TxTree, TxTreeNode } from "./tree/txTree";
|
|
12
16
|
import { SignerSession, TreeNonces, TreePartialSigs } from "./tree/signingSession";
|
|
13
17
|
import { Ramps } from "./wallet/ramps";
|
|
14
18
|
import { isVtxoExpiringSoon, VtxoManager } from "./wallet/vtxo-manager";
|
|
15
19
|
import { ServiceWorkerWallet, ServiceWorkerReadonlyWallet } from "./wallet/serviceWorker/wallet";
|
|
16
20
|
import { OnchainWallet } from "./wallet/onchain";
|
|
17
|
-
import { setupServiceWorker } from "./
|
|
18
|
-
import { Worker } from "./wallet/serviceWorker/worker";
|
|
19
|
-
import { Request } from "./wallet/serviceWorker/request";
|
|
20
|
-
import { Response } from "./wallet/serviceWorker/response";
|
|
21
|
+
import { setupServiceWorker } from "./worker/browser/utils";
|
|
21
22
|
import { ESPLORA_URL, EsploraProvider, OnchainProvider, ExplorerTransaction } from "./providers/onchain";
|
|
22
23
|
import { RestArkProvider, ArkProvider, SettlementEvent, SettlementEventType, ArkInfo, SignedIntent, Output, TxNotification, BatchFinalizationEvent, BatchFinalizedEvent, BatchFailedEvent, TreeSigningStartedEvent, TreeNoncesEvent, BatchStartedEvent, TreeTxEvent, TreeSignatureEvent, ScheduledSession, FeeInfo } from "./providers/ark";
|
|
24
|
+
import { DelegatorProvider, DelegateInfo, DelegateOptions, RestDelegatorProvider } from "./providers/delegator";
|
|
23
25
|
import { CLTVMultisigTapscript, ConditionCSVMultisigTapscript, ConditionMultisigTapscript, CSVMultisigTapscript, decodeTapscript, MultisigTapscript, TapscriptType, ArkTapscript, RelativeTimelock } from "./script/tapscript";
|
|
24
|
-
import { hasBoardingTxExpired, buildOffchainTx, verifyTapscriptSignatures, ArkTxInput, OffchainTx, combineTapscriptSigs } from "./utils/arkTransaction";
|
|
26
|
+
import { hasBoardingTxExpired, buildOffchainTx, verifyTapscriptSignatures, ArkTxInput, OffchainTx, combineTapscriptSigs, isValidArkAddress } from "./utils/arkTransaction";
|
|
25
27
|
import { VtxoTaprootTree, ConditionWitness, getArkPsbtFields, setArkPsbtField, ArkPsbtFieldCoder, ArkPsbtFieldKey, ArkPsbtFieldKeyType, CosignerPublicKey, VtxoTreeExpiry } from "./utils/unknownFields";
|
|
26
28
|
import { Intent } from "./intent";
|
|
29
|
+
import { BIP322 } from "./bip322";
|
|
27
30
|
import { ArkNote } from "./arknote";
|
|
28
31
|
import { networks, Network, NetworkName } from "./networks";
|
|
29
32
|
import { RestIndexerProvider, IndexerProvider, IndexerTxType, ChainTxType, PageResponse, BatchInfo, ChainTx, CommitmentTx, TxHistoryRecord, VtxoChain, Tx, Vtxo, PaginationOptions, SubscriptionResponse, SubscriptionHeartbeat, SubscriptionEvent } from "./providers/indexer";
|
|
@@ -31,11 +34,18 @@ import { Nonces } from "./musig2/nonces";
|
|
|
31
34
|
import { PartialSig } from "./musig2/sign";
|
|
32
35
|
import { AnchorBumper, P2A } from "./utils/anchor";
|
|
33
36
|
import { Unroll } from "./wallet/unroll";
|
|
34
|
-
import { WalletRepositoryImpl } from "./repositories/walletRepository";
|
|
35
|
-
import { ContractRepositoryImpl } from "./repositories/contractRepository";
|
|
36
37
|
import { ArkError, maybeArkError } from "./providers/errors";
|
|
37
38
|
import { validateVtxoTxGraph, validateConnectorsTxGraph } from "./tree/validation";
|
|
38
39
|
import { buildForfeitTx } from "./forfeit";
|
|
40
|
+
import { IndexedDBWalletRepository, IndexedDBContractRepository, InMemoryWalletRepository, InMemoryContractRepository, MIGRATION_KEY, migrateWalletRepository, requiresMigration, getMigrationStatus, rollbackMigration, WalletRepositoryImpl, ContractRepositoryImpl, WalletRepository, ContractRepository } from "./repositories";
|
|
41
|
+
import type { MigrationStatus } from "./repositories";
|
|
42
|
+
import { DelegatorManagerImpl, DelegatorManager } from "./wallet/delegator";
|
|
39
43
|
export * from "./arkfee";
|
|
40
|
-
export
|
|
41
|
-
|
|
44
|
+
export * as asset from "./asset";
|
|
45
|
+
import { ContractManager, ContractWatcher, contractHandlers, DefaultContractHandler, DelegateContractHandler, VHTLCContractHandler, encodeArkContract, decodeArkContract, contractFromArkContract, contractFromArkContractWithAddress, isArkContract } from "./contracts";
|
|
46
|
+
import type { Contract, ContractVtxo, ContractState, ContractEvent, ContractEventCallback, ContractBalance, ContractWithVtxos, ContractHandler, PathSelection, PathContext, ContractManagerConfig, CreateContractParams, ContractWatcherConfig, ParsedArkContract, DefaultContractParams, DelegateContractParams, VHTLCContractParams } from "./contracts";
|
|
47
|
+
import { IContractManager } from "./contracts/contractManager";
|
|
48
|
+
import { closeDatabase, openDatabase } from "./repositories/indexedDB/manager";
|
|
49
|
+
import { WalletMessageHandler } from "./wallet/serviceWorker/wallet-message-handler";
|
|
50
|
+
export { Wallet, ReadonlyWallet, SingleKey, ReadonlySingleKey, SeedIdentity, MnemonicIdentity, ReadonlyDescriptorIdentity, OnchainWallet, Ramps, VtxoManager, DelegatorManagerImpl, RestDelegatorProvider, ESPLORA_URL, EsploraProvider, RestArkProvider, RestIndexerProvider, ArkAddress, DefaultVtxo, DelegateVtxo, VtxoScript, VHTLC, TxType, IndexerTxType, ChainTxType, SettlementEventType, setupServiceWorker, MessageBus, WalletMessageHandler, ServiceWorkerWallet, ServiceWorkerReadonlyWallet, decodeTapscript, MultisigTapscript, CSVMultisigTapscript, ConditionCSVMultisigTapscript, ConditionMultisigTapscript, CLTVMultisigTapscript, TapTreeCoder, ArkPsbtFieldKey, ArkPsbtFieldKeyType, setArkPsbtField, getArkPsbtFields, CosignerPublicKey, VtxoTreeExpiry, VtxoTaprootTree, ConditionWitness, buildOffchainTx, verifyTapscriptSignatures, waitForIncomingFunds, hasBoardingTxExpired, combineTapscriptSigs, isVtxoExpiringSoon, isValidArkAddress, ArkNote, networks, closeDatabase, openDatabase, IndexedDBWalletRepository, IndexedDBContractRepository, InMemoryWalletRepository, InMemoryContractRepository, MIGRATION_KEY, migrateWalletRepository, requiresMigration, getMigrationStatus, rollbackMigration, WalletRepositoryImpl, ContractRepositoryImpl, Intent, BIP322, TxTree, P2A, Unroll, Transaction, ArkError, maybeArkError, Batch, validateVtxoTxGraph, validateConnectorsTxGraph, buildForfeitTx, isRecoverable, isSpendable, isSubdust, isExpired, getSequence, ContractManager, ContractWatcher, contractHandlers, DefaultContractHandler, DelegateContractHandler, VHTLCContractHandler, encodeArkContract, decodeArkContract, contractFromArkContract, contractFromArkContractWithAddress, isArkContract, };
|
|
51
|
+
export type { Identity, ReadonlyIdentity, IWallet, IReadonlyWallet, BaseWalletConfig, WalletConfig, ReadonlyWalletConfig, ProviderClass, ArkTransaction, Coin, ExtendedCoin, ExtendedVirtualCoin, WalletBalance, SendBitcoinParams, SettleParams, Status, VirtualStatus, Outpoint, VirtualCoin, TxKey, TapscriptType, ArkTxInput, OffchainTx, TapLeaves, IncomingFunds, SeedIdentityOptions, MnemonicOptions, NetworkOptions, DescriptorOptions, IndexerProvider, PageResponse, BatchInfo, ChainTx, CommitmentTx, TxHistoryRecord, Vtxo, VtxoChain, Tx, OnchainProvider, ArkProvider, SettlementEvent, FeeInfo, ArkInfo, SignedIntent, Output, TxNotification, ExplorerTransaction, BatchFinalizationEvent, BatchFinalizedEvent, BatchFailedEvent, TreeSigningStartedEvent, TreeNoncesEvent, BatchStartedEvent, TreeTxEvent, TreeSignatureEvent, ScheduledSession, PaginationOptions, SubscriptionResponse, SubscriptionHeartbeat, SubscriptionEvent, Network, NetworkName, ArkTapscript, RelativeTimelock, EncodedVtxoScript, TapLeafScript, SignerSession, TreeNonces, TreePartialSigs, GetVtxosFilter, Asset, Recipient, IssuanceParams, IssuanceResult, ReissuanceParams, BurnParams, AssetDetails, AssetMetadata, KnownMetadata, Nonces, PartialSig, ArkPsbtFieldCoder, TxTreeNode, AnchorBumper, StorageConfig, Contract, ContractVtxo, ContractState, ContractEvent, ContractEventCallback, ContractBalance, ContractWithVtxos, ContractHandler, IContractManager, PathSelection, PathContext, ContractManagerConfig, CreateContractParams, ContractWatcherConfig, ParsedArkContract, DefaultContractParams, DelegateContractParams, VHTLCContractParams, MessageHandler, RequestEnvelope, ResponseEnvelope, DelegatorManager, DelegatorProvider, DelegateInfo, DelegateOptions, WalletRepository, ContractRepository, MigrationStatus, };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TransactionInput, TransactionOutput } from "@scure/btc-signer/psbt.js";
|
|
2
2
|
import { Transaction } from "../utils/transaction";
|
|
3
|
+
import { ExtendedCoin } from "../wallet";
|
|
3
4
|
/**
|
|
4
5
|
* Intent proof implementation for Bitcoin message signing.
|
|
5
6
|
*
|
|
@@ -37,7 +38,7 @@ export declare namespace Intent {
|
|
|
37
38
|
* @param outputs - Optional array of transaction outputs
|
|
38
39
|
* @returns An unsigned Intent proof transaction
|
|
39
40
|
*/
|
|
40
|
-
function create(message: string | Message,
|
|
41
|
+
function create(message: string | Message, ins: (TransactionInput | ExtendedCoin)[], outputs?: TransactionOutput[]): Proof;
|
|
41
42
|
function fee(proof: Proof): number;
|
|
42
43
|
type RegisterMessage = {
|
|
43
44
|
type: "register";
|
|
@@ -57,3 +58,16 @@ export declare namespace Intent {
|
|
|
57
58
|
type Message = RegisterMessage | DeleteMessage | GetPendingTxMessage;
|
|
58
59
|
function encodeMessage(message: Message): string;
|
|
59
60
|
}
|
|
61
|
+
export declare const OP_RETURN_EMPTY_PKSCRIPT: Uint8Array<ArrayBuffer>;
|
|
62
|
+
export declare const TAG_INTENT_PROOF = "ark-intent-proof-message";
|
|
63
|
+
/**
|
|
64
|
+
* Creates the "to_spend" transaction used by both intent proofs and BIP-322.
|
|
65
|
+
*
|
|
66
|
+
* The message is hashed with the given tagged-hash tag before being placed
|
|
67
|
+
* into the scriptSig as `OP_0 <hash>`.
|
|
68
|
+
*
|
|
69
|
+
* @param message - The message to embed
|
|
70
|
+
* @param pkScript - The scriptPubKey of the signer's address
|
|
71
|
+
* @param tag - Tagged-hash tag (defaults to the Ark intent proof tag)
|
|
72
|
+
*/
|
|
73
|
+
export declare function craftToSpendTx(message: string, pkScript: Uint8Array, tag?: string): Transaction;
|
|
@@ -15,7 +15,8 @@ export declare enum SettlementEventType {
|
|
|
15
15
|
TreeSigningStarted = "tree_signing_started",
|
|
16
16
|
TreeNonces = "tree_nonces",
|
|
17
17
|
TreeTx = "tree_tx",
|
|
18
|
-
TreeSignature = "tree_signature"
|
|
18
|
+
TreeSignature = "tree_signature",
|
|
19
|
+
StreamStarted = "stream_started"
|
|
19
20
|
}
|
|
20
21
|
export type BatchFinalizationEvent = {
|
|
21
22
|
type: SettlementEventType.BatchFinalization;
|
|
@@ -66,7 +67,11 @@ export type TreeSignatureEvent = {
|
|
|
66
67
|
txid: string;
|
|
67
68
|
signature: string;
|
|
68
69
|
};
|
|
69
|
-
export type
|
|
70
|
+
export type StreamStartedEvent = {
|
|
71
|
+
type: SettlementEventType.StreamStarted;
|
|
72
|
+
id: string;
|
|
73
|
+
};
|
|
74
|
+
export type SettlementEvent = BatchFinalizationEvent | BatchFinalizedEvent | BatchFailedEvent | TreeSigningStartedEvent | TreeNoncesEvent | BatchStartedEvent | TreeTxEvent | TreeSignatureEvent | StreamStartedEvent;
|
|
70
75
|
export interface ScheduledSession {
|
|
71
76
|
duration: bigint;
|
|
72
77
|
fees: FeeInfo;
|
|
@@ -229,6 +234,9 @@ declare namespace ProtoTypes {
|
|
|
229
234
|
txid: string;
|
|
230
235
|
signature: string;
|
|
231
236
|
}
|
|
237
|
+
interface StreamStartedEvent {
|
|
238
|
+
id: string;
|
|
239
|
+
}
|
|
232
240
|
interface Heartbeat {
|
|
233
241
|
}
|
|
234
242
|
export interface VtxoData {
|
|
@@ -259,6 +267,7 @@ declare namespace ProtoTypes {
|
|
|
259
267
|
treeNonces?: TreeNoncesEvent;
|
|
260
268
|
treeTx?: TreeTxEvent;
|
|
261
269
|
treeSignature?: TreeSignatureEvent;
|
|
270
|
+
streamStarted?: StreamStartedEvent;
|
|
262
271
|
heartbeat?: Heartbeat;
|
|
263
272
|
}
|
|
264
273
|
export interface GetTransactionsStreamResponse {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Intent } from "../intent";
|
|
2
|
+
import { SignedIntent } from "./ark";
|
|
3
|
+
export interface DelegateInfo {
|
|
4
|
+
pubkey: string;
|
|
5
|
+
fee: string;
|
|
6
|
+
delegatorAddress: string;
|
|
7
|
+
}
|
|
8
|
+
export interface DelegateOptions {
|
|
9
|
+
rejectReplace?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface DelegatorProvider {
|
|
12
|
+
delegate(intent: SignedIntent<Intent.RegisterMessage>, forfeitTxs: string[], options?: DelegateOptions): Promise<void>;
|
|
13
|
+
getDelegateInfo(): Promise<DelegateInfo>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* REST-based Delegator provider implementation.
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const provider = new RestDelegatorProvider('https://delegator.example.com');
|
|
20
|
+
* const info = await provider.getDelegateInfo();
|
|
21
|
+
* await provider.delegate(intent, forfeitTxs);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare class RestDelegatorProvider implements DelegatorProvider {
|
|
25
|
+
url: string;
|
|
26
|
+
constructor(url: string);
|
|
27
|
+
delegate(intent: SignedIntent<Intent.RegisterMessage>, forfeitTxs: string[], options?: DelegateOptions): Promise<void>;
|
|
28
|
+
getDelegateInfo(): Promise<DelegateInfo>;
|
|
29
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Outpoint, VirtualCoin } from "../wallet";
|
|
1
|
+
import { AssetDetails, Outpoint, VirtualCoin } from "../wallet";
|
|
2
2
|
export type PaginationOptions = {
|
|
3
3
|
pageIndex?: number;
|
|
4
4
|
pageSize?: number;
|
|
@@ -16,8 +16,11 @@ export declare enum ChainTxType {
|
|
|
16
16
|
CHECKPOINT = "INDEXER_CHAINED_TX_TYPE_CHECKPOINT"
|
|
17
17
|
}
|
|
18
18
|
export interface PageResponse {
|
|
19
|
+
/** Current page index **/
|
|
19
20
|
current: number;
|
|
21
|
+
/** Next page index **/
|
|
20
22
|
next: number;
|
|
23
|
+
/** Total pages given the page-size used in the query **/
|
|
21
24
|
total: number;
|
|
22
25
|
}
|
|
23
26
|
export interface BatchInfo {
|
|
@@ -56,6 +59,10 @@ export interface TxHistoryRecord {
|
|
|
56
59
|
isSettled: boolean;
|
|
57
60
|
settledBy: string;
|
|
58
61
|
}
|
|
62
|
+
export interface VtxoAsset {
|
|
63
|
+
assetId: string;
|
|
64
|
+
amount: string;
|
|
65
|
+
}
|
|
59
66
|
export interface Vtxo {
|
|
60
67
|
outpoint: Outpoint;
|
|
61
68
|
createdAt: string;
|
|
@@ -70,6 +77,7 @@ export interface Vtxo {
|
|
|
70
77
|
commitmentTxids: string[];
|
|
71
78
|
settledBy?: string;
|
|
72
79
|
arkTxid?: string;
|
|
80
|
+
assets?: VtxoAsset[];
|
|
73
81
|
}
|
|
74
82
|
export interface VtxoChain {
|
|
75
83
|
chain: ChainTx[];
|
|
@@ -130,6 +138,7 @@ export interface IndexerProvider {
|
|
|
130
138
|
vtxos: VirtualCoin[];
|
|
131
139
|
page?: PageResponse;
|
|
132
140
|
}>;
|
|
141
|
+
getAssetDetails(assetId: string): Promise<AssetDetails>;
|
|
133
142
|
subscribeForScripts(scripts: string[], subscriptionId?: string): Promise<string>;
|
|
134
143
|
unsubscribeForScripts(subscriptionId: string, scripts?: string[]): Promise<void>;
|
|
135
144
|
}
|
|
@@ -181,6 +190,7 @@ export declare class RestIndexerProvider implements IndexerProvider {
|
|
|
181
190
|
vtxos: VirtualCoin[];
|
|
182
191
|
page?: PageResponse;
|
|
183
192
|
}>;
|
|
193
|
+
getAssetDetails(assetId: string): Promise<AssetDetails>;
|
|
184
194
|
subscribeForScripts(scripts: string[], subscriptionId?: string): Promise<string>;
|
|
185
195
|
unsubscribeForScripts(subscriptionId: string, scripts?: string[]): Promise<void>;
|
|
186
196
|
}
|
|
@@ -1,21 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { Contract, ContractState } from "../contracts/types";
|
|
2
|
+
/**
|
|
3
|
+
* Filter options for querying contracts.
|
|
4
|
+
*/
|
|
5
|
+
export interface ContractFilter {
|
|
6
|
+
/** Filter by script(s) */
|
|
7
|
+
script?: string | string[];
|
|
8
|
+
/** Filter by state(s) */
|
|
9
|
+
state?: ContractState | ContractState[];
|
|
10
|
+
/** Filter by contract type(s) */
|
|
11
|
+
type?: string | string[];
|
|
10
12
|
}
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
export interface ContractRepository extends AsyncDisposable {
|
|
14
|
+
readonly version: 1;
|
|
15
|
+
/**
|
|
16
|
+
* Clear all data from storage.
|
|
17
|
+
*/
|
|
18
|
+
clear(): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Get contracts with optional filter.
|
|
21
|
+
* Returns all contracts if no filter provided.
|
|
22
|
+
*/
|
|
23
|
+
getContracts(filter?: ContractFilter): Promise<Contract[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Save or update a contract.
|
|
26
|
+
*/
|
|
27
|
+
saveContract(contract: Contract): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Delete a contract by script.
|
|
30
|
+
*/
|
|
31
|
+
deleteContract(script: string): Promise<void>;
|
|
21
32
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ContractFilter, ContractRepository } from "../contractRepository";
|
|
2
|
+
import { Contract } from "../../contracts";
|
|
3
|
+
/**
|
|
4
|
+
* In-memory implementation of ContractRepository.
|
|
5
|
+
* Data is ephemeral and scoped to the instance.
|
|
6
|
+
*/
|
|
7
|
+
export declare class InMemoryContractRepository implements ContractRepository {
|
|
8
|
+
readonly version: 1;
|
|
9
|
+
private readonly contractData;
|
|
10
|
+
private readonly collections;
|
|
11
|
+
private readonly contractsByScript;
|
|
12
|
+
clear(): Promise<void>;
|
|
13
|
+
getContracts(filter?: ContractFilter): Promise<Contract[]>;
|
|
14
|
+
saveContract(contract: Contract): Promise<void>;
|
|
15
|
+
deleteContract(script: string): Promise<void>;
|
|
16
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ArkTransaction, ExtendedCoin, ExtendedVirtualCoin } from "../../wallet";
|
|
2
|
+
import { WalletRepository, WalletState } from "../walletRepository";
|
|
3
|
+
/**
|
|
4
|
+
* In-memory implementation of WalletRepository.
|
|
5
|
+
* Data is ephemeral and scoped to the instance.
|
|
6
|
+
*/
|
|
7
|
+
export declare class InMemoryWalletRepository implements WalletRepository {
|
|
8
|
+
readonly version: 1;
|
|
9
|
+
private readonly vtxosByAddress;
|
|
10
|
+
private readonly utxosByAddress;
|
|
11
|
+
private readonly txsByAddress;
|
|
12
|
+
private walletState;
|
|
13
|
+
getVtxos(address: string): Promise<ExtendedVirtualCoin[]>;
|
|
14
|
+
saveVtxos(address: string, vtxos: ExtendedVirtualCoin[]): Promise<void>;
|
|
15
|
+
deleteVtxos(address: string): Promise<void>;
|
|
16
|
+
getUtxos(address: string): Promise<ExtendedCoin[]>;
|
|
17
|
+
saveUtxos(address: string, utxos: ExtendedCoin[]): Promise<void>;
|
|
18
|
+
deleteUtxos(address: string): Promise<void>;
|
|
19
|
+
getTransactionHistory(address: string): Promise<ArkTransaction[]>;
|
|
20
|
+
saveTransactions(address: string, txs: ArkTransaction[]): Promise<void>;
|
|
21
|
+
deleteTransactions(address: string): Promise<void>;
|
|
22
|
+
getWalletState(): Promise<WalletState | null>;
|
|
23
|
+
saveWalletState(state: WalletState): Promise<void>;
|
|
24
|
+
clear(): Promise<void>;
|
|
25
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
26
|
+
}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
export * from "./walletRepository";
|
|
2
2
|
export * from "./contractRepository";
|
|
3
|
+
export * from "./inMemory/walletRepository";
|
|
4
|
+
export * from "./inMemory/contractRepository";
|
|
5
|
+
export * from "./indexedDB/contractRepository";
|
|
6
|
+
export * from "./indexedDB/walletRepository";
|
|
7
|
+
export { MIGRATION_KEY, migrateWalletRepository, requiresMigration, getMigrationStatus, rollbackMigration, type MigrationStatus, } from "./migrations/fromStorageAdapter";
|
|
8
|
+
export { WalletRepositoryImpl } from "./migrations/walletRepositoryImpl";
|
|
9
|
+
export { ContractRepositoryImpl } from "./migrations/contractRepositoryImpl";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Contract } from "../../contracts";
|
|
2
|
+
import { ContractFilter, ContractRepository } from "../contractRepository";
|
|
3
|
+
/**
|
|
4
|
+
* IndexedDB-based implementation of ContractRepository.
|
|
5
|
+
*
|
|
6
|
+
* Data is stored as JSON strings in key/value stores.
|
|
7
|
+
*/
|
|
8
|
+
export declare class IndexedDBContractRepository implements ContractRepository {
|
|
9
|
+
private readonly dbName;
|
|
10
|
+
readonly version: 1;
|
|
11
|
+
private db;
|
|
12
|
+
constructor(dbName?: string);
|
|
13
|
+
clear(): Promise<void>;
|
|
14
|
+
getContracts(filter?: ContractFilter): Promise<Contract[]>;
|
|
15
|
+
saveContract(contract: Contract): Promise<void>;
|
|
16
|
+
deleteContract(script: string): Promise<void>;
|
|
17
|
+
private getContractsByIndexValues;
|
|
18
|
+
private applyContractFilter;
|
|
19
|
+
private getDB;
|
|
20
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { DB_VERSION, STORE_CONTRACTS, LEGACY_STORE_CONTRACT_COLLECTIONS, STORE_TRANSACTIONS, STORE_UTXOS, STORE_VTXOS, STORE_WALLET_STATE } from "./schema";
|
|
2
|
+
export { STORE_VTXOS, STORE_UTXOS, STORE_TRANSACTIONS, STORE_WALLET_STATE, STORE_CONTRACTS, LEGACY_STORE_CONTRACT_COLLECTIONS, DB_VERSION, };
|
|
3
|
+
export { serializeTapLeaf, serializeVtxo, serializeUtxo, deserializeTapLeaf, deserializeVtxo, deserializeUtxo, } from "../serialization";
|
|
4
|
+
export type { SerializedTapLeaf, SerializedVtxo, SerializedUtxo, } from "../serialization";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare function getGlobalObject(): {
|
|
2
|
+
globalObject: typeof globalThis;
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* Opens an IndexedDB database and increments the reference count.
|
|
6
|
+
* Handles global object detection and callbacks.
|
|
7
|
+
*
|
|
8
|
+
* @param dbName The name of the database to open.
|
|
9
|
+
* @param dbVersion The database version to open.
|
|
10
|
+
* @param initDatabase A function that migrates the database schema, called on `onupgradeneeded` only.
|
|
11
|
+
*
|
|
12
|
+
* @returns A promise that resolves to the database instance.
|
|
13
|
+
*/
|
|
14
|
+
export declare function openDatabase(dbName: string, dbVersion: number, initDatabase: (db: IDBDatabase) => void): Promise<IDBDatabase>;
|
|
15
|
+
/**
|
|
16
|
+
* Decrements the reference count and closes the database when no references remain.
|
|
17
|
+
*
|
|
18
|
+
* @param dbName The name of the database to close.
|
|
19
|
+
*
|
|
20
|
+
* @returns True if the database was closed, false otherwise.
|
|
21
|
+
*/
|
|
22
|
+
export declare function closeDatabase(dbName: string): Promise<boolean>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const STORE_VTXOS = "vtxos";
|
|
2
|
+
export declare const STORE_UTXOS = "utxos";
|
|
3
|
+
export declare const STORE_TRANSACTIONS = "transactions";
|
|
4
|
+
export declare const STORE_WALLET_STATE = "walletState";
|
|
5
|
+
export declare const STORE_CONTRACTS = "contracts";
|
|
6
|
+
export declare const LEGACY_STORE_CONTRACT_COLLECTIONS = "contractsCollections";
|
|
7
|
+
export declare const DB_VERSION = 2;
|
|
8
|
+
export declare function initDatabase(db: IDBDatabase): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ExtendedCoin, ExtendedVirtualCoin, ArkTransaction } from "../../wallet";
|
|
2
|
+
import { WalletRepository, WalletState } from "../walletRepository";
|
|
3
|
+
/**
|
|
4
|
+
* IndexedDB-based implementation of WalletRepository.
|
|
5
|
+
*/
|
|
6
|
+
export declare class IndexedDBWalletRepository implements WalletRepository {
|
|
7
|
+
private readonly dbName;
|
|
8
|
+
readonly version: 1;
|
|
9
|
+
private db;
|
|
10
|
+
constructor(dbName?: string);
|
|
11
|
+
clear(): Promise<void>;
|
|
12
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
13
|
+
getVtxos(address: string): Promise<ExtendedVirtualCoin[]>;
|
|
14
|
+
saveVtxos(address: string, vtxos: ExtendedVirtualCoin[]): Promise<void>;
|
|
15
|
+
deleteVtxos(address: string): Promise<void>;
|
|
16
|
+
getUtxos(address: string): Promise<ExtendedCoin[]>;
|
|
17
|
+
saveUtxos(address: string, utxos: ExtendedCoin[]): Promise<void>;
|
|
18
|
+
deleteUtxos(address: string): Promise<void>;
|
|
19
|
+
getTransactionHistory(address: string): Promise<ArkTransaction[]>;
|
|
20
|
+
saveTransactions(address: string, txs: ArkTransaction[]): Promise<void>;
|
|
21
|
+
deleteTransactions(address: string): Promise<void>;
|
|
22
|
+
getWalletState(): Promise<WalletState | null>;
|
|
23
|
+
saveWalletState(state: WalletState): Promise<void>;
|
|
24
|
+
private getDB;
|
|
25
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebSQL adapter over expo-sqlite.
|
|
3
|
+
*
|
|
4
|
+
* Bridges the WebSQL API surface that indexeddbshim expects to the
|
|
5
|
+
* synchronous expo-sqlite driver. Only the subset actually called by
|
|
6
|
+
* the shim is implemented:
|
|
7
|
+
*
|
|
8
|
+
* openDatabase(name, version, displayName, estimatedSize) → WebSQLDatabase
|
|
9
|
+
* db.transaction(cb, errCb?, successCb?)
|
|
10
|
+
* tx.executeSql(sql, args?, successCb?, errorCb?)
|
|
11
|
+
* resultSet = { insertId, rowsAffected, rows: { length, item(i) } }
|
|
12
|
+
*/
|
|
13
|
+
import { type SQLiteDatabase } from "expo-sqlite";
|
|
14
|
+
export interface SQLResultSetRowList {
|
|
15
|
+
length: number;
|
|
16
|
+
item(index: number): any;
|
|
17
|
+
}
|
|
18
|
+
export interface SQLResultSet {
|
|
19
|
+
insertId: number;
|
|
20
|
+
rowsAffected: number;
|
|
21
|
+
rows: SQLResultSetRowList;
|
|
22
|
+
}
|
|
23
|
+
export interface SQLError {
|
|
24
|
+
code: number;
|
|
25
|
+
message: string;
|
|
26
|
+
}
|
|
27
|
+
type ExecuteSqlSuccessCb = (tx: WebSQLTransaction, resultSet: SQLResultSet) => void;
|
|
28
|
+
type ExecuteSqlErrorCb = (tx: WebSQLTransaction, error: SQLError) => boolean | void;
|
|
29
|
+
interface QueuedStatement {
|
|
30
|
+
sql: string;
|
|
31
|
+
args: any[];
|
|
32
|
+
successCb?: ExecuteSqlSuccessCb;
|
|
33
|
+
errorCb?: ExecuteSqlErrorCb;
|
|
34
|
+
}
|
|
35
|
+
export declare class WebSQLTransaction {
|
|
36
|
+
/** @internal */
|
|
37
|
+
_queue: QueuedStatement[];
|
|
38
|
+
executeSql(sql: string, args?: any[], successCb?: ExecuteSqlSuccessCb, errorCb?: ExecuteSqlErrorCb): void;
|
|
39
|
+
}
|
|
40
|
+
export declare class WebSQLDatabase {
|
|
41
|
+
/** @internal */
|
|
42
|
+
_db: SQLiteDatabase;
|
|
43
|
+
version: string;
|
|
44
|
+
constructor(db: SQLiteDatabase, version: string);
|
|
45
|
+
transaction(callback: (tx: WebSQLTransaction) => void, errorCb?: (error: SQLError) => void, successCb?: () => void): void;
|
|
46
|
+
readTransaction(callback: (tx: WebSQLTransaction) => void, errorCb?: (error: SQLError) => void, successCb?: () => void): void;
|
|
47
|
+
}
|
|
48
|
+
export declare function openDatabase(name: string, version: string, _displayName: string, _estimatedSize: number, _creationCallback?: (db: WebSQLDatabase) => void): WebSQLDatabase;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { StorageAdapter } from "../../storage";
|
|
2
|
+
import { ContractFilter, ContractRepository } from "../contractRepository";
|
|
3
|
+
import { Contract } from "../../contracts/types";
|
|
4
|
+
export declare const getContractStorageKey: (id: string, key: string) => string;
|
|
5
|
+
export declare const getCollectionStorageKey: (type: string) => string;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated This is only to be used in migration from storage V1
|
|
8
|
+
*/
|
|
9
|
+
export declare class ContractRepositoryImpl implements ContractRepository {
|
|
10
|
+
readonly version: 1;
|
|
11
|
+
private storage;
|
|
12
|
+
constructor(storage: StorageAdapter);
|
|
13
|
+
getContractData<T>(contractId: string, key: string): Promise<T | null>;
|
|
14
|
+
setContractData<T>(contractId: string, key: string, data: T): Promise<void>;
|
|
15
|
+
deleteContractData(contractId: string, key: string): Promise<void>;
|
|
16
|
+
getContractCollection<T>(contractType: string): Promise<ReadonlyArray<T>>;
|
|
17
|
+
saveToContractCollection<T, K extends keyof T>(contractType: string, item: T, idField: K): Promise<void>;
|
|
18
|
+
removeFromContractCollection<T, K extends keyof T>(contractType: string, id: T[K], idField: K): Promise<void>;
|
|
19
|
+
getContracts(_?: ContractFilter): Promise<Contract[]>;
|
|
20
|
+
saveContract(_: Contract): Promise<void>;
|
|
21
|
+
deleteContract(_: string): Promise<void>;
|
|
22
|
+
clear(): Promise<void>;
|
|
23
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
24
|
+
}
|