@midnight-ntwrk/wallet-sdk-shielded 2.0.0-rc.0 → 2.0.0-rc.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.
@@ -1,13 +1,13 @@
1
1
  import * as ledger from '@midnight-ntwrk/ledger-v7';
2
2
  import type { KeyMaterialProvider } from '@midnight-ntwrk/zkir-v2';
3
- import { ProverClient } from '@midnight-ntwrk/wallet-sdk-prover-client/effect';
4
3
  import { InvalidProtocolSchemeError } from '@midnight-ntwrk/wallet-sdk-utilities/networking';
5
- import { Effect, Layer } from 'effect';
4
+ import { Effect } from 'effect';
6
5
  import { WalletError } from './WalletError.js';
7
6
  export interface ProvingService<TTransaction> {
8
7
  prove(transaction: ledger.UnprovenTransaction): Effect.Effect<TTransaction, WalletError>;
9
8
  }
10
- export declare const makeProvingService: (clientLayer: Layer.Layer<ProverClient.ProverClient, InvalidProtocolSchemeError>) => ProvingService<ledger.FinalizedTransaction>;
9
+ export declare const fromProvingProviderEffect: (provider: Effect.Effect<ledger.ProvingProvider, InvalidProtocolSchemeError>) => ProvingService<ledger.FinalizedTransaction>;
10
+ export declare const fromProvingProvider: (provider: ledger.ProvingProvider) => ProvingService<ledger.FinalizedTransaction>;
11
11
  export type WasmProvingConfiguration = {
12
12
  keyMaterialProvider?: KeyMaterialProvider;
13
13
  };
@@ -11,31 +11,38 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import * as ledger from '@midnight-ntwrk/ledger-v7';
14
- import { HttpProverClient, WasmProver, ProverClient } from '@midnight-ntwrk/wallet-sdk-prover-client/effect';
14
+ import { HttpProverClient, WasmProver } from '@midnight-ntwrk/wallet-sdk-prover-client/effect';
15
+ import { ClientError, ServerError } from '@midnight-ntwrk/wallet-sdk-utilities/networking';
15
16
  import { Effect, pipe } from 'effect';
16
17
  import { ProvingError } from './WalletError.js';
17
- export const makeProvingService = (clientLayer) => {
18
+ export const fromProvingProviderEffect = (provider) => {
18
19
  return {
19
20
  prove(transaction) {
20
- return pipe(ProverClient.ProverClient, Effect.flatMap((client) => client.proveTransaction(transaction, ledger.CostModel.initialCostModel())), Effect.map((transaction) => transaction.bind()), Effect.provide(clientLayer), Effect.catchAll((error) => Effect.fail(new ProvingError({
21
+ return pipe(provider, Effect.flatMap((provider) => Effect.tryPromise({
22
+ try: () => transaction.prove(provider, ledger.CostModel.initialCostModel()),
23
+ catch: (error) => error instanceof ClientError || error instanceof ServerError
24
+ ? error
25
+ : new ClientError({ message: 'Failed to prove transaction', cause: error }),
26
+ })), Effect.map((transaction) => transaction.bind()), Effect.catchAll((error) => Effect.fail(new ProvingError({
21
27
  message: error.message,
22
28
  cause: error,
23
29
  }))));
24
30
  },
25
31
  };
26
32
  };
33
+ export const fromProvingProvider = (provider) => {
34
+ return fromProvingProviderEffect(Effect.succeed(provider));
35
+ };
27
36
  export const makeDefaultProvingService = (configuration) => makeServerProvingService(configuration);
28
37
  export const makeServerProvingService = (configuration) => {
29
- const clientLayer = HttpProverClient.layer({
38
+ return pipe(HttpProverClient.create({
30
39
  url: configuration.provingServerUrl,
31
- });
32
- return makeProvingService(clientLayer);
40
+ }), Effect.map((client) => client.asProvingProvider()), fromProvingProviderEffect);
33
41
  };
34
42
  export const makeWasmProvingService = (configuration) => {
35
- const proverLayer = WasmProver.layer({
43
+ return pipe(WasmProver.create({
36
44
  keyMaterialProvider: configuration.keyMaterialProvider ?? WasmProver.makeDefaultKeyMaterialProvider(),
37
- });
38
- return makeProvingService(proverLayer);
45
+ }), Effect.map((prover) => prover.asProvingProvider()), fromProvingProviderEffect);
39
46
  };
40
47
  export const makeSimulatorProvingService = () => {
41
48
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midnight-ntwrk/wallet-sdk-shielded",
3
- "version": "2.0.0-rc.0",
3
+ "version": "2.0.0-rc.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -29,14 +29,14 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@midnight-ntwrk/ledger-v7": "7.0.0",
32
- "@midnight-ntwrk/wallet-sdk-abstractions": "1.0.0",
32
+ "@midnight-ntwrk/wallet-sdk-abstractions": "2.0.0-rc.0",
33
33
  "@midnight-ntwrk/wallet-sdk-address-format": "3.0.0",
34
- "@midnight-ntwrk/wallet-sdk-capabilities": "3.1.0-rc.0",
35
- "@midnight-ntwrk/wallet-sdk-indexer-client": "1.1.0-rc.0",
34
+ "@midnight-ntwrk/wallet-sdk-capabilities": "3.1.0-rc.1",
35
+ "@midnight-ntwrk/wallet-sdk-indexer-client": "1.1.0-rc.1",
36
36
  "@midnight-ntwrk/wallet-sdk-node-client": "1.0.0",
37
- "@midnight-ntwrk/wallet-sdk-prover-client": "1.1.0-rc.0",
38
- "@midnight-ntwrk/wallet-sdk-runtime": "1.0.0",
39
- "@midnight-ntwrk/wallet-sdk-utilities": "1.0.0",
37
+ "@midnight-ntwrk/wallet-sdk-prover-client": "1.1.0-rc.1",
38
+ "@midnight-ntwrk/wallet-sdk-runtime": "1.0.1-rc.0",
39
+ "@midnight-ntwrk/wallet-sdk-utilities": "1.0.1-rc.0",
40
40
  "@midnight-ntwrk/zkir-v2": "2.1.0",
41
41
  "@scure/base": "^1.1.9",
42
42
  "effect": "^3.19.14",