@meshsdk/wallet 1.9.0-beta.49 → 1.9.0-beta.50

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
@@ -709,6 +709,7 @@ var EmbeddedWallet = class extends WalletStaticMethods {
709
709
  };
710
710
  if (dRepKey) {
711
711
  const { pubDRepKey, dRepIDBech32, dRepIDHash, dRepIDCip105 } = WalletStaticMethods.getDRepKey(dRepKey, this._networkId);
712
+ _account.drepKey = dRepKey;
712
713
  _account.pubDRepKey = pubDRepKey;
713
714
  _account.dRepIDBech32 = dRepIDBech32;
714
715
  _account.dRepIDHash = dRepIDHash;
@@ -758,15 +759,26 @@ var EmbeddedWallet = class extends WalletStaticMethods {
758
759
  * @param unsignedTx - a transaction in CBOR
759
760
  * @param accountIndex account index (default: 0)
760
761
  * @param keyIndex key index (default: 0)
762
+ * @param accountType - type of the account (default: payment)
761
763
  * @returns VkeyWitness
762
764
  */
763
- signTx(unsignedTx, accountIndex = 0, keyIndex = 0) {
765
+ signTx(unsignedTx, accountIndex = 0, keyIndex = 0, accountType = "payment") {
764
766
  try {
765
767
  const txHash = (0, import_core_cst.deserializeTxHash)((0, import_core_cst.resolveTxHash)(unsignedTx));
766
- const { paymentKey } = this.getAccount(accountIndex, keyIndex);
768
+ const { paymentKey, stakeKey, drepKey } = this.getAccount(
769
+ accountIndex,
770
+ keyIndex
771
+ );
772
+ let key = paymentKey;
773
+ if (accountType === "stake") {
774
+ key = stakeKey;
775
+ } else if (accountType === "drep") {
776
+ if (!drepKey) throw new Error("DRep key not found");
777
+ key = drepKey;
778
+ }
767
779
  const vKeyWitness = new import_core_cst.VkeyWitness(
768
- paymentKey.toPublic().hex(),
769
- paymentKey.sign((0, import_core_cst.HexBlob)(txHash)).hex()
780
+ key.toPublic().hex(),
781
+ key.sign((0, import_core_cst.HexBlob)(txHash)).hex()
770
782
  );
771
783
  return vKeyWitness;
772
784
  } catch (error) {
@@ -1583,6 +1595,7 @@ var import_core_cst5 = require("@meshsdk/core-cst");
1583
1595
  var import_transaction = require("@meshsdk/transaction");
1584
1596
  var MeshWallet = class {
1585
1597
  _keyType;
1598
+ _accountType = "payment";
1586
1599
  _wallet;
1587
1600
  _accountIndex = 0;
1588
1601
  _keyIndex = 0;
@@ -1597,6 +1610,7 @@ var MeshWallet = class {
1597
1610
  if (options.submitter) this._submitter = options.submitter;
1598
1611
  if (options.accountIndex) this._accountIndex = options.accountIndex;
1599
1612
  if (options.keyIndex) this._keyIndex = options.keyIndex;
1613
+ if (options.accountType) this._accountType = options.accountType;
1600
1614
  switch (options.key.type) {
1601
1615
  case "root":
1602
1616
  this._wallet = new EmbeddedWallet({
@@ -1863,7 +1877,8 @@ var MeshWallet = class {
1863
1877
  const newSignatures = this._wallet.signTx(
1864
1878
  unsignedTx,
1865
1879
  this._accountIndex,
1866
- this._keyIndex
1880
+ this._keyIndex,
1881
+ this._accountType
1867
1882
  );
1868
1883
  let signedTx = EmbeddedWallet.addWitnessSets(unsignedTx, [newSignatures]);
1869
1884
  return signedTx;
package/dist/index.d.cts CHANGED
@@ -378,6 +378,7 @@ declare function register({ serverUrl, username, }: {
378
378
  errorCode?: undefined;
379
379
  }>;
380
380
 
381
+ type AccountType = "payment" | "stake" | "drep";
381
382
  type Account = {
382
383
  baseAddress: Address;
383
384
  enterpriseAddress: Address;
@@ -389,6 +390,7 @@ type Account = {
389
390
  stakeKey: Ed25519PrivateKey;
390
391
  paymentKeyHex: string;
391
392
  stakeKeyHex: string;
393
+ drepKey?: Ed25519PrivateKey;
392
394
  pubDRepKey?: string;
393
395
  dRepIDBech32?: DRepID;
394
396
  dRepIDHash?: Ed25519KeyHashHex;
@@ -459,9 +461,10 @@ declare class EmbeddedWallet extends WalletStaticMethods {
459
461
  * @param unsignedTx - a transaction in CBOR
460
462
  * @param accountIndex account index (default: 0)
461
463
  * @param keyIndex key index (default: 0)
464
+ * @param accountType - type of the account (default: payment)
462
465
  * @returns VkeyWitness
463
466
  */
464
- signTx(unsignedTx: string, accountIndex?: number, keyIndex?: number): VkeyWitness;
467
+ signTx(unsignedTx: string, accountIndex?: number, keyIndex?: number, accountType?: AccountType): VkeyWitness;
465
468
  }
466
469
 
467
470
  type CreateMeshWalletOptions = {
@@ -487,6 +490,7 @@ type CreateMeshWalletOptions = {
487
490
  };
488
491
  accountIndex?: number;
489
492
  keyIndex?: number;
493
+ accountType?: AccountType;
490
494
  };
491
495
  /**
492
496
  * Mesh Wallet provides a set of APIs to interact with the blockchain. This wallet is compatible with Mesh transaction builders.
@@ -517,6 +521,7 @@ type CreateMeshWalletOptions = {
517
521
  */
518
522
  declare class MeshWallet implements IWallet {
519
523
  private readonly _keyType;
524
+ private readonly _accountType;
520
525
  private readonly _wallet;
521
526
  private readonly _accountIndex;
522
527
  private readonly _keyIndex;
@@ -753,4 +758,4 @@ declare class MeshWallet implements IWallet {
753
758
  private buildAddressFromBech32Address;
754
759
  }
755
760
 
756
- 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
@@ -378,6 +378,7 @@ declare function register({ serverUrl, username, }: {
378
378
  errorCode?: undefined;
379
379
  }>;
380
380
 
381
+ type AccountType = "payment" | "stake" | "drep";
381
382
  type Account = {
382
383
  baseAddress: Address;
383
384
  enterpriseAddress: Address;
@@ -389,6 +390,7 @@ type Account = {
389
390
  stakeKey: Ed25519PrivateKey;
390
391
  paymentKeyHex: string;
391
392
  stakeKeyHex: string;
393
+ drepKey?: Ed25519PrivateKey;
392
394
  pubDRepKey?: string;
393
395
  dRepIDBech32?: DRepID;
394
396
  dRepIDHash?: Ed25519KeyHashHex;
@@ -459,9 +461,10 @@ declare class EmbeddedWallet extends WalletStaticMethods {
459
461
  * @param unsignedTx - a transaction in CBOR
460
462
  * @param accountIndex account index (default: 0)
461
463
  * @param keyIndex key index (default: 0)
464
+ * @param accountType - type of the account (default: payment)
462
465
  * @returns VkeyWitness
463
466
  */
464
- signTx(unsignedTx: string, accountIndex?: number, keyIndex?: number): VkeyWitness;
467
+ signTx(unsignedTx: string, accountIndex?: number, keyIndex?: number, accountType?: AccountType): VkeyWitness;
465
468
  }
466
469
 
467
470
  type CreateMeshWalletOptions = {
@@ -487,6 +490,7 @@ type CreateMeshWalletOptions = {
487
490
  };
488
491
  accountIndex?: number;
489
492
  keyIndex?: number;
493
+ accountType?: AccountType;
490
494
  };
491
495
  /**
492
496
  * Mesh Wallet provides a set of APIs to interact with the blockchain. This wallet is compatible with Mesh transaction builders.
@@ -517,6 +521,7 @@ type CreateMeshWalletOptions = {
517
521
  */
518
522
  declare class MeshWallet implements IWallet {
519
523
  private readonly _keyType;
524
+ private readonly _accountType;
520
525
  private readonly _wallet;
521
526
  private readonly _accountIndex;
522
527
  private readonly _keyIndex;
@@ -753,4 +758,4 @@ declare class MeshWallet implements IWallet {
753
758
  private buildAddressFromBech32Address;
754
759
  }
755
760
 
756
- 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
@@ -719,6 +719,7 @@ var EmbeddedWallet = class extends WalletStaticMethods {
719
719
  };
720
720
  if (dRepKey) {
721
721
  const { pubDRepKey, dRepIDBech32, dRepIDHash, dRepIDCip105 } = WalletStaticMethods.getDRepKey(dRepKey, this._networkId);
722
+ _account.drepKey = dRepKey;
722
723
  _account.pubDRepKey = pubDRepKey;
723
724
  _account.dRepIDBech32 = dRepIDBech32;
724
725
  _account.dRepIDHash = dRepIDHash;
@@ -768,15 +769,26 @@ var EmbeddedWallet = class extends WalletStaticMethods {
768
769
  * @param unsignedTx - a transaction in CBOR
769
770
  * @param accountIndex account index (default: 0)
770
771
  * @param keyIndex key index (default: 0)
772
+ * @param accountType - type of the account (default: payment)
771
773
  * @returns VkeyWitness
772
774
  */
773
- signTx(unsignedTx, accountIndex = 0, keyIndex = 0) {
775
+ signTx(unsignedTx, accountIndex = 0, keyIndex = 0, accountType = "payment") {
774
776
  try {
775
777
  const txHash = deserializeTxHash(resolveTxHash(unsignedTx));
776
- const { paymentKey } = this.getAccount(accountIndex, keyIndex);
778
+ const { paymentKey, stakeKey, drepKey } = this.getAccount(
779
+ accountIndex,
780
+ keyIndex
781
+ );
782
+ let key = paymentKey;
783
+ if (accountType === "stake") {
784
+ key = stakeKey;
785
+ } else if (accountType === "drep") {
786
+ if (!drepKey) throw new Error("DRep key not found");
787
+ key = drepKey;
788
+ }
777
789
  const vKeyWitness = new VkeyWitness(
778
- paymentKey.toPublic().hex(),
779
- paymentKey.sign(HexBlob(txHash)).hex()
790
+ key.toPublic().hex(),
791
+ key.sign(HexBlob(txHash)).hex()
780
792
  );
781
793
  return vKeyWitness;
782
794
  } catch (error) {
@@ -1630,6 +1642,7 @@ import {
1630
1642
  import { Transaction as Transaction3 } from "@meshsdk/transaction";
1631
1643
  var MeshWallet = class {
1632
1644
  _keyType;
1645
+ _accountType = "payment";
1633
1646
  _wallet;
1634
1647
  _accountIndex = 0;
1635
1648
  _keyIndex = 0;
@@ -1644,6 +1657,7 @@ var MeshWallet = class {
1644
1657
  if (options.submitter) this._submitter = options.submitter;
1645
1658
  if (options.accountIndex) this._accountIndex = options.accountIndex;
1646
1659
  if (options.keyIndex) this._keyIndex = options.keyIndex;
1660
+ if (options.accountType) this._accountType = options.accountType;
1647
1661
  switch (options.key.type) {
1648
1662
  case "root":
1649
1663
  this._wallet = new EmbeddedWallet({
@@ -1910,7 +1924,8 @@ var MeshWallet = class {
1910
1924
  const newSignatures = this._wallet.signTx(
1911
1925
  unsignedTx,
1912
1926
  this._accountIndex,
1913
- this._keyIndex
1927
+ this._keyIndex,
1928
+ this._accountType
1914
1929
  );
1915
1930
  let signedTx = EmbeddedWallet.addWitnessSets(unsignedTx, [newSignatures]);
1916
1931
  return signedTx;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshsdk/wallet",
3
- "version": "1.9.0-beta.49",
3
+ "version": "1.9.0-beta.50",
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.49",
39
- "@meshsdk/core-cst": "1.9.0-beta.49",
40
- "@meshsdk/transaction": "1.9.0-beta.49",
38
+ "@meshsdk/common": "1.9.0-beta.50",
39
+ "@meshsdk/core-cst": "1.9.0-beta.50",
40
+ "@meshsdk/transaction": "1.9.0-beta.50",
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
+ }