UpdateTokenCommand是我要在AbstractTokenContract中添加的那个
override fun dispatchOnCommand(commands: List<CommandWithParties<TokenCommand>>, inputs: List<IndexedState<WalletState>>, outputs: List<IndexedState<WalletState>>, attachments: List<Attachment>) {
super.dispatchOnCommand(commands, inputs, outputs, attachments)
when (commands.first().value) {
// Issuances should only contain one issue command.
is IssueTokenCommand -> verifyIssue(commands.single(), inputs, outputs, attachments)
// Moves may contain more than one move command.
is MoveTokenCommand -> verifyMove(commands, inputs, outputs, attachments)
// Redeems must only contain one redeem command.
is RedeemTokenCommand -> verifyRedeem(commands.single(), inputs, outputs, attachments)
// Transfer Command
is UpdateTokenCommand -> verifyUpdate(commands.single(), inputs, outputs, attachments)
}
}
要注意的是,此合同示例中的IOUState实际上是如何查看命令类型的,以确定合同将如何验证该资产上的交易。
override fun verify(tx: LedgerTransaction) {
val command = tx.commands.requireSingleCommand<IOUContract.Commands>()
when (command.value) {
is Commands.Issue -> requireThat {