Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generic event factory #55

Closed
wants to merge 1 commit into from
Closed

Conversation

valle-xyz
Copy link

With this function, most of the boilerplate code through createFooEvent helpers can be avoided. It can be called with an array of ethereum.Value directly.

Here is an example:

        // You can define values as a variable:
        let signature = Bytes.fromHexString(
            "0x2233cc"
        ); 

        // Or parse them directly:
        let newFooEvent = newEvent<FooEvent>([
            ethereum.Value.fromAddress(
                Address.fromString("0xa16081f360e3847006db660bae1c6d1b2e17ec2a")
            ),
            ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(1)),
            ethereum.Value.fromBytes(signature),
        ]);

        // Now you simply handle the new event
        handleFooEvent(newFooEvent);

With this function, most of the boilerplate code through createFooEvent helpers can be avoided. It can be called with an array of ethereum.Value directly.

Here is an example:

```
    let signature = Bytes.fromHexString(
            "0x2233cc"
        ); // Example signature
        let newFooEvent = newEvent<FooEvent>([
            ethereum.Value.fromAddress(
                Address.fromString("0xa16081f360e3847006db660bae1c6d1b2e17ec2a")
            ),
            ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(1)),
            ethereum.Value.fromBytes(signature),
        ]);

        handleFooEvent(newFooEvent);
```
@georg-getz
Copy link
Member

Hi, just seeing this, it seems interesting. The whole team is off until the 5th of February though. We will review/release this then.

@georg-getz georg-getz self-requested a review February 26, 2023 01:00
@valle-xyz
Copy link
Author

Awesome! Enjoy your holiday! :-)

@georg-getz
Copy link
Member

Hi, I changed the code a bit and added a few more helper functions here so I'm closing this. They're available in matchstick-as 0.5.2

@georg-getz georg-getz closed this Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants