subsquid / squid-sdk

The main repo of the squid SDK
Apache License 2.0
1.23k stars 151 forks source link

ink! smart contract without events should have any type #151

Closed vikiival closed 1 year ago

vikiival commented 1 year ago

Describe the bug

I have a smart contract that does not emit any events

the problem is when I do npx squid-ink-typegen (+ args ofc)

it generates content like:

export function decodeEvent(hex: string): Event {
    return _abi.decodeEvent(hex)
}

export type Event = never

Now it it impossible to build the squid

src/abi/marketplace.ts:1412:5 - error TS2322: Type 'any' is not assignable to type 'never'.

1412     return _abi.decodeEvent(hex)
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 1 error in src/abi/marketplace.ts:1412
  1. FIX is to return any if there is no event present
export type Event = any

or

  1. do not generate decodeEvent function
belopash commented 1 year ago

It looks correct to me. Why do you want to use this function if there are no events?

belopash commented 1 year ago

Maybe we should make generated files similar to evm-typegen, so there will be no such issues. @tmcgroul what do you think?

tmcgroul commented 1 year ago

Maybe we should make generated files similar to evm-typegen, so there will be no such issues. @tmcgroul what do you think?

Fixed just the type issue for now. I think there is no reason to make generated files similar to evm-typegen... but some features would be useful to implement