austintgriffith/dapparatus

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

leonmak opened this issue · 5 comments

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

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.

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.

@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 });
          }}
        />

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.

Maybe Event loader is trying to load before ContractLoader has finished