# WIP: Report of Celeste and Gardens interaction
[ConvictionVoting](https://github.com/1Hive/conviction-voting-app/blob/master/contracts/ConvictionVoting.sol#L13) contract inherit from [DisputableAragonApp](https://github.com/aragon/aragonOS/blob/4bbe3e96fc5a3aa6340b11ec67e6550029da7af9/contracts/apps/disputable/DisputableAragonApp.sol#L14) and have in additional the function [_addProposal()](https://github.com/1Hive/conviction-voting-app/blob/master/contracts/ConvictionVoting.sol#L581), when that is called will create one disputable action and register although their parent function [_registerDisputableAction()](https://github.com/aragon/aragonOS/blob/4bbe3e96fc5a3aa6340b11ec67e6550029da7af9/contracts/apps/disputable/DisputableAragonApp.sol#L139)
```solidity=
function _addProposal(string _title, bytes _link, uint256 _requestedAmount, bool _stableRequestAmount, address _beneficiary)
internal notPaused
{
uint256 agreementActionId = _registerDisputableAction(proposalCounter, _link, msg.sender);
--- snip ---
```
The **_registerDisputableAction()** function detailed
```solidity=
function _registerDisputableAction(uint256 _disputableActionId, bytes _context, address _submitter) internal returns (uint256) {
IAgreement agreement = _ensureAgreement();
return agreement.newAction(_disputableActionId, _context, _submitter);
}
```
Creating a Action in the [Agreement App](https://github.com/1Hive/agreement-app) using the [newAction()](https://github.com/1Hive/agreement-app/blob/master/contracts/Agreement.sol#L329) function where create the reference of **DisputableAragonApp** which is stored together with [currentSettingId](https://github.com/1Hive/agreement-app/blob/master/contracts/Agreement.sol#L354) in list actions to be used later on.
```solidity=
function newAction(uint256 _disputableActionId, bytes _context, address _submitter) external returns (uint256) {
--- snip ---
uint256 currentSettingId = _getCurrentSettingId();
--- snip ---
Action storage action = actions[id];
--- snip ---
// Pay action submission fees
Setting storage setting = _getSetting(currentSettingId);
DisputableAragonApp disputable = DisputableAragonApp(msg.sender);
_payAppFees(setting, disputable, _submitter, id);
--- snip ---
action.disputable = disputable;
action.settingId = currentSettingId;
--- snip ---
}
```
The **currentSettingId** represent a struct called [Settings](https://github.com/1Hive/agreement-app/blob/master/contracts/Agreement.sol#L92) that contain the [IArbitrator](https://github.com/1Hive/celeste-contracts/blob/master/contracts/court/Celeste.sol#L11) reference in that case Celeste contract.
```solidity=
struct Setting {
IArbitrator arbitrator;
IAragonAppFeesCashier aragonAppFeesCashier; // Fees cashier to deposit action fees (linked to the selected arbitrator)
string title;
bytes content;
}
```
When [disputeAction()](https://github.com/1Hive/agreement-app/blob/master/contracts/Agreement.sol#L460) function is called the [_createDispute()](https://github.com/1Hive/agreement-app/blob/master/contracts/Agreement.sol#L1022) also is called and start the creation of dispute calling the **IArbitrator.createDispute()** in that case Celeste contract.
```solidity=
function disputeAction(uint256 _actionId, bool _submitterFinishedEvidence) external {
(Action storage action, Challenge storage challenge, uint256 challengeId) = _getChallengedAction(_actionId);
--- snip ---
// Retrieve the Arbitrator defined in the action.currentSettingId
IArbitrator arbitrator = _getArbitratorFor(action);
bytes memory metadata = abi.encodePacked(appId(), action.lastChallengeId);
uint256 disputeId = _createDispute(action, challenge, arbitrator, metadata);
--- snip ---
```
```solidity=
function _createDispute(Action storage _action, Challenge storage _challenge, IArbitrator _arbitrator, bytes memory _metadata)
internal
returns (uint256)
{
// Pull arbitration fees from submitter
(address disputeFeeRecipient, ERC20 feeToken, uint256 feeAmount) = _arbitrator.getDisputeFees();
_challenge.submitterArbitratorFees.token = feeToken;
_challenge.submitterArbitratorFees.amount = feeAmount;
address submitter = _action.submitter;
_depositFrom(feeToken, submitter, feeAmount);
// Create dispute. The arbitrator should pull its arbitration fees (if any) from this Agreement on `createDispute()`.
_approveFor(feeToken, disputeFeeRecipient, feeAmount);
uint256 disputeId = _arbitrator.createDispute(DISPUTES_POSSIBLE_OUTCOMES, _metadata);
--- snip ---
```
# Part 2
The `_arbitrator.createDispute()` call the [Celeste.createDispute()](https://github.com/1Hive/celeste-contracts/blob/927d780dbf5cbf6a52074db19293fd3162135087/contracts/court/Celeste.sol#L88)
```solidity=
function createDispute(uint256 _possibleRulings, bytes calldata _metadata) external returns (uint256) {
IArbitrable subject = IArbitrable(msg.sender);
IDisputeManager disputeManager = IDisputeManager(_getDisputeManager());
return disputeManager.createDispute(subject, _possibleRulings.toUint8(), _metadata);
}
```
That following calling the **createDispute** from module [DisputeManager](https://github.com/1Hive/celeste-contracts/blob/master/contracts/disputes/DisputeManager.sol#L19) configured in the **Controller** (**Celeste** is Controller)
Note the ***subject*** variable of type [IArbitrable](https://github.com/1Hive/celeste-contracts/blob/master/contracts/arbitration/IArbitrable.sol#L6) is also the [Agreement App](https://github.com/1Hive/agreement-app) used to start the creation of the dispute.
# Part 3
In the end of [disputeAction()](https://github.com/1Hive/agreement-app/blob/master/contracts/Agreement.sol#L484) **ActionDisputed** event [is emitted](https://github.com/1Hive/agreement-app/blob/master/contracts/Agreement.sol#L484)
```solidity=
--- snip ---
emit ActionDisputed(_actionId, challengeId);
```
The event is captured by [Gardens Subgraph](https://api.thegraph.com/subgraphs/name/1hive/gardens-xdai/graphql?query=%7B%0A++proposals%7B%0A++++id%0A++%7D%0A%7D) and the Gardens UI subscribe for modifications on **Proposals entity**
# References
- [DisputeManager docs](https://github.com/1Hive/celeste-contracts/blob/master/docs/4-entry-points/3-dispute-manager.md)
- The DisputeManager module is in charge of handling all the disputes-related behavior. This is where disputes are created and appealed. It is also in charge of computing the final ruling for each dispute, and to settle the rewards and penalties of all the parties involved in the dispute.
- [IArbitrable](https://github.com/1Hive/celeste-contracts/blob/master/contracts/arbitration/IArbitrable.sol)
- [IArbitrator](https://github.com/1Hive/celeste-contracts/blob/master/contracts/arbitration/IArbitrator.sol)
# Conclusions
- How the dispute is resolved?
-
- The [Resolve function](https://github.com/1Hive/agreement-app/blob/master/contracts/Agreement.sol#L537) its called
- How the Arbitrator sends the result of the dispute to the Gardens?
-