@effectstream/wallets 0.104.0 → 0.200.1

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.104.0",
3
+ "version": "0.200.1",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "homepage": "https://effectstream.github.io/docs/",
6
6
  "repository": {
@@ -20,13 +20,13 @@
20
20
  "./solana-local": "./src/solana/local.ts"
21
21
  },
22
22
  "peerDependencies": {
23
- "@effectstream/midnight-contracts": "0.104.0",
23
+ "@effectstream/midnight-contracts": "0.200.1",
24
24
  "@lucid-evolution/lucid": "^0.4.29",
25
25
  "@lucid-evolution/provider": "^0.1.90",
26
26
  "@lucid-evolution/utils": "^0.1.66",
27
- "@midnight-ntwrk/ledger-v8": "^8.1.0",
28
- "@midnightntwrk/wallet-sdk-hd": "^3.0.3",
29
- "@midnightntwrk/wallet-sdk-unshielded-wallet": "^3.1.0"
27
+ "@midnightntwrk/ledger-v9": "1.0.0-rc.3",
28
+ "@midnightntwrk/wallet-sdk-hd": "3.1.0-beta.1",
29
+ "@midnightntwrk/wallet-sdk-unshielded-wallet": "4.0.0-beta.2"
30
30
  },
31
31
  "peerDependenciesMeta": {
32
32
  "@effectstream/midnight-contracts": {
@@ -41,7 +41,7 @@
41
41
  "@lucid-evolution/utils": {
42
42
  "optional": true
43
43
  },
44
- "@midnight-ntwrk/ledger-v8": {
44
+ "@midnightntwrk/ledger-v9": {
45
45
  "optional": true
46
46
  },
47
47
  "@midnightntwrk/wallet-sdk-hd": {
@@ -52,19 +52,19 @@
52
52
  }
53
53
  },
54
54
  "devDependencies": {
55
- "@effectstream/midnight-contracts": "0.104.0",
55
+ "@effectstream/midnight-contracts": "0.200.1",
56
56
  "@lucid-evolution/lucid": "^0.4.30",
57
57
  "@lucid-evolution/provider": "^0.1.91",
58
58
  "@lucid-evolution/utils": "^0.1.66",
59
- "@midnight-ntwrk/ledger-v8": "8.1.0",
60
- "@midnightntwrk/wallet-sdk-hd": "3.0.3",
61
- "@midnightntwrk/wallet-sdk-unshielded-wallet": "3.1.0"
59
+ "@midnightntwrk/ledger-v9": "1.0.0-rc.3",
60
+ "@midnightntwrk/wallet-sdk-hd": "3.1.0-beta.1",
61
+ "@midnightntwrk/wallet-sdk-unshielded-wallet": "4.0.0-beta.2"
62
62
  },
63
63
  "dependencies": {
64
- "@effectstream/concise": "0.104.0",
65
- "@effectstream/crypto": "0.104.0",
66
- "@effectstream/event-client": "0.104.0",
67
- "@effectstream/utils": "0.104.0",
64
+ "@effectstream/concise": "0.200.1",
65
+ "@effectstream/crypto": "0.200.1",
66
+ "@effectstream/event-client": "0.200.1",
67
+ "@effectstream/utils": "0.200.1",
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",
@@ -1,3 +1,5 @@
1
+ // MUST stay first: it sets the flag @polkadot/util reads while loading.
2
+ import "@effectstream/utils/polkadot-esm-cjs-warning";
1
3
  import { Buffer } from "node:buffer";
2
4
  import { utf8ToHex } from 'web3-utils';
3
5
  import type { ApiPromise } from "avail-js-sdk";
@@ -1,3 +1,6 @@
1
+ // MUST stay first: avail-js-sdk requires the CJS @polkadot build, and
2
+ // @polkadot/util reads the flag this sets while loading.
3
+ import "@effectstream/utils/polkadot-esm-cjs-warning";
1
4
  import type { Result } from "@effectstream/utils/types";
2
5
  import type { IProvider } from "../IProvider.ts";
3
6
  import type { WalletMode, ApiForMode } from "../utils.ts";
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, mock, test } from "bun:test";
2
2
  import { Buffer } from "node:buffer";
3
3
  import { AddressType } from "@effectstream/utils/types";
4
- import { verifySignature } from "@midnight-ntwrk/ledger-v8";
4
+ import { verifySignature } from "@midnightntwrk/ledger-v9";
5
5
  import { CryptoManager } from "@effectstream/crypto";
6
6
  import { MidnightLocalConnector, type MidnightLocalApi } from "./local.ts";
7
7
 
@@ -20,7 +20,7 @@ describe("MidnightLocalProvider", () => {
20
20
  expect(address.length).toBeGreaterThan(0);
21
21
  });
22
22
 
23
- test("signMessage produces a signature that verifies via ledger-v8", async () => {
23
+ test("signMessage produces a signature that verifies via tagged ledger-v9 APIs", async () => {
24
24
  const provider = await MidnightLocalConnector.instance().connectFromSeed({
25
25
  seed: DETERMINISTIC_SEED,
26
26
  networkId: "undeployed",
@@ -34,11 +34,13 @@ describe("MidnightLocalProvider", () => {
34
34
 
35
35
  const messageBytes = Buffer.from(message, "utf-8");
36
36
  const ok = verifySignature(
37
- signed.verifyingKey as never,
37
+ { tag: "schnorr", value: signed.verifyingKey },
38
38
  messageBytes,
39
- signed.signature as never,
39
+ { tag: "schnorr", value: signed.signature },
40
40
  );
41
41
  expect(ok).toBe(true);
42
+ expect(signed.verifyingKey).not.toContain("[object Object]");
43
+ expect(signed.signature).not.toContain("[object Object]");
42
44
 
43
45
  // signMessage on the IProvider surface returns "signature|verifyingKey"
44
46
  // (Midnight signing is non-deterministic, so the inner signature differs
@@ -48,9 +50,9 @@ describe("MidnightLocalProvider", () => {
48
50
  expect(rest).toEqual([]);
49
51
  expect(innerVk).toBe(signed.verifyingKey);
50
52
  const okAgain = verifySignature(
51
- innerVk as never,
53
+ { tag: "schnorr", value: innerVk },
52
54
  messageBytes,
53
- innerSig as never,
55
+ { tag: "schnorr", value: innerSig },
54
56
  );
55
57
  expect(okAgain).toBe(true);
56
58
  });
@@ -170,12 +170,15 @@ export class MidnightLocalConnector {
170
170
  hdMod.Roles.NightExternal,
171
171
  );
172
172
  const unshieldedKeystore = keystoreMod.createKeystore(
173
- unshieldedSeed,
173
+ { kind: "schnorr", secret: unshieldedSeed },
174
174
  args.networkId as never,
175
175
  );
176
176
 
177
177
  const unshieldedAddress = unshieldedKeystore.getBech32Address().asString();
178
- const verifyingKey = String(unshieldedKeystore.getPublicKey());
178
+ const verifyingKey = schnorrValue(
179
+ unshieldedKeystore.getPublicKey(),
180
+ "verifying key",
181
+ );
179
182
 
180
183
  const api: MidnightLocalApi = {
181
184
  signData: async (data, options) => {
@@ -183,10 +186,13 @@ export class MidnightLocalConnector {
183
186
  options.encoding === "hex"
184
187
  ? Buffer.from(data, "hex")
185
188
  : Buffer.from(data, "utf-8");
186
- const signature = unshieldedKeystore.signData(bytes);
189
+ const signature = schnorrValue(
190
+ unshieldedKeystore.signData(bytes),
191
+ "signature",
192
+ );
187
193
  return {
188
194
  data,
189
- signature: String(signature),
195
+ signature,
190
196
  verifyingKey,
191
197
  };
192
198
  },
@@ -247,10 +253,13 @@ export class MidnightLocalConnector {
247
253
  hdMod.Roles.NightExternal,
248
254
  );
249
255
  const unshieldedKeystore = keystoreMod.createKeystore(
250
- unshieldedSeed,
256
+ { kind: "schnorr", secret: unshieldedSeed },
251
257
  args.networkId as never,
252
258
  );
253
- const verifyingKey = String(unshieldedKeystore.getPublicKey());
259
+ const verifyingKey = schnorrValue(
260
+ unshieldedKeystore.getPublicKey(),
261
+ "verifying key",
262
+ );
254
263
 
255
264
  const fullNetworkUrls = {
256
265
  indexer: networkUrls.indexer,
@@ -285,10 +294,13 @@ export class MidnightLocalConnector {
285
294
  options.encoding === "hex"
286
295
  ? Buffer.from(data, "hex")
287
296
  : Buffer.from(data, "utf-8");
288
- const signature = unshieldedKeystore.signData(bytes);
297
+ const signature = schnorrValue(
298
+ unshieldedKeystore.signData(bytes),
299
+ "signature",
300
+ );
289
301
  return {
290
302
  data,
291
- signature: String(signature),
303
+ signature,
292
304
  verifyingKey,
293
305
  };
294
306
  },
@@ -367,7 +379,7 @@ export class MidnightLocalProvider implements IProvider<MidnightApi> {
367
379
  );
368
380
  // Format: "signature|verifyingKey". Midnight signatures are not
369
381
  // self-recovering (unlike EVM ECDSA), so the verifier needs the public
370
- // key to call ledger-v8.verifySignature. Mirrors Cardano's "sig+key"
382
+ // key to call ledger-v9.verifySignature with tagged Schnorr values. Mirrors Cardano's "sig+key"
371
383
  // convention, just with `|` as the separator to keep the formats distinct.
372
384
  return `${signed.signature}|${signed.verifyingKey}`;
373
385
  };
@@ -422,3 +434,13 @@ function generateRandomHexSeed(byteLength: number): string {
422
434
  .map((b) => b.toString(16).padStart(2, "0"))
423
435
  .join("");
424
436
  }
437
+
438
+ function schnorrValue(
439
+ value: { tag: "schnorr" | "ecdsa"; value: string },
440
+ label: string,
441
+ ): string {
442
+ if (value.tag !== "schnorr") {
443
+ throw new Error(`Expected Schnorr ${label}, received ${value.tag}`);
444
+ }
445
+ return value.value;
446
+ }