Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web3Utils #29

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Web3Utils #29

wants to merge 5 commits into from

Conversation

sisou
Copy link
Member

@sisou sisou commented Oct 23, 2019

Provide web3 utilities to work with in-browser web3 providers such as MetaMask and Opera Wallet.

Includes a demo page to test it.

@sisou sisou requested review from danimoh, mraveux and nibhar October 23, 2019 12:42
@sisou sisou self-assigned this Oct 23, 2019
@sisou
Copy link
Member Author

sisou commented Oct 24, 2019

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.

demos/Web3Utils.html Outdated Show resolved Hide resolved
demos/Web3Utils.html Outdated Show resolved Hide resolved
src/web3-utils/Web3Utils.ts Outdated Show resolved Hide resolved
src/web3-utils/Web3Utils.ts Outdated Show resolved Hide resolved
src/web3-utils/Web3Utils.ts Outdated Show resolved Hide resolved
@sisou sisou force-pushed the soeren/web3 branch 3 times, most recently from 8a0390d to 7295d8d Compare November 16, 2019 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants