@meshsdk/wallet 2.0.0-beta.1 → 2.0.0-beta.2

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/README.md CHANGED
@@ -127,3 +127,73 @@ However, due to our experiences with Cardano development, the return types defin
127
127
  `MeshWallet` is an attempt to extend the `BaseCardanoWallet` in such a way that there are extra endpoints that do this parsing of the CBOR hex returns in a more readibly consumable way.
128
128
 
129
129
  Probably the most relevant of these APIs would be the difference between `signTx` and `signTxReturnFullTx`. As the name of the API suggests, `signTxReturnFullTx` returns the transaction in FULL, with the extra vkey witnesses placed into the witness set. While `signTx` returns the signatures serialized in a transaction witness set, which requires extra manipulation using a serialization library to place the signatures in the transaction's witness set before it can be submitted.
130
+
131
+ ## CIP-30
132
+
133
+ Once a MeshWallet is set up, it is possible to use it as an instance of a CIP-30 wallet.
134
+
135
+ ```typescript
136
+ const meshWallet = await MeshWallet.fromMnemonic({
137
+ networkId: 0,
138
+ walletAddressType: AddressType.Base,
139
+ mnemonic: mnemonic,
140
+ fetcher: fetcher,
141
+ });
142
+
143
+ const meshWalletBalance = await meshWallet.getBalance();
144
+ const meshWalletChangeAddress = await meshWallet.getChangeAddress();
145
+ const meshWalletNetworkId = await meshWallet.getNetworkId();
146
+ const meshWalletCollateral = await meshWallet.getCollateral();
147
+ const meshWalletUtxos = await meshWallet.getUtxos();
148
+ const meshWalletRewardAddresses = await meshWallet.getRewardAddresses();
149
+
150
+ const meshWalletsignedData = await meshWallet.signData(
151
+ meshWalletChangeAddress,
152
+ "abc"
153
+ );
154
+ const signature = await meshWallet.signTx(transactionHex, true);
155
+ ```
156
+
157
+ ## Browser Wallet
158
+
159
+ `mesh-wallet` provides a class that helps with setting up Cardano Browser wallets.
160
+
161
+ Once enabled, the wallet object can be used the same way as a MeshWallet.
162
+
163
+ ```typescript
164
+ const browserWallet = await CardanoBrowserWallet.enable("eternl");
165
+
166
+ const browserBalance = await browserWallet.getBalance();
167
+ const browserChangeAddress = await browserWallet.getChangeAddress();
168
+ const browserCollateral = await browserWallet.getCollateral();
169
+ const browserUtxos = await browserWallet.getUtxos();
170
+ const browserNetworkId = await browserWallet.getNetworkId();
171
+ const browserRewardAddresses = await browserWallet.getRewardAddresses();
172
+
173
+ const browserSignedData = await browserWallet.signData(
174
+ meshWalletChangeAddress,
175
+ "abc"
176
+ );
177
+ const signature = await browserWallet.signTx(transactionHex, true);
178
+ ```
179
+
180
+ ## Mesh Browser Wallet
181
+
182
+ `mesh-wallet` also provides a wrapper class around `CardanoBrowserWallet` called `MeshBrowserWallet` that implements all the convenient return types that might be easier to consume immediately.
183
+
184
+ ```typescript
185
+ const meshBrowserWallet = await MeshBrowserWallet.enable("eternl");
186
+
187
+ const browserBalance = await meshBrowserWallet.getBalanceMesh();
188
+ const browserChangeAddress = await meshBrowserWallet.getChangeAddressBech32();
189
+ const browserCollateral = await meshBrowserWallet.getCollateralMesh();
190
+ const browserUtxos = await meshBrowserWallet.getUtxosMesh();
191
+ const browserNetworkId = await meshBrowserWallet.getNetworkId();
192
+ const browserRewardAddresses =
193
+ await meshBrowserWallet.getRewardAddressesBech32();
194
+
195
+ const signedTx = await meshBrowserWallet.signTxReturnFullTx(
196
+ transactionHex,
197
+ true
198
+ );
199
+ ```
package/dist/index.cjs CHANGED
@@ -22545,8 +22545,8 @@ var CardanoAddress = class {
22545
22545
  const rewardAddress = import_core3.Cardano.RewardAddress.fromCredentials(
22546
22546
  this.networkId === 1 ? import_core3.Cardano.NetworkId.Mainnet : import_core3.Cardano.NetworkId.Testnet,
22547
22547
  {
22548
- hash: (0, import_crypto3.Hash28ByteBase16)(this.paymentCredential.hash),
22549
- type: this.paymentCredential.type
22548
+ hash: (0, import_crypto3.Hash28ByteBase16)(this.stakeCredential.hash),
22549
+ type: this.stakeCredential.type
22550
22550
  }
22551
22551
  );
22552
22552
  return rewardAddress.toAddress().toBech32();
@@ -22556,8 +22556,8 @@ var CardanoAddress = class {
22556
22556
  const rewardAddress = import_core3.Cardano.RewardAddress.fromCredentials(
22557
22557
  this.networkId === 1 ? import_core3.Cardano.NetworkId.Mainnet : import_core3.Cardano.NetworkId.Testnet,
22558
22558
  {
22559
- hash: (0, import_crypto3.Hash28ByteBase16)(this.paymentCredential.hash),
22560
- type: mapCredentialTypeToCredential(this.paymentCredential.type)
22559
+ hash: (0, import_crypto3.Hash28ByteBase16)(this.stakeCredential.hash),
22560
+ type: this.stakeCredential.type
22561
22561
  }
22562
22562
  );
22563
22563
  return rewardAddress.toAddress().toBytes();
package/dist/index.js CHANGED
@@ -22544,8 +22544,8 @@ var CardanoAddress = class {
22544
22544
  const rewardAddress = Cardano.RewardAddress.fromCredentials(
22545
22545
  this.networkId === 1 ? Cardano.NetworkId.Mainnet : Cardano.NetworkId.Testnet,
22546
22546
  {
22547
- hash: Hash28ByteBase16(this.paymentCredential.hash),
22548
- type: this.paymentCredential.type
22547
+ hash: Hash28ByteBase16(this.stakeCredential.hash),
22548
+ type: this.stakeCredential.type
22549
22549
  }
22550
22550
  );
22551
22551
  return rewardAddress.toAddress().toBech32();
@@ -22555,8 +22555,8 @@ var CardanoAddress = class {
22555
22555
  const rewardAddress = Cardano.RewardAddress.fromCredentials(
22556
22556
  this.networkId === 1 ? Cardano.NetworkId.Mainnet : Cardano.NetworkId.Testnet,
22557
22557
  {
22558
- hash: Hash28ByteBase16(this.paymentCredential.hash),
22559
- type: mapCredentialTypeToCredential(this.paymentCredential.type)
22558
+ hash: Hash28ByteBase16(this.stakeCredential.hash),
22559
+ type: this.stakeCredential.type
22560
22560
  }
22561
22561
  );
22562
22562
  return rewardAddress.toAddress().toBytes();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshsdk/wallet",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.2",
4
4
  "description": "Wallets - https://meshjs.dev/apis/wallets",
5
5
  "main": "./dist/index.cjs",
6
6
  "browser": "./dist/index.js",
@@ -19,6 +19,9 @@
19
19
  ],
20
20
  "scripts": {
21
21
  "build": "tsup src/index.ts --format esm,cjs --dts",
22
+ "build:demo": "tsup demo/src/main.ts --format esm --outDir demo/dist --clean",
23
+ "dev:demo": "tsup demo/src/main.ts --format esm --outDir demo/dist --watch",
24
+ "preview:demo": "npx serve demo -p 5173",
22
25
  "build:docs": "typedoc src/index.ts --json ../../apps/docs/src/data/mesh-wallets.json",
23
26
  "clean": "rm -rf .turbo && rm -rf dist && rm -rf node_modules",
24
27
  "dev": "tsup src/index.ts --format esm,cjs --watch --dts",
@@ -37,16 +40,15 @@
37
40
  "@types/jest": "^29.5.12",
38
41
  "ts-node": "^10.9.2",
39
42
  "ts-jest": "^29.1.4",
40
- "dotenv": "^16.4.5"
43
+ "dotenv": "^16.4.5",
44
+ "@meshsdk/provider": "1.9.0-beta.90",
45
+ "@meshsdk/common": "1.9.0-beta.90"
41
46
  },
42
47
  "dependencies": {
43
- "@cardano-sdk/core": "0.46.10",
48
+ "@cardano-sdk/core": "0.46.11",
44
49
  "@cardano-sdk/crypto": "0.4.4",
45
50
  "@cardano-sdk/util": "0.17.1",
46
51
  "@harmoniclabs/cbor": "^1.6.6",
47
- "@meshsdk/core-cst": "1.9.0-beta.87",
48
- "@meshsdk/provider": "1.9.0-beta.87",
49
- "@meshsdk/common": "1.9.0-beta.87",
50
52
  "json-bigint": "^1.0.0",
51
53
  "@simplewebauthn/browser": "^13.0.0",
52
54
  "@types/base32-encoding": "^1.0.2",