@midnight-ntwrk/wallet-sdk 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 ADDED
@@ -0,0 +1,148 @@
1
+ # @midnight-ntwrk/wallet-sdk
2
+
3
+ Barrel package for the Midnight Wallet SDK. Instead of installing and importing from multiple
4
+ `@midnight-ntwrk/wallet-sdk-*` packages individually, this package re-exports them all through a single dependency with
5
+ multiple entry points.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @midnight-ntwrk/wallet-sdk
11
+ ```
12
+
13
+ ## Overview
14
+
15
+ This package provides a unified installation and import experience for the Midnight Wallet SDK. The main entry point
16
+ re-exports the core wallet types, while dedicated sub-path exports give access to each underlying package:
17
+
18
+ | Entry Point | Re-exports |
19
+ | ------------------------------------------- | ---------------------------------------------------------------------------------------- |
20
+ | `@midnight-ntwrk/wallet-sdk` | Core: abstractions, address-format, dust-wallet, facade, hd, shielded, unshielded-wallet |
21
+ | `@midnight-ntwrk/wallet-sdk/address-format` | `@midnight-ntwrk/wallet-sdk-address-format` |
22
+ | `@midnight-ntwrk/wallet-sdk/capabilities` | `@midnight-ntwrk/wallet-sdk-capabilities` |
23
+ | `@midnight-ntwrk/wallet-sdk/dust` | `@midnight-ntwrk/wallet-sdk-dust-wallet` |
24
+ | `@midnight-ntwrk/wallet-sdk/facade` | `@midnight-ntwrk/wallet-sdk-facade` |
25
+ | `@midnight-ntwrk/wallet-sdk/hd` | `@midnight-ntwrk/wallet-sdk-hd` |
26
+ | `@midnight-ntwrk/wallet-sdk/proving` | `@midnight-ntwrk/wallet-sdk-capabilities/proving` |
27
+ | `@midnight-ntwrk/wallet-sdk/shielded` | `@midnight-ntwrk/wallet-sdk-shielded` |
28
+ | `@midnight-ntwrk/wallet-sdk/testing` | `@midnight-ntwrk/wallet-sdk-utilities/testing` |
29
+ | `@midnight-ntwrk/wallet-sdk/unshielded` | `@midnight-ntwrk/wallet-sdk-unshielded-wallet` |
30
+
31
+ The Wallet Facade (`WalletFacade`) provides a high-level unified interface that aggregates the functionality of all
32
+ wallet types (shielded, unshielded, and dust). It simplifies wallet operations by providing:
33
+
34
+ - Combined state management across all wallet types
35
+ - Unified transaction balancing for shielded, unshielded, and dust
36
+ - Coordinated transfer and swap operations
37
+ - Simplified transaction finalization flow
38
+ - Dust registration management
39
+
40
+ ## Usage
41
+
42
+ ### Initializing the Facade
43
+
44
+ ```typescript
45
+ import { WalletFacade } from '@midnight-ntwrk/wallet-sdk';
46
+
47
+ const facade = new WalletFacade(shieldedWallet, unshieldedWallet, dustWallet);
48
+
49
+ // Start all wallets
50
+ await facade.start(shieldedSecretKeys, dustSecretKey);
51
+ ```
52
+
53
+ ### Observing Combined State
54
+
55
+ ```typescript
56
+ facade.state().subscribe((state) => {
57
+ console.log('Shielded:', state.shielded);
58
+ console.log('Unshielded:', state.unshielded);
59
+ console.log('Dust:', state.dust);
60
+ console.log('All synced:', state.isSynced);
61
+ });
62
+
63
+ // Or wait for full sync
64
+ const syncedState = await facade.waitForSyncedState();
65
+ ```
66
+
67
+ ### Creating Transfer Transactions
68
+
69
+ ```typescript
70
+ const recipe = await facade.transferTransaction(
71
+ [
72
+ {
73
+ type: 'shielded',
74
+ outputs: [{ type: 'TOKEN_B', receiverAddress: shieldedAddr, amount: 1000n }],
75
+ },
76
+ {
77
+ type: 'unshielded',
78
+ outputs: [{ type: 'TOKEN_A', receiverAddress: unshieldedAddr, amount: 500n }],
79
+ },
80
+ ],
81
+ { shieldedSecretKeys, dustSecretKey },
82
+ { ttl: new Date(Date.now() + 3600000) },
83
+ );
84
+ ```
85
+
86
+ ### Balancing Transactions
87
+
88
+ ```typescript
89
+ // Balance a finalized transaction
90
+ const recipe = await facade.balanceFinalizedTransaction(
91
+ finalizedTx,
92
+ { shieldedSecretKeys, dustSecretKey },
93
+ { ttl, tokenKindsToBalance: 'all' }, // or ['shielded', 'dust']
94
+ );
95
+
96
+ // Finalize the balanced recipe
97
+ const finalTx = await facade.finalizeRecipe(recipe);
98
+
99
+ // Submit to the network
100
+ const txId = await facade.submitTransaction(finalTx);
101
+ ```
102
+
103
+ ### Creating Swap Offers
104
+
105
+ ```typescript
106
+ const swapRecipe = await facade.initSwap(
107
+ { shielded: { NIGHT: 1000n } }, // inputs
108
+ [{ type: 'shielded', outputs: [{ type: 'TOKEN_A', receiverAddress, amount: 100n }] }], // outputs
109
+ { shieldedSecretKeys, dustSecretKey },
110
+ { ttl, payFees: false },
111
+ );
112
+ ```
113
+
114
+ ### Dust Registration
115
+
116
+ ```typescript
117
+ // Register Night UTXOs for dust generation
118
+ const registrationRecipe = await facade.registerNightUtxosForDustGeneration(
119
+ nightUtxos,
120
+ nightVerifyingKey,
121
+ signDustRegistration,
122
+ );
123
+
124
+ // Estimate registration costs
125
+ const { fee, dustGenerationEstimations } = await facade.estimateRegistration(nightUtxos);
126
+ ```
127
+
128
+ ## Types
129
+
130
+ ### BalancingRecipe
131
+
132
+ The facade returns different recipe types depending on the input transaction:
133
+
134
+ - `FinalizedTransactionRecipe` - For finalized transactions
135
+ - `UnboundTransactionRecipe` - For unbound transactions
136
+ - `UnprovenTransactionRecipe` - For unproven transactions
137
+
138
+ ### TokenKindsToBalance
139
+
140
+ Control which token types to balance:
141
+
142
+ ```typescript
143
+ type TokenKindsToBalance = 'all' | ('dust' | 'shielded' | 'unshielded')[];
144
+ ```
145
+
146
+ ## License
147
+
148
+ Apache-2.0
@@ -0,0 +1 @@
1
+ export * from '@midnight-ntwrk/wallet-sdk-address-format';
@@ -0,0 +1,13 @@
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
+ export * from '@midnight-ntwrk/wallet-sdk-address-format';
@@ -0,0 +1 @@
1
+ export * from '@midnight-ntwrk/wallet-sdk-capabilities';
@@ -0,0 +1,13 @@
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
+ export * from '@midnight-ntwrk/wallet-sdk-capabilities';
package/dist/dust.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '@midnight-ntwrk/wallet-sdk-dust-wallet';
package/dist/dust.js ADDED
@@ -0,0 +1,13 @@
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
+ export * from '@midnight-ntwrk/wallet-sdk-dust-wallet';
@@ -0,0 +1 @@
1
+ export * from '@midnight-ntwrk/wallet-sdk-facade';
package/dist/facade.js ADDED
@@ -0,0 +1,13 @@
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
+ export * from '@midnight-ntwrk/wallet-sdk-facade';
package/dist/hd.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '@midnight-ntwrk/wallet-sdk-hd';
package/dist/hd.js ADDED
@@ -0,0 +1,13 @@
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
+ export * from '@midnight-ntwrk/wallet-sdk-hd';
@@ -0,0 +1,7 @@
1
+ export * from '@midnight-ntwrk/wallet-sdk-abstractions';
2
+ export * from '@midnight-ntwrk/wallet-sdk-address-format';
3
+ export * from '@midnight-ntwrk/wallet-sdk-dust-wallet';
4
+ export * from '@midnight-ntwrk/wallet-sdk-facade';
5
+ export * from '@midnight-ntwrk/wallet-sdk-hd';
6
+ export * from '@midnight-ntwrk/wallet-sdk-shielded';
7
+ export * from '@midnight-ntwrk/wallet-sdk-unshielded-wallet';
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
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
+ export * from '@midnight-ntwrk/wallet-sdk-abstractions';
14
+ export * from '@midnight-ntwrk/wallet-sdk-address-format';
15
+ export * from '@midnight-ntwrk/wallet-sdk-dust-wallet';
16
+ export * from '@midnight-ntwrk/wallet-sdk-facade';
17
+ export * from '@midnight-ntwrk/wallet-sdk-hd';
18
+ export * from '@midnight-ntwrk/wallet-sdk-shielded';
19
+ export * from '@midnight-ntwrk/wallet-sdk-unshielded-wallet';
@@ -0,0 +1 @@
1
+ export * from '@midnight-ntwrk/wallet-sdk-capabilities/proving';
@@ -0,0 +1,13 @@
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
+ export * from '@midnight-ntwrk/wallet-sdk-capabilities/proving';
@@ -0,0 +1 @@
1
+ export * from '@midnight-ntwrk/wallet-sdk-shielded';
@@ -0,0 +1,13 @@
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
+ export * from '@midnight-ntwrk/wallet-sdk-shielded';
@@ -0,0 +1 @@
1
+ export * from '@midnight-ntwrk/wallet-sdk-utilities/testing';
@@ -0,0 +1,13 @@
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
+ export * from '@midnight-ntwrk/wallet-sdk-utilities/testing';
@@ -0,0 +1 @@
1
+ export * from '@midnight-ntwrk/wallet-sdk-unshielded-wallet';
@@ -0,0 +1,13 @@
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
+ export * from '@midnight-ntwrk/wallet-sdk-unshielded-wallet';
package/package.json ADDED
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "@midnight-ntwrk/wallet-sdk",
3
+ "description": "Barrel package re-exporting all Midnight Wallet SDK packages",
4
+ "version": "1.0.0",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "author": "Midnight Foundation",
10
+ "license": "Apache-2.0",
11
+ "publishConfig": {
12
+ "registry": "https://npm.pkg.github.com/"
13
+ },
14
+ "files": [
15
+ "dist/"
16
+ ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/midnight-ntwrk/artifacts.git"
20
+ },
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "import": "./dist/index.js"
25
+ },
26
+ "./address-format": {
27
+ "types": "./dist/address-format.d.ts",
28
+ "import": "./dist/address-format.js"
29
+ },
30
+ "./capabilities": {
31
+ "types": "./dist/capabilities.d.ts",
32
+ "import": "./dist/capabilities.js"
33
+ },
34
+ "./dust": {
35
+ "types": "./dist/dust.d.ts",
36
+ "import": "./dist/dust.js"
37
+ },
38
+ "./facade": {
39
+ "types": "./dist/facade.d.ts",
40
+ "import": "./dist/facade.js"
41
+ },
42
+ "./hd": {
43
+ "types": "./dist/hd.d.ts",
44
+ "import": "./dist/hd.js"
45
+ },
46
+ "./proving": {
47
+ "types": "./dist/proving.d.ts",
48
+ "import": "./dist/proving.js"
49
+ },
50
+ "./shielded": {
51
+ "types": "./dist/shielded.d.ts",
52
+ "import": "./dist/shielded.js"
53
+ },
54
+ "./testing": {
55
+ "types": "./dist/testing.d.ts",
56
+ "import": "./dist/testing.js"
57
+ },
58
+ "./unshielded": {
59
+ "types": "./dist/unshielded.d.ts",
60
+ "import": "./dist/unshielded.js"
61
+ }
62
+ },
63
+ "dependencies": {
64
+ "@midnight-ntwrk/wallet-sdk-abstractions": "^2.1.0",
65
+ "@midnight-ntwrk/wallet-sdk-address-format": "^3.1.1",
66
+ "@midnight-ntwrk/wallet-sdk-capabilities": "^3.3.0",
67
+ "@midnight-ntwrk/wallet-sdk-dust-wallet": "^4.0.0",
68
+ "@midnight-ntwrk/wallet-sdk-facade": "^4.0.0",
69
+ "@midnight-ntwrk/wallet-sdk-hd": "^3.0.2",
70
+ "@midnight-ntwrk/wallet-sdk-shielded": "^3.0.0",
71
+ "@midnight-ntwrk/wallet-sdk-unshielded-wallet": "^3.0.0",
72
+ "@midnight-ntwrk/wallet-sdk-utilities": "^1.1.1"
73
+ },
74
+ "scripts": {
75
+ "typecheck": "tsc -b ./tsconfig.json --noEmit --force",
76
+ "lint": "eslint --max-warnings 0",
77
+ "format": "prettier --write \"**/*.{ts,js,json,yaml,yml,md}\"",
78
+ "format:check": "prettier --check \"**/*.{ts,js,json,yaml,yml,md}\"",
79
+ "dist": "tsc -b ./tsconfig.build.json",
80
+ "dist:publish": "tsc -b ./tsconfig.publish.json",
81
+ "clean": "rimraf --glob dist 'tsconfig.*.tsbuildinfo' && date +%s > .clean-timestamp",
82
+ "publint": "publint --strict"
83
+ }
84
+ }