You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+24-10Lines changed: 24 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,32 +8,46 @@ This is a solidity implementation of [Cross Framework](https://github.com/datach
8
8
Currently, it provides the following features:
9
9
- the registry feature that allows developers to register their contracts
10
10
- the coordinator feature of the simple commit protocol
11
-
- the participant feature of the simple commit protocol
11
+
- the participant feature
12
12
- it's implemented on top of [yui-ibc-solidity](https://github.com/hyperledger-labs/yui-ibc-solidity)
13
13
14
-
The two-phase commit will be provided in the future.
14
+
The coordinator feature of the two-phase commit will be provided in the future.
15
15
16
16
## Demo
17
17
18
18
For an ERC20 atomic swap demo, please refer to [ethereum-cross-demo](https://github.com/datachainlab/ethereum-cross-demo)
19
19
20
20
## Contract module development
21
21
22
-
A developer who develops contract using Cross Framework need to implement IContractModule, which is defined in [IContractModule.sol](./src/core/IContractModule.sol).
23
-
24
-
```
25
22
// IContractModule defines the expected interface of a contract module on Cross Framework
23
+
```solidity
26
24
interface IContractModule {
27
-
// onContractCall is a callback function that is called at the commit(simple-commit) phase
// onCommit is a callback function that is called at the commit(2pc) phase
35
+
// It is expected that it commits the changes in the contract module
36
+
// IMPORTANT: This function MUST NOT revert.
37
+
function onCommit(CrossContext calldata context) external;
38
+
39
+
// onAbort is a callback function that is called at the commit(2pc) phase
40
+
// It is expected that it aborts the changes in the contract module
41
+
// IMPORTANT: This function MUST NOT revert.
42
+
function onAbort(CrossContext calldata context) external;
29
43
}
30
44
```
31
45
32
-
-Currently, only one function `onContractCall` is defined, which implements the process of a transaction called via the cross-chain transaction.
46
+
-For the current simple-commit coordinator flow, the coordinator-side participant (A) uses `onContractPrepare` to execute and lock state changes, and later finalizes them with `onCommit` or `onAbort` based on the acknowledgement from the counterparty.
33
47
34
-
- The return value of `onContractCall` is emitted as an Event `OnContractCall` with the transaction info.
48
+
- The counterparty participant (B) executes the incoming call and finalizes immediately via `onContractCommitImmediately`.
35
49
36
-
-If it gets an unexpected call, the developer need to perform `revert` in the contract. This will request the coordinator to abort the transaction.
50
+
-IMPORTANT: `onCommit` and `onAbort` MUST NOT revert.
0 commit comments