Skip to content

Use try catch #205

@skosito

Description

@skosito
          In cases where we want to invoke an interface (there are a few of them across all the contracts), we can call them in a controlled way, such as in:
        IZRC20 zrc20token = IZRC20(zrc20);
        
        try zrc20token.withdrawGasFee() returns (address gasZRC20, uint256 gasFee) {
            if (gasZRC20 == address(0)) revert InvalidZRC20;
            if (!zrc20token.transferFrom(msg.sender, FUNGIBLE_MODULE_ADDRESS, gasFee)) {
                revert GasFeeTransferFailed();
            }
        } catch {
            revert SomeErrorEvent();
        }

Originally posted by @fbac in https://github.com/zeta-chain/protocol-contracts/pull/162#discussion_r1663924981

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions