rainlanguage / rain-protocol

Rain Protocol lets you build web3 economies at any scale.
https://rainprotocol.xyz/
25 stars 16 forks source link

Struct interfaces from typechain #453

Open marcusnewton opened 2 years ago

marcusnewton commented 2 years ago

It's difficult to bump typechain since we depend on importing XStruct types to help us type check our config structs in our tests. The latest versions of typechain now wrap properties with PromiseOrValue<T> which is frustrating as we would need to await every usage of those properties in our tests, even though there's nothing to await.

The other option is somehow extracting only the non-array properties from union types that typechain generates, however I'm not sure of how to make TypeScript let us do that.

  export type FooStructOutput = [BigNumber, BigNumber] & {
    a: BigNumber;
    b: BigNumber;
  };

Ideally, however, typechain would generate actual interfaces we can use that simply contain struct properties without being wrapped by PromiseOrValue<T>. Will seek to get this resolved upstream.

marcusnewton commented 2 years ago

Submitted upstream issue https://github.com/dethcrypto/TypeChain/issues/759

marcusnewton commented 2 years ago

See our utility type to sanitise XOutputStruct types: https://github.com/beehive-innovation/rain-protocol/blob/bump-typechain-hardhat/utils/types/index.ts#L19-L41