@miden-sdk/para 0.16.0-rc.5 → 0.16.0-rc.6
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/{types → cjs}/modalClient.d.ts +1 -1
- package/dist/{types → cjs}/utils.d.ts +1 -1
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/midenClient.d.ts +19 -0
- package/dist/esm/modalClient.d.ts +11 -0
- package/dist/esm/types.d.ts +34 -0
- package/dist/esm/utils.d.ts +33 -0
- package/package.json +16 -13
- /package/dist/{types → cjs}/index.d.ts +0 -0
- /package/dist/{types → cjs}/midenClient.d.ts +0 -0
- /package/dist/{types → cjs}/types.d.ts +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ParaWeb, { Wallet } from "@getpara/web-sdk";
|
|
2
2
|
import type { TransactionSummary } from "@miden-sdk/miden-sdk";
|
|
3
3
|
import { hexToBytes } from "@noble/hashes/utils.js";
|
|
4
|
-
import { TxSummaryJson } from "./types";
|
|
4
|
+
import { TxSummaryJson } from "./types.js";
|
|
5
5
|
/** @public */
|
|
6
6
|
export { hexToBytes };
|
|
7
7
|
/**
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export * from "./midenClient.js";
|
|
2
|
+
export { evmPkToCommitment, getUncompressedPublicKeyFromWallet, } from "./utils.js";
|
|
3
|
+
export type { MidenAccountOpts, Opts, MidenAccountStorageMode, TxSummaryJson, } from "./types.js";
|
|
4
|
+
export type { CustomSignConfirmStep } from "./midenClient.js";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ParaWeb, Wallet } from "@getpara/web-sdk";
|
|
2
|
+
import type { Opts, TxSummaryJson } from "./types.js";
|
|
3
|
+
import type { MidenClient } from "@miden-sdk/miden-sdk";
|
|
4
|
+
export type CustomSignConfirmStep = (txSummaryJson: TxSummaryJson) => Promise<unknown>;
|
|
5
|
+
/**
|
|
6
|
+
* Creates a signing callback that routes Miden signing requests through Para.
|
|
7
|
+
* Prompts the user with a modal before delegating the keccak-hashed message to Para's signer,
|
|
8
|
+
* and optionally runs a custom confirmation step in between.
|
|
9
|
+
*/
|
|
10
|
+
export declare const signCb: (para: ParaWeb, wallet: Wallet, showSigningModal: boolean, customSignConfirmStep?: CustomSignConfirmStep) => (_: Uint8Array, signingInputs: Uint8Array) => Promise<Uint8Array<ArrayBuffer>>;
|
|
11
|
+
/**
|
|
12
|
+
* Builds a MidenClient wired to Para wallets and ensures an account exists for the user.
|
|
13
|
+
* Filters to EVM wallets, prompts for selection, creates the client, and
|
|
14
|
+
* hydrates or creates the corresponding Miden account before returning the client + account id.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createParaMidenClient(para: ParaWeb, wallets: Wallet[], opts: Opts, showSigningModal?: boolean, customSignConfirmStep?: CustomSignConfirmStep): Promise<{
|
|
17
|
+
client: MidenClient;
|
|
18
|
+
accountId: string;
|
|
19
|
+
}>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TxSummaryJson } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Shows a lightweight confirmation modal for signing a hashed transaction.
|
|
4
|
+
* Resolves to true when the user confirms, false when cancelled; no-op on the server.
|
|
5
|
+
*/
|
|
6
|
+
export declare const signingModal: (txSummaryJson: TxSummaryJson) => Promise<boolean>;
|
|
7
|
+
/**
|
|
8
|
+
* Shows a selectable list of account commitments and resolves with the chosen index.
|
|
9
|
+
* Returns 0 immediately when only one account is provided or when running server-side.
|
|
10
|
+
*/
|
|
11
|
+
export declare const accountSelectionModal: (accounts: string[]) => Promise<number>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** @public */
|
|
2
|
+
export interface MidenClientOpts {
|
|
3
|
+
endpoint?: string;
|
|
4
|
+
noteTransportUrl?: string;
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use noteTransportUrl instead
|
|
7
|
+
*/
|
|
8
|
+
nodeTransportUrl?: string;
|
|
9
|
+
seed?: string;
|
|
10
|
+
}
|
|
11
|
+
export type MidenAccountStorageMode = "public" | "private";
|
|
12
|
+
export interface MidenAccountOpts {
|
|
13
|
+
accountSeed?: string;
|
|
14
|
+
storageMode: MidenAccountStorageMode;
|
|
15
|
+
}
|
|
16
|
+
export type Opts = MidenClientOpts & MidenAccountOpts;
|
|
17
|
+
interface NoteIdAndAsset {
|
|
18
|
+
id: string;
|
|
19
|
+
assets: {
|
|
20
|
+
assetId: string;
|
|
21
|
+
amount: string;
|
|
22
|
+
}[];
|
|
23
|
+
}
|
|
24
|
+
interface InputNoteSender {
|
|
25
|
+
sender: string;
|
|
26
|
+
}
|
|
27
|
+
interface OutputNoteType {
|
|
28
|
+
noteType: string;
|
|
29
|
+
}
|
|
30
|
+
export interface TxSummaryJson {
|
|
31
|
+
inputNotes: (NoteIdAndAsset & InputNoteSender)[];
|
|
32
|
+
outputNotes: (NoteIdAndAsset & OutputNoteType)[];
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import ParaWeb, { Wallet } from "@getpara/web-sdk";
|
|
2
|
+
import type { TransactionSummary } from "@miden-sdk/miden-sdk";
|
|
3
|
+
import { hexToBytes } from "@noble/hashes/utils.js";
|
|
4
|
+
import { TxSummaryJson } from "./types.js";
|
|
5
|
+
/** @public */
|
|
6
|
+
export { hexToBytes };
|
|
7
|
+
/**
|
|
8
|
+
* Converts a Para hex signature into the serialized format expected by Miden.
|
|
9
|
+
* Prefixes the auth scheme byte and appends the extra padding byte required by current crypto libs.
|
|
10
|
+
*/
|
|
11
|
+
export declare const fromHexSig: (hexString: string) => Uint8Array<ArrayBuffer>;
|
|
12
|
+
/**
|
|
13
|
+
* Derives a 32-byte seed buffer from a UTF-8 string, truncating when longer than 32 bytes.
|
|
14
|
+
*/
|
|
15
|
+
export declare const accountSeedFromStr: (str?: string) => Uint8Array<ArrayBuffer> | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Converts an uncompressed EVM public key into a Miden commitment.
|
|
18
|
+
* Assumes input format `0x04${x}${y}` where x and y are 64-char hex strings.
|
|
19
|
+
*
|
|
20
|
+
* The protocol commits to the affine point as Poseidon2 over 16 field elements:
|
|
21
|
+
* the x coordinate then the y coordinate, each as eight 32-bit limbs in
|
|
22
|
+
* little-endian limb order. 0.15 hashed a different preimage — nine felts
|
|
23
|
+
* packed from the 33-byte compressed SEC1 encoding — so a commitment computed
|
|
24
|
+
* by an older release will not match one computed here.
|
|
25
|
+
*/
|
|
26
|
+
export declare const evmPkToCommitment: (uncompressedPublicKey: string) => Promise<import("@miden-sdk/miden-sdk").Word>;
|
|
27
|
+
/**
|
|
28
|
+
* Retrieves the uncompressed public key for a Para wallet, falling back to JWT data when absent.
|
|
29
|
+
* Throws rather than returning undefined: callers derive the account commitment from this value,
|
|
30
|
+
* so an absent key is an error, not a state to propagate.
|
|
31
|
+
*/
|
|
32
|
+
export declare const getUncompressedPublicKeyFromWallet: (para: ParaWeb, wallet: Wallet) => Promise<string>;
|
|
33
|
+
export declare const txSummaryToJson: (txSummary: TransactionSummary) => TxSummaryJson;
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miden-sdk/para",
|
|
3
|
-
"version": "0.16.0-rc.
|
|
3
|
+
"version": "0.16.0-rc.6",
|
|
4
|
+
"type": "commonjs",
|
|
4
5
|
"description": "Miden x Para Integration",
|
|
5
6
|
"license": "MIT",
|
|
6
7
|
"author": "Miden Contributors",
|
|
@@ -28,17 +29,22 @@
|
|
|
28
29
|
"react": "^19.2.0",
|
|
29
30
|
"react-test-renderer": "^19.2.0",
|
|
30
31
|
"typescript": "^5.8.3",
|
|
31
|
-
"@miden-sdk/miden-sdk": "0.16.0-rc.
|
|
32
|
+
"@miden-sdk/miden-sdk": "0.16.0-rc.6"
|
|
32
33
|
},
|
|
33
34
|
"peerDependencies": {
|
|
34
35
|
"@getpara/web-sdk": "^2.11.0",
|
|
35
|
-
"@miden-sdk/miden-sdk": "^0.16.0-rc.
|
|
36
|
+
"@miden-sdk/miden-sdk": "^0.16.0-rc.6"
|
|
36
37
|
},
|
|
37
38
|
"exports": {
|
|
38
39
|
".": {
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
"import": {
|
|
41
|
+
"types": "./dist/esm/index.d.ts",
|
|
42
|
+
"default": "./dist/esm/index.js"
|
|
43
|
+
},
|
|
44
|
+
"require": {
|
|
45
|
+
"types": "./dist/cjs/index.d.ts",
|
|
46
|
+
"default": "./dist/cjs/index.js"
|
|
47
|
+
}
|
|
42
48
|
}
|
|
43
49
|
},
|
|
44
50
|
"files": [
|
|
@@ -49,8 +55,8 @@
|
|
|
49
55
|
"main": "dist/cjs/index.js",
|
|
50
56
|
"module": "dist/esm/index.js",
|
|
51
57
|
"sideEffects": false,
|
|
52
|
-
"types": "dist/
|
|
53
|
-
"typings": "dist/
|
|
58
|
+
"types": "dist/cjs/index.d.ts",
|
|
59
|
+
"typings": "dist/cjs/index.d.ts",
|
|
54
60
|
"keywords": [
|
|
55
61
|
"miden",
|
|
56
62
|
"para",
|
|
@@ -63,11 +69,8 @@
|
|
|
63
69
|
"scripts": {
|
|
64
70
|
"test": "node --test",
|
|
65
71
|
"build": "rm -rf dist && node ./scripts/build.mjs && npm run build:types",
|
|
66
|
-
"build:
|
|
67
|
-
"build:esm": "rm -rf dist/esm && tsc --module es6 --outDir dist/esm && printf '{\"type\":\"module\",\"sideEffects\":false}' > dist/esm/package.json",
|
|
68
|
-
"build:types": "rm -rf dist/types && tsc --module es2020 --declarationDir dist/types --emitDeclarationOnly --declaration",
|
|
72
|
+
"build:types": "tsc --module es2020 --declarationDir dist/esm --emitDeclarationOnly --declaration && tsc --module commonjs --declarationDir dist/cjs --emitDeclarationOnly --declaration",
|
|
69
73
|
"format": "pnpm exec prettier \"**/*.{js,jsx,ts,tsx}\" --write && pnpm exec eslint . --fix",
|
|
70
|
-
"format-check": "pnpm exec prettier \"**/*.{js,jsx,ts,tsx}\" && pnpm exec eslint"
|
|
71
|
-
"old-build": "pnpm run build:cjs && pnpm run build:esm && pnpm run build:types"
|
|
74
|
+
"format-check": "pnpm exec prettier \"**/*.{js,jsx,ts,tsx}\" && pnpm exec eslint"
|
|
72
75
|
}
|
|
73
76
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|