Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import {
ReadonlyWallet,
waitForIncomingFunds,
IncomingFunds,
MissingSigningDescriptorError,
} from "./wallet/wallet";
import { TxTree, TxTreeNode } from "./tree/txTree";
import {
Expand All @@ -96,7 +97,10 @@ import {
ServiceWorkerReadonlyWallet,
DEFAULT_MESSAGE_TIMEOUTS,
} from "./wallet/serviceWorker/wallet";
import type { MessageTimeouts } from "./wallet/serviceWorker/wallet";
import type {
MessageTimeouts,
ServiceWorkerWalletMode,
} from "./wallet/serviceWorker/wallet";
import { OnchainWallet } from "./wallet/onchain";
import { setupServiceWorker } from "./worker/browser/utils";
import {
Expand Down Expand Up @@ -401,6 +405,7 @@ export {
// Errors
ArkError,
maybeArkError,
MissingSigningDescriptorError,

// Batch session
Batch,
Expand Down Expand Up @@ -575,6 +580,7 @@ export type {
RequestEnvelope,
ResponseEnvelope,
MessageTimeouts,
ServiceWorkerWalletMode,

// Delegator types
IDelegatorManager,
Expand Down
12 changes: 12 additions & 0 deletions src/wallet/serviceWorker/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ type RequestType = WalletUpdaterRequest["type"];

export type MessageTimeouts = Partial<Record<RequestType, number>>;

export type ServiceWorkerWalletMode = "auto" | "static" | "hd";

export const DEFAULT_MESSAGE_TIMEOUTS: Readonly<Record<RequestType, number>> = {
// Fast reads — fail quickly
GET_ADDRESS: 10_000,
Expand Down Expand Up @@ -356,6 +358,14 @@ interface ServiceWorkerWalletOptions {
messageBusTimeoutMs?: number;
/** Optional settlement configuration forwarded to the worker wallet. */
settlementConfig?: SettlementConfig | false;
/**
* Receive-address strategy forwarded to the worker wallet.
*
* Service workers can only receive serializable configuration, so the
* descriptor-provider object form accepted by `Wallet.create()` is not
* supported here.
*/
walletMode?: ServiceWorkerWalletMode;
/** Optional contract watcher configuration forwarded to the worker wallet. */
watcherConfig?: Partial<Omit<ContractWatcherConfig, "indexerProvider">>;
/**
Expand Down Expand Up @@ -400,6 +410,7 @@ type MessageBusInitConfig = {
esploraUrl?: string;
timeoutMs?: number;
settlementConfig?: SettlementConfig | false;
walletMode?: ServiceWorkerWalletMode;
watcherConfig?: Partial<Omit<ContractWatcherConfig, "indexerProvider">>;
messageTimeouts?: Record<string, number>;
};
Expand Down Expand Up @@ -1428,6 +1439,7 @@ export class ServiceWorkerWallet
indexerUrl: options.indexerUrl,
esploraUrl: options.esploraUrl,
settlementConfig: options.settlementConfig,
walletMode: options.walletMode,
watcherConfig: options.watcherConfig,
messageTimeouts,
};
Expand Down
Loading