@midnight-ntwrk/wallet-sdk-capabilities 3.1.0-rc.1 → 3.1.0

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.
@@ -1,5 +1,5 @@
1
1
  // This file is part of MIDNIGHT-WALLET-SDK.
2
- // Copyright (C) 2025 Midnight Foundation
2
+ // Copyright (C) Midnight Foundation
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  // Licensed under the Apache License, Version 2.0 (the "License");
5
5
  // You may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  // This file is part of MIDNIGHT-WALLET-SDK.
2
- // Copyright (C) 2025 Midnight Foundation
2
+ // Copyright (C) Midnight Foundation
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  // Licensed under the Apache License, Version 2.0 (the "License");
5
5
  // You may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  // This file is part of MIDNIGHT-WALLET-SDK.
2
- // Copyright (C) 2025 Midnight Foundation
2
+ // Copyright (C) Midnight Foundation
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  // Licensed under the Apache License, Version 2.0 (the "License");
5
5
  // You may not use this file except in compliance with the License.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './balancer/index.js';
2
2
  export * from './pendingTransactions/index.js';
3
+ export * from './proving/index.js';
3
4
  export * from './submission/index.js';
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // This file is part of MIDNIGHT-WALLET-SDK.
2
- // Copyright (C) 2025 Midnight Foundation
2
+ // Copyright (C) Midnight Foundation
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  // Licensed under the Apache License, Version 2.0 (the "License");
5
5
  // You may not use this file except in compliance with the License.
@@ -12,4 +12,5 @@
12
12
  // limitations under the License.
13
13
  export * from './balancer/index.js';
14
14
  export * from './pendingTransactions/index.js';
