paulmillr Github contribution chart
paulmillr Github Stats
paulmillr Most Used Languages

Activity

04 Oct 2022

Paulmillr

README update

Pushed On 04 Oct 2022 at 06:20:21
Create Branch

Paulmillr

Create, sign & decode BTC transactions with minimum deps.

On 04 Oct 2022 at 05:23:57

Paulmillr

Release 0.1.1.

Pushed On 04 Oct 2022 at 05:23:55

Paulmillr

Initial development funded

Pushed On 04 Oct 2022 at 05:16:53

Paulmillr

Initial development funded

Pushed On 04 Oct 2022 at 05:16:20

Paulmillr

Missing crypto module when building the project using ncc and Webpack

Hi everyone, this may or may not be an issue with js-ethereum-cryptography itself but rather an issue with @vercel/ncc and webpack builds. I'm posting it here anyways in case anyone has any ideas on what is going on.

Issue I have a project that is using a dependency that is dependent on the keccak file from ethereum-cryptography@1.0.3. I then bunde my project into a single JS file using the ncc build command from this project, which uses Webpack internally.

Now the issue is that ncc transforms this code to the code below as ncc can't find the crypto package for some reason:

/***/ 84310:
/***/ ((module) => {

function webpackEmptyContext(req) {
	var e = new Error("Cannot find module '" + req + "'");
	e.code = 'MODULE_NOT_FOUND';
	throw e;
}
webpackEmptyContext.keys = () => ([]);
webpackEmptyContext.resolve = webpackEmptyContext;
webpackEmptyContext.id = 84310;
module.exports = webpackEmptyContext;
/***/ }), 

This leads to my project crashing with this error when I try run it:

Error: Cannot find module 'crypto'
    at Object.webpackEmptyContext (/Users/christophersastropranoto/Documents/external-adapters-js/packages/sources/layer2-sequencer-health/bundle/index.js:183577:10)
    at /Users/christophersastropranoto/Documents/external-adapters-js/packages/sources/layer2-sequencer-health/bundle/index.js:83270:43
    at Object.78777 (/Users/christophersastropranoto/Documents/external-adapters-js/packages/sources/layer2-sequencer-health/bundle/index.js:83273:3)
    at __nccwpck_require__ (/Users/christophersastropranoto/Documents/external-adapters-js/packages/sources/layer2-sequencer-health/bundle/index.js:183842:43)
    at Object.35681 (/Users/christophersastropranoto/Documents/external-adapters-js/packages/sources/layer2-sequencer-health/bundle/index.js:83194:17)
    at __nccwpck_require__ (/Users/christophersastropranoto/Documents/external-adapters-js/packages/sources/layer2-sequencer-health/bundle/index.js:183842:43)
    at Object.30038 (/Users/christophersastropranoto/Documents/external-adapters-js/packages/sources/layer2-sequencer-health/bundle/index.js:169615:16)
    at __nccwpck_require__ (/Users/christophersastropranoto/Documents/external-adapters-js/packages/sources/layer2-sequencer-health/bundle/index.js:183842:43)
    at Object.55944 (/Users/christophersastropranoto/Documents/external-adapters-js/packages/sources/layer2-sequencer-health/bundle/index.js:168123:14)
    at __nccwpck_require__ (/Users/christophersastropranoto/Documents/external-adapters-js/packages/sources/layer2-sequencer-health/bundle/index.js:183842:43) {
  code: 'MODULE_NOT_FOUND'
} 

I've confirmed that this issue is also happening when I try to build the ethereum-cryptography package by itself.

Steps to repro

Run from the root of the ethereum-cryptography repository.

  1. Add @vercel/ncc package yarn add @vercel/ncc
  2. Build the keccak.ts file. ncc build keccak.js -o bundle/index.js
  3. This should have created a new directory named bundle in the root folder with an index.js file. Inspect the generated index.js file and find the code below
exports.crypto = (() => {
    const webCrypto = typeof self === "object" && "crypto" in self ? self.crypto : undefined;
    const nodeRequire =  true &&
        __nccwpck_require__(387).bind(module); ------>. The node ID might be different
    return {
        node: nodeRequire && !webCrypto ? nodeRequire("crypto") : undefined,
        web: webCrypto
    };
})(); 
  1. The module with ID 387 resolves to the code below
