Skip to content

[Bug]: On Delegate Calls, All State Changes (including Events) Should be Stored in the Contract that Initiated the Delegate Call #111

@0xNeshi

Description

@0xNeshi

What happened?

Currently they are stored in the contract that was the target of the delegate call (i.e. the one with code that emits the event).

    #[motsu::test]
    fn delegate_call_with_event(
        proxy: Contract<Proxy>,
        erc20: Contract<Erc20>,
        alice: Address,
    ) {
        proxy.sender(alice).constructor(erc20.address());

        // mint 1000 tokens
        let amount = U256::from(1000);

        let mint_call =
            IERC20::mintCall { to: alice, value: amount }.abi_encode();
        proxy
            .sender(alice)
            .fallback(&mint_call)
            .expect("should be able to mint");
        
        // ERROR: THIS ASSERT FAILS, BUT SHOULD WORK
        proxy.assert_emitted(&Transfer {
            from: Address::ZERO,
            to: alice,
            value: amount,
        });

        // THIS ASSERT SHOULD FAIL, BUT WORKS
        erc20.assert_emitted(&Transfer {
            from: Address::ZERO,
            to: alice,
            value: amount,
        });

Related #104

platform

  • linux
  • windows
  • macos

Expected behavior

Events should be stored on the contract that initiated the delegate call

Contribution Guidelines

  • I agree to follow this project's Contribution Guidelines

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions