Skip to content

Commit a306e4a

Browse files
committed
update notary selection TokenSDk
1 parent 4e05ce0 commit a306e4a

File tree

14 files changed

+60
-74
lines changed

14 files changed

+60
-74
lines changed

Tokens/bikemarket/workflows/src/main/java/net/corda/samples/bikemarket/flows/CreateFrameToken.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.corda.samples.bikemarket.flows;
22

33
import com.r3.corda.lib.tokens.workflows.flows.rpc.CreateEvolvableTokens;
4+
import net.corda.core.identity.CordaX500Name;
45
import net.corda.samples.bikemarket.states.FrameTokenState;
56
import net.corda.core.contracts.TransactionState;
67
import net.corda.core.contracts.UniqueIdentifier;
@@ -22,13 +23,8 @@ public CreateFrameToken(String frameSerial) {
2223
public String call() throws FlowException {
2324

2425
// Obtain a reference to a notary we wish to use.
25-
/** METHOD 1: Take first notary on network, WARNING: use for test, non-prod environments, and single-notary networks only!*
26-
* METHOD 2: Explicit selection of notary by CordaX500Name - argument can by coded in flow or parsed from config (Preferred)
27-
*
28-
* * - For production you always want to use Method 2 as it guarantees the expected notary is returned.
29-
*/
30-
final Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0); // METHOD 1
31-
// final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB")); // METHOD 2
26+
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
27+
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB"));
3228

3329
//create non-fungible frame token
3430
UniqueIdentifier uuid = new UniqueIdentifier();

Tokens/bikemarket/workflows/src/main/java/net/corda/samples/bikemarket/flows/CreateWheelToken.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.corda.samples.bikemarket.flows;
22

33
import com.r3.corda.lib.tokens.workflows.flows.rpc.CreateEvolvableTokens;
4+
import net.corda.core.identity.CordaX500Name;
45
import net.corda.samples.bikemarket.states.WheelsTokenState;
56
import net.corda.core.contracts.TransactionState;
67
import net.corda.core.contracts.UniqueIdentifier;
@@ -22,13 +23,8 @@ public CreateWheelToken(String wheelsSerial) {
2223
public String call() throws FlowException {
2324

2425
// Obtain a reference to a notary we wish to use.
25-
/** METHOD 1: Take first notary on network, WARNING: use for test, non-prod environments, and single-notary networks only!*
26-
* METHOD 2: Explicit selection of notary by CordaX500Name - argument can by coded in flow or parsed from config (Preferred)
27-
*
28-
* * - For production you always want to use Method 2 as it guarantees the expected notary is returned.
29-
*/
30-
final Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0); // METHOD 1
31-
// final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB")); // METHOD 2
26+
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
27+
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB"));
3228

3329
//create non-fungible frame token
3430
UniqueIdentifier uuid = new UniqueIdentifier();

Tokens/bikemarket/workflows/src/main/java/net/corda/samples/bikemarket/flows/TransferBikeTokens.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.r3.corda.lib.tokens.workflows.internal.flows.distribution.UpdateDistributionListFlow;
88
import com.r3.corda.lib.tokens.workflows.internal.flows.finality.ObserverAwareFinalityFlow;
99
import com.r3.corda.lib.tokens.workflows.utilities.NotaryUtilities;
10+
import net.corda.core.identity.CordaX500Name;
1011
import net.corda.core.transactions.TransactionBuilder;
1112
import net.corda.samples.bikemarket.states.FrameTokenState;
1213
import net.corda.samples.bikemarket.states.WheelsTokenState;
@@ -61,9 +62,12 @@ public String call() throws FlowException {
6162
//get the pointer to the wheel
6263
TokenPointer wheeltokenPointer = wheeltokentype.toPointer(wheeltokentype.getClass());
6364

65+
// Obtain a reference to a notary we wish to use.
66+
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
67+
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB"));
6468

6569
FlowSession sellerSession = initiateFlow(holder);
66-
TransactionBuilder txBuilder = new TransactionBuilder(NotaryUtilities.getPreferredNotary(getServiceHub()));
70+
TransactionBuilder txBuilder = new TransactionBuilder(notary);
6771
MoveTokensUtilities.addMoveNonFungibleTokens(txBuilder, getServiceHub(), frametokenPointer, holder);
6872
MoveTokensUtilities.addMoveNonFungibleTokens(txBuilder, getServiceHub(), wheeltokenPointer, holder);
6973

Tokens/bikemarket/workflows/src/main/java/net/corda/samples/bikemarket/flows/TransferPartTokens.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.r3.corda.lib.tokens.workflows.internal.flows.distribution.UpdateDistributionListFlow;
88
import com.r3.corda.lib.tokens.workflows.internal.flows.finality.ObserverAwareFinalityFlow;
99
import com.r3.corda.lib.tokens.workflows.utilities.NotaryUtilities;
10+
import net.corda.core.identity.CordaX500Name;
1011
import net.corda.core.transactions.TransactionBuilder;
1112
import net.corda.samples.bikemarket.states.FrameTokenState;
1213
import net.corda.samples.bikemarket.states.WheelsTokenState;
@@ -57,8 +58,12 @@ public String call() throws FlowException {
5758
//get the pointer to the frame
5859
TokenPointer frametokenPointer = frametokentype.toPointer(frametokentype.getClass());
5960

61+
// Obtain a reference to a notary we wish to use.
62+
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
63+
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB"));
64+
6065
FlowSession sellerSession = initiateFlow(holder);
61-
TransactionBuilder txBuilder = new TransactionBuilder(NotaryUtilities.getPreferredNotary(getServiceHub()));
66+
TransactionBuilder txBuilder = new TransactionBuilder(notary);
6267
MoveTokensUtilities.addMoveNonFungibleTokens(txBuilder, getServiceHub(), frametokenPointer, holder);
6368

6469
SignedTransaction ptx = getServiceHub().signInitialTransaction(txBuilder);

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

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

33
import com.google.common.collect.ImmutableList;
44
import net.corda.core.contracts.StateAndRef;
5+
import net.corda.core.identity.CordaX500Name;
56
import net.corda.samples.bikemarket.flows.CreateFrameToken;
67
import net.corda.samples.bikemarket.flows.CreateWheelToken;
78
import net.corda.samples.bikemarket.states.FrameTokenState;
89
import net.corda.samples.bikemarket.states.WheelsTokenState;
9-
import net.corda.testing.node.MockNetwork;
10-
import net.corda.testing.node.MockNetworkParameters;
11-
import net.corda.testing.node.TestCordapp;
10+
import net.corda.testing.node.*;
1211
import org.junit.After;
1312
import org.junit.Before;
1413
import org.junit.Test;
15-
import net.corda.testing.node.StartedMockNode;
14+
1615
import java.util.concurrent.Future;
1716

1817
public class FlowTests {
@@ -27,7 +26,9 @@ public void setup() {
2726
TestCordapp.findCordapp("net.corda.samples.bikemarket.contracts"),
2827
TestCordapp.findCordapp("net.corda.samples.bikemarket.flows"),
2928
TestCordapp.findCordapp("com.r3.corda.lib.tokens.contracts"),
30-
TestCordapp.findCordapp("com.r3.corda.lib.tokens.workflows"))));
29+
TestCordapp.findCordapp("com.r3.corda.lib.tokens.workflows")))
30+
.withNotarySpecs(ImmutableList.of(new MockNetworkNotarySpec(CordaX500Name.parse("O=Notary,L=London,C=GB"))))
31+
);
3132
a = network.createPartyNode(null);
3233
b = network.createPartyNode(null);
3334
network.runNetwork();

