dop-wallet-v6 1.3.31 → 1.3.33

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/.eslintrc.js CHANGED
@@ -63,15 +63,25 @@ module.exports = {
63
63
  },
64
64
  overrides: [
65
65
  {
66
- files: ['**/__tests__/**', './src/tests/**'],
66
+ files: ['**/__tests__/**', './src/tests/**', '**/*.test.ts'],
67
67
  rules: {
68
68
  '@typescript-eslint/no-explicit-any': 0,
69
69
  '@typescript-eslint/no-unsafe-member-access': 0,
70
+ '@typescript-eslint/no-unsafe-assignment': 0,
71
+ '@typescript-eslint/no-unsafe-call': 0,
72
+ '@typescript-eslint/no-unsafe-argument': 0,
73
+ '@typescript-eslint/no-unsafe-return': 0,
74
+ '@typescript-eslint/strict-boolean-expressions': 0,
75
+ '@typescript-eslint/restrict-template-expressions': 0,
76
+ '@typescript-eslint/no-non-null-assertion': 0,
70
77
  'import/no-extraneous-dependencies': 0,
71
78
  'no-console': 0,
72
79
  '@typescript-eslint/no-unused-vars': 0,
73
80
  'no-useless-concat': 0,
74
81
  '@typescript-eslint/await-thenable': 0,
82
+ 'no-plusplus': 0,
83
+ 'no-constant-condition': 0,
84
+ 'func-names': 0,
75
85
  },
76
86
  },
77
87
  ],
package/README.md CHANGED
@@ -1,23 +1,381 @@
1
+ # DOP Wallet SDK v6
1
2
 
3
+ **Privacy-preserving blockchain transactions for Ethereum, Polygon, BNB Chain, Arbitrum, and Base**
2
4
 
