@effectstream/wallets 0.103.1 → 0.103.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effectstream/wallets",
3
- "version": "0.103.1",
3
+ "version": "0.103.2",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "homepage": "https://effectstream.github.io/docs/",
6
6
  "repository": {
@@ -20,7 +20,7 @@
20
20
  "./solana-local": "./src/solana/local.ts"
21
21
  },
22
22
  "peerDependencies": {
23
- "@effectstream/midnight-contracts": "0.103.1",
23
+ "@effectstream/midnight-contracts": "0.103.2",
24
24
  "@lucid-evolution/lucid": "^0.4.29",
25
25
  "@lucid-evolution/provider": "^0.1.90",
26
26
  "@lucid-evolution/utils": "^0.1.66",
@@ -52,7 +52,7 @@
52
52
  }
53
53
  },
54
54
  "devDependencies": {
55
- "@effectstream/midnight-contracts": "0.103.1",
55
+ "@effectstream/midnight-contracts": "0.103.2",
56
56
  "@lucid-evolution/lucid": "^0.4.30",
57
57
  "@lucid-evolution/provider": "^0.1.91",
58
58
  "@lucid-evolution/utils": "^0.1.66",
@@ -61,10 +61,10 @@
61
61
  "@midnightntwrk/wallet-sdk-unshielded-wallet": "3.1.0"
62
62
  },
63
63
  "dependencies": {
64
- "@effectstream/concise": "0.103.1",
65
- "@effectstream/crypto": "0.103.1",
66
- "@effectstream/event-client": "0.103.1",
67
- "@effectstream/utils": "0.103.1",
64
+ "@effectstream/concise": "0.103.2",
65
+ "@effectstream/crypto": "0.103.2",
66
+ "@effectstream/event-client": "0.103.2",
67
+ "@effectstream/utils": "0.103.2",
68
68
  "@aurowallet/mina-provider": "^1.0.12",
69
69
  "@metamask/providers": "^22.1.0",
70
70
  "@midnight-ntwrk/dapp-connector-api": "4.0.1",
package/src/IProvider.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AddressType } from "@effectstream/utils";
1
+ import { AddressType } from "@effectstream/utils/types";
2
2
 
3
3
 
