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

ContractLoader Error: Cannot find module './contracts/contracts.js'. #2

Open
leonmak opened this issue Nov 7, 2018 · 5 comments
Open

Comments

@leonmak
Copy link

leonmak commented Nov 7, 2018

I'm not sure why but I can't seem to use ContractLoader

Error: Cannot find module './contracts/contracts.js'.

  35 | />
  36 | <ContractLoader
  37 |    web3={web3}
> 38 |    require={path => {return require(`${__dirname}/${path}`)}}
  39 |    onReady={(contracts)=>{
  40 |      console.log("contracts loaded",contracts)
  41 |      this.setState({contracts:contracts})

trying out the article https://medium.com/@austin_48503/%EF%B8%8Fclevis-blockchain-orchestration-682d2396aeef
with https://github.com/austintgriffith/broadcaster-example-dapp.git

@leonmak
Copy link
Author

leonmak commented Nov 7, 2018

update: I had to move the contract files from clevis compile, deploy to the src folder and change the paths in the ContractLoader component, but got ERROR LOADING CONTRACT Broadcaster Error: You must provide the json interface of the contract when instantiating a contract object.

@austintgriffith
Copy link
Owner

yeah so the trick here is to run a 'clevis test publish' or 'clevis test full' before uncommenting the contract loader because it needs to inject the contracts in.

However, we should probably do a better job of detecting that it's not there and throw a quiet error in the console instead of crashing the app.

@pi0neerpat
Copy link
Collaborator

@austintgriffith I had the same issue, so I'll add a note in the docs.

I am now getting "contract is undefined" from the Events component, despite the loader working properly.

<Events
          config={{ hide: false }}
          contract={contracts.Name}
          eventName={'Create'}
          block={block}
          id={'_id'}
          filter={{}}
          onUpdate={(eventData, allEvents) => {
            console.log('EVENT DATA:', eventData);
            this.setState({ events: allEvents });
          }}
        />

@austintgriffith
Copy link
Owner

I think on the Dapparatus side, let's just catch any of those errors quietly and dish them to the console. I hate that it breaks the the entire app when those contracts are missing.

This is a change that would need to go into both the and the components to catch first time errors.

@pi0neerpat
Copy link
Collaborator

Maybe Event loader is trying to load before ContractLoader has finished

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