Skip to content

Commit

Permalink
Merge pull request #1 from onix-labs/1.0.0
Browse files Browse the repository at this point in the history
1.0.0
  • Loading branch information
MrMatthewLayton authored Feb 8, 2021
2 parents 0f198e0 + 04a2b9f commit ff0ca6a
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 3 deletions.
11 changes: 8 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,20 @@ buildscript {
junit_version = '5.3.1'

onixlabs_group = 'io.onixlabs'
onixlabs_corda_core_release_version = '1.0.0-rc5'
onixlabs_corda_core_release_version = '1.0.0'

cordapp_platform_version = 8
cordapp_signing_enabled = true
cordapp_contract_name = 'ONIXLabs Corda Identity Framework Contract'
cordapp_workflow_name = 'ONIXLabs Corda Identity Framework Workflow'
cordapp_vendor_name = 'ONIXLabs'
cordapp_license = 'Apache License, Version 2.0'
cordapp_version_id = 1

cordapp_signing_enabled = true
cordapp_signing_alias = 'cordapp-signer'
cordapp_signing_storetype = 'PKCS12'
cordapp_signing_keystore = getProperty('jar.sign.keystore')
cordapp_signing_password = getProperty('jar.sign.password')
}

repositories {
Expand All @@ -40,7 +45,7 @@ buildscript {
}

group 'io.onixlabs'
version '1.0.0-rc7'
version '1.0.0'

subprojects {
repositories {
Expand Down
7 changes: 7 additions & 0 deletions onixlabs-corda-identity-framework-contract/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ cordapp {
}
signing {
enabled = cordapp_signing_enabled
options {
keystore cordapp_signing_keystore
alias cordapp_signing_alias
storepass cordapp_signing_password
keypass cordapp_signing_password
storetype cordapp_signing_storetype
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ open class CordaClaimContract : Contract {
internal const val CONTRACT_RULE_OUTPUTS =
"On claim issuing, only one claim state must be created."

internal const val CONTRACT_RULE_ISSUER_PARTICIPANT =
"On claim issuing, the issuer of the created claim state must be a participant."

internal const val CONTRACT_RULE_HOLDER_PARTICIPANT =
"On claim issuing, the holder of the created claim state must be a participant."

internal const val CONTRACT_RULE_SIGNERS =
"On claim issuing, the issuer must sign the transaction."
}
Expand All @@ -80,6 +86,12 @@ open class CordaClaimContract : Contract {
internal const val CONTRACT_RULE_OUTPUTS =
"On claim amending, only one claim state must be created."

internal const val CONTRACT_RULE_ISSUER_PARTICIPANT =
"On claim amending, the issuer of the created claim state must be a participant."

internal const val CONTRACT_RULE_HOLDER_PARTICIPANT =
"On claim amending, the holder of the created claim state must be a participant."

internal const val CONTRACT_RULE_STATE_REF =
"On claim amending, the created claim state must point to the consumed claim state."

Expand Down Expand Up @@ -143,6 +155,8 @@ open class CordaClaimContract : Contract {

val claimOutput = claimOutputs.single()

Issue.CONTRACT_RULE_ISSUER_PARTICIPANT using (claimOutput.issuer in claimOutput.participants)
Issue.CONTRACT_RULE_HOLDER_PARTICIPANT using (claimOutput.holder in claimOutput.participants)
Issue.CONTRACT_RULE_SIGNERS using (claimOutput.issuer.owningKey in signers)

onVerifyIssue(transaction, signers)
Expand All @@ -164,6 +178,8 @@ open class CordaClaimContract : Contract {
val claimInput = claimInputs.single()
val claimOutput = claimOutputs.single()

Amend.CONTRACT_RULE_ISSUER_PARTICIPANT using (claimOutput.issuer in claimOutput.participants)
Amend.CONTRACT_RULE_HOLDER_PARTICIPANT using (claimOutput.holder in claimOutput.participants)
Amend.CONTRACT_RULE_STATE_REF using (claimOutput.isPointingTo(claimInput))
Amend.CONTRACT_RULE_CHANGES using (claimOutput.internalImmutableEquals(claimInput.state.data))
Amend.CONTRACT_RULE_SIGNERS using (claimOutput.issuer.owningKey in signers)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@

package io.onixlabs.corda.identityframework.contract

import net.corda.core.contracts.BelongsToContract
import net.corda.core.contracts.StateRef
import net.corda.core.contracts.UniqueIdentifier
import net.corda.core.crypto.SecureHash
import net.corda.core.identity.AbstractParty
import net.corda.core.identity.CordaX500Name
import net.corda.testing.core.DUMMY_NOTARY_NAME
import net.corda.testing.core.TestIdentity
Expand All @@ -31,3 +34,19 @@ val CLAIM_1 = CordaClaim(IDENTITY_A.party, IDENTITY_B.party, "example", "Hello,
val CLAIM_2 = CordaClaim(IDENTITY_B.party, IDENTITY_B.party, "example", 123)

val EMPTY_REF = StateRef(SecureHash.zeroHash, 0)

@BelongsToContract(CordaClaimContract::class)
class CustomCordaClaim(
value: String = "Hello, World!",
previousStateRef: StateRef? = null,
override val participants: List<AbstractParty> = emptyList()
) : CordaClaim<String>(IDENTITY_A.party, IDENTITY_B.party, "example", value, UniqueIdentifier(), previousStateRef) {

override fun amend(previousStateRef: StateRef, value: String): CordaClaim<String> {
return CustomCordaClaim(value, previousStateRef)
}

fun withIssuerAndHolder() = CustomCordaClaim(participants = listOf(issuer, holder))
fun withoutIssuer() = CustomCordaClaim(participants = listOf(holder))
fun withoutHolder() = CustomCordaClaim(participants = listOf(issuer))
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,32 @@ class CordaClaimContractAmendCommandTests : ContractTest() {
}
}

@Test
fun `On claim amending, the issuer of the created claim state must be a participant`() {
services.ledger {
transaction {
val issuedClaim1 = issue(CustomCordaClaim().withIssuerAndHolder())
input(issuedClaim1.ref)
output(CordaClaimContract.ID, issuedClaim1.amend("Amended Value").withoutIssuer())
command(keysOf(IDENTITY_A), CordaClaimContract.Amend)
failsWith(CordaClaimContract.Amend.CONTRACT_RULE_ISSUER_PARTICIPANT)
}
}
}

@Test
fun `On claim amending, the holder of the created claim state must be a participant`() {
services.ledger {
transaction {
val issuedClaim1 = issue(CustomCordaClaim().withIssuerAndHolder())
input(issuedClaim1.ref)
output(CordaClaimContract.ID, issuedClaim1.amend("Amended Value").withoutHolder())
command(keysOf(IDENTITY_A), CordaClaimContract.Amend)
failsWith(CordaClaimContract.Amend.CONTRACT_RULE_HOLDER_PARTICIPANT)
}
}
}

@Test
fun `On claim amending, the created claim state must point to the consumed claim state`() {
services.ledger {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,28 @@ class CordaClaimContractIssueCommandTests : ContractTest() {
}
}

@Test
fun `On claim issuing, the issuer of the created claim state must be a participant`() {
services.ledger {
transaction {
output(CordaClaimContract.ID, CustomCordaClaim().withoutIssuer())
command(keysOf(IDENTITY_A), CordaClaimContract.Issue)
failsWith(CordaClaimContract.Issue.CONTRACT_RULE_ISSUER_PARTICIPANT)
}
}
}

@Test
fun `On claim issuing, the holder of the created claim state must be a participant`() {
services.ledger {
transaction {
output(CordaClaimContract.ID, CustomCordaClaim().withoutHolder())
command(keysOf(IDENTITY_A), CordaClaimContract.Issue)
failsWith(CordaClaimContract.Issue.CONTRACT_RULE_HOLDER_PARTICIPANT)
}
}
}

@Test
fun `On claim issuing, the issuer must sign the transaction`() {
services.ledger {
Expand Down
7 changes: 7 additions & 0 deletions onixlabs-corda-identity-framework-workflow/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ cordapp {
}
signing {
enabled = cordapp_signing_enabled
options {
keystore cordapp_signing_keystore
alias cordapp_signing_alias
storepass cordapp_signing_password
keypass cordapp_signing_password
storetype cordapp_signing_storetype
}
}
}

Expand Down

0 comments on commit ff0ca6a

Please sign in to comment.