npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@alicenet_/alicenetjs

v2.0.5

Published

##### Requirements - `Nodejs 16+` - `NPM 6+` ##

Downloads

17

Readme

alicenetjs

Requirements
  • Nodejs 16+
  • NPM 6+

Install

npm i @alicenet_/alicenetjs

Usage

Supports SECP256k1 and BN curve types.

SECP256k1 (curve = 1)

BN (curve = 2)

Require

First AliceNetJS must be required where you would like to use it -- To quickly inititiate AliceNetJS It needs the RPC url to connect to

const AliceWallet = require("alicenetjs");
const aliceWallet = new AliceWallet(${alicenet_rpc})
Add Account

Accounts can be added to the wallet instance as secp256k1 (int(1)) or BN ((int(2)) curves via a private key

If you wish to use MultiSig features, please opt for BN curve (2)

await aliceWallet.Account.addAccount(${PRIVATE_KEY}, ${CURVE})
Example
await aliceWallet.Account.addAccount(privateKey, 1); // Creates a secp256k1 curve based key pair account
Create A ValueStore

Valuestores are used to move value of the utility token from one address to another

The curve of the receiving address must be declared

await aliceWallet.Transaction.createValueStore(0x${FROM}, ${VALUE}, 0x${TO}, ${TO_CURVE})
Example
await aliceWallet.Transaction.createValueStore(0x4240A00833065c29D1EB117e200a87c95D640289, 10, 0x219D27f4DBf2831f45Dd55436dE084571Ae2cE15, 2)
--
await aliceWallet.Transaction.createValueStore(aliceWallet.Account.accounts[0]["address"], 1, aliceWallet.Account.accounts[0]["address"], 1)
Create A DataStore

Datastores are used to store segments of data on chain for various use cases, data is stored as hexadecimal blobs

await aliceWallet.Transaction.createDataStore(0x${FROM}, ${INDEX}, ${DURATION}, ${RAW_DATA}, !(optional){ISSUED_AT_EPOCH})
Example
await  aliceWallet.Transaction.createDataStore(0x4240A00833065c29D1EB117e200a87c95D640289, "0xA", 20, "0xC0FFEE")
--
await aliceWallet.Transaction.createDataStore(aliceWallet.Account.accounts[0]["address"], "0xA", 1, "0xC0FFEE", 1)
Send Transaction

Transactions can contain both value stores and data stores ( Up to 255 ) -- Once all of have been created the transaction can be sent,

await aliceWallet.sendTransaction(!(optional){CHANGE_ADDRESS}, !(optional){CHANGE_ADDRESS_CURVE}, !(optional)[{UTXOIDs}])
Example
await aliceWallet.Transaction.sendTx()
--
await aliceWallet.Transaction.sendTx(0x4240A00833065c29D1EB117e200a87c95D640289, 2)
--
await aliceWallet.Transaction.sendTx(0x4240A00833065c29D1EB117e200a87c95D640289, 2, [0197314d4f3e46eb7dd8cd7bcd2daf5305a4c8f9089ae6e9a1552350dfce56ac])

Wallet Modules

  • Account
  • Transaction
  • RPC

Details on these modules can be found in the generated docs

Generate Docs

  • Create the docs
    • npm run build-docs
  • Open index with a browser
    • firefox docs/index.html

Tests

Create .env file in the root folder to specify account, chainId, and RPC.
It is required that your .env has OPTIONAL_TEST_SUITE_PRIVATE_KEY and OPTIONAL_TEST_SUITE_SECONDARY_PRIVATE_KEY with a funded private key value. For the Faucet utility you need to provide the api endpoint here FAUCET_API_URL.

  • Run all tests
    • npm test
  • Run only unit tests
    • npm run test-unit
  • Run only integration tests
    • npm run test-integration
  • Run a single test
    • npm run test-single path/to/file.js
  • Run all tests with coverage
    • npm run test-coverage
  • Run only unit tests with coverage
    • npm run test-unit-coverage
  • Run only integration tests with coverage
    • npm run test-integration-coverage

Test Coverage

When you run npm run test-coverage it generates a file under coverage/cobertura-coverage.xml with a general test coverage output.

Webpack5 environment

Use node core modules polyfill if you choose to run the library on Webpack5 environment.

If you run into this error:

BREAKING CHANGE: webpack<5 used to include polyfills for node.js core modules by default.

1.- Install react-app-rewired package

npm i react-app-rewired package

2.- Install missing dependencies

npm install --save-dev crypto-browserify stream-browserify assert stream-http https-browserify os-browserify url buffer process

3.- Create config-overrides.js

const webpack = require('webpack'); 
module.exports = function override(config) { 
	const fallback = config.resolve.fallback || {}; 
	Object.assign(fallback, { 
		"crypto": require.resolve("crypto-browserify"), 
		"stream": require.resolve("stream-browserify"), 
		"assert": require.resolve("assert"), 
		"http": require.resolve("stream-http"), 
		"https": require.resolve("https-browserify"), 
		"os": require.resolve("os-browserify"), 
		"url": require.resolve("url") 
}) 
config.resolve.fallback = fallback; 
config.plugins = (config.plugins || []).concat([ 
	new webpack.ProvidePlugin({ 
		process: 'process/browser', 
		Buffer: ['buffer', 'Buffer'] 
	}) 
]) 
return config; 

}

4.- Override package.json "scripts": { "start": "react-app-rewired start", "build": "react-app-rewired build", "test": "react-app-rewired test", "eject": "react-scripts eject" },

Now your missing NodeJS polyfills should be included in your app and the error will be gone.

https://devdojo.com/erickagulopez/how-to-polyfill-node-core-modules-in-webpack