Open sisou opened 5 years ago
Instead of the Web3Utils
being a class, I changed it to export individual functions instead.
This makes no difference when used as it currently is (as the main.js
file still exports the whole Web3Utils namespace as Web3Utils
), but allows tree-shaking of unused methods when imported directly from the module instead:
// Working as usual, but not tree-shakable:
import { Web3Utils} from '@nimiq/utils';
// Also working, AND is tree-shakable:
import * as Web3Utils from '@nimiq/utils/dist/module/web3-utils/Web3Utils';
Granted, the import path is not great yet. Having to write the whole path to /dist/module/web3-utils/Web3Utils
is a pain. But it is tree-shakable and once all PRs are merged, this whole package can be converted to this pattern and the modules can be made accessible at @nimiq/utils/Web3Utils
.
Provide web3 utilities to work with in-browser web3 providers such as MetaMask and Opera Wallet.
Includes a demo page to test it.