15
+ export * from './proving/index.js';
15
16
  export * from './submission/index.js';
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * This file is part of MIDNIGHT-WALLET-SDK.
3
- * Copyright (C) 2025 Midnight Foundation
3
+ * Copyright (C) Midnight Foundation
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * You may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * This file is part of MIDNIGHT-WALLET-SDK.
3
- * Copyright (C) 2025 Midnight Foundation
3
+ * Copyright (C) Midnight Foundation
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * You may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * This file is part of MIDNIGHT-WALLET-SDK.
3
- * Copyright (C) 2025 Midnight Foundation
3
+ * Copyright (C) Midnight Foundation
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * You may not use this file except in compliance with the License.
@@ -0,0 +1 @@
1
+ export * from './provingService.js';
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This file is part of MIDNIGHT-WALLET-SDK.
3
+ * Copyright (C) Midnight Foundation
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * You may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+ export * from './provingService.js';
@@ -0,0 +1,37 @@
1
+ import * as ledger from '@midnight-ntwrk/ledger-v7';
2
+ import type { KeyMaterialProvider } from '@midnight-ntwrk/zkir-v2';
3
+ import { InvalidProtocolSchemeError } from '@midnight-ntwrk/wallet-sdk-utilities/networking';
4
+ import { Effect } from 'effect';
5
+ declare const ProvingError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
6
+ readonly _tag: "Wallet.Proving";
7
+ } & Readonly<A>;
8
+ export declare class ProvingError extends ProvingError_base<{
9
+ message: string;
10
+ cause: Error;
11
+ }> {
12
+ }
13
+ export interface ProvingServiceEffect<TTransaction> {
14
+ prove(transaction: ledger.UnprovenTransaction): Effect.Effect<TTransaction, ProvingError>;
15
+ }
16
+ export interface ProvingService<TTransaction> {
17
+ prove(transaction: ledger.UnprovenTransaction): Promise<TTransaction>;
18
+ }
19
+ export type UnboundTransaction = ledger.Transaction<ledger.SignatureEnabled, ledger.Proof, ledger.PreBinding>;
20
+ export declare const fromProvingProviderEffect: (provider: Effect.Effect<ledger.ProvingProvider, InvalidProtocolSchemeError>) => ProvingServiceEffect<UnboundTransaction>;
21
+ export declare const fromProvingProvider: (provider: ledger.ProvingProvider) => ProvingServiceEffect<UnboundTransaction>;
22
+ export type ServerProvingConfiguration = {
23
+ provingServerUrl: URL;
24
+ };
25
+ export type WasmProvingConfiguration = {
26
+ keyMaterialProvider?: KeyMaterialProvider;
27
+ };
28
+ export type DefaultProvingConfiguration = ServerProvingConfiguration;
29
+ export declare const makeServerProvingServiceEffect: (configuration: ServerProvingConfiguration) => ProvingServiceEffect<UnboundTransaction>;
30
+ export declare const makeWasmProvingServiceEffect: (configuration?: WasmProvingConfiguration) => ProvingServiceEffect<UnboundTransaction>;
31
+ export declare const makeSimulatorProvingServiceEffect: () => ProvingServiceEffect<ledger.ProofErasedTransaction>;
32
+ export declare const makeDefaultProvingServiceEffect: (configuration: DefaultProvingConfiguration) => ProvingServiceEffect<UnboundTransaction>;
33
+ export declare const makeDefaultProvingService: (configuration: DefaultProvingConfiguration) => ProvingService<UnboundTransaction>;
34
+ export declare const makeServerProvingService: (configuration: ServerProvingConfiguration) => ProvingService<UnboundTransaction>;
35
+ export declare const makeWasmProvingService: (configuration?: WasmProvingConfiguration) => ProvingService<UnboundTransaction>;
36
+ export declare const makeSimulatorProvingService: () => ProvingService<ledger.ProofErasedTransaction>;
37
+ export {};
@@ -0,0 +1,61 @@
1
+ // This file is part of MIDNIGHT-WALLET-SDK.
2
+ // Copyright (C) Midnight Foundation
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // You may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import * as ledger from '@midnight-ntwrk/ledger-v7';
14
+ import { HttpProverClient, WasmProver } from '@midnight-ntwrk/wallet-sdk-prover-client/effect';
15
+ import { ClientError, ServerError } from '@midnight-ntwrk/wallet-sdk-utilities/networking';
16
+ import { Data, Effect, pipe } from 'effect';
17
+ export class ProvingError extends Data.TaggedError('Wallet.Proving') {
18
+ }
19
+ const wrapEffectService = (effectService) => ({
20
+ prove: (transaction) => Effect.runPromise(effectService.prove(transaction)),
21
+ });
22
+ export const fromProvingProviderEffect = (provider) => {
23
+ return {
24
+ prove(transaction) {
25
+ return pipe(provider, Effect.flatMap((provider) => Effect.tryPromise({
26
+ try: () => transaction.prove(provider, ledger.CostModel.initialCostModel()),
27
+ catch: (error) => error instanceof ClientError || error instanceof ServerError
28
+ ? error
29
+ : new ClientError({ message: 'Failed to prove transaction', cause: error }),
30
+ })), Effect.catchAll((error) => Effect.fail(new ProvingError({
31
+ message: error.message,
32
+ cause: error,
33
+ }))));
34
+ },
35
+ };
36
+ };
37
+ export const fromProvingProvider = (provider) => {
38
+ return fromProvingProviderEffect(Effect.succeed(provider));
39
+ };
40
+ export const makeServerProvingServiceEffect = (configuration) => {
41
+ return pipe(HttpProverClient.create({
42
+ url: configuration.provingServerUrl,
43
+ }), Effect.map((client) => client.asProvingProvider()), fromProvingProviderEffect);
44
+ };
45
+ export const makeWasmProvingServiceEffect = (configuration) => {
46
+ return pipe(WasmProver.create({
47
+ keyMaterialProvider: configuration?.keyMaterialProvider ?? WasmProver.makeDefaultKeyMaterialProvider(),
48
+ }), Effect.map((prover) => prover.asProvingProvider()), fromProvingProviderEffect);
49
+ };
50
+ export const makeSimulatorProvingServiceEffect = () => {
51
+ return {
52
+ prove(transaction) {
53
+ return Effect.succeed(transaction.eraseProofs());
54
+ },
55
+ };
56
+ };
57
+ export const makeDefaultProvingServiceEffect = (configuration) => makeServerProvingServiceEffect(configuration);
58
+ export const makeDefaultProvingService = (configuration) => wrapEffectService(makeDefaultProvingServiceEffect(configuration));
59
+ export const makeServerProvingService = (configuration) => wrapEffectService(makeServerProvingServiceEffect(configuration));
60
+ export const makeWasmProvingService = (configuration) => wrapEffectService(makeWasmProvingServiceEffect(configuration));
61
+ export const makeSimulatorProvingService = () => wrapEffectService(makeSimulatorProvingServiceEffect());
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * This file is part of MIDNIGHT-WALLET-SDK.
3
- * Copyright (C) 2025 Midnight Foundation
3
+ * Copyright (C) Midnight Foundation
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * You may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  // This file is part of MIDNIGHT-WALLET-SDK.
2
- // Copyright (C) 2025 Midnight Foundation
2
+ // Copyright (C) Midnight Foundation
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  // Licensed under the Apache License, Version 2.0 (the "License");
5
5
  // You may not use this file except in compliance with the License.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midnight-ntwrk/wallet-sdk-capabilities",