Tokens/dollartohousetoken/workflows/src/main/java/net/corda/samples/dollartohousetoken/flows/HouseSaleInitiatorFlow.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import co.paralleluniverse.fibers.Suspendable;
44
import com.r3.corda.lib.tokens.workflows.flows.move.MoveTokensUtilities;
5+
import net.corda.core.identity.CordaX500Name;
56
import net.corda.samples.dollartohousetoken.states.HouseState;
67
import com.google.common.collect.ImmutableList;
78
import com.r3.corda.lib.tokens.contracts.states.FungibleToken;
@@ -39,13 +40,8 @@ public HouseSaleInitiatorFlow(String houseId, Party buyer) {
3940
public String call() throws FlowException {
4041

4142
// Obtain a reference to a notary we wish to use.
42-
/** METHOD 1: Take first notary on network, WARNING: use for test, non-prod environments, and single-notary networks only!*
43-
* METHOD 2: Explicit selection of notary by CordaX500Name - argument can by coded in flow or parsed from config (Preferred)
44-
*
45-
* * - For production you always want to use Method 2 as it guarantees the expected notary is returned.
46-
*/
47-
final Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0); // METHOD 1
48-
// final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB")); // METHOD 2
43+
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
44+
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB"));
4945

5046
/* Get the UUID from the houseId parameter */
5147
UUID uuid = UUID.fromString(houseId);

Tokens/dollartohousetoken/workflows/src/main/java/net/corda/samples/dollartohousetoken/flows/HouseTokenCreateAndIssueFlow.java

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

33
import co.paralleluniverse.fibers.Suspendable;
44
import com.r3.corda.lib.tokens.workflows.utilities.NonFungibleTokenBuilder;
5+
import net.corda.core.identity.CordaX500Name;
56
import net.corda.samples.dollartohousetoken.states.HouseState;
67
import com.google.common.collect.ImmutableList;
78
import com.r3.corda.lib.tokens.contracts.states.NonFungibleToken;
@@ -49,16 +50,9 @@ public HouseTokenCreateAndIssueFlow(Party owner, Amount<Currency> valuation,
4950
@Suspendable
5051
public String call() throws FlowException {
5152

52-
/* Choose the notary for the transaction */
53-
5453
// Obtain a reference to a notary we wish to use.
55-
/** METHOD 1: Take first notary on network, WARNING: use for test, non-prod environments, and single-notary networks only!*
56-
* METHOD 2: Explicit selection of notary by CordaX500Name - argument can by coded in flow or parsed from config (Preferred)
57-
*
58-
* * - For production you always want to use Method 2 as it guarantees the expected notary is returned.
59-
*/
60-
final Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0); // METHOD 1
61-
// final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB")); // METHOD 2
54+
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
55+
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB"));
6256

6357
/* Get a reference of own identity */
6458
Party issuer = getOurIdentity();

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@
44
import com.r3.corda.lib.tokens.contracts.states.NonFungibleToken;
55
import net.corda.core.contracts.Amount;
66
import net.corda.core.contracts.StateAndRef;
7+
import net.corda.core.identity.CordaX500Name;
78
import net.corda.core.node.NetworkParameters;
89
import net.corda.core.node.services.Vault;
910
import net.corda.core.node.services.vault.QueryCriteria;
1011
import net.corda.samples.dollartohousetoken.flows.HouseTokenCreateAndIssueFlow;
1112
import net.corda.samples.dollartohousetoken.states.HouseState;
12-
import net.corda.testing.node.MockNetwork;
13-
import net.corda.testing.node.MockNetworkParameters;
14-
import net.corda.testing.node.TestCordapp;
13+
import net.corda.testing.node.*;
1514
import org.junit.After;
1615
import org.junit.Before;
1716
import org.junit.Test;
18-
import net.corda.testing.node.StartedMockNode;
1917

2018
import java.time.Instant;
2119
import java.util.Arrays;
@@ -42,7 +40,9 @@ public void setup() {
4240
TestCordapp.findCordapp("net.corda.samples.dollartohousetoken.contracts"),
4341
TestCordapp.findCordapp("net.corda.samples.dollartohousetoken.flows"),
4442
TestCordapp.findCordapp("com.r3.corda.lib.tokens.contracts"),
45-
TestCordapp.findCordapp("com.r3.corda.lib.tokens.workflows"))).withNetworkParameters(testNetworkParameters));
43+
TestCordapp.findCordapp("com.r3.corda.lib.tokens.workflows"))).withNetworkParameters(testNetworkParameters)
44+
.withNotarySpecs(ImmutableList.of(new MockNetworkNotarySpec(CordaX500Name.parse("O=Notary,L=London,C=GB"))))
45+
);
4646
a = network.createPartyNode(null);
4747
b = network.createPartyNode(null);
4848
network.runNetwork();