3
- # DOP Wallet SDK
5
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
+ [![npm version](https://img.shields.io/npm/v/dop-wallet-v6.svg)](https://www.npmjs.com/package/dop-wallet-v6)
7
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D16-brightgreen.svg)](https://nodejs.org)
8
+ [![React Native](https://img.shields.io/badge/react--native-%3E%3D0.70-blue.svg)](https://reactnative.dev)
4
9
 
5
- The DOP Wallet SDK is an open-source project developed by [DOP](https://www.dop.org) contributors.
10
+ The DOP Wallet SDK enables developers to integrate private token transfers, shielding, and zero-knowledge proofs into their applications. Built with TypeScript and compatible with **Node.js**, **browsers**, and **React Native**.
6
11
 
7
- The Wallet SDK enables dApp and DeFi developers to provide privacy to users safely and conveniently on Ethereum, Polygon and BNB Chain.
12
+ **Developed by [DOP](https://www.dop.org) contributors.**
8
13
 
9
- The repo is written in TypeScript, and compatible with **Node.js**, **modern web browsers**, and **React Native**.
14
+ ---
10
15
 
11
- ## 📱 React Native Support
16
+ ## 📚 Complete Documentation
12
17
 
13
- This SDK now has comprehensive React Native support with optimized polyfills and easy integration:
18
+ **See [SDK_DOCS.md](./SDK_DOCS.md) for complete API reference, installation guides, and working examples.**
19
+
20
+ The SDK_DOCS.md contains:
21
+ - Installation for Node.js, Browser, and React Native
22
+ - Complete API reference verified against working test files
23
+ - Step-by-step workflows for Shield, Unshield, and Private Transfers
24
+ - Real code examples that compile and run
25
+ - Error handling and performance tips
26
+ - React Native integration guide
27
+
28
+ ---
29
+
30
+ ## ✨ Features
31
+
32
+ - 🔒 **Private Transfers**: Send ERC20, ERC721, ERC1155 tokens without revealing amounts or recipients
33
+ - 🛡️ **Shield/Unshield**: Convert between public and private token balances
34
+ - 📊 **Balance Queries**: View private balances across multiple chains
35
+ - 🔐 **Zero-Knowledge Proofs**: Generate and verify zk-SNARK proofs
36
+ - 🌐 **Multi-Chain**: Ethereum, Polygon, BNB Chain, Arbitrum, Base
37
+ - 📱 **React Native**: Full mobile support with custom proof generation
38
+
39
+ ---
40
+
41
+ ## 🚀 Quick Start
42
+
43
+ ### Installation
44
+
45
+ ```bash
46
+ npm install dop-wallet-v6 dop-sharedmodels-v3
47
+ ```
48
+
49
+ For Node.js:
50
+ ```bash
51
+ npm install leveldown snarkjs
52
+ ```
53
+
54
+ For React Native:
55
+ ```bash
56
+ npm install react-native-get-random-values @react-native-async-storage/async-storage
57
+ npm install buffer assert stream-browserify crypto-browserify events
58
+ ```
59
+
60
+ ### Node.js Example
61
+
62
+ ```typescript
63
+ import {
64
+ startDopEngine,
65
+ createOrImportDopWallet,
66
+ gasEstimateForEncrypt,
67
+ populateEncrypt,
68
+ getSerializedERC20Balances,
69
+ getProver
70
+ } from 'dop-wallet-v6';
71
+ import { NetworkName, NETWORK_CONFIG, TXIDVersion } from 'dop-sharedmodels-v3';
72
+ import { groth16 } from 'snarkjs';
73
+ import LevelDOWN from 'leveldown';
74
+
75
+ // Initialize
76
+ const db = new LevelDOWN('./dop-db');
77
+ await startDopEngine('my-app', db, false, artifactStore, false, false, true);
78
+
79
+ // Setup prover (required for transfers/unshield)
80
+ const prover = getProver();
81
+ prover.setSnarkJSGroth16(groth16);
82
+
83
+ // Create wallet
84
+ const { walletInfo, mnemonic } = await createOrImportDopWallet('encryption-key');
85
+ console.log('Save this mnemonic:', mnemonic);
86
+
87
+ // Shield tokens (3-step process)
88
+ const { gasEstimate } = await gasEstimateForEncrypt(/* ... */);
89
+ const txRequest = await populateEncrypt(/* ... */);
90
+ await publicWallet.sendTransaction(txRequest);
91
+
92
+ // Check balance
93
+ const balances = getSerializedERC20Balances(
94
+ TXIDVersion.V3_PoseidonMerkle,
95
+ NETWORK_CONFIG[NetworkName.Polygon].chain,
96
+ walletInfo.id
97
+ );
98
+ ```
99
+
100
+ **See [SDK_DOCS.md](./SDK_DOCS.md) for complete working examples.**
101
+
102
+ ### React Native Example
103
+
104
+ ```typescript
105
+ import 'react-native-get-random-values'; // MUST BE FIRST!
106
+ import { Buffer } from 'buffer';
107
+ global.Buffer = global.Buffer || Buffer;
108
+ import 'dop-wallet-v6/react-native-shims';
109
+
110
+ import {
111
+ startDopEngine,
112
+ createOrImportDopWallet,
113
+ populateEncrypt,
114
+ getSerializedERC20Balances
115
+ } from 'dop-wallet-v6';
116
+ import MemDOWN from 'memdown';
117
+
118
+ // Initialize with React Native settings
119
+ const db = new MemDOWN();
120
+ await startDopEngine('my-app', db, __DEV__, artifactStore, true, false, __DEV__);
121
+
122
+ // Create wallet
123
+ const { walletInfo } = await createOrImportDopWallet('encryption-key');
124
+
125
+ // Shield works immediately
126
+ const txRequest = await populateEncrypt(/* ... */);
127
+ await wallet.sendTransaction(txRequest);
128
+
129
+ // Check balance
130
+ const balances = getSerializedERC20Balances(TXIDVersion.V3_PoseidonMerkle, chain, walletInfo.id);
131
+
132
+ // For private transfers, configure custom Rapidsnark prover
133
+ // See SDK_DOCS.md React Native section
134
+ ```
135
+
136
+ ---
137
+
138
+ ## 📚 Documentation
139
+
140
+ **📖 [SDK_DOCS.md](./SDK_DOCS.md)** - Complete unified documentation (RECOMMENDED)
141
+
142
+ The SDK_DOCS.md contains everything you need:
143
+ - Installation for all platforms
144
+ - Complete API reference verified against tests
145
+ - Step-by-step workflows with real code
146
+ - React Native integration guide
147
+ - Error handling and performance tips
148
+
149
+ ### Quick Navigation
150
+
151
+ - **New to DOP?** → Start with [SDK_DOCS.md](./SDK_DOCS.md)
152
+ - **Looking for specific function?** → See API Reference section in SDK_DOCS.md
153
+ - **React Native setup?** → See React Native section in SDK_DOCS.md
154
+ - **Complete workflows?** → See Complete Workflows section in SDK_DOCS.md
155
+
156
+ ---
157
+
158
+ ## 🔧 Environment Support
159
+
160
+ | Feature | Node.js | Browser | React Native |
161
+ |---------|---------|---------|--------------|
162
+ | Shield (encrypt) tokens | ✅ | ✅ | ✅ |
163
+ | View private balances | ✅ | ✅ | ✅ |
164
+ | Private transfers | ✅ | ✅ | ✅* |
165
+ | Unshield (decrypt) tokens | ✅ | ✅ | ✅* |
166
+ | Wallet management | ✅ | ✅ | ✅ |
167
+ | Transaction history | ✅ | ✅ | ✅ |
168
+
169
+ *React Native private transfers require custom Rapidsnark prover setup. See [REACT_NATIVE_USER_CONFIGURABLE_PROVER.md](./REACT_NATIVE_USER_CONFIGURABLE_PROVER.md).
170
+
171
+ ---
172
+
173
+ ## 🎯 Use Cases
174
+
175
+ - **Privacy-preserving DeFi**: Let users trade and transfer without revealing balances
176
+ - **Private payroll**: Pay employees privately on-chain
177
+ - **Confidential treasury**: Manage organizational funds with selective transparency
178
+ - **Private gaming economies**: In-game token transfers without public visibility
179
+ - **Compliant privacy**: Optional selective transparency for regulatory requirements
180
+
181
+ ---
182
+
183
+ ## 🛠️ Core Operations
184
+
185
+ ### Important: Multi-Step Process
186
+
187
+ DOP transactions require 3 steps:
188
+ 1. **Gas Estimation** - Calculate transaction cost
189
+ 2. **Proof Generation** - Create zero-knowledge proof (30s-2min for transfers/unshield)
190
+ 3. **Transaction** - Populate and submit transaction
191
+
192
+ ### Shield Tokens (Public → Private)
14
193
 
15
194
  ```typescript
195
+ // Step 1: Estimate gas
196
+ const { gasEstimate } = await gasEstimateForEncrypt(/* ... */);
197
+
198
+ // Step 2: Populate transaction
199
+ const txRequest = await populateEncrypt(/* ... */);
200
+
201
+ // Step 3: Send
202
+ await wallet.sendTransaction(txRequest);
203
+ ```
204
+
205
+ ### Check Private Balances
206
+
207
+ ```typescript
208
+ const balances = getSerializedERC20Balances(
209
+ TXIDVersion.V3_PoseidonMerkle,
210
+ chain,
211
+ walletId
212
+ );
213
+ ```
214
+
215
+ ### Private Transfer
216
+
217
+ ```typescript
218
+ // Step 1: Estimate gas
219
+ const { gasEstimate } = await gasEstimateForUnprovenTransfer(/* ... */);
220
+
221
+ // Step 2: Generate proof (1-2 minutes)
222
+ const { proof, publicInputs } = await generateTransferProofForExplorer(/* ... */);
223
+
224
+ // Step 3: Populate and send
225
+ const txRequest = await populateProvedTransfer(/* ... */);
226
+ await wallet.sendTransaction(txRequest);
227
+ ```
228
+
229
+ ### Unshield Tokens (Private → Public)
230
+
231
+ ```typescript
232
+ // Step 1: Estimate gas
233
+ const { gasEstimate } = await gasEstimateForUnprovenDecrypt(/* ... */);
234
+
235
+ // Step 2: Generate proof (30s-2min)
236
+ const { proof, publicInputs } = await generateDecryptToOriginProof(/* ... */);
237
+
238
+ // Step 3: Populate and send
239
+ const txRequest = await populateProvedDecrypt(/* ... */);
240
+ await wallet.sendTransaction(txRequest);
241
+ ```
242
+
243
+ **See [SDK_DOCS.md](./SDK_DOCS.md) for complete working examples.**
244
+
245
+ ---
246
+
247
+ ## 🌐 Supported Networks
248
+
249
+ - **Ethereum Mainnet**
250
+ - **Polygon**
251
+ - **BNB Chain**
252
+ - **Arbitrum**
253
+ - **Base**
254
+
255
+ All networks support ERC20, ERC721, and ERC1155 tokens.
256
+
257
+ ---
258
+
259
+ ## 📱 React Native Setup
260
+
261
+ ### Prerequisites
262
+
263
+ ```bash
264
+ npm install react-native-get-random-values @react-native-async-storage/async-storage
265
+ npm install buffer assert stream-browserify crypto-browserify events
266
+ ```
267
+
268
+ ### Entry Point Setup (CRITICAL)
269
+
270
+ **At the very top of index.js or App.js:**
271
+
272
+ ```typescript
273
+ // MUST BE FIRST IMPORTS
16
274
  import 'react-native-get-random-values';
17
- import { DopWallet } from 'dop-wallet-v6/react-native';
275
+ import { Buffer } from 'buffer';
276
+ global.Buffer = global.Buffer || Buffer;
277
+
278
+ // Import DOP shims
279
+ import 'dop-wallet-v6/react-native-shims';
280
+
281
+ // Now your app code
18
282
  ```
19
283
 
20
- **📚 Quick Start:** See [REACT_NATIVE_INTEGRATION_GUIDE.md](./REACT_NATIVE_INTEGRATION_GUIDE.md) for complete setup instructions.
284
+ ### Basic Setup
285
+
286
+ ```typescript
287
+ import { startDopEngine } from 'dop-wallet-v6';
288
+ import MemDOWN from 'memdown';
289
+
290
+ const db = new MemDOWN();
291
+ await startDopEngine(
292
+ 'my-rn-app',
293
+ db,
294
+ __DEV__,
295
+ artifactStore,
296
+ true, // useNativeArtifacts for React Native
297
+ false,
298
+ __DEV__
299
+ );
300
+ ```
301
+
302
+ ### What Works Out of the Box
303
+
304
+ - ✅ Shield tokens
305
+ - ✅ Check balances
306
+ - ✅ Wallet management
307
+ - ❌ Private transfers (needs Rapidsnark)
308
+ - ❌ Unshield (needs Rapidsnark)
309
+
310
+ **📖 Complete React Native Guide**: See React Native section in [SDK_DOCS.md](./SDK_DOCS.md)
311
+
312
+ ---
313
+
314
+ ## 🔐 Security
315
+
316
+ - **Zero-Knowledge Proofs**: Transactions are cryptographically private
317
+ - **Client-Side Keys**: Private keys never leave user's device
318
+ - **Open Source**: Fully auditable codebase
319
+ - **BIP39 Mnemonics**: Standard 12/24-word recovery phrases
320
+
321
+ ---
322
+
323
+ ## 🤝 Contributing
324
+
325
+ Contributions are welcome! Please:
326
+
327
+ 1. Fork the repository
328
+ 2. Create a feature branch
329
+ 3. Make your changes with tests
330
+ 4. Submit a pull request
331
+
332
+ ---
333
+
334
+ ## 📄 License
335
+
336
+ MIT License - see [LICENSE](LICENSE) file for details
337
+
338
+ ---
339
+
340
+ ## 🆘 Support
341
+
342
+ - **Documentation**: [SDK_DOCS.md](./SDK_DOCS.md)
343
+ - **Issues**: [GitHub Issues](https://github.com/VAR-META-Tech/new-dop-wallet-v3/issues)
344
+ - **Website**: [https://www.dop.org](https://www.dop.org)
345
+
346
+ ---
347
+
348
+ ## 🏗️ Architecture
349
+
350
+ ```
351
+ Application
352
+
353
+ DOP Wallet SDK
354
+
355
+ ├─ DOP Engine (core logic)
356
+ ├─ Merkletree Sync (blockchain scanning)
357
+ ├─ Proof Generation
358
+ │ ├─ SnarkJS (Node.js/Browser)
359
+ │ └─ Rapidsnark (React Native - custom setup required)
360
+ └─ Blockchain Interface (ethers.js)
361
+
362
+ Ethereum, Polygon, BNB Chain, Arbitrum, Base
363
+ ```
364
+
365
+ ---
366
+
367
+ ## 📊 Status
368
+
369
+ **Version**: 1.3.32
370
+ **Status**: Production Ready ✅
371
+ **Last Updated**: December 7, 2025
372
+
373
+ **Recent Updates:**
374
+ - ✅ Comprehensive SDK documentation rewrite
375
+ - ✅ API verified against working test files
376
+ - ✅ Complete workflows with real code examples
377
+ - ✅ React Native integration guide
21
378
 
22
- **🔧 Verify Compatibility:** Run `npm run verify-rn-compatibility` to ensure your setup is correct.
379
+ ---
23
380
 
381
+ **Built by the DOP community**
@@ -1,9 +1,13 @@
1
1
  export * from './artifacts';
2
2
  export * from './init';
3
3
  export * from './react-native-init';
4
+ export * from './react-native-prover-setup';
4
5
  export * from './engine';
5
6
  export * from './load-provider';
6
7
  export * from './merkletree';
7
8
  export * from './prover';
8
9
  export * from './providers';
9
10
  export * from './encrypts';
11
+ export * from '../crypto/react-native-crypto-provider';
12
+ export * from '../crypto/react-native-rapidsnark-prover';
13
+ export * from '../crypto/user-rapidsnark-adapter';
@@ -17,10 +17,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./artifacts"), exports);
18
18
  __exportStar(require("./init"), exports);
19
19
  __exportStar(require("./react-native-init"), exports);
20
+ __exportStar(require("./react-native-prover-setup"), exports);
20
21
  __exportStar(require("./engine"), exports);
21
22
  __exportStar(require("./load-provider"), exports);
22
23
  __exportStar(require("./merkletree"), exports);
23
24
  __exportStar(require("./prover"), exports);
24
25
  __exportStar(require("./providers"), exports);
25
26
  __exportStar(require("./encrypts"), exports);
27
+ // Export React Native crypto provider utilities
28
+ __exportStar(require("../crypto/react-native-crypto-provider"), exports);
29
+ __exportStar(require("../crypto/react-native-rapidsnark-prover"), exports);
30
+ __exportStar(require("../crypto/user-rapidsnark-adapter"), exports);
26
31
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/dop/core/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,yCAAuB;AACvB,sDAAoC;AACpC,2CAAyB;AACzB,kDAAgC;AAChC,+CAA6B;AAC7B,2CAAyB;AACzB,8CAA4B;AAC5B,6CAA2B","sourcesContent":["export * from './artifacts';\nexport * from './init';\nexport * from './react-native-init';\nexport * from './engine';\nexport * from './load-provider';\nexport * from './merkletree';\nexport * from './prover';\nexport * from './providers';\nexport * from './encrypts';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/dop/core/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,yCAAuB;AACvB,sDAAoC;AACpC,8DAA4C;AAC5C,2CAAyB;AACzB,kDAAgC;AAChC,+CAA6B;AAC7B,2CAAyB;AACzB,8CAA4B;AAC5B,6CAA2B;AAE3B,gDAAgD;AAChD,yEAAuD;AACvD,2EAAyD;AACzD,oEAAkD","sourcesContent":["export * from './artifacts';\nexport * from './init';\nexport * from './react-native-init';\nexport * from './react-native-prover-setup';\nexport * from './engine';\nexport * from './load-provider';\nexport * from './merkletree';\nexport * from './prover';\nexport * from './providers';\nexport * from './encrypts';\n\n// Export React Native crypto provider utilities\nexport * from '../crypto/react-native-crypto-provider';\nexport * from '../crypto/react-native-rapidsnark-prover';\nexport * from '../crypto/user-rapidsnark-adapter';\n"]}
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.startDopEngineReactNative = exports.ReactNativeLevelDB = void 0;
4
27
  const init_1 = require("./init");
@@ -593,8 +616,12 @@ const startDopEngineReactNative = async (walletSource, shouldDebug, artifactStor
593
616
  });
594
617
  }
595
618
  // Initialize the DOP Engine with the React Native database
596
- return (0, init_1.startDopEngine)(walletSource, db, // Cast to any since TypeScript doesn't know about our custom implementation
619
+ await (0, init_1.startDopEngine)(walletSource, db, // Cast to any since TypeScript doesn't know about our custom implementation
597
620
  shouldDebug, artifactStore, useNativeArtifacts, skipMerkletreeScans, verboseScanLogging);
621
+ // CRITICAL: Auto-setup Rapidsnark prover for React Native
622
+ // This enables proof generation for transfers, shield, and unshield operations
623
+ const { autoSetupProverForReactNative } = await Promise.resolve().then(() => __importStar(require('./react-native-prover-setup')));
624
+ await autoSetupProverForReactNative();
598
625
  };
599
626
  exports.startDopEngineReactNative = startDopEngineReactNative;
600
627
  //# sourceMappingURL=react-native-init.js.map