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

Modify ethers imports #3

Open
connorbode opened this issue Dec 24, 2021 · 2 comments
Open

Modify ethers imports #3

connorbode opened this issue Dec 24, 2021 · 2 comments

Comments

@connorbode
Copy link

There are a number of ethersjs imports in the library as follows:

import ethers from 'ethers'

In my build process, this causes an error as ethersjs does not have a default export. The correct way of importing seems to be import { ethers } from 'ethers'

@jp4g
Copy link

jp4g commented Feb 17, 2022

I am having this issue importing circomlibjs into .tsx/ .jsx files. Off the bat I was having multiple issues with webpack building, which I was able to resolve adding the following to my package.json:

...
"devDependencies": {
    "assert": "npm:assert-browserify",
    "crypto": "npm:crypto-browserify",
    "fs": "npm:-@^0.0.1",
    "os": "npm:os-browserify",
    "path": "npm:path-browserify",
    "stream": "npm:stream-browserify"
}
...

There is this repeating error left. For all files that import ethers using import ethers as "ethers" this error throws during build process:

ERROR in ./node_modules/circomlibjs/src/poseidon_gencontract.js 139:32-56
export 'default' (imported as 'ethers') was not found in 'ethers' (possible exports: BaseContract, BigNumber, Contract, ContractFactory, FixedNumber, Signer, VoidSigner, Wallet, Wordlist, constants, errors, ethers, getDefaultProvider, logger, providers, utils, version, wordlists)
 @ ./node_modules/circomlibjs/main.js 12:0-67 13:32-49
 @ ./src/zk/index.ts 3:0-46 9:27-42
 @ ./src/views/Game/index.tsx 11:0-32 127:10-20
 @ ./src/Routes.tsx 8:0-30 20:32-36
 @ ./src/App.tsx 4:0-28 10:35-41
 @ ./src/index.tsx 7:0-24 11:33-36

Based on @connorbode 's juggestion I have set up the following postinstall.sh:

#!/bin/bash
sed -i'' 's/import ethers as "ethers"/import { ethers } as "ethers"/g' ./node_modules/circomlibjs/src/evmasm.js
sed -i'' 's/import ethers as "ethers"/import { ethers } as "ethers"/g' ./node_modules/circomlibjs/src/mimcsponge.js
sed -i'' 's/import ethers as "ethers"/import { ethers } as "ethers"/g' ./node_modules/circomlibjs/src/mimc7_gencontract.js
sed -i'' 's/import ethers as "ethers"/import { ethers } as "ethers"/g' ./node_modules/circomlibjs/src/poseidon_gencontract.js
sed -i'' 's/import ethers as "ethers"/import { ethers } as "ethers"/g' ./node_modules/circomlibjs/src/mimcsponge_gencontract.js
sed -i'' 's/import ethers as "ethers"/import { ethers } as "ethers"/g' ./node_modules/circomlibjs/src/mimc7.js

This results in a "successful" complilation, however webpack serves a blank page. Any input would be greatly appreciated

Edit: here is the offending repository of code: https://github.com/Ian-Bright/battlezip-frontend/tree/zk

@Ian-Bright
Copy link

Ian-Bright commented Feb 17, 2022

Having the same issue myself

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

No branches or pull requests

3 participants