@meshsdk/wallet 1.9.0-beta.2 → 1.9.0-beta.21
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/index.cjs +54 -36
- package/dist/index.d.cts +29 -15
- package/dist/index.d.ts +29 -15
- package/dist/index.js +58 -40
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -569,23 +569,23 @@ var bech32 = /* @__PURE__ */ genBech32("bech32");
|
|
|
569
569
|
var import_common = require("@meshsdk/common");
|
|
570
570
|
var import_core_cst = require("@meshsdk/core-cst");
|
|
571
571
|
var WalletStaticMethods = class {
|
|
572
|
-
static
|
|
572
|
+
static privateKeyBech32ToPrivateKeyHex(_bech32) {
|
|
573
573
|
const bech32DecodedBytes = bech32.decodeToBytes(_bech32).bytes;
|
|
574
574
|
const bip32PrivateKey = import_core_cst.Bip32PrivateKey.fromBytes(bech32DecodedBytes);
|
|
575
575
|
return (0, import_common.bytesToHex)(bip32PrivateKey.bytes());
|
|
576
576
|
}
|
|
577
|
-
static
|
|
577
|
+
static mnemonicToPrivateKeyHex(words) {
|
|
578
578
|
const entropy = (0, import_common.mnemonicToEntropy)(words.join(" "));
|
|
579
579
|
const bip32PrivateKey = (0, import_core_cst.buildBip32PrivateKey)(entropy);
|
|
580
580
|
return (0, import_common.bytesToHex)(bip32PrivateKey.bytes());
|
|
581
581
|
}
|
|
582
|
-
static
|
|
582
|
+
static signingKeyToHexes(paymentKey, stakeKey) {
|
|
583
583
|
return [
|
|
584
584
|
paymentKey.startsWith("5820") ? paymentKey.slice(4) : paymentKey,
|
|
585
585
|
stakeKey.startsWith("5820") ? stakeKey.slice(4) : stakeKey
|
|
586
586
|
];
|
|
587
587
|
}
|
|
588
|
-
static
|
|
588
|
+
static bip32BytesToPrivateKeyHex(bip32Bytes) {
|
|
589
589
|
const bip32PrivateKey = import_core_cst.Bip32PrivateKey.fromBytes(bip32Bytes);
|
|
590
590
|
return (0, import_common.bytesToHex)(bip32PrivateKey.bytes());
|
|
591
591
|
}
|
|
@@ -593,22 +593,22 @@ var WalletStaticMethods = class {
|
|
|
593
593
|
const baseAddress = (0, import_core_cst.buildBaseAddress)(
|
|
594
594
|
networkId,
|
|
595
595
|
import_core_cst.Hash28ByteBase16.fromEd25519KeyHashHex(
|
|
596
|
-
|
|
596
|
+
paymentKey.toPublic().hash().hex()
|
|
597
597
|
),
|
|
598
598
|
import_core_cst.Hash28ByteBase16.fromEd25519KeyHashHex(
|
|
599
|
-
|
|
599
|
+
stakingKey.toPublic().hash().hex()
|
|
600
600
|
)
|
|
601
601
|
).toAddress();
|
|
602
602
|
const enterpriseAddress = (0, import_core_cst.buildEnterpriseAddress)(
|
|
603
603
|
networkId,
|
|
604
604
|
import_core_cst.Hash28ByteBase16.fromEd25519KeyHashHex(
|
|
605
|
-
|
|
605
|
+
paymentKey.toPublic().hash().hex()
|
|
606
606
|
)
|
|
607
607
|
).toAddress();
|
|
608
608
|
const rewardAddress = (0, import_core_cst.buildRewardAddress)(
|
|
609
609
|
networkId,
|
|
610
610
|
import_core_cst.Hash28ByteBase16.fromEd25519KeyHashHex(
|
|
611
|
-
|
|
611
|
+
stakingKey.toPublic().hash().hex()
|
|
612
612
|
)
|
|
613
613
|
).toAddress();
|
|
614
614
|
return {
|
|
@@ -618,15 +618,12 @@ var WalletStaticMethods = class {
|
|
|
618
618
|
};
|
|
619
619
|
}
|
|
620
620
|
static getDRepKey(dRepKey, networkId = 0) {
|
|
621
|
-
const
|
|
622
|
-
const pubDRepKey = pubKey.toString("hex");
|
|
621
|
+
const pubDRepKey = dRepKey.toPublic().hex().toString();
|
|
623
622
|
const dRepIDBech32 = (0, import_core_cst.buildDRepID)(
|
|
624
623
|
(0, import_core_cst.Ed25519PublicKeyHex)(pubDRepKey),
|
|
625
624
|
networkId
|
|
626
625
|
);
|
|
627
|
-
const dRep = import_core_cst.DRep.newKeyHash(
|
|
628
|
-
(0, import_core_cst.Ed25519KeyHashHex)(dRepKey.toPublicKey().hash().toString("hex"))
|
|
629
|
-
);
|
|
626
|
+
const dRep = import_core_cst.DRep.newKeyHash(dRepKey.toPublic().hash().hex());
|
|
630
627
|
const dRepIDHash = dRep.toKeyHash();
|
|
631
628
|
return {
|
|
632
629
|
pubDRepKey,
|
|
@@ -653,40 +650,43 @@ var WalletStaticMethods = class {
|
|
|
653
650
|
}
|
|
654
651
|
};
|
|
655
652
|
var EmbeddedWallet = class extends WalletStaticMethods {
|
|
656
|
-
|
|
653
|
+
_walletSecret;
|
|
657
654
|
_networkId;
|
|
658
655
|
constructor(options) {
|
|
659
656
|
super();
|
|
660
657
|
this._networkId = options.networkId;
|
|
661
658
|
switch (options.key.type) {
|
|
662
659
|
case "mnemonic":
|
|
663
|
-
this.
|
|
660
|
+
this._walletSecret = WalletStaticMethods.mnemonicToPrivateKeyHex(
|
|
664
661
|
options.key.words
|
|
665
662
|
);
|
|
666
663
|
break;
|
|
667
664
|
case "root":
|
|
668
|
-
this.
|
|
665
|
+
this._walletSecret = WalletStaticMethods.privateKeyBech32ToPrivateKeyHex(
|
|
669
666
|
options.key.bech32
|
|
670
667
|
);
|
|
671
668
|
break;
|
|
672
669
|
case "cli":
|
|
673
|
-
this.
|
|
670
|
+
this._walletSecret = WalletStaticMethods.signingKeyToHexes(
|
|
674
671
|
options.key.payment,
|
|
675
672
|
options.key.stake ?? "f0".repeat(32)
|
|
676
673
|
);
|
|
677
674
|
break;
|
|
678
675
|
case "bip32Bytes":
|
|
679
|
-
this.
|
|
676
|
+
this._walletSecret = WalletStaticMethods.bip32BytesToPrivateKeyHex(
|
|
680
677
|
options.key.bip32Bytes
|
|
681
678
|
);
|
|
682
679
|
break;
|
|
683
680
|
}
|
|
684
681
|
}
|
|
682
|
+
async init() {
|
|
683
|
+
await import_core_cst.Crypto.ready();
|
|
684
|
+
}
|
|
685
685
|
getAccount(accountIndex = 0, keyIndex = 0) {
|
|
686
|
-
if (this.
|
|
686
|
+
if (this._walletSecret == void 0)
|
|
687
687
|
throw new Error("[EmbeddedWallet] No keys initialized");
|
|
688
688
|
const { paymentKey, stakeKey, dRepKey } = (0, import_core_cst.buildKeys)(
|
|
689
|
-
this.
|
|
689
|
+
this._walletSecret,
|
|
690
690
|
accountIndex,
|
|
691
691
|
keyIndex
|
|
692
692
|
);
|
|
@@ -700,8 +700,8 @@ var EmbeddedWallet = class extends WalletStaticMethods {
|
|
|
700
700
|
rewardAddressBech32: rewardAddress.toBech32(),
|
|
701
701
|
paymentKey,
|
|
702
702
|
stakeKey,
|
|
703
|
-
paymentKeyHex: paymentKey.
|
|
704
|
-
stakeKeyHex: stakeKey.
|
|
703
|
+
paymentKeyHex: paymentKey.hex(),
|
|
704
|
+
stakeKeyHex: stakeKey.hex()
|
|
705
705
|
};
|
|
706
706
|
if (dRepKey) {
|
|
707
707
|
const { pubDRepKey, dRepIDBech32, dRepIDHash } = WalletStaticMethods.getDRepKey(dRepKey, this._networkId);
|
|
@@ -760,10 +760,8 @@ var EmbeddedWallet = class extends WalletStaticMethods {
|
|
|
760
760
|
const txHash = (0, import_core_cst.deserializeTxHash)((0, import_core_cst.resolveTxHash)(unsignedTx));
|
|
761
761
|
const { paymentKey } = this.getAccount(accountIndex, keyIndex);
|
|
762
762
|
const vKeyWitness = new import_core_cst.VkeyWitness(
|
|
763
|
-
|
|
764
|
-
(0, import_core_cst.
|
|
765
|
-
paymentKey.sign(Buffer.from(txHash, "hex")).toString("hex")
|
|
766
|
-
)
|
|
763
|
+
paymentKey.toPublic().hex(),
|
|
764
|
+
paymentKey.sign((0, import_core_cst.HexBlob)(txHash)).hex()
|
|
767
765
|
);
|
|
768
766
|
return vKeyWitness;
|
|
769
767
|
} catch (error) {
|
|
@@ -812,6 +810,15 @@ var AppWallet = class {
|
|
|
812
810
|
});
|
|
813
811
|
}
|
|
814
812
|
}
|
|
813
|
+
/**
|
|
814
|
+
* Initializes the wallet. This is a required call as fetching addresses from the wallet is an async operation.
|
|
815
|
+
* @returns void
|
|
816
|
+
*/
|
|
817
|
+
async init() {
|
|
818
|
+
if (this._wallet) {
|
|
819
|
+
await this._wallet.init();
|
|
820
|
+
}
|
|
821
|
+
}
|
|
815
822
|
/**
|
|
816
823
|
* Get a list of UTXOs to be used as collateral inputs for transactions with plutus script inputs.
|
|
817
824
|
*
|
|
@@ -1578,6 +1585,7 @@ var import_common4 = require("@meshsdk/common");
|
|
|
1578
1585
|
var import_core_cst5 = require("@meshsdk/core-cst");
|
|
1579
1586
|
var import_transaction = require("@meshsdk/transaction");
|
|
1580
1587
|
var MeshWallet = class {
|
|
1588
|
+
_keyType;
|
|
1581
1589
|
_wallet;
|
|
1582
1590
|
_accountIndex = 0;
|
|
1583
1591
|
_keyIndex = 0;
|
|
@@ -1587,6 +1595,7 @@ var MeshWallet = class {
|
|
|
1587
1595
|
addresses = {};
|
|
1588
1596
|
constructor(options) {
|
|
1589
1597
|
this._networkId = options.networkId;
|
|
1598
|
+
this._keyType = options.key.type;
|
|
1590
1599
|
if (options.fetcher) this._fetcher = options.fetcher;
|
|
1591
1600
|
if (options.submitter) this._submitter = options.submitter;
|
|
1592
1601
|
if (options.accountIndex) this._accountIndex = options.accountIndex;
|
|
@@ -1600,7 +1609,6 @@ var MeshWallet = class {
|
|
|
1600
1609
|
bech32: options.key.bech32
|
|
1601
1610
|
}
|
|
1602
1611
|
});
|
|
1603
|
-
this.getAddressesFromWallet(this._wallet);
|
|
1604
1612
|
break;
|
|
1605
1613
|
case "cli":
|
|
1606
1614
|
this._wallet = new EmbeddedWallet({
|
|
@@ -1611,7 +1619,6 @@ var MeshWallet = class {
|
|
|
1611
1619
|
stake: options.key.stake
|
|
1612
1620
|
}
|
|
1613
1621
|
});
|
|
1614
|
-
this.getAddressesFromWallet(this._wallet);
|
|
1615
1622
|
break;
|
|
1616
1623
|
case "mnemonic":
|
|
1617
1624
|
this._wallet = new EmbeddedWallet({
|
|
@@ -1621,7 +1628,6 @@ var MeshWallet = class {
|
|
|
1621
1628
|
words: options.key.words
|
|
1622
1629
|
}
|
|
1623
1630
|
});
|
|
1624
|
-
this.getAddressesFromWallet(this._wallet);
|
|
1625
1631
|
break;
|
|
1626
1632
|
case "bip32Bytes":
|
|
1627
1633
|
this._wallet = new EmbeddedWallet({
|
|
@@ -1631,7 +1637,6 @@ var MeshWallet = class {
|
|
|
1631
1637
|
bip32Bytes: options.key.bip32Bytes
|
|
1632
1638
|
}
|
|
1633
1639
|
});
|
|
1634
|
-
this.getAddressesFromWallet(this._wallet);
|
|
1635
1640
|
break;
|
|
1636
1641
|
case "address":
|
|
1637
1642
|
this._wallet = null;
|
|
@@ -1639,6 +1644,16 @@ var MeshWallet = class {
|
|
|
1639
1644
|
break;
|
|
1640
1645
|
}
|
|
1641
1646
|
}
|
|
1647
|
+
/**
|
|
1648
|
+
* Initializes the wallet. This is a required call as fetching addresses from the wallet is an async operation.
|
|
1649
|
+
* @returns void
|
|
1650
|
+
*/
|
|
1651
|
+
async init() {
|
|
1652
|
+
if (this._wallet) {
|
|
1653
|
+
await this._wallet.init();
|
|
1654
|
+
this.getAddressesFromWallet(this._wallet);
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1642
1657
|
/**
|
|
1643
1658
|
* Returns all derived addresses from the wallet.
|
|
1644
1659
|
* @returns a list of addresses
|
|
@@ -1680,8 +1695,11 @@ var MeshWallet = class {
|
|
|
1680
1695
|
*
|
|
1681
1696
|
* @returns an address
|
|
1682
1697
|
*/
|
|
1683
|
-
getChangeAddress() {
|
|
1684
|
-
|
|
1698
|
+
async getChangeAddress(addressType = "payment") {
|
|
1699
|
+
if (this.addresses.baseAddressBech32 && addressType === "payment") {
|
|
1700
|
+
return this.addresses.baseAddressBech32;
|
|
1701
|
+
}
|
|
1702
|
+
return this.addresses.enterpriseAddressBech32;
|
|
1685
1703
|
}
|
|
1686
1704
|
/**
|
|
1687
1705
|
* This function shall return a list of one or more UTXOs (unspent transaction outputs) controlled by the wallet that are required to reach AT LEAST the combined ADA value target specified in amount AND the best suitable to be used as collateral inputs for transactions with plutus script inputs (pure ADA-only UTXOs).
|
|
@@ -1760,7 +1778,7 @@ var MeshWallet = class {
|
|
|
1760
1778
|
* @returns a list of unused addresses
|
|
1761
1779
|
*/
|
|
1762
1780
|
async getUnusedAddresses() {
|
|
1763
|
-
return [this.getChangeAddress()];
|
|
1781
|
+
return [await this.getChangeAddress()];
|
|
1764
1782
|
}
|
|
1765
1783
|
/**
|
|
1766
1784
|
* Returns a list of used addresses controlled by the wallet.
|
|
@@ -1768,7 +1786,7 @@ var MeshWallet = class {
|
|
|
1768
1786
|
* @returns a list of used addresses
|
|
1769
1787
|
*/
|
|
1770
1788
|
async getUsedAddresses() {
|
|
1771
|
-
return [this.getChangeAddress()];
|
|
1789
|
+
return [await this.getChangeAddress()];
|
|
1772
1790
|
}
|
|
1773
1791
|
/**
|
|
1774
1792
|
* Get a list of UTXOs to be used for transaction building.
|
|
@@ -1805,7 +1823,7 @@ var MeshWallet = class {
|
|
|
1805
1823
|
);
|
|
1806
1824
|
}
|
|
1807
1825
|
if (address === void 0) {
|
|
1808
|
-
address = this.getChangeAddress();
|
|
1826
|
+
address = await this.getChangeAddress();
|
|
1809
1827
|
}
|
|
1810
1828
|
return this._wallet.signData(
|
|
1811
1829
|
address,
|
|
@@ -1976,7 +1994,7 @@ var MeshWallet = class {
|
|
|
1976
1994
|
*/
|
|
1977
1995
|
async createCollateral() {
|
|
1978
1996
|
const tx = new import_transaction.Transaction({ initiator: this });
|
|
1979
|
-
tx.sendLovelace(this.getChangeAddress(), "5000000");
|
|
1997
|
+
tx.sendLovelace(await this.getChangeAddress(), "5000000");
|
|
1980
1998
|
const unsignedTx = await tx.build();
|
|
1981
1999
|
const signedTx = await this.signTx(unsignedTx);
|
|
1982
2000
|
const txHash = await this.submitTx(signedTx);
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataSignature, IFetcher, ISubmitter, ISigner, IWallet, Wallet, Asset, UTxO, AssetExtended } from '@meshsdk/common';
|
|
2
|
-
import { Ed25519PublicKeyHex, TransactionUnspentOutput, Address,
|
|
2
|
+
import { Ed25519PublicKeyHex, TransactionUnspentOutput, Address, Ed25519PrivateKey, DRepID, Ed25519KeyHashHex, VkeyWitness } from '@meshsdk/core-cst';
|
|
3
3
|
import * as _simplewebauthn_browser from '@simplewebauthn/browser';
|
|
4
4
|
|
|
5
5
|
type Cardano = {
|
|
@@ -77,6 +77,11 @@ declare class AppWallet implements ISigner, ISubmitter {
|
|
|
77
77
|
private readonly _submitter?;
|
|
78
78
|
private readonly _wallet;
|
|
79
79
|
constructor(options: CreateAppWalletOptions);
|
|
80
|
+
/**
|
|
81
|
+
* Initializes the wallet. This is a required call as fetching addresses from the wallet is an async operation.
|
|
82
|
+
* @returns void
|
|
83
|
+
*/
|
|
84
|
+
init(): Promise<void>;
|
|
80
85
|
/**
|
|
81
86
|
* Get a list of UTXOs to be used as collateral inputs for transactions with plutus script inputs.
|
|
82
87
|
*
|
|
@@ -107,7 +112,7 @@ declare global {
|
|
|
107
112
|
/**
|
|
108
113
|
* Browser Wallet provides a set of APIs to interact with the blockchain. This wallet is compatible with Mesh transaction builders.
|
|
109
114
|
*
|
|
110
|
-
* These wallets APIs are in accordance to CIP-30, which defines the API for dApps to communicate with the user's wallet. Additional utility functions provided for developers that are useful for building
|
|
115
|
+
* These wallets APIs are in accordance to CIP-30, which defines the API for dApps to communicate with the user's wallet. Additional utility functions provided for developers that are useful for building applications.
|
|
111
116
|
* ```javascript
|
|
112
117
|
* import { BrowserWallet } from '@meshsdk/core';
|
|
113
118
|
*
|
|
@@ -384,8 +389,8 @@ type Account = {
|
|
|
384
389
|
baseAddressBech32: string;
|
|
385
390
|
enterpriseAddressBech32: string;
|
|
386
391
|
rewardAddressBech32: string;
|
|
387
|
-
paymentKey:
|
|
388
|
-
stakeKey:
|
|
392
|
+
paymentKey: Ed25519PrivateKey;
|
|
393
|
+
stakeKey: Ed25519PrivateKey;
|
|
389
394
|
paymentKeyHex: string;
|
|
390
395
|
stakeKeyHex: string;
|
|
391
396
|
pubDRepKey?: string;
|
|
@@ -411,16 +416,16 @@ type CreateEmbeddedWalletOptions = {
|
|
|
411
416
|
key: EmbeddedWalletKeyType;
|
|
412
417
|
};
|
|
413
418
|
declare class WalletStaticMethods {
|
|
414
|
-
static
|
|
415
|
-
static
|
|
416
|
-
static
|
|
417
|
-
static
|
|
418
|
-
static getAddresses(paymentKey:
|
|
419
|
+
static privateKeyBech32ToPrivateKeyHex(_bech32: string): string;
|
|
420
|
+
static mnemonicToPrivateKeyHex(words: string[]): string;
|
|
421
|
+
static signingKeyToHexes(paymentKey: string, stakeKey: string): [string, string];
|
|
422
|
+
static bip32BytesToPrivateKeyHex(bip32Bytes: Uint8Array): string;
|
|
423
|
+
static getAddresses(paymentKey: Ed25519PrivateKey, stakingKey: Ed25519PrivateKey, networkId?: number): {
|
|
419
424
|
baseAddress: Address;
|
|
420
425
|
enterpriseAddress: Address;
|
|
421
426
|
rewardAddress: Address;
|
|
422
427
|
};
|
|
423
|
-
static getDRepKey(dRepKey:
|
|
428
|
+
static getDRepKey(dRepKey: Ed25519PrivateKey, networkId?: number): {
|
|
424
429
|
pubDRepKey: string;
|
|
425
430
|
dRepIDBech32: DRepID;
|
|
426
431
|
dRepIDHash: Ed25519KeyHashHex;
|
|
@@ -429,9 +434,10 @@ declare class WalletStaticMethods {
|
|
|
429
434
|
static addWitnessSets(txHex: string, witnesses: VkeyWitness[]): string;
|
|
430
435
|
}
|
|
431
436
|
declare class EmbeddedWallet extends WalletStaticMethods {
|
|
432
|
-
private readonly
|
|
437
|
+
private readonly _walletSecret?;
|
|
433
438
|
private readonly _networkId;
|
|
434
439
|
constructor(options: CreateEmbeddedWalletOptions);
|
|
440
|
+
init(): Promise<void>;
|
|
435
441
|
getAccount(accountIndex?: number, keyIndex?: number): Account;
|
|
436
442
|
/**
|
|
437
443
|
* Get wallet network ID.
|
|
@@ -495,20 +501,23 @@ type CreateMeshWalletOptions = {
|
|
|
495
501
|
* ```javascript
|
|
496
502
|
* import { MeshWallet, BlockfrostProvider } from '@meshsdk/core';
|
|
497
503
|
*
|
|
498
|
-
* const
|
|
504
|
+
* const provider = new BlockfrostProvider('<BLOCKFROST_API_KEY>');
|
|
499
505
|
*
|
|
500
506
|
* const wallet = new MeshWallet({
|
|
501
507
|
* networkId: 0,
|
|
502
|
-
* fetcher:
|
|
503
|
-
* submitter:
|
|
508
|
+
* fetcher: provider,
|
|
509
|
+
* submitter: provider,
|
|
504
510
|
* key: {
|
|
505
511
|
* type: 'mnemonic',
|
|
506
512
|
* words: ["solution","solution","solution","solution","solution",","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution"],
|
|
507
513
|
* },
|
|
508
514
|
* });
|
|
509
515
|
* ```
|
|
516
|
+
*
|
|
517
|
+
* Please call `await wallet.init()` after creating the wallet to fetch the addresses from the wallet.
|
|
510
518
|
*/
|
|
511
519
|
declare class MeshWallet implements IWallet {
|
|
520
|
+
private readonly _keyType;
|
|
512
521
|
private readonly _wallet;
|
|
513
522
|
private readonly _accountIndex;
|
|
514
523
|
private readonly _keyIndex;
|
|
@@ -527,6 +536,11 @@ declare class MeshWallet implements IWallet {
|
|
|
527
536
|
dRepIDHash?: Ed25519KeyHashHex;
|
|
528
537
|
};
|
|
529
538
|
constructor(options: CreateMeshWalletOptions);
|
|
539
|
+
/**
|
|
540
|
+
* Initializes the wallet. This is a required call as fetching addresses from the wallet is an async operation.
|
|
541
|
+
* @returns void
|
|
542
|
+
*/
|
|
543
|
+
init(): Promise<void>;
|
|
530
544
|
/**
|
|
531
545
|
* Returns all derived addresses from the wallet.
|
|
532
546
|
* @returns a list of addresses
|
|
@@ -555,7 +569,7 @@ declare class MeshWallet implements IWallet {
|
|
|
555
569
|
*
|
|
556
570
|
* @returns an address
|
|
557
571
|
*/
|
|
558
|
-
getChangeAddress(): string
|
|
572
|
+
getChangeAddress(addressType?: GetAddressType): Promise<string>;
|
|
559
573
|
/**
|
|
560
574
|
* This function shall return a list of one or more UTXOs (unspent transaction outputs) controlled by the wallet that are required to reach AT LEAST the combined ADA value target specified in amount AND the best suitable to be used as collateral inputs for transactions with plutus script inputs (pure ADA-only UTXOs).
|
|
561
575
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataSignature, IFetcher, ISubmitter, ISigner, IWallet, Wallet, Asset, UTxO, AssetExtended } from '@meshsdk/common';
|
|
2
|
-
import { Ed25519PublicKeyHex, TransactionUnspentOutput, Address,
|
|
2
|
+
import { Ed25519PublicKeyHex, TransactionUnspentOutput, Address, Ed25519PrivateKey, DRepID, Ed25519KeyHashHex, VkeyWitness } from '@meshsdk/core-cst';
|
|
3
3
|
import * as _simplewebauthn_browser from '@simplewebauthn/browser';
|
|
4
4
|
|
|
5
5
|
type Cardano = {
|
|
@@ -77,6 +77,11 @@ declare class AppWallet implements ISigner, ISubmitter {
|
|
|
77
77
|
private readonly _submitter?;
|
|
78
78
|
private readonly _wallet;
|
|
79
79
|
constructor(options: CreateAppWalletOptions);
|
|
80
|
+
/**
|
|
81
|
+
* Initializes the wallet. This is a required call as fetching addresses from the wallet is an async operation.
|
|
82
|
+
* @returns void
|
|
83
|
+
*/
|
|
84
|
+
init(): Promise<void>;
|
|
80
85
|
/**
|
|
81
86
|
* Get a list of UTXOs to be used as collateral inputs for transactions with plutus script inputs.
|
|
82
87
|
*
|
|
@@ -107,7 +112,7 @@ declare global {
|
|
|
107
112
|
/**
|
|
108
113
|
* Browser Wallet provides a set of APIs to interact with the blockchain. This wallet is compatible with Mesh transaction builders.
|
|
109
114
|
*
|
|
110
|
-
* These wallets APIs are in accordance to CIP-30, which defines the API for dApps to communicate with the user's wallet. Additional utility functions provided for developers that are useful for building
|
|
115
|
+
* These wallets APIs are in accordance to CIP-30, which defines the API for dApps to communicate with the user's wallet. Additional utility functions provided for developers that are useful for building applications.
|
|
111
116
|
* ```javascript
|
|
112
117
|
* import { BrowserWallet } from '@meshsdk/core';
|
|
113
118
|
*
|
|
@@ -384,8 +389,8 @@ type Account = {
|
|
|
384
389
|
baseAddressBech32: string;
|
|
385
390
|
enterpriseAddressBech32: string;
|
|
386
391
|
rewardAddressBech32: string;
|
|
387
|
-
paymentKey:
|
|
388
|
-
stakeKey:
|
|
392
|
+
paymentKey: Ed25519PrivateKey;
|
|
393
|
+
stakeKey: Ed25519PrivateKey;
|
|
389
394
|
paymentKeyHex: string;
|
|
390
395
|
stakeKeyHex: string;
|
|
391
396
|
pubDRepKey?: string;
|
|
@@ -411,16 +416,16 @@ type CreateEmbeddedWalletOptions = {
|
|
|
411
416
|
key: EmbeddedWalletKeyType;
|
|
412
417
|
};
|
|
413
418
|
declare class WalletStaticMethods {
|
|
414
|
-
static
|
|
415
|
-
static
|
|
416
|
-
static
|
|
417
|
-
static
|
|
418
|
-
static getAddresses(paymentKey:
|
|
419
|
+
static privateKeyBech32ToPrivateKeyHex(_bech32: string): string;
|
|
420
|
+
static mnemonicToPrivateKeyHex(words: string[]): string;
|
|
421
|
+
static signingKeyToHexes(paymentKey: string, stakeKey: string): [string, string];
|
|
422
|
+
static bip32BytesToPrivateKeyHex(bip32Bytes: Uint8Array): string;
|
|
423
|
+
static getAddresses(paymentKey: Ed25519PrivateKey, stakingKey: Ed25519PrivateKey, networkId?: number): {
|
|
419
424
|
baseAddress: Address;
|
|
420
425
|
enterpriseAddress: Address;
|
|
421
426
|
rewardAddress: Address;
|
|
422
427
|
};
|
|
423
|
-
static getDRepKey(dRepKey:
|
|
428
|
+
static getDRepKey(dRepKey: Ed25519PrivateKey, networkId?: number): {
|
|
424
429
|
pubDRepKey: string;
|
|
425
430
|
dRepIDBech32: DRepID;
|
|
426
431
|
dRepIDHash: Ed25519KeyHashHex;
|
|
@@ -429,9 +434,10 @@ declare class WalletStaticMethods {
|
|
|
429
434
|
static addWitnessSets(txHex: string, witnesses: VkeyWitness[]): string;
|
|
430
435
|
}
|
|
431
436
|
declare class EmbeddedWallet extends WalletStaticMethods {
|
|
432
|
-
private readonly
|
|
437
|
+
private readonly _walletSecret?;
|
|
433
438
|
private readonly _networkId;
|
|
434
439
|
constructor(options: CreateEmbeddedWalletOptions);
|
|
440
|
+
init(): Promise<void>;
|
|
435
441
|
getAccount(accountIndex?: number, keyIndex?: number): Account;
|
|
436
442
|
/**
|
|
437
443
|
* Get wallet network ID.
|
|
@@ -495,20 +501,23 @@ type CreateMeshWalletOptions = {
|
|
|
495
501
|
* ```javascript
|
|
496
502
|
* import { MeshWallet, BlockfrostProvider } from '@meshsdk/core';
|
|
497
503
|
*
|
|
498
|
-
* const
|
|
504
|
+
* const provider = new BlockfrostProvider('<BLOCKFROST_API_KEY>');
|
|
499
505
|
*
|
|
500
506
|
* const wallet = new MeshWallet({
|
|
501
507
|
* networkId: 0,
|
|
502
|
-
* fetcher:
|
|
503
|
-
* submitter:
|
|
508
|
+
* fetcher: provider,
|
|
509
|
+
* submitter: provider,
|
|
504
510
|
* key: {
|
|
505
511
|
* type: 'mnemonic',
|
|
506
512
|
* words: ["solution","solution","solution","solution","solution",","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution"],
|
|
507
513
|
* },
|
|
508
514
|
* });
|
|
509
515
|
* ```
|
|
516
|
+
*
|
|
517
|
+
* Please call `await wallet.init()` after creating the wallet to fetch the addresses from the wallet.
|
|
510
518
|
*/
|
|
511
519
|
declare class MeshWallet implements IWallet {
|
|
520
|
+
private readonly _keyType;
|
|
512
521
|
private readonly _wallet;
|
|
513
522
|
private readonly _accountIndex;
|
|
514
523
|
private readonly _keyIndex;
|
|
@@ -527,6 +536,11 @@ declare class MeshWallet implements IWallet {
|
|
|
527
536
|
dRepIDHash?: Ed25519KeyHashHex;
|
|
528
537
|
};
|
|
529
538
|
constructor(options: CreateMeshWalletOptions);
|
|
539
|
+
/**
|
|
540
|
+
* Initializes the wallet. This is a required call as fetching addresses from the wallet is an async operation.
|
|
541
|
+
* @returns void
|
|
542
|
+
*/
|
|
543
|
+
init(): Promise<void>;
|
|
530
544
|
/**
|
|
531
545
|
* Returns all derived addresses from the wallet.
|
|
532
546
|
* @returns a list of addresses
|
|
@@ -555,7 +569,7 @@ declare class MeshWallet implements IWallet {
|
|
|
555
569
|
*
|
|
556
570
|
* @returns an address
|
|
557
571
|
*/
|
|
558
|
-
getChangeAddress(): string
|
|
572
|
+
getChangeAddress(addressType?: GetAddressType): Promise<string>;
|
|
559
573
|
/**
|
|
560
574
|
* This function shall return a list of one or more UTXOs (unspent transaction outputs) controlled by the wallet that are required to reach AT LEAST the combined ADA value target specified in amount AND the best suitable to be used as collateral inputs for transactions with plutus script inputs (pure ADA-only UTXOs).
|
|
561
575
|
*
|
package/dist/index.js
CHANGED
|
@@ -564,13 +564,13 @@ import {
|
|
|
564
564
|
buildEnterpriseAddress,
|
|
565
565
|
buildKeys,
|
|
566
566
|
buildRewardAddress,
|
|
567
|
+
Crypto,
|
|
567
568
|
deserializeTx,
|
|
568
569
|
deserializeTxHash,
|
|
569
570
|
DRep,
|
|
570
|
-
Ed25519KeyHashHex,
|
|
571
571
|
Ed25519PublicKeyHex,
|
|
572
|
-
Ed25519SignatureHex,
|
|
573
572
|
Hash28ByteBase16,
|
|
573
|
+
HexBlob,
|
|
574
574
|
resolveTxHash,
|
|
575
575
|
Serialization,
|
|
576
576
|
signData,
|
|
@@ -578,23 +578,23 @@ import {
|
|
|
578
578
|
VkeyWitness
|
|
579
579
|
} from "@meshsdk/core-cst";
|
|
580
580
|
var WalletStaticMethods = class {
|
|
581
|
-
static
|
|
581
|
+
static privateKeyBech32ToPrivateKeyHex(_bech32) {
|
|
582
582
|
const bech32DecodedBytes = bech32.decodeToBytes(_bech32).bytes;
|
|
583
583
|
const bip32PrivateKey = Bip32PrivateKey.fromBytes(bech32DecodedBytes);
|
|
584
584
|
return bytesToHex(bip32PrivateKey.bytes());
|
|
585
585
|
}
|
|
586
|
-
static
|
|
586
|
+
static mnemonicToPrivateKeyHex(words) {
|
|
587
587
|
const entropy = mnemonicToEntropy(words.join(" "));
|
|
588
588
|
const bip32PrivateKey = buildBip32PrivateKey(entropy);
|
|
589
589
|
return bytesToHex(bip32PrivateKey.bytes());
|
|
590
590
|
}
|
|
591
|
-
static
|
|
591
|
+
static signingKeyToHexes(paymentKey, stakeKey) {
|
|
592
592
|
return [
|
|
593
593
|
paymentKey.startsWith("5820") ? paymentKey.slice(4) : paymentKey,
|
|
594
594
|
stakeKey.startsWith("5820") ? stakeKey.slice(4) : stakeKey
|
|
595
595
|
];
|
|
596
596
|
}
|
|
597
|
-
static
|
|
597
|
+
static bip32BytesToPrivateKeyHex(bip32Bytes) {
|
|
598
598
|
const bip32PrivateKey = Bip32PrivateKey.fromBytes(bip32Bytes);
|
|
599
599
|
return bytesToHex(bip32PrivateKey.bytes());
|
|
600
600
|
}
|
|
@@ -602,22 +602,22 @@ var WalletStaticMethods = class {
|
|
|
602
602
|
const baseAddress = buildBaseAddress(
|
|
603
603
|
networkId,
|
|
604
604
|
Hash28ByteBase16.fromEd25519KeyHashHex(
|
|
605
|
-
|
|
605
|
+
paymentKey.toPublic().hash().hex()
|
|
606
606
|
),
|
|
607
607
|
Hash28ByteBase16.fromEd25519KeyHashHex(
|
|
608
|
-
|
|
608
|
+
stakingKey.toPublic().hash().hex()
|
|
609
609
|
)
|
|
610
610
|
).toAddress();
|
|
611
611
|
const enterpriseAddress = buildEnterpriseAddress(
|
|
612
612
|
networkId,
|
|
613
613
|
Hash28ByteBase16.fromEd25519KeyHashHex(
|
|
614
|
-
|
|
614
|
+
paymentKey.toPublic().hash().hex()
|
|
615
615
|
)
|
|
616
616
|
).toAddress();
|
|
617
617
|
const rewardAddress = buildRewardAddress(
|
|
618
618
|
networkId,
|
|
619
619
|
Hash28ByteBase16.fromEd25519KeyHashHex(
|
|
620
|
-
|
|
620
|
+
stakingKey.toPublic().hash().hex()
|
|
621
621
|
)
|
|
622
622
|
).toAddress();
|
|
623
623
|
return {
|
|
@@ -627,15 +627,12 @@ var WalletStaticMethods = class {
|
|
|
627
627
|
};
|
|
628
628
|
}
|
|
629
629
|
static getDRepKey(dRepKey, networkId = 0) {
|
|
630
|
-
const
|
|
631
|
-
const pubDRepKey = pubKey.toString("hex");
|
|
630
|
+
const pubDRepKey = dRepKey.toPublic().hex().toString();
|
|
632
631
|
const dRepIDBech32 = buildDRepID(
|
|
633
632
|
Ed25519PublicKeyHex(pubDRepKey),
|
|
634
633
|
networkId
|
|
635
634
|
);
|
|
636
|
-
const dRep = DRep.newKeyHash(
|
|
637
|
-
Ed25519KeyHashHex(dRepKey.toPublicKey().hash().toString("hex"))
|
|
638
|
-
);
|
|
635
|
+
const dRep = DRep.newKeyHash(dRepKey.toPublic().hash().hex());
|
|
639
636
|
const dRepIDHash = dRep.toKeyHash();
|
|
640
637
|
return {
|
|
641
638
|
pubDRepKey,
|
|
@@ -662,40 +659,43 @@ var WalletStaticMethods = class {
|
|
|
662
659
|
}
|
|
663
660
|
};
|
|
664
661
|
var EmbeddedWallet = class extends WalletStaticMethods {
|
|
665
|
-
|
|
662
|
+
_walletSecret;
|
|
666
663
|
_networkId;
|
|
667
664
|
constructor(options) {
|
|
668
665
|
super();
|
|
669
666
|
this._networkId = options.networkId;
|
|
670
667
|
switch (options.key.type) {
|
|
671
668
|
case "mnemonic":
|
|
672
|
-
this.
|
|
669
|
+
this._walletSecret = WalletStaticMethods.mnemonicToPrivateKeyHex(
|
|
673
670
|
options.key.words
|
|
674
671
|
);
|
|
675
672
|
break;
|
|
676
673
|
case "root":
|
|
677
|
-
this.
|
|
674
|
+
this._walletSecret = WalletStaticMethods.privateKeyBech32ToPrivateKeyHex(
|
|
678
675
|
options.key.bech32
|
|
679
676
|
);
|
|
680
677
|
break;
|
|
681
678
|
case "cli":
|
|
682
|
-
this.
|
|
679
|
+
this._walletSecret = WalletStaticMethods.signingKeyToHexes(
|
|
683
680
|
options.key.payment,
|
|
684
681
|
options.key.stake ?? "f0".repeat(32)
|
|
685
682
|
);
|
|
686
683
|
break;
|
|
687
684
|
case "bip32Bytes":
|
|
688
|
-
this.
|
|
685
|
+
this._walletSecret = WalletStaticMethods.bip32BytesToPrivateKeyHex(
|
|
689
686
|
options.key.bip32Bytes
|
|
690
687
|
);
|
|
691
688
|
break;
|
|
692
689
|
}
|
|
693
690
|
}
|
|
691
|
+
async init() {
|
|
692
|
+
await Crypto.ready();
|
|
693
|
+
}
|
|
694
694
|
getAccount(accountIndex = 0, keyIndex = 0) {
|
|
695
|
-
if (this.
|
|
695
|
+
if (this._walletSecret == void 0)
|
|
696
696
|
throw new Error("[EmbeddedWallet] No keys initialized");
|
|
697
697
|
const { paymentKey, stakeKey, dRepKey } = buildKeys(
|
|
698
|
-
this.
|
|
698
|
+
this._walletSecret,
|
|
699
699
|
accountIndex,
|
|
700
700
|
keyIndex
|
|
701
701
|
);
|
|
@@ -709,8 +709,8 @@ var EmbeddedWallet = class extends WalletStaticMethods {
|
|
|
709
709
|
rewardAddressBech32: rewardAddress.toBech32(),
|
|
710
710
|
paymentKey,
|
|
711
711
|
stakeKey,
|
|
712
|
-
paymentKeyHex: paymentKey.
|
|
713
|
-
stakeKeyHex: stakeKey.
|
|
712
|
+
paymentKeyHex: paymentKey.hex(),
|
|
713
|
+
stakeKeyHex: stakeKey.hex()
|
|
714
714
|
};
|
|
715
715
|
if (dRepKey) {
|
|
716
716
|
const { pubDRepKey, dRepIDBech32, dRepIDHash } = WalletStaticMethods.getDRepKey(dRepKey, this._networkId);
|
|
@@ -769,10 +769,8 @@ var EmbeddedWallet = class extends WalletStaticMethods {
|
|
|
769
769
|
const txHash = deserializeTxHash(resolveTxHash(unsignedTx));
|
|
770
770
|
const { paymentKey } = this.getAccount(accountIndex, keyIndex);
|
|
771
771
|
const vKeyWitness = new VkeyWitness(
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
paymentKey.sign(Buffer.from(txHash, "hex")).toString("hex")
|
|
775
|
-
)
|
|
772
|
+
paymentKey.toPublic().hex(),
|
|
773
|
+
paymentKey.sign(HexBlob(txHash)).hex()
|
|
776
774
|
);
|
|
777
775
|
return vKeyWitness;
|
|
778
776
|
} catch (error) {
|
|
@@ -821,6 +819,15 @@ var AppWallet = class {
|
|
|
821
819
|
});
|
|
822
820
|
}
|
|
823
821
|
}
|
|
822
|
+
/**
|
|
823
|
+
* Initializes the wallet. This is a required call as fetching addresses from the wallet is an async operation.
|
|
824
|
+
* @returns void
|
|
825
|
+
*/
|
|
826
|
+
async init() {
|
|
827
|
+
if (this._wallet) {
|
|
828
|
+
await this._wallet.init();
|
|
829
|
+
}
|
|
830
|
+
}
|
|
824
831
|
/**
|
|
825
832
|
* Get a list of UTXOs to be used as collateral inputs for transactions with plutus script inputs.
|
|
826
833
|
*
|
|
@@ -1447,13 +1454,13 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1447
1454
|
// src/browser/webauthn/cardano/build-wallet-from-passkey.ts
|
|
1448
1455
|
var import_base32_encoding = __toESM(require_base32_encoding(), 1);
|
|
1449
1456
|
var import_bech32 = __toESM(require_dist(), 1);
|
|
1450
|
-
import { Crypto } from "@meshsdk/core-cst";
|
|
1457
|
+
import { Crypto as Crypto2 } from "@meshsdk/core-cst";
|
|
1451
1458
|
async function buildWalletFromPasskey(rawId, password, appSalt = "appSalt") {
|
|
1452
1459
|
const entropy = await createEntropy(rawId, appSalt);
|
|
1453
1460
|
return buildKey(Buffer.from(entropy), password);
|
|
1454
1461
|
}
|
|
1455
1462
|
function buildKey(entropy, password) {
|
|
1456
|
-
const bip32Key =
|
|
1463
|
+
const bip32Key = Crypto2.Bip32PrivateKey.fromBip39Entropy(entropy, password);
|
|
1457
1464
|
const bytes = import_base32_encoding.default.encode(bip32Key.bytes());
|
|
1458
1465
|
const bech32PrivateKey = import_bech32.bech32.encode("xprv", bytes, 1023);
|
|
1459
1466
|
return {
|
|
@@ -1625,6 +1632,7 @@ import {
|
|
|
1625
1632
|
} from "@meshsdk/core-cst";
|
|
1626
1633
|
import { Transaction as Transaction3 } from "@meshsdk/transaction";
|
|
1627
1634
|
var MeshWallet = class {
|
|
1635
|
+
_keyType;
|
|
1628
1636
|
_wallet;
|
|
1629
1637
|
_accountIndex = 0;
|
|
1630
1638
|
_keyIndex = 0;
|
|
@@ -1634,6 +1642,7 @@ var MeshWallet = class {
|
|
|
1634
1642
|
addresses = {};
|
|
1635
1643
|
constructor(options) {
|
|
1636
1644
|
this._networkId = options.networkId;
|
|
1645
|
+
this._keyType = options.key.type;
|
|
1637
1646
|
if (options.fetcher) this._fetcher = options.fetcher;
|
|
1638
1647
|
if (options.submitter) this._submitter = options.submitter;
|
|
1639
1648
|
if (options.accountIndex) this._accountIndex = options.accountIndex;
|
|
@@ -1647,7 +1656,6 @@ var MeshWallet = class {
|
|
|
1647
1656
|
bech32: options.key.bech32
|
|
1648
1657
|
}
|
|
1649
1658
|
});
|
|
1650
|
-
this.getAddressesFromWallet(this._wallet);
|
|
1651
1659
|
break;
|
|
1652
1660
|
case "cli":
|
|
1653
1661
|
this._wallet = new EmbeddedWallet({
|
|
@@ -1658,7 +1666,6 @@ var MeshWallet = class {
|
|
|
1658
1666
|
stake: options.key.stake
|
|
1659
1667
|
}
|
|
1660
1668
|
});
|
|
1661
|
-
this.getAddressesFromWallet(this._wallet);
|
|
1662
1669
|
break;
|
|
1663
1670
|
case "mnemonic":
|
|
1664
1671
|
this._wallet = new EmbeddedWallet({
|
|
@@ -1668,7 +1675,6 @@ var MeshWallet = class {
|
|
|
1668
1675
|
words: options.key.words
|
|
1669
1676
|
}
|
|
1670
1677
|
});
|
|
1671
|
-
this.getAddressesFromWallet(this._wallet);
|
|
1672
1678
|
break;
|
|
1673
1679
|
case "bip32Bytes":
|
|
1674
1680
|
this._wallet = new EmbeddedWallet({
|
|
@@ -1678,7 +1684,6 @@ var MeshWallet = class {
|
|
|
1678
1684
|
bip32Bytes: options.key.bip32Bytes
|
|
1679
1685
|
}
|
|
1680
1686
|
});
|
|
1681
|
-
this.getAddressesFromWallet(this._wallet);
|
|
1682
1687
|
break;
|
|
1683
1688
|
case "address":
|
|
1684
1689
|
this._wallet = null;
|
|
@@ -1686,6 +1691,16 @@ var MeshWallet = class {
|
|
|
1686
1691
|
break;
|
|
1687
1692
|
}
|
|
1688
1693
|
}
|
|
1694
|
+
/**
|
|
1695
|
+
* Initializes the wallet. This is a required call as fetching addresses from the wallet is an async operation.
|
|
1696
|
+
* @returns void
|
|
1697
|
+
*/
|
|
1698
|
+
async init() {
|
|
1699
|
+
if (this._wallet) {
|
|
1700
|
+
await this._wallet.init();
|
|
1701
|
+
this.getAddressesFromWallet(this._wallet);
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1689
1704
|
/**
|
|
1690
1705
|
* Returns all derived addresses from the wallet.
|
|
1691
1706
|
* @returns a list of addresses
|
|
@@ -1727,8 +1742,11 @@ var MeshWallet = class {
|
|
|
1727
1742
|
*
|
|
1728
1743
|
* @returns an address
|
|
1729
1744
|
*/
|
|
1730
|
-
getChangeAddress() {
|
|
1731
|
-
|
|
1745
|
+
async getChangeAddress(addressType = "payment") {
|
|
1746
|
+
if (this.addresses.baseAddressBech32 && addressType === "payment") {
|
|
1747
|
+
return this.addresses.baseAddressBech32;
|
|
1748
|
+
}
|
|
1749
|
+
return this.addresses.enterpriseAddressBech32;
|
|
1732
1750
|
}
|
|
1733
1751
|
/**
|
|
1734
1752
|
* This function shall return a list of one or more UTXOs (unspent transaction outputs) controlled by the wallet that are required to reach AT LEAST the combined ADA value target specified in amount AND the best suitable to be used as collateral inputs for transactions with plutus script inputs (pure ADA-only UTXOs).
|
|
@@ -1807,7 +1825,7 @@ var MeshWallet = class {
|
|
|
1807
1825
|
* @returns a list of unused addresses
|
|
1808
1826
|
*/
|
|
1809
1827
|
async getUnusedAddresses() {
|
|
1810
|
-
return [this.getChangeAddress()];
|
|
1828
|
+
return [await this.getChangeAddress()];
|
|
1811
1829
|
}
|
|
1812
1830
|
/**
|
|
1813
1831
|
* Returns a list of used addresses controlled by the wallet.
|
|
@@ -1815,7 +1833,7 @@ var MeshWallet = class {
|
|
|
1815
1833
|
* @returns a list of used addresses
|
|
1816
1834
|
*/
|
|
1817
1835
|
async getUsedAddresses() {
|
|
1818
|
-
return [this.getChangeAddress()];
|
|
1836
|
+
return [await this.getChangeAddress()];
|
|
1819
1837
|
}
|
|
1820
1838
|
/**
|
|
1821
1839
|
* Get a list of UTXOs to be used for transaction building.
|
|
@@ -1852,7 +1870,7 @@ var MeshWallet = class {
|
|
|
1852
1870
|
);
|
|
1853
1871
|
}
|
|
1854
1872
|
if (address === void 0) {
|
|
1855
|
-
address = this.getChangeAddress();
|
|
1873
|
+
address = await this.getChangeAddress();
|
|
1856
1874
|
}
|
|
1857
1875
|
return this._wallet.signData(
|
|
1858
1876
|
address,
|
|
@@ -2023,7 +2041,7 @@ var MeshWallet = class {
|
|
|
2023
2041
|
*/
|
|
2024
2042
|
async createCollateral() {
|
|
2025
2043
|
const tx = new Transaction3({ initiator: this });
|
|
2026
|
-
tx.sendLovelace(this.getChangeAddress(), "5000000");
|
|
2044
|
+
tx.sendLovelace(await this.getChangeAddress(), "5000000");
|
|
2027
2045
|
const unsignedTx = await tx.build();
|
|
2028
2046
|
const signedTx = await this.signTx(unsignedTx);
|
|
2029
2047
|
const txHash = await this.submitTx(signedTx);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meshsdk/wallet",
|
|
3
|
-
"version": "1.9.0-beta.
|
|
3
|
+
"version": "1.9.0-beta.21",
|
|
4
4
|
"description": "Wallets - https://meshjs.dev/apis/wallets",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"browser": "./dist/index.js",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"typescript": "^5.3.3"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@meshsdk/common": "1.9.0-beta.
|
|
39
|
-
"@meshsdk/core-cst": "1.9.0-beta.
|
|
40
|
-
"@meshsdk/transaction": "1.9.0-beta.
|
|
38
|
+
"@meshsdk/common": "1.9.0-beta.21",
|
|
39
|
+
"@meshsdk/core-cst": "1.9.0-beta.21",
|
|
40
|
+
"@meshsdk/transaction": "1.9.0-beta.21",
|
|
41
41
|
"@simplewebauthn/browser": "^13.0.0"
|
|
42
42
|
},
|
|
43
43
|
"prettier": "@meshsdk/configs/prettier",
|