Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Should a contract be able to specify when it is considered completed? #595

Open
jeromesimeon opened this issue Mar 29, 2019 · 1 comment
Labels
1.0-feature 1.0 Type: Question ❓ Further information is requested

Comments

@jeromesimeon
Copy link
Member

jeromesimeon commented Mar 29, 2019

Currently, there is no way to execute logic at contract termination (or even to indicate what conditions should be met for termination).

While this could be encoded in the logic of the contract itself (with e.g., a state field indicating that the contract is in TERMINATED state), it might be useful to provide a first-class clause for this.

This could look as follows:

contract MyAgreement over MyVariables {
  clause init() { // initialization?
      set state MyState { ... }
  }

  clause purchase(request:Purchase) : PurchaseResponse {
    ...
  }
  clause payment(request:Payment) : PaymentResponse {
    ...
  }

  clause packageReceived(request:DeliveryRequest) : Response {
     terminate()
  } 

  clause terminate() : TerminatedResponse { // finalize? shutdown? completion?
     enforce state.status = "BREACHED" and isAfter(now(), "01/01/2020");
     return TerminatedResponse{}
  }

  clause terminate() : TerminatedResponse { // finalize? shutdown? completion?
     throw ("You can never");
  }

  clause terminate() : TerminatedResponse { // finalize? shutdown? completion?
     return TerminatedResponse{}
  }

 clause terminate(why:String) : TerminatedResponse { // finalize? shutdown? completion?
     return TerminatedResponse{ message: why }
  }
}

Note that after the terminate clause of the contract has been clause, the contract will not accept requests anymore.

@jeromesimeon jeromesimeon added the Type: Question ❓ Further information is requested label Mar 29, 2019
@jeromesimeon
Copy link
Member Author

From @mttrbrts Maybe completed is a better terminology than terminated

@jeromesimeon jeromesimeon changed the title Should contract include a terminate clause in the style of the init clause Should a contract be able to specify when and how a it is considered completed? Apr 10, 2019
@jeromesimeon jeromesimeon changed the title Should a contract be able to specify when and how a it is considered completed? Should a contract be able to specify when it is considered completed? Jun 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1.0-feature 1.0 Type: Question ❓ Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant