@meshsdk/wallet 1.7.8 → 1.7.10

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 CHANGED
@@ -216,6 +216,8 @@ function genBech32(encoding) {
216
216
  function encode(prefix, words, limit = 90) {
217
217
  if (typeof prefix !== "string")
218
218
  throw new Error(`bech32.encode prefix should be string, not ${typeof prefix}`);
219
+ if (words instanceof Uint8Array)
220
+ words = Array.from(words);
219
221
  if (!Array.isArray(words) || words.length && typeof words[0] !== "number")
220
222
  throw new Error(`bech32.encode words should be array of numbers, not ${typeof words}`);
221
223
  if (prefix.length === 0)
@@ -253,7 +255,19 @@ function genBech32(encoding) {
253
255
  const { prefix, words } = decode(str, false);
254
256
  return { prefix, words, bytes: fromWords(words) };
255
257
  }
256
- return { encode, decode, decodeToBytes, decodeUnsafe, fromWords, fromWordsUnsafe, toWords };
258
+ function encodeFromBytes(prefix, bytes) {
259
+ return encode(prefix, toWords(bytes));
260
+ }
261
+ return {
262
+ encode,
263
+ decode,
264
+ encodeFromBytes,
265
+ decodeToBytes,
266
+ decodeUnsafe,
267
+ fromWords,
268
+ fromWordsUnsafe,
269
+ toWords
270
+ };
257
271
  }
258
272
  var bech32 = /* @__PURE__ */ genBech32("bech32");
259
273
 
@@ -640,14 +654,11 @@ var BrowserWallet = class _BrowserWallet {
640
654
  * @returns a list of wallet names
641
655
  */
642
656
  static async getAvailableWallets({
643
- metamask = {
644
- network: "preprod"
645
- }
657
+ metamask = void 0
646
658
  } = {}) {
647
659
  if (window === void 0) return [];
648
660
  if (metamask) await checkIfMetamaskInstalled(metamask.network);
649
- const wallets = _BrowserWallet.getInstalledWallets();
650
- return wallets;
661
+ return _BrowserWallet.getInstalledWallets();
651
662
  }
652
663
  /**
653
664
  * Returns a list of wallets installed on user's device. Each wallet is an object with the following properties:
@@ -807,6 +818,9 @@ var BrowserWallet = class _BrowserWallet {
807
818
  if (address === void 0) {
808
819
  address = (await this.getUsedAddresses())[0];
809
820
  }
821
+ if (address.startsWith("drep1")) {
822
+ return this._walletInstance.cip95.signData(address, (0, import_common2.fromUTF8)(payload));
823
+ }
810
824
  const signerAddress = (0, import_core_cst3.toAddress)(address).toBytes().toString();
811
825
  return this._walletInstance.signData(signerAddress, (0, import_common2.fromUTF8)(payload));
812
826
  }
package/dist/index.d.cts CHANGED
@@ -44,6 +44,7 @@ interface Cip95WalletApi {
44
44
  getRegisteredPubStakeKeys: () => Promise<Ed25519PublicKeyHex[]>;
45
45
  getUnregisteredPubStakeKeys: () => Promise<Ed25519PublicKeyHex[]>;
46
46
  getPubDRepKey: () => Promise<Ed25519PublicKeyHex>;
47
+ signData(address: string, payload: string): Promise<DataSignature>;
47
48
  }
48
49
  type WalletInstance = Cip30WalletApi & Cip95WalletApi;
49
50
  type ExperimentalFeatures = {
@@ -102,6 +103,16 @@ declare global {
102
103
  cardano: Cardano;
103
104
  }
104
105
  }
106
+ /**
107
+ * Browser Wallet provides a set of APIs to interact with the blockchain. This wallet is compatible with Mesh transaction builders.
108
+ *
109
+ * These wallets APIs are in accordance to CIP-30, which defines the API for dApps to communicate with the user's wallet. Additional utility functions provided for developers that are useful for building dApps.
110
+ * ```javascript
111
+ * import { BrowserWallet } from '@meshsdk/core';
112
+ *
113
+ * const wallet = await BrowserWallet.enable('eternl');
114
+ * ```
115
+ */
105
116
  declare class BrowserWallet implements IInitiator, ISigner, ISubmitter {
106
117
  readonly _walletInstance: WalletInstance;
107
118
  readonly _walletName: string;
package/dist/index.d.ts CHANGED
@@ -44,6 +44,7 @@ interface Cip95WalletApi {
44
44
  getRegisteredPubStakeKeys: () => Promise<Ed25519PublicKeyHex[]>;
45
45
  getUnregisteredPubStakeKeys: () => Promise<Ed25519PublicKeyHex[]>;
46
46
  getPubDRepKey: () => Promise<Ed25519PublicKeyHex>;
47
+ signData(address: string, payload: string): Promise<DataSignature>;
47
48
  }
48
49
  type WalletInstance = Cip30WalletApi & Cip95WalletApi;
49
50
  type ExperimentalFeatures = {
@@ -102,6 +103,16 @@ declare global {
102
103
  cardano: Cardano;
103
104
  }
104
105
  }
106
+ /**
107
+ * Browser Wallet provides a set of APIs to interact with the blockchain. This wallet is compatible with Mesh transaction builders.
108
+ *
109
+ * These wallets APIs are in accordance to CIP-30, which defines the API for dApps to communicate with the user's wallet. Additional utility functions provided for developers that are useful for building dApps.
110
+ * ```javascript
111
+ * import { BrowserWallet } from '@meshsdk/core';
112
+ *
113
+ * const wallet = await BrowserWallet.enable('eternl');
114
+ * ```
115
+ */
105
116
  declare class BrowserWallet implements IInitiator, ISigner, ISubmitter {
106
117
  readonly _walletInstance: WalletInstance;
107
118
  readonly _walletName: string;
package/dist/index.js CHANGED
@@ -180,6 +180,8 @@ function genBech32(encoding) {
180
180
  function encode(prefix, words, limit = 90) {
181
181
  if (typeof prefix !== "string")
182
182
  throw new Error(`bech32.encode prefix should be string, not ${typeof prefix}`);
183
+ if (words instanceof Uint8Array)
184
+ words = Array.from(words);
183
185
  if (!Array.isArray(words) || words.length && typeof words[0] !== "number")
184
186
  throw new Error(`bech32.encode words should be array of numbers, not ${typeof words}`);
185
187
  if (prefix.length === 0)
@@ -217,7 +219,19 @@ function genBech32(encoding) {
217
219
  const { prefix, words } = decode(str, false);
218
220
  return { prefix, words, bytes: fromWords(words) };
219
221
  }
220
- return { encode, decode, decodeToBytes, decodeUnsafe, fromWords, fromWordsUnsafe, toWords };
222
+ function encodeFromBytes(prefix, bytes) {
223
+ return encode(prefix, toWords(bytes));
224
+ }
225
+ return {
226
+ encode,
227
+ decode,
228
+ encodeFromBytes,
229
+ decodeToBytes,
230
+ decodeUnsafe,
231
+ fromWords,
232
+ fromWordsUnsafe,
233
+ toWords
234
+ };
221
235
  }
222
236
  var bech32 = /* @__PURE__ */ genBech32("bech32");
223
237
 
@@ -596,7 +610,7 @@ import {
596
610
 
597
611
  // src/browser/metamask.ts
598
612
  import { initNufiDappCardanoSdk } from "@nufi/dapp-client-cardano";
599
- import nufiCoreSdk from "@nufi/dapp-client-core";
613
+ import publicNufiCoreSdk from "@nufi/dapp-client-core";
600
614
 
601
615
  // src/types/nufisnap.ts
602
616
  var nufiSnap = {
@@ -615,7 +629,7 @@ var nufiDomain = {
615
629
  };
616
630
  async function checkIfMetamaskInstalled(network = "preprod") {
617
631
  try {
618
- const _nufiCoreSdk = nufiCoreSdk.default;
632
+ const _nufiCoreSdk = publicNufiCoreSdk.default;
619
633
  if (Object.keys(nufiDomain).includes(network)) {
620
634
  _nufiCoreSdk.init(nufiDomain[network]);
621
635
  } else {
@@ -649,14 +663,11 @@ var BrowserWallet = class _BrowserWallet {
649
663
  * @returns a list of wallet names
650
664
  */
651
665
  static async getAvailableWallets({
652
- metamask = {
653
- network: "preprod"
654
- }
666
+ metamask = void 0
655
667
  } = {}) {
656
668
  if (window === void 0) return [];
657
669
  if (metamask) await checkIfMetamaskInstalled(metamask.network);
658
- const wallets = _BrowserWallet.getInstalledWallets();
659
- return wallets;
670
+ return _BrowserWallet.getInstalledWallets();
660
671
  }
661
672
  /**
662
673
  * Returns a list of wallets installed on user's device. Each wallet is an object with the following properties:
@@ -816,6 +827,9 @@ var BrowserWallet = class _BrowserWallet {
816
827
  if (address === void 0) {
817
828
  address = (await this.getUsedAddresses())[0];
818
829
  }
830
+ if (address.startsWith("drep1")) {
831
+ return this._walletInstance.cip95.signData(address, fromUTF8(payload));
832
+ }
819
833
  const signerAddress = toAddress2(address).toBytes().toString();
820
834
  return this._walletInstance.signData(signerAddress, fromUTF8(payload));
821
835
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshsdk/wallet",
3
- "version": "1.7.8",
3
+ "version": "1.7.10",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "browser": "./dist/index.js",
@@ -9,9 +9,9 @@
9
9
  "type": "module",
10
10
  "exports": {
11
11
  ".": {
12
+ "types": "./dist/index.d.ts",
12
13
  "import": "./dist/index.js",
13
- "require": "./dist/index.cjs",
14
- "types": "./dist/index.d.ts"
14
+ "require": "./dist/index.cjs"
15
15
  }
16
16
  },
17
17
  "files": [
@@ -35,12 +35,12 @@
35
35
  "typescript": "^5.3.3"
36
36
  },
37
37
  "dependencies": {
38
- "@meshsdk/common": "1.7.8",
39
- "@meshsdk/core-csl": "1.7.8",
40
- "@meshsdk/core-cst": "1.7.8",
41
- "@meshsdk/transaction": "1.7.8",
42
- "@nufi/dapp-client-cardano": "^0.3.1",
43
- "@nufi/dapp-client-core": "^0.3.1"
38
+ "@meshsdk/common": "1.7.10",
39
+ "@meshsdk/core-csl": "1.7.10",
40
+ "@meshsdk/core-cst": "1.7.10",
41
+ "@meshsdk/transaction": "1.7.10",
42
+ "@nufi/dapp-client-cardano": "0.3.5",
43
+ "@nufi/dapp-client-core": "0.3.5"
44
44
  },
45
45
  "prettier": "@meshsdk/configs/prettier",
46
46
  "publishConfig": {