@arkade-os/sdk 0.4.0-next.5 → 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 +16 -2
- package/dist/cjs/wallet/serviceWorker/wallet.js +53 -18
- package/dist/cjs/wallet/wallet.js +10 -3
- 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 +16 -2
- package/dist/esm/wallet/serviceWorker/wallet.js +53 -18
- package/dist/esm/wallet/wallet.js +10 -3
- 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 +12 -2
- package/dist/types/wallet/serviceWorker/wallet.d.ts +5 -6
- package/dist/types/wallet/wallet.d.ts +3 -2
- 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
|
}
|
|
@@ -293,6 +293,19 @@ class WalletMessageHandler {
|
|
|
293
293
|
const response = await this.handleDelegate(message);
|
|
294
294
|
return this.tagged({ id, ...response });
|
|
295
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
|
+
}
|
|
296
309
|
default:
|
|
297
310
|
console.error("Unknown message type", message);
|
|
298
311
|
throw new Error("Unknown message");
|
|
@@ -508,14 +521,15 @@ class WalletMessageHandler {
|
|
|
508
521
|
}
|
|
509
522
|
async handleDelegate(message) {
|
|
510
523
|
const wallet = this.requireWallet();
|
|
511
|
-
|
|
524
|
+
const delegatorManager = await wallet.getDelegatorManager();
|
|
525
|
+
if (!delegatorManager) {
|
|
512
526
|
throw new Error("Delegator not configured");
|
|
513
527
|
}
|
|
514
528
|
const { vtxoOutpoints, destination, delegateAt } = message.payload;
|
|
515
529
|
const allVtxos = await wallet.getVtxos();
|
|
516
530
|
const outpointSet = new Set(vtxoOutpoints.map((o) => `${o.txid}:${o.vout}`));
|
|
517
531
|
const filtered = allVtxos.filter((v) => outpointSet.has(`${v.txid}:${v.vout}`));
|
|
518
|
-
const result = await
|
|
532
|
+
const result = await delegatorManager.delegate(filtered, destination, delegateAt !== undefined ? new Date(delegateAt) : undefined);
|
|
519
533
|
return {
|
|
520
534
|
tag: this.messageTag,
|
|
521
535
|
type: "DELEGATE_SUCCESS",
|
|
@@ -501,13 +501,14 @@ class ServiceWorkerReadonlyWallet {
|
|
|
501
501
|
}
|
|
502
502
|
exports.ServiceWorkerReadonlyWallet = ServiceWorkerReadonlyWallet;
|
|
503
503
|
class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet {
|
|
504
|
-
constructor(serviceWorker, identity, walletRepository, contractRepository, messageTag) {
|
|
504
|
+
constructor(serviceWorker, identity, walletRepository, contractRepository, messageTag, hasDelegator) {
|
|
505
505
|
super(serviceWorker, identity, walletRepository, contractRepository, messageTag);
|
|
506
506
|
this.serviceWorker = serviceWorker;
|
|
507
507
|
this.identity = identity;
|
|
508
508
|
this.walletRepository = walletRepository;
|
|
509
509
|
this.contractRepository = contractRepository;
|
|
510
510
|
this._assetManager = new ServiceWorkerAssetManager((msg) => this.sendMessage(msg), messageTag);
|
|
511
|
+
this.hasDelegator = hasDelegator;
|
|
511
512
|
}
|
|
512
513
|
get assetManager() {
|
|
513
514
|
return this._assetManager;
|
|
@@ -528,7 +529,7 @@ class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet {
|
|
|
528
529
|
const privateKey = identity.toHex();
|
|
529
530
|
const messageTag = options.walletUpdaterTag ?? wallet_message_handler_1.DEFAULT_MESSAGE_TAG;
|
|
530
531
|
// Create the wallet instance
|
|
531
|
-
const wallet = new ServiceWorkerWallet(options.serviceWorker, identity, walletRepository, contractRepository, messageTag);
|
|
532
|
+
const wallet = new ServiceWorkerWallet(options.serviceWorker, identity, walletRepository, contractRepository, messageTag, !!options.delegatorUrl);
|
|
532
533
|
const initConfig = {
|
|
533
534
|
key: { privateKey },
|
|
534
535
|
arkServerUrl: options.arkServerUrl,
|
|
@@ -656,24 +657,58 @@ class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet {
|
|
|
656
657
|
throw new Error(`Send failed: ${error}`);
|
|
657
658
|
}
|
|
658
659
|
}
|
|
659
|
-
async
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
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
|
+
}
|
|
668
709
|
},
|
|
669
710
|
};
|
|
670
|
-
|
|
671
|
-
const response = await this.sendMessage(message);
|
|
672
|
-
return response.payload;
|
|
673
|
-
}
|
|
674
|
-
catch (error) {
|
|
675
|
-
throw new Error(`Delegation failed: ${error}`);
|
|
676
|
-
}
|
|
711
|
+
return manager;
|
|
677
712
|
}
|
|
678
713
|
}
|
|
679
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");
|
|
@@ -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
|
}
|
|
@@ -290,6 +290,19 @@ export class WalletMessageHandler {
|
|
|
290
290
|
const response = await this.handleDelegate(message);
|
|
291
291
|
return this.tagged({ id, ...response });
|
|
292
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
|
+
}
|
|
293
306
|
default:
|
|
294
307
|
console.error("Unknown message type", message);
|
|
295
308
|
throw new Error("Unknown message");
|
|
@@ -505,14 +518,15 @@ export class WalletMessageHandler {
|
|
|
505
518
|
}
|
|
506
519
|
async handleDelegate(message) {
|
|
507
520
|
const wallet = this.requireWallet();
|
|
508
|
-
|
|
521
|
+
const delegatorManager = await wallet.getDelegatorManager();
|
|
522
|
+
if (!delegatorManager) {
|
|
509
523
|
throw new Error("Delegator not configured");
|
|
510
524
|
}
|
|
511
525
|
const { vtxoOutpoints, destination, delegateAt } = message.payload;
|
|
512
526
|
const allVtxos = await wallet.getVtxos();
|
|
513
527
|
const outpointSet = new Set(vtxoOutpoints.map((o) => `${o.txid}:${o.vout}`));
|
|
514
528
|
const filtered = allVtxos.filter((v) => outpointSet.has(`${v.txid}:${v.vout}`));
|
|
515
|
-
const result = await
|
|
529
|
+
const result = await delegatorManager.delegate(filtered, destination, delegateAt !== undefined ? new Date(delegateAt) : undefined);
|
|
516
530
|
return {
|
|
517
531
|
tag: this.messageTag,
|
|
518
532
|
type: "DELEGATE_SUCCESS",
|
|
@@ -497,13 +497,14 @@ export class ServiceWorkerReadonlyWallet {
|
|
|
497
497
|
}
|
|
498
498
|
}
|
|
499
499
|
export class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet {
|
|
500
|
-
constructor(serviceWorker, identity, walletRepository, contractRepository, messageTag) {
|
|
500
|
+
constructor(serviceWorker, identity, walletRepository, contractRepository, messageTag, hasDelegator) {
|
|
501
501
|
super(serviceWorker, identity, walletRepository, contractRepository, messageTag);
|
|
502
502
|
this.serviceWorker = serviceWorker;
|
|
503
503
|
this.identity = identity;
|
|
504
504
|
this.walletRepository = walletRepository;
|
|
505
505
|
this.contractRepository = contractRepository;
|
|
506
506
|
this._assetManager = new ServiceWorkerAssetManager((msg) => this.sendMessage(msg), messageTag);
|
|
507
|
+
this.hasDelegator = hasDelegator;
|
|
507
508
|
}
|
|
508
509
|
get assetManager() {
|
|
509
510
|
return this._assetManager;
|
|
@@ -524,7 +525,7 @@ export class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet {
|
|
|
524
525
|
const privateKey = identity.toHex();
|
|
525
526
|
const messageTag = options.walletUpdaterTag ?? DEFAULT_MESSAGE_TAG;
|
|
526
527
|
// Create the wallet instance
|
|
527
|
-
const wallet = new ServiceWorkerWallet(options.serviceWorker, identity, walletRepository, contractRepository, messageTag);
|
|
528
|
+
const wallet = new ServiceWorkerWallet(options.serviceWorker, identity, walletRepository, contractRepository, messageTag, !!options.delegatorUrl);
|
|
528
529
|
const initConfig = {
|
|
529
530
|
key: { privateKey },
|
|
530
531
|
arkServerUrl: options.arkServerUrl,
|
|
@@ -652,23 +653,57 @@ export class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet {
|
|
|
652
653
|
throw new Error(`Send failed: ${error}`);
|
|
653
654
|
}
|
|
654
655
|
}
|
|
655
|
-
async
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
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
|
+
}
|
|
664
705
|
},
|
|
665
706
|
};
|
|
666
|
-
|
|
667
|
-
const response = await this.sendMessage(message);
|
|
668
|
-
return response.payload;
|
|
669
|
-
}
|
|
670
|
-
catch (error) {
|
|
671
|
-
throw new Error(`Delegation failed: ${error}`);
|
|
672
|
-
}
|
|
707
|
+
return manager;
|
|
673
708
|
}
|
|
674
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");
|
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";
|
|
@@ -345,8 +346,17 @@ export type ResponseDelegate = ResponseEnvelope & {
|
|
|
345
346
|
}[];
|
|
346
347
|
};
|
|
347
348
|
};
|
|
348
|
-
export type
|
|
349
|
-
|
|
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);
|
|
350
360
|
export declare class WalletMessageHandler implements MessageHandler<WalletUpdaterRequest, WalletUpdaterResponse> {
|
|
351
361
|
readonly messageTag: string;
|
|
352
362
|
private wallet;
|
|
@@ -3,8 +3,9 @@ import { SettlementEvent } from "../../providers/ark";
|
|
|
3
3
|
import { Identity, ReadonlyIdentity } from "../../identity";
|
|
4
4
|
import { WalletRepository } from "../../repositories/walletRepository";
|
|
5
5
|
import { ContractRepository } from "../../repositories/contractRepository";
|
|
6
|
-
import { ResponseGetStatus, WalletUpdaterRequest, WalletUpdaterResponse
|
|
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,9 +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>;
|
|
137
|
-
|
|
138
|
-
txid: string;
|
|
139
|
-
vout: number;
|
|
140
|
-
}[], destination: string, delegateAt?: Date): Promise<ResponseDelegate["payload"]>;
|
|
139
|
+
getDelegatorManager(): Promise<IDelegatorManager | undefined>;
|
|
141
140
|
}
|
|
142
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;
|