@arkade-os/sdk 0.4.0-next.4 → 0.4.0-next.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/wallet/delegator.js +3 -0
- package/dist/cjs/wallet/expo/wallet.js +3 -0
- package/dist/cjs/wallet/serviceWorker/wallet-message-handler.js +46 -0
- package/dist/cjs/wallet/serviceWorker/wallet.js +58 -2
- package/dist/cjs/wallet/wallet.js +10 -3
- package/dist/cjs/worker/messageBus.js +6 -0
- package/dist/esm/wallet/delegator.js +3 -0
- package/dist/esm/wallet/expo/wallet.js +3 -0
- package/dist/esm/wallet/serviceWorker/wallet-message-handler.js +46 -0
- package/dist/esm/wallet/serviceWorker/wallet.js +58 -2
- package/dist/esm/wallet/wallet.js +10 -3
- package/dist/esm/worker/messageBus.js +6 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/wallet/delegator.d.ts +5 -3
- package/dist/types/wallet/expo/wallet.d.ts +2 -0
- package/dist/types/wallet/index.d.ts +2 -0
- package/dist/types/wallet/serviceWorker/wallet-message-handler.d.ts +40 -2
- package/dist/types/wallet/serviceWorker/wallet.d.ts +4 -1
- package/dist/types/wallet/wallet.d.ts +3 -2
- package/dist/types/worker/messageBus.d.ts +1 -0
- package/package.json +1 -1
|
@@ -13,6 +13,9 @@ class DelegatorManagerImpl {
|
|
|
13
13
|
this.arkInfoProvider = arkInfoProvider;
|
|
14
14
|
this.identity = identity;
|
|
15
15
|
}
|
|
16
|
+
async getDelegateInfo() {
|
|
17
|
+
return this.delegatorProvider.getDelegateInfo();
|
|
18
|
+
}
|
|
16
19
|
async delegate(vtxos, destination, delegateAt) {
|
|
17
20
|
if (vtxos.length === 0) {
|
|
18
21
|
return { delegated: [], failed: [] };
|
|
@@ -215,6 +215,9 @@ class ExpoWallet {
|
|
|
215
215
|
getContractManager() {
|
|
216
216
|
return this.wallet.getContractManager();
|
|
217
217
|
}
|
|
218
|
+
getDelegatorManager() {
|
|
219
|
+
return this.wallet.getDelegatorManager();
|
|
220
|
+
}
|
|
218
221
|
sendBitcoin(params) {
|
|
219
222
|
return this.wallet.sendBitcoin(params);
|
|
220
223
|
}
|
|
@@ -289,6 +289,23 @@ class WalletMessageHandler {
|
|
|
289
289
|
payload: { txid },
|
|
290
290
|
});
|
|
291
291
|
}
|
|
292
|
+
case "DELEGATE": {
|
|
293
|
+
const response = await this.handleDelegate(message);
|
|
294
|
+
return this.tagged({ id, ...response });
|
|
295
|
+
}
|
|
296
|
+
case "GET_DELEGATE_INFO": {
|
|
297
|
+
const wallet = this.requireWallet();
|
|
298
|
+
const delegatorManager = await wallet.getDelegatorManager();
|
|
299
|
+
if (!delegatorManager) {
|
|
300
|
+
throw new Error("Delegator not configured");
|
|
301
|
+
}
|
|
302
|
+
const info = await delegatorManager.getDelegateInfo();
|
|
303
|
+
return this.tagged({
|
|
304
|
+
id,
|
|
305
|
+
type: "DELEGATE_INFO",
|
|
306
|
+
payload: { info },
|
|
307
|
+
});
|
|
308
|
+
}
|
|
292
309
|
default:
|
|
293
310
|
console.error("Unknown message type", message);
|
|
294
311
|
throw new Error("Unknown message");
|
|
@@ -502,6 +519,35 @@ class WalletMessageHandler {
|
|
|
502
519
|
payload: { tx: signature },
|
|
503
520
|
};
|
|
504
521
|
}
|
|
522
|
+
async handleDelegate(message) {
|
|
523
|
+
const wallet = this.requireWallet();
|
|
524
|
+
const delegatorManager = await wallet.getDelegatorManager();
|
|
525
|
+
if (!delegatorManager) {
|
|
526
|
+
throw new Error("Delegator not configured");
|
|
527
|
+
}
|
|
528
|
+
const { vtxoOutpoints, destination, delegateAt } = message.payload;
|
|
529
|
+
const allVtxos = await wallet.getVtxos();
|
|
530
|
+
const outpointSet = new Set(vtxoOutpoints.map((o) => `${o.txid}:${o.vout}`));
|
|
531
|
+
const filtered = allVtxos.filter((v) => outpointSet.has(`${v.txid}:${v.vout}`));
|
|
532
|
+
const result = await delegatorManager.delegate(filtered, destination, delegateAt !== undefined ? new Date(delegateAt) : undefined);
|
|
533
|
+
return {
|
|
534
|
+
tag: this.messageTag,
|
|
535
|
+
type: "DELEGATE_SUCCESS",
|
|
536
|
+
payload: {
|
|
537
|
+
delegated: result.delegated.map((o) => ({
|
|
538
|
+
txid: o.txid,
|
|
539
|
+
vout: o.vout,
|
|
540
|
+
})),
|
|
541
|
+
failed: result.failed.map((f) => ({
|
|
542
|
+
outpoints: f.outpoints.map((o) => ({
|
|
543
|
+
txid: o.txid,
|
|
544
|
+
vout: o.vout,
|
|
545
|
+
})),
|
|
546
|
+
error: String(f.error),
|
|
547
|
+
})),
|
|
548
|
+
},
|
|
549
|
+
};
|
|
550
|
+
}
|
|
505
551
|
async handleGetVtxos(message) {
|
|
506
552
|
if (!this.readonlyWallet) {
|
|
507
553
|
throw new Error("Wallet handler not initialized");
|
|
@@ -124,6 +124,7 @@ class ServiceWorkerReadonlyWallet {
|
|
|
124
124
|
url: initConfig.arkServerUrl,
|
|
125
125
|
publicKey: initConfig.arkServerPublicKey,
|
|
126
126
|
},
|
|
127
|
+
delegatorUrl: initConfig.delegatorUrl,
|
|
127
128
|
timeoutMs: options.messageBusTimeoutMs,
|
|
128
129
|
}, options.messageBusTimeoutMs);
|
|
129
130
|
// Initialize the wallet handler
|
|
@@ -500,13 +501,14 @@ class ServiceWorkerReadonlyWallet {
|
|
|
500
501
|
}
|
|
501
502
|
exports.ServiceWorkerReadonlyWallet = ServiceWorkerReadonlyWallet;
|
|
502
503
|
class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet {
|
|
503
|
-
constructor(serviceWorker, identity, walletRepository, contractRepository, messageTag) {
|
|
504
|
+
constructor(serviceWorker, identity, walletRepository, contractRepository, messageTag, hasDelegator) {
|
|
504
505
|
super(serviceWorker, identity, walletRepository, contractRepository, messageTag);
|
|
505
506
|
this.serviceWorker = serviceWorker;
|
|
506
507
|
this.identity = identity;
|
|
507
508
|
this.walletRepository = walletRepository;
|
|
508
509
|
this.contractRepository = contractRepository;
|
|
509
510
|
this._assetManager = new ServiceWorkerAssetManager((msg) => this.sendMessage(msg), messageTag);
|
|
511
|
+
this.hasDelegator = hasDelegator;
|
|
510
512
|
}
|
|
511
513
|
get assetManager() {
|
|
512
514
|
return this._assetManager;
|
|
@@ -527,7 +529,7 @@ class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet {
|
|
|
527
529
|
const privateKey = identity.toHex();
|
|
528
530
|
const messageTag = options.walletUpdaterTag ?? wallet_message_handler_1.DEFAULT_MESSAGE_TAG;
|
|
529
531
|
// Create the wallet instance
|
|
530
|
-
const wallet = new ServiceWorkerWallet(options.serviceWorker, identity, walletRepository, contractRepository, messageTag);
|
|
532
|
+
const wallet = new ServiceWorkerWallet(options.serviceWorker, identity, walletRepository, contractRepository, messageTag, !!options.delegatorUrl);
|
|
531
533
|
const initConfig = {
|
|
532
534
|
key: { privateKey },
|
|
533
535
|
arkServerUrl: options.arkServerUrl,
|
|
@@ -540,6 +542,7 @@ class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet {
|
|
|
540
542
|
url: initConfig.arkServerUrl,
|
|
541
543
|
publicKey: initConfig.arkServerPublicKey,
|
|
542
544
|
},
|
|
545
|
+
delegatorUrl: initConfig.delegatorUrl,
|
|
543
546
|
timeoutMs: options.messageBusTimeoutMs,
|
|
544
547
|
}, options.messageBusTimeoutMs);
|
|
545
548
|
// Initialize the service worker with the config
|
|
@@ -654,5 +657,58 @@ class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet {
|
|
|
654
657
|
throw new Error(`Send failed: ${error}`);
|
|
655
658
|
}
|
|
656
659
|
}
|
|
660
|
+
async getDelegatorManager() {
|
|
661
|
+
if (!this.hasDelegator) {
|
|
662
|
+
return undefined;
|
|
663
|
+
}
|
|
664
|
+
const wallet = this;
|
|
665
|
+
const messageTag = this.messageTag;
|
|
666
|
+
const manager = {
|
|
667
|
+
async delegate(vtxos, destination, delegateAt) {
|
|
668
|
+
const message = {
|
|
669
|
+
tag: messageTag,
|
|
670
|
+
type: "DELEGATE",
|
|
671
|
+
id: (0, utils_2.getRandomId)(),
|
|
672
|
+
payload: {
|
|
673
|
+
vtxoOutpoints: vtxos.map((v) => ({
|
|
674
|
+
txid: v.txid,
|
|
675
|
+
vout: v.vout,
|
|
676
|
+
})),
|
|
677
|
+
destination,
|
|
678
|
+
delegateAt: delegateAt?.getTime(),
|
|
679
|
+
},
|
|
680
|
+
};
|
|
681
|
+
try {
|
|
682
|
+
const response = await wallet.sendMessage(message);
|
|
683
|
+
const payload = response.payload;
|
|
684
|
+
return {
|
|
685
|
+
delegated: payload.delegated,
|
|
686
|
+
failed: payload.failed.map((f) => ({
|
|
687
|
+
outpoints: f.outpoints,
|
|
688
|
+
error: f.error,
|
|
689
|
+
})),
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
catch (error) {
|
|
693
|
+
throw new Error(`Delegation failed: ${error}`);
|
|
694
|
+
}
|
|
695
|
+
},
|
|
696
|
+
async getDelegateInfo() {
|
|
697
|
+
const message = {
|
|
698
|
+
type: "GET_DELEGATE_INFO",
|
|
699
|
+
id: (0, utils_2.getRandomId)(),
|
|
700
|
+
tag: messageTag,
|
|
701
|
+
};
|
|
702
|
+
try {
|
|
703
|
+
const response = await wallet.sendMessage(message);
|
|
704
|
+
return response.payload.info;
|
|
705
|
+
}
|
|
706
|
+
catch (e) {
|
|
707
|
+
throw new Error("Failed to get delegate info");
|
|
708
|
+
}
|
|
709
|
+
},
|
|
710
|
+
};
|
|
711
|
+
return manager;
|
|
712
|
+
}
|
|
657
713
|
}
|
|
658
714
|
exports.ServiceWorkerWallet = ServiceWorkerWallet;
|
|
@@ -459,9 +459,13 @@ class ReadonlyWallet {
|
|
|
459
459
|
* Falls back to only the current script if ContractManager is not yet initialized.
|
|
460
460
|
*/
|
|
461
461
|
async getWalletScripts() {
|
|
462
|
-
if
|
|
462
|
+
// Only use the contract manager if it's already initialized or
|
|
463
|
+
// currently initializing — never trigger initialization here to
|
|
464
|
+
// avoid blocking callers that don't need it.
|
|
465
|
+
if (this._contractManager || this._contractManagerInitializing) {
|
|
463
466
|
try {
|
|
464
|
-
const
|
|
467
|
+
const manager = await this.getContractManager();
|
|
468
|
+
const contracts = await manager.getContracts({
|
|
465
469
|
type: ["default", "delegate"],
|
|
466
470
|
});
|
|
467
471
|
if (contracts.length > 0) {
|
|
@@ -676,7 +680,7 @@ class Wallet extends ReadonlyWallet {
|
|
|
676
680
|
...vtxo_manager_1.DEFAULT_RENEWAL_CONFIG,
|
|
677
681
|
...renewalConfig,
|
|
678
682
|
};
|
|
679
|
-
this.
|
|
683
|
+
this._delegatorManager = delegatorProvider
|
|
680
684
|
? new delegator_1.DelegatorManagerImpl(delegatorProvider, arkProvider, identity)
|
|
681
685
|
: undefined;
|
|
682
686
|
}
|
|
@@ -731,6 +735,9 @@ class Wallet extends ReadonlyWallet {
|
|
|
731
735
|
: this.identity; // Identity extends ReadonlyIdentity, so this is safe
|
|
732
736
|
return new ReadonlyWallet(readonlyIdentity, this.network, this.onchainProvider, this.indexerProvider, this.arkServerPublicKey, this.offchainTapscript, this.boardingTapscript, this.dustAmount, this.walletRepository, this.contractRepository, this.delegatorProvider, this.watcherConfig);
|
|
733
737
|
}
|
|
738
|
+
async getDelegatorManager() {
|
|
739
|
+
return this._delegatorManager;
|
|
740
|
+
}
|
|
734
741
|
async sendBitcoin(params) {
|
|
735
742
|
if (params.amount <= 0) {
|
|
736
743
|
throw new Error("Amount must be positive");
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.MessageBus = void 0;
|
|
5
5
|
const service_worker_manager_1 = require("./browser/service-worker-manager");
|
|
6
6
|
const ark_1 = require("../providers/ark");
|
|
7
|
+
const delegator_1 = require("../providers/delegator");
|
|
7
8
|
const identity_1 = require("../identity");
|
|
8
9
|
const wallet_1 = require("../wallet/wallet");
|
|
9
10
|
const base_1 = require("@scure/base");
|
|
@@ -139,6 +140,9 @@ class MessageBus {
|
|
|
139
140
|
walletRepository: this.walletRepository,
|
|
140
141
|
contractRepository: this.contractRepository,
|
|
141
142
|
};
|
|
143
|
+
const delegatorProvider = config.delegatorUrl
|
|
144
|
+
? new delegator_1.RestDelegatorProvider(config.delegatorUrl)
|
|
145
|
+
: undefined;
|
|
142
146
|
if ("privateKey" in config.wallet) {
|
|
143
147
|
const identity = identity_1.SingleKey.fromHex(config.wallet.privateKey);
|
|
144
148
|
const wallet = await wallet_1.Wallet.create({
|
|
@@ -146,6 +150,7 @@ class MessageBus {
|
|
|
146
150
|
arkServerUrl: config.arkServer.url,
|
|
147
151
|
arkServerPublicKey: config.arkServer.publicKey,
|
|
148
152
|
storage,
|
|
153
|
+
delegatorProvider,
|
|
149
154
|
});
|
|
150
155
|
return { wallet, arkProvider, readonlyWallet: wallet };
|
|
151
156
|
}
|
|
@@ -156,6 +161,7 @@ class MessageBus {
|
|
|
156
161
|
arkServerUrl: config.arkServer.url,
|
|
157
162
|
arkServerPublicKey: config.arkServer.publicKey,
|
|
158
163
|
storage,
|
|
164
|
+
delegatorProvider,
|
|
159
165
|
});
|
|
160
166
|
return { readonlyWallet, arkProvider };
|
|
161
167
|
}
|
|
@@ -10,6 +10,9 @@ export class DelegatorManagerImpl {
|
|
|
10
10
|
this.arkInfoProvider = arkInfoProvider;
|
|
11
11
|
this.identity = identity;
|
|
12
12
|
}
|
|
13
|
+
async getDelegateInfo() {
|
|
14
|
+
return this.delegatorProvider.getDelegateInfo();
|
|
15
|
+
}
|
|
13
16
|
async delegate(vtxos, destination, delegateAt) {
|
|
14
17
|
if (vtxos.length === 0) {
|
|
15
18
|
return { delegated: [], failed: [] };
|
|
@@ -179,6 +179,9 @@ export class ExpoWallet {
|
|
|
179
179
|
getContractManager() {
|
|
180
180
|
return this.wallet.getContractManager();
|
|
181
181
|
}
|
|
182
|
+
getDelegatorManager() {
|
|
183
|
+
return this.wallet.getDelegatorManager();
|
|
184
|
+
}
|
|
182
185
|
sendBitcoin(params) {
|
|
183
186
|
return this.wallet.sendBitcoin(params);
|
|
184
187
|
}
|
|
@@ -286,6 +286,23 @@ export class WalletMessageHandler {
|
|
|
286
286
|
payload: { txid },
|
|
287
287
|
});
|
|
288
288
|
}
|
|
289
|
+
case "DELEGATE": {
|
|
290
|
+
const response = await this.handleDelegate(message);
|
|
291
|
+
return this.tagged({ id, ...response });
|
|
292
|
+
}
|
|
293
|
+
case "GET_DELEGATE_INFO": {
|
|
294
|
+
const wallet = this.requireWallet();
|
|
295
|
+
const delegatorManager = await wallet.getDelegatorManager();
|
|
296
|
+
if (!delegatorManager) {
|
|
297
|
+
throw new Error("Delegator not configured");
|
|
298
|
+
}
|
|
299
|
+
const info = await delegatorManager.getDelegateInfo();
|
|
300
|
+
return this.tagged({
|
|
301
|
+
id,
|
|
302
|
+
type: "DELEGATE_INFO",
|
|
303
|
+
payload: { info },
|
|
304
|
+
});
|
|
305
|
+
}
|
|
289
306
|
default:
|
|
290
307
|
console.error("Unknown message type", message);
|
|
291
308
|
throw new Error("Unknown message");
|
|
@@ -499,6 +516,35 @@ export class WalletMessageHandler {
|
|
|
499
516
|
payload: { tx: signature },
|
|
500
517
|
};
|
|
501
518
|
}
|
|
519
|
+
async handleDelegate(message) {
|
|
520
|
+
const wallet = this.requireWallet();
|
|
521
|
+
const delegatorManager = await wallet.getDelegatorManager();
|
|
522
|
+
if (!delegatorManager) {
|
|
523
|
+
throw new Error("Delegator not configured");
|
|
524
|
+
}
|
|
525
|
+
const { vtxoOutpoints, destination, delegateAt } = message.payload;
|
|
526
|
+
const allVtxos = await wallet.getVtxos();
|
|
527
|
+
const outpointSet = new Set(vtxoOutpoints.map((o) => `${o.txid}:${o.vout}`));
|
|
528
|
+
const filtered = allVtxos.filter((v) => outpointSet.has(`${v.txid}:${v.vout}`));
|
|
529
|
+
const result = await delegatorManager.delegate(filtered, destination, delegateAt !== undefined ? new Date(delegateAt) : undefined);
|
|
530
|
+
return {
|
|
531
|
+
tag: this.messageTag,
|
|
532
|
+
type: "DELEGATE_SUCCESS",
|
|
533
|
+
payload: {
|
|
534
|
+
delegated: result.delegated.map((o) => ({
|
|
535
|
+
txid: o.txid,
|
|
536
|
+
vout: o.vout,
|
|
537
|
+
})),
|
|
538
|
+
failed: result.failed.map((f) => ({
|
|
539
|
+
outpoints: f.outpoints.map((o) => ({
|
|
540
|
+
txid: o.txid,
|
|
541
|
+
vout: o.vout,
|
|
542
|
+
})),
|
|
543
|
+
error: String(f.error),
|
|
544
|
+
})),
|
|
545
|
+
},
|
|
546
|
+
};
|
|
547
|
+
}
|
|
502
548
|
async handleGetVtxos(message) {
|
|
503
549
|
if (!this.readonlyWallet) {
|
|
504
550
|
throw new Error("Wallet handler not initialized");
|
|
@@ -121,6 +121,7 @@ export class ServiceWorkerReadonlyWallet {
|
|
|
121
121
|
url: initConfig.arkServerUrl,
|
|
122
122
|
publicKey: initConfig.arkServerPublicKey,
|
|
123
123
|
},
|
|
124
|
+
delegatorUrl: initConfig.delegatorUrl,
|
|
124
125
|
timeoutMs: options.messageBusTimeoutMs,
|
|
125
126
|
}, options.messageBusTimeoutMs);
|
|
126
127
|
// Initialize the wallet handler
|
|
@@ -496,13 +497,14 @@ export class ServiceWorkerReadonlyWallet {
|
|
|
496
497
|
}
|
|
497
498
|
}
|
|
498
499
|
export class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet {
|
|
499
|
-
constructor(serviceWorker, identity, walletRepository, contractRepository, messageTag) {
|
|
500
|
+
constructor(serviceWorker, identity, walletRepository, contractRepository, messageTag, hasDelegator) {
|
|
500
501
|
super(serviceWorker, identity, walletRepository, contractRepository, messageTag);
|
|
501
502
|
this.serviceWorker = serviceWorker;
|
|
502
503
|
this.identity = identity;
|
|
503
504
|
this.walletRepository = walletRepository;
|
|
504
505
|
this.contractRepository = contractRepository;
|
|
505
506
|
this._assetManager = new ServiceWorkerAssetManager((msg) => this.sendMessage(msg), messageTag);
|
|
507
|
+
this.hasDelegator = hasDelegator;
|
|
506
508
|
}
|
|
507
509
|
get assetManager() {
|
|
508
510
|
return this._assetManager;
|
|
@@ -523,7 +525,7 @@ export class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet {
|
|
|
523
525
|
const privateKey = identity.toHex();
|
|
524
526
|
const messageTag = options.walletUpdaterTag ?? DEFAULT_MESSAGE_TAG;
|
|
525
527
|
// Create the wallet instance
|
|
526
|
-
const wallet = new ServiceWorkerWallet(options.serviceWorker, identity, walletRepository, contractRepository, messageTag);
|
|
528
|
+
const wallet = new ServiceWorkerWallet(options.serviceWorker, identity, walletRepository, contractRepository, messageTag, !!options.delegatorUrl);
|
|
527
529
|
const initConfig = {
|
|
528
530
|
key: { privateKey },
|
|
529
531
|
arkServerUrl: options.arkServerUrl,
|
|
@@ -536,6 +538,7 @@ export class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet {
|
|
|
536
538
|
url: initConfig.arkServerUrl,
|
|
537
539
|
publicKey: initConfig.arkServerPublicKey,
|
|
538
540
|
},
|
|
541
|
+
delegatorUrl: initConfig.delegatorUrl,
|
|
539
542
|
timeoutMs: options.messageBusTimeoutMs,
|
|
540
543
|
}, options.messageBusTimeoutMs);
|
|
541
544
|
// Initialize the service worker with the config
|
|
@@ -650,4 +653,57 @@ export class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet {
|
|
|
650
653
|
throw new Error(`Send failed: ${error}`);
|
|
651
654
|
}
|
|
652
655
|
}
|
|
656
|
+
async getDelegatorManager() {
|
|
657
|
+
if (!this.hasDelegator) {
|
|
658
|
+
return undefined;
|
|
659
|
+
}
|
|
660
|
+
const wallet = this;
|
|
661
|
+
const messageTag = this.messageTag;
|
|
662
|
+
const manager = {
|
|
663
|
+
async delegate(vtxos, destination, delegateAt) {
|
|
664
|
+
const message = {
|
|
665
|
+
tag: messageTag,
|
|
666
|
+
type: "DELEGATE",
|
|
667
|
+
id: getRandomId(),
|
|
668
|
+
payload: {
|
|
669
|
+
vtxoOutpoints: vtxos.map((v) => ({
|
|
670
|
+
txid: v.txid,
|
|
671
|
+
vout: v.vout,
|
|
672
|
+
})),
|
|
673
|
+
destination,
|
|
674
|
+
delegateAt: delegateAt?.getTime(),
|
|
675
|
+
},
|
|
676
|
+
};
|
|
677
|
+
try {
|
|
678
|
+
const response = await wallet.sendMessage(message);
|
|
679
|
+
const payload = response.payload;
|
|
680
|
+
return {
|
|
681
|
+
delegated: payload.delegated,
|
|
682
|
+
failed: payload.failed.map((f) => ({
|
|
683
|
+
outpoints: f.outpoints,
|
|
684
|
+
error: f.error,
|
|
685
|
+
})),
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
catch (error) {
|
|
689
|
+
throw new Error(`Delegation failed: ${error}`);
|
|
690
|
+
}
|
|
691
|
+
},
|
|
692
|
+
async getDelegateInfo() {
|
|
693
|
+
const message = {
|
|
694
|
+
type: "GET_DELEGATE_INFO",
|
|
695
|
+
id: getRandomId(),
|
|
696
|
+
tag: messageTag,
|
|
697
|
+
};
|
|
698
|
+
try {
|
|
699
|
+
const response = await wallet.sendMessage(message);
|
|
700
|
+
return response.payload.info;
|
|
701
|
+
}
|
|
702
|
+
catch (e) {
|
|
703
|
+
throw new Error("Failed to get delegate info");
|
|
704
|
+
}
|
|
705
|
+
},
|
|
706
|
+
};
|
|
707
|
+
return manager;
|
|
708
|
+
}
|
|
653
709
|
}
|
|
@@ -454,9 +454,13 @@ export class ReadonlyWallet {
|
|
|
454
454
|
* Falls back to only the current script if ContractManager is not yet initialized.
|
|
455
455
|
*/
|
|
456
456
|
async getWalletScripts() {
|
|
457
|
-
if
|
|
457
|
+
// Only use the contract manager if it's already initialized or
|
|
458
|
+
// currently initializing — never trigger initialization here to
|
|
459
|
+
// avoid blocking callers that don't need it.
|
|
460
|
+
if (this._contractManager || this._contractManagerInitializing) {
|
|
458
461
|
try {
|
|
459
|
-
const
|
|
462
|
+
const manager = await this.getContractManager();
|
|
463
|
+
const contracts = await manager.getContracts({
|
|
460
464
|
type: ["default", "delegate"],
|
|
461
465
|
});
|
|
462
466
|
if (contracts.length > 0) {
|
|
@@ -670,7 +674,7 @@ export class Wallet extends ReadonlyWallet {
|
|
|
670
674
|
...DEFAULT_RENEWAL_CONFIG,
|
|
671
675
|
...renewalConfig,
|
|
672
676
|
};
|
|
673
|
-
this.
|
|
677
|
+
this._delegatorManager = delegatorProvider
|
|
674
678
|
? new DelegatorManagerImpl(delegatorProvider, arkProvider, identity)
|
|
675
679
|
: undefined;
|
|
676
680
|
}
|
|
@@ -725,6 +729,9 @@ export class Wallet extends ReadonlyWallet {
|
|
|
725
729
|
: this.identity; // Identity extends ReadonlyIdentity, so this is safe
|
|
726
730
|
return new ReadonlyWallet(readonlyIdentity, this.network, this.onchainProvider, this.indexerProvider, this.arkServerPublicKey, this.offchainTapscript, this.boardingTapscript, this.dustAmount, this.walletRepository, this.contractRepository, this.delegatorProvider, this.watcherConfig);
|
|
727
731
|
}
|
|
732
|
+
async getDelegatorManager() {
|
|
733
|
+
return this._delegatorManager;
|
|
734
|
+
}
|
|
728
735
|
async sendBitcoin(params) {
|
|
729
736
|
if (params.amount <= 0) {
|
|
730
737
|
throw new Error("Amount must be positive");
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference lib="webworker" />
|
|
2
2
|
import { getActiveServiceWorker, setupServiceWorkerOnce, } from './browser/service-worker-manager.js';
|
|
3
3
|
import { RestArkProvider } from '../providers/ark.js';
|
|
4
|
+
import { RestDelegatorProvider } from '../providers/delegator.js';
|
|
4
5
|
import { ReadonlySingleKey, SingleKey } from '../identity/index.js';
|
|
5
6
|
import { ReadonlyWallet, Wallet } from '../wallet/wallet.js';
|
|
6
7
|
import { hex } from "@scure/base";
|
|
@@ -136,6 +137,9 @@ export class MessageBus {
|
|
|
136
137
|
walletRepository: this.walletRepository,
|
|
137
138
|
contractRepository: this.contractRepository,
|
|
138
139
|
};
|
|
140
|
+
const delegatorProvider = config.delegatorUrl
|
|
141
|
+
? new RestDelegatorProvider(config.delegatorUrl)
|
|
142
|
+
: undefined;
|
|
139
143
|
if ("privateKey" in config.wallet) {
|
|
140
144
|
const identity = SingleKey.fromHex(config.wallet.privateKey);
|
|
141
145
|
const wallet = await Wallet.create({
|
|
@@ -143,6 +147,7 @@ export class MessageBus {
|
|
|
143
147
|
arkServerUrl: config.arkServer.url,
|
|
144
148
|
arkServerPublicKey: config.arkServer.publicKey,
|
|
145
149
|
storage,
|
|
150
|
+
delegatorProvider,
|
|
146
151
|
});
|
|
147
152
|
return { wallet, arkProvider, readonlyWallet: wallet };
|
|
148
153
|
}
|
|
@@ -153,6 +158,7 @@ export class MessageBus {
|
|
|
153
158
|
arkServerUrl: config.arkServer.url,
|
|
154
159
|
arkServerPublicKey: config.arkServer.publicKey,
|
|
155
160
|
storage,
|
|
161
|
+
delegatorProvider,
|
|
156
162
|
});
|
|
157
163
|
return { readonlyWallet, arkProvider };
|
|
158
164
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ import { validateVtxoTxGraph, validateConnectorsTxGraph } from "./tree/validatio
|
|
|
39
39
|
import { buildForfeitTx } from "./forfeit";
|
|
40
40
|
import { IndexedDBWalletRepository, IndexedDBContractRepository, InMemoryWalletRepository, InMemoryContractRepository, MIGRATION_KEY, migrateWalletRepository, requiresMigration, getMigrationStatus, rollbackMigration, WalletRepositoryImpl, ContractRepositoryImpl, WalletRepository, ContractRepository } from "./repositories";
|
|
41
41
|
import type { MigrationStatus } from "./repositories";
|
|
42
|
-
import { DelegatorManagerImpl,
|
|
42
|
+
import { DelegatorManagerImpl, IDelegatorManager } from "./wallet/delegator";
|
|
43
43
|
export * from "./arkfee";
|
|
44
44
|
export * as asset from "./extension/asset";
|
|
45
45
|
import { ContractManager, ContractWatcher, contractHandlers, DefaultContractHandler, DelegateContractHandler, VHTLCContractHandler, encodeArkContract, decodeArkContract, contractFromArkContract, contractFromArkContractWithAddress, isArkContract } from "./contracts";
|
|
@@ -48,4 +48,4 @@ import { IContractManager } from "./contracts/contractManager";
|
|
|
48
48
|
import { closeDatabase, openDatabase } from "./repositories/indexedDB/manager";
|
|
49
49
|
import { WalletMessageHandler } from "./wallet/serviceWorker/wallet-message-handler";
|
|
50
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,
|
|
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, IDelegatorManager, DelegatorProvider, DelegateInfo, DelegateOptions, WalletRepository, ContractRepository, MigrationStatus, };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ArkProvider, ExtendedVirtualCoin, Identity, Outpoint } from "..";
|
|
1
|
+
import { ArkProvider, DelegateInfo, ExtendedVirtualCoin, Identity, Outpoint } from "..";
|
|
2
2
|
import { DelegatorProvider } from "../providers/delegator";
|
|
3
|
-
export interface
|
|
3
|
+
export interface IDelegatorManager {
|
|
4
4
|
delegate(vtxos: ExtendedVirtualCoin[], destination: string, delegateAt?: Date): Promise<{
|
|
5
5
|
delegated: Outpoint[];
|
|
6
6
|
failed: {
|
|
@@ -8,12 +8,14 @@ export interface DelegatorManager {
|
|
|
8
8
|
error: unknown;
|
|
9
9
|
}[];
|
|
10
10
|
}>;
|
|
11
|
+
getDelegateInfo(): Promise<DelegateInfo>;
|
|
11
12
|
}
|
|
12
|
-
export declare class DelegatorManagerImpl implements
|
|
13
|
+
export declare class DelegatorManagerImpl implements IDelegatorManager {
|
|
13
14
|
readonly delegatorProvider: DelegatorProvider;
|
|
14
15
|
readonly arkInfoProvider: Pick<ArkProvider, "getInfo">;
|
|
15
16
|
readonly identity: Identity;
|
|
16
17
|
constructor(delegatorProvider: DelegatorProvider, arkInfoProvider: Pick<ArkProvider, "getInfo">, identity: Identity);
|
|
18
|
+
getDelegateInfo(): Promise<DelegateInfo>;
|
|
17
19
|
delegate(vtxos: ExtendedVirtualCoin[], destination: string, delegateAt?: Date): Promise<{
|
|
18
20
|
delegated: Outpoint[];
|
|
19
21
|
failed: {
|
|
@@ -3,6 +3,7 @@ import type { IWallet, IAssetManager, WalletBalance, WalletConfig, SendBitcoinPa
|
|
|
3
3
|
import type { SettlementEvent } from "../../providers/ark";
|
|
4
4
|
import type { Identity } from "../../identity";
|
|
5
5
|
import type { IContractManager } from "../../contracts/contractManager";
|
|
6
|
+
import type { IDelegatorManager } from "../delegator";
|
|
6
7
|
import type { TaskQueue } from "../../worker/expo/taskQueue";
|
|
7
8
|
import type { TaskProcessor } from "../../worker/expo/taskRunner";
|
|
8
9
|
/**
|
|
@@ -90,6 +91,7 @@ export declare class ExpoWallet implements IWallet {
|
|
|
90
91
|
getBoardingUtxos(): Promise<ExtendedCoin[]>;
|
|
91
92
|
getTransactionHistory(): Promise<ArkTransaction[]>;
|
|
92
93
|
getContractManager(): Promise<IContractManager>;
|
|
94
|
+
getDelegatorManager(): Promise<IDelegatorManager | undefined>;
|
|
93
95
|
sendBitcoin(params: SendBitcoinParams): Promise<string>;
|
|
94
96
|
settle(params?: SettleParams, eventCallback?: (event: SettlementEvent) => void): Promise<string>;
|
|
95
97
|
send(...recipients: Recipient[]): Promise<string>;
|
|
@@ -9,6 +9,7 @@ import { OnchainProvider } from "../providers/onchain";
|
|
|
9
9
|
import { ContractWatcherConfig } from "../contracts/contractWatcher";
|
|
10
10
|
import { ContractRepository, WalletRepository } from "../repositories";
|
|
11
11
|
import { IContractManager } from "../contracts/contractManager";
|
|
12
|
+
import { IDelegatorManager } from "./delegator";
|
|
12
13
|
import { DelegatorProvider } from "../providers/delegator";
|
|
13
14
|
/**
|
|
14
15
|
* Base configuration options shared by all wallet types.
|
|
@@ -276,6 +277,7 @@ export interface IWallet extends IReadonlyWallet {
|
|
|
276
277
|
settle(params?: SettleParams, eventCallback?: (event: SettlementEvent) => void): Promise<string>;
|
|
277
278
|
send(...recipients: Recipient[]): Promise<string>;
|
|
278
279
|
assetManager: IAssetManager;
|
|
280
|
+
getDelegatorManager(): Promise<IDelegatorManager | undefined>;
|
|
279
281
|
}
|
|
280
282
|
/**
|
|
281
283
|
* Readonly wallet interface for Bitcoin transactions with Ark protocol support.
|
|
@@ -2,6 +2,7 @@ import { SettlementEvent } from "../../providers/ark";
|
|
|
2
2
|
import type { Contract, ContractEvent, ContractWithVtxos, GetContractsFilter, PathSelection } from "../../contracts";
|
|
3
3
|
import type { CreateContractParams, GetAllSpendingPathsOptions, GetSpendablePathsOptions } from "../../contracts/contractManager";
|
|
4
4
|
import { ArkTransaction, AssetDetails, BurnParams, ExtendedCoin, GetVtxosFilter, IssuanceParams, IssuanceResult, IWallet, Recipient, ReissuanceParams, SendBitcoinParams, SettleParams, WalletBalance } from "../index";
|
|
5
|
+
import { DelegateInfo } from "../../providers/delegator";
|
|
5
6
|
import { MessageHandler, RequestEnvelope, ResponseEnvelope } from "../../worker/messageBus";
|
|
6
7
|
import { Transaction } from "../../utils/transaction";
|
|
7
8
|
export declare const DEFAULT_MESSAGE_TAG = "WALLET_UPDATER";
|
|
@@ -318,8 +319,44 @@ export type ResponseBurn = ResponseEnvelope & {
|
|
|
318
319
|
txid: string;
|
|
319
320
|
};
|
|
320
321
|
};
|
|
321
|
-
export type
|
|
322
|
-
|
|
322
|
+
export type RequestDelegate = RequestEnvelope & {
|
|
323
|
+
type: "DELEGATE";
|
|
324
|
+
payload: {
|
|
325
|
+
vtxoOutpoints: {
|
|
326
|
+
txid: string;
|
|
327
|
+
vout: number;
|
|
328
|
+
}[];
|
|
329
|
+
destination: string;
|
|
330
|
+
delegateAt?: number;
|
|
331
|
+
};
|
|
332
|
+
};
|
|
333
|
+
export type ResponseDelegate = ResponseEnvelope & {
|
|
334
|
+
type: "DELEGATE_SUCCESS";
|
|
335
|
+
payload: {
|
|
336
|
+
delegated: {
|
|
337
|
+
txid: string;
|
|
338
|
+
vout: number;
|
|
339
|
+
}[];
|
|
340
|
+
failed: {
|
|
341
|
+
outpoints: {
|
|
342
|
+
txid: string;
|
|
343
|
+
vout: number;
|
|
344
|
+
}[];
|
|
345
|
+
error: string;
|
|
346
|
+
}[];
|
|
347
|
+
};
|
|
348
|
+
};
|
|
349
|
+
export type RequestGetDelegateInfo = RequestEnvelope & {
|
|
350
|
+
type: "GET_DELEGATE_INFO";
|
|
351
|
+
};
|
|
352
|
+
export type ResponseGetDelegateInfo = ResponseEnvelope & {
|
|
353
|
+
type: "DELEGATE_INFO";
|
|
354
|
+
payload: {
|
|
355
|
+
info: DelegateInfo;
|
|
356
|
+
};
|
|
357
|
+
};
|
|
358
|
+
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 | RequestDelegate | RequestGetDelegateInfo;
|
|
359
|
+
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 | ResponseDelegate | ResponseGetDelegateInfo);
|
|
323
360
|
export declare class WalletMessageHandler implements MessageHandler<WalletUpdaterRequest, WalletUpdaterResponse> {
|
|
324
361
|
readonly messageTag: string;
|
|
325
362
|
private wallet;
|
|
@@ -360,6 +397,7 @@ export declare class WalletMessageHandler implements MessageHandler<WalletUpdate
|
|
|
360
397
|
private handleSettle;
|
|
361
398
|
private handleSendBitcoin;
|
|
362
399
|
private handleSignTransaction;
|
|
400
|
+
private handleDelegate;
|
|
363
401
|
private handleGetVtxos;
|
|
364
402
|
private clear;
|
|
365
403
|
private ensureContractEventBroadcasting;
|
|
@@ -5,6 +5,7 @@ import { WalletRepository } from "../../repositories/walletRepository";
|
|
|
5
5
|
import { ContractRepository } from "../../repositories/contractRepository";
|
|
6
6
|
import { ResponseGetStatus, WalletUpdaterRequest, WalletUpdaterResponse } from "./wallet-message-handler";
|
|
7
7
|
import type { IContractManager } from "../../contracts/contractManager";
|
|
8
|
+
import type { IDelegatorManager } from "../delegator";
|
|
8
9
|
type PrivateKeyIdentity = Identity & {
|
|
9
10
|
toHex(): string;
|
|
10
11
|
};
|
|
@@ -106,7 +107,8 @@ export declare class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet imp
|
|
|
106
107
|
readonly contractRepository: ContractRepository;
|
|
107
108
|
readonly identity: Identity;
|
|
108
109
|
private readonly _assetManager;
|
|
109
|
-
|
|
110
|
+
private readonly hasDelegator;
|
|
111
|
+
protected constructor(serviceWorker: ServiceWorker, identity: PrivateKeyIdentity, walletRepository: WalletRepository, contractRepository: ContractRepository, messageTag: string, hasDelegator: boolean);
|
|
110
112
|
get assetManager(): IAssetManager;
|
|
111
113
|
static create(options: ServiceWorkerWalletCreateOptions): Promise<ServiceWorkerWallet>;
|
|
112
114
|
/**
|
|
@@ -134,5 +136,6 @@ export declare class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet imp
|
|
|
134
136
|
sendBitcoin(params: SendBitcoinParams): Promise<string>;
|
|
135
137
|
settle(params?: SettleParams, callback?: (event: SettlementEvent) => void): Promise<string>;
|
|
136
138
|
send(...recipients: Recipient[]): Promise<string>;
|
|
139
|
+
getDelegatorManager(): Promise<IDelegatorManager | undefined>;
|
|
137
140
|
}
|
|
138
141
|
export {};
|
|
@@ -16,7 +16,7 @@ import { ContractRepository } from "../repositories/contractRepository";
|
|
|
16
16
|
import { Batch } from "./batch";
|
|
17
17
|
import { DelegatorProvider } from "../providers/delegator";
|
|
18
18
|
import { DelegateVtxo } from "../script/delegate";
|
|
19
|
-
import {
|
|
19
|
+
import { IDelegatorManager } from "./delegator";
|
|
20
20
|
import { ContractManager } from "../contracts/contractManager";
|
|
21
21
|
export type IncomingFunds = {
|
|
22
22
|
type: "utxo";
|
|
@@ -165,7 +165,7 @@ export declare class Wallet extends ReadonlyWallet implements IWallet {
|
|
|
165
165
|
readonly forfeitPubkey: Bytes;
|
|
166
166
|
static MIN_FEE_RATE: number;
|
|
167
167
|
readonly identity: Identity;
|
|
168
|
-
readonly
|
|
168
|
+
private readonly _delegatorManager?;
|
|
169
169
|
private _walletAssetManager?;
|
|
170
170
|
readonly renewalConfig: Required<Omit<WalletConfig["renewalConfig"], "enabled">> & {
|
|
171
171
|
enabled: boolean;
|
|
@@ -192,6 +192,7 @@ export declare class Wallet extends ReadonlyWallet implements IWallet {
|
|
|
192
192
|
* ```
|
|
193
193
|
*/
|
|
194
194
|
toReadonly(): Promise<ReadonlyWallet>;
|
|
195
|
+
getDelegatorManager(): Promise<IDelegatorManager | undefined>;
|
|
195
196
|
sendBitcoin(params: SendBitcoinParams): Promise<string>;
|
|
196
197
|
settle(params?: SettleParams, eventCallback?: (event: SettlementEvent) => void): Promise<string>;
|
|
197
198
|
private handleSettlementFinalizationEvent;
|