@meshsdk/wallet 1.9.0-beta.7 → 1.9.0-beta.70
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 +78 -41
- package/dist/index.d.cts +27 -20
- package/dist/index.d.ts +27 -20
- package/dist/index.js +80 -43
- package/package.json +5 -5
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,12 @@ 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);
|
|
712
|
+
_account.drepKey = dRepKey;
|
|
708
713
|
_account.pubDRepKey = pubDRepKey;
|
|
709
714
|
_account.dRepIDBech32 = dRepIDBech32;
|
|
710
715
|
_account.dRepIDHash = dRepIDHash;
|
|
716
|
+
_account.dRepIDCip105 = dRepIDCip105;
|
|
711
717
|
}
|
|
712
718
|
return _account;
|
|
713
719
|
}
|
|
@@ -729,7 +735,13 @@ var EmbeddedWallet = class extends WalletStaticMethods {
|
|
|
729
735
|
*/
|
|
730
736
|
signData(address, payload, accountIndex = 0, keyIndex = 0) {
|
|
731
737
|
try {
|
|
732
|
-
const {
|
|
738
|
+
const {
|
|
739
|
+
baseAddress,
|
|
740
|
+
enterpriseAddress,
|
|
741
|
+
rewardAddress,
|
|
742
|
+
paymentKey,
|
|
743
|
+
stakeKey
|
|
744
|
+
} = this.getAccount(accountIndex, keyIndex);
|
|
733
745
|
const foundAddress = [baseAddress, enterpriseAddress, rewardAddress].find(
|
|
734
746
|
(a) => a.toBech32() === address
|
|
735
747
|
);
|
|
@@ -739,7 +751,7 @@ var EmbeddedWallet = class extends WalletStaticMethods {
|
|
|
739
751
|
);
|
|
740
752
|
return (0, import_core_cst.signData)(payload, {
|
|
741
753
|
address: import_core_cst.Address.fromBech32(address),
|
|
742
|
-
key: paymentKey
|
|
754
|
+
key: address === rewardAddress.toBech32() ? stakeKey : paymentKey
|
|
743
755
|
});
|
|
744
756
|
} catch (error) {
|
|
745
757
|
throw new Error(
|
|
@@ -753,15 +765,26 @@ var EmbeddedWallet = class extends WalletStaticMethods {
|
|
|
753
765
|
* @param unsignedTx - a transaction in CBOR
|
|
754
766
|
* @param accountIndex account index (default: 0)
|
|
755
767
|
* @param keyIndex key index (default: 0)
|
|
768
|
+
* @param accountType - type of the account (default: payment)
|
|
756
769
|
* @returns VkeyWitness
|
|
757
770
|
*/
|
|
758
|
-
signTx(unsignedTx, accountIndex = 0, keyIndex = 0) {
|
|
771
|
+
signTx(unsignedTx, accountIndex = 0, keyIndex = 0, accountType = "payment") {
|
|
759
772
|
try {
|
|
760
773
|
const txHash = (0, import_core_cst.deserializeTxHash)((0, import_core_cst.resolveTxHash)(unsignedTx));
|
|
761
|
-
const { paymentKey } = this.getAccount(
|
|
774
|
+
const { paymentKey, stakeKey, drepKey } = this.getAccount(
|
|
775
|
+
accountIndex,
|
|
776
|
+
keyIndex
|
|
777
|
+
);
|
|
778
|
+
let key = paymentKey;
|
|
779
|
+
if (accountType === "stake") {
|
|
780
|
+
key = stakeKey;
|
|
781
|
+
} else if (accountType === "drep") {
|
|
782
|
+
if (!drepKey) throw new Error("DRep key not found");
|
|
783
|
+
key = drepKey;
|
|
784
|
+
}
|
|
762
785
|
const vKeyWitness = new import_core_cst.VkeyWitness(
|
|
763
|
-
|
|
764
|
-
|
|
786
|
+
key.toPublic().hex(),
|
|
787
|
+
key.sign((0, import_core_cst.HexBlob)(txHash)).hex()
|
|
765
788
|
);
|
|
766
789
|
return vKeyWitness;
|
|
767
790
|
} catch (error) {
|
|
@@ -981,7 +1004,7 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
981
1004
|
return wallets;
|
|
982
1005
|
}
|
|
983
1006
|
/**
|
|
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
|
|
1007
|
+
* 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
1008
|
*
|
|
986
1009
|
* 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
1010
|
*
|
|
@@ -1104,18 +1127,19 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1104
1127
|
* @param address - optional, if not provided, the first staking address will be used
|
|
1105
1128
|
* @returns a signature
|
|
1106
1129
|
*/
|
|
1107
|
-
async signData(payload, address) {
|
|
1130
|
+
async signData(payload, address, convertFromUTF8 = true) {
|
|
1108
1131
|
if (address === void 0) {
|
|
1109
1132
|
address = (await this.getUsedAddresses())[0];
|
|
1110
1133
|
if (address === void 0) {
|
|
1111
1134
|
address = await this.getChangeAddress();
|
|
1112
1135
|
}
|
|
1113
1136
|
}
|
|
1137
|
+
const _payload = convertFromUTF8 ? (0, import_common2.fromUTF8)(payload) : payload;
|
|
1114
1138
|
if (address.startsWith("drep1")) {
|
|
1115
|
-
return this._walletInstance.cip95.signData(address,
|
|
1139
|
+
return this._walletInstance.cip95.signData(address, _payload);
|
|
1116
1140
|
}
|
|
1117
1141
|
const signerAddress = (0, import_core_cst3.toAddress)(address).toBytes().toString();
|
|
1118
|
-
return this._walletInstance.signData(signerAddress,
|
|
1142
|
+
return this._walletInstance.signData(signerAddress, _payload);
|
|
1119
1143
|
}
|
|
1120
1144
|
/**
|
|
1121
1145
|
* Requests user to sign the provided transaction (tx). The wallet should ask the user for permission, and if given, try to sign the supplied body and return a signed transaction. partialSign should be true if the transaction provided requires multiple signatures.
|
|
@@ -1187,7 +1211,7 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1187
1211
|
/**
|
|
1188
1212
|
* Submits the signed transaction to the blockchain network.
|
|
1189
1213
|
*
|
|
1190
|
-
* As wallets should already have this ability to submit transaction, we allow
|
|
1214
|
+
* 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
1215
|
*
|
|
1192
1216
|
* @param tx
|
|
1193
1217
|
* @returns a transaction hash
|
|
@@ -1293,19 +1317,18 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1293
1317
|
* The connected wallet account provides the account's public DRep Key, derivation as described in CIP-0105.
|
|
1294
1318
|
* 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
1319
|
*
|
|
1296
|
-
* @returns
|
|
1320
|
+
* @returns DRep object
|
|
1297
1321
|
*/
|
|
1298
1322
|
async getDRep() {
|
|
1323
|
+
const pubDRepKey = await this.getPubDRepKey();
|
|
1299
1324
|
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);
|
|
1325
|
+
if (pubDRepKey === void 0) return void 0;
|
|
1326
|
+
const { dRepIDHash } = await _BrowserWallet.dRepKeyToDRepID(pubDRepKey);
|
|
1327
|
+
const dRepIDCip105 = (0, import_core_cst3.hexToBech32)("drep", dRepIDHash);
|
|
1305
1328
|
return {
|
|
1306
|
-
publicKey:
|
|
1329
|
+
publicKey: pubDRepKey,
|
|
1307
1330
|
publicKeyHash: dRepIDHash,
|
|
1308
|
-
dRepIDCip105
|
|
1331
|
+
dRepIDCip105
|
|
1309
1332
|
};
|
|
1310
1333
|
} catch (e) {
|
|
1311
1334
|
console.error(e);
|
|
@@ -1321,15 +1344,8 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1321
1344
|
async getPubDRepKey() {
|
|
1322
1345
|
try {
|
|
1323
1346
|
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
|
-
};
|
|
1347
|
+
const pubDRepKey = await this._walletInstance.cip95.getPubDRepKey();
|
|
1348
|
+
return pubDRepKey;
|
|
1333
1349
|
} catch (e) {
|
|
1334
1350
|
console.error(e);
|
|
1335
1351
|
return void 0;
|
|
@@ -1388,8 +1404,7 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1388
1404
|
if (window.cardano[walletName] === void 0) return void 0;
|
|
1389
1405
|
const wallet = window.cardano[walletName];
|
|
1390
1406
|
if (extensions.length > 0) {
|
|
1391
|
-
|
|
1392
|
-
return wallet.enable({ extensions: _extensions });
|
|
1407
|
+
return wallet.enable({ extensions });
|
|
1393
1408
|
} else {
|
|
1394
1409
|
return wallet?.enable();
|
|
1395
1410
|
}
|
|
@@ -1586,6 +1601,7 @@ var import_core_cst5 = require("@meshsdk/core-cst");
|
|
|
1586
1601
|
var import_transaction = require("@meshsdk/transaction");
|
|
1587
1602
|
var MeshWallet = class {
|
|
1588
1603
|
_keyType;
|
|
1604
|
+
_accountType = "payment";
|
|
1589
1605
|
_wallet;
|
|
1590
1606
|
_accountIndex = 0;
|
|
1591
1607
|
_keyIndex = 0;
|
|
@@ -1600,6 +1616,7 @@ var MeshWallet = class {
|
|
|
1600
1616
|
if (options.submitter) this._submitter = options.submitter;
|
|
1601
1617
|
if (options.accountIndex) this._accountIndex = options.accountIndex;
|
|
1602
1618
|
if (options.keyIndex) this._keyIndex = options.keyIndex;
|
|
1619
|
+
if (options.accountType) this._accountType = options.accountType;
|
|
1603
1620
|
switch (options.key.type) {
|
|
1604
1621
|
case "root":
|
|
1605
1622
|
this._wallet = new EmbeddedWallet({
|
|
@@ -1649,7 +1666,7 @@ var MeshWallet = class {
|
|
|
1649
1666
|
* @returns void
|
|
1650
1667
|
*/
|
|
1651
1668
|
async init() {
|
|
1652
|
-
if (this._wallet) {
|
|
1669
|
+
if (this._wallet && !this._wallet.cryptoIsReady) {
|
|
1653
1670
|
await this._wallet.init();
|
|
1654
1671
|
this.getAddressesFromWallet(this._wallet);
|
|
1655
1672
|
}
|
|
@@ -1669,6 +1686,7 @@ var MeshWallet = class {
|
|
|
1669
1686
|
* @returns a list of assets and their quantities
|
|
1670
1687
|
*/
|
|
1671
1688
|
async getBalance() {
|
|
1689
|
+
await this.init();
|
|
1672
1690
|
const utxos = await this.getUnspentOutputs();
|
|
1673
1691
|
const assets = /* @__PURE__ */ new Map();
|
|
1674
1692
|
utxos.map((utxo) => {
|
|
@@ -1695,8 +1713,12 @@ var MeshWallet = class {
|
|
|
1695
1713
|
*
|
|
1696
1714
|
* @returns an address
|
|
1697
1715
|
*/
|
|
1698
|
-
async getChangeAddress() {
|
|
1699
|
-
|
|
1716
|
+
async getChangeAddress(addressType = "payment") {
|
|
1717
|
+
await this.init();
|
|
1718
|
+
if (this.addresses.baseAddressBech32 && addressType === "payment") {
|
|
1719
|
+
return this.addresses.baseAddressBech32;
|
|
1720
|
+
}
|
|
1721
|
+
return this.addresses.enterpriseAddressBech32;
|
|
1700
1722
|
}
|
|
1701
1723
|
/**
|
|
1702
1724
|
* 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 +1729,7 @@ var MeshWallet = class {
|
|
|
1707
1729
|
* @returns a list of UTXOs
|
|
1708
1730
|
*/
|
|
1709
1731
|
async getCollateral(addressType = "payment") {
|
|
1732
|
+
await this.init();
|
|
1710
1733
|
const utxos = await this.getCollateralUnspentOutput(addressType);
|
|
1711
1734
|
return utxos.map((utxo, i) => {
|
|
1712
1735
|
return (0, import_core_cst5.fromTxUnspentOutput)(utxo);
|
|
@@ -1729,6 +1752,7 @@ var MeshWallet = class {
|
|
|
1729
1752
|
* @returns a list of UTXOs
|
|
1730
1753
|
*/
|
|
1731
1754
|
async getCollateralUnspentOutput(addressType = "payment") {
|
|
1755
|
+
await this.init();
|
|
1732
1756
|
const utxos = await this.getUnspentOutputs(addressType);
|
|
1733
1757
|
const pureAdaUtxos = utxos.filter((utxo) => {
|
|
1734
1758
|
return utxo.output().amount().multiasset() === void 0;
|
|
@@ -1747,10 +1771,16 @@ var MeshWallet = class {
|
|
|
1747
1771
|
* The connected wallet account provides the account's public DRep Key, derivation as described in CIP-0105.
|
|
1748
1772
|
* 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
1773
|
*
|
|
1750
|
-
* @returns
|
|
1774
|
+
* @returns DRep object
|
|
1751
1775
|
*/
|
|
1752
1776
|
async getDRep() {
|
|
1753
|
-
|
|
1777
|
+
await this.init();
|
|
1778
|
+
if (this.addresses.pubDRepKey && this.addresses.dRepIDHash && this.addresses.dRepIDCip105)
|
|
1779
|
+
return {
|
|
1780
|
+
publicKey: this.addresses.pubDRepKey,
|
|
1781
|
+
publicKeyHash: this.addresses.dRepIDHash,
|
|
1782
|
+
dRepIDCip105: this.addresses.dRepIDCip105
|
|
1783
|
+
};
|
|
1754
1784
|
return void 0;
|
|
1755
1785
|
}
|
|
1756
1786
|
/**
|
|
@@ -1794,6 +1824,7 @@ var MeshWallet = class {
|
|
|
1794
1824
|
* @returns a list of UTXOs
|
|
1795
1825
|
*/
|
|
1796
1826
|
async getUsedUTxOs(addressType = "payment") {
|
|
1827
|
+
await this.init();
|
|
1797
1828
|
return await this.getUnspentOutputs(addressType);
|
|
1798
1829
|
}
|
|
1799
1830
|
/**
|
|
@@ -1814,6 +1845,7 @@ var MeshWallet = class {
|
|
|
1814
1845
|
* @returns a signature
|
|
1815
1846
|
*/
|
|
1816
1847
|
async signData(payload, address) {
|
|
1848
|
+
await this.init();
|
|
1817
1849
|
if (!this._wallet) {
|
|
1818
1850
|
throw new Error(
|
|
1819
1851
|
"[MeshWallet] Read only wallet does not support signing data."
|
|
@@ -1837,6 +1869,7 @@ var MeshWallet = class {
|
|
|
1837
1869
|
* @returns a signed transaction in CBOR
|
|
1838
1870
|
*/
|
|
1839
1871
|
async signTx(unsignedTx, partialSign = false) {
|
|
1872
|
+
await this.init();
|
|
1840
1873
|
if (!this._wallet) {
|
|
1841
1874
|
throw new Error(
|
|
1842
1875
|
"[MeshWallet] Read only wallet does not support signing data."
|
|
@@ -1850,7 +1883,8 @@ var MeshWallet = class {
|
|
|
1850
1883
|
const newSignatures = this._wallet.signTx(
|
|
1851
1884
|
unsignedTx,
|
|
1852
1885
|
this._accountIndex,
|
|
1853
|
-
this._keyIndex
|
|
1886
|
+
this._keyIndex,
|
|
1887
|
+
this._accountType
|
|
1854
1888
|
);
|
|
1855
1889
|
let signedTx = EmbeddedWallet.addWitnessSets(unsignedTx, [newSignatures]);
|
|
1856
1890
|
return signedTx;
|
|
@@ -1863,6 +1897,7 @@ var MeshWallet = class {
|
|
|
1863
1897
|
* @returns array of signed transactions CborHex string
|
|
1864
1898
|
*/
|
|
1865
1899
|
async signTxs(unsignedTxs, partialSign = false) {
|
|
1900
|
+
await this.init();
|
|
1866
1901
|
if (!this._wallet) {
|
|
1867
1902
|
throw new Error(
|
|
1868
1903
|
"[MeshWallet] Read only wallet does not support signing data."
|
|
@@ -1878,7 +1913,7 @@ var MeshWallet = class {
|
|
|
1878
1913
|
/**
|
|
1879
1914
|
* Submits the signed transaction to the blockchain network.
|
|
1880
1915
|
*
|
|
1881
|
-
* As wallets should already have this ability to submit transaction, we allow
|
|
1916
|
+
* 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
1917
|
*
|
|
1883
1918
|
* @param tx - a signed transaction in CBOR
|
|
1884
1919
|
* @returns a transaction hash
|
|
@@ -2001,7 +2036,8 @@ var MeshWallet = class {
|
|
|
2001
2036
|
return {
|
|
2002
2037
|
pubDRepKey: this.addresses.pubDRepKey,
|
|
2003
2038
|
dRepIDBech32: this.addresses.dRepIDBech32,
|
|
2004
|
-
dRepIDHash: this.addresses.dRepIDHash
|
|
2039
|
+
dRepIDHash: this.addresses.dRepIDHash,
|
|
2040
|
+
dRepIDCip105: this.addresses.dRepIDCip105
|
|
2005
2041
|
};
|
|
2006
2042
|
}
|
|
2007
2043
|
/**
|
|
@@ -2028,7 +2064,8 @@ var MeshWallet = class {
|
|
|
2028
2064
|
rewardAddressBech32: account.rewardAddressBech32,
|
|
2029
2065
|
pubDRepKey: account.pubDRepKey,
|
|
2030
2066
|
dRepIDBech32: account.dRepIDBech32,
|
|
2031
|
-
dRepIDHash: account.dRepIDHash
|
|
2067
|
+
dRepIDHash: account.dRepIDHash,
|
|
2068
|
+
dRepIDCip105: account.dRepIDCip105
|
|
2032
2069
|
};
|
|
2033
2070
|
}
|
|
2034
2071
|
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.
|
|
@@ -220,7 +220,7 @@ declare class BrowserWallet implements IWallet {
|
|
|
220
220
|
* @param address - optional, if not provided, the first staking address will be used
|
|
221
221
|
* @returns a signature
|
|
222
222
|
*/
|
|
223
|
-
signData(payload: string, address?: string): Promise<DataSignature>;
|
|
223
|
+
signData(payload: string, address?: string | undefined, convertFromUTF8?: boolean): Promise<DataSignature>;
|
|
224
224
|
/**
|
|
225
225
|
* Requests user to sign the provided transaction (tx). The wallet should ask the user for permission, and if given, try to sign the supplied body and return a signed transaction. partialSign should be true if the transaction provided requires multiple signatures.
|
|
226
226
|
*
|
|
@@ -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[];
|
|
@@ -382,6 +378,7 @@ declare function register({ serverUrl, username, }: {
|
|
|
382
378
|
errorCode?: undefined;
|
|
383
379
|
}>;
|
|
384
380
|
|
|
381
|
+
type AccountType = "payment" | "stake" | "drep";
|
|
385
382
|
type Account = {
|
|
386
383
|
baseAddress: Address;
|
|
387
384
|
enterpriseAddress: Address;
|
|
@@ -393,9 +390,11 @@ type Account = {
|
|
|
393
390
|
stakeKey: Ed25519PrivateKey;
|
|
394
391
|
paymentKeyHex: string;
|
|
395
392
|
stakeKeyHex: string;
|
|
393
|
+
drepKey?: Ed25519PrivateKey;
|
|
396
394
|
pubDRepKey?: string;
|
|
397
395
|
dRepIDBech32?: DRepID;
|
|
398
396
|
dRepIDHash?: Ed25519KeyHashHex;
|
|
397
|
+
dRepIDCip105?: string;
|
|
399
398
|
};
|
|
400
399
|
type EmbeddedWalletKeyType = {
|
|
401
400
|
type: "root";
|
|
@@ -429,6 +428,7 @@ declare class WalletStaticMethods {
|
|
|
429
428
|
pubDRepKey: string;
|
|
430
429
|
dRepIDBech32: DRepID;
|
|
431
430
|
dRepIDHash: Ed25519KeyHashHex;
|
|
431
|
+
dRepIDCip105: string;
|
|
432
432
|
};
|
|
433
433
|
static generateMnemonic(strength?: number): string[];
|
|
434
434
|
static addWitnessSets(txHex: string, witnesses: VkeyWitness[]): string;
|
|
@@ -436,6 +436,7 @@ declare class WalletStaticMethods {
|
|
|
436
436
|
declare class EmbeddedWallet extends WalletStaticMethods {
|
|
437
437
|
private readonly _walletSecret?;
|
|
438
438
|
private readonly _networkId;
|
|
439
|
+
cryptoIsReady: boolean;
|
|
439
440
|
constructor(options: CreateEmbeddedWalletOptions);
|
|
440
441
|
init(): Promise<void>;
|
|
441
442
|
getAccount(accountIndex?: number, keyIndex?: number): Account;
|
|
@@ -460,9 +461,10 @@ declare class EmbeddedWallet extends WalletStaticMethods {
|
|
|
460
461
|
* @param unsignedTx - a transaction in CBOR
|
|
461
462
|
* @param accountIndex account index (default: 0)
|
|
462
463
|
* @param keyIndex key index (default: 0)
|
|
464
|
+
* @param accountType - type of the account (default: payment)
|
|
463
465
|
* @returns VkeyWitness
|
|
464
466
|
*/
|
|
465
|
-
signTx(unsignedTx: string, accountIndex?: number, keyIndex?: number): VkeyWitness;
|
|
467
|
+
signTx(unsignedTx: string, accountIndex?: number, keyIndex?: number, accountType?: AccountType): VkeyWitness;
|
|
466
468
|
}
|
|
467
469
|
|
|
468
470
|
type CreateMeshWalletOptions = {
|
|
@@ -488,6 +490,7 @@ type CreateMeshWalletOptions = {
|
|
|
488
490
|
};
|
|
489
491
|
accountIndex?: number;
|
|
490
492
|
keyIndex?: number;
|
|
493
|
+
accountType?: AccountType;
|
|
491
494
|
};
|
|
492
495
|
/**
|
|
493
496
|
* Mesh Wallet provides a set of APIs to interact with the blockchain. This wallet is compatible with Mesh transaction builders.
|
|
@@ -501,12 +504,12 @@ type CreateMeshWalletOptions = {
|
|
|
501
504
|
* ```javascript
|
|
502
505
|
* import { MeshWallet, BlockfrostProvider } from '@meshsdk/core';
|
|
503
506
|
*
|
|
504
|
-
* const
|
|
507
|
+
* const provider = new BlockfrostProvider('<BLOCKFROST_API_KEY>');
|
|
505
508
|
*
|
|
506
509
|
* const wallet = new MeshWallet({
|
|
507
510
|
* networkId: 0,
|
|
508
|
-
* fetcher:
|
|
509
|
-
* submitter:
|
|
511
|
+
* fetcher: provider,
|
|
512
|
+
* submitter: provider,
|
|
510
513
|
* key: {
|
|
511
514
|
* type: 'mnemonic',
|
|
512
515
|
* words: ["solution","solution","solution","solution","solution",","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution"],
|
|
@@ -518,6 +521,7 @@ type CreateMeshWalletOptions = {
|
|
|
518
521
|
*/
|
|
519
522
|
declare class MeshWallet implements IWallet {
|
|
520
523
|
private readonly _keyType;
|
|
524
|
+
private readonly _accountType;
|
|
521
525
|
private readonly _wallet;
|
|
522
526
|
private readonly _accountIndex;
|
|
523
527
|
private readonly _keyIndex;
|
|
@@ -534,6 +538,7 @@ declare class MeshWallet implements IWallet {
|
|
|
534
538
|
pubDRepKey?: string;
|
|
535
539
|
dRepIDBech32?: DRepID;
|
|
536
540
|
dRepIDHash?: Ed25519KeyHashHex;
|
|
541
|
+
dRepIDCip105?: string;
|
|
537
542
|
};
|
|
538
543
|
constructor(options: CreateMeshWalletOptions);
|
|
539
544
|
/**
|
|
@@ -555,6 +560,7 @@ declare class MeshWallet implements IWallet {
|
|
|
555
560
|
pubDRepKey?: string;
|
|
556
561
|
dRepIDBech32?: DRepID;
|
|
557
562
|
dRepIDHash?: Ed25519KeyHashHex;
|
|
563
|
+
dRepIDCip105?: string;
|
|
558
564
|
};
|
|
559
565
|
/**
|
|
560
566
|
* 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 +575,7 @@ declare class MeshWallet implements IWallet {
|
|
|
569
575
|
*
|
|
570
576
|
* @returns an address
|
|
571
577
|
*/
|
|
572
|
-
getChangeAddress(): Promise<string>;
|
|
578
|
+
getChangeAddress(addressType?: GetAddressType): Promise<string>;
|
|
573
579
|
/**
|
|
574
580
|
* 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
581
|
*
|
|
@@ -598,7 +604,7 @@ declare class MeshWallet implements IWallet {
|
|
|
598
604
|
* The connected wallet account provides the account's public DRep Key, derivation as described in CIP-0105.
|
|
599
605
|
* 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
606
|
*
|
|
601
|
-
* @returns
|
|
607
|
+
* @returns DRep object
|
|
602
608
|
*/
|
|
603
609
|
getDRep(): Promise<{
|
|
604
610
|
publicKey: string;
|
|
@@ -672,7 +678,7 @@ declare class MeshWallet implements IWallet {
|
|
|
672
678
|
/**
|
|
673
679
|
* Submits the signed transaction to the blockchain network.
|
|
674
680
|
*
|
|
675
|
-
* As wallets should already have this ability to submit transaction, we allow
|
|
681
|
+
* 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
682
|
*
|
|
677
683
|
* @param tx - a signed transaction in CBOR
|
|
678
684
|
* @returns a transaction hash
|
|
@@ -739,6 +745,7 @@ declare class MeshWallet implements IWallet {
|
|
|
739
745
|
pubDRepKey: string | undefined;
|
|
740
746
|
dRepIDBech32: string | undefined;
|
|
741
747
|
dRepIDHash: string | undefined;
|
|
748
|
+
dRepIDCip105: string | undefined;
|
|
742
749
|
};
|
|
743
750
|
/**
|
|
744
751
|
* Generate mnemonic or private key
|
|
@@ -751,4 +758,4 @@ declare class MeshWallet implements IWallet {
|
|
|
751
758
|
private buildAddressFromBech32Address;
|
|
752
759
|
}
|
|
753
760
|
|
|
754
|
-
export { type Account, AppWallet, type AppWalletKeyType, BrowserWallet, type CreateAppWalletOptions, type CreateEmbeddedWalletOptions, type CreateMeshWalletOptions, EmbeddedWallet, type EmbeddedWalletKeyType, MeshWallet, WalletStaticMethods, connect, login, register };
|
|
761
|
+
export { type Account, type AccountType, AppWallet, type AppWalletKeyType, BrowserWallet, type CreateAppWalletOptions, type CreateEmbeddedWalletOptions, type CreateMeshWalletOptions, EmbeddedWallet, type EmbeddedWalletKeyType, MeshWallet, WalletStaticMethods, connect, login, register };
|
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.
|
|
@@ -220,7 +220,7 @@ declare class BrowserWallet implements IWallet {
|
|
|
220
220
|
* @param address - optional, if not provided, the first staking address will be used
|
|
221
221
|
* @returns a signature
|
|
222
222
|
*/
|
|
223
|
-
signData(payload: string, address?: string): Promise<DataSignature>;
|
|
223
|
+
signData(payload: string, address?: string | undefined, convertFromUTF8?: boolean): Promise<DataSignature>;
|
|
224
224
|
/**
|
|
225
225
|
* Requests user to sign the provided transaction (tx). The wallet should ask the user for permission, and if given, try to sign the supplied body and return a signed transaction. partialSign should be true if the transaction provided requires multiple signatures.
|
|
226
226
|
*
|
|
@@ -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[];
|
|
@@ -382,6 +378,7 @@ declare function register({ serverUrl, username, }: {
|
|
|
382
378
|
errorCode?: undefined;
|
|
383
379
|
}>;
|
|
384
380
|
|
|
381
|
+
type AccountType = "payment" | "stake" | "drep";
|
|
385
382
|
type Account = {
|
|
386
383
|
baseAddress: Address;
|
|
387
384
|
enterpriseAddress: Address;
|
|
@@ -393,9 +390,11 @@ type Account = {
|
|
|
393
390
|
stakeKey: Ed25519PrivateKey;
|
|
394
391
|
paymentKeyHex: string;
|
|
395
392
|
stakeKeyHex: string;
|
|
393
|
+
drepKey?: Ed25519PrivateKey;
|
|
396
394
|
pubDRepKey?: string;
|
|
397
395
|
dRepIDBech32?: DRepID;
|
|
398
396
|
dRepIDHash?: Ed25519KeyHashHex;
|
|
397
|
+
dRepIDCip105?: string;
|
|
399
398
|
};
|
|
400
399
|
type EmbeddedWalletKeyType = {
|
|
401
400
|
type: "root";
|
|
@@ -429,6 +428,7 @@ declare class WalletStaticMethods {
|
|
|
429
428
|
pubDRepKey: string;
|
|
430
429
|
dRepIDBech32: DRepID;
|
|
431
430
|
dRepIDHash: Ed25519KeyHashHex;
|
|
431
|
+
dRepIDCip105: string;
|
|
432
432
|
};
|
|
433
433
|
static generateMnemonic(strength?: number): string[];
|
|
434
434
|
static addWitnessSets(txHex: string, witnesses: VkeyWitness[]): string;
|
|
@@ -436,6 +436,7 @@ declare class WalletStaticMethods {
|
|
|
436
436
|
declare class EmbeddedWallet extends WalletStaticMethods {
|
|
437
437
|
private readonly _walletSecret?;
|
|
438
438
|
private readonly _networkId;
|
|
439
|
+
cryptoIsReady: boolean;
|
|
439
440
|
constructor(options: CreateEmbeddedWalletOptions);
|
|
440
441
|
init(): Promise<void>;
|
|
441
442
|
getAccount(accountIndex?: number, keyIndex?: number): Account;
|
|
@@ -460,9 +461,10 @@ declare class EmbeddedWallet extends WalletStaticMethods {
|
|
|
460
461
|
* @param unsignedTx - a transaction in CBOR
|
|
461
462
|
* @param accountIndex account index (default: 0)
|
|
462
463
|
* @param keyIndex key index (default: 0)
|
|
464
|
+
* @param accountType - type of the account (default: payment)
|
|
463
465
|
* @returns VkeyWitness
|
|
464
466
|
*/
|
|
465
|
-
signTx(unsignedTx: string, accountIndex?: number, keyIndex?: number): VkeyWitness;
|
|
467
|
+
signTx(unsignedTx: string, accountIndex?: number, keyIndex?: number, accountType?: AccountType): VkeyWitness;
|
|
466
468
|
}
|
|
467
469
|
|
|
468
470
|
type CreateMeshWalletOptions = {
|
|
@@ -488,6 +490,7 @@ type CreateMeshWalletOptions = {
|
|
|
488
490
|
};
|
|
489
491
|
accountIndex?: number;
|
|
490
492
|
keyIndex?: number;
|
|
493
|
+
accountType?: AccountType;
|
|
491
494
|
};
|
|
492
495
|
/**
|
|
493
496
|
* Mesh Wallet provides a set of APIs to interact with the blockchain. This wallet is compatible with Mesh transaction builders.
|
|
@@ -501,12 +504,12 @@ type CreateMeshWalletOptions = {
|
|
|
501
504
|
* ```javascript
|
|
502
505
|
* import { MeshWallet, BlockfrostProvider } from '@meshsdk/core';
|
|
503
506
|
*
|
|
504
|
-
* const
|
|
507
|
+
* const provider = new BlockfrostProvider('<BLOCKFROST_API_KEY>');
|
|
505
508
|
*
|
|
506
509
|
* const wallet = new MeshWallet({
|
|
507
510
|
* networkId: 0,
|
|
508
|
-
* fetcher:
|
|
509
|
-
* submitter:
|
|
511
|
+
* fetcher: provider,
|
|
512
|
+
* submitter: provider,
|
|
510
513
|
* key: {
|
|
511
514
|
* type: 'mnemonic',
|
|
512
515
|
* words: ["solution","solution","solution","solution","solution",","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution"],
|
|
@@ -518,6 +521,7 @@ type CreateMeshWalletOptions = {
|
|
|
518
521
|
*/
|
|
519
522
|
declare class MeshWallet implements IWallet {
|
|
520
523
|
private readonly _keyType;
|
|
524
|
+
private readonly _accountType;
|
|
521
525
|
private readonly _wallet;
|
|
522
526
|
private readonly _accountIndex;
|
|
523
527
|
private readonly _keyIndex;
|
|
@@ -534,6 +538,7 @@ declare class MeshWallet implements IWallet {
|
|
|
534
538
|
pubDRepKey?: string;
|
|
535
539
|
dRepIDBech32?: DRepID;
|
|
536
540
|
dRepIDHash?: Ed25519KeyHashHex;
|
|
541
|
+
dRepIDCip105?: string;
|
|
537
542
|
};
|
|
538
543
|
constructor(options: CreateMeshWalletOptions);
|
|
539
544
|
/**
|
|
@@ -555,6 +560,7 @@ declare class MeshWallet implements IWallet {
|
|
|
555
560
|
pubDRepKey?: string;
|
|
556
561
|
dRepIDBech32?: DRepID;
|
|
557
562
|
dRepIDHash?: Ed25519KeyHashHex;
|
|
563
|
+
dRepIDCip105?: string;
|
|
558
564
|
};
|
|
559
565
|
/**
|
|
560
566
|
* 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 +575,7 @@ declare class MeshWallet implements IWallet {
|
|
|
569
575
|
*
|
|
570
576
|
* @returns an address
|
|
571
577
|
*/
|
|
572
|
-
getChangeAddress(): Promise<string>;
|
|
578
|
+
getChangeAddress(addressType?: GetAddressType): Promise<string>;
|
|
573
579
|
/**
|
|
574
580
|
* 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
581
|
*
|
|
@@ -598,7 +604,7 @@ declare class MeshWallet implements IWallet {
|
|
|
598
604
|
* The connected wallet account provides the account's public DRep Key, derivation as described in CIP-0105.
|
|
599
605
|
* 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
606
|
*
|
|
601
|
-
* @returns
|
|
607
|
+
* @returns DRep object
|
|
602
608
|
*/
|
|
603
609
|
getDRep(): Promise<{
|
|
604
610
|
publicKey: string;
|
|
@@ -672,7 +678,7 @@ declare class MeshWallet implements IWallet {
|
|
|
672
678
|
/**
|
|
673
679
|
* Submits the signed transaction to the blockchain network.
|
|
674
680
|
*
|
|
675
|
-
* As wallets should already have this ability to submit transaction, we allow
|
|
681
|
+
* 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
682
|
*
|
|
677
683
|
* @param tx - a signed transaction in CBOR
|
|
678
684
|
* @returns a transaction hash
|
|
@@ -739,6 +745,7 @@ declare class MeshWallet implements IWallet {
|
|
|
739
745
|
pubDRepKey: string | undefined;
|
|
740
746
|
dRepIDBech32: string | undefined;
|
|
741
747
|
dRepIDHash: string | undefined;
|
|
748
|
+
dRepIDCip105: string | undefined;
|
|
742
749
|
};
|
|
743
750
|
/**
|
|
744
751
|
* Generate mnemonic or private key
|
|
@@ -751,4 +758,4 @@ declare class MeshWallet implements IWallet {
|
|
|
751
758
|
private buildAddressFromBech32Address;
|
|
752
759
|
}
|
|
753
760
|
|
|
754
|
-
export { type Account, AppWallet, type AppWalletKeyType, BrowserWallet, type CreateAppWalletOptions, type CreateEmbeddedWalletOptions, type CreateMeshWalletOptions, EmbeddedWallet, type EmbeddedWalletKeyType, MeshWallet, WalletStaticMethods, connect, login, register };
|
|
761
|
+
export { type Account, type AccountType, AppWallet, type AppWalletKeyType, BrowserWallet, type CreateAppWalletOptions, type CreateEmbeddedWalletOptions, type CreateMeshWalletOptions, EmbeddedWallet, type EmbeddedWalletKeyType, MeshWallet, WalletStaticMethods, connect, login, register };
|
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,12 @@ 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);
|
|
722
|
+
_account.drepKey = dRepKey;
|
|
717
723
|
_account.pubDRepKey = pubDRepKey;
|
|
718
724
|
_account.dRepIDBech32 = dRepIDBech32;
|
|
719
725
|
_account.dRepIDHash = dRepIDHash;
|
|
726
|
+
_account.dRepIDCip105 = dRepIDCip105;
|
|
720
727
|
}
|
|
721
728
|
return _account;
|
|
722
729
|
}
|
|
@@ -738,7 +745,13 @@ var EmbeddedWallet = class extends WalletStaticMethods {
|
|
|
738
745
|
*/
|
|
739
746
|
signData(address, payload, accountIndex = 0, keyIndex = 0) {
|
|
740
747
|
try {
|
|
741
|
-
const {
|
|
748
|
+
const {
|
|
749
|
+
baseAddress,
|
|
750
|
+
enterpriseAddress,
|
|
751
|
+
rewardAddress,
|
|
752
|
+
paymentKey,
|
|
753
|
+
stakeKey
|
|
754
|
+
} = this.getAccount(accountIndex, keyIndex);
|
|
742
755
|
const foundAddress = [baseAddress, enterpriseAddress, rewardAddress].find(
|
|
743
756
|
(a) => a.toBech32() === address
|
|
744
757
|
);
|
|
@@ -748,7 +761,7 @@ var EmbeddedWallet = class extends WalletStaticMethods {
|
|
|
748
761
|
);
|
|
749
762
|
return signData(payload, {
|
|
750
763
|
address: Address.fromBech32(address),
|
|
751
|
-
key: paymentKey
|
|
764
|
+
key: address === rewardAddress.toBech32() ? stakeKey : paymentKey
|
|
752
765
|
});
|
|
753
766
|
} catch (error) {
|
|
754
767
|
throw new Error(
|
|
@@ -762,15 +775,26 @@ var EmbeddedWallet = class extends WalletStaticMethods {
|
|
|
762
775
|
* @param unsignedTx - a transaction in CBOR
|
|
763
776
|
* @param accountIndex account index (default: 0)
|
|
764
777
|
* @param keyIndex key index (default: 0)
|
|
778
|
+
* @param accountType - type of the account (default: payment)
|
|
765
779
|
* @returns VkeyWitness
|
|
766
780
|
*/
|
|
767
|
-
signTx(unsignedTx, accountIndex = 0, keyIndex = 0) {
|
|
781
|
+
signTx(unsignedTx, accountIndex = 0, keyIndex = 0, accountType = "payment") {
|
|
768
782
|
try {
|
|
769
783
|
const txHash = deserializeTxHash(resolveTxHash(unsignedTx));
|
|
770
|
-
const { paymentKey } = this.getAccount(
|
|
784
|
+
const { paymentKey, stakeKey, drepKey } = this.getAccount(
|
|
785
|
+
accountIndex,
|
|
786
|
+
keyIndex
|
|
787
|
+
);
|
|
788
|
+
let key = paymentKey;
|
|
789
|
+
if (accountType === "stake") {
|
|
790
|
+
key = stakeKey;
|
|
791
|
+
} else if (accountType === "drep") {
|
|
792
|
+
if (!drepKey) throw new Error("DRep key not found");
|
|
793
|
+
key = drepKey;
|
|
794
|
+
}
|
|
771
795
|
const vKeyWitness = new VkeyWitness(
|
|
772
|
-
|
|
773
|
-
|
|
796
|
+
key.toPublic().hex(),
|
|
797
|
+
key.sign(HexBlob(txHash)).hex()
|
|
774
798
|
);
|
|
775
799
|
return vKeyWitness;
|
|
776
800
|
} catch (error) {
|
|
@@ -943,7 +967,6 @@ import {
|
|
|
943
967
|
} from "@meshsdk/common";
|
|
944
968
|
import {
|
|
945
969
|
addressToBech32,
|
|
946
|
-
blake2b,
|
|
947
970
|
CardanoSDKUtil,
|
|
948
971
|
deserializeAddress,
|
|
949
972
|
deserializeTx as deserializeTx3,
|
|
@@ -953,7 +976,7 @@ import {
|
|
|
953
976
|
Ed25519PublicKeyHex as Ed25519PublicKeyHex2,
|
|
954
977
|
fromTxUnspentOutput,
|
|
955
978
|
fromValue,
|
|
956
|
-
hexToBech32,
|
|
979
|
+
hexToBech32 as hexToBech322,
|
|
957
980
|
Serialization as Serialization2,
|
|
958
981
|
toAddress as toAddress2,
|
|
959
982
|
Transaction as Transaction2,
|
|
@@ -1012,7 +1035,7 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1012
1035
|
return wallets;
|
|
1013
1036
|
}
|
|
1014
1037
|
/**
|
|
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
|
|
1038
|
+
* 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
1039
|
*
|
|
1017
1040
|
* 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
1041
|
*
|
|
@@ -1135,18 +1158,19 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1135
1158
|
* @param address - optional, if not provided, the first staking address will be used
|
|
1136
1159
|
* @returns a signature
|
|
1137
1160
|
*/
|
|
1138
|
-
async signData(payload, address) {
|
|
1161
|
+
async signData(payload, address, convertFromUTF8 = true) {
|
|
1139
1162
|
if (address === void 0) {
|
|
1140
1163
|
address = (await this.getUsedAddresses())[0];
|
|
1141
1164
|
if (address === void 0) {
|
|
1142
1165
|
address = await this.getChangeAddress();
|
|
1143
1166
|
}
|
|
1144
1167
|
}
|
|
1168
|
+
const _payload = convertFromUTF8 ? fromUTF8(payload) : payload;
|
|
1145
1169
|
if (address.startsWith("drep1")) {
|
|
1146
|
-
return this._walletInstance.cip95.signData(address,
|
|
1170
|
+
return this._walletInstance.cip95.signData(address, _payload);
|
|
1147
1171
|
}
|
|
1148
1172
|
const signerAddress = toAddress2(address).toBytes().toString();
|
|
1149
|
-
return this._walletInstance.signData(signerAddress,
|
|
1173
|
+
return this._walletInstance.signData(signerAddress, _payload);
|
|
1150
1174
|
}
|
|
1151
1175
|
/**
|
|
1152
1176
|
* Requests user to sign the provided transaction (tx). The wallet should ask the user for permission, and if given, try to sign the supplied body and return a signed transaction. partialSign should be true if the transaction provided requires multiple signatures.
|
|
@@ -1218,7 +1242,7 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1218
1242
|
/**
|
|
1219
1243
|
* Submits the signed transaction to the blockchain network.
|
|
1220
1244
|
*
|
|
1221
|
-
* As wallets should already have this ability to submit transaction, we allow
|
|
1245
|
+
* 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
1246
|
*
|
|
1223
1247
|
* @param tx
|
|
1224
1248
|
* @returns a transaction hash
|
|
@@ -1324,19 +1348,18 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1324
1348
|
* The connected wallet account provides the account's public DRep Key, derivation as described in CIP-0105.
|
|
1325
1349
|
* 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
1350
|
*
|
|
1327
|
-
* @returns
|
|
1351
|
+
* @returns DRep object
|
|
1328
1352
|
*/
|
|
1329
1353
|
async getDRep() {
|
|
1354
|
+
const pubDRepKey = await this.getPubDRepKey();
|
|
1330
1355
|
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);
|
|
1356
|
+
if (pubDRepKey === void 0) return void 0;
|
|
1357
|
+
const { dRepIDHash } = await _BrowserWallet.dRepKeyToDRepID(pubDRepKey);
|
|
1358
|
+
const dRepIDCip105 = hexToBech322("drep", dRepIDHash);
|
|
1336
1359
|
return {
|
|
1337
|
-
publicKey:
|
|
1360
|
+
publicKey: pubDRepKey,
|
|
1338
1361
|
publicKeyHash: dRepIDHash,
|
|
1339
|
-
dRepIDCip105
|
|
1362
|
+
dRepIDCip105
|
|
1340
1363
|
};
|
|
1341
1364
|
} catch (e) {
|
|
1342
1365
|
console.error(e);
|
|
@@ -1352,15 +1375,8 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1352
1375
|
async getPubDRepKey() {
|
|
1353
1376
|
try {
|
|
1354
1377
|
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
|
-
};
|
|
1378
|
+
const pubDRepKey = await this._walletInstance.cip95.getPubDRepKey();
|
|
1379
|
+
return pubDRepKey;
|
|
1364
1380
|
} catch (e) {
|
|
1365
1381
|
console.error(e);
|
|
1366
1382
|
return void 0;
|
|
@@ -1419,8 +1435,7 @@ var BrowserWallet = class _BrowserWallet {
|
|
|
1419
1435
|
if (window.cardano[walletName] === void 0) return void 0;
|
|
1420
1436
|
const wallet = window.cardano[walletName];
|
|
1421
1437
|
if (extensions.length > 0) {
|
|
1422
|
-
|
|
1423
|
-
return wallet.enable({ extensions: _extensions });
|
|
1438
|
+
return wallet.enable({ extensions });
|
|
1424
1439
|
} else {
|
|
1425
1440
|
return wallet?.enable();
|
|
1426
1441
|
}
|
|
@@ -1633,6 +1648,7 @@ import {
|
|
|
1633
1648
|
import { Transaction as Transaction3 } from "@meshsdk/transaction";
|
|
1634
1649
|
var MeshWallet = class {
|
|
1635
1650
|
_keyType;
|
|
1651
|
+
_accountType = "payment";
|
|
1636
1652
|
_wallet;
|
|
1637
1653
|
_accountIndex = 0;
|
|
1638
1654
|
_keyIndex = 0;
|
|
@@ -1647,6 +1663,7 @@ var MeshWallet = class {
|
|
|
1647
1663
|
if (options.submitter) this._submitter = options.submitter;
|
|
1648
1664
|
if (options.accountIndex) this._accountIndex = options.accountIndex;
|
|
1649
1665
|
if (options.keyIndex) this._keyIndex = options.keyIndex;
|
|
1666
|
+
if (options.accountType) this._accountType = options.accountType;
|
|
1650
1667
|
switch (options.key.type) {
|
|
1651
1668
|
case "root":
|
|
1652
1669
|
this._wallet = new EmbeddedWallet({
|
|
@@ -1696,7 +1713,7 @@ var MeshWallet = class {
|
|
|
1696
1713
|
* @returns void
|
|
1697
1714
|
*/
|
|
1698
1715
|
async init() {
|
|
1699
|
-
if (this._wallet) {
|
|
1716
|
+
if (this._wallet && !this._wallet.cryptoIsReady) {
|
|
1700
1717
|
await this._wallet.init();
|
|
1701
1718
|
this.getAddressesFromWallet(this._wallet);
|
|
1702
1719
|
}
|
|
@@ -1716,6 +1733,7 @@ var MeshWallet = class {
|
|
|
1716
1733
|
* @returns a list of assets and their quantities
|
|
1717
1734
|
*/
|
|
1718
1735
|
async getBalance() {
|
|
1736
|
+
await this.init();
|
|
1719
1737
|
const utxos = await this.getUnspentOutputs();
|
|
1720
1738
|
const assets = /* @__PURE__ */ new Map();
|
|
1721
1739
|
utxos.map((utxo) => {
|
|
@@ -1742,8 +1760,12 @@ var MeshWallet = class {
|
|
|
1742
1760
|
*
|
|
1743
1761
|
* @returns an address
|
|
1744
1762
|
*/
|
|
1745
|
-
async getChangeAddress() {
|
|
1746
|
-
|
|
1763
|
+
async getChangeAddress(addressType = "payment") {
|
|
1764
|
+
await this.init();
|
|
1765
|
+
if (this.addresses.baseAddressBech32 && addressType === "payment") {
|
|
1766
|
+
return this.addresses.baseAddressBech32;
|
|
1767
|
+
}
|
|
1768
|
+
return this.addresses.enterpriseAddressBech32;
|
|
1747
1769
|
}
|
|
1748
1770
|
/**
|
|
1749
1771
|
* 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 +1776,7 @@ var MeshWallet = class {
|
|
|
1754
1776
|
* @returns a list of UTXOs
|
|
1755
1777
|
*/
|
|
1756
1778
|
async getCollateral(addressType = "payment") {
|
|
1779
|
+
await this.init();
|
|
1757
1780
|
const utxos = await this.getCollateralUnspentOutput(addressType);
|
|
1758
1781
|
return utxos.map((utxo, i) => {
|
|
1759
1782
|
return fromTxUnspentOutput2(utxo);
|
|
@@ -1776,6 +1799,7 @@ var MeshWallet = class {
|
|
|
1776
1799
|
* @returns a list of UTXOs
|
|
1777
1800
|
*/
|
|
1778
1801
|
async getCollateralUnspentOutput(addressType = "payment") {
|
|
1802
|
+
await this.init();
|
|
1779
1803
|
const utxos = await this.getUnspentOutputs(addressType);
|
|
1780
1804
|
const pureAdaUtxos = utxos.filter((utxo) => {
|
|
1781
1805
|
return utxo.output().amount().multiasset() === void 0;
|
|
@@ -1794,10 +1818,16 @@ var MeshWallet = class {
|
|
|
1794
1818
|
* The connected wallet account provides the account's public DRep Key, derivation as described in CIP-0105.
|
|
1795
1819
|
* 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
1820
|
*
|
|
1797
|
-
* @returns
|
|
1821
|
+
* @returns DRep object
|
|
1798
1822
|
*/
|
|
1799
1823
|
async getDRep() {
|
|
1800
|
-
|
|
1824
|
+
await this.init();
|
|
1825
|
+
if (this.addresses.pubDRepKey && this.addresses.dRepIDHash && this.addresses.dRepIDCip105)
|
|
1826
|
+
return {
|
|
1827
|
+
publicKey: this.addresses.pubDRepKey,
|
|
1828
|
+
publicKeyHash: this.addresses.dRepIDHash,
|
|
1829
|
+
dRepIDCip105: this.addresses.dRepIDCip105
|
|
1830
|
+
};
|
|
1801
1831
|
return void 0;
|
|
1802
1832
|
}
|
|
1803
1833
|
/**
|
|
@@ -1841,6 +1871,7 @@ var MeshWallet = class {
|
|
|
1841
1871
|
* @returns a list of UTXOs
|
|
1842
1872
|
*/
|
|
1843
1873
|
async getUsedUTxOs(addressType = "payment") {
|
|
1874
|
+
await this.init();
|
|
1844
1875
|
return await this.getUnspentOutputs(addressType);
|
|
1845
1876
|
}
|
|
1846
1877
|
/**
|
|
@@ -1861,6 +1892,7 @@ var MeshWallet = class {
|
|
|
1861
1892
|
* @returns a signature
|
|
1862
1893
|
*/
|
|
1863
1894
|
async signData(payload, address) {
|
|
1895
|
+
await this.init();
|
|
1864
1896
|
if (!this._wallet) {
|
|
1865
1897
|
throw new Error(
|
|
1866
1898
|
"[MeshWallet] Read only wallet does not support signing data."
|
|
@@ -1884,6 +1916,7 @@ var MeshWallet = class {
|
|
|
1884
1916
|
* @returns a signed transaction in CBOR
|
|
1885
1917
|
*/
|
|
1886
1918
|
async signTx(unsignedTx, partialSign = false) {
|
|
1919
|
+
await this.init();
|
|
1887
1920
|
if (!this._wallet) {
|
|
1888
1921
|
throw new Error(
|
|
1889
1922
|
"[MeshWallet] Read only wallet does not support signing data."
|
|
@@ -1897,7 +1930,8 @@ var MeshWallet = class {
|
|
|
1897
1930
|
const newSignatures = this._wallet.signTx(
|
|
1898
1931
|
unsignedTx,
|
|
1899
1932
|
this._accountIndex,
|
|
1900
|
-
this._keyIndex
|
|
1933
|
+
this._keyIndex,
|
|
1934
|
+
this._accountType
|
|
1901
1935
|
);
|
|
1902
1936
|
let signedTx = EmbeddedWallet.addWitnessSets(unsignedTx, [newSignatures]);
|
|
1903
1937
|
return signedTx;
|
|
@@ -1910,6 +1944,7 @@ var MeshWallet = class {
|
|
|
1910
1944
|
* @returns array of signed transactions CborHex string
|
|
1911
1945
|
*/
|
|
1912
1946
|
async signTxs(unsignedTxs, partialSign = false) {
|
|
1947
|
+
await this.init();
|
|
1913
1948
|
if (!this._wallet) {
|
|
1914
1949
|
throw new Error(
|
|
1915
1950
|
"[MeshWallet] Read only wallet does not support signing data."
|
|
@@ -1925,7 +1960,7 @@ var MeshWallet = class {
|
|
|
1925
1960
|
/**
|
|
1926
1961
|
* Submits the signed transaction to the blockchain network.
|
|
1927
1962
|
*
|
|
1928
|
-
* As wallets should already have this ability to submit transaction, we allow
|
|
1963
|
+
* 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
1964
|
*
|
|
1930
1965
|
* @param tx - a signed transaction in CBOR
|
|
1931
1966
|
* @returns a transaction hash
|
|
@@ -2048,7 +2083,8 @@ var MeshWallet = class {
|
|
|
2048
2083
|
return {
|
|
2049
2084
|
pubDRepKey: this.addresses.pubDRepKey,
|
|
2050
2085
|
dRepIDBech32: this.addresses.dRepIDBech32,
|
|
2051
|
-
dRepIDHash: this.addresses.dRepIDHash
|
|
2086
|
+
dRepIDHash: this.addresses.dRepIDHash,
|
|
2087
|
+
dRepIDCip105: this.addresses.dRepIDCip105
|
|
2052
2088
|
};
|
|
2053
2089
|
}
|
|
2054
2090
|
/**
|
|
@@ -2075,7 +2111,8 @@ var MeshWallet = class {
|
|
|
2075
2111
|
rewardAddressBech32: account.rewardAddressBech32,
|
|
2076
2112
|
pubDRepKey: account.pubDRepKey,
|
|
2077
2113
|
dRepIDBech32: account.dRepIDBech32,
|
|
2078
|
-
dRepIDHash: account.dRepIDHash
|
|
2114
|
+
dRepIDHash: account.dRepIDHash,
|
|
2115
|
+
dRepIDCip105: account.dRepIDCip105
|
|
2079
2116
|
};
|
|
2080
2117
|
}
|
|
2081
2118
|
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.70",
|
|
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.70",
|
|
39
|
+
"@meshsdk/core-cst": "1.9.0-beta.70",
|
|
40
|
+
"@meshsdk/transaction": "1.9.0-beta.70",
|
|
41
41
|
"@simplewebauthn/browser": "^13.0.0"
|
|
42
42
|
},
|
|
43
43
|
"prettier": "@meshsdk/configs/prettier",
|
|
@@ -52,4 +52,4 @@
|
|
|
52
52
|
"blockchain",
|
|
53
53
|
"sdk"
|
|
54
54
|
]
|
|
55
|
-
}
|
|
55
|
+
}
|