4
4
  export type WalletOption = {
@@ -1,5 +1,5 @@
1
1
  import { PeraWalletConnect } from "@perawallet/connect";
2
- import { AddressType, uint8ArrayToHexString } from "@effectstream/utils";
2
+ import { AddressType, uint8ArrayToHexString } from "@effectstream/utils/types";
3
3
  import {
4
4
  type IConnector,
5
5
  type IInjectedConnector,
@@ -1,4 +1,4 @@
1
- import type { Result } from "@effectstream/utils";
1
+ import type { Result } from "@effectstream/utils/types";
2
2
  import type { IProvider } from "../IProvider.ts";
3
3
  import type { WalletMode, ApiForMode } from "../utils.ts";
4
4
  import { type LoginInfoMap, connectInjected } from "../wallet-modes.ts";
@@ -1,7 +1,7 @@
1
1
  import { Buffer } from "node:buffer";
2
2
  import { utf8ToHex } from 'web3-utils';
3
3
  import type { ApiPromise } from "avail-js-sdk";
4
- import { AddressType } from "@effectstream/utils";
4
+ import { AddressType } from "@effectstream/utils/types";
5
5
  import type { IProvider, ActiveConnection, AddressAndType, UserSignature } from "../IProvider.ts";
6
6
  type PolkadotAddress = string;
7
7
  import { u8aToHex } from "@polkadot/util";
@@ -1,4 +1,4 @@
1
- import type { Result } from "@effectstream/utils";
1
+ import type { Result } from "@effectstream/utils/types";
2
2
  import type { IProvider } from "../IProvider.ts";
3
3
  import type { WalletMode, ApiForMode } from "../utils.ts";
4
4
  import type { LoginInfoMap } from "../wallet-modes.ts";
@@ -1,5 +1,5 @@
1
1
  import { bech32 } from "bech32";
2
- import { hexStringToUint8Array, AddressType } from "@effectstream/utils";
2
+ import { hexStringToUint8Array, AddressType } from "@effectstream/utils/types";
3
3
  import {
4
4
  type IConnector,
5
5
  type IInjectedConnector,
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import { CryptoManager } from "@effectstream/crypto";
3
- import { AddressType } from "@effectstream/utils";
3
+ import { AddressType } from "@effectstream/utils/types";
4
4
  import { CardanoLocalConnector } from "./local.ts";
5
5
 
6
6
  describe("CardanoLocalProvider", () => {
@@ -1,4 +1,4 @@
1
- import { AddressType } from "@effectstream/utils";
1
+ import { AddressType } from "@effectstream/utils/types";
2
2
  import { utf8ToHex } from "web3-utils";
3
3
  import type {
4
4
  ActiveConnection,
@@ -1,4 +1,4 @@
1
- import type { Result } from "@effectstream/utils";
1
+ import type { Result } from "@effectstream/utils/types";
2
2
  import type { IProvider } from "../IProvider.ts";
3
3
  import type { WalletMode, ApiForMode } from "../utils.ts";
4
4
  import type { LoginInfoMap } from "../wallet-modes.ts";
@@ -1,4 +1,4 @@
1
- import type { Result } from "@effectstream/utils";
1
+ import type { Result } from "@effectstream/utils/types";
2
2
  import type { IProvider } from "../IProvider.ts";
3
3
  import type { WalletMode, ApiForMode } from "../utils.ts";
4
4
  import { type LoginInfoMap, connectInjected } from "../wallet-modes.ts";
@@ -1,4 +1,4 @@
1
- import { AddressType, type EvmAddress } from "@effectstream/utils";
1
+ import { AddressType, type EvmAddress } from "@effectstream/utils/types";
2
2
  import type { Wallet } from "./types.ts";
3
3
  import type { IProvider } from "./IProvider.ts";
4
4
  import { type Chain, numberToHex } from "viem";
package/src/evm/ethers.ts CHANGED
@@ -6,7 +6,7 @@ import type {
6
6
  } from "ethers";
7
7
 
8
8
  import { Buffer } from "node:buffer";
9
- import { AddressType } from "@effectstream/utils";
9
+ import { AddressType } from "@effectstream/utils/types";
10
10
  import type {
11
11
  ActiveConnection,
12
12
  AddressAndType,
@@ -1,5 +1,5 @@
1
1
  import type { MetaMaskInpageProvider } from "@metamask/providers";
2
- import { AddressType } from "@effectstream/utils";
2
+ import { AddressType } from "@effectstream/utils/types";
3
3
  import {
4
4
  type ActiveConnection,
5
5
  type AddressAndType,
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import { CryptoManager } from "@effectstream/crypto";
3
- import { AddressType } from "@effectstream/utils";
3
+ import { AddressType } from "@effectstream/utils/types";
4
4
  import { ViemConnector } from "./viem.ts";
5
5
 
6
6
  const TEST_KEY =
package/src/evm/viem.ts CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  type WalletClient,
9
9
  } from "viem";
10
10
  import { privateKeyToAccount } from "viem/accounts";
11
- import { AddressType } from "@effectstream/utils";
11
+ import { AddressType } from "@effectstream/utils/types";
12
12
  import type {
13
13
  ActiveConnection,
14
14
  AddressAndType,
@@ -1,4 +1,4 @@
1
- import type { Result } from "@effectstream/utils";
1
+ import type { Result } from "@effectstream/utils/types";
2
2
  import type { IProvider } from "../IProvider.ts";
3
3
  import type { WalletMode, ApiForMode } from "../utils.ts";
4
4
  import type { LoginInfoMap } from "../wallet-modes.ts";
@@ -1,4 +1,4 @@
1
- import type { Result } from "@effectstream/utils";
1
+ import type { Result } from "@effectstream/utils/types";
2
2
  import type { IProvider } from "../IProvider.ts";
3
3
  import type { ApiForMode, WalletMode } from "../utils.ts";
4
4
  import { connectInjected, type LoginInfoMap } from "../wallet-modes.ts";
@@ -1,4 +1,4 @@
1
- import type { Result } from "@effectstream/utils";
1
+ import type { Result } from "@effectstream/utils/types";
2
2
  import type { IProvider } from "../IProvider.ts";
3
3
  import type { WalletMode, ApiForMode } from "../utils.ts";
4
4
  import type { LoginInfoMap } from "../wallet-modes.ts";
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, mock, test } from "bun:test";
2
2
  import { Buffer } from "node:buffer";
3
- import { AddressType } from "@effectstream/utils";
3
+ import { AddressType } from "@effectstream/utils/types";
4
4
  import { verifySignature } from "@midnight-ntwrk/ledger-v8";
5
5
  import { CryptoManager } from "@effectstream/crypto";
6
6
  import { MidnightLocalConnector, type MidnightLocalApi } from "./local.ts";
@@ -117,10 +117,17 @@ describe("MidnightLocalProvider", () => {
117
117
  expect(api.walletFacade).toBe(fakeFacade);
118
118
  expect(api.dustAddress).toBe(`dust-for-${DETERMINISTIC_SEED.slice(0, 8)}`);
119
119
  expect(api.shieldedAddress).toBe("deadbeef-coin-pub-key");
120
+ // The encryption key is surfaced alongside the coin key: anything building
121
+ // a shielded output for this wallet needs both, and re-deriving it meant
122
+ // reaching back into @effectstream/midnight-contracts.
123
+ expect(api.shieldedEncryptionPublicKey).toBe("deadbeef-enc-pub-key");
120
124
 
121
- // getShieldedAddresses no longer throws in facade mode.
125
+ // getShieldedAddresses no longer throws in facade mode, and mirrors the
126
+ // dapp-connector-api's shape (same field names; hex rather than bech32m).
122
127
  await expect(api.getShieldedAddresses()).resolves.toEqual({
123
128
  shieldedAddress: "deadbeef-coin-pub-key",
129
+ shieldedCoinPublicKey: "deadbeef-coin-pub-key",
130
+ shieldedEncryptionPublicKey: "deadbeef-enc-pub-key",
124
131
  });
125
132
 
126
133
  expect(provider.getConnection().metadata.displayName).toBe(
@@ -1,5 +1,5 @@
1
1
  import { Buffer } from "node:buffer";
2
- import { AddressType, type MidnightAddress } from "@effectstream/utils";
2
+ import { AddressType, type MidnightAddress } from "@effectstream/utils/types";
3
3
  import type {
4
4
  ActiveConnection,
5
5
  AddressAndType,
@@ -63,7 +63,26 @@ export type MidnightLocalApi = {
63
63
  data: string,
64
64
  options: { encoding: "text" | "hex"; keyType: "unshielded" },
65
65
  ) => Promise<{ data: string; signature: string; verifyingKey: string }>;
66
- getShieldedAddresses: () => Promise<{ shieldedAddress: string }>;
66
+ /**
67
+ * Shielded keys, in the same SHAPE as the dapp-connector-api's
68
+ * `getShieldedAddresses()` so a consumer can branch on encoding rather than
69
+ * on structure.
70
+ *
71
+ * Encoding still differs by design: these are HEX
72
+ * (`ShieldedAddress.{coin,encryption}PublicKeyString()` return
73
+ * `.data.toString('hex')`), whereas Lace returns bech32m. Do not run these
74
+ * through `parseCoinPublicKeyToHex` / `parseEncPublicKeyToHex`.
75
+ *
76
+ * Both keys matter for contract calls that pay the caller: the coin public
77
+ * key is the output recipient, and the ciphertext is keyed off the
78
+ * encryption public key. Supplying only one means the wallet never finds the
79
+ * coin it was just sent.
80
+ */
81
+ getShieldedAddresses: () => Promise<{
82
+ shieldedAddress: string;
83
+ shieldedCoinPublicKey: string;
84
+ shieldedEncryptionPublicKey: string;
85
+ }>;
67
86
  /** The derived seed, exposed so tests can persist/reuse the wallet. */
68
87
  seed: string;
69
88
  /** Public verifying key for the unshielded signing role (hex). */
@@ -83,6 +102,13 @@ export type MidnightLocalApi = {
83
102
  dustAddress?: string;
84
103
  /** Hex-encoded shielded coin public key. Populated only in facade mode. */
85
104
  shieldedAddress?: string;
105
+ /**
106
+ * Hex-encoded shielded ENCRYPTION public key. Populated only in facade mode.
107
+ * Needed alongside `shieldedAddress` by anything that builds a shielded
108
+ * output for this wallet (e.g. a contract mint) — without it the ciphertext
109
+ * is keyed to the wrong recipient and the coin is never discovered.
110
+ */
111
+ shieldedEncryptionPublicKey?: string;
86
112
  /**
87
113
  * Escape hatch: the entire `WalletResult` returned by
88
114
  * `@effectstream/midnight-contracts.buildWalletFacade`. Exposes the raw
@@ -199,9 +225,17 @@ export class MidnightLocalConnector {
199
225
  // of `@effectstream/wallets`.
200
226
  const contractsMod = await import(
201
227
  "@effectstream/midnight-contracts/wallet-info"
202
- ).catch(() => {
228
+ ).catch((cause: unknown) => {
229
+ // Preserve the underlying reason. A missing peer dep is only ONE way this
230
+ // import fails — it also rejects when the module resolves but cannot load,
231
+ // e.g. in a browser bundle where `./wallet-info` drags in node:fs. Naming
232
+ // only the peer-dep case sends people to reinstall a package they already
233
+ // have.
203
234
  throw new Error(
204
- "@effectstream/midnight-contracts is required when `networkUrls` is passed to MidnightLocal.connectFromSeed. Install it as a peer dependency.",
235
+ "Could not load @effectstream/midnight-contracts/wallet-info, needed when `networkUrls` is passed to MidnightLocal.connectFromSeed. " +
236
+ "Either it is not installed (add it as a peer dependency), or it failed to load in this runtime — see `cause`. " +
237
+ `Underlying error: ${cause instanceof Error ? cause.message : String(cause)}`,
238
+ { cause },
205
239
  );
206
240
  });
207
241
  const { hdMod, keystoreMod } = await loadKeystoreDeps();
@@ -237,6 +271,13 @@ export class MidnightLocalConnector {
237
271
  walletResult.wallet.shielded,
238
272
  );
239
273
  const shieldedAddress = initialShielded.address.coinPublicKeyString();
274
+ // The encryption key sits right next to the coin key on the same address
275
+ // object. It used to be dropped here, which forced every consumer that
276
+ // builds a shielded output for this wallet (a contract mint, say) to
277
+ // re-derive it by calling getInitialShieldedState again from
278
+ // @effectstream/midnight-contracts.
279
+ const shieldedEncryptionPublicKey =
280
+ initialShielded.address.encryptionPublicKeyString();
240
281
 
241
282
  const api: MidnightLocalApi = {
242
283
  signData: async (data, options) => {
@@ -251,13 +292,21 @@ export class MidnightLocalConnector {
251
292
  verifyingKey,
252
293
  };
253
294
  },
254
- getShieldedAddresses: async () => ({ shieldedAddress }),
295
+ // `shieldedAddress` is repeated as `shieldedCoinPublicKey` so the shape
296
+ // matches the dapp-connector-api's — locally the "address" IS the coin
297
+ // public key, so they are the same value under both names.
298
+ getShieldedAddresses: async () => ({
299
+ shieldedAddress,
300
+ shieldedCoinPublicKey: shieldedAddress,
301
+ shieldedEncryptionPublicKey,
302
+ }),
255
303
  seed,
256
304
  verifyingKey,
257
305
  unshieldedAddress: walletResult.unshieldedAddress,
258
306
  walletFacade: walletResult.wallet,
259
307
  dustAddress: walletResult.dustAddress,
260
308
  shieldedAddress,
309
+ shieldedEncryptionPublicKey,
261
310
  walletResult,
262
311
  };
263
312
 
@@ -1,4 +1,4 @@
1
- import { AddressType, type MidnightAddress } from "@effectstream/utils";
1
+ import { AddressType, type MidnightAddress } from "@effectstream/utils/types";
2
2
  import type {
3
3
  ConnectedAPI,
4
4
  InitialAPI,
@@ -1,4 +1,4 @@
1
- import type { Result } from "@effectstream/utils";
1
+ import type { Result } from "@effectstream/utils/types";
2
2
  import type { IProvider } from "../IProvider.ts";
3
3
  import type { WalletMode, ApiForMode } from "../utils.ts";
4
4
  import type { LoginInfoMap } from "../wallet-modes.ts";
@@ -1,4 +1,4 @@
1
- import type { Result } from "@effectstream/utils";
1
+ import type { Result } from "@effectstream/utils/types";
2
2
  import type { IProvider } from "../IProvider.ts";
3
3
  import type { WalletMode, ApiForMode } from "../utils.ts";
4
4
  import { type LoginInfoMap, connectInjected } from "../wallet-modes.ts";
package/src/mina/mina.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as AuroMinaApi from "@aurowallet/mina-provider";
2
- import { AddressType } from "@effectstream/utils";
2
+ import { AddressType } from "@effectstream/utils/types";
3
3
  import {
4
4
  type IConnector,
5
5
  type IInjectedConnector,
@@ -1,4 +1,4 @@
1
- import type { Result } from "@effectstream/utils";
1
+ import type { Result } from "@effectstream/utils/types";
2
2
  import type { IProvider } from "../IProvider.ts";
3
3
  import type { WalletMode, ApiForMode } from "../utils.ts";
4
4
  import { type LoginInfoMap, connectInjected } from "../wallet-modes.ts";
package/src/mod.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export type { IProvider, AddressAndType, UserSignature, WalletOption } from "./IProvider.ts";
2
2
  export type { Wallet } from "./types.ts";
3
- export type { AddressType, WalletAddress } from "@effectstream/utils";
3
+ export type { AddressType, WalletAddress } from "@effectstream/utils/types";
4
4
  export { accountPayload_, accountMessages } from "@effectstream/concise";
5
5
  export { WalletMode, WalletNameMap } from "./utils.ts";
6
6
  // Main entry point
@@ -2,7 +2,7 @@ import type {
2
2
  InjectedExtension,
3
3
  InjectedWindowProvider,
4
4
  } from "@polkadot/extension-inject/types";
5
- import { AddressType } from "@effectstream/utils";
5
+ import { AddressType } from "@effectstream/utils/types";
6
6
  import {
7
7
  type IConnector,
8
8
  type IInjectedConnector,
@@ -6,7 +6,7 @@
6
6
  // import { connectInjected } from './wallet-modes.js';
7
7
  // import type { Result } from '@effectstream/utils';
8
8
 
9
- import type { Result } from "@effectstream/utils";
9
+ import type { Result } from "@effectstream/utils/types";
10
10
  import type { IProvider } from "../IProvider.ts";
11
11
  import type { WalletMode, ApiForMode } from "../utils.ts";
12
12
  import { type LoginInfoMap, connectInjected } from "../wallet-modes.ts";
@@ -1,7 +1,7 @@
1
1
  import { test, expect } from "bun:test";
2
2
  import { SolanaLocalConnector } from "./local.ts";
3
3
  import { CryptoManager } from "@effectstream/crypto";
4
- import { AddressType } from "@effectstream/utils";
4
+ import { AddressType } from "@effectstream/utils/types";
5
5
 
6
6
  const verifier = () => CryptoManager.getCryptoManager(AddressType.SOLANA);
7
7
 
@@ -1,4 +1,4 @@
1
- import { AddressType } from "@effectstream/utils";
1
+ import { AddressType } from "@effectstream/utils/types";
2
2
  import { ed25519 } from "@noble/curves/ed25519";
3
3
  import bs58 from "bs58";
4
4
  import { Buffer } from "node:buffer";
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, test } from "bun:test";
2
- import { AddressType } from "@effectstream/utils";
2
+ import { AddressType } from "@effectstream/utils/types";
3
3
  import {
4
4
  Keypair,
5
5
  PublicKey,
@@ -1,4 +1,4 @@
1
- import { AddressType } from "@effectstream/utils";
1
+ import { AddressType } from "@effectstream/utils/types";
2
2
  import {
3
3
  type IConnector,
4
4
  type IInjectedConnector,
@@ -1,4 +1,4 @@
1
- import type { Result } from "@effectstream/utils";
1
+ import type { Result } from "@effectstream/utils/types";
2
2
  import type { IProvider } from "../IProvider.ts";
3
3
  import type { WalletMode, ApiForMode } from "../utils.ts";
4
4
  import { type LoginInfoMap, connectInjected } from "../wallet-modes.ts";
package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export type Hash = string;
2
- import type { WalletAddress } from "@effectstream/utils";
2
+ import type { WalletAddress } from "@effectstream/utils/types";
3
3
  import type { IProvider, UserSignature, WalletOption } from "./IProvider.ts";
4
4
 
5
5
  export type SignFunction = (message: string) => Promise<UserSignature>;
package/src/utils.test.ts CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  connectInjectedWallet,
4
4
  } from "./utils.ts";
5
5
  import type { IInjectedConnector, IProvider } from "./IProvider.ts";
6
- import { AddressType } from "@effectstream/utils";
6
+ import { AddressType } from "@effectstream/utils/types";
7
7
 
8
8
  const MOCK_ADDRESS = "0xmock";
9
9
  const MOCK_METADATA = { name: "MockWallet", displayName: "Mock Wallet", icon: "", version: "1.0" };
@@ -1,5 +1,5 @@
1
1
  import type { ApiPromise } from "avail-js-sdk";
2
- import type { Result } from "@effectstream/utils";
2
+ import type { Result } from "@effectstream/utils/types";
3
3
  import type { AlgorandApi } from "./algorand/algorand.ts";
4
4
  import type { CardanoApi } from "./cardano/cardano.ts";
5
5
  import type { CardanoLocalNetwork } from "./cardano/local.ts";
@@ -19,7 +19,7 @@ import {
19
19
  type InjectionPreference,
20
20
  WalletMode,
21
21
  } from "./utils.ts";
22
- import { AddressType } from "@effectstream/utils";
22
+ import { AddressType } from "@effectstream/utils/types";
23
23
  import { formatError } from "./helpers/format-error.ts";
24
24
  import type { MidnightApi } from "./midnight/midnight.ts";
25
25
  import type {} from "./midnight/local.ts";
package/src/wallets.ts CHANGED
@@ -9,7 +9,7 @@ import { viemLoginWrapper } from "./evm/wrapper-viem.ts";
9
9
  import { minaLoginWrapper } from "./mina/wrapper.ts";
10
10
  import { availJsLoginWrapper } from "./avail/wrapper.ts";
11
11
  import { WalletMode } from "./utils.ts";
12
- import type { Result } from "@effectstream/utils";
12
+ import type { Result } from "@effectstream/utils/types";
13
13
  import type { Wallet } from "./types.ts";
14
14
  import type { LoginInfo } from "./wallet-modes.ts";
15
15
  // import { assertNever } from "assert-never";