@meshsdk/wallet 1.8.13 → 1.9.0-beta-38
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 +94 -67
- package/dist/index.d.cts +43 -27
- package/dist/index.d.ts +43 -27
- package/dist/index.js +100 -70
- package/package.json +4 -5
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,20 +618,19 @@ 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();
|
|
628
|
+
const dRepIDCip105 = (0, import_core_cst.hexToBech32)("drep", dRepIDHash);
|
|
631
629
|
return {
|
|
632
630
|
pubDRepKey,
|
|
633
631
|
dRepIDBech32,
|
|
634
|
-
dRepIDHash
|
|
632
|
+
dRepIDHash,
|
|
633
|
+
dRepIDCip105
|
|
635
634
|
};
|
|
636
635
|
}
|
|
637
636
|
static generateMnemonic(strength = 256) {
|
|
@@ -653,40 +652,45 @@ var WalletStaticMethods = class {
|
|
|
653
652
|
}
|
|
654
653
|
};
|
|
655
654
|
var EmbeddedWallet = class extends WalletStaticMethods {
|
|
656
|
-
|
|
655
|
+
_walletSecret;
|
|
657
656
|
_networkId;
|
|
657
|
+
cryptoIsReady = false;
|
|
658
658
|
constructor(options) {
|
|
659
659
|
super();
|
|
660
660
|
this._networkId = options.networkId;
|
|
661
661
|
switch (options.key.type) {
|
|
662
662
|
case "mnemonic":
|
|
663
|
-
this.
|
|
663
|
+
this._walletSecret = WalletStaticMethods.mnemonicToPrivateKeyHex(
|
|
664
664
|
options.key.words
|
|
665
665
|
);
|
|
666
666
|
break;
|
|
667
667
|
case "root":
|
|
668
|
-
this.
|
|
668
|
+
this._walletSecret = WalletStaticMethods.privateKeyBech32ToPrivateKeyHex(
|
|
669
669
|
options.key.bech32
|
|
670
670
|
);
|
|
671
671
|
break;
|
|
672
672
|
case "cli":
|
|
673
|
-
this.
|
|
673
|
+
this._walletSecret = WalletStaticMethods.signingKeyToHexes(
|
|
674
674
|
options.key.payment,
|
|
675
675
|
options.key.stake ?? "f0".repeat(32)
|
|
676
676
|
);
|
|
677
677
|
break;
|
|
678
678
|
case "bip32Bytes":
|
|
679
|
-
this.
|
|
679
|
+
this._walletSecret = WalletStaticMethods.bip32BytesToPrivateKeyHex(
|
|
680
680
|
options.key.bip32Bytes
|
|
681
681
|
);
|
|
682
682
|
break;
|
|
683
683
|
}
|
|
684
684
|
}
|
|
685
|
+
async init() {
|
|
686
|
+
await import_core_cst.Crypto.ready();
|
|
687
|
+
this.cryptoIsReady = true;
|
|
688
|
+
}
|
|
685
689
|
getAccount(accountIndex = 0, keyIndex = 0) {
|
|
686
|
-
if (this.
|
|
690
|
+
if (this._walletSecret == void 0)
|
|
687
691
|
throw new Error("[EmbeddedWallet] No keys initialized");
|
|
688
692
|
const { paymentKey, stakeKey, dRepKey } = (0, import_core_cst.buildKeys)(
|
|
689
|
-
this.
|
|
693
|
+
this._walletSecret,
|
|
690
694
|
accountIndex,
|
|
691
695
|
keyIndex
|
|
692
696
|
);
|
|
@@ -700,14 +704,15 @@ var EmbeddedWallet = class extends WalletStaticMethods {
|
|
|
700
704
|
rewardAddressBech32: rewardAddress.toBech32(),
|
|
701
705
|
paymentKey,
|
|
702
706
|
stakeKey,
|
|
703
|
-
paymentKeyHex: paymentKey.
|
|
704
|
-
stakeKeyHex: stakeKey.
|
|
707
|
+
paymentKeyHex: paymentKey.hex(),
|
|
708
|
+
stakeKeyHex: stakeKey.hex()
|
|
705
709
|
};
|
|
706
710
|
if (dRepKey) {
|
|
707
|
-
const { pubDRepKey, dRepIDBech32, dRepIDHash } = WalletStaticMethods.getDRepKey(dRepKey, this._networkId);
|
|
711
|
+
const { pubDRepKey, dRepIDBech32, dRepIDHash, dRepIDCip105 } = WalletStaticMethods.getDRepKey(dRepKey, this._networkId);
|
|
708
712
|
_account.pubDRepKey = pubDRepKey;
|
|
709
713
|
_account.dRepIDBech32 = dRepIDBech32;
|
|
710
714
|
_account.dRepIDHash = dRepIDHash;
|
|
715
|
+
_account.dRepIDCip105 = dRepIDCip105;
|
|
711
716
|
}
|
|
712
717
|
return _account;
|
|
713
718
|
}
|
|
@@ -760,10 +765,8 @@ var EmbeddedWallet = class extends WalletStaticMethods {
|
|
|
760
765
|
const txHash = (0, import_core_cst.deserializeTxHash)((0, import_core_cst.resolveTxHash)(unsignedTx));
|
|
761
766
|
const { paymentKey } = this.getAccount(accountIndex, keyIndex);
|
|
762
767
|
const vKeyWitness = new import_core_cst.VkeyWitness(
|
|
763
|
-
|
|
764
|
-
(0, import_core_cst.
|
|
765
|
-
paymentKey.sign(Buffer.from(txHash, "hex")).toString("hex")
|
|
766
|
-
)
|
|
768
|
+
paymentKey.toPublic().hex(),
|
|
769
|
+
paymentKey.sign((0, import_core_cst.HexBlob)(txHash)).hex()
|
|
767
770
|
);
|
|
768
771
|
return vKeyWitness;
|
|
769
772
|
} catch (error) {
|
|
@@ -812,6 +815,15 @@ var AppWallet = class {
|
|
|
812
815
|
});
|
|
813
816
|
}
|
|
814
817
|
}
|
|
818
|
+
/**
|
|
819
|
+
* Initializes the wallet. This is a required call as fetching addresses from the wallet is an async operation.
|
|
820
|
+
* @returns void
|
|
821
|
+
*/
|
|
822
|
+
async init() {
|
|
823
|
+
if (this._wallet) {
|
|
824
|
+
await this._wallet.init();
|
|
825
|
+
}
|
|
826
|
+
}
|
|
815
827
|
/**
|
|
816
828
|
* Get a list of UTXOs to be used as collateral inputs for transactions with plutus script inputs.
|
|
817
829
|
*
|
|
@@ -920,7 +932,6 @@ var AppWallet = class {
|
|
|
920
932
|
|
|
921
933
|
// src/browser/browser-wallet.ts
|
|
922
934
|
var import_common2 = require("@meshsdk/common");
|
|
923
|
-
var import_core_csl = require("@meshsdk/core-csl");
|
|
924
935
|
var import_core_cst3 = require("@meshsdk/core-cst");
|
|
925
936
|
var BrowserWallet = class _BrowserWallet {
|
|
926
937
|
constructor(_walletInstance, _walletName) {
|
|
@@ -975,7 +986,7 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
975
986
|
return wallets;
|
|
976
987
|
}
|
|
977
988
|
/**
|
|
978
|
-
* This is the entrypoint to start communication with the user's wallet. The wallet should request the user's permission to connect the web page to the user's wallet, and if permission has been granted, the wallet will be returned and exposing the full API for the
|
|
989
|
+
* This is the entrypoint to start communication with the user's wallet. The wallet should request the user's permission to connect the web page to the user's wallet, and if permission has been granted, the wallet will be returned and exposing the full API for the app to use.
|
|
979
990
|
*
|
|
980
991
|
* Query BrowserWallet.getInstalledWallets() to get a list of available wallets, then provide the wallet name for which wallet the user would like to connect with.
|
|
981
992
|
*
|
|
@@ -1181,7 +1192,7 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1181
1192
|
/**
|
|
1182
1193
|
* Submits the signed transaction to the blockchain network.
|
|
1183
1194
|
*
|
|
1184
|
-
* As wallets should already have this ability to submit transaction, we allow
|
|
1195
|
+
* As wallets should already have this ability to submit transaction, we allow apps to request that a transaction be sent through it. If the wallet accepts the transaction and tries to send it, it shall return the transaction ID for the app to track. The wallet can return error messages or failure if there was an error in sending it.
|
|
1185
1196
|
*
|
|
1186
1197
|
* @param tx
|
|
1187
1198
|
* @returns a transaction hash
|
|
@@ -1287,19 +1298,18 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1287
1298
|
* The connected wallet account provides the account's public DRep Key, derivation as described in CIP-0105.
|
|
1288
1299
|
* These are used by the client to identify the user's on-chain CIP-1694 interactions, i.e. if a user has registered to be a DRep.
|
|
1289
1300
|
*
|
|
1290
|
-
* @returns
|
|
1301
|
+
* @returns DRep object
|
|
1291
1302
|
*/
|
|
1292
1303
|
async getDRep() {
|
|
1304
|
+
const pubDRepKey = await this.getPubDRepKey();
|
|
1293
1305
|
try {
|
|
1294
|
-
if (
|
|
1295
|
-
const
|
|
1296
|
-
const
|
|
1297
|
-
const csldRepIdKeyHash = import_core_csl.csl.PublicKey.from_hex(dRepKey).hash();
|
|
1298
|
-
const dRepId = csldRepIdKeyHash.to_bech32("drep");
|
|
1306
|
+
if (pubDRepKey === void 0) return void 0;
|
|
1307
|
+
const { dRepIDHash } = await _BrowserWallet.dRepKeyToDRepID(pubDRepKey);
|
|
1308
|
+
const dRepIDCip105 = (0, import_core_cst3.hexToBech32)("drep", dRepIDHash);
|
|
1299
1309
|
return {
|
|
1300
|
-
publicKey:
|
|
1310
|
+
publicKey: pubDRepKey,
|
|
1301
1311
|
publicKeyHash: dRepIDHash,
|
|
1302
|
-
dRepIDCip105
|
|
1312
|
+
dRepIDCip105
|
|
1303
1313
|
};
|
|
1304
1314
|
} catch (e) {
|
|
1305
1315
|
console.error(e);
|
|
@@ -1315,15 +1325,8 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1315
1325
|
async getPubDRepKey() {
|
|
1316
1326
|
try {
|
|
1317
1327
|
if (this._walletInstance.cip95 === void 0) return void 0;
|
|
1318
|
-
const
|
|
1319
|
-
|
|
1320
|
-
const csldRepIdKeyHash = import_core_csl.csl.PublicKey.from_hex(dRepKey).hash();
|
|
1321
|
-
const dRepId = csldRepIdKeyHash.to_bech32("drep");
|
|
1322
|
-
return {
|
|
1323
|
-
pubDRepKey: dRepKey,
|
|
1324
|
-
dRepIDHash,
|
|
1325
|
-
dRepIDBech32: dRepId
|
|
1326
|
-
};
|
|
1328
|
+
const pubDRepKey = await this._walletInstance.cip95.getPubDRepKey();
|
|
1329
|
+
return pubDRepKey;
|
|
1327
1330
|
} catch (e) {
|
|
1328
1331
|
console.error(e);
|
|
1329
1332
|
return void 0;
|
|
@@ -1382,8 +1385,7 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1382
1385
|
if (window.cardano[walletName] === void 0) return void 0;
|
|
1383
1386
|
const wallet = window.cardano[walletName];
|
|
1384
1387
|
if (extensions.length > 0) {
|
|
1385
|
-
|
|
1386
|
-
return wallet.enable({ extensions: _extensions });
|
|
1388
|
+
return wallet.enable({ extensions });
|
|
1387
1389
|
} else {
|
|
1388
1390
|
return wallet?.enable();
|
|
1389
1391
|
}
|
|
@@ -1576,10 +1578,10 @@ async function handleLogin({
|
|
|
1576
1578
|
|
|
1577
1579
|
// src/mesh/index.ts
|
|
1578
1580
|
var import_common4 = require("@meshsdk/common");
|
|
1579
|
-
var import_core_csl2 = require("@meshsdk/core-csl");
|
|
1580
1581
|
var import_core_cst5 = require("@meshsdk/core-cst");
|
|
1581
1582
|
var import_transaction = require("@meshsdk/transaction");
|
|
1582
1583
|
var MeshWallet = class {
|
|
1584
|
+
_keyType;
|
|
1583
1585
|
_wallet;
|
|
1584
1586
|
_accountIndex = 0;
|
|
1585
1587
|
_keyIndex = 0;
|
|
@@ -1589,6 +1591,7 @@ var MeshWallet = class {
|
|
|
1589
1591
|
addresses = {};
|
|
1590
1592
|
constructor(options) {
|
|
1591
1593
|
this._networkId = options.networkId;
|
|
1594
|
+
this._keyType = options.key.type;
|
|
1592
1595
|
if (options.fetcher) this._fetcher = options.fetcher;
|
|
1593
1596
|
if (options.submitter) this._submitter = options.submitter;
|
|
1594
1597
|
if (options.accountIndex) this._accountIndex = options.accountIndex;
|
|
@@ -1602,7 +1605,6 @@ var MeshWallet = class {
|
|
|
1602
1605
|
bech32: options.key.bech32
|
|
1603
1606
|
}
|
|
1604
1607
|
});
|
|
1605
|
-
this.getAddressesFromWallet(this._wallet);
|
|
1606
1608
|
break;
|
|
1607
1609
|
case "cli":
|
|
1608
1610
|
this._wallet = new EmbeddedWallet({
|
|
@@ -1613,7 +1615,6 @@ var MeshWallet = class {
|
|
|
1613
1615
|
stake: options.key.stake
|
|
1614
1616
|
}
|
|
1615
1617
|
});
|
|
1616
|
-
this.getAddressesFromWallet(this._wallet);
|
|
1617
1618
|
break;
|
|
1618
1619
|
case "mnemonic":
|
|
1619
1620
|
this._wallet = new EmbeddedWallet({
|
|
@@ -1623,7 +1624,6 @@ var MeshWallet = class {
|
|
|
1623
1624
|
words: options.key.words
|
|
1624
1625
|
}
|
|
1625
1626
|
});
|
|
1626
|
-
this.getAddressesFromWallet(this._wallet);
|
|
1627
1627
|
break;
|
|
1628
1628
|
case "bip32Bytes":
|
|
1629
1629
|
this._wallet = new EmbeddedWallet({
|
|
@@ -1633,7 +1633,6 @@ var MeshWallet = class {
|
|
|
1633
1633
|
bip32Bytes: options.key.bip32Bytes
|
|
1634
1634
|
}
|
|
1635
1635
|
});
|
|
1636
|
-
this.getAddressesFromWallet(this._wallet);
|
|
1637
1636
|
break;
|
|
1638
1637
|
case "address":
|
|
1639
1638
|
this._wallet = null;
|
|
@@ -1641,6 +1640,16 @@ var MeshWallet = class {
|
|
|
1641
1640
|
break;
|
|
1642
1641
|
}
|
|
1643
1642
|
}
|
|
1643
|
+
/**
|
|
1644
|
+
* Initializes the wallet. This is a required call as fetching addresses from the wallet is an async operation.
|
|
1645
|
+
* @returns void
|
|
1646
|
+
*/
|
|
1647
|
+
async init() {
|
|
1648
|
+
if (this._wallet && !this._wallet.cryptoIsReady) {
|
|
1649
|
+
await this._wallet.init();
|
|
1650
|
+
this.getAddressesFromWallet(this._wallet);
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1644
1653
|
/**
|
|
1645
1654
|
* Returns all derived addresses from the wallet.
|
|
1646
1655
|
* @returns a list of addresses
|
|
@@ -1656,6 +1665,7 @@ var MeshWallet = class {
|
|
|
1656
1665
|
* @returns a list of assets and their quantities
|
|
1657
1666
|
*/
|
|
1658
1667
|
async getBalance() {
|
|
1668
|
+
await this.init();
|
|
1659
1669
|
const utxos = await this.getUnspentOutputs();
|
|
1660
1670
|
const assets = /* @__PURE__ */ new Map();
|
|
1661
1671
|
utxos.map((utxo) => {
|
|
@@ -1682,8 +1692,12 @@ var MeshWallet = class {
|
|
|
1682
1692
|
*
|
|
1683
1693
|
* @returns an address
|
|
1684
1694
|
*/
|
|
1685
|
-
getChangeAddress() {
|
|
1686
|
-
|
|
1695
|
+
async getChangeAddress(addressType = "payment") {
|
|
1696
|
+
await this.init();
|
|
1697
|
+
if (this.addresses.baseAddressBech32 && addressType === "payment") {
|
|
1698
|
+
return this.addresses.baseAddressBech32;
|
|
1699
|
+
}
|
|
1700
|
+
return this.addresses.enterpriseAddressBech32;
|
|
1687
1701
|
}
|
|
1688
1702
|
/**
|
|
1689
1703
|
* 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).
|
|
@@ -1694,6 +1708,7 @@ var MeshWallet = class {
|
|
|
1694
1708
|
* @returns a list of UTXOs
|
|
1695
1709
|
*/
|
|
1696
1710
|
async getCollateral(addressType = "payment") {
|
|
1711
|
+
await this.init();
|
|
1697
1712
|
const utxos = await this.getCollateralUnspentOutput(addressType);
|
|
1698
1713
|
return utxos.map((utxo, i) => {
|
|
1699
1714
|
return (0, import_core_cst5.fromTxUnspentOutput)(utxo);
|
|
@@ -1716,6 +1731,7 @@ var MeshWallet = class {
|
|
|
1716
1731
|
* @returns a list of UTXOs
|
|
1717
1732
|
*/
|
|
1718
1733
|
async getCollateralUnspentOutput(addressType = "payment") {
|
|
1734
|
+
await this.init();
|
|
1719
1735
|
const utxos = await this.getUnspentOutputs(addressType);
|
|
1720
1736
|
const pureAdaUtxos = utxos.filter((utxo) => {
|
|
1721
1737
|
return utxo.output().amount().multiasset() === void 0;
|
|
@@ -1734,10 +1750,16 @@ var MeshWallet = class {
|
|
|
1734
1750
|
* The connected wallet account provides the account's public DRep Key, derivation as described in CIP-0105.
|
|
1735
1751
|
* These are used by the client to identify the user's on-chain CIP-1694 interactions, i.e. if a user has registered to be a DRep.
|
|
1736
1752
|
*
|
|
1737
|
-
* @returns
|
|
1753
|
+
* @returns DRep object
|
|
1738
1754
|
*/
|
|
1739
1755
|
async getDRep() {
|
|
1740
|
-
|
|
1756
|
+
await this.init();
|
|
1757
|
+
if (this.addresses.pubDRepKey && this.addresses.dRepIDHash && this.addresses.dRepIDCip105)
|
|
1758
|
+
return {
|
|
1759
|
+
publicKey: this.addresses.pubDRepKey,
|
|
1760
|
+
publicKeyHash: this.addresses.dRepIDHash,
|
|
1761
|
+
dRepIDCip105: this.addresses.dRepIDCip105
|
|
1762
|
+
};
|
|
1741
1763
|
return void 0;
|
|
1742
1764
|
}
|
|
1743
1765
|
/**
|
|
@@ -1762,7 +1784,7 @@ var MeshWallet = class {
|
|
|
1762
1784
|
* @returns a list of unused addresses
|
|
1763
1785
|
*/
|
|
1764
1786
|
async getUnusedAddresses() {
|
|
1765
|
-
return [this.getChangeAddress()];
|
|
1787
|
+
return [await this.getChangeAddress()];
|
|
1766
1788
|
}
|
|
1767
1789
|
/**
|
|
1768
1790
|
* Returns a list of used addresses controlled by the wallet.
|
|
@@ -1770,7 +1792,7 @@ var MeshWallet = class {
|
|
|
1770
1792
|
* @returns a list of used addresses
|
|
1771
1793
|
*/
|
|
1772
1794
|
async getUsedAddresses() {
|
|
1773
|
-
return [this.getChangeAddress()];
|
|
1795
|
+
return [await this.getChangeAddress()];
|
|
1774
1796
|
}
|
|
1775
1797
|
/**
|
|
1776
1798
|
* Get a list of UTXOs to be used for transaction building.
|
|
@@ -1801,13 +1823,14 @@ var MeshWallet = class {
|
|
|
1801
1823
|
* @returns a signature
|
|
1802
1824
|
*/
|
|
1803
1825
|
async signData(payload, address) {
|
|
1826
|
+
await this.init();
|
|
1804
1827
|
if (!this._wallet) {
|
|
1805
1828
|
throw new Error(
|
|
1806
1829
|
"[MeshWallet] Read only wallet does not support signing data."
|
|
1807
1830
|
);
|
|
1808
1831
|
}
|
|
1809
1832
|
if (address === void 0) {
|
|
1810
|
-
address = this.getChangeAddress();
|
|
1833
|
+
address = await this.getChangeAddress();
|
|
1811
1834
|
}
|
|
1812
1835
|
return this._wallet.signData(
|
|
1813
1836
|
address,
|
|
@@ -1824,6 +1847,7 @@ var MeshWallet = class {
|
|
|
1824
1847
|
* @returns a signed transaction in CBOR
|
|
1825
1848
|
*/
|
|
1826
1849
|
async signTx(unsignedTx, partialSign = false) {
|
|
1850
|
+
await this.init();
|
|
1827
1851
|
if (!this._wallet) {
|
|
1828
1852
|
throw new Error(
|
|
1829
1853
|
"[MeshWallet] Read only wallet does not support signing data."
|
|
@@ -1850,6 +1874,7 @@ var MeshWallet = class {
|
|
|
1850
1874
|
* @returns array of signed transactions CborHex string
|
|
1851
1875
|
*/
|
|
1852
1876
|
async signTxs(unsignedTxs, partialSign = false) {
|
|
1877
|
+
await this.init();
|
|
1853
1878
|
if (!this._wallet) {
|
|
1854
1879
|
throw new Error(
|
|
1855
1880
|
"[MeshWallet] Read only wallet does not support signing data."
|
|
@@ -1865,7 +1890,7 @@ var MeshWallet = class {
|
|
|
1865
1890
|
/**
|
|
1866
1891
|
* Submits the signed transaction to the blockchain network.
|
|
1867
1892
|
*
|
|
1868
|
-
* As wallets should already have this ability to submit transaction, we allow
|
|
1893
|
+
* As wallets should already have this ability to submit transaction, we allow apps to request that a transaction be sent through it. If the wallet accepts the transaction and tries to send it, it shall return the transaction ID for the app to track. The wallet can return error messages or failure if there was an error in sending it.
|
|
1869
1894
|
*
|
|
1870
1895
|
* @param tx - a signed transaction in CBOR
|
|
1871
1896
|
* @returns a transaction hash
|
|
@@ -1978,7 +2003,7 @@ var MeshWallet = class {
|
|
|
1978
2003
|
*/
|
|
1979
2004
|
async createCollateral() {
|
|
1980
2005
|
const tx = new import_transaction.Transaction({ initiator: this });
|
|
1981
|
-
tx.sendLovelace(this.getChangeAddress(), "5000000");
|
|
2006
|
+
tx.sendLovelace(await this.getChangeAddress(), "5000000");
|
|
1982
2007
|
const unsignedTx = await tx.build();
|
|
1983
2008
|
const signedTx = await this.signTx(unsignedTx);
|
|
1984
2009
|
const txHash = await this.submitTx(signedTx);
|
|
@@ -1988,7 +2013,8 @@ var MeshWallet = class {
|
|
|
1988
2013
|
return {
|
|
1989
2014
|
pubDRepKey: this.addresses.pubDRepKey,
|
|
1990
2015
|
dRepIDBech32: this.addresses.dRepIDBech32,
|
|
1991
|
-
dRepIDHash: this.addresses.dRepIDHash
|
|
2016
|
+
dRepIDHash: this.addresses.dRepIDHash,
|
|
2017
|
+
dRepIDCip105: this.addresses.dRepIDCip105
|
|
1992
2018
|
};
|
|
1993
2019
|
}
|
|
1994
2020
|
/**
|
|
@@ -2000,7 +2026,7 @@ var MeshWallet = class {
|
|
|
2000
2026
|
static brew(privateKey = false, strength = 256) {
|
|
2001
2027
|
const mnemonic = EmbeddedWallet.generateMnemonic(strength);
|
|
2002
2028
|
if (privateKey) {
|
|
2003
|
-
return (0,
|
|
2029
|
+
return (0, import_core_cst5.resolvePrivateKey)(mnemonic);
|
|
2004
2030
|
}
|
|
2005
2031
|
return mnemonic;
|
|
2006
2032
|
}
|
|
@@ -2015,7 +2041,8 @@ var MeshWallet = class {
|
|
|
2015
2041
|
rewardAddressBech32: account.rewardAddressBech32,
|
|
2016
2042
|
pubDRepKey: account.pubDRepKey,
|
|
2017
2043
|
dRepIDBech32: account.dRepIDBech32,
|
|
2018
|
-
dRepIDHash: account.dRepIDHash
|
|
2044
|
+
dRepIDHash: account.dRepIDHash,
|
|
2045
|
+
dRepIDCip105: account.dRepIDCip105
|
|
2019
2046
|
};
|
|
2020
2047
|
}
|
|
2021
2048
|
buildAddressFromBech32Address(address) {
|