dop-engine-vmt-test
v1.0.1
Published
Wallet framework for DOP smart contracts and private balances on Ethereum and more.
Readme
DOP Engine SDK
Wallet framework for DOP smart contracts and private balances on Ethereum and more.
Read about DOP: www.dop.org
For simple implementations, use DOP Wallet SDK.
Installing
With NPM
npm install dop-engine-v3
With Yarn
yarn add dop-engine-v3
API
There are many APIs that can be imported via import { } from 'dop-engine-v3' but the most important is DopEngine.
General
Constructors
DopEngine.initForWallet()(static method) creates an instanceDopEngine.initForPOINode()(static method) creates an instance
Others
DopEngine.setEngineDebugger()(static method)dopEngine.loadNetwork()(instance method)dopEngine.unload()(instance method)
Wallet management
DOP Wallet
dopEngine.createWalletFromMnemonic()(instance method)dopEngine.loadExistingWallet()(instance method)
View-only DOP Wallet
dopEngine.createViewOnlyWalletFromShareableViewingKey()(instance method)dopEngine.loadExistingViewOnlyWallet()(instance method)
Teardown
dopEngine.unloadWallet()(instance method)dopEngine.deleteWallet()(instance method)
Scanning
"Scanning" consists of algorithms that fetch smart contract data to (re)build merkletree data structures, while also attempting to decrypt notes on the merkletrees, in order to calculate wallet balances.
dopEngine.scanContractHistory()(instance method)dopEngine.emitScanEventHistoryComplete()(instance method)dopEngine.syncDopTransactionsV2()(instance method)dopEngine.fullRescanUTXOMerkletreesAndWallets()(instance method)dopEngine.fullResetTXIDMerkletreesV2()(instance method)dopEngine.resetDopTxidsAfterTxidIndex()(instance method)
Getters
Merkletrees
dopEngine.getUTXOMerkletree()(instance method)dopEngine.getTXIDMerkletree()(instance method)
Others
dopEngine.getLatestDopTxidData()(instance method)dopEngine.getCompletedTxidFromNullifiers()(instance method)dopEngine.getAllEncryptCommitments()(instance method)
Utilities
Mnemonic.generate()(static method)Mnemonic.validate()(static method)Mnemonic.toSeed()(static method)Mnemonic.toEntropy()(static method)Mnemonic.fromEntropy()(static method)Mnemonic.to0xPrivateKey()(static method)Mnemonic.to0xAddress()(static method)BlindedCommitment.getForDecrypt()(static method)BlindedCommitment.getForEncryptOrTransact()(static method)ByteUtils.u8ToBigInt()(static method)ByteUtils.hexToBigInt()(static method)ByteUtils.nToBytes()(static method)ByteUtils.nToHex()(static method)ByteUtils.bytesToN()(static method)ByteUtils.hexStringToBytes()(static method)ByteUtils.randomHex()(static method)ByteUtils.hexlify()(static method)ByteUtils.arrayify()(static method)ByteUtils.formatToByteLength()(static method)ByteUtils.hexToBytes()(static method)getGlobalTreePosition()convertTransactionStructToCommitmentSummary()encryptJSONDataWithSharedKey()tryDecryptJSONDataWithSharedKey()getPublicViewingKey()
Types
AddressDatafor encoding 0zk addressesSpendingPublicKeySpendingKeyPairViewingKeyPairMerklerootValidatorMerkletreeLeafInvalidMerklerootDetailsMerkletreesMetadataPOINodeInterface
Developing
Install nodejs
Install modules
npm install OR yarn
Build TypeScript
npm build OR yarn build
Run unit tests
npm test-V2 OR yarn test-V2
Run all tests, including contract integration tests (requires Hardhat setup below)
npm run test-hardhat-V2 OR yarn test-hardhat-V2
Hardhat setup
Clone the contracts repo
git clone [email protected]:Dop-Privacy/contract.git
Start hardhat node from the contract repo and leave it running
npm run node
In another terminal deploy the contracts to the hardhat node network
npm run deploy
The default test config should work fine here as addresses are deterministic on the hardhat node network. If you are running your own test setup you will need to use the config override file. Copy test/configOverrides.test.ts.example to test/configOverrides.test.ts and enter your own values.
You can run subsequent test runs against the same hardhat node deployment as the testing suite will use snapshots to restore hardhat back to the initial state after each test. If for some reason the testing suite is interrupted before it can restore to snapshot you will need to terminate the hardhat node process, restart it, and run the deploy test script again.
In some situations it will be useful to recompile the contract from scratch. In that case, first run npm run clean and then npm run compile, after which it is safe to re-run the node and deploy script.
