mirror of
https://github.com/corda/corda.git
synced 2025-01-18 02:39:51 +00:00
Rename PartyReference to PartyAndReference
This commit is contained in:
parent
2035a7ba54
commit
642b951bae
@ -34,7 +34,7 @@ class AnotherDummyContract : Contract, core.node.DummyContractBackdoor {
|
||||
// The "empty contract"
|
||||
override val legalContractReference: SecureHash = SecureHash.sha256("https://anotherdummy.org")
|
||||
|
||||
override fun generateInitial(owner: PartyReference, magicNumber: Int) : TransactionBuilder {
|
||||
override fun generateInitial(owner: PartyAndReference, magicNumber: Int) : TransactionBuilder {
|
||||
val state = State(magicNumber)
|
||||
return TransactionBuilder().withItems( state, Command(Commands.Create(), owner.party.owningKey) )
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package core.node
|
||||
|
||||
interface DummyContractBackdoor {
|
||||
fun generateInitial(owner: core.PartyReference, magicNumber: Int) : core.TransactionBuilder
|
||||
fun generateInitial(owner: core.PartyAndReference, magicNumber: Int) : core.TransactionBuilder
|
||||
|
||||
fun inspectState(state: core.ContractState) : Int
|
||||
}
|
@ -13,7 +13,7 @@ import java.time.*;
|
||||
public interface ICommercialPaperState extends ContractState {
|
||||
ICommercialPaperState withOwner(PublicKey newOwner);
|
||||
|
||||
ICommercialPaperState withIssuance(PartyReference newIssuance);
|
||||
ICommercialPaperState withIssuance(PartyAndReference newIssuance);
|
||||
|
||||
ICommercialPaperState withFaceValue(Amount newFaceValue);
|
||||
|
||||
|
@ -23,7 +23,7 @@ public class JavaCommercialPaper implements Contract {
|
||||
public static Contract JCP_PROGRAM_ID = new JavaCommercialPaper();
|
||||
|
||||
public static class State implements ContractState, ICommercialPaperState {
|
||||
private PartyReference issuance;
|
||||
private PartyAndReference issuance;
|
||||
private PublicKey owner;
|
||||
private Amount faceValue;
|
||||
private Instant maturityDate;
|
||||
@ -31,7 +31,7 @@ public class JavaCommercialPaper implements Contract {
|
||||
public State() {
|
||||
} // For serialization
|
||||
|
||||
public State(PartyReference issuance, PublicKey owner, Amount faceValue, Instant maturityDate) {
|
||||
public State(PartyAndReference issuance, PublicKey owner, Amount faceValue, Instant maturityDate) {
|
||||
this.issuance = issuance;
|
||||
this.owner = owner;
|
||||
this.faceValue = faceValue;
|
||||
@ -46,7 +46,7 @@ public class JavaCommercialPaper implements Contract {
|
||||
return new State(this.issuance, newOwner, this.faceValue, this.maturityDate);
|
||||
}
|
||||
|
||||
public ICommercialPaperState withIssuance(PartyReference newIssuance) {
|
||||
public ICommercialPaperState withIssuance(PartyAndReference newIssuance) {
|
||||
return new State(newIssuance, this.owner, this.faceValue, this.maturityDate);
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ public class JavaCommercialPaper implements Contract {
|
||||
return new State(this.issuance, this.owner, this.faceValue, newMaturityDate);
|
||||
}
|
||||
|
||||
public PartyReference getIssuance() {
|
||||
public PartyAndReference getIssuance() {
|
||||
return issuance;
|
||||
}
|
||||
|
||||
@ -215,7 +215,7 @@ public class JavaCommercialPaper implements Contract {
|
||||
return SecureHash.sha256("https://en.wikipedia.org/wiki/Commercial_paper");
|
||||
}
|
||||
|
||||
public TransactionBuilder generateIssue(@NotNull PartyReference issuance, @NotNull Amount faceValue, @Nullable Instant maturityDate) {
|
||||
public TransactionBuilder generateIssue(@NotNull PartyAndReference issuance, @NotNull Amount faceValue, @Nullable Instant maturityDate) {
|
||||
State state = new State(issuance, issuance.getParty().getOwningKey(), faceValue, maturityDate);
|
||||
return new TransactionBuilder().withItems(state, new Command(new Commands.Issue(), issuance.getParty().getOwningKey()));
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class Cash : Contract {
|
||||
/** A state representing a cash claim against some party */
|
||||
data class State(
|
||||
/** Where the underlying currency backing this ledger entry can be found (propagated) */
|
||||
val deposit: PartyReference,
|
||||
val deposit: PartyAndReference,
|
||||
|
||||
val amount: Amount,
|
||||
|
||||
@ -147,7 +147,7 @@ class Cash : Contract {
|
||||
/**
|
||||
* Puts together an issuance transaction for the specified amount that starts out being owned by the given pubkey.
|
||||
*/
|
||||
fun generateIssue(tx: TransactionBuilder, amount: Amount, at: PartyReference, owner: PublicKey) {
|
||||
fun generateIssue(tx: TransactionBuilder, amount: Amount, at: PartyAndReference, owner: PublicKey) {
|
||||
check(tx.inputStates().isEmpty())
|
||||
check(tx.outputStates().sumCashOrNull() == null)
|
||||
tx.addOutputState(Cash.State(at, amount, owner))
|
||||
|
@ -38,7 +38,7 @@ class CommercialPaper : Contract {
|
||||
override val legalContractReference: SecureHash = SecureHash.sha256("https://en.wikipedia.org/wiki/Commercial_paper")
|
||||
|
||||
data class State(
|
||||
val issuance: PartyReference,
|
||||
val issuance: PartyAndReference,
|
||||
override val owner: PublicKey,
|
||||
val faceValue: Amount,
|
||||
val maturityDate: Instant
|
||||
@ -52,7 +52,7 @@ class CommercialPaper : Contract {
|
||||
// Although kotlin is smart enough not to need these, as we are using the ICommercialPaperState, we need to declare them explicitly for use later,
|
||||
override fun withOwner(newOwner: PublicKey): ICommercialPaperState = copy(owner = newOwner)
|
||||
|
||||
override fun withIssuance(newIssuance: PartyReference): ICommercialPaperState = copy(issuance = newIssuance)
|
||||
override fun withIssuance(newIssuance: PartyAndReference): ICommercialPaperState = copy(issuance = newIssuance)
|
||||
override fun withFaceValue(newFaceValue: Amount): ICommercialPaperState = copy(faceValue = newFaceValue)
|
||||
override fun withMaturityDate(newMaturityDate: Instant): ICommercialPaperState = copy(maturityDate = newMaturityDate)
|
||||
}
|
||||
@ -129,7 +129,7 @@ class CommercialPaper : Contract {
|
||||
* an existing transaction because you aren't able to issue multiple pieces of CP in a single transaction
|
||||
* at the moment: this restriction is not fundamental and may be lifted later.
|
||||
*/
|
||||
fun generateIssue(issuance: PartyReference, faceValue: Amount, maturityDate: Instant): TransactionBuilder {
|
||||
fun generateIssue(issuance: PartyAndReference, faceValue: Amount, maturityDate: Instant): TransactionBuilder {
|
||||
val state = State(issuance, issuance.party.owningKey, faceValue, maturityDate)
|
||||
return TransactionBuilder().withItems(state, Command(Commands.Issue(), issuance.party.owningKey))
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ class CrowdFund : Contract {
|
||||
* Returns a transaction that registers a crowd-funding campaing, owned by the issuing institution's key. Does not update
|
||||
* an existing transaction because it's not possible to register multiple campaigns in a single transaction
|
||||
*/
|
||||
fun generateRegister(owner: PartyReference, fundingTarget: Amount, fundingName: String, closingTime: Instant): TransactionBuilder {
|
||||
fun generateRegister(owner: PartyAndReference, fundingTarget: Amount, fundingName: String, closingTime: Instant): TransactionBuilder {
|
||||
val campaign = Campaign(owner = owner.party.owningKey, name = fundingName, target = fundingTarget, closingTime = closingTime)
|
||||
val state = State(campaign)
|
||||
return TransactionBuilder().withItems(state, Command(Commands.Register(), owner.party.owningKey))
|
||||
|
@ -23,7 +23,7 @@ class DummyContract : Contract {
|
||||
// The "empty contract"
|
||||
override val legalContractReference: SecureHash = SecureHash.sha256("")
|
||||
|
||||
fun generateInitial(owner: PartyReference, magicNumber: Int) : TransactionBuilder {
|
||||
fun generateInitial(owner: PartyAndReference, magicNumber: Int) : TransactionBuilder {
|
||||
val state = State(magicNumber)
|
||||
return TransactionBuilder().withItems( state, Command(Commands.Create(), owner.party.owningKey) )
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ inline fun <reified T : ContractState> List<StateAndRef<ContractState>>.filterSt
|
||||
data class Party(val name: String, val owningKey: PublicKey) {
|
||||
override fun toString() = name
|
||||
|
||||
fun ref(bytes: OpaqueBytes) = PartyReference(this, bytes)
|
||||
fun ref(bytes: OpaqueBytes) = PartyAndReference(this, bytes)
|
||||
fun ref(vararg bytes: Byte) = ref(OpaqueBytes.of(*bytes))
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ data class Party(val name: String, val owningKey: PublicKey) {
|
||||
* Reference to something being stored or issued by a party e.g. in a vault or (more likely) on their normal
|
||||
* ledger. The reference is intended to be encrypted so it's meaningless to anyone other than the party.
|
||||
*/
|
||||
data class PartyReference(val party: Party, val reference: OpaqueBytes) {
|
||||
data class PartyAndReference(val party: Party, val reference: OpaqueBytes) {
|
||||
override fun toString() = "${party.name}$reference"
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ import kotlin.test.assertFailsWith
|
||||
import kotlin.test.assertNotNull
|
||||
|
||||
interface DummyContractBackdoor {
|
||||
fun generateInitial(owner: PartyReference, magicNumber: Int): TransactionBuilder
|
||||
fun generateInitial(owner: PartyAndReference, magicNumber: Int): TransactionBuilder
|
||||
fun inspectState(state: ContractState): Int
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user