Skip to content

Commit 024675e

Browse files
committed
feat: enhance receiveApproval function with order matching capabilities and detailed documentation
1 parent f21473b commit 024675e

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

docs/solidity/index.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,33 @@ function recover() external returns (uint256)
247247
### receiveApproval
248248

249249
```solidity
250-
function receiveApproval(address sender, uint256 amount, address token, bytes) external returns (bool)
250+
function receiveApproval(address sender, uint256 amount, address token, bytes data) external returns (bool)
251251
```
252252

253+
Receives approval and optionally matches orders in one transaction
254+
255+
Usage patterns:
256+
1. Simple deposit: RLC.approveAndCall(escrow, amount, "")
257+
2. Deposit + match: RLC.approveAndCall(escrow, amount, encodedOrders)
258+
259+
The `data` parameter should be ABI-encoded orders if matching is desired:
260+
abi.encode(appOrder, datasetOrder, workerpoolOrder, requestOrder)
261+
262+
#### Parameters
263+
264+
| Name | Type | Description |
265+
| ---- | ---- | ----------- |
266+
| sender | address | The address that approved tokens (must be requester if matching) |
267+
| amount | uint256 | Amount of tokens approved and to be deposited |
268+
| token | address | Address of the token (must be RLC) |
269+
| data | bytes | Optional: ABI-encoded orders for matching |
270+
271+
#### Return Values
272+
273+
| Name | Type | Description |
274+
| ---- | ---- | ----------- |
275+
| [0] | bool | success True if operation succeeded @custom:example ```solidity // Encode orders bytes memory data = abi.encode(appOrder, datasetOrder, workerpoolOrder, requestOrder); // One transaction does it all RLC(token).approveAndCall(iexecProxy, dealCost, data); ``` |
276+
253277
## IexecOrderManagementFacet
254278

255279
### manageAppOrder
@@ -343,6 +367,11 @@ function matchOrders(struct IexecLibOrders_v5.AppOrder _apporder, struct IexecLi
343367

344368
Match orders. The requester gets debited.
345369

370+
This function does not use `msg.sender` to determine who pays for the deal.
371+
The sponsor is always set to `_requestorder.requester`, regardless of who calls this function.
372+
This design allows the function to be safely called via delegatecall from other facets
373+
(e.g., IexecEscrowTokenFacet.receiveApproval) without security concerns.
374+
346375
#### Parameters
347376

348377
| Name | Type | Description |

0 commit comments

Comments
 (0)