Skip to content
This repository has been archived by the owner on Dec 13, 2019. It is now read-only.

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
snario committed Nov 29, 2018
1 parent 5a1fe09 commit eb57b4e
Show file tree
Hide file tree
Showing 60 changed files with 3,564 additions and 2,581 deletions.
551 changes: 0 additions & 551 deletions packages/contracts/contracts/AppInstance.sol

This file was deleted.

22 changes: 22 additions & 0 deletions packages/contracts/contracts/AppRegistry.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
pragma solidity ^0.4.25;
pragma experimental "ABIEncoderV2";

import "./mixins/MixinAppRegistryCore.sol";
import "./mixins/MixinCancelChallenge.sol";
import "./mixins/MixinSetResolution.sol";
import "./mixins/MixinSetState.sol";
import "./mixins/MixinSetStateWithAction.sol";


/// @dev Base contract implmenting all logic needed for full-featured App registry
contract AppRegistry is
MixinAppRegistryCore,
MixinSetState,
MixinSetStateWithAction,
MixinCancelChallenge,
MixinSetResolution
{
constructor ()
public
{}
}
32 changes: 32 additions & 0 deletions packages/contracts/contracts/ConditionalTransaction.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
pragma solidity 0.4.25;
pragma experimental "ABIEncoderV2";

import "./libs/Transfer.sol";
import "./libs/LibCondition.sol";

import "./ContractRegistry.sol";
import "./NonceRegistry.sol";


/// @title ConditionalTransaction - A conditional transfer contract
/// @author Liam Horne - <[email protected]>
/// @author Mitchell Van Der Hoeff - <[email protected]>
/// @notice Supports a complex transfer of funds contingent on some condition.
contract ConditionalTransaction is LibCondition {

using Transfer for Transfer.Transaction;

function executeSimpleConditionalTransaction(
Condition condition,
Transfer.Transaction memory txn
)
public
{
require(
isSatisfied(condition),
"Condition was not satisfied for conditional transaction"
);
txn.execute();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ pragma solidity 0.4.25;
import "openzeppelin-eth/contracts/utils/Address.sol";


/// @title Registry - A global Ethereum deterministic address translator
/// @title ContractRegistry - A global Ethereum deterministic address translator
/// @author Liam Horne - <[email protected]>
/// @notice Supports deployment of contract initcode with the ability to deterministically reference the address before the actual contract is deployed regardless of msg.sender or transaction nonce
/// @dev Will be obsolete for most use cases when CREATE2 is added to the EVM https://github.com/ethereum/EIPs/pull/1014
contract Registry {
contract ContractRegistry {

using Address for address;

Expand Down Expand Up @@ -62,7 +62,7 @@ contract Registry {
/// @param ptr A counterfactual address
/// @param data The data being sent in the call to the counterfactual contract
function proxyCall(address registry, bytes32 ptr, bytes data) public {
address to = Registry(registry).resolver(ptr);
address to = ContractRegistry(registry).resolver(ptr);
require(to != address(0), "Resolved to a 0x0 address");
require(to.isContract(), "Tried to call function on a non-contract");
require(to.call(data), "Registry.proxyCall failed.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,55 +1,49 @@
pragma solidity 0.4.25;
pragma experimental "ABIEncoderV2";

import "../lib/Transfer.sol";
import "../Conditional.sol";
import "../Registry.sol";
import "../NonceRegistry.sol";
import "../AppInstance.sol";
import "./libs/Transfer.sol";
import "./libs/LibCondition.sol";

import "./ContractRegistry.sol";
import "./NonceRegistry.sol";
import "./AppRegistry.sol";


/// @title ConditionalTransaction - A conditional transfer contract
/// @author Liam Horne - <[email protected]>
/// @author Mitchell Van Der Hoeff - <[email protected]>
/// @notice Supports a complex transfer of funds contingent on some condition.
contract ConditionalTransaction is Conditional {
contract StateChannelTransaction is LibCondition {

using Transfer for Transfer.Transaction;

function executeSimpleConditionalTransaction(
Condition condition,
Transfer.Transaction memory txn
)
public
{
require(
Conditional.isSatisfied(condition),
"Condition was not satisfied for conditional transaction"
);
txn.execute();
}

/// @notice Execute a fund transfer for a state channel app in a finalized state
/// @param uninstallKey The key in the nonce registry
/// @param appCfAddress Counterfactual address of the app contract
/// @param terms The pre-agreed upon terms of the funds transfer
function executeAppConditionalTransaction(
address registry,
address nonceRegistry,
address appRegistryAddress,
address nonceRegistryAddress,
bytes32 uninstallKey,
bytes32 appCfAddress,
Transfer.Terms terms
)
public
{
NonceRegistry nonceRegistry = NonceRegistry(nonceRegistryAddress);
AppRegistry appRegistry = AppRegistry(appRegistryAddress);

require(
!NonceRegistry(nonceRegistry).isFinalized(uninstallKey, 1),
!nonceRegistry.isFinalized(uninstallKey, 1),
"App has been uninstalled"
);

address appAddr = Registry(registry).resolver(appCfAddress);
AppInstance app = AppInstance(appAddr);
Transfer.Transaction memory txn = app.getResolution();
// require(
// appRegistry.isFinalized(appCfAddress),
// "App is not in an OFF state yet"
// );

Transfer.Transaction memory txn = appRegistry.getResolution(appCfAddress);

require(
Transfer.meetsTerms(txn, terms),
Expand All @@ -59,4 +53,5 @@ contract ConditionalTransaction is Conditional {
txn.execute();
}


}
126 changes: 0 additions & 126 deletions packages/contracts/contracts/appDefinitions/CommitRevealApp.sol

This file was deleted.

98 changes: 0 additions & 98 deletions packages/contracts/contracts/appDefinitions/CountingApp.sol

This file was deleted.

Loading

0 comments on commit eb57b4e

Please sign in to comment.