3
- "version": "3.1.0-rc.1",
3
+ "version": "3.1.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -33,25 +33,31 @@
33
33
  "./pendingTransactions": {
34
34
  "types": "./dist/pendingTransactions/index.d.ts",
35
35
  "import": "./dist/pendingTransactions/index.js"
36
+ },
37
+ "./proving": {
38
+ "types": "./dist/proving/index.d.ts",
39
+ "import": "./dist/proving/index.js"
36
40
  }
37
41
  },
38
42
  "dependencies": {
39
- "@midnight-ntwrk/wallet-sdk-address-format": "^3.0.0",
40
- "@midnight-ntwrk/wallet-sdk-hd": "^3.0.0",
41
- "@midnight-ntwrk/wallet-sdk-indexer-client": "^1.1.0-rc.1",
42
- "@midnight-ntwrk/wallet-sdk-node-client": "^1.0.0",
43
- "@midnight-ntwrk/wallet-sdk-utilities": "^1.0.1-rc.0",
44
- "effect": "^3.19.14"
43
+ "@midnight-ntwrk/ledger-v7": "^7.0.2",
44
+ "@midnight-ntwrk/wallet-sdk-abstractions": "^2.0.0",
45
+ "@midnight-ntwrk/wallet-sdk-indexer-client": "^1.1.0",
46
+ "@midnight-ntwrk/wallet-sdk-node-client": "^1.0.1",
47
+ "@midnight-ntwrk/wallet-sdk-prover-client": "^1.1.0",
48
+ "@midnight-ntwrk/wallet-sdk-utilities": "^1.0.1",
49
+ "@midnight-ntwrk/zkir-v2": "^2.1.0",
50
+ "effect": "^3.19.19",
51
+ "rxjs": "^7.8.2"
45
52
  },
46
53
  "devDependencies": {
47
- "@midnight-ntwrk/ledger-v7": "^7.0.0",
48
- "eslint": "^9.37.0",
49
- "fast-check": "^4.2.0",
50
- "prettier": "^3.7.0",
51
- "publint": "~0.3.14",
52
- "rimraf": "^6.0.1",
53
- "typescript": "^5.9.3",
54
- "vitest": "^4.0.16"
54
+ "@effect/cluster": "^0.56.4",
55
+ "@effect/experimental": "^0.58.0",
56
+ "@effect/platform": "^0.94.5",
57
+ "@effect/platform-node": "^0.104.1",
58
+ "@effect/rpc": "^0.73.2",
59
+ "@effect/sql": "^0.49.0",
60
+ "@effect/workflow": "^0.16.0"
55
61
  },
56
62
  "scripts": {
57
63
  "typecheck": "tsc -b ./tsconfig.json --noEmit --force",