mirror of
https://github.com/corda/corda.git
synced 2025-01-18 02:39:51 +00:00
legalContractRef changed String to SecureHash (of contract contents)
This commit is contained in:
parent
25a28a0a28
commit
fa32935e77
@ -29,7 +29,16 @@ class InsufficientBalanceException(val amountMissing: Amount) : Exception()
|
||||
* vaults can ignore the issuer/depositRefs and just examine the amount fields.
|
||||
*/
|
||||
object Cash : Contract {
|
||||
override val legalContractReference: String = "https://www.big-book-of-banking-law.gov/cash-claims.html"
|
||||
/**
|
||||
* TODO:
|
||||
* 1) hash should be of the contents, not the URI
|
||||
* 2) allow the content to be specified at time of instance creation?
|
||||
* Motivation: it's the difference between a state object referencing a programRef, which references a
|
||||
* legalContractReference and a state object which directly references both. The latter allows the legal wording
|
||||
* to evolve without requiring code changes. But creates a risk that users create objects governed by a program
|
||||
* that is inconsistent with the legal contract
|
||||
*/
|
||||
override val legalContractReference: SecureHash = SecureHash.sha256("https://www.big-book-of-banking-law.gov/cash-claims.html");
|
||||
|
||||
/** A state representing a cash claim against some institution */
|
||||
data class State(
|
||||
|
@ -23,7 +23,8 @@ val CP_PROGRAM_ID = SecureHash.sha256("replace-me-later-with-bytecode-hash")
|
||||
|
||||
// TODO: Generalise the notion of an owned instrument into a superclass/supercontract. Consider composition vs inheritance.
|
||||
object CommercialPaper : Contract {
|
||||
override val legalContractReference: String = "https://en.wikipedia.org/wiki/Commercial_paper"
|
||||
// TODO: should reference the content of the legal agreement, not its URI
|
||||
override val legalContractReference: SecureHash = SecureHash.sha256("https://en.wikipedia.org/wiki/Commercial_paper")
|
||||
|
||||
data class State(
|
||||
val issuance: InstitutionReference,
|
||||
|
@ -18,5 +18,6 @@ object DummyContract : Contract {
|
||||
// Always accepts.
|
||||
}
|
||||
|
||||
override val legalContractReference: String = "/dev/null"
|
||||
// The "empty contract"
|
||||
override val legalContractReference: SecureHash = SecureHash.sha256("")
|
||||
}
|
@ -118,7 +118,8 @@ public class JavaCommercialPaper implements Contract {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getLegalContractReference() {
|
||||
return "https://en.wikipedia.org/wiki/Commercial_paper";
|
||||
public SecureHash getLegalContractReference() {
|
||||
// TODO: Should return hash of the contract's contents, not its URI
|
||||
return SecureHash.Companion.sha256("https://en.wikipedia.org/wiki/Commercial_paper");
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,9 @@ interface Contract {
|
||||
*/
|
||||
fun verify(tx: TransactionForVerification)
|
||||
|
||||
// TODO: This should probably be a hash of a document, rather than a URL to it.
|
||||
/** Unparsed reference to the natural language contract that this code is supposed to express (usually a URL). */
|
||||
val legalContractReference: String
|
||||
/**
|
||||
* Unparsed reference to the natural language contract that this code is supposed to express (usually a hash of
|
||||
* the contract's contents).
|
||||
*/
|
||||
val legalContractReference: SecureHash
|
||||
}
|
Loading…
Reference in New Issue
Block a user