Tokens/fungiblehousetoken/workflows/src/main/java/net/corda/samples/tokenizedhouse/flows/RealEstateEvolvableFungibleTokenFlow.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.r3.corda.lib.tokens.contracts.types.TokenType;
77
import com.r3.corda.lib.tokens.workflows.flows.rpc.*;
88
import com.r3.corda.lib.tokens.workflows.utilities.FungibleTokenBuilder;
9+
import net.corda.core.identity.CordaX500Name;
910
import net.corda.samples.tokenizedhouse.states.FungibleHouseTokenState;
1011
import kotlin.Unit;
1112
import net.corda.core.contracts.*;
@@ -38,14 +39,8 @@ public CreateHouseTokenFlow(String symbol, int valuation) {
3839
@Suspendable
3940
public SignedTransaction call() throws FlowException {
4041
// Obtain a reference to a notary we wish to use.
41-
/** METHOD 1: Take first notary on network, WARNING: use for test, non-prod environments, and single-notary networks only!*
42-
* METHOD 2: Explicit selection of notary by CordaX500Name - argument can by coded in flow or parsed from config (Preferred)
43-
*
44-
* * - For production you always want to use Method 2 as it guarantees the expected notary is returned.
45-
*/
46-
final Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0); // METHOD 1
47-
// final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB")); // METHOD 2
48-
42+
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
43+
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB"));
4944
//create token type
5045
FungibleHouseTokenState evolvableTokenType = new FungibleHouseTokenState(valuation, getOurIdentity(),
5146
new UniqueIdentifier(), 0, this.symbol);

Tokens/fungiblehousetoken/workflows/src/test/java/net/corda/samples/tokenizedhouse/FlowTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33
import com.google.common.collect.ImmutableList;
44
import net.corda.core.contracts.Amount;
55
import net.corda.core.contracts.StateAndRef;
6+
import net.corda.core.identity.CordaX500Name;
67
import net.corda.core.node.NetworkParameters;
78
import net.corda.core.node.services.Vault;
89
import net.corda.core.node.services.vault.QueryCriteria;
910
import net.corda.core.transactions.SignedTransaction;
1011
import net.corda.samples.tokenizedhouse.flows.RealEstateEvolvableFungibleTokenFlow;
1112
import net.corda.samples.tokenizedhouse.states.FungibleHouseTokenState;
12-
import net.corda.testing.node.MockNetwork;
13-
import net.corda.testing.node.MockNetworkParameters;
14-
import net.corda.testing.node.StartedMockNode;
15-
import net.corda.testing.node.TestCordapp;
13+
import net.corda.testing.node.*;
1614
import org.junit.After;
1715
import org.junit.Before;
1816
import org.junit.Test;
@@ -39,7 +37,9 @@ public void setup() {
3937
TestCordapp.findCordapp("net.corda.samples.tokenizedhouse.contracts"),
4038
TestCordapp.findCordapp("net.corda.samples.tokenizedhouse.flows"),
4139
TestCordapp.findCordapp("com.r3.corda.lib.tokens.contracts"),
42-
TestCordapp.findCordapp("com.r3.corda.lib.tokens.workflows"))).withNetworkParameters(testNetworkParameters));
40+
TestCordapp.findCordapp("com.r3.corda.lib.tokens.workflows"))).withNetworkParameters(testNetworkParameters)
41+
.withNotarySpecs(ImmutableList.of(new MockNetworkNotarySpec(CordaX500Name.parse("O=Notary,L=London,C=GB"))))
42+
);
4343
a = network.createPartyNode(null);
4444
b = network.createPartyNode(null);
4545
network.runNetwork();

0 commit comments

Comments
 (0)