TITLE: Running Unit Tests (Shell) DESCRIPTION: This command executes the unit tests for the Neuron project. It's used to verify the correctness and functionality of the codebase, ensuring that all components behave as expected. SOURCE: https://github.com/nervosnetwork/neuron/blob/develop/README.md#_snippet_6 LANGUAGE: shell CODE: ``` yarn test ``` ---------------------------------------- TITLE: Installing Dependencies and Rebuilding Native Modules (Shell) DESCRIPTION: These commands install project dependencies using Yarn and then rebuild native Node.js modules using Lerna. This step is crucial for ensuring all required packages are available and correctly compiled for the Neuron project. SOURCE: https://github.com/nervosnetwork/neuron/blob/develop/README.md#_snippet_1 LANGUAGE: shell CODE: ``` $ yarn $ lerna run rebuild:nativemodules ``` ---------------------------------------- TITLE: Generating RSA Keypair for Log Encryption (Shell) DESCRIPTION: This shell script demonstrates how to generate an RSA key pair using OpenSSL. It first creates a 2048-bit private key (`key.pem`) and then derives the corresponding public key (`public.pem`) from it. The public key is used for log encryption, while the private key is required for decryption. SOURCE: https://github.com/nervosnetwork/neuron/blob/develop/scripts/admin/decrypt-log/README.md#_snippet_0 LANGUAGE: sh CODE: ``` # for ADMIN_PRIVATE_KEY openssl genrsa -out key.pem 2048 # for LOG_ENCRYPTION_PUBLIC_KEY openssl rsa -in key.pem -outform PEM -pubout -out public.pem ``` ---------------------------------------- TITLE: Starting Neuron in Development Mode (Shell) DESCRIPTION: This sequence of commands first downloads the CKB binary specific to the platform, which Neuron will automatically start. Subsequently, `yarn start` launches Neuron in development mode, initiating both the `neuron-ui` (React UI) and `neuron-wallet` (core wallet) layers. SOURCE: https://github.com/nervosnetwork/neuron/blob/develop/README.md#_snippet_2 LANGUAGE: shell CODE: ``` ./scripts/download-ckb.sh yarn start ``` ---------------------------------------- TITLE: Performing AES Decryption of Log Content (JavaScript) DESCRIPTION: This Node.js snippet demonstrates how to decrypt the actual log content using the decrypted AES key and the initial vector (IV). It utilizes Node.js's `crypto` module to initialize an AES-256-CBC decipher with the provided base64-encoded key and IV, then processes the base64-encoded encrypted content, outputting the original UTF-8 message. SOURCE: https://github.com/nervosnetwork/neuron/blob/develop/scripts/admin/decrypt-log/README.md#_snippet_3 LANGUAGE: js CODE: ``` const aesKey = ""; const iv = Buffer.from("", "base64"); const decipher = createDecipheriv("aes-256-cbc", aesKey, iv); console.log( Buffer.concat([ decipher.update("", "base64"), decipher.final(), ]).toString("utf-8") ); ``` ---------------------------------------- TITLE: Starting Neuron UI Independently (Shell) DESCRIPTION: This command starts only the `neuron-ui` component of Neuron, which is the React-based user interface. It will be accessible at `http://localhost:3000`, allowing for independent development and testing of the UI layer. SOURCE: https://github.com/nervosnetwork/neuron/blob/develop/README.md#_snippet_3 LANGUAGE: shell CODE: ``` yarn start:ui ``` ---------------------------------------- TITLE: Starting Neuron Wallet Independently (Shell) DESCRIPTION: This command initiates only the `neuron-wallet` component, which represents the core wallet layer of Neuron. This allows developers to work on and test the wallet's backend logic separately from the user interface. SOURCE: https://github.com/nervosnetwork/neuron/blob/develop/README.md#_snippet_4 LANGUAGE: shell CODE: ``` yarn start:wallet ``` ---------------------------------------- TITLE: Installing Lerna Globally (Shell) DESCRIPTION: This command installs Lerna, a tool for managing JavaScript projects with multiple packages, globally on the system. Lerna is a prerequisite for managing dependencies in the Neuron project. SOURCE: https://github.com/nervosnetwork/neuron/blob/develop/README.md#_snippet_0 LANGUAGE: shell CODE: ``` $ yarn global add lerna ``` ---------------------------------------- TITLE: Decrypting Protected Log Key with OpenSSL (Shell) DESCRIPTION: This OpenSSL command decrypts an encrypted AES key (`LOCAL_KEY`) using a password-protected RSA private key (`private.key`). It uses OAEP padding mode and requires the password for the private key to be provided via `MY_KEY_PASSWORD`. The decrypted AES key is then saved to `aes.key`. SOURCE: https://github.com/nervosnetwork/neuron/blob/develop/scripts/admin/decrypt-log/README.md#_snippet_2 LANGUAGE: sh CODE: ``` openssl pkeyutl -pkeyopt rsa_padding_mode:oaep -passin "${MY_KEY_PASSWORD}" -decrypt -inkey private.key -in "${LOCAL_KEY}" -out "aes.key" ``` ---------------------------------------- TITLE: Decrypting Log Message using Bun (Shell) DESCRIPTION: This shell command prepares environment variables `LOG_MESSAGE` and `ADMIN_PRIVATE_KEY` for a Bun script. The `LOG_MESSAGE` should contain the full encrypted log string, and `ADMIN_PRIVATE_KEY` should be the PEM-formatted RSA private key. The `bun run.ts` command then executes a script to perform the actual decryption. SOURCE: https://github.com/nervosnetwork/neuron/blob/develop/scripts/admin/decrypt-log/README.md#_snippet_1 LANGUAGE: sh CODE: ``` export LOG_MESSAGE="" export ADMIN_PRIVATE_KEY="" bun run.ts ``` ---------------------------------------- TITLE: Configuring Testnet SUDT Dependencies (Shell) DESCRIPTION: This example demonstrates how environment variables are structured in the `packages/neuron-wallet/.env` file for configuring Testnet SUDT (Simple User Defined Token) dependencies. It defines the transaction hash, index, type, code hash, and hash type for a SUDT script, crucial for interacting with specific token contracts on the testnet. SOURCE: https://github.com/nervosnetwork/neuron/blob/develop/README.md#_snippet_5 LANGUAGE: shell CODE: ``` TESTNET_SUDT_DEP_TXHASH=0xe12877ebd2c3c364dc46c5c992bcfaf4fee33fa13eebdf82c591fc9825aab769 TESTNET_SUDT_DEP_INDEX=0 TESTNET_SUDT_DEP_TYPE=code TESTNET_SUDT_SCRIPT_CODEHASH=0xc5e5dcf215925f7ef4dfaf5f4b4f105bc321c02776d6e7d52a1db3fcd9d011a4 TESTNET_SUDT_SCRIPT_HASHTYPE=type ```