graphprotocol / graph-node

Graph Node indexes data from blockchains such as Ethereum and serves it over GraphQL
https://thegraph.com
Apache License 2.0
2.91k stars 968 forks source link

Code example gives `unexpected upcast` #5088

Open pscott opened 10 months ago

pscott commented 10 months ago

Hi,

I'm getting some errors while trying to run the example code on my environment. This code here: https://github.com/graphprotocol/graph-node/blob/6a7806cc465949ebb9e5b8269eeb763857797efc/tests/integration-tests/host-exports/src/mapping.ts#L73-L88

Gives:

  Describe entity assertions:
thread 'main' panicked at '🆘 Unexpected error upon calling hook: Mapping aborted at tests/boost.test.ts, line 40, column 42, with message: unexpected upcast
wasm backtrace:
    0: 0x1c63 - <unknown>!start:tests/boost.test~anonymous|0~anonymous|0

The problem comes from the as ethereum.Tuple casting. I've tried other examples, they all give the same result.

My setup: mac m1 running with graph test -d versions:

  "dependencies": {
    "@graphprotocol/graph-cli": "0.64.0",
    "@graphprotocol/graph-ts": "0.32.0"
  },
  "devDependencies": {
    "matchstick-as": "^0.6.0"
  }
incrypto32 commented 9 months ago

Why don't you simply do something like

 let tupleArray: ethereum.Tuple = [ 
   fixedSizedArray, 
   bool 
 ]; 

this?

I believe casting only changes how the type is interpreted by the compiler but the runtime type remains the same, maybe thats the reason it fails.

pscott commented 9 months ago

@incrypto32 thx for your input.

The reason I created an issue was not to find a solution to my problem, but rather to point out the fact that the example given in the documentation is wrong. I believe the documentation should be updated (as for the exact way it should be updated, I will let someone with more experience than me jump in :))

github-actions[bot] commented 3 months ago

Looks like this issue has been open for 6 months with no activity. Is it still relevant? If not, please remember to close it.