@miden-sdk/para 0.16.0 → 0.16.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/README.md +2 -2
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/midenClient.d.ts +1 -1
- package/dist/cjs/midenClient.js +1 -1
- package/dist/cjs/utils.d.ts +11 -1
- package/dist/cjs/utils.js +23 -0
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +4 -2
- package/dist/esm/midenClient.d.ts +1 -1
- package/dist/esm/midenClient.js +3 -4
- package/dist/esm/utils.d.ts +11 -1
- package/dist/esm/utils.js +23 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -19,12 +19,12 @@ This project uses Yarn 1.22.22. The version is locked in `package.json` and will
|
|
|
19
19
|
`@miden-sdk/para` expects these packages to be provided by the consuming app. Install matching versions alongside this package to avoid duplicate copies:
|
|
20
20
|
|
|
21
21
|
- `@miden-sdk/miden-sdk@^0.13.0`
|
|
22
|
-
- `@getpara/web-sdk
|
|
22
|
+
- `@getpara/web-sdk@^3.18.0`
|
|
23
23
|
|
|
24
24
|
Example install:
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
|
-
yarn add @miden-sdk/para @miden-sdk/miden-sdk@^0.
|
|
27
|
+
yarn add @miden-sdk/para @miden-sdk/miden-sdk@^0.16.1 @getpara/web-sdk@^3.18.0
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
When creating a client with `storageMode` set to `private`, supply an `accountSeed`; the initializer will throw if it is missing so that private accounts remain recoverable.
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from "./midenClient.js";
|
|
2
|
-
export { evmPkToCommitment, getUncompressedPublicKeyFromWallet, } from "./utils.js";
|
|
2
|
+
export { evmPkToCommitment, getUncompressedPublicKeyFromWallet, resolveEvmWallets, } from "./utils.js";
|
|
3
3
|
export type { MidenAccountOpts, Opts, MidenAccountStorageMode, TxSummaryJson, } from "./types.js";
|
|
4
4
|
export type { CustomSignConfirmStep } from "./midenClient.js";
|
package/dist/cjs/index.js
CHANGED
|
@@ -20,7 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
var index_exports = {};
|
|
21
21
|
__export(index_exports, {
|
|
22
22
|
evmPkToCommitment: () => import_utils.evmPkToCommitment,
|
|
23
|
-
getUncompressedPublicKeyFromWallet: () => import_utils.getUncompressedPublicKeyFromWallet
|
|
23
|
+
getUncompressedPublicKeyFromWallet: () => import_utils.getUncompressedPublicKeyFromWallet,
|
|
24
|
+
resolveEvmWallets: () => import_utils.resolveEvmWallets
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(index_exports);
|
|
26
27
|
__reExport(index_exports, require("./midenClient.js"), module.exports);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ParaWeb, Wallet } from "@getpara/web-sdk";
|
|
1
|
+
import type { ParaWeb, Wallet } from "@getpara/web-sdk";
|
|
2
2
|
import type { Opts, TxSummaryJson } from "./types.js";
|
|
3
3
|
import type { MidenClient } from "@miden-sdk/miden-sdk";
|
|
4
4
|
export type CustomSignConfirmStep = (txSummaryJson: TxSummaryJson) => Promise<unknown>;
|
package/dist/cjs/midenClient.js
CHANGED
|
@@ -89,7 +89,7 @@ async function createAccount(client, publicKey, opts) {
|
|
|
89
89
|
return account.id().toString();
|
|
90
90
|
}
|
|
91
91
|
async function createParaMidenClient(para, wallets, opts, showSigningModal = true, customSignConfirmStep) {
|
|
92
|
-
const evmWallets =
|
|
92
|
+
const evmWallets = (0, import_utils.resolveEvmWallets)(para, wallets);
|
|
93
93
|
if (!evmWallets?.length) {
|
|
94
94
|
throw new Error("No EVM wallets provided");
|
|
95
95
|
}
|
package/dist/cjs/utils.d.ts
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
import ParaWeb
|
|
1
|
+
import type ParaWeb from "@getpara/web-sdk";
|
|
2
|
+
import type { Wallet } from "@getpara/web-sdk";
|
|
2
3
|
import type { TransactionSummary } from "@miden-sdk/miden-sdk";
|
|
3
4
|
import { hexToBytes } from "@noble/hashes/utils.js";
|
|
4
5
|
import { TxSummaryJson } from "./types.js";
|
|
5
6
|
/** @public */
|
|
6
7
|
export { hexToBytes };
|
|
8
|
+
/**
|
|
9
|
+
* Prefer Para 3.x `getWalletsByType("EVM")`, which returns full `Wallet`
|
|
10
|
+
* records including `publicKey`. `useAccount().embedded.wallets` is
|
|
11
|
+
* `AvailableWallet[]` and omits `publicKey`, so signing would otherwise
|
|
12
|
+
* always fall through to `issueJwt`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const resolveEvmWallets: (para: ParaWeb, wallets: Array<Pick<Wallet, "id"> & {
|
|
15
|
+
type?: string;
|
|
16
|
+
}>) => Wallet[];
|
|
7
17
|
/**
|
|
8
18
|
* Converts a Para hex signature into the serialized format expected by Miden.
|
|
9
19
|
* Prefixes the auth scheme byte and appends the extra padding byte required by current crypto libs.
|
package/dist/cjs/utils.js
CHANGED
|
@@ -33,10 +33,33 @@ __export(utils_exports, {
|
|
|
33
33
|
fromHexSig: () => fromHexSig,
|
|
34
34
|
getUncompressedPublicKeyFromWallet: () => getUncompressedPublicKeyFromWallet,
|
|
35
35
|
hexToBytes: () => import_utils.hexToBytes,
|
|
36
|
+
resolveEvmWallets: () => resolveEvmWallets,
|
|
36
37
|
txSummaryToJson: () => txSummaryToJson
|
|
37
38
|
});
|
|
38
39
|
module.exports = __toCommonJS(utils_exports);
|
|
39
40
|
var import_utils = require("@noble/hashes/utils.js");
|
|
41
|
+
const EVM_WALLET_TYPE = "EVM";
|
|
42
|
+
const isEvmWallet = (wallet) => wallet.type === EVM_WALLET_TYPE;
|
|
43
|
+
const resolveEvmWallets = (para, wallets) => {
|
|
44
|
+
const listed = wallets.filter(isEvmWallet);
|
|
45
|
+
if (typeof para.getWalletsByType !== "function") {
|
|
46
|
+
return listed;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
const full = para.getWalletsByType(EVM_WALLET_TYPE);
|
|
50
|
+
if (!Array.isArray(full) || full.length === 0) {
|
|
51
|
+
return listed;
|
|
52
|
+
}
|
|
53
|
+
if (listed.length === 0) {
|
|
54
|
+
return full;
|
|
55
|
+
}
|
|
56
|
+
const ids = new Set(listed.map((wallet) => wallet.id));
|
|
57
|
+
const matched = full.filter((wallet) => ids.has(wallet.id));
|
|
58
|
+
return matched.length > 0 ? matched : listed;
|
|
59
|
+
} catch {
|
|
60
|
+
return listed;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
40
63
|
const fromHexSig = (hexString) => {
|
|
41
64
|
if (hexString.length % 2 !== 0) {
|
|
42
65
|
throw new Error("Invalid string len");
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from "./midenClient.js";
|
|
2
|
-
export { evmPkToCommitment, getUncompressedPublicKeyFromWallet, } from "./utils.js";
|
|
2
|
+
export { evmPkToCommitment, getUncompressedPublicKeyFromWallet, resolveEvmWallets, } from "./utils.js";
|
|
3
3
|
export type { MidenAccountOpts, Opts, MidenAccountStorageMode, TxSummaryJson, } from "./types.js";
|
|
4
4
|
export type { CustomSignConfirmStep } from "./midenClient.js";
|
package/dist/esm/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export * from "./midenClient.js";
|
|
2
2
|
import {
|
|
3
3
|
evmPkToCommitment,
|
|
4
|
-
getUncompressedPublicKeyFromWallet
|
|
4
|
+
getUncompressedPublicKeyFromWallet,
|
|
5
|
+
resolveEvmWallets
|
|
5
6
|
} from "./utils.js";
|
|
6
7
|
export {
|
|
7
8
|
evmPkToCommitment,
|
|
8
|
-
getUncompressedPublicKeyFromWallet
|
|
9
|
+
getUncompressedPublicKeyFromWallet,
|
|
10
|
+
resolveEvmWallets
|
|
9
11
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ParaWeb, Wallet } from "@getpara/web-sdk";
|
|
1
|
+
import type { ParaWeb, Wallet } from "@getpara/web-sdk";
|
|
2
2
|
import type { Opts, TxSummaryJson } from "./types.js";
|
|
3
3
|
import type { MidenClient } from "@miden-sdk/miden-sdk";
|
|
4
4
|
export type CustomSignConfirmStep = (txSummaryJson: TxSummaryJson) => Promise<unknown>;
|
package/dist/esm/midenClient.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
hexStringToBase64
|
|
3
|
-
} from "@getpara/web-sdk";
|
|
1
|
+
import { hexStringToBase64 } from "@getpara/web-sdk";
|
|
4
2
|
import { keccak_256 as keccak256 } from "@noble/hashes/sha3.js";
|
|
5
3
|
import {
|
|
6
4
|
accountSeedFromStr,
|
|
7
5
|
evmPkToCommitment,
|
|
8
6
|
fromHexSig,
|
|
9
7
|
getUncompressedPublicKeyFromWallet,
|
|
8
|
+
resolveEvmWallets,
|
|
10
9
|
txSummaryToJson
|
|
11
10
|
} from "./utils.js";
|
|
12
11
|
import { bytesToHex, hexToBytes } from "@noble/hashes/utils.js";
|
|
@@ -63,7 +62,7 @@ async function createAccount(client, publicKey, opts) {
|
|
|
63
62
|
return account.id().toString();
|
|
64
63
|
}
|
|
65
64
|
async function createParaMidenClient(para, wallets, opts, showSigningModal = true, customSignConfirmStep) {
|
|
66
|
-
const evmWallets =
|
|
65
|
+
const evmWallets = resolveEvmWallets(para, wallets);
|
|
67
66
|
if (!evmWallets?.length) {
|
|
68
67
|
throw new Error("No EVM wallets provided");
|
|
69
68
|
}
|
package/dist/esm/utils.d.ts
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
import ParaWeb
|
|
1
|
+
import type ParaWeb from "@getpara/web-sdk";
|
|
2
|
+
import type { Wallet } from "@getpara/web-sdk";
|
|
2
3
|
import type { TransactionSummary } from "@miden-sdk/miden-sdk";
|
|
3
4
|
import { hexToBytes } from "@noble/hashes/utils.js";
|
|
4
5
|
import { TxSummaryJson } from "./types.js";
|
|
5
6
|
/** @public */
|
|
6
7
|
export { hexToBytes };
|
|
8
|
+
/**
|
|
9
|
+
* Prefer Para 3.x `getWalletsByType("EVM")`, which returns full `Wallet`
|
|
10
|
+
* records including `publicKey`. `useAccount().embedded.wallets` is
|
|
11
|
+
* `AvailableWallet[]` and omits `publicKey`, so signing would otherwise
|
|
12
|
+
* always fall through to `issueJwt`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const resolveEvmWallets: (para: ParaWeb, wallets: Array<Pick<Wallet, "id"> & {
|
|
15
|
+
type?: string;
|
|
16
|
+
}>) => Wallet[];
|
|
7
17
|
/**
|
|
8
18
|
* Converts a Para hex signature into the serialized format expected by Miden.
|
|
9
19
|
* Prefixes the auth scheme byte and appends the extra padding byte required by current crypto libs.
|
package/dist/esm/utils.js
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
import { hexToBytes, utf8ToBytes } from "@noble/hashes/utils.js";
|
|
2
|
+
const EVM_WALLET_TYPE = "EVM";
|
|
3
|
+
const isEvmWallet = (wallet) => wallet.type === EVM_WALLET_TYPE;
|
|
4
|
+
const resolveEvmWallets = (para, wallets) => {
|
|
5
|
+
const listed = wallets.filter(isEvmWallet);
|
|
6
|
+
if (typeof para.getWalletsByType !== "function") {
|
|
7
|
+
return listed;
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
const full = para.getWalletsByType(EVM_WALLET_TYPE);
|
|
11
|
+
if (!Array.isArray(full) || full.length === 0) {
|
|
12
|
+
return listed;
|
|
13
|
+
}
|
|
14
|
+
if (listed.length === 0) {
|
|
15
|
+
return full;
|
|
16
|
+
}
|
|
17
|
+
const ids = new Set(listed.map((wallet) => wallet.id));
|
|
18
|
+
const matched = full.filter((wallet) => ids.has(wallet.id));
|
|
19
|
+
return matched.length > 0 ? matched : listed;
|
|
20
|
+
} catch {
|
|
21
|
+
return listed;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
2
24
|
const fromHexSig = (hexString) => {
|
|
3
25
|
if (hexString.length % 2 !== 0) {
|
|
4
26
|
throw new Error("Invalid string len");
|
|
@@ -107,5 +129,6 @@ export {
|
|
|
107
129
|
fromHexSig,
|
|
108
130
|
getUncompressedPublicKeyFromWallet,
|
|
109
131
|
hexToBytes,
|
|
132
|
+
resolveEvmWallets,
|
|
110
133
|
txSummaryToJson
|
|
111
134
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miden-sdk/para",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"description": "Miden x Para Integration",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@noble/hashes": "^2.0.1"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@getpara/web-sdk": "^
|
|
22
|
+
"@getpara/web-sdk": "^3.18.0",
|
|
23
23
|
"@types/react": "^19.0.0",
|
|
24
24
|
"esbuild": "^0.24.0",
|
|
25
25
|
"eslint": "^9.39.1",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"react": "^19.2.0",
|
|
30
30
|
"react-test-renderer": "^19.2.0",
|
|
31
31
|
"typescript": "^5.8.3",
|
|
32
|
-
"@miden-sdk/miden-sdk": "0.16.
|
|
32
|
+
"@miden-sdk/miden-sdk": "0.16.1"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@getpara/web-sdk": "^
|
|
36
|
-
"@miden-sdk/miden-sdk": "^0.16.
|
|
35
|
+
"@getpara/web-sdk": "^3.18.0",
|
|
36
|
+
"@miden-sdk/miden-sdk": "^0.16.1"
|
|
37
37
|
},
|
|
38
38
|
"exports": {
|
|
39
39
|
".": {
|