Skip to content

Address[] can not assign to Bytes[] #1017

@sdakhara

Description

@sdakhara

I don't know what went wrong but when i try npm run build which runs graph build it throws error mentioned bellow

Compile subgraphERROR TS2322: Type '~lib/array/Array<~lib/@graphprotocol/graph-ts/common/numbers/Address>' is not assignable to type '~lib/array/Array<~lib/@graphprotocol/graph-ts/common/collections/Bytes>'.

   entity.targets = event.params.targets;
                    ~~~~~~~~~~~~~~~~~~~~
 in src/dcode-dao.ts(43,20)

✖ Failed to compile subgraph: Failed to compile data source mapping: 1 compile error(s)
Error: Failed to compile data source mapping: 1 compile error(s)
    at Compiler._compileDataSourceMapping (/home/eu4/Desktop/DcodeGraph/node_modules/@graphprotocol/graph-cli/src/compiler/index.js:320:13)
    at /home/eu4/Desktop/DcodeGraph/node_modules/@graphprotocol/graph-cli/src/compiler/index.js:224:20
    at updateInDeepMap (/home/eu4/Desktop/DcodeGraph/node_modules/immutable/dist/immutable.js:1971:22)
    at updateInDeepMap (/home/eu4/Desktop/DcodeGraph/node_modules/immutable/dist/immutable.js:1980:23)
    at updateInDeepMap (/home/eu4/Desktop/DcodeGraph/node_modules/immutable/dist/immutable.js:1980:23)
    at Map.updateIn (/home/eu4/Desktop/DcodeGraph/node_modules/immutable/dist/immutable.js:1278:26)
    at /home/eu4/Desktop/DcodeGraph/node_modules/@graphprotocol/graph-cli/src/compiler/index.js:223:24
    at /home/eu4/Desktop/DcodeGraph/node_modules/immutable/dist/immutable.js:3016:46
    at List.__iterate (/home/eu4/Desktop/DcodeGraph/node_modules/immutable/dist/immutable.js:2206:13)
    at IndexedIterable.mappedSequence.__iterateUncached (/home/eu4/Desktop/DcodeGraph/node_modules/immutable/dist/immutable.js:3015:23)
UNCAUGHT EXCEPTION: Error: The AssemblyScript compiler crashed when compiling this file: 'src/dcode-dao.ts'
Suggestion: try to comment the whole file and uncomment it little by little while re-running the graph-cli until you isolate the line where the problem happens.
Also, please contact us so we can make the CLI better by handling errors like this. You can reach out in any of these links:
- Discord channel: https://discord.gg/eM8CA6WA9r
- Github issues: https://github.com/graphprotocol/graph-cli/issues

I was creating a DAO contract using Openzeppelin Governor contract and this contract emits an event called

ProposalCreated (uint256 proposalId, address proposer, address[] targets, uint256[] values, string[] signatures, bytes[] calldatas, uint256 startBlock, uint256 endBlock, string description)

You can see that it emits an Address array named targets. when i run npm run codegen it create this parameter as an Address Array type object. and in side the build script it assigns to a Bytes Array type Object.

and it throws the error.

ERROR TS2322: Type '~lib/array/Array<~lib/@graphprotocol/graph-ts/common/numbers/Address>' is not assignable to type '~lib/array/Array<~lib/@graphprotocol/graph-ts/common/collections/Bytes>'.

   entity.targets = event.params.targets;
                    ~~~~~~~~~~~~~~~~~~~~
 in src/dcode-dao.ts(43,20)

i have mentioned whole error console on top of the issue.

inshort
Address Array can not be Assigned to the Bytes Array.

Tell me if you need any screen shot of the error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions