EOSIO / demux-js-eos

Demux-js Action Reader implementations for EOSIO blockchains
MIT License
39 stars 17 forks source link

Make `EosPayload` a generic interface #75

Closed flux627 closed 5 years ago

flux627 commented 5 years ago

This change allows users to pass in a type for the EosPayload.data property when defining their updaters/effects, which should correspond to the Blockchain contract action's struct:

interface AssetStruct {
  amount: number
  symbol: string
}

const apply = async (state: any, payload: EosPayload<AssetStruct>, blockInfo: BlockInfo) => {
  state.save({
    amount: payload.data.amount,
    symbol: payload.data.symbol,
  })
}