This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For simplicity, batches will be sold in whole | |
private void verifySale(LedgerTransaction tx, CommandWithParties<DrugContract.DrugCommands> command) { | |
requireThat(require -> { | |
require.using("Drug sale should consume one input statet", | |
tx.getInputs().size() == 1); | |
require.using("Drug sale should have one output state", | |
tx.getOutputs().size() == 1); | |
Drug in = tx.inputsOfType(Drug.class).get(0); | |
Drug out = tx.outputsOfType(Drug.class).get(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void verify(@NotNull LedgerTransaction tx) throws IllegalArgumentException { | |
CommandWithParties<DrugCommands> command = requireSingleCommand(tx.getCommands(), DrugCommands.class); | |
DrugCommands commandType = command.getValue(); | |
if (commandType instanceof DrugCommands.IssueDrug) { | |
verifyIssuance(tx, command); | |
} else if (commandType instanceof DrugCommands.SellDrug) { | |
verifySale(tx, command); | |
} else { | |
throw new IllegalArgumentException("Command not recognized"); |