Skip to content

Commit a1c357b

Browse files
Split TransactionBuilder extensions into separate files for maintainability.
1 parent 18d956d commit a1c357b

File tree

4 files changed

+66
-66
lines changed

4 files changed

+66
-66
lines changed

onixlabs-corda-identity-framework-workflow/src/main/kotlin/io/onixlabs/corda/identityframework/workflow/Extensions.TransactionBuilder.Accounts.kt

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,46 @@ package io.onixlabs.corda.identityframework.workflow
1919
import io.onixlabs.corda.identityframework.contract.accounts.Account
2020
import io.onixlabs.corda.identityframework.contract.accounts.AccountContract
2121
import net.corda.core.contracts.StateAndRef
22+
import net.corda.core.transactions.TransactionBuilder
2223

2324
/**
2425
* Adds an account for issuance to a transaction builder, including the required command.
2526
*
26-
* @param state The account state to be created in the transaction.
27+
* @param account The account state to be created in the transaction.
2728
* @return Returns the current transaction builder.
2829
*/
29-
fun Builder.addIssuedAccount(state: Account): Builder = apply {
30-
addOutputState(state)
31-
addCommand(AccountContract.Issue, state.owner.owningKey)
30+
fun TransactionBuilder.addIssuedAccount(
31+
account: Account
32+
): TransactionBuilder = apply {
33+
addOutputState(account)
34+
addCommand(AccountContract.Issue, account.owner.owningKey)
3235
}
3336

3437
/**
3538
* Adds an account for amendment to a transaction builder, including the required command.
3639
*
37-
* @param oldState The old account state to be consumed in the transaction.
38-
* @param newState The new account state to be created in the transaction.
40+
* @param oldAccount The old account state to be consumed in the transaction.
41+
* @param newAccount The new account state to be created in the transaction.
3942
* @return Returns the current transaction builder.
4043
*/
41-
fun Builder.addAmendedAccount(oldState: StateAndRef<Account>, newState: Account): Builder = apply {
42-
addInputState(oldState)
43-
addOutputState(newState)
44-
addCommand(AccountContract.Amend, newState.owner.owningKey)
44+
fun TransactionBuilder.addAmendedAccount(
45+
oldAccount: StateAndRef<Account>,
46+
newAccount: Account
47+
): TransactionBuilder = apply {
48+
addInputState(oldAccount)
49+
addOutputState(newAccount)
50+
addCommand(AccountContract.Amend, newAccount.owner.owningKey)
4551
}
4652

4753
/**
4854
* Adds an account for revocation to a transaction builder, including the required command.
4955
*
50-
* @param state The account state to be consumed in the transaction.
56+
* @param account The account state to be consumed in the transaction.
5157
* @return Returns the current transaction builder.
5258
*/
53-
fun Builder.addRevokedAccount(state: StateAndRef<Account>): Builder = apply {
54-
addInputState(state)
55-
addCommand(AccountContract.Revoke, state.state.data.owner.owningKey)
59+
fun TransactionBuilder.addRevokedAccount(
60+
account: StateAndRef<Account>
61+
): TransactionBuilder = apply {
62+
addInputState(account)
63+
addCommand(AccountContract.Revoke, account.state.data.owner.owningKey)
5664
}

onixlabs-corda-identity-framework-workflow/src/main/kotlin/io/onixlabs/corda/identityframework/workflow/Extensions.TransactionBuilder.Attestations.kt

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,46 @@ package io.onixlabs.corda.identityframework.workflow
1919
import io.onixlabs.corda.identityframework.contract.attestations.Attestation
2020
import io.onixlabs.corda.identityframework.contract.attestations.AttestationContract
2121
import net.corda.core.contracts.StateAndRef
22+
import net.corda.core.transactions.TransactionBuilder
2223

2324
/**
2425
* Adds an attestation for issuance to a transaction builder, including the required command.
2526
*
26-
* @param state The attestation state to be created in the transaction.
27+
* @param attestation The attestation state to be created in the transaction.
2728
* @return Returns the current transaction builder.
2829
*/
29-
fun Builder.addIssuedAttestation(state: Attestation<*>): Builder = apply {
30-
addOutputState(state)
31-
addCommand(AttestationContract.Issue, state.attestor.owningKey)
30+
fun TransactionBuilder.addIssuedAttestation(
31+
attestation: Attestation<*>
32+
): TransactionBuilder = apply {
33+
addOutputState(attestation)
34+
addCommand(AttestationContract.Issue, attestation.attestor.owningKey)
3235
}
3336

3437
/**
3538
* Adds an attestation for amendment to a transaction builder, including the required command.
3639
*
37-
* @param oldState The old attestation state to be consumed in the transaction.
38-
* @param newState The new attestation state to be created in the transaction.
40+
* @param oldAttestation The old attestation state to be consumed in the transaction.
41+
* @param newAttestation The new attestation state to be created in the transaction.
3942
* @return Returns the current transaction builder.
4043
*/
41-
fun Builder.addAmendedAttestation(oldState: StateAndRef<Attestation<*>>, newState: Attestation<*>): Builder = apply {
42-
addInputState(oldState)
43-
addOutputState(newState)
44-
addCommand(AttestationContract.Amend, newState.attestor.owningKey)
44+
fun TransactionBuilder.addAmendedAttestation(
45+
oldAttestation: StateAndRef<Attestation<*>>,
46+
newAttestation: Attestation<*>
47+
): TransactionBuilder = apply {
48+
addInputState(oldAttestation)
49+
addOutputState(newAttestation)
50+
addCommand(AttestationContract.Amend, newAttestation.attestor.owningKey)
4551
}
4652

4753
/**
4854
* Adds an attestation for revocation to a transaction builder, including the required command.
4955
*
50-
* @param state The attestation state to be consumed in the transaction.
56+
* @param attestation The attestation state to be consumed in the transaction.
5157
* @return Returns the current transaction builder.
5258
*/
53-
fun Builder.addRevokedAttestation(state: StateAndRef<Attestation<*>>): Builder = apply {
54-
addInputState(state)
55-
addCommand(AttestationContract.Revoke, state.state.data.attestor.owningKey)
59+
fun TransactionBuilder.addRevokedAttestation(
60+
attestation: StateAndRef<Attestation<*>>
61+
): TransactionBuilder = apply {
62+
addInputState(attestation)
63+
addCommand(AttestationContract.Revoke, attestation.state.data.attestor.owningKey)
5664
}

onixlabs-corda-identity-framework-workflow/src/main/kotlin/io/onixlabs/corda/identityframework/workflow/Extensions.TransactionBuilder.Claims.kt

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,46 @@ package io.onixlabs.corda.identityframework.workflow
1919
import io.onixlabs.corda.identityframework.contract.claims.CordaClaim
2020
import io.onixlabs.corda.identityframework.contract.claims.CordaClaimContract
2121
import net.corda.core.contracts.StateAndRef
22+
import net.corda.core.transactions.TransactionBuilder
2223

2324
/**
2425
* Adds a claim for issuance to a transaction builder, including the required command.
2526
*
26-
* @param state The claim state to be created in the transaction.
27+
* @param claim The claim state to be created in the transaction.
2728
* @return Returns the current transaction builder.
2829
*/
29-
fun Builder.addIssuedClaim(state: CordaClaim<*>): Builder = apply {
30-
addOutputState(state)
31-
addCommand(CordaClaimContract.Issue, state.issuer.owningKey)
30+
fun TransactionBuilder.addIssuedClaim(
31+
claim: CordaClaim<*>
32+
): TransactionBuilder = apply {
33+
addOutputState(claim)
34+
addCommand(CordaClaimContract.Issue, claim.issuer.owningKey)
3235
}
3336

3437
/**
3538
* Adds a claim for amendment to a transaction builder, including the required command.
3639
*
37-
* @param oldState The old claim state to be consumed in the transaction.
38-
* @param newState The new claim state to be created in the transaction.
40+
* @param oldClaim The old claim state to be consumed in the transaction.
41+
* @param newClaim The new claim state to be created in the transaction.
3942
* @return Returns the current transaction builder.
4043
*/
41-
fun Builder.addAmendedClaim(oldState: StateAndRef<CordaClaim<*>>, newState: CordaClaim<*>): Builder = apply {
42-
addInputState(oldState)
43-
addOutputState(newState)
44-
addCommand(CordaClaimContract.Amend, newState.issuer.owningKey)
44+
fun TransactionBuilder.addAmendedClaim(
45+
oldClaim: StateAndRef<CordaClaim<*>>,
46+
newClaim: CordaClaim<*>
47+
): TransactionBuilder = apply {
48+
addInputState(oldClaim)
49+
addOutputState(newClaim)
50+
addCommand(CordaClaimContract.Amend, newClaim.issuer.owningKey)
4551
}
4652

4753
/**
4854
* Adds a claim for revocation to a transaction builder, including the required command.
4955
*
50-
* @param state The claim state to be consumed in the transaction.
56+
* @param claim The claim state to be consumed in the transaction.
5157
* @return Returns the current transaction builder.
5258
*/
53-
fun Builder.addRevokedClaim(state: StateAndRef<CordaClaim<*>>): Builder = apply {
54-
addInputState(state)
55-
addCommand(CordaClaimContract.Revoke, state.state.data.issuer.owningKey)
59+
fun TransactionBuilder.addRevokedClaim(
60+
claim: StateAndRef<CordaClaim<*>>
61+
): TransactionBuilder = apply {
62+
addInputState(claim)
63+
addCommand(CordaClaimContract.Revoke, claim.state.data.issuer.owningKey)
5664
}

onixlabs-corda-identity-framework-workflow/src/main/kotlin/io/onixlabs/corda/identityframework/workflow/TypeAliases.kt

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)