trufflesuite / drizzle

Reactive Ethereum dapp UI suite
906 stars 238 forks source link

drizzleOptions clarrification #86

Open dabruhce opened 4 years ago

dabruhce commented 4 years ago

Basically with the drizzleOptions.js file I assume that I should be able to listen to contract events if I include them in drizzleOptions. The contract seems to load fine, but when I trigger the event it never gets picked up. Is my assumption incorrect?

In scenario below events for MyContract work fine, but I never see Name contract fire events when they fire.


//drizzleOptions.js

/* this contract is deployed via truffle Migrate */
import MyContract from './contracts/MyContract';

/* this contract is unrelated to project */
import { abi as NameABI } from "./contracts/Name.json"
const contractAddress = '0x526ga'; //some address

const web3Contract = new web3.eth.Contract(nameABI, contractAddress)

let contractConfig = {
  contractName: "Name",
  web3Contract: web3Contract
}

const eventOptions = web3Contract.events.OnName();
const event = {
  eventName: "OnName",
  eventOptions
}

const options = {
  web3: {
    block: false,
    fallback: {
      type: 'ws',
      url: 'ws://127.0.0.1:8545'
    }
  },
  contracts: [MyContract, contractConfig],
  events: {
    MyContract: ["Event1, "Event2"],
    event
    /* or this.. Names: ["OnName"] */
  },
  polls: {
    accounts: 10000,
  },
};

export default options;
dabruhce commented 4 years ago

ended up listening w/ web3 and passing messages around w/ store and handled then in middleware

cds-amal commented 4 years ago

Hi @brucedotio,

Sorry for the late response. We have a tutorial that shows how to work with events. It is similar in concept with your solution. I will update out documentation to explain how to work with events.