mirror of
https://github.com/corda/corda.git
synced 2025-04-16 07:27:17 +00:00
Updates tutorial to match template changes. (#4201)
This commit is contained in:
parent
611ca53cf7
commit
99f6cc9e65
@ -8,7 +8,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TemplateContract implements Contract {
|
||||
// This is used to identify our contract when building a transaction.
|
||||
public static final String TEMPLATE_CONTRACT_ID = "com.template.TemplateContract";
|
||||
public static final String ID = "com.template.TemplateContract";
|
||||
|
||||
/**
|
||||
* A transaction is considered valid if the verify() function of the contract of each of the transaction's input
|
||||
|
@ -13,8 +13,6 @@ import net.corda.core.transactions.SignedTransaction;
|
||||
import net.corda.core.transactions.TransactionBuilder;
|
||||
import net.corda.core.utilities.ProgressTracker;
|
||||
|
||||
import static com.template.TemplateContract.TEMPLATE_CONTRACT_ID;
|
||||
|
||||
// Replace Initiator's definition with:
|
||||
@InitiatingFlow
|
||||
@StartableByRPC
|
||||
@ -53,7 +51,7 @@ public class IOUFlow extends FlowLogic<Void> {
|
||||
|
||||
// We create a transaction builder and add the components.
|
||||
TransactionBuilder txBuilder = new TransactionBuilder(notary)
|
||||
.addOutputState(outputState, TEMPLATE_CONTRACT_ID)
|
||||
.addOutputState(outputState, TemplateContract.ID)
|
||||
.addCommand(cmd);
|
||||
|
||||
// Signing the transaction.
|
||||
|
@ -18,7 +18,7 @@ import static net.corda.core.contracts.ContractsDSL.requireThat;
|
||||
|
||||
// Replace TemplateContract's definition with:
|
||||
public class IOUContract implements Contract {
|
||||
public static final String IOU_CONTRACT_ID = "com.template.IOUContract";
|
||||
public static final String ID = "com.template.IOUContract";
|
||||
|
||||
// Our Create command.
|
||||
public static class Create implements CommandData {
|
||||
|
@ -52,7 +52,7 @@ public class IOUFlow extends FlowLogic<Void> {
|
||||
|
||||
// We create the transaction components.
|
||||
IOUState outputState = new IOUState(iouValue, getOurIdentity(), otherParty);
|
||||
StateAndContract outputContractAndState = new StateAndContract(outputState, IOUContract.IOU_CONTRACT_ID);
|
||||
StateAndContract outputContractAndState = new StateAndContract(outputState, IOUContract.ID);
|
||||
List<PublicKey> requiredSigners = ImmutableList.of(getOurIdentity().getOwningKey(), otherParty.getOwningKey());
|
||||
Command cmd = new Command<>(new IOUContract.Create(), requiredSigners);
|
||||
|
||||
|
@ -16,8 +16,6 @@ import net.corda.core.identity.Party
|
||||
import net.corda.core.transactions.TransactionBuilder
|
||||
import net.corda.core.utilities.ProgressTracker
|
||||
|
||||
import com.template.TemplateContract.TEMPLATE_CONTRACT_ID
|
||||
|
||||
// Replace Initiator's definition with:
|
||||
@InitiatingFlow
|
||||
@StartableByRPC
|
||||
@ -39,7 +37,7 @@ class IOUFlow(val iouValue: Int,
|
||||
|
||||
// We create a transaction builder and add the components.
|
||||
val txBuilder = TransactionBuilder(notary = notary)
|
||||
.addOutputState(outputState, TEMPLATE_CONTRACT_ID)
|
||||
.addOutputState(outputState, TemplateContract.ID)
|
||||
.addCommand(cmd)
|
||||
|
||||
// We sign the transaction.
|
||||
|
@ -8,10 +8,11 @@ import net.corda.core.transactions.LedgerTransaction
|
||||
// Add these imports:
|
||||
import net.corda.core.contracts.*
|
||||
|
||||
// Replace IOUContract's contract ID and definition with:
|
||||
const val IOU_CONTRACT_ID = "com.template.IOUContract"
|
||||
|
||||
class IOUContract : Contract {
|
||||
companion object {
|
||||
const val ID = "com.template.IOUContract"
|
||||
}
|
||||
|
||||
// Our Create command.
|
||||
class Create : CommandData
|
||||
|
||||
|
@ -36,7 +36,7 @@ class IOUFlow(val iouValue: Int,
|
||||
|
||||
// We create the transaction components.
|
||||
val outputState = IOUState(iouValue, ourIdentity, otherParty)
|
||||
val outputContractAndState = StateAndContract(outputState, IOU_CONTRACT_ID)
|
||||
val outputContractAndState = StateAndContract(outputState, IOUContract.ID)
|
||||
val cmd = Command(IOUContract.Create(), listOf(ourIdentity.owningKey, otherParty.owningKey))
|
||||
|
||||
// We add the items to the builder.
|
||||
|
Loading…
x
Reference in New Issue
Block a user