/***/ 387:
/***/ ((module) => {

function webpackEmptyContext(req) {
	var e = new Error("Cannot find module '" + req + "'");
	e.code = 'MODULE_NOT_FOUND';
	throw e;
}
webpackEmptyContext.keys = () => ([]);
webpackEmptyContext.resolve = webpackEmptyContext;
webpackEmptyContext.id = 387;
module.exports = webpackEmptyContext; 

Expected Behavior

Running ncc build does not generate a webpackEmptyContext function when looking for the crypto module.

Versions

@vercel/ncc: 0.34.0

Any suggestions on what to check are appreciated! Thanks in advance.

Forked On 04 Oct 2022 at 01:57:56

Paulmillr

@cds95 right -- even if you did not configure anything specifically, vercel/ncc executes some configuration on its own.

Commented On 04 Oct 2022 at 01:57:56

Paulmillr

Missing crypto module when building the project using ncc and Webpack

Hi everyone, this may or may not be an issue with js-ethereum-cryptography itself but rather an issue with @vercel/ncc and webpack builds. I'm posting it here anyways in case anyone has any ideas on what is going on.

Issue I have a project that is using a dependency that is dependent on the keccak file from ethereum-cryptography@1.0.3. I then bunde my project into a single JS file using the ncc build command from this project, which uses Webpack internally.

Now the issue is that ncc transforms this code to the code below as ncc can't find the crypto package for some reason:

/***/ 84310:
/***/ ((module) => {

function webpackEmptyContext(req) {
	var e = new Error("Cannot find module '" + req + "'");
	e.code = 'MODULE_NOT_FOUND';
	throw e;
}
webpackEmptyContext.keys = () => ([]);
webpackEmptyContext.resolve = webpackEmptyContext;
webpackEmptyContext.id = 84310;
module.exports = webpackEmptyContext;
/***/ }), 

This leads to my project crashing with this error when I try run it:

Error: Cannot find module 'crypto'
    at Object.webpackEmptyContext (/Users/christophersastropranoto/Documents/external-adapters-js/packages/sources/layer2-sequencer-health/bundle/index.js:183577:10)
    at /Users/christophersastropranoto/Documents/external-adapters-js/packages/sources/layer2-sequencer-health/bundle/index.js:83270:43
    at Object.78777 (/Users/christophersastropranoto/Documents/external-adapters-js/packages/sources/layer2-sequencer-health/bundle/index.js:83273:3)
    at __nccwpck_require__ (/Users/christophersastropranoto/Documents/external-adapters-js/packages/sources/layer2-sequencer-health/bundle/index.js:183842:43)
    at Object.35681 (/Users/christophersastropranoto/Documents/external-adapters-js/packages/sources/layer2-sequencer-health/bundle/index.js:83194:17)
    at __nccwpck_require__ (/Users/christophersastropranoto/Documents/external-adapters-js/packages/sources/layer2-sequencer-health/bundle/index.js:183842:43)
    at Object.30038 (/Users/christophersastropranoto/Documents/external-adapters-js/packages/sources/layer2-sequencer-health/bundle/index.js:169615:16)
    at __nccwpck_require__ (/Users/christophersastropranoto/Documents/external-adapters-js/packages/sources/layer2-sequencer-health/bundle/index.js:183842:43)
    at Object.55944 (/Users/christophersastropranoto/Documents/external-adapters-js/packages/sources/layer2-sequencer-health/bundle/index.js:168123:14)
    at __nccwpck_require__ (/Users/christophersastropranoto/Documents/external-adapters-js/packages/sources/layer2-sequencer-health/bundle/index.js:183842:43) {
  code: 'MODULE_NOT_FOUND'
} 

I've confirmed that this issue is also happening when I try to build the ethereum-cryptography package by itself.

Steps to repro

Run from the root of the ethereum-cryptography repository.

  1. Add @vercel/ncc package yarn add @vercel/ncc
  2. Build the keccak.ts file. ncc build keccak.js -o bundle/index.js
  3. This should have created a new directory named bundle in the root folder with an index.js file. Inspect the generated index.js file and find the code below
exports.crypto = (() => {
    const webCrypto = typeof self === "object" && "crypto" in self ? self.crypto : undefined;
    const nodeRequire =  true &&
        __nccwpck_require__(387).bind(module); ------>. The node ID might be different
    return {
        node: nodeRequire && !webCrypto ? nodeRequire("crypto") : undefined,
        web: webCrypto
    };
})(); 
  1. The module with ID 387 resolves to the code below
/***/ 387:
/***/ ((module) => {

function webpackEmptyContext(req) {
	var e = new Error("Cannot find module '" + req + "'");
	e.code = 'MODULE_NOT_FOUND';
	throw e;
}
webpackEmptyContext.keys = () => ([]);
webpackEmptyContext.resolve = webpackEmptyContext;
webpackEmptyContext.id = 387;
module.exports = webpackEmptyContext; 

Expected Behavior

Running ncc build does not generate a webpackEmptyContext function when looking for the crypto module.

Versions

@vercel/ncc: 0.34.0

Any suggestions on what to check are appreciated! Thanks in advance.

Forked On 04 Oct 2022 at 01:41:14

Paulmillr

The code is tested with webpack and rollup, so the problem seems to be in your configuration. Report this to NCC.

Commented On 04 Oct 2022 at 01:41:14
Create Branch

Paulmillr

Minimal implementation of SLIP-0010 hierarchical deterministic (HD) wallets

On 04 Oct 2022 at 12:20:57

Paulmillr

Remove pkg json type module

Pushed On 04 Oct 2022 at 12:20:55

Paulmillr

Release 0.1.2.

Pushed On 04 Oct 2022 at 12:20:55

Paulmillr

Update README.md

Pushed On 03 Oct 2022 at 10:36:10

Paulmillr

README: hdkey

Pushed On 03 Oct 2022 at 09:48:53

Paulmillr

git repo

Pushed On 03 Oct 2022 at 09:48:30

Paulmillr

README: hdkey

Pushed On 03 Oct 2022 at 09:47:24

Paulmillr

README: hdkey

Pushed On 03 Oct 2022 at 09:46:55
Create Branch

Paulmillr

Minimal implementation of SLIP-0010 hierarchical deterministic (HD) wallets

On 03 Oct 2022 at 09:44:52

Paulmillr

Release 0.1.1.

Pushed On 03 Oct 2022 at 09:44:51

Paulmillr

fix tests

Pushed On 03 Oct 2022 at 09:42:28

Paulmillr

Commonjs version, rename pkg

Pushed On 03 Oct 2022 at 09:41:08
Issue Comment

Paulmillr

const mn = bip39.generateMnemonic(wordlist)

I can't make a mnemonic example like readme file.

image

But, this works.

Forked On 03 Oct 2022 at 01:26:08

Paulmillr

import { wordlist } from '@scure/bip39/wordlists/english';

See it's {wordlist} which uses destructive assignment. Since you are not using it, you are not following readme example in full

Commented On 03 Oct 2022 at 01:26:08

Paulmillr

Update README.md

Pushed On 01 Oct 2022 at 07:39:54

Paulmillr

Add link to noble

Pushed On 01 Oct 2022 at 07:34:10

Paulmillr

Link to ed25519-hdkey

Pushed On 01 Oct 2022 at 07:31:42

Paulmillr

Link to ed25519-hdkey

Pushed On 01 Oct 2022 at 06:04:53

Paulmillr

Link to ed25519-hdkey

Pushed On 01 Oct 2022 at 06:04:31

Paulmillr

Fix misleading comment, stating incorrect multiplication.

Pushed On 01 Oct 2022 at 08:10:53

Paulmillr

Merge pull request #58 from Sajjon/fix_misleading_comment

Pushed On 01 Oct 2022 at 08:10:53

Paulmillr

[No Code Change] Fix misleading comment, stating incorrect multiplication.

Created On 01 Oct 2022 at 08:10:52