trufflesuite / drizzle

Reactive Ethereum dapp UI suite
906 stars 236 forks source link

IDrizzleOptions in TypeScript cannot read contract.json #66

Closed hoonsubin closed 4 years ago

hoonsubin commented 4 years ago

Error message:

Failed to compile
/home/hoonkim/Projects/ethereum-lockdrop/app/src/helpers/lockdrop/EthereumLockdrop.ts
TypeScript error in /home/hoonkim/Projects/ethereum-lockdrop/app/src/helpers/lockdrop/EthereumLockdrop.ts(11,14):
Type '{ "contractName": string; "abi": ({ "inputs": { "internalType": string; "name": string; "type": string; }[]; "payable": boolean; "stateMutability": string; "type": string; } | { "anonymous": boolean; "inputs": { "indexed": boolean; "internalType": string; "name": string; "type": string; }[]; "name": string; "type": ...' is not assignable to type 'IContract'.
  Types of property 'abi' are incompatible.
    Type '({ "inputs": { "internalType": string; "name": string; "type": string; }[]; "payable": boolean; "stateMutability": string; "type": string; } | { "anonymous": boolean; "inputs": { "indexed": boolean; "internalType": string; "name": string; "type": string; }[]; "name": string; "type": string; } | { ...; } | { ...; })[]' is not assignable to type 'ABI[]'.
      Type '{ "inputs": { "internalType": string; "name": string; "type": string; }[]; "payable": boolean; "stateMutability": string; "type": string; } | { "anonymous": boolean; "inputs": { "indexed": boolean; "internalType": string; "name": string; "type": string; }[]; "name": string; "type": string; } | { ...; } | { ...; }' is not assignable to type 'ABI'.
        Type '{ "inputs": { "internalType": string; "name": string; "type": string; }[]; "payable": boolean; "stateMutability": string; "type": string; }' is missing the following properties from type 'ABI': constant, name, outputs  TS2322

     9 | 
    10 | export const drizzleOptions: IDrizzleOptions = {
  > 11 |    contracts: [Lockdrop],
       |                ^
    12 |    events: {
    13 |        Lockdrop: ["Locked"],
    14 |    }

I'm using Ubuntu 19.10 and drizzle version ^1.5.1. This issue happens with other smart contracts and other systems as well. The code where this error happens: https://github.com/hoonsubin/ethereum-lockdrop/blob/master/app/src/helpers/lockdrop/EthereumLockdrop.ts

am-kra4un commented 4 years ago

have the same trouble

adrianmcli commented 4 years ago

Looks like the ABI produced is missing the following properties: constant, name, outputs.

This is probably where the problem lies: https://github.com/trufflesuite/drizzle/blob/develop/packages/store/types/IContract.d.ts#L1-L17

@hoonsubin @am-kra4un Can I ask which version Solidity compiler you guys are using? And also Truffle version if possible.

hoonsubin commented 4 years ago

@adrianmcli Thank you for your reply.

Truffle v5.1.15 (core: 5.1.15) Solidity - 0.5.15 (solc-js) Node v13.8.0 Web3.js v1.2.1

I've made a temporary workaround by wrapping the contract json as any

am-kra4un commented 4 years ago

@adrianmcli, you're right. This is the first item of the abi array, that caused a problem { "inputs": [], "payable": false, "stateMutability": "nonpayable", "type": "constructor" },

Truffle v5.1.11 (core: 5.1.11) Solidity v0.5.16 (solc-js) Node v10.16.0 Web3.js v1.2.1

adrianmcli commented 4 years ago

We can probably change the types to make those optional for now. I'll happily merge a PR for that if you would like to provide one.