Skip to content

Commit dab6822

Browse files
committed
fungiblehousetoken revamp
1 parent ddc2168 commit dab6822

File tree

25 files changed

+241
-229
lines changed

25 files changed

+241
-229
lines changed

Tokens/bikemarket/build.gradle

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ buildscript {
33
file("$projectDir/../constants.properties").withInputStream { constants.load(it) }
44

55
ext {
6-
76
corda_release_group = constants.getProperty("cordaReleaseGroup")
87
corda_release_version = constants.getProperty("cordaVersion")
98
corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion")
@@ -13,12 +12,10 @@ buildscript {
1312
slf4j_version = constants.getProperty("slf4jVersion")
1413
corda_platform_version = constants.getProperty("platformVersion").toInteger()
1514
guava_version = constants.getProperty("guavaVersion")
15+
1616
//Tokens
1717
tokens_release_group = 'com.r3.corda.lib.tokens'
1818
tokens_release_version = '1.2'
19-
//CI
20-
confidential_id_release_group = "com.r3.corda.lib.ci"
21-
confidential_id_release_version = "1.0"
2219
}
2320

2421
repositories {
@@ -45,9 +42,10 @@ allprojects {
4542
mavenCentral()
4643
maven { url 'https://software.r3.com/artifactory/corda' }
4744
maven { url 'https://jitpack.io' }
48-
// Can be removed post-release - used to get nightly snapshot build.
45+
//SDK lib
4946
maven { url 'https://software.r3.com/artifactory/corda-lib' }
50-
maven { url 'https://software.r3.com/artifactory/corda-tokens-dev' }
47+
//Gradle Plugins
48+
maven { url 'https://repo.gradle.org/gradle/libs-releases' }
5149
}
5250

5351
tasks.withType(JavaCompile) {
@@ -101,10 +99,6 @@ dependencies {
10199
// Token SDK dependencies.
102100
cordapp "$tokens_release_group:tokens-contracts:$tokens_release_version"
103101
cordapp "$tokens_release_group:tokens-workflows:$tokens_release_version"
104-
105-
// CI dependencies
106-
cordapp "$confidential_id_release_group:ci-workflows:$confidential_id_release_version"
107-
108102
}
109103

110104
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
@@ -114,7 +108,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
114108
}
115109
cordapp("$tokens_release_group:tokens-contracts:$tokens_release_version")
116110
cordapp("$tokens_release_group:tokens-workflows:$tokens_release_version")
117-
cordapp("$confidential_id_release_group:ci-workflows:$confidential_id_release_version")
118111
cordapp project(':contracts')
119112
cordapp project(':workflows')
120113
runSchemaMigration = true

Tokens/bikemarket/workflows/src/test/java/net/corda/samples/bikemarket/FlowTests.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
import com.google.common.collect.ImmutableList;
44
import net.corda.core.contracts.StateAndRef;
5-
import net.corda.core.contracts.UniqueIdentifier;
6-
import net.corda.core.node.NetworkParameters;
7-
import net.corda.core.node.services.vault.QueryCriteria;
85
import net.corda.samples.bikemarket.flows.CreateFrameToken;
96
import net.corda.samples.bikemarket.flows.CreateWheelToken;
107
import net.corda.samples.bikemarket.states.FrameTokenState;
@@ -16,8 +13,6 @@
1613
import org.junit.Before;
1714
import org.junit.Test;
1815
import net.corda.testing.node.StartedMockNode;
19-
import java.util.*;
20-
import java.time.Instant;
2116
import java.util.concurrent.Future;
2217

2318
public class FlowTests {

Tokens/dollartohousetoken/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ allprojects {
4242
mavenCentral()
4343
maven { url 'https://software.r3.com/artifactory/corda' }
4444
maven { url 'https://jitpack.io' }
45+
//SDK lib
4546
maven { url 'https://software.r3.com/artifactory/corda-lib' }
47+
//Gradle Plugins
4648
maven { url 'https://repo.gradle.org/gradle/libs-releases' }
4749
}
4850

Tokens/dollartohousetoken/contracts/src/test/java/net/corda/samples/dollartohousetoken/contracts/ContractTests.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
import net.corda.testing.core.TestIdentity;
88
import net.corda.testing.node.MockServices;
99
import org.junit.Test;
10-
1110
import java.util.Arrays;
12-
1311
import static net.corda.testing.node.NodeTestUtils.ledger;
1412

1513
public class ContractTests {

Tokens/fungiblehousetoken/build.gradle

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ buildscript {
1313
slf4j_version = constants.getProperty("slf4jVersion")
1414
corda_platform_version = constants.getProperty("platformVersion")
1515
guava_version = constants.getProperty("guavaVersion")
16+
17+
//Tokens
1618
tokens_release_group = 'com.r3.corda.lib.tokens'
1719
tokens_release_version = '1.2'
18-
19-
confidential_id_release_group = "com.r3.corda.lib.ci"
20-
confidential_id_release_version = "1.0"
2120
}
2221

2322
repositories {
@@ -43,9 +42,9 @@ allprojects {
4342
mavenCentral()
4443
maven { url 'https://software.r3.com/artifactory/corda' }
4544
maven { url 'https://jitpack.io' }
46-
// Can be removed post-release - used to get nightly snapshot build.
45+
//SDK lib
4746
maven { url 'https://software.r3.com/artifactory/corda-lib' }
48-
maven { url 'https://software.r3.com/artifactory/corda-tokens-dev' }
47+
//Gradle Plugins
4948
maven { url 'https://repo.gradle.org/gradle/libs-releases' }
5049
}
5150

@@ -64,20 +63,10 @@ allprojects {
6463
}
6564
}
6665

67-
6866
apply plugin: 'net.corda.plugins.cordapp'
6967
apply plugin: 'net.corda.plugins.cordformation'
7068
apply plugin: 'net.corda.plugins.quasar-utils'
7169

72-
cordapp {
73-
info {
74-
name "CorDapp tokenizedhouse"
75-
vendor "Corda Open Source"
76-
targetPlatformVersion corda_platform_version.toInteger()
77-
minimumPlatformVersion corda_platform_version.toInteger()
78-
}
79-
}
80-
8170
sourceSets {
8271
main {
8372
resources {
@@ -106,8 +95,6 @@ dependencies {
10695
// Token SDK dependencies.
10796
cordapp "$tokens_release_group:tokens-contracts:$tokens_release_version"
10897
cordapp "$tokens_release_group:tokens-workflows:$tokens_release_version"
109-
110-
cordapp "$confidential_id_release_group:ci-workflows:$confidential_id_release_version"
11198
}
11299

113100
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
@@ -117,10 +104,10 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
117104
}
118105
cordapp("$tokens_release_group:tokens-contracts:$tokens_release_version")
119106
cordapp("$tokens_release_group:tokens-workflows:$tokens_release_version")
120-
cordapp("$confidential_id_release_group:ci-workflows:$confidential_id_release_version")
107+
//cordapp("$confidential_id_release_group:ci-workflows:$confidential_id_release_version")
121108
cordapp project(':contracts')
122109
cordapp project(':workflows')
123-
runSchemaMigration = true
110+
runSchemaMigration = true
124111
}
125112
node {
126113
name "O=Notary,L=London,C=GB"

Tokens/fungiblehousetoken/contracts/src/main/java/net/corda/examples/tokenizedhouse/contracts/HouseTokenStateContract.java

Lines changed: 0 additions & 21 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package net.corda.samples.tokenizedhouse.contracts;
2+
3+
import com.r3.corda.lib.tokens.contracts.EvolvableTokenContract;
4+
import net.corda.core.contracts.Contract;
5+
import net.corda.core.transactions.LedgerTransaction;
6+
import net.corda.samples.tokenizedhouse.states.FungibleHouseTokenState;
7+
import org.jetbrains.annotations.NotNull;
8+
9+
import java.math.BigDecimal;
10+
11+
import static net.corda.core.contracts.ContractsDSL.requireThat;
12+
13+
/**
14+
* This doesn't do anything over and above the [EvolvableTokenContract].
15+
*/
16+
public class HouseTokenStateContract extends EvolvableTokenContract implements Contract {
17+
18+
public static final String CONTRACT_ID = "net.corda.samples.tokenizedhouse.contracts.HouseTokenStateContract";
19+
20+
@Override
21+
public void additionalCreateChecks(@NotNull LedgerTransaction tx) {
22+
// Write contract validation logic to be performed while creation of token
23+
FungibleHouseTokenState outputState = (FungibleHouseTokenState) tx.getOutput(0);
24+
requireThat( require -> {
25+
require.using("Valuation must be greater than zero",
26+
outputState.getValuation() > 0);
27+
return null;
28+
});
29+
}
30+
31+
@Override
32+
public void additionalUpdateChecks(@NotNull LedgerTransaction tx) {
33+
// Write contract validation logic to be performed while updation of token
34+
}
35+
}

Tokens/fungiblehousetoken/contracts/src/main/java/net/corda/examples/tokenizedhouse/states/FungibleHouseTokenState.java renamed to Tokens/fungiblehousetoken/contracts/src/main/java/net/corda/samples/tokenizedhouse/states/FungibleHouseTokenState.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package net.corda.examples.tokenizedhouse.states;
1+
package net.corda.samples.tokenizedhouse.states;
22

33
import com.google.common.collect.ImmutableList;
44
import com.r3.corda.lib.tokens.contracts.states.EvolvableTokenType;
5-
import net.corda.examples.tokenizedhouse.contracts.HouseTokenStateContract;
5+
import net.corda.samples.tokenizedhouse.contracts.HouseTokenStateContract;
66
import net.corda.core.contracts.BelongsToContract;
77
import net.corda.core.contracts.UniqueIdentifier;
88
import net.corda.core.identity.Party;
@@ -15,13 +15,13 @@
1515
@BelongsToContract(HouseTokenStateContract.class)
1616
public class FungibleHouseTokenState extends EvolvableTokenType {
1717

18-
private final BigDecimal valuation;
18+
private final int valuation;
1919
private final Party maintainer;
2020
private final UniqueIdentifier uniqueIdentifier;
2121
private final String symbol;
2222
private final int fractionDigits;
2323

24-
public FungibleHouseTokenState(BigDecimal valuation, Party maintainer,
24+
public FungibleHouseTokenState(int valuation, Party maintainer,
2525
UniqueIdentifier uniqueIdentifier, int fractionDigits, String symbol) {
2626
this.valuation = valuation;
2727
this.maintainer = maintainer;
@@ -30,7 +30,7 @@ public FungibleHouseTokenState(BigDecimal valuation, Party maintainer,
3030
this.fractionDigits = fractionDigits;
3131
}
3232

33-
public BigDecimal getValuation() {
33+
public int getValuation() {
3434
return valuation;
3535
}
3636

@@ -58,17 +58,13 @@ public UniqueIdentifier getLinearId() {
5858
return this.uniqueIdentifier;
5959
}
6060

61-
public UniqueIdentifier getUniqueIdentifier() {
62-
return uniqueIdentifier;
63-
}
64-
6561
@Override
6662
public boolean equals(Object o) {
6763
if (this == o) return true;
6864
if (o == null || getClass() != o.getClass()) return false;
6965
FungibleHouseTokenState that = (FungibleHouseTokenState) o;
7066
return getFractionDigits() == that.getFractionDigits() &&
71-
getValuation().equals(that.getValuation()) &&
67+
getValuation() == (that.getValuation()) &&
7268
getMaintainer().equals(that.getMaintainer()) &&
7369
uniqueIdentifier.equals(that.uniqueIdentifier);
7470
}

Tokens/fungiblehousetoken/contracts/src/test/java/net/corda/examples/tokenizedhouse/contracts/ContractTests.java

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package net.corda.samples.tokenizedhouse.contracts;
2+
3+
import net.corda.core.contracts.UniqueIdentifier;
4+
import net.corda.core.identity.CordaX500Name;
5+
import net.corda.samples.tokenizedhouse.states.FungibleHouseTokenState;
6+
import net.corda.testing.core.TestIdentity;
7+
import net.corda.testing.node.MockServices;
8+
import org.junit.Test;
9+
import static net.corda.testing.node.NodeTestUtils.ledger;
10+
11+
public class ContractTests {
12+
private final MockServices ledgerServices = new MockServices();
13+
TestIdentity Operator = new TestIdentity(new CordaX500Name("Alice", "TestLand", "US"));
14+
15+
//sample tests
16+
@Test
17+
public void valuationCannotBeZero() {
18+
FungibleHouseTokenState tokenPass = new FungibleHouseTokenState(10000,Operator.getParty(),
19+
new UniqueIdentifier(),
20+
0,"NYCHelena");
21+
FungibleHouseTokenState tokenFail = new FungibleHouseTokenState(0,Operator.getParty(),
22+
new UniqueIdentifier(),
23+
0,"NYCHelena");
24+
ledger(ledgerServices, l -> {
25+
l.transaction(tx -> {
26+
tx.output(HouseTokenStateContract.CONTRACT_ID, tokenFail);
27+
tx.command(Operator.getPublicKey(), new com.r3.corda.lib.tokens.contracts.commands.Create());
28+
return tx.fails();
29+
});
30+
l.transaction(tx -> {
31+
tx.output(HouseTokenStateContract.CONTRACT_ID, tokenPass);
32+
tx.command(Operator.getPublicKey(), new com.r3.corda.lib.tokens.contracts.commands.Create());
33+
return tx.verifies();
34+
});
35+
return null;
36+
});
37+
}
38+
}

0 commit comments

Comments
 (0)