Skip to content

Commit fcb4266

Browse files
committed
update emcumbrance sample
1 parent a78b0f0 commit fcb4266

File tree

17 files changed

+92
-98
lines changed

17 files changed

+92
-98
lines changed

Features/encumbrance-avatar/README.md

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,37 +32,23 @@ performing the DVP for the NFT against the tokens.
3232
## How to use run this sample
3333

3434
Build the CorDapp using below command. This will deploy three nodes - buyer, seller and notary.
35+
```
36+
./gradlew clean deployNodes
37+
./build/nodes/runnodes
38+
```
3539

36-
./gradlew clean deployNodes
37-
38-
Execute below commands for all the nodes. This will run the migration scripts on all the nodes.
39-
40-
cd buil/nodes/PartyA
41-
java -jar corda.jar run-migration-scripts --core-schemas
42-
java -jar corda.jar run-migration-scripts --app-schemas
43-
java -jar corda.jar
44-
45-
cd buil/nodes/PartyB
46-
java -jar corda.jar run-migration-scripts --core-schemas
47-
java -jar corda.jar run-migration-scripts --app-schemas
48-
java -jar corda.jar
49-
50-
cd buil/nodes/Notary
51-
java -jar corda.jar run-migration-scripts --core-schemas
52-
java -jar corda.jar run-migration-scripts --app-schemas
53-
java -jar corda.jar
5440

5541
Create the Avatar on PartyA node
5642

57-
start CreateAvatarFlow avatarId : 1, expiryAfterMinutes : 3
43+
start CreateAvatarFlow avatarId : PETER-7526, expiryAfterMinutes : 3
5844

5945
Sell the Avatar to PartyB node from PartyA node
6046

61-
start TransferAvatarFlow avatarId : 1, buyer : PartyB
47+
start TransferAvatarFlow avatarId : PETER-7526, buyer : PartyB
6248

6349
Confirm if PartyB owns the Avatar
6450

65-
run vaultQuery contractStateType : com.template.states.Avatar
51+
run vaultQuery contractStateType : Avatar
6652

6753
Note
6854
As you can see in both the flows, Avatar is encumbered by Expiry. But Encumbrances should form a complete directed cycle,

Features/encumbrance-avatar/build.gradle

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,6 @@ apply plugin: 'net.corda.plugins.cordapp'
5555
apply plugin: 'net.corda.plugins.cordformation'
5656
apply plugin: 'net.corda.plugins.quasar-utils'
5757

58-
cordapp {
59-
info {
60-
name "CorDapp Template"
61-
vendor "Corda Open Source"
62-
targetPlatformVersion corda_platform_version.toInteger()
63-
minimumPlatformVersion corda_platform_version.toInteger()
64-
}
65-
}
66-
6758
sourceSets {
6859
main {
6960
resources {

Features/encumbrance-avatar/contracts/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cordapp {
55
targetPlatformVersion corda_platform_version.toInteger()
66
minimumPlatformVersion corda_platform_version.toInteger()
77
contract {
8-
name "Template CorDapp"
8+
name "Avatar CorDapp"
99
vendor "Corda Open Source"
1010
licence "Apache License, Version 2.0"
1111
versionId 1

Features/encumbrance-avatar/contracts/src/main/java/com/template/contracts/AvatarContract.java renamed to Features/encumbrance-avatar/contracts/src/main/java/net/corda/samples/avatar/contracts/AvatarContract.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package com.template.contracts;
1+
package net.corda.samples.avatar.contracts;
22

3-
import com.template.states.Avatar;
4-
import com.template.states.Expiry;
3+
import net.corda.samples.avatar.states.Avatar;
4+
import net.corda.samples.avatar.states.Expiry;
55
import net.corda.core.contracts.CommandData;
66
import net.corda.core.contracts.CommandWithParties;
77
import net.corda.core.contracts.Contract;
@@ -16,7 +16,7 @@
1616

1717
public class AvatarContract implements Contract {
1818

19-
public static final String AVATAR_CONTRACT_ID = "com.template.contracts.AvatarContract";
19+
public static final String AVATAR_CONTRACT_ID = "net.corda.samples.avatar.contracts.AvatarContract";
2020

2121
@Override
2222
public void verify(@NotNull LedgerTransaction tx) throws IllegalArgumentException {

Features/encumbrance-avatar/contracts/src/main/java/com/template/contracts/ExpiryContract.java renamed to Features/encumbrance-avatar/contracts/src/main/java/net/corda/samples/avatar/contracts/ExpiryContract.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package com.template.contracts;
1+
package net.corda.samples.avatar.contracts;
22

3-
import com.template.states.Expiry;
3+
import net.corda.samples.avatar.states.Expiry;
44
import net.corda.core.contracts.CommandData;
55
import net.corda.core.contracts.Contract;
66
import net.corda.core.contracts.TimeWindow;
@@ -13,7 +13,7 @@
1313
//ExpiryContract is also run when Avatar's contract is run
1414
public class ExpiryContract implements Contract {
1515

16-
public static final String EXPIRY_CONTRACT_ID = "com.template.contracts.ExpiryContract";
16+
public static final String EXPIRY_CONTRACT_ID = "net.corda.samples.avatar.contracts.ExpiryContract";
1717

1818
@Override
1919
public void verify(@NotNull LedgerTransaction tx) throws IllegalArgumentException {

Features/encumbrance-avatar/contracts/src/main/java/com/template/states/Avatar.java renamed to Features/encumbrance-avatar/contracts/src/main/java/net/corda/samples/avatar/states/Avatar.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package com.template.states;
1+
package net.corda.samples.avatar.states;
22

33
import com.google.common.collect.ImmutableList;
4-
import com.template.contracts.AvatarContract;
4+
import net.corda.samples.avatar.contracts.AvatarContract;
55
import net.corda.core.contracts.BelongsToContract;
66
import net.corda.core.contracts.ContractState;
77
import net.corda.core.identity.AbstractParty;

Features/encumbrance-avatar/contracts/src/main/java/com/template/states/Expiry.java renamed to Features/encumbrance-avatar/contracts/src/main/java/net/corda/samples/avatar/states/Expiry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package com.template.states;
1+
package net.corda.samples.avatar.states;
22

33
import com.google.common.collect.ImmutableList;
4-
import com.template.contracts.ExpiryContract;
4+
import net.corda.samples.avatar.contracts.ExpiryContract;
55
import net.corda.core.contracts.BelongsToContract;
66
import net.corda.core.contracts.ContractState;
77
import net.corda.core.identity.AbstractParty;

Features/encumbrance-avatar/contracts/src/test/java/com/template/contracts/ContractTests.java renamed to Features/encumbrance-avatar/contracts/src/test/java/net/corda/samples/avatar/contracts/ContractTests.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
package com.template.contracts;
1+
package net.corda.samples.avatar.contracts;
22

33
import com.google.common.collect.ImmutableList;
4-
import com.template.states.Avatar;
5-
import com.template.states.Expiry;
64
import net.corda.core.identity.CordaX500Name;
5+
import net.corda.samples.avatar.states.Avatar;
6+
import net.corda.samples.avatar.states.Expiry;
77
import net.corda.testing.core.TestIdentity;
88
import net.corda.testing.node.MockServices;
99
import org.junit.Test;
@@ -74,9 +74,8 @@ public void specifyTimeWindow() {
7474
ledger(ledgerServices, (ledger -> {
7575
ledger.transaction(tx -> {
7676
//this fails as time window is not specified
77-
tx.output(AvatarContract.AVATAR_CONTRACT_ID, new Avatar(seller.getParty(), "1"));
78-
tx.output(ExpiryContract.EXPIRY_CONTRACT_ID,
79-
new Expiry(Instant.now().plus(2, ChronoUnit.MINUTES), "1", seller.getParty()));
77+
tx.output(AvatarContract.AVATAR_CONTRACT_ID, 1, new Avatar(seller.getParty(), "1"));
78+
tx.output(ExpiryContract.EXPIRY_CONTRACT_ID, 0, new Expiry(Instant.now().plus(2, ChronoUnit.MINUTES), "1", seller.getParty()));
8079
tx.command(ImmutableList.of(seller.getPublicKey()), new AvatarContract.Commands.Create());
8180
tx.fails();
8281

@@ -93,9 +92,8 @@ public void specifyTimeWindow() {
9392
public void avatarIsRejectedIfItIsExpired() {
9493
ledger(ledgerServices, (ledger -> {
9594
ledger.transaction(tx -> {
96-
tx.output(AvatarContract.AVATAR_CONTRACT_ID, new Avatar(seller.getParty(), "1"));
97-
tx.output(ExpiryContract.EXPIRY_CONTRACT_ID,
98-
new Expiry(Instant.now().plus(2, ChronoUnit.MINUTES), "1", seller.getParty()));
95+
tx.output(AvatarContract.AVATAR_CONTRACT_ID, 1, new Avatar(seller.getParty(), "1"));
96+
tx.output(ExpiryContract.EXPIRY_CONTRACT_ID, 0, new Expiry(Instant.now().plus(2, ChronoUnit.MINUTES), "1", seller.getParty()));
9997
tx.command(ImmutableList.of(seller.getPublicKey()), new AvatarContract.Commands.Create());
10098
tx.timeWindow(Instant.now(), Duration.ofMinutes(3));
10199
tx.fails();
@@ -110,9 +108,8 @@ public void avatarIsRejectedIfItIsExpired() {
110108
public void expirationDateShouldBeAfterTheTimeWindow() {
111109
ledger(ledgerServices, (ledger -> {
112110
ledger.transaction(tx -> {
113-
tx.output(AvatarContract.AVATAR_CONTRACT_ID, new Avatar(seller.getParty(), "1"));
114-
tx.output(ExpiryContract.EXPIRY_CONTRACT_ID,
115-
new Expiry(Instant.now().plus(3, ChronoUnit.MINUTES), "1", seller.getParty()));
111+
tx.output(AvatarContract.AVATAR_CONTRACT_ID, 1, new Avatar(seller.getParty(), "1"));
112+
tx.output(ExpiryContract.EXPIRY_CONTRACT_ID, 0, new Expiry(Instant.now().plus(3, ChronoUnit.MINUTES), "1", seller.getParty()));
116113
tx.command(ImmutableList.of(seller.getPublicKey()), new AvatarContract.Commands.Create());
117114
tx.timeWindow(Instant.now(), Duration.ofMinutes(2));
118115
tx.verifies();
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
name=Test
2-
group=com.template
2+
group=net.corda.samples.avatar
33
version=0.1

Features/encumbrance-avatar/workflows/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cordapp {
66
targetPlatformVersion corda_platform_version.toInteger()
77
minimumPlatformVersion corda_platform_version.toInteger()
88
workflow {
9-
name "Template Flows"
9+
name "Avatar Flows"
1010
vendor "Corda Open Source"
1111
licence "Apache License, Version 2.0"
1212
versionId 1

0 commit comments

Comments
 (0)