@arkade-os/sdk 0.3.12 → 0.4.0-next.0
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 +483 -54
- package/dist/cjs/adapters/expo-db.js +35 -0
- 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/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/db/manager.js +97 -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 +70 -14
- package/dist/cjs/intent/index.js +28 -2
- 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/onchain.js +2 -2
- 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 +57 -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/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/utils/txSizeEstimator.js +39 -14
- 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/onchain.js +57 -12
- package/dist/cjs/wallet/serviceWorker/wallet-message-handler.js +568 -0
- package/dist/cjs/wallet/serviceWorker/wallet.js +383 -102
- package/dist/cjs/wallet/unroll.js +7 -2
- package/dist/cjs/wallet/utils.js +60 -0
- package/dist/cjs/wallet/validation.js +151 -0
- package/dist/cjs/wallet/vtxo-manager.js +1 -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/adapters/expo-db.js +27 -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/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/db/manager.js +92 -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 +25 -15
- package/dist/esm/intent/index.js +28 -2
- 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/onchain.js +2 -2
- 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 +42 -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/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/utils/txSizeEstimator.js +39 -14
- 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/onchain.js +57 -12
- package/dist/esm/wallet/serviceWorker/wallet-message-handler.js +564 -0
- package/dist/esm/wallet/serviceWorker/wallet.js +382 -101
- package/dist/esm/wallet/unroll.js +7 -2
- package/dist/esm/wallet/utils.js +55 -0
- package/dist/esm/wallet/validation.js +139 -0
- package/dist/esm/wallet/vtxo-manager.js +1 -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/adapters/expo-db.d.ts +7 -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/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/db/manager.d.ts +22 -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 +21 -12
- package/dist/types/intent/index.d.ts +2 -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 +56 -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/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/utils/txSizeEstimator.d.ts +12 -2
- 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/onchain.d.ts +22 -1
- 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 +13 -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 +71 -17
- 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
|
@@ -3,10 +3,13 @@ import { ArkProvider, Output, SettlementEvent } from "../providers/ark";
|
|
|
3
3
|
import { Identity, ReadonlyIdentity } from "../identity";
|
|
4
4
|
import { RelativeTimelock } from "../script/tapscript";
|
|
5
5
|
import { EncodedVtxoScript, TapLeafScript } from "../script/base";
|
|
6
|
-
import { StorageAdapter } from "../storage";
|
|
7
6
|
import { RenewalConfig } from "./vtxo-manager";
|
|
8
7
|
import { IndexerProvider } from "../providers/indexer";
|
|
9
8
|
import { OnchainProvider } from "../providers/onchain";
|
|
9
|
+
import { ContractWatcherConfig } from "../contracts/contractWatcher";
|
|
10
|
+
import { ContractRepository, WalletRepository } from "../repositories";
|
|
11
|
+
import { IContractManager } from "../contracts/contractManager";
|
|
12
|
+
import { DelegatorProvider } from "../providers/delegator";
|
|
10
13
|
/**
|
|
11
14
|
* Base configuration options shared by all wallet types.
|
|
12
15
|
*
|
|
@@ -28,10 +31,11 @@ export interface BaseWalletConfig {
|
|
|
28
31
|
arkServerPublicKey?: string;
|
|
29
32
|
boardingTimelock?: RelativeTimelock;
|
|
30
33
|
exitTimelock?: RelativeTimelock;
|
|
31
|
-
storage?:
|
|
34
|
+
storage?: StorageConfig;
|
|
32
35
|
arkProvider?: ArkProvider;
|
|
33
36
|
indexerProvider?: IndexerProvider;
|
|
34
37
|
onchainProvider?: OnchainProvider;
|
|
38
|
+
delegatorProvider?: DelegatorProvider;
|
|
35
39
|
}
|
|
36
40
|
/**
|
|
37
41
|
* Configuration options for readonly wallet initialization.
|
|
@@ -62,6 +66,11 @@ export interface BaseWalletConfig {
|
|
|
62
66
|
*/
|
|
63
67
|
export interface ReadonlyWalletConfig extends BaseWalletConfig {
|
|
64
68
|
identity: ReadonlyIdentity;
|
|
69
|
+
/**
|
|
70
|
+
* Configuration for the ContractManager's watcher.
|
|
71
|
+
* Controls reconnection behavior and failsafe polling.
|
|
72
|
+
*/
|
|
73
|
+
watcherConfig?: Partial<Omit<ContractWatcherConfig, "indexerProvider">>;
|
|
65
74
|
}
|
|
66
75
|
/**
|
|
67
76
|
* Configuration options for full wallet initialization.
|
|
@@ -101,6 +110,10 @@ export interface WalletConfig extends ReadonlyWalletConfig {
|
|
|
101
110
|
identity: Identity;
|
|
102
111
|
renewalConfig?: RenewalConfig;
|
|
103
112
|
}
|
|
113
|
+
export type StorageConfig = {
|
|
114
|
+
walletRepository: WalletRepository;
|
|
115
|
+
contractRepository: ContractRepository;
|
|
116
|
+
};
|
|
104
117
|
/**
|
|
105
118
|
* Provider class constructor interface for dependency injection.
|
|
106
119
|
* Ensures provider classes follow the consistent constructor pattern.
|
|
@@ -119,6 +132,7 @@ export interface WalletBalance {
|
|
|
119
132
|
available: number;
|
|
120
133
|
recoverable: number;
|
|
121
134
|
total: number;
|
|
135
|
+
assets: Asset[];
|
|
122
136
|
}
|
|
123
137
|
export interface SendBitcoinParams {
|
|
124
138
|
address: string;
|
|
@@ -127,8 +141,43 @@ export interface SendBitcoinParams {
|
|
|
127
141
|
memo?: string;
|
|
128
142
|
selectedVtxos?: VirtualCoin[];
|
|
129
143
|
}
|
|
144
|
+
export interface Asset {
|
|
145
|
+
assetId: string;
|
|
146
|
+
amount: number;
|
|
147
|
+
}
|
|
130
148
|
export interface Recipient {
|
|
131
149
|
address: string;
|
|
150
|
+
amount?: number;
|
|
151
|
+
assets?: Asset[];
|
|
152
|
+
}
|
|
153
|
+
export type KnownMetadata = Partial<{
|
|
154
|
+
name: string;
|
|
155
|
+
ticker: string;
|
|
156
|
+
decimals: number;
|
|
157
|
+
icon: string;
|
|
158
|
+
}>;
|
|
159
|
+
export type AssetMetadata = KnownMetadata & Record<string, unknown>;
|
|
160
|
+
export type AssetDetails = {
|
|
161
|
+
assetId: string;
|
|
162
|
+
supply: number;
|
|
163
|
+
metadata?: AssetMetadata;
|
|
164
|
+
controlAssetId?: string;
|
|
165
|
+
};
|
|
166
|
+
export interface IssuanceParams {
|
|
167
|
+
amount: number;
|
|
168
|
+
controlAssetId?: string;
|
|
169
|
+
metadata?: AssetMetadata;
|
|
170
|
+
}
|
|
171
|
+
export interface IssuanceResult {
|
|
172
|
+
arkTxId: string;
|
|
173
|
+
assetId: string;
|
|
174
|
+
}
|
|
175
|
+
export interface ReissuanceParams {
|
|
176
|
+
assetId: string;
|
|
177
|
+
amount: number;
|
|
178
|
+
}
|
|
179
|
+
export interface BurnParams {
|
|
180
|
+
assetId: string;
|
|
132
181
|
amount: number;
|
|
133
182
|
}
|
|
134
183
|
export interface SettleParams {
|
|
@@ -163,6 +212,7 @@ export interface VirtualCoin extends Coin {
|
|
|
163
212
|
createdAt: Date;
|
|
164
213
|
isUnrolled: boolean;
|
|
165
214
|
isSpent?: boolean;
|
|
215
|
+
assets?: Asset[];
|
|
166
216
|
}
|
|
167
217
|
export declare enum TxType {
|
|
168
218
|
TxSent = "SENT",
|
|
@@ -179,6 +229,7 @@ export interface ArkTransaction {
|
|
|
179
229
|
amount: number;
|
|
180
230
|
settled: boolean;
|
|
181
231
|
createdAt: number;
|
|
232
|
+
assets?: Asset[];
|
|
182
233
|
}
|
|
183
234
|
export type TapLeaves = {
|
|
184
235
|
forfeitTapLeafScript: TapLeafScript;
|
|
@@ -198,6 +249,20 @@ export type GetVtxosFilter = {
|
|
|
198
249
|
withRecoverable?: boolean;
|
|
199
250
|
withUnrolled?: boolean;
|
|
200
251
|
};
|
|
252
|
+
/**
|
|
253
|
+
* Readonly asset manager interface for asset operations that do not require wallet identity.
|
|
254
|
+
*/
|
|
255
|
+
export interface IReadonlyAssetManager {
|
|
256
|
+
getAssetDetails(assetId: string): Promise<AssetDetails>;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Asset manager interface for asset operations that require wallet identity.
|
|
260
|
+
*/
|
|
261
|
+
export interface IAssetManager extends IReadonlyAssetManager {
|
|
262
|
+
issue(params: IssuanceParams): Promise<IssuanceResult>;
|
|
263
|
+
reissue(params: ReissuanceParams): Promise<string>;
|
|
264
|
+
burn(params: BurnParams): Promise<string>;
|
|
265
|
+
}
|
|
201
266
|
/**
|
|
202
267
|
* Core wallet interface for Bitcoin transactions with Ark protocol support.
|
|
203
268
|
*
|
|
@@ -209,6 +274,8 @@ export interface IWallet extends IReadonlyWallet {
|
|
|
209
274
|
identity: Identity;
|
|
210
275
|
sendBitcoin(params: SendBitcoinParams): Promise<string>;
|
|
211
276
|
settle(params?: SettleParams, eventCallback?: (event: SettlementEvent) => void): Promise<string>;
|
|
277
|
+
send(...recipients: Recipient[]): Promise<string>;
|
|
278
|
+
assetManager: IAssetManager;
|
|
212
279
|
}
|
|
213
280
|
/**
|
|
214
281
|
* Readonly wallet interface for Bitcoin transactions with Ark protocol support.
|
|
@@ -225,4 +292,10 @@ export interface IReadonlyWallet {
|
|
|
225
292
|
getVtxos(filter?: GetVtxosFilter): Promise<ExtendedVirtualCoin[]>;
|
|
226
293
|
getBoardingUtxos(): Promise<ExtendedCoin[]>;
|
|
227
294
|
getTransactionHistory(): Promise<ArkTransaction[]>;
|
|
295
|
+
/**
|
|
296
|
+
* Returns the contract manager associated with this wallet.
|
|
297
|
+
* This is useful for querying contract state and watching for contract events.
|
|
298
|
+
*/
|
|
299
|
+
getContractManager(): Promise<IContractManager>;
|
|
300
|
+
assetManager: IReadonlyAssetManager;
|
|
228
301
|
}
|
|
@@ -25,7 +25,6 @@ import { Transaction } from "../utils/transaction";
|
|
|
25
25
|
export declare class OnchainWallet implements AnchorBumper {
|
|
26
26
|
private identity;
|
|
27
27
|
static MIN_FEE_RATE: number;
|
|
28
|
-
static DUST_AMOUNT: number;
|
|
29
28
|
readonly onchainP2TR: P2TR;
|
|
30
29
|
readonly provider: OnchainProvider;
|
|
31
30
|
readonly network: Network;
|
|
@@ -34,6 +33,28 @@ export declare class OnchainWallet implements AnchorBumper {
|
|
|
34
33
|
get address(): string;
|
|
35
34
|
getCoins(): Promise<Coin[]>;
|
|
36
35
|
getBalance(): Promise<number>;
|
|
36
|
+
/**
|
|
37
|
+
* Iteratively selects coins and estimates transaction fees until convergence.
|
|
38
|
+
*
|
|
39
|
+
* This method handles the circular dependency between coin selection and fee
|
|
40
|
+
* estimation: the fee depends on transaction size, which depends on the number
|
|
41
|
+
* of inputs (selected coins) and whether a change output is needed.
|
|
42
|
+
*
|
|
43
|
+
* The algorithm iterates up to 10 times, refining the fee estimate based on
|
|
44
|
+
* the actual transaction structure. It resolves dust oscillation loops that
|
|
45
|
+
* occur when the change amount hovers near the dust threshold—adding/removing
|
|
46
|
+
* the change output causes the fee to fluctuate, preventing convergence.
|
|
47
|
+
* When a lower fee is computed (indicating the change output was dropped),
|
|
48
|
+
* the function accepts this state to guarantee termination.
|
|
49
|
+
*
|
|
50
|
+
* @param coins - Available coins to select from
|
|
51
|
+
* @param amount - Target send amount in satoshis
|
|
52
|
+
* @param feeRate - Fee rate in sat/vbyte
|
|
53
|
+
* @param recipientAddress - Destination address for size estimation
|
|
54
|
+
* @returns Selected inputs, change amount, and calculated fee
|
|
55
|
+
* @throws Error if fee estimation fails to converge within max iterations
|
|
56
|
+
*/
|
|
57
|
+
private estimateFeesAndSelectCoins;
|
|
37
58
|
send(params: SendBitcoinParams): Promise<string>;
|
|
38
59
|
bumpP2A(parent: Transaction): Promise<[string, string]>;
|
|
39
60
|
}
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { SettlementEvent } from "../../providers/ark";
|
|
2
|
+
import type { Contract, ContractEvent, ContractWithVtxos, GetContractsFilter, PathSelection } from "../../contracts";
|
|
3
|
+
import type { CreateContractParams, GetAllSpendingPathsOptions, GetSpendablePathsOptions } from "../../contracts/contractManager";
|
|
4
|
+
import { ArkTransaction, AssetDetails, BurnParams, ExtendedCoin, GetVtxosFilter, IssuanceParams, IssuanceResult, IWallet, Recipient, ReissuanceParams, SendBitcoinParams, SettleParams, WalletBalance } from "../index";
|
|
5
|
+
import { MessageHandler, RequestEnvelope, ResponseEnvelope } from "../../worker/messageBus";
|
|
6
|
+
import { Transaction } from "../../utils/transaction";
|
|
7
|
+
export declare const DEFAULT_MESSAGE_TAG = "WALLET_UPDATER";
|
|
8
|
+
export type RequestInitWallet = RequestEnvelope & {
|
|
9
|
+
type: "INIT_WALLET";
|
|
10
|
+
payload: {
|
|
11
|
+
key: {
|
|
12
|
+
privateKey: string;
|
|
13
|
+
} | {
|
|
14
|
+
publicKey: string;
|
|
15
|
+
};
|
|
16
|
+
arkServerUrl: string;
|
|
17
|
+
arkServerPublicKey?: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export type ResponseInitWallet = ResponseEnvelope & {
|
|
21
|
+
type: "WALLET_INITIALIZED";
|
|
22
|
+
};
|
|
23
|
+
export type RequestSettle = RequestEnvelope & {
|
|
24
|
+
type: "SETTLE";
|
|
25
|
+
payload: {
|
|
26
|
+
params?: SettleParams;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export type ResponseSettle = ResponseEnvelope & {
|
|
30
|
+
type: "SETTLE_SUCCESS";
|
|
31
|
+
payload: {
|
|
32
|
+
txid: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export type RequestSendBitcoin = RequestEnvelope & {
|
|
36
|
+
type: "SEND_BITCOIN";
|
|
37
|
+
payload: SendBitcoinParams;
|
|
38
|
+
};
|
|
39
|
+
export type ResponseSendBitcoin = ResponseEnvelope & {
|
|
40
|
+
type: "SEND_BITCOIN_SUCCESS";
|
|
41
|
+
payload: {
|
|
42
|
+
txid: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export type RequestGetAddress = RequestEnvelope & {
|
|
46
|
+
type: "GET_ADDRESS";
|
|
47
|
+
};
|
|
48
|
+
export type ResponseGetAddress = ResponseEnvelope & {
|
|
49
|
+
type: "ADDRESS";
|
|
50
|
+
payload: {
|
|
51
|
+
address: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
export type RequestGetBoardingAddress = RequestEnvelope & {
|
|
55
|
+
type: "GET_BOARDING_ADDRESS";
|
|
56
|
+
};
|
|
57
|
+
export type ResponseGetBoardingAddress = ResponseEnvelope & {
|
|
58
|
+
type: "BOARDING_ADDRESS";
|
|
59
|
+
payload: {
|
|
60
|
+
address: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export type RequestGetBalance = RequestEnvelope & {
|
|
64
|
+
type: "GET_BALANCE";
|
|
65
|
+
};
|
|
66
|
+
export type ResponseGetBalance = ResponseEnvelope & {
|
|
67
|
+
type: "BALANCE";
|
|
68
|
+
payload: WalletBalance;
|
|
69
|
+
};
|
|
70
|
+
export type RequestGetVtxos = RequestEnvelope & {
|
|
71
|
+
type: "GET_VTXOS";
|
|
72
|
+
payload: {
|
|
73
|
+
filter?: GetVtxosFilter;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
export type ResponseGetVtxos = ResponseEnvelope & {
|
|
77
|
+
type: "VTXOS";
|
|
78
|
+
payload: {
|
|
79
|
+
vtxos: Awaited<ReturnType<IWallet["getVtxos"]>>;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
export type RequestGetBoardingUtxos = RequestEnvelope & {
|
|
83
|
+
type: "GET_BOARDING_UTXOS";
|
|
84
|
+
};
|
|
85
|
+
export type ResponseGetBoardingUtxos = ResponseEnvelope & {
|
|
86
|
+
type: "BOARDING_UTXOS";
|
|
87
|
+
payload: {
|
|
88
|
+
utxos: ExtendedCoin[];
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
export type RequestGetTransactionHistory = RequestEnvelope & {
|
|
92
|
+
type: "GET_TRANSACTION_HISTORY";
|
|
93
|
+
};
|
|
94
|
+
export type ResponseGetTransactionHistory = ResponseEnvelope & {
|
|
95
|
+
type: "TRANSACTION_HISTORY";
|
|
96
|
+
payload: {
|
|
97
|
+
transactions: ArkTransaction[];
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
export type RequestGetStatus = RequestEnvelope & {
|
|
101
|
+
type: "GET_STATUS";
|
|
102
|
+
};
|
|
103
|
+
export type ResponseGetStatus = ResponseEnvelope & {
|
|
104
|
+
type: "WALLET_STATUS";
|
|
105
|
+
payload: {
|
|
106
|
+
walletInitialized: boolean;
|
|
107
|
+
xOnlyPublicKey: Uint8Array | undefined;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
export type RequestClear = RequestEnvelope & {
|
|
111
|
+
type: "CLEAR";
|
|
112
|
+
};
|
|
113
|
+
export type ResponseClear = ResponseEnvelope & {
|
|
114
|
+
type: "CLEAR_SUCCESS";
|
|
115
|
+
payload: {
|
|
116
|
+
cleared: boolean;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
export type RequestSignTransaction = RequestEnvelope & {
|
|
120
|
+
type: "SIGN_TRANSACTION";
|
|
121
|
+
payload: {
|
|
122
|
+
tx: Transaction;
|
|
123
|
+
inputIndexes?: number[];
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
export type ResponseSignTransaction = ResponseEnvelope & {
|
|
127
|
+
type: "SIGN_TRANSACTION";
|
|
128
|
+
payload: {
|
|
129
|
+
tx: Transaction;
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
export type RequestReloadWallet = RequestEnvelope & {
|
|
133
|
+
type: "RELOAD_WALLET";
|
|
134
|
+
};
|
|
135
|
+
export type ResponseReloadWallet = ResponseEnvelope & {
|
|
136
|
+
type: "RELOAD_SUCCESS";
|
|
137
|
+
payload: {
|
|
138
|
+
reloaded: boolean;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
export type RequestCreateContract = RequestEnvelope & {
|
|
142
|
+
type: "CREATE_CONTRACT";
|
|
143
|
+
payload: CreateContractParams;
|
|
144
|
+
};
|
|
145
|
+
export type ResponseCreateContract = ResponseEnvelope & {
|
|
146
|
+
type: "CONTRACT_CREATED";
|
|
147
|
+
payload: {
|
|
148
|
+
contract: Contract;
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
export type RequestGetContracts = RequestEnvelope & {
|
|
152
|
+
type: "GET_CONTRACTS";
|
|
153
|
+
payload: {
|
|
154
|
+
filter?: GetContractsFilter;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
export type ResponseGetContracts = ResponseEnvelope & {
|
|
158
|
+
type: "CONTRACTS";
|
|
159
|
+
payload: {
|
|
160
|
+
contracts: Contract[];
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
export type RequestGetContractsWithVtxos = RequestEnvelope & {
|
|
164
|
+
type: "GET_CONTRACTS_WITH_VTXOS";
|
|
165
|
+
payload: {
|
|
166
|
+
filter?: GetContractsFilter;
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
export type ResponseGetContractsWithVtxos = ResponseEnvelope & {
|
|
170
|
+
type: "CONTRACTS_WITH_VTXOS";
|
|
171
|
+
payload: {
|
|
172
|
+
contracts: ContractWithVtxos[];
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
export type RequestUpdateContract = RequestEnvelope & {
|
|
176
|
+
type: "UPDATE_CONTRACT";
|
|
177
|
+
payload: {
|
|
178
|
+
script: string;
|
|
179
|
+
updates: Partial<Omit<Contract, "id" | "createdAt">>;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
export type ResponseUpdateContract = ResponseEnvelope & {
|
|
183
|
+
type: "CONTRACT_UPDATED";
|
|
184
|
+
payload: {
|
|
185
|
+
contract: Contract;
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
export type RequestDeleteContract = RequestEnvelope & {
|
|
189
|
+
type: "DELETE_CONTRACT";
|
|
190
|
+
payload: {
|
|
191
|
+
script: string;
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
export type ResponseDeleteContract = ResponseEnvelope & {
|
|
195
|
+
type: "CONTRACT_DELETED";
|
|
196
|
+
payload: {
|
|
197
|
+
deleted: boolean;
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
export type RequestGetSpendablePaths = RequestEnvelope & {
|
|
201
|
+
type: "GET_SPENDABLE_PATHS";
|
|
202
|
+
payload: {
|
|
203
|
+
options: GetSpendablePathsOptions;
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
export type ResponseGetSpendablePaths = ResponseEnvelope & {
|
|
207
|
+
type: "SPENDABLE_PATHS";
|
|
208
|
+
payload: {
|
|
209
|
+
paths: PathSelection[];
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
export type RequestIsContractManagerWatching = RequestEnvelope & {
|
|
213
|
+
type: "IS_CONTRACT_MANAGER_WATCHING";
|
|
214
|
+
};
|
|
215
|
+
export type ResponseIsContractManagerWatching = ResponseEnvelope & {
|
|
216
|
+
type: "CONTRACT_WATCHING";
|
|
217
|
+
payload: {
|
|
218
|
+
isWatching: boolean;
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
export type RequestGetAllSpendingPaths = RequestEnvelope & {
|
|
222
|
+
type: "GET_ALL_SPENDING_PATHS";
|
|
223
|
+
payload: {
|
|
224
|
+
options: GetAllSpendingPathsOptions;
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
export type ResponseGetAllSpendingPaths = ResponseEnvelope & {
|
|
228
|
+
type: "ALL_SPENDING_PATHS";
|
|
229
|
+
payload: {
|
|
230
|
+
paths: PathSelection[];
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
export type ResponseSettleEvent = ResponseEnvelope & {
|
|
234
|
+
broadcast: true;
|
|
235
|
+
type: "SETTLE_EVENT";
|
|
236
|
+
payload: SettlementEvent;
|
|
237
|
+
};
|
|
238
|
+
export type ResponseUtxoUpdate = ResponseEnvelope & {
|
|
239
|
+
broadcast: true;
|
|
240
|
+
type: "UTXO_UPDATE";
|
|
241
|
+
payload: {
|
|
242
|
+
coins: ExtendedCoin[];
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
export type ResponseVtxoUpdate = ResponseEnvelope & {
|
|
246
|
+
broadcast: true;
|
|
247
|
+
type: "VTXO_UPDATE";
|
|
248
|
+
payload: {
|
|
249
|
+
newVtxos: ExtendedCoin[];
|
|
250
|
+
spentVtxos: ExtendedCoin[];
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
export type ResponseContractEvent = ResponseEnvelope & {
|
|
254
|
+
tag: string;
|
|
255
|
+
broadcast: true;
|
|
256
|
+
type: "CONTRACT_EVENT";
|
|
257
|
+
payload: {
|
|
258
|
+
event: ContractEvent;
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
export type RequestSend = RequestEnvelope & {
|
|
262
|
+
type: "SEND";
|
|
263
|
+
payload: {
|
|
264
|
+
recipients: Recipient[];
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
export type ResponseSend = ResponseEnvelope & {
|
|
268
|
+
type: "SEND_SUCCESS";
|
|
269
|
+
payload: {
|
|
270
|
+
txid: string;
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
export type RequestGetAssetDetails = RequestEnvelope & {
|
|
274
|
+
type: "GET_ASSET_DETAILS";
|
|
275
|
+
payload: {
|
|
276
|
+
assetId: string;
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
export type ResponseGetAssetDetails = ResponseEnvelope & {
|
|
280
|
+
type: "ASSET_DETAILS";
|
|
281
|
+
payload: {
|
|
282
|
+
assetDetails: AssetDetails;
|
|
283
|
+
};
|
|
284
|
+
};
|
|
285
|
+
export type RequestIssue = RequestEnvelope & {
|
|
286
|
+
type: "ISSUE";
|
|
287
|
+
payload: {
|
|
288
|
+
params: IssuanceParams;
|
|
289
|
+
};
|
|
290
|
+
};
|
|
291
|
+
export type ResponseIssue = ResponseEnvelope & {
|
|
292
|
+
type: "ISSUE_SUCCESS";
|
|
293
|
+
payload: {
|
|
294
|
+
result: IssuanceResult;
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
export type RequestReissue = RequestEnvelope & {
|
|
298
|
+
type: "REISSUE";
|
|
299
|
+
payload: {
|
|
300
|
+
params: ReissuanceParams;
|
|
301
|
+
};
|
|
302
|
+
};
|
|
303
|
+
export type ResponseReissue = ResponseEnvelope & {
|
|
304
|
+
type: "REISSUE_SUCCESS";
|
|
305
|
+
payload: {
|
|
306
|
+
txid: string;
|
|
307
|
+
};
|
|
308
|
+
};
|
|
309
|
+
export type RequestBurn = RequestEnvelope & {
|
|
310
|
+
type: "BURN";
|
|
311
|
+
payload: {
|
|
312
|
+
params: BurnParams;
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
export type ResponseBurn = ResponseEnvelope & {
|
|
316
|
+
type: "BURN_SUCCESS";
|
|
317
|
+
payload: {
|
|
318
|
+
txid: string;
|
|
319
|
+
};
|
|
320
|
+
};
|
|
321
|
+
export type WalletUpdaterRequest = RequestInitWallet | RequestSettle | RequestSendBitcoin | RequestGetAddress | RequestGetBoardingAddress | RequestGetBalance | RequestGetVtxos | RequestGetBoardingUtxos | RequestGetTransactionHistory | RequestGetStatus | RequestClear | RequestReloadWallet | RequestSignTransaction | RequestCreateContract | RequestGetContracts | RequestGetContractsWithVtxos | RequestUpdateContract | RequestDeleteContract | RequestGetSpendablePaths | RequestGetAllSpendingPaths | RequestIsContractManagerWatching | RequestSend | RequestGetAssetDetails | RequestIssue | RequestReissue | RequestBurn;
|
|
322
|
+
export type WalletUpdaterResponse = ResponseEnvelope & (ResponseInitWallet | ResponseSettle | ResponseSettleEvent | ResponseSendBitcoin | ResponseGetAddress | ResponseGetBoardingAddress | ResponseGetBalance | ResponseGetVtxos | ResponseGetBoardingUtxos | ResponseGetTransactionHistory | ResponseGetStatus | ResponseClear | ResponseReloadWallet | ResponseUtxoUpdate | ResponseVtxoUpdate | ResponseSignTransaction | ResponseCreateContract | ResponseGetContracts | ResponseGetContractsWithVtxos | ResponseUpdateContract | ResponseDeleteContract | ResponseGetSpendablePaths | ResponseGetAllSpendingPaths | ResponseIsContractManagerWatching | ResponseContractEvent | ResponseSend | ResponseGetAssetDetails | ResponseIssue | ResponseReissue | ResponseBurn);
|
|
323
|
+
export declare class WalletMessageHandler implements MessageHandler<WalletUpdaterRequest, WalletUpdaterResponse> {
|
|
324
|
+
readonly messageTag: string;
|
|
325
|
+
private wallet;
|
|
326
|
+
private readonlyWallet;
|
|
327
|
+
private arkProvider;
|
|
328
|
+
private indexerProvider;
|
|
329
|
+
private walletRepository;
|
|
330
|
+
private incomingFundsSubscription;
|
|
331
|
+
private contractEventsSubscription;
|
|
332
|
+
private onNextTick;
|
|
333
|
+
/**
|
|
334
|
+
* Instantiate a new WalletUpdater.
|
|
335
|
+
* Can override the default `messageTag` allowing more than one updater to run in parallel.
|
|
336
|
+
* Note that the default ServiceWorkerWallet sends messages to the default WalletUpdater tag.
|
|
337
|
+
*/
|
|
338
|
+
constructor(options?: {
|
|
339
|
+
messageTag?: string;
|
|
340
|
+
});
|
|
341
|
+
start(...params: Parameters<MessageHandler["start"]>): Promise<void>;
|
|
342
|
+
stop(): Promise<void>;
|
|
343
|
+
tick(_now: number): Promise<WalletUpdaterResponse[]>;
|
|
344
|
+
private scheduleForNextTick;
|
|
345
|
+
private requireWallet;
|
|
346
|
+
private tagged;
|
|
347
|
+
handleMessage(message: WalletUpdaterRequest): Promise<WalletUpdaterResponse>;
|
|
348
|
+
private handleInitWallet;
|
|
349
|
+
private handleGetBalance;
|
|
350
|
+
private getAllBoardingUtxos;
|
|
351
|
+
/**
|
|
352
|
+
* Get spendable vtxos for the current wallet address
|
|
353
|
+
*/
|
|
354
|
+
private getSpendableVtxos;
|
|
355
|
+
/**
|
|
356
|
+
* Get swept vtxos for the current wallet address
|
|
357
|
+
*/
|
|
358
|
+
private getSweptVtxos;
|
|
359
|
+
private onWalletInitialized;
|
|
360
|
+
private handleSettle;
|
|
361
|
+
private handleSendBitcoin;
|
|
362
|
+
private handleSignTransaction;
|
|
363
|
+
private handleGetVtxos;
|
|
364
|
+
private clear;
|
|
365
|
+
private ensureContractEventBroadcasting;
|
|
366
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { IWallet, WalletBalance, SendBitcoinParams, SettleParams, ArkTransaction, ExtendedCoin, ExtendedVirtualCoin, GetVtxosFilter, IReadonlyWallet } from "..";
|
|
2
|
-
import { Request } from "./request";
|
|
3
|
-
import { Response } from "./response";
|
|
1
|
+
import { IWallet, WalletBalance, SendBitcoinParams, SettleParams, ArkTransaction, ExtendedCoin, ExtendedVirtualCoin, GetVtxosFilter, StorageConfig, IReadonlyWallet, IReadonlyAssetManager, IAssetManager, Recipient } from "..";
|
|
4
2
|
import { SettlementEvent } from "../../providers/ark";
|
|
5
3
|
import { Identity, ReadonlyIdentity } from "../../identity";
|
|
6
4
|
import { WalletRepository } from "../../repositories/walletRepository";
|
|
7
5
|
import { ContractRepository } from "../../repositories/contractRepository";
|
|
6
|
+
import { ResponseGetStatus, WalletUpdaterRequest, WalletUpdaterResponse } from "./wallet-message-handler";
|
|
7
|
+
import type { IContractManager } from "../../contracts/contractManager";
|
|
8
8
|
type PrivateKeyIdentity = Identity & {
|
|
9
9
|
toHex(): string;
|
|
10
10
|
};
|
|
@@ -27,10 +27,10 @@ type PrivateKeyIdentity = Identity & {
|
|
|
27
27
|
* });
|
|
28
28
|
*
|
|
29
29
|
* // ADVANCED: Manual setup with service worker control
|
|
30
|
-
* const
|
|
30
|
+
* const worker = await setupServiceWorker("/service-worker.js");
|
|
31
31
|
* const identity = SingleKey.fromHex('your_private_key_hex');
|
|
32
32
|
* const wallet = await ServiceWorkerWallet.create({
|
|
33
|
-
*
|
|
33
|
+
* worker,
|
|
34
34
|
* identity,
|
|
35
35
|
* arkServerUrl: 'https://mutinynet.arkade.sh'
|
|
36
36
|
* });
|
|
@@ -44,9 +44,11 @@ interface ServiceWorkerWalletOptions {
|
|
|
44
44
|
arkServerPublicKey?: string;
|
|
45
45
|
arkServerUrl: string;
|
|
46
46
|
esploraUrl?: string;
|
|
47
|
-
|
|
48
|
-
dbVersion?: number;
|
|
47
|
+
storage?: StorageConfig;
|
|
49
48
|
identity: ReadonlyIdentity | Identity;
|
|
49
|
+
delegatorUrl?: string;
|
|
50
|
+
walletUpdaterTag?: string;
|
|
51
|
+
messageBusTimeoutMs?: number;
|
|
50
52
|
}
|
|
51
53
|
export type ServiceWorkerWalletCreateOptions = ServiceWorkerWalletOptions & {
|
|
52
54
|
serviceWorker: ServiceWorker;
|
|
@@ -56,10 +58,13 @@ export type ServiceWorkerWalletSetupOptions = ServiceWorkerWalletOptions & {
|
|
|
56
58
|
};
|
|
57
59
|
export declare class ServiceWorkerReadonlyWallet implements IReadonlyWallet {
|
|
58
60
|
readonly serviceWorker: ServiceWorker;
|
|
61
|
+
protected readonly messageTag: string;
|
|
59
62
|
readonly walletRepository: WalletRepository;
|
|
60
63
|
readonly contractRepository: ContractRepository;
|
|
61
64
|
readonly identity: ReadonlyIdentity;
|
|
62
|
-
|
|
65
|
+
private readonly _readonlyAssetManager;
|
|
66
|
+
get assetManager(): IReadonlyAssetManager;
|
|
67
|
+
protected constructor(serviceWorker: ServiceWorker, identity: ReadonlyIdentity, walletRepository: WalletRepository, contractRepository: ContractRepository, messageTag: string);
|
|
63
68
|
static create(options: ServiceWorkerWalletCreateOptions): Promise<ServiceWorkerReadonlyWallet>;
|
|
64
69
|
/**
|
|
65
70
|
* Simplified setup method that handles service worker registration,
|
|
@@ -83,23 +88,26 @@ export declare class ServiceWorkerReadonlyWallet implements IReadonlyWallet {
|
|
|
83
88
|
* ```
|
|
84
89
|
*/
|
|
85
90
|
static setup(options: ServiceWorkerWalletSetupOptions): Promise<ServiceWorkerReadonlyWallet>;
|
|
86
|
-
protected sendMessage
|
|
91
|
+
protected sendMessage(request: WalletUpdaterRequest): Promise<WalletUpdaterResponse>;
|
|
87
92
|
clear(): Promise<void>;
|
|
88
93
|
getAddress(): Promise<string>;
|
|
89
94
|
getBoardingAddress(): Promise<string>;
|
|
90
95
|
getBalance(): Promise<WalletBalance>;
|
|
91
96
|
getBoardingUtxos(): Promise<ExtendedCoin[]>;
|
|
92
|
-
getStatus(): Promise<
|
|
97
|
+
getStatus(): Promise<ResponseGetStatus["payload"]>;
|
|
93
98
|
getTransactionHistory(): Promise<ArkTransaction[]>;
|
|
94
99
|
getVtxos(filter?: GetVtxosFilter): Promise<ExtendedVirtualCoin[]>;
|
|
95
100
|
reload(): Promise<boolean>;
|
|
101
|
+
getContractManager(): Promise<IContractManager>;
|
|
96
102
|
}
|
|
97
103
|
export declare class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet implements IWallet {
|
|
98
104
|
readonly serviceWorker: ServiceWorker;
|
|
99
105
|
readonly walletRepository: WalletRepository;
|
|
100
106
|
readonly contractRepository: ContractRepository;
|
|
101
107
|
readonly identity: Identity;
|
|
102
|
-
|
|
108
|
+
private readonly _assetManager;
|
|
109
|
+
protected constructor(serviceWorker: ServiceWorker, identity: PrivateKeyIdentity, walletRepository: WalletRepository, contractRepository: ContractRepository, messageTag: string);
|
|
110
|
+
get assetManager(): IAssetManager;
|
|
103
111
|
static create(options: ServiceWorkerWalletCreateOptions): Promise<ServiceWorkerWallet>;
|
|
104
112
|
/**
|
|
105
113
|
* Simplified setup method that handles service worker registration,
|
|
@@ -125,5 +133,6 @@ export declare class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet imp
|
|
|
125
133
|
static setup(options: ServiceWorkerWalletSetupOptions): Promise<ServiceWorkerWallet>;
|
|
126
134
|
sendBitcoin(params: SendBitcoinParams): Promise<string>;
|
|
127
135
|
settle(params?: SettleParams, callback?: (event: SettlementEvent) => void): Promise<string>;
|
|
136
|
+
send(...recipients: Recipient[]): Promise<string>;
|
|
128
137
|
}
|
|
129
138
|
export {};
|
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Recipient } from ".";
|
|
2
|
+
import { type Coin, type ExtendedCoin, type ExtendedVirtualCoin, type VirtualCoin } from "..";
|
|
3
|
+
import type { Contract } from "../contracts/types";
|
|
2
4
|
import { ReadonlyWallet } from "./wallet";
|
|
5
|
+
import { Bytes } from "@scure/btc-signer/utils";
|
|
6
|
+
export declare const DUST_AMOUNT = 546;
|
|
3
7
|
export declare function extendVirtualCoin(wallet: {
|
|
4
8
|
offchainTapscript: ReadonlyWallet["offchainTapscript"];
|
|
5
9
|
}, vtxo: VirtualCoin): ExtendedVirtualCoin;
|
|
6
10
|
export declare function extendCoin(wallet: {
|
|
7
11
|
boardingTapscript: ReadonlyWallet["boardingTapscript"];
|
|
8
12
|
}, utxo: Coin): ExtendedCoin;
|
|
13
|
+
export declare function extendVtxoFromContract(vtxo: VirtualCoin, contract: Contract): ExtendedVirtualCoin;
|
|
14
|
+
export declare function getRandomId(): string;
|
|
15
|
+
export declare function isValidArkAddress(address: string): boolean;
|
|
16
|
+
type ValidatedRecipient = Required<Recipient> & {
|
|
17
|
+
script: Bytes;
|
|
18
|
+
};
|
|
19
|
+
export declare function validateRecipients(recipients: Recipient[], dustAmount: number): ValidatedRecipient[];
|
|
20
|
+
export {};
|