@midnight-ntwrk/wallet-sdk-prover-client 1.0.0-beta.8 → 1.0.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.
- package/README.md +77 -0
- package/dist/effect/HttpProverClient.js +13 -1
- package/dist/effect/ProverClient.d.ts +1 -1
- package/dist/effect/ProverClient.js +12 -0
- package/dist/effect/index.js +12 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -0
- package/package.json +11 -9
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# @midnight-ntwrk/wallet-sdk-prover-client
|
|
2
|
+
|
|
3
|
+
Client for interacting with the Midnight ZK proof generation service.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @midnight-ntwrk/wallet-sdk-prover-client
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
This package provides a client for submitting transactions to a Proof Server that generates zero-knowledge proofs. It is
|
|
14
|
+
used to finalize shielded transactions by converting unproven transactions into proven ones.
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
### Basic Usage
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { HttpProverClient } from '@midnight-ntwrk/wallet-sdk-prover-client';
|
|
22
|
+
|
|
23
|
+
// Initialize the client with the Proof Server URL
|
|
24
|
+
const proverClient = new HttpProverClient({
|
|
25
|
+
serverUrl: 'http://localhost:6300',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Prove an unproven transaction
|
|
29
|
+
const provenTransaction = await proverClient.proveTransaction(unprovenTransaction);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### With Custom Cost Model
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
const provenTransaction = await proverClient.proveTransaction(unprovenTransaction, customCostModel);
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## API
|
|
39
|
+
|
|
40
|
+
### HttpProverClient
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
class HttpProverClient {
|
|
44
|
+
constructor(config: { serverUrl: string });
|
|
45
|
+
|
|
46
|
+
proveTransaction<S extends Signaturish, B extends Bindingish>(
|
|
47
|
+
transaction: Transaction<S, PreProof, B>,
|
|
48
|
+
costModel?: CostModel,
|
|
49
|
+
): Promise<Transaction<S, Proof, B>>;
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Exports
|
|
54
|
+
|
|
55
|
+
### Default Export
|
|
56
|
+
|
|
57
|
+
- `HttpProverClient` - HTTP client for the Proof Server
|
|
58
|
+
|
|
59
|
+
### Effect Submodule (`/effect`)
|
|
60
|
+
|
|
61
|
+
Effect.ts-based implementation:
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import { ProverClient, HttpProverClient } from '@midnight-ntwrk/wallet-sdk-prover-client/effect';
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Error Handling
|
|
68
|
+
|
|
69
|
+
The client may throw the following errors:
|
|
70
|
+
|
|
71
|
+
- `ClientError` - Issues with the provided transaction or connection problems
|
|
72
|
+
- `ServerError` - Internal server errors or connection failures
|
|
73
|
+
- `InvalidProtocolSchemeError` - Invalid URL scheme in configuration
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
Apache-2.0
|
|
@@ -1,10 +1,22 @@
|
|
|
1
|
+
// This file is part of MIDNIGHT-WALLET-SDK.
|
|
2
|
+
// Copyright (C) 2025 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.
|
|
1
13
|
import { Chunk, Duration, Effect, Either, Layer, pipe, Schedule, Stream } from 'effect';
|
|
2
14
|
import { FetchHttpClient, HttpClient, HttpClientRequest } from '@effect/platform';
|
|
3
15
|
import { SerializedTransaction, SerializedUnprovenTransaction } from '@midnight-ntwrk/wallet-sdk-abstractions';
|
|
4
16
|
import { ProverClient } from './ProverClient.js';
|
|
5
17
|
import { ClientError, ServerError, HttpURL, } from '@midnight-ntwrk/wallet-sdk-utilities/networking';
|
|
6
18
|
import { BlobOps } from '@midnight-ntwrk/wallet-sdk-utilities';
|
|
7
|
-
import * as ledger from '@midnight-ntwrk/ledger-
|
|
19
|
+
import * as ledger from '@midnight-ntwrk/ledger-v7';
|
|
8
20
|
const PROVE_TX_PATH = '/prove';
|
|
9
21
|
const CHECK_TX_PATH = '/check';
|
|
10
22
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect, Context } from 'effect';
|
|
2
|
-
import * as ledger from '@midnight-ntwrk/ledger-
|
|
2
|
+
import * as ledger from '@midnight-ntwrk/ledger-v7';
|
|
3
3
|
import { ClientError, ServerError } from '@midnight-ntwrk/wallet-sdk-utilities/networking';
|
|
4
4
|
declare const ProverClient_base: Context.TagClass<ProverClient, "@midnight-ntwrk/prover-client#ProverClient", ProverClient.Service>;
|
|
5
5
|
/**
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
// This file is part of MIDNIGHT-WALLET-SDK.
|
|
2
|
+
// Copyright (C) 2025 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.
|
|
1
13
|
import { Context } from 'effect';
|
|
2
14
|
/**
|
|
3
15
|
* A client that provides proof services for unproven transactions.
|
package/dist/effect/index.js
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
|
+
// This file is part of MIDNIGHT-WALLET-SDK.
|
|
2
|
+
// Copyright (C) 2025 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.
|
|
1
13
|
export * as ProverClient from './ProverClient.js';
|
|
2
14
|
export * as HttpProverClient from './HttpProverClient.js';
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
// This file is part of MIDNIGHT-WALLET-SDK.
|
|
2
|
+
// Copyright (C) 2025 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.
|
|
1
13
|
import { Effect } from 'effect';
|
|
2
14
|
import { ProverClient, HttpProverClient as _HttpProverClient } from './effect/index.js';
|
|
3
15
|
/**
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midnight-ntwrk/wallet-sdk-prover-client",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
|
-
"author": "
|
|
8
|
+
"author": "Midnight Foundation",
|
|
9
9
|
"license": "Apache-2.0",
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"registry": "https://npm.pkg.github.com/"
|
|
@@ -29,24 +29,26 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@effect/platform": "^0.90.0",
|
|
32
|
-
"@midnight-ntwrk/ledger-
|
|
33
|
-
"@midnight-ntwrk/wallet-sdk-abstractions": "1.0.0
|
|
34
|
-
"@midnight-ntwrk/wallet-sdk-utilities": "1.0.0
|
|
35
|
-
"effect": "^3.
|
|
32
|
+
"@midnight-ntwrk/ledger-v7": "7.0.0",
|
|
33
|
+
"@midnight-ntwrk/wallet-sdk-abstractions": "1.0.0",
|
|
34
|
+
"@midnight-ntwrk/wallet-sdk-utilities": "1.0.0",
|
|
35
|
+
"effect": "^3.19.14"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"eslint": "^9.37.0",
|
|
39
|
+
"prettier": "^3.7.0",
|
|
39
40
|
"publint": "~0.3.14",
|
|
40
41
|
"rimraf": "^6.0.1",
|
|
41
|
-
"testcontainers": "^11.
|
|
42
|
+
"testcontainers": "^11.10.0",
|
|
42
43
|
"typescript": "^5.9.3",
|
|
43
|
-
"vitest": "^
|
|
44
|
+
"vitest": "^4.0.16"
|
|
44
45
|
},
|
|
45
46
|
"scripts": {
|
|
46
47
|
"typecheck": "tsc -b ./tsconfig.json --noEmit",
|
|
47
48
|
"test": "vitest run",
|
|
48
49
|
"lint": "eslint --max-warnings 0",
|
|
49
|
-
"format": "prettier --write \"**/*.{ts,js,json,yaml,yml}\"",
|
|
50
|
+
"format": "prettier --write \"**/*.{ts,js,json,yaml,yml,md}\"",
|
|
51
|
+
"format:check": "prettier --check \"**/*.{ts,js,json,yaml,yml,md}\"",
|
|
50
52
|
"dist": "tsc -b ./tsconfig.build.json",
|
|
51
53
|
"dist:publish": "tsc -b ./tsconfig.publish.json",
|
|
52
54
|
"clean": "rimraf --glob dist 'tsconfig.*.tsbuildinfo' && date +%s > .clean-timestamp",
|