Skip to content

Commit

Permalink
feat(contracts): rename xfunc to xrecv (#401)
Browse files Browse the repository at this point in the history
Rename xfunc to xrecv

task: none
  • Loading branch information
kevinhalliday authored Feb 26, 2024
1 parent 7a73449 commit 089244e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@omni-network/contracts",
"version": "0.2.0-alpha.1",
"version": "0.2.0-alpha.2",
"license": "GPL-3.0-only",
"packageManager": "pnpm@8.14.0",
"repository": "https://github.com/omni-network/omni/contracts",
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/examples/PingPong.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ contract PingPong is XApp {
* @param times The pingpongs in the loop
* @param n The number of xcalls left to make
*/
function pingpong(uint64 times, uint64 n) external xfunc {
function pingpong(uint64 times, uint64 n) external xrecv {
require(isXCall(), "PingPong: not an omni xcall");

if (n == 0) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/pkg/XApp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ contract XApp {
XTypes.Msg internal xmsg;

/// @dev Read current xmsg into storage before execution, delete it afterwards
modifier xfunc() {
modifier xrecv() {
xmsg = omni.xmsg();
_;
delete xmsg;
Expand Down
16 changes: 8 additions & 8 deletions docs/site/docs/develop/xapp.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ contract XGreeter is XApp {
}
/// @dev Greet on this chain
/// The `xfunc` modifier reads the current xmsg into `xmsg` storage
function greet(string calldata greeting) external xfunc {
/// The `xrecv` modifier reads the current xmsg into `xmsg` storage
function greet(string calldata greeting) external xrecv {
require(isXCall(), "XGreeter: only xcall");
emit Greetings(xmsg.sender, xmsg.sourceChainId, greeting);
}
Expand Down Expand Up @@ -103,7 +103,7 @@ function xgreet(uint64 destChainId, address to, string calldata greeting) extern

<br />

### `xmsg`
### `xrecv`

When receiving an `xcall`, you can read its context via `omni.xmsg()`.

Expand All @@ -123,21 +123,21 @@ function greet(string calldata greeting) external {

<br />

For convenience, `XApp` defines the `xfunc` modifier. This modifier reads the current xmsg into storage, and deletes after its function's execution.
For convenience, `XApp` defines the `xrecv` modifier. This modifier reads the current xmsg into storage, and deletes after its function's execution.

```solidity
modifier xfunc() {
modifier xrecv() {
xmsg = omni.xmsg();
_;
delete xmsg;
}
```

It also visually marks a function as the target of an `xcall`. Though, the `xfunc` modifier is not required to receive an `xcall`. Using this modifier, we can simplify our `XGreeter` a bit further.
It also visually marks a function as the target of an `xcall`. Though, the `xrecv` modifier is not required to receive an `xcall`. Using this modifier, we can simplify our `XGreeter` a bit further.


```solidity
function greet(string calldata greeting) external xfunc {
function greet(string calldata greeting) external xrecv {
emit Greetings(xmsg.sender, xmsg.sourceChainId, greeting);
}
```
Expand Down Expand Up @@ -165,7 +165,7 @@ Note that not only does `isXCall` check with the portal that the current transac


```solidity
function greet(string calldata greeting) external xfunc {
function greet(string calldata greeting) external xrecv {
require(isXCall(), "XGreeter: only xcall");
emit Greetings(xmsg.sender, xmsg.sourceChainId, greeting);
}
Expand Down

0 comments on commit 089244e

Please sign in to comment.