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

feat: add DepositedAndCalled and WithdrawnAndCalled events #403

Merged
merged 9 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions v2/contracts/evm/GatewayEVM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ contract GatewayEVM is

if (!deposited) revert DepositFailed();

emit Deposited(msg.sender, receiver, msg.value, address(0), payload, revertOptions);
emit DepositedAndCalled(msg.sender, receiver, msg.value, address(0), payload, revertOptions);
}

/// @notice Deposits ERC20 tokens to the custody or connector contract and calls an omnichain smart contract.
Expand All @@ -333,7 +333,7 @@ contract GatewayEVM is

_transferFromToAssetHandler(msg.sender, asset, amount);

emit Deposited(msg.sender, receiver, amount, asset, payload, revertOptions);
emit DepositedAndCalled(msg.sender, receiver, amount, asset, payload, revertOptions);
}

/// @notice Calls an omnichain smart contract without asset transfer.
Expand Down
18 changes: 17 additions & 1 deletion v2/contracts/evm/interfaces/IGatewayEVM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ interface IGatewayEVMEvents {
/// @param receiver The address of the receiver.
/// @param amount The amount of ETH or tokens deposited.
/// @param asset The address of the ERC20 token (zero address if ETH).
/// @param payload The calldata passed with the deposit.
/// @param payload The calldata passed with the deposit. No longer used. Kept to maintain compatibility.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Clarify the deprecation of the payload parameter in the Deposited event

The comment for the payload parameter indicates it's "No longer used" but "Kept to maintain compatibility." To enhance clarity, consider marking this parameter as deprecated using a standard annotation or adding a clear deprecation notice. This will help developers understand that it should not be used in new implementations.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we need to keep unused field? we have breaking interface in v21 for other things as well

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Keep depositAndCall emitted events valid between node upgrade -> gateway upgrade (even though it should not be used)
  • I think changing the events mess up with the indexers

/// @param revertOptions Revert options.
event Deposited(
address indexed sender,
Expand All @@ -43,6 +43,22 @@ interface IGatewayEVMEvents {
RevertOptions revertOptions
);

/// @notice Emitted when a deposit and call is made.
/// @param sender The address of the sender.
/// @param receiver The address of the receiver.
/// @param amount The amount of ETH or tokens deposited.
/// @param asset The address of the ERC20 token (zero address if ETH).
/// @param payload The calldata passed with the deposit.
/// @param revertOptions Revert options.
event DepositedAndCalled(
address indexed sender,
address indexed receiver,
uint256 amount,
address asset,
bytes payload,
RevertOptions revertOptions
);

/// @notice Emitted when an omnichain smart contract call is made without asset transfer.
/// @param sender The address of the sender.
/// @param receiver The address of the receiver.
Expand Down
4 changes: 2 additions & 2 deletions v2/contracts/zevm/GatewayZEVM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ contract GatewayZEVM is
if (message.length + revertOptions.revertMessage.length > MAX_MESSAGE_SIZE) revert MessageSizeExceeded();

uint256 gasFee = _withdrawZRC20WithGasLimit(amount, zrc20, callOptions.gasLimit);
emit Withdrawn(
emit WithdrawnAndCalled(
msg.sender,
0,
receiver,
Expand Down Expand Up @@ -269,7 +269,7 @@ contract GatewayZEVM is
// if (message.length + revertOptions.revertMessage.length > MAX_MESSAGE_SIZE) revert MessageSizeExceeded();

// _transferZETA(amount, PROTOCOL_ADDRESS);
// emit Withdrawn(
// emit WithdrawnAndCalled(
// msg.sender, chainId, receiver, address(zetaToken), amount, 0, 0, message, callOptions, revertOptions
// );
}
Expand Down
26 changes: 25 additions & 1 deletion v2/contracts/zevm/interfaces/IGatewayZEVM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface IGatewayZEVMEvents {
/// @param value The amount of tokens withdrawn.
/// @param gasfee The gas fee for the withdrawal.
/// @param protocolFlatFee The protocol flat fee for the withdrawal.
/// @param message The calldata passed to the contract call.
/// @param message The calldata passed with the withdraw. No longer used. Kept to maintain compatibility.
/// @param callOptions Call options including gas limit and arbirtrary call flag.
/// @param revertOptions Revert options.
event Withdrawn(
Expand All @@ -46,6 +46,30 @@ interface IGatewayZEVMEvents {
CallOptions callOptions,
RevertOptions revertOptions
);

/// @notice Emitted when a withdraw and call is made.
/// @param sender The address from which the tokens are withdrawn.
/// @param chainId Chain id of external chain.
/// @param receiver The receiver address on the external chain.
/// @param zrc20 The address of the ZRC20 token.
/// @param value The amount of tokens withdrawn.
/// @param gasfee The gas fee for the withdrawal.
/// @param protocolFlatFee The protocol flat fee for the withdrawal.
/// @param message The calldata passed to the contract call.
/// @param callOptions Call options including gas limit and arbirtrary call flag.
/// @param revertOptions Revert options.
event WithdrawnAndCalled(
address indexed sender,
uint256 indexed chainId,
bytes receiver,
address zrc20,
uint256 value,
uint256 gasfee,
uint256 protocolFlatFee,
bytes message,
CallOptions callOptions,
RevertOptions revertOptions
);
}

/// @title IGatewayZEVMErrors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ function withdrawAndRevert(

Deposits asset to custody and pay fee in zeta erc20.

**Note:**
This method is deprecated.


```solidity
function deposit(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ uint256 public constant MAX_PAYLOAD_SIZE = 1024;
## Functions
### constructor

**Note:**
constructor


```solidity
constructor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,32 @@ event Deposited(

**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`sender`|`address`|The address of the sender.|
|`receiver`|`address`|The address of the receiver.|
|`amount`|`uint256`|The amount of ETH or tokens deposited.|
|`asset`|`address`|The address of the ERC20 token (zero address if ETH).|
|`payload`|`bytes`|The calldata passed with the deposit. No longer used. Kept to maintain compatibility.|
|`revertOptions`|`RevertOptions`|Revert options.|

### DepositedAndCalled
Emitted when a deposit and call is made.


```solidity
event DepositedAndCalled(
address indexed sender,
address indexed receiver,
uint256 amount,
address asset,
bytes payload,
RevertOptions revertOptions
);
```

**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`sender`|`address`|The address of the sender.|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ modifier onlyProtocol();

### constructor

**Note:**
constructor


```solidity
constructor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,40 @@ event Withdrawn(

**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`sender`|`address`|The address from which the tokens are withdrawn.|
|`chainId`|`uint256`|Chain id of external chain.|
|`receiver`|`bytes`|The receiver address on the external chain.|
|`zrc20`|`address`|The address of the ZRC20 token.|
|`value`|`uint256`|The amount of tokens withdrawn.|
|`gasfee`|`uint256`|The gas fee for the withdrawal.|
|`protocolFlatFee`|`uint256`|The protocol flat fee for the withdrawal.|
|`message`|`bytes`|The calldata passed with the withdraw. No longer used. Kept to maintain compatibility.|
|`callOptions`|`CallOptions`|Call options including gas limit and arbirtrary call flag.|
|`revertOptions`|`RevertOptions`|Revert options.|

### WithdrawnAndCalled
Emitted when a withdraw and call is made.


```solidity
event WithdrawnAndCalled(
address indexed sender,
uint256 indexed chainId,
bytes receiver,
address zrc20,
uint256 value,
uint256 gasfee,
uint256 protocolFlatFee,
bytes message,
CallOptions callOptions,
RevertOptions revertOptions
);
```

**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`sender`|`address`|The address from which the tokens are withdrawn.|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# zContract
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/main/v2/contracts/zevm/interfaces/UniversalContract.sol)

**Note:**
should be removed once v2 SystemContract is not used anymore.
UniversalContract should be used


## Functions
### onCrossChainCall
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# zContext
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/main/v2/contracts/zevm/interfaces/UniversalContract.sol)

**Note:**
should be removed once v2 SystemContract is not used anymore.
MessageContext should be used


```solidity
struct zContext {
Expand Down
Loading
Loading