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 onAbort interface #450

Merged
merged 4 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
28 changes: 28 additions & 0 deletions contracts/Revert.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,38 @@ struct RevertContext {
bytes revertMessage;
}

/// @notice Struct containing abort context passed to onAbort.
/// @param sender Address of account that initiated smart contract call.
/// bytes is used as the crosschain transaction can be initiated from a non-EVM chain.
/// @param asset Address of asset. On a connected chain, it contains the fungible
/// token address or is empty if it's a gas token. On ZetaChain, it contains the
/// address of the ZRC20.
/// @param amount Amount specified with the transaction.
/// @param outgoing Flag to indicate if the crosschain transaction was outgoing: from ZetaChain to connected chain.
lumtis marked this conversation as resolved.
Show resolved Hide resolved
/// if false, the transaction was incoming: from connected chain to ZetaChain.
/// @param chainID Chain ID of the connected chain.
/// @param revertMessage Arbitrary data specified in the RevertOptions object when initating the crosschain transaction.
struct AbortContext {
bytes sender;
address asset;
uint256 amount;
bool outgoing;
fadeev marked this conversation as resolved.
Show resolved Hide resolved
uint256 chainID;
bytes revertMessage;
}

/// @title Revertable
/// @notice Interface for contracts that support revertable calls.
interface Revertable {
/// @notice Called when a revertable call is made.
/// @param revertContext Revert context to pass to onRevert.
function onRevert(RevertContext calldata revertContext) external;
}

/// @title Abortable
/// @notice Interface for contracts that support abortable calls.
interface Abortable {
/// @notice Called when a revertable call is aborted.
/// @param abortContext Abort context to pass to onAbort.
function onAbort(AbortContext calldata abortContext) external;
}
10 changes: 5 additions & 5 deletions docs/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

Contracts of official protocol contracts deployed by the core ZetaChain team.

### Learn more about ZetaChain
## Learn more about ZetaChain

* Check our [website](https://www.zetachain.com/).
* Read our [docs](https://docs.zetachain.com/).

### Codebase
## Codebase

The protocol contracts V2 codebase is separated into two sections:
The protocol contracts codebase is separated into two sections:

- `zevm`: contracts deployed on ZetaChain
- `evm`: contracts deployed on EVM connected chains (Ethereum, Base, etc..)
Expand All @@ -31,7 +31,7 @@ The protocol contracts V2 codebase is separated into two sections:

[Learn more about the Gateway contracts](https://www.zetachain.com/docs/developers/evm/gateway/)

### Usage
## Usage

**Install dependencies**

Expand Down Expand Up @@ -68,6 +68,6 @@ To view detailed instructions on how to deploy the contracts, please refer to th

This guide covers all steps required to deploy the contracts, including environment setup, commands, and best practices.

### Community
## Community

[X](https://x.com/zetablockchain) | [Discord](https://discord.com/invite/zetachain) | [Telegram](https://t.me/zetachainofficial) | [Website](https://zetachain.com)
2 changes: 2 additions & 0 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,6 @@
- [INotSupportedMethods](contracts/Errors.sol/interface.INotSupportedMethods.md)
- [RevertOptions](contracts/Revert.sol/struct.RevertOptions.md)
- [RevertContext](contracts/Revert.sol/struct.RevertContext.md)
- [AbortContext](contracts/Revert.sol/struct.AbortContext.md)
- [Revertable](contracts/Revert.sol/interface.Revertable.md)
- [Abortable](contracts/Revert.sol/interface.Abortable.md)
2 changes: 2 additions & 0 deletions docs/src/contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
- [INotSupportedMethods](Errors.sol/interface.INotSupportedMethods.md)
- [RevertOptions](Revert.sol/struct.RevertOptions.md)
- [RevertContext](Revert.sol/struct.RevertContext.md)
- [AbortContext](Revert.sol/struct.AbortContext.md)
- [Revertable](Revert.sol/interface.Revertable.md)
- [Abortable](Revert.sol/interface.Abortable.md)
22 changes: 22 additions & 0 deletions docs/src/contracts/Revert.sol/interface.Abortable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Abortable
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/main/v2/contracts/Revert.sol)

Interface for contracts that support abortable calls.


## Functions
### onAbort

Called when a revertable call is aborted.


```solidity
function onAbort(AbortContext calldata abortContext) external;
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`abortContext`|`AbortContext`|Abort context to pass to onAbort.|


28 changes: 28 additions & 0 deletions docs/src/contracts/Revert.sol/struct.AbortContext.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# AbortContext
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/main/v2/contracts/Revert.sol)

Struct containing abort context passed to onAbort.


```solidity
struct AbortContext {
bytes sender;
address asset;
uint256 amount;
bool outgoing;
uint256 chainID;
bytes revertMessage;
}
```

**Properties**

|Name|Type|Description|
|----|----|-----------|
|`sender`|`bytes`|Address of account that initiated smart contract call. bytes is used as the crosschain transaction can be initiated from a non-EVM chain.|
|`asset`|`address`|Address of asset. On a connected chain, it contains the fungible token address or is empty if it's a gas token. On ZetaChain, it contains the address of the ZRC20.|
|`amount`|`uint256`|Amount specified with the transaction.|
|`outgoing`|`bool`|Flag to indicate if the crosschain transaction was outgoing: from ZetaChain to connected chain. if false, the transaction was incoming: from connected chain to ZetaChain.|
|`chainID`|`uint256`|Chain ID of the connected chain.|
|`revertMessage`|`bytes`|Arbitrary data specified in the RevertOptions object when initating the crosschain transaction.|

12 changes: 7 additions & 5 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ title: "Protocol contracts"

Contracts of official protocol contracts deployed by the core ZetaChain team.

### Learn more about ZetaChain
## Learn more about ZetaChain

* Check our [website](https://www.zetachain.com/).
* Read our [docs](https://docs.zetachain.com/).

### Codebase
## Codebase

The protocol contracts V2 codebase is separated into two sections:
The protocol contracts codebase is separated into two sections:

- `zevm`: contracts deployed on ZetaChain
- `evm`: contracts deployed on EVM connected chains (Ethereum, Base, etc..)
Expand All @@ -35,7 +35,7 @@ The protocol contracts V2 codebase is separated into two sections:

[Learn more about the Gateway contracts](https://www.zetachain.com/docs/developers/evm/gateway/)

### Usage
## Usage

**Install dependencies**

Expand Down Expand Up @@ -72,7 +72,7 @@ To view detailed instructions on how to deploy the contracts, please refer to th

This guide covers all steps required to deploy the contracts, including environment setup, commands, and best practices.

### Community
## Community

[X](https://x.com/zetablockchain) | [Discord](https://discord.com/invite/zetachain) | [Telegram](https://t.me/zetachainofficial) | [Website](https://zetachain.com)# Summary
- [Home](README.md)
Expand Down Expand Up @@ -137,4 +137,6 @@ This guide covers all steps required to deploy the contracts, including environm
- [INotSupportedMethods](protocol/contracts/Errors.sol/interface.INotSupportedMethods.md)
- [RevertOptions](protocol/contracts/Revert.sol/struct.RevertOptions.md)
- [RevertContext](protocol/contracts/Revert.sol/struct.RevertContext.md)
- [AbortContext](protocol/contracts/Revert.sol/struct.AbortContext.md)
- [Revertable](protocol/contracts/Revert.sol/interface.Revertable.md)
- [Abortable](protocol/contracts/Revert.sol/interface.Abortable.md)
Loading
Loading