@meshsdk/wallet 1.9.0-beta.4 → 1.9.0-beta.41
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 +46 -31
- package/dist/index.d.cts +19 -17
- package/dist/index.d.ts +19 -17
- package/dist/index.js +48 -33
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -625,10 +625,12 @@ var WalletStaticMethods = class {
|
|
|
625
625
|
);
|
|
626
626
|
const dRep = import_core_cst.DRep.newKeyHash(dRepKey.toPublic().hash().hex());
|
|
627
627
|
const dRepIDHash = dRep.toKeyHash();
|
|
628
|
+
const dRepIDCip105 = (0, import_core_cst.hexToBech32)("drep", dRepIDHash);
|
|
628
629
|
return {
|
|
629
630
|
pubDRepKey,
|
|
630
631
|
dRepIDBech32,
|
|
631
|
-
dRepIDHash
|
|
632
|
+
dRepIDHash,
|
|
633
|
+
dRepIDCip105
|
|
632
634
|
};
|
|
633
635
|
}
|
|
634
636
|
static generateMnemonic(strength = 256) {
|
|
@@ -652,6 +654,7 @@ var WalletStaticMethods = class {
|
|
|
652
654
|
var EmbeddedWallet = class extends WalletStaticMethods {
|
|
653
655
|
_walletSecret;
|
|
654
656
|
_networkId;
|
|
657
|
+
cryptoIsReady = false;
|
|
655
658
|
constructor(options) {
|
|
656
659
|
super();
|
|
657
660
|
this._networkId = options.networkId;
|
|
@@ -681,6 +684,7 @@ var EmbeddedWallet = class extends WalletStaticMethods {
|
|
|
681
684
|
}
|
|
682
685
|
async init() {
|
|
683
686
|
await import_core_cst.Crypto.ready();
|
|
687
|
+
this.cryptoIsReady = true;
|
|
684
688
|
}
|
|
685
689
|
getAccount(accountIndex = 0, keyIndex = 0) {
|
|
686
690
|
if (this._walletSecret == void 0)
|
|
@@ -704,10 +708,11 @@ var EmbeddedWallet = class extends WalletStaticMethods {
|
|
|
704
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
|
}
|
|
@@ -981,7 +986,7 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
981
986
|
return wallets;
|
|
982
987
|
}
|
|
983
988
|
/**
|
|
984
|
-
* 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.
|
|
985
990
|
*
|
|
986
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.
|
|
987
992
|
*
|
|
@@ -1187,7 +1192,7 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1187
1192
|
/**
|
|
1188
1193
|
* Submits the signed transaction to the blockchain network.
|
|
1189
1194
|
*
|
|
1190
|
-
* 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.
|
|
1191
1196
|
*
|
|
1192
1197
|
* @param tx
|
|
1193
1198
|
* @returns a transaction hash
|
|
@@ -1293,19 +1298,18 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1293
1298
|
* The connected wallet account provides the account's public DRep Key, derivation as described in CIP-0105.
|
|
1294
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.
|
|
1295
1300
|
*
|
|
1296
|
-
* @returns
|
|
1301
|
+
* @returns DRep object
|
|
1297
1302
|
*/
|
|
1298
1303
|
async getDRep() {
|
|
1304
|
+
const pubDRepKey = await this.getPubDRepKey();
|
|
1299
1305
|
try {
|
|
1300
|
-
if (
|
|
1301
|
-
const
|
|
1302
|
-
const
|
|
1303
|
-
const csldRepIdKeyHash = (0, import_core_cst3.blake2b)(28).update(Buffer.from(dRepKey, "hex")).digest("hex");
|
|
1304
|
-
const dRepId = (0, import_core_cst3.hexToBech32)("drep", csldRepIdKeyHash);
|
|
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);
|
|
1305
1309
|
return {
|
|
1306
|
-
publicKey:
|
|
1310
|
+
publicKey: pubDRepKey,
|
|
1307
1311
|
publicKeyHash: dRepIDHash,
|
|
1308
|
-
dRepIDCip105
|
|
1312
|
+
dRepIDCip105
|
|
1309
1313
|
};
|
|
1310
1314
|
} catch (e) {
|
|
1311
1315
|
console.error(e);
|
|
@@ -1321,15 +1325,8 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1321
1325
|
async getPubDRepKey() {
|
|
1322
1326
|
try {
|
|
1323
1327
|
if (this._walletInstance.cip95 === void 0) return void 0;
|
|
1324
|
-
const
|
|
1325
|
-
|
|
1326
|
-
const csldRepIdKeyHash = (0, import_core_cst3.blake2b)(28).update(Buffer.from(dRepKey, "hex")).digest("hex");
|
|
1327
|
-
const dRepId = (0, import_core_cst3.hexToBech32)("drep", csldRepIdKeyHash);
|
|
1328
|
-
return {
|
|
1329
|
-
pubDRepKey: dRepKey,
|
|
1330
|
-
dRepIDHash,
|
|
1331
|
-
dRepIDBech32: dRepId
|
|
1332
|
-
};
|
|
1328
|
+
const pubDRepKey = await this._walletInstance.cip95.getPubDRepKey();
|
|
1329
|
+
return pubDRepKey;
|
|
1333
1330
|
} catch (e) {
|
|
1334
1331
|
console.error(e);
|
|
1335
1332
|
return void 0;
|
|
@@ -1388,8 +1385,7 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1388
1385
|
if (window.cardano[walletName] === void 0) return void 0;
|
|
1389
1386
|
const wallet = window.cardano[walletName];
|
|
1390
1387
|
if (extensions.length > 0) {
|
|
1391
|
-
|
|
1392
|
-
return wallet.enable({ extensions: _extensions });
|
|
1388
|
+
return wallet.enable({ extensions });
|
|
1393
1389
|
} else {
|
|
1394
1390
|
return wallet?.enable();
|
|
1395
1391
|
}
|
|
@@ -1649,7 +1645,7 @@ var MeshWallet = class {
|
|
|
1649
1645
|
* @returns void
|
|
1650
1646
|
*/
|
|
1651
1647
|
async init() {
|
|
1652
|
-
if (this._wallet) {
|
|
1648
|
+
if (this._wallet && !this._wallet.cryptoIsReady) {
|
|
1653
1649
|
await this._wallet.init();
|
|
1654
1650
|
this.getAddressesFromWallet(this._wallet);
|
|
1655
1651
|
}
|
|
@@ -1669,6 +1665,7 @@ var MeshWallet = class {
|
|
|
1669
1665
|
* @returns a list of assets and their quantities
|
|
1670
1666
|
*/
|
|
1671
1667
|
async getBalance() {
|
|
1668
|
+
await this.init();
|
|
1672
1669
|
const utxos = await this.getUnspentOutputs();
|
|
1673
1670
|
const assets = /* @__PURE__ */ new Map();
|
|
1674
1671
|
utxos.map((utxo) => {
|
|
@@ -1695,8 +1692,12 @@ var MeshWallet = class {
|
|
|
1695
1692
|
*
|
|
1696
1693
|
* @returns an address
|
|
1697
1694
|
*/
|
|
1698
|
-
async getChangeAddress() {
|
|
1699
|
-
|
|
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;
|
|
1700
1701
|
}
|
|
1701
1702
|
/**
|
|
1702
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).
|
|
@@ -1707,6 +1708,7 @@ var MeshWallet = class {
|
|
|
1707
1708
|
* @returns a list of UTXOs
|
|
1708
1709
|
*/
|
|
1709
1710
|
async getCollateral(addressType = "payment") {
|
|
1711
|
+
await this.init();
|
|
1710
1712
|
const utxos = await this.getCollateralUnspentOutput(addressType);
|
|
1711
1713
|
return utxos.map((utxo, i) => {
|
|
1712
1714
|
return (0, import_core_cst5.fromTxUnspentOutput)(utxo);
|
|
@@ -1729,6 +1731,7 @@ var MeshWallet = class {
|
|
|
1729
1731
|
* @returns a list of UTXOs
|
|
1730
1732
|
*/
|
|
1731
1733
|
async getCollateralUnspentOutput(addressType = "payment") {
|
|
1734
|
+
await this.init();
|
|
1732
1735
|
const utxos = await this.getUnspentOutputs(addressType);
|
|
1733
1736
|
const pureAdaUtxos = utxos.filter((utxo) => {
|
|
1734
1737
|
return utxo.output().amount().multiasset() === void 0;
|
|
@@ -1747,10 +1750,16 @@ var MeshWallet = class {
|
|
|
1747
1750
|
* The connected wallet account provides the account's public DRep Key, derivation as described in CIP-0105.
|
|
1748
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.
|
|
1749
1752
|
*
|
|
1750
|
-
* @returns
|
|
1753
|
+
* @returns DRep object
|
|
1751
1754
|
*/
|
|
1752
1755
|
async getDRep() {
|
|
1753
|
-
|
|
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
|
+
};
|
|
1754
1763
|
return void 0;
|
|
1755
1764
|
}
|
|
1756
1765
|
/**
|
|
@@ -1794,6 +1803,7 @@ var MeshWallet = class {
|
|
|
1794
1803
|
* @returns a list of UTXOs
|
|
1795
1804
|
*/
|
|
1796
1805
|
async getUsedUTxOs(addressType = "payment") {
|
|
1806
|
+
await this.init();
|
|
1797
1807
|
return await this.getUnspentOutputs(addressType);
|
|
1798
1808
|
}
|
|
1799
1809
|
/**
|
|
@@ -1814,6 +1824,7 @@ var MeshWallet = class {
|
|
|
1814
1824
|
* @returns a signature
|
|
1815
1825
|
*/
|
|
1816
1826
|
async signData(payload, address) {
|
|
1827
|
+
await this.init();
|
|
1817
1828
|
if (!this._wallet) {
|
|
1818
1829
|
throw new Error(
|
|
1819
1830
|
"[MeshWallet] Read only wallet does not support signing data."
|
|
@@ -1837,6 +1848,7 @@ var MeshWallet = class {
|
|
|
1837
1848
|
* @returns a signed transaction in CBOR
|
|
1838
1849
|
*/
|
|
1839
1850
|
async signTx(unsignedTx, partialSign = false) {
|
|
1851
|
+
await this.init();
|
|
1840
1852
|
if (!this._wallet) {
|
|
1841
1853
|
throw new Error(
|
|
1842
1854
|
"[MeshWallet] Read only wallet does not support signing data."
|
|
@@ -1863,6 +1875,7 @@ var MeshWallet = class {
|
|
|
1863
1875
|
* @returns array of signed transactions CborHex string
|
|
1864
1876
|
*/
|
|
1865
1877
|
async signTxs(unsignedTxs, partialSign = false) {
|
|
1878
|
+
await this.init();
|
|
1866
1879
|
if (!this._wallet) {
|
|
1867
1880
|
throw new Error(
|
|
1868
1881
|
"[MeshWallet] Read only wallet does not support signing data."
|
|
@@ -1878,7 +1891,7 @@ var MeshWallet = class {
|
|
|
1878
1891
|
/**
|
|
1879
1892
|
* Submits the signed transaction to the blockchain network.
|
|
1880
1893
|
*
|
|
1881
|
-
* As wallets should already have this ability to submit transaction, we allow
|
|
1894
|
+
* 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.
|
|
1882
1895
|
*
|
|
1883
1896
|
* @param tx - a signed transaction in CBOR
|
|
1884
1897
|
* @returns a transaction hash
|
|
@@ -2001,7 +2014,8 @@ var MeshWallet = class {
|
|
|
2001
2014
|
return {
|
|
2002
2015
|
pubDRepKey: this.addresses.pubDRepKey,
|
|
2003
2016
|
dRepIDBech32: this.addresses.dRepIDBech32,
|
|
2004
|
-
dRepIDHash: this.addresses.dRepIDHash
|
|
2017
|
+
dRepIDHash: this.addresses.dRepIDHash,
|
|
2018
|
+
dRepIDCip105: this.addresses.dRepIDCip105
|
|
2005
2019
|
};
|
|
2006
2020
|
}
|
|
2007
2021
|
/**
|
|
@@ -2028,7 +2042,8 @@ var MeshWallet = class {
|
|
|
2028
2042
|
rewardAddressBech32: account.rewardAddressBech32,
|
|
2029
2043
|
pubDRepKey: account.pubDRepKey,
|
|
2030
2044
|
dRepIDBech32: account.dRepIDBech32,
|
|
2031
|
-
dRepIDHash: account.dRepIDHash
|
|
2045
|
+
dRepIDHash: account.dRepIDHash,
|
|
2046
|
+
dRepIDCip105: account.dRepIDCip105
|
|
2032
2047
|
};
|
|
2033
2048
|
}
|
|
2034
2049
|
buildAddressFromBech32Address(address) {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataSignature, IFetcher, ISubmitter, ISigner, IWallet, Wallet, Asset, UTxO, AssetExtended } from '@meshsdk/common';
|
|
1
|
+
import { DataSignature, IFetcher, ISubmitter, ISigner, IWallet, Wallet, Extension, Asset, UTxO, AssetExtended } from '@meshsdk/common';
|
|
2
2
|
import { Ed25519PublicKeyHex, TransactionUnspentOutput, Address, Ed25519PrivateKey, DRepID, Ed25519KeyHashHex, VkeyWitness } from '@meshsdk/core-cst';
|
|
3
3
|
import * as _simplewebauthn_browser from '@simplewebauthn/browser';
|
|
4
4
|
|
|
@@ -112,7 +112,7 @@ declare global {
|
|
|
112
112
|
/**
|
|
113
113
|
* Browser Wallet provides a set of APIs to interact with the blockchain. This wallet is compatible with Mesh transaction builders.
|
|
114
114
|
*
|
|
115
|
-
* These wallets APIs are in accordance to CIP-30, which defines the API for
|
|
115
|
+
* These wallets APIs are in accordance to CIP-30, which defines the API for apps to communicate with the user's wallet. Additional utility functions provided for developers that are useful for building applications.
|
|
116
116
|
* ```javascript
|
|
117
117
|
* import { BrowserWallet } from '@meshsdk/core';
|
|
118
118
|
*
|
|
@@ -145,7 +145,7 @@ declare class BrowserWallet implements IWallet {
|
|
|
145
145
|
*/
|
|
146
146
|
static getInstalledWallets(): Wallet[];
|
|
147
147
|
/**
|
|
148
|
-
* 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
|
|
148
|
+
* 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.
|
|
149
149
|
*
|
|
150
150
|
* 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.
|
|
151
151
|
*
|
|
@@ -153,7 +153,7 @@ declare class BrowserWallet implements IWallet {
|
|
|
153
153
|
* @param extensions - optional, a list of CIPs that the wallet should support
|
|
154
154
|
* @returns WalletInstance
|
|
155
155
|
*/
|
|
156
|
-
static enable(walletName: string, extensions?:
|
|
156
|
+
static enable(walletName: string, extensions?: Extension[]): Promise<BrowserWallet>;
|
|
157
157
|
/**
|
|
158
158
|
* Returns a list of assets in the wallet. This API will return every assets in the wallet. Each asset is an object with the following properties:
|
|
159
159
|
* - A unit is provided to display asset's name on the user interface.
|
|
@@ -240,7 +240,7 @@ declare class BrowserWallet implements IWallet {
|
|
|
240
240
|
/**
|
|
241
241
|
* Submits the signed transaction to the blockchain network.
|
|
242
242
|
*
|
|
243
|
-
* As wallets should already have this ability to submit transaction, we allow
|
|
243
|
+
* 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.
|
|
244
244
|
*
|
|
245
245
|
* @param tx
|
|
246
246
|
* @returns a transaction hash
|
|
@@ -299,7 +299,7 @@ declare class BrowserWallet implements IWallet {
|
|
|
299
299
|
* The connected wallet account provides the account's public DRep Key, derivation as described in CIP-0105.
|
|
300
300
|
* 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.
|
|
301
301
|
*
|
|
302
|
-
* @returns
|
|
302
|
+
* @returns DRep object
|
|
303
303
|
*/
|
|
304
304
|
getDRep(): Promise<{
|
|
305
305
|
publicKey: string;
|
|
@@ -312,11 +312,7 @@ declare class BrowserWallet implements IWallet {
|
|
|
312
312
|
*
|
|
313
313
|
* @returns wallet account's public DRep Key
|
|
314
314
|
*/
|
|
315
|
-
getPubDRepKey(): Promise<
|
|
316
|
-
pubDRepKey: string;
|
|
317
|
-
dRepIDHash: string;
|
|
318
|
-
dRepIDBech32: string;
|
|
319
|
-
} | undefined>;
|
|
315
|
+
getPubDRepKey(): Promise<string | undefined>;
|
|
320
316
|
getRegisteredPubStakeKeys(): Promise<{
|
|
321
317
|
pubStakeKeys: string[];
|
|
322
318
|
pubStakeKeyHashes: string[];
|
|
@@ -396,6 +392,7 @@ type Account = {
|
|
|
396
392
|
pubDRepKey?: string;
|
|
397
393
|
dRepIDBech32?: DRepID;
|
|
398
394
|
dRepIDHash?: Ed25519KeyHashHex;
|
|
395
|
+
dRepIDCip105?: string;
|
|
399
396
|
};
|
|
400
397
|
type EmbeddedWalletKeyType = {
|
|
401
398
|
type: "root";
|
|
@@ -429,6 +426,7 @@ declare class WalletStaticMethods {
|
|
|
429
426
|
pubDRepKey: string;
|
|
430
427
|
dRepIDBech32: DRepID;
|
|
431
428
|
dRepIDHash: Ed25519KeyHashHex;
|
|
429
|
+
dRepIDCip105: string;
|
|
432
430
|
};
|
|
433
431
|
static generateMnemonic(strength?: number): string[];
|
|
434
432
|
static addWitnessSets(txHex: string, witnesses: VkeyWitness[]): string;
|
|
@@ -436,6 +434,7 @@ declare class WalletStaticMethods {
|
|
|
436
434
|
declare class EmbeddedWallet extends WalletStaticMethods {
|
|
437
435
|
private readonly _walletSecret?;
|
|
438
436
|
private readonly _networkId;
|
|
437
|
+
cryptoIsReady: boolean;
|
|
439
438
|
constructor(options: CreateEmbeddedWalletOptions);
|
|
440
439
|
init(): Promise<void>;
|
|
441
440
|
getAccount(accountIndex?: number, keyIndex?: number): Account;
|
|
@@ -501,12 +500,12 @@ type CreateMeshWalletOptions = {
|
|
|
501
500
|
* ```javascript
|
|
502
501
|
* import { MeshWallet, BlockfrostProvider } from '@meshsdk/core';
|
|
503
502
|
*
|
|
504
|
-
* const
|
|
503
|
+
* const provider = new BlockfrostProvider('<BLOCKFROST_API_KEY>');
|
|
505
504
|
*
|
|
506
505
|
* const wallet = new MeshWallet({
|
|
507
506
|
* networkId: 0,
|
|
508
|
-
* fetcher:
|
|
509
|
-
* submitter:
|
|
507
|
+
* fetcher: provider,
|
|
508
|
+
* submitter: provider,
|
|
510
509
|
* key: {
|
|
511
510
|
* type: 'mnemonic',
|
|
512
511
|
* words: ["solution","solution","solution","solution","solution",","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution"],
|
|
@@ -534,6 +533,7 @@ declare class MeshWallet implements IWallet {
|
|
|
534
533
|
pubDRepKey?: string;
|
|
535
534
|
dRepIDBech32?: DRepID;
|
|
536
535
|
dRepIDHash?: Ed25519KeyHashHex;
|
|
536
|
+
dRepIDCip105?: string;
|
|
537
537
|
};
|
|
538
538
|
constructor(options: CreateMeshWalletOptions);
|
|
539
539
|
/**
|
|
@@ -555,6 +555,7 @@ declare class MeshWallet implements IWallet {
|
|
|
555
555
|
pubDRepKey?: string;
|
|
556
556
|
dRepIDBech32?: DRepID;
|
|
557
557
|
dRepIDHash?: Ed25519KeyHashHex;
|
|
558
|
+
dRepIDCip105?: string;
|
|
558
559
|
};
|
|
559
560
|
/**
|
|
560
561
|
* Returns a list of assets in the wallet. This API will return every assets in the wallet. Each asset is an object with the following properties:
|
|
@@ -569,7 +570,7 @@ declare class MeshWallet implements IWallet {
|
|
|
569
570
|
*
|
|
570
571
|
* @returns an address
|
|
571
572
|
*/
|
|
572
|
-
getChangeAddress(): Promise<string>;
|
|
573
|
+
getChangeAddress(addressType?: GetAddressType): Promise<string>;
|
|
573
574
|
/**
|
|
574
575
|
* 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).
|
|
575
576
|
*
|
|
@@ -598,7 +599,7 @@ declare class MeshWallet implements IWallet {
|
|
|
598
599
|
* The connected wallet account provides the account's public DRep Key, derivation as described in CIP-0105.
|
|
599
600
|
* 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.
|
|
600
601
|
*
|
|
601
|
-
* @returns
|
|
602
|
+
* @returns DRep object
|
|
602
603
|
*/
|
|
603
604
|
getDRep(): Promise<{
|
|
604
605
|
publicKey: string;
|
|
@@ -672,7 +673,7 @@ declare class MeshWallet implements IWallet {
|
|
|
672
673
|
/**
|
|
673
674
|
* Submits the signed transaction to the blockchain network.
|
|
674
675
|
*
|
|
675
|
-
* As wallets should already have this ability to submit transaction, we allow
|
|
676
|
+
* 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.
|
|
676
677
|
*
|
|
677
678
|
* @param tx - a signed transaction in CBOR
|
|
678
679
|
* @returns a transaction hash
|
|
@@ -739,6 +740,7 @@ declare class MeshWallet implements IWallet {
|
|
|
739
740
|
pubDRepKey: string | undefined;
|
|
740
741
|
dRepIDBech32: string | undefined;
|
|
741
742
|
dRepIDHash: string | undefined;
|
|
743
|
+
dRepIDCip105: string | undefined;
|
|
742
744
|
};
|
|
743
745
|
/**
|
|
744
746
|
* Generate mnemonic or private key
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataSignature, IFetcher, ISubmitter, ISigner, IWallet, Wallet, Asset, UTxO, AssetExtended } from '@meshsdk/common';
|
|
1
|
+
import { DataSignature, IFetcher, ISubmitter, ISigner, IWallet, Wallet, Extension, Asset, UTxO, AssetExtended } from '@meshsdk/common';
|
|
2
2
|
import { Ed25519PublicKeyHex, TransactionUnspentOutput, Address, Ed25519PrivateKey, DRepID, Ed25519KeyHashHex, VkeyWitness } from '@meshsdk/core-cst';
|
|
3
3
|
import * as _simplewebauthn_browser from '@simplewebauthn/browser';
|
|
4
4
|
|
|
@@ -112,7 +112,7 @@ declare global {
|
|
|
112
112
|
/**
|
|
113
113
|
* Browser Wallet provides a set of APIs to interact with the blockchain. This wallet is compatible with Mesh transaction builders.
|
|
114
114
|
*
|
|
115
|
-
* These wallets APIs are in accordance to CIP-30, which defines the API for
|
|
115
|
+
* These wallets APIs are in accordance to CIP-30, which defines the API for apps to communicate with the user's wallet. Additional utility functions provided for developers that are useful for building applications.
|
|
116
116
|
* ```javascript
|
|
117
117
|
* import { BrowserWallet } from '@meshsdk/core';
|
|
118
118
|
*
|
|
@@ -145,7 +145,7 @@ declare class BrowserWallet implements IWallet {
|
|
|
145
145
|
*/
|
|
146
146
|
static getInstalledWallets(): Wallet[];
|
|
147
147
|
/**
|
|
148
|
-
* 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
|
|
148
|
+
* 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.
|
|
149
149
|
*
|
|
150
150
|
* 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.
|
|
151
151
|
*
|
|
@@ -153,7 +153,7 @@ declare class BrowserWallet implements IWallet {
|
|
|
153
153
|
* @param extensions - optional, a list of CIPs that the wallet should support
|
|
154
154
|
* @returns WalletInstance
|
|
155
155
|
*/
|
|
156
|
-
static enable(walletName: string, extensions?:
|
|
156
|
+
static enable(walletName: string, extensions?: Extension[]): Promise<BrowserWallet>;
|
|
157
157
|
/**
|
|
158
158
|
* Returns a list of assets in the wallet. This API will return every assets in the wallet. Each asset is an object with the following properties:
|
|
159
159
|
* - A unit is provided to display asset's name on the user interface.
|
|
@@ -240,7 +240,7 @@ declare class BrowserWallet implements IWallet {
|
|
|
240
240
|
/**
|
|
241
241
|
* Submits the signed transaction to the blockchain network.
|
|
242
242
|
*
|
|
243
|
-
* As wallets should already have this ability to submit transaction, we allow
|
|
243
|
+
* 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.
|
|
244
244
|
*
|
|
245
245
|
* @param tx
|
|
246
246
|
* @returns a transaction hash
|
|
@@ -299,7 +299,7 @@ declare class BrowserWallet implements IWallet {
|
|
|
299
299
|
* The connected wallet account provides the account's public DRep Key, derivation as described in CIP-0105.
|
|
300
300
|
* 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.
|
|
301
301
|
*
|
|
302
|
-
* @returns
|
|
302
|
+
* @returns DRep object
|
|
303
303
|
*/
|
|
304
304
|
getDRep(): Promise<{
|
|
305
305
|
publicKey: string;
|
|
@@ -312,11 +312,7 @@ declare class BrowserWallet implements IWallet {
|
|
|
312
312
|
*
|
|
313
313
|
* @returns wallet account's public DRep Key
|
|
314
314
|
*/
|
|
315
|
-
getPubDRepKey(): Promise<
|
|
316
|
-
pubDRepKey: string;
|
|
317
|
-
dRepIDHash: string;
|
|
318
|
-
dRepIDBech32: string;
|
|
319
|
-
} | undefined>;
|
|
315
|
+
getPubDRepKey(): Promise<string | undefined>;
|
|
320
316
|
getRegisteredPubStakeKeys(): Promise<{
|
|
321
317
|
pubStakeKeys: string[];
|
|
322
318
|
pubStakeKeyHashes: string[];
|
|
@@ -396,6 +392,7 @@ type Account = {
|
|
|
396
392
|
pubDRepKey?: string;
|
|
397
393
|
dRepIDBech32?: DRepID;
|
|
398
394
|
dRepIDHash?: Ed25519KeyHashHex;
|
|
395
|
+
dRepIDCip105?: string;
|
|
399
396
|
};
|
|
400
397
|
type EmbeddedWalletKeyType = {
|
|
401
398
|
type: "root";
|
|
@@ -429,6 +426,7 @@ declare class WalletStaticMethods {
|
|
|
429
426
|
pubDRepKey: string;
|
|
430
427
|
dRepIDBech32: DRepID;
|
|
431
428
|
dRepIDHash: Ed25519KeyHashHex;
|
|
429
|
+
dRepIDCip105: string;
|
|
432
430
|
};
|
|
433
431
|
static generateMnemonic(strength?: number): string[];
|
|
434
432
|
static addWitnessSets(txHex: string, witnesses: VkeyWitness[]): string;
|
|
@@ -436,6 +434,7 @@ declare class WalletStaticMethods {
|
|
|
436
434
|
declare class EmbeddedWallet extends WalletStaticMethods {
|
|
437
435
|
private readonly _walletSecret?;
|
|
438
436
|
private readonly _networkId;
|
|
437
|
+
cryptoIsReady: boolean;
|
|
439
438
|
constructor(options: CreateEmbeddedWalletOptions);
|
|
440
439
|
init(): Promise<void>;
|
|
441
440
|
getAccount(accountIndex?: number, keyIndex?: number): Account;
|
|
@@ -501,12 +500,12 @@ type CreateMeshWalletOptions = {
|
|
|
501
500
|
* ```javascript
|
|
502
501
|
* import { MeshWallet, BlockfrostProvider } from '@meshsdk/core';
|
|
503
502
|
*
|
|
504
|
-
* const
|
|
503
|
+
* const provider = new BlockfrostProvider('<BLOCKFROST_API_KEY>');
|
|
505
504
|
*
|
|
506
505
|
* const wallet = new MeshWallet({
|
|
507
506
|
* networkId: 0,
|
|
508
|
-
* fetcher:
|
|
509
|
-
* submitter:
|
|
507
|
+
* fetcher: provider,
|
|
508
|
+
* submitter: provider,
|
|
510
509
|
* key: {
|
|
511
510
|
* type: 'mnemonic',
|
|
512
511
|
* words: ["solution","solution","solution","solution","solution",","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution"],
|
|
@@ -534,6 +533,7 @@ declare class MeshWallet implements IWallet {
|
|
|
534
533
|
pubDRepKey?: string;
|
|
535
534
|
dRepIDBech32?: DRepID;
|
|
536
535
|
dRepIDHash?: Ed25519KeyHashHex;
|
|
536
|
+
dRepIDCip105?: string;
|
|
537
537
|
};
|
|
538
538
|
constructor(options: CreateMeshWalletOptions);
|
|
539
539
|
/**
|
|
@@ -555,6 +555,7 @@ declare class MeshWallet implements IWallet {
|
|
|
555
555
|
pubDRepKey?: string;
|
|
556
556
|
dRepIDBech32?: DRepID;
|
|
557
557
|
dRepIDHash?: Ed25519KeyHashHex;
|
|
558
|
+
dRepIDCip105?: string;
|
|
558
559
|
};
|
|
559
560
|
/**
|
|
560
561
|
* Returns a list of assets in the wallet. This API will return every assets in the wallet. Each asset is an object with the following properties:
|
|
@@ -569,7 +570,7 @@ declare class MeshWallet implements IWallet {
|
|
|
569
570
|
*
|
|
570
571
|
* @returns an address
|
|
571
572
|
*/
|
|
572
|
-
getChangeAddress(): Promise<string>;
|
|
573
|
+
getChangeAddress(addressType?: GetAddressType): Promise<string>;
|
|
573
574
|
/**
|
|
574
575
|
* 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).
|
|
575
576
|
*
|
|
@@ -598,7 +599,7 @@ declare class MeshWallet implements IWallet {
|
|
|
598
599
|
* The connected wallet account provides the account's public DRep Key, derivation as described in CIP-0105.
|
|
599
600
|
* 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.
|
|
600
601
|
*
|
|
601
|
-
* @returns
|
|
602
|
+
* @returns DRep object
|
|
602
603
|
*/
|
|
603
604
|
getDRep(): Promise<{
|
|
604
605
|
publicKey: string;
|
|
@@ -672,7 +673,7 @@ declare class MeshWallet implements IWallet {
|
|
|
672
673
|
/**
|
|
673
674
|
* Submits the signed transaction to the blockchain network.
|
|
674
675
|
*
|
|
675
|
-
* As wallets should already have this ability to submit transaction, we allow
|
|
676
|
+
* 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.
|
|
676
677
|
*
|
|
677
678
|
* @param tx - a signed transaction in CBOR
|
|
678
679
|
* @returns a transaction hash
|
|
@@ -739,6 +740,7 @@ declare class MeshWallet implements IWallet {
|
|
|
739
740
|
pubDRepKey: string | undefined;
|
|
740
741
|
dRepIDBech32: string | undefined;
|
|
741
742
|
dRepIDHash: string | undefined;
|
|
743
|
+
dRepIDCip105: string | undefined;
|
|
742
744
|
};
|
|
743
745
|
/**
|
|
744
746
|
* Generate mnemonic or private key
|
package/dist/index.js
CHANGED
|
@@ -571,6 +571,7 @@ import {
|
|
|
571
571
|
Ed25519PublicKeyHex,
|
|
572
572
|
Hash28ByteBase16,
|
|
573
573
|
HexBlob,
|
|
574
|
+
hexToBech32,
|
|
574
575
|
resolveTxHash,
|
|
575
576
|
Serialization,
|
|
576
577
|
signData,
|
|
@@ -634,10 +635,12 @@ var WalletStaticMethods = class {
|
|
|
634
635
|
);
|
|
635
636
|
const dRep = DRep.newKeyHash(dRepKey.toPublic().hash().hex());
|
|
636
637
|
const dRepIDHash = dRep.toKeyHash();
|
|
638
|
+
const dRepIDCip105 = hexToBech32("drep", dRepIDHash);
|
|
637
639
|
return {
|
|
638
640
|
pubDRepKey,
|
|
639
641
|
dRepIDBech32,
|
|
640
|
-
dRepIDHash
|
|
642
|
+
dRepIDHash,
|
|
643
|
+
dRepIDCip105
|
|
641
644
|
};
|
|
642
645
|
}
|
|
643
646
|
static generateMnemonic(strength = 256) {
|
|
@@ -661,6 +664,7 @@ var WalletStaticMethods = class {
|
|
|
661
664
|
var EmbeddedWallet = class extends WalletStaticMethods {
|
|
662
665
|
_walletSecret;
|
|
663
666
|
_networkId;
|
|
667
|
+
cryptoIsReady = false;
|
|
664
668
|
constructor(options) {
|
|
665
669
|
super();
|
|
666
670
|
this._networkId = options.networkId;
|
|
@@ -690,6 +694,7 @@ var EmbeddedWallet = class extends WalletStaticMethods {
|
|
|
690
694
|
}
|
|
691
695
|
async init() {
|
|
692
696
|
await Crypto.ready();
|
|
697
|
+
this.cryptoIsReady = true;
|
|
693
698
|
}
|
|
694
699
|
getAccount(accountIndex = 0, keyIndex = 0) {
|
|
695
700
|
if (this._walletSecret == void 0)
|
|
@@ -713,10 +718,11 @@ var EmbeddedWallet = class extends WalletStaticMethods {
|
|
|
713
718
|
stakeKeyHex: stakeKey.hex()
|
|
714
719
|
};
|
|
715
720
|
if (dRepKey) {
|
|
716
|
-
const { pubDRepKey, dRepIDBech32, dRepIDHash } = WalletStaticMethods.getDRepKey(dRepKey, this._networkId);
|
|
721
|
+
const { pubDRepKey, dRepIDBech32, dRepIDHash, dRepIDCip105 } = WalletStaticMethods.getDRepKey(dRepKey, this._networkId);
|
|
717
722
|
_account.pubDRepKey = pubDRepKey;
|
|
718
723
|
_account.dRepIDBech32 = dRepIDBech32;
|
|
719
724
|
_account.dRepIDHash = dRepIDHash;
|
|
725
|
+
_account.dRepIDCip105 = dRepIDCip105;
|
|
720
726
|
}
|
|
721
727
|
return _account;
|
|
722
728
|
}
|
|
@@ -943,7 +949,6 @@ import {
|
|
|
943
949
|
} from "@meshsdk/common";
|
|
944
950
|
import {
|
|
945
951
|
addressToBech32,
|
|
946
|
-
blake2b,
|
|
947
952
|
CardanoSDKUtil,
|
|
948
953
|
deserializeAddress,
|
|
949
954
|
deserializeTx as deserializeTx3,
|
|
@@ -953,7 +958,7 @@ import {
|
|
|
953
958
|
Ed25519PublicKeyHex as Ed25519PublicKeyHex2,
|
|
954
959
|
fromTxUnspentOutput,
|
|
955
960
|
fromValue,
|
|
956
|
-
hexToBech32,
|
|
961
|
+
hexToBech32 as hexToBech322,
|
|
957
962
|
Serialization as Serialization2,
|
|
958
963
|
toAddress as toAddress2,
|
|
959
964
|
Transaction as Transaction2,
|
|
@@ -1012,7 +1017,7 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1012
1017
|
return wallets;
|
|
1013
1018
|
}
|
|
1014
1019
|
/**
|
|
1015
|
-
* 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
|
|
1020
|
+
* 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.
|
|
1016
1021
|
*
|
|
1017
1022
|
* 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.
|
|
1018
1023
|
*
|
|
@@ -1218,7 +1223,7 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1218
1223
|
/**
|
|
1219
1224
|
* Submits the signed transaction to the blockchain network.
|
|
1220
1225
|
*
|
|
1221
|
-
* As wallets should already have this ability to submit transaction, we allow
|
|
1226
|
+
* 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.
|
|
1222
1227
|
*
|
|
1223
1228
|
* @param tx
|
|
1224
1229
|
* @returns a transaction hash
|
|
@@ -1324,19 +1329,18 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1324
1329
|
* The connected wallet account provides the account's public DRep Key, derivation as described in CIP-0105.
|
|
1325
1330
|
* 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.
|
|
1326
1331
|
*
|
|
1327
|
-
* @returns
|
|
1332
|
+
* @returns DRep object
|
|
1328
1333
|
*/
|
|
1329
1334
|
async getDRep() {
|
|
1335
|
+
const pubDRepKey = await this.getPubDRepKey();
|
|
1330
1336
|
try {
|
|
1331
|
-
if (
|
|
1332
|
-
const
|
|
1333
|
-
const
|
|
1334
|
-
const csldRepIdKeyHash = blake2b(28).update(Buffer.from(dRepKey, "hex")).digest("hex");
|
|
1335
|
-
const dRepId = hexToBech32("drep", csldRepIdKeyHash);
|
|
1337
|
+
if (pubDRepKey === void 0) return void 0;
|
|
1338
|
+
const { dRepIDHash } = await _BrowserWallet.dRepKeyToDRepID(pubDRepKey);
|
|
1339
|
+
const dRepIDCip105 = hexToBech322("drep", dRepIDHash);
|
|
1336
1340
|
return {
|
|
1337
|
-
publicKey:
|
|
1341
|
+
publicKey: pubDRepKey,
|
|
1338
1342
|
publicKeyHash: dRepIDHash,
|
|
1339
|
-
dRepIDCip105
|
|
1343
|
+
dRepIDCip105
|
|
1340
1344
|
};
|
|
1341
1345
|
} catch (e) {
|
|
1342
1346
|
console.error(e);
|
|
@@ -1352,15 +1356,8 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1352
1356
|
async getPubDRepKey() {
|
|
1353
1357
|
try {
|
|
1354
1358
|
if (this._walletInstance.cip95 === void 0) return void 0;
|
|
1355
|
-
const
|
|
1356
|
-
|
|
1357
|
-
const csldRepIdKeyHash = blake2b(28).update(Buffer.from(dRepKey, "hex")).digest("hex");
|
|
1358
|
-
const dRepId = hexToBech32("drep", csldRepIdKeyHash);
|
|
1359
|
-
return {
|
|
1360
|
-
pubDRepKey: dRepKey,
|
|
1361
|
-
dRepIDHash,
|
|
1362
|
-
dRepIDBech32: dRepId
|
|
1363
|
-
};
|
|
1359
|
+
const pubDRepKey = await this._walletInstance.cip95.getPubDRepKey();
|
|
1360
|
+
return pubDRepKey;
|
|
1364
1361
|
} catch (e) {
|
|
1365
1362
|
console.error(e);
|
|
1366
1363
|
return void 0;
|
|
@@ -1419,8 +1416,7 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1419
1416
|
if (window.cardano[walletName] === void 0) return void 0;
|
|
1420
1417
|
const wallet = window.cardano[walletName];
|
|
1421
1418
|
if (extensions.length > 0) {
|
|
1422
|
-
|
|
1423
|
-
return wallet.enable({ extensions: _extensions });
|
|
1419
|
+
return wallet.enable({ extensions });
|
|
1424
1420
|
} else {
|
|
1425
1421
|
return wallet?.enable();
|
|
1426
1422
|
}
|
|
@@ -1696,7 +1692,7 @@ var MeshWallet = class {
|
|
|
1696
1692
|
* @returns void
|
|
1697
1693
|
*/
|
|
1698
1694
|
async init() {
|
|
1699
|
-
if (this._wallet) {
|
|
1695
|
+
if (this._wallet && !this._wallet.cryptoIsReady) {
|
|
1700
1696
|
await this._wallet.init();
|
|
1701
1697
|
this.getAddressesFromWallet(this._wallet);
|
|
1702
1698
|
}
|
|
@@ -1716,6 +1712,7 @@ var MeshWallet = class {
|
|
|
1716
1712
|
* @returns a list of assets and their quantities
|
|
1717
1713
|
*/
|
|
1718
1714
|
async getBalance() {
|
|
1715
|
+
await this.init();
|
|
1719
1716
|
const utxos = await this.getUnspentOutputs();
|
|
1720
1717
|
const assets = /* @__PURE__ */ new Map();
|
|
1721
1718
|
utxos.map((utxo) => {
|
|
@@ -1742,8 +1739,12 @@ var MeshWallet = class {
|
|
|
1742
1739
|
*
|
|
1743
1740
|
* @returns an address
|
|
1744
1741
|
*/
|
|
1745
|
-
async getChangeAddress() {
|
|
1746
|
-
|
|
1742
|
+
async getChangeAddress(addressType = "payment") {
|
|
1743
|
+
await this.init();
|
|
1744
|
+
if (this.addresses.baseAddressBech32 && addressType === "payment") {
|
|
1745
|
+
return this.addresses.baseAddressBech32;
|
|
1746
|
+
}
|
|
1747
|
+
return this.addresses.enterpriseAddressBech32;
|
|
1747
1748
|
}
|
|
1748
1749
|
/**
|
|
1749
1750
|
* 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).
|
|
@@ -1754,6 +1755,7 @@ var MeshWallet = class {
|
|
|
1754
1755
|
* @returns a list of UTXOs
|
|
1755
1756
|
*/
|
|
1756
1757
|
async getCollateral(addressType = "payment") {
|
|
1758
|
+
await this.init();
|
|
1757
1759
|
const utxos = await this.getCollateralUnspentOutput(addressType);
|
|
1758
1760
|
return utxos.map((utxo, i) => {
|
|
1759
1761
|
return fromTxUnspentOutput2(utxo);
|
|
@@ -1776,6 +1778,7 @@ var MeshWallet = class {
|
|
|
1776
1778
|
* @returns a list of UTXOs
|
|
1777
1779
|
*/
|
|
1778
1780
|
async getCollateralUnspentOutput(addressType = "payment") {
|
|
1781
|
+
await this.init();
|
|
1779
1782
|
const utxos = await this.getUnspentOutputs(addressType);
|
|
1780
1783
|
const pureAdaUtxos = utxos.filter((utxo) => {
|
|
1781
1784
|
return utxo.output().amount().multiasset() === void 0;
|
|
@@ -1794,10 +1797,16 @@ var MeshWallet = class {
|
|
|
1794
1797
|
* The connected wallet account provides the account's public DRep Key, derivation as described in CIP-0105.
|
|
1795
1798
|
* 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.
|
|
1796
1799
|
*
|
|
1797
|
-
* @returns
|
|
1800
|
+
* @returns DRep object
|
|
1798
1801
|
*/
|
|
1799
1802
|
async getDRep() {
|
|
1800
|
-
|
|
1803
|
+
await this.init();
|
|
1804
|
+
if (this.addresses.pubDRepKey && this.addresses.dRepIDHash && this.addresses.dRepIDCip105)
|
|
1805
|
+
return {
|
|
1806
|
+
publicKey: this.addresses.pubDRepKey,
|
|
1807
|
+
publicKeyHash: this.addresses.dRepIDHash,
|
|
1808
|
+
dRepIDCip105: this.addresses.dRepIDCip105
|
|
1809
|
+
};
|
|
1801
1810
|
return void 0;
|
|
1802
1811
|
}
|
|
1803
1812
|
/**
|
|
@@ -1841,6 +1850,7 @@ var MeshWallet = class {
|
|
|
1841
1850
|
* @returns a list of UTXOs
|
|
1842
1851
|
*/
|
|
1843
1852
|
async getUsedUTxOs(addressType = "payment") {
|
|
1853
|
+
await this.init();
|
|
1844
1854
|
return await this.getUnspentOutputs(addressType);
|
|
1845
1855
|
}
|
|
1846
1856
|
/**
|
|
@@ -1861,6 +1871,7 @@ var MeshWallet = class {
|
|
|
1861
1871
|
* @returns a signature
|
|
1862
1872
|
*/
|
|
1863
1873
|
async signData(payload, address) {
|
|
1874
|
+
await this.init();
|
|
1864
1875
|
if (!this._wallet) {
|
|
1865
1876
|
throw new Error(
|
|
1866
1877
|
"[MeshWallet] Read only wallet does not support signing data."
|
|
@@ -1884,6 +1895,7 @@ var MeshWallet = class {
|
|
|
1884
1895
|
* @returns a signed transaction in CBOR
|
|
1885
1896
|
*/
|
|
1886
1897
|
async signTx(unsignedTx, partialSign = false) {
|
|
1898
|
+
await this.init();
|
|
1887
1899
|
if (!this._wallet) {
|
|
1888
1900
|
throw new Error(
|
|
1889
1901
|
"[MeshWallet] Read only wallet does not support signing data."
|
|
@@ -1910,6 +1922,7 @@ var MeshWallet = class {
|
|
|
1910
1922
|
* @returns array of signed transactions CborHex string
|
|
1911
1923
|
*/
|
|
1912
1924
|
async signTxs(unsignedTxs, partialSign = false) {
|
|
1925
|
+
await this.init();
|
|
1913
1926
|
if (!this._wallet) {
|
|
1914
1927
|
throw new Error(
|
|
1915
1928
|
"[MeshWallet] Read only wallet does not support signing data."
|
|
@@ -1925,7 +1938,7 @@ var MeshWallet = class {
|
|
|
1925
1938
|
/**
|
|
1926
1939
|
* Submits the signed transaction to the blockchain network.
|
|
1927
1940
|
*
|
|
1928
|
-
* As wallets should already have this ability to submit transaction, we allow
|
|
1941
|
+
* 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.
|
|
1929
1942
|
*
|
|
1930
1943
|
* @param tx - a signed transaction in CBOR
|
|
1931
1944
|
* @returns a transaction hash
|
|
@@ -2048,7 +2061,8 @@ var MeshWallet = class {
|
|
|
2048
2061
|
return {
|
|
2049
2062
|
pubDRepKey: this.addresses.pubDRepKey,
|
|
2050
2063
|
dRepIDBech32: this.addresses.dRepIDBech32,
|
|
2051
|
-
dRepIDHash: this.addresses.dRepIDHash
|
|
2064
|
+
dRepIDHash: this.addresses.dRepIDHash,
|
|
2065
|
+
dRepIDCip105: this.addresses.dRepIDCip105
|
|
2052
2066
|
};
|
|
2053
2067
|
}
|
|
2054
2068
|
/**
|
|
@@ -2075,7 +2089,8 @@ var MeshWallet = class {
|
|
|
2075
2089
|
rewardAddressBech32: account.rewardAddressBech32,
|
|
2076
2090
|
pubDRepKey: account.pubDRepKey,
|
|
2077
2091
|
dRepIDBech32: account.dRepIDBech32,
|
|
2078
|
-
dRepIDHash: account.dRepIDHash
|
|
2092
|
+
dRepIDHash: account.dRepIDHash,
|
|
2093
|
+
dRepIDCip105: account.dRepIDCip105
|
|
2079
2094
|
};
|
|
2080
2095
|
}
|
|
2081
2096
|
buildAddressFromBech32Address(address) {
|
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.41",
|
|
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.41",
|
|
39
|
+
"@meshsdk/core-cst": "1.9.0-beta.41",
|
|
40
|
+
"@meshsdk/transaction": "1.9.0-beta.41",
|
|
41
41
|
"@simplewebauthn/browser": "^13.0.0"
|
|
42
42
|
},
|
|
43
43
|
"prettier": "@meshsdk/configs/prettier",
|