All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.corda.contracts.testing.DummyLinearContract.kt Maven / Gradle / Ivy

package net.corda.contracts.testing

import net.corda.core.contracts.*
import net.corda.core.contracts.clauses.Clause
import net.corda.core.contracts.clauses.FilterOn
import net.corda.core.contracts.clauses.verifyClause
import net.corda.core.crypto.CompositeKey
import net.corda.core.crypto.SecureHash
import net.corda.core.crypto.containsAny
import java.security.PublicKey

class DummyLinearContract : Contract {
    override val legalContractReference: SecureHash = SecureHash.sha256("Test")

    val clause: Clause = LinearState.ClauseVerifier()
    override fun verify(tx: TransactionForContract) = verifyClause(tx,
            FilterOn(clause, { states -> states.filterIsInstance() }),
            emptyList())

    data class State(
            override val linearId: UniqueIdentifier = UniqueIdentifier(),
            override val contract: Contract = DummyLinearContract(),
            override val participants: List = listOf(),
            val nonce: SecureHash = SecureHash.randomSHA256()) : LinearState {

        override fun isRelevant(ourKeys: Set): Boolean {
            return participants.any { it.containsAny(ourKeys) }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy