Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on May 15, 2020. It is now read-only.
/samplesPublic archive

Commit16f1a12

Browse files
Upgrade Sample to TokenSDK 1.1
1 parentbed7c81 commit16f1a12

File tree

8 files changed

+49
-33
lines changed

8 files changed

+49
-33
lines changed

‎dollartohousetoken-TokenSDK/build.gradle‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ buildscript {
1616
corda_platform_version= constants.getProperty("platformVersion").toInteger()
1717
//Tokens
1818
tokens_release_group='com.r3.corda.lib.tokens'
19-
tokens_release_version='1.0'
19+
tokens_release_version='1.1'
2020

2121
}
2222

@@ -45,7 +45,6 @@ allprojects {
4545
maven { url'https://jitpack.io' }
4646
// Can be removed post-release - used to get nightly snapshot build.
4747
maven { url'https://ci-artifactory.corda.r3cev.com/artifactory/corda-lib' }
48-
maven { url'https://ci-artifactory.corda.r3cev.com/artifactory/corda-lib-dev' }
4948
}
5049

5150
tasks.withType(JavaCompile) {
@@ -102,6 +101,8 @@ dependencies {
102101
cordapp"$tokens_release_group:tokens-contracts:$tokens_release_version"
103102
cordapp"$tokens_release_group:tokens-workflows:$tokens_release_version"
104103
cordapp"$tokens_release_group:tokens-money:$tokens_release_version"
104+
cordapp"$tokens_release_group:tokens-selection:$tokens_release_version"
105+
105106
}
106107

107108
taskdeployNodes(type:net.corda.plugins.Cordform,dependsOn: ['jar']) {
@@ -112,6 +113,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
112113
cordapp("$tokens_release_group:tokens-contracts:$tokens_release_version")
113114
cordapp("$tokens_release_group:tokens-workflows:$tokens_release_version")
114115
cordapp("$tokens_release_group:tokens-money:$tokens_release_version")
116+
cordapp("$tokens_release_group:tokens-selection:$tokens_release_version")
115117
cordapp project(':contracts')
116118
cordapp project(':workflows')
117119
}

‎dollartohousetoken-TokenSDK/contracts/build.gradle‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ dependencies {
1919
// Corda dependencies.
2020
cordaCompile"$corda_core_release_group:corda-core:$corda_core_release_version"
2121
cordaRuntime"$corda_release_group:corda:$corda_release_version"
22-
testCompile"$corda_release_group:corda-node-driver:$corda_release_version"
22+
testCompile ("$corda_release_group:corda-node-driver:$corda_release_version"){
23+
excludegroup:'org.gradle',module:'gradle-tooling-api'
24+
}
2325

2426
// Token SDK dependencies.
2527
cordaCompile"$tokens_release_group:tokens-contracts:$tokens_release_version"

‎dollartohousetoken-TokenSDK/contracts/src/main/java/net/corda/examples/dollartohousetoken/states/HouseState.java‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
packagenet.corda.examples.dollartohousetoken.states;
22

3-
importnet.corda.examples.dollartohousetoken.contracts.HouseContract;
4-
importcom.google.common.collect.ImmutableList;
53
importcom.r3.corda.lib.tokens.contracts.states.EvolvableTokenType;
64
importcom.r3.corda.lib.tokens.contracts.types.TokenPointer;
75
importnet.corda.core.contracts.Amount;
86
importnet.corda.core.contracts.BelongsToContract;
97
importnet.corda.core.contracts.LinearPointer;
108
importnet.corda.core.contracts.UniqueIdentifier;
119
importnet.corda.core.identity.Party;
10+
importnet.corda.examples.dollartohousetoken.contracts.HouseContract;
1211
importorg.jetbrains.annotations.NotNull;
1312

1413
importjava.util.Currency;
@@ -78,12 +77,12 @@ public int getFractionDigits() {
7877
@NotNull
7978
@Override
8079
publicList<Party>getMaintainers() {
81-
returnImmutableList.copyOf(maintainers);
80+
returnmaintainers;
8281
}
8382

84-
/* This method returns a TokenPointer by using the linear Id of the evolvable state */
85-
publicTokenPointer<HouseState>toPointer(){
86-
LinearPointer<HouseState>linearPointer =newLinearPointer<>(linearId,HouseState.class);
87-
returnnewTokenPointer<>(linearPointer,fractionDigits);
88-
}
83+
// /* This method returns a TokenPointer by using the linear Id of the evolvable state */
84+
// public TokenPointer<HouseState> toPointer(){
85+
// LinearPointer<HouseState> linearPointer = new LinearPointer<>(linearId, HouseState.class);
86+
// return new TokenPointer<>(linearPointer, fractionDigits);
87+
// }
8988
}

‎dollartohousetoken-TokenSDK/workflows/build.gradle‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,18 @@ dependencies {
4545

4646
// For testing.
4747
testCompile"junit:junit:$junit_version"
48-
testCompile"$corda_release_group:corda-node-driver:$corda_release_version"
48+
testCompile ("$corda_release_group:corda-node-driver:$corda_release_version"){
49+
excludegroup:'org.gradle',module:'gradle-tooling-api'
50+
}
4951

5052
// CorDapp dependencies.
5153
cordapp project(":contracts")
5254

5355
// Token SDK dependencies.
5456
cordaCompile"$tokens_release_group:tokens-money:$tokens_release_version"
5557
cordaCompile"$tokens_release_group:tokens-workflows:$tokens_release_version"
58+
cordaCompile"$tokens_release_group:tokens-selection:$tokens_release_version"
59+
5660
}
5761

5862
taskintegrationTest(type:Test,dependsOn: []) {

‎dollartohousetoken-TokenSDK/workflows/src/main/java/net/corda/examples/dollartohousetoken/flows/FiatCurrencyIssueFlow.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
packagenet.corda.examples.dollartohousetoken.flows;
22

33
importco.paralleluniverse.fibers.Suspendable;
4-
importcom.google.common.collect.ImmutableList;
54
importcom.r3.corda.lib.tokens.contracts.states.FungibleToken;
65
importcom.r3.corda.lib.tokens.contracts.types.IssuedTokenType;
76
importcom.r3.corda.lib.tokens.contracts.types.TokenType;
@@ -10,11 +9,12 @@
109
importnet.corda.core.contracts.Amount;
1110
importnet.corda.core.flows.FlowException;
1211
importnet.corda.core.flows.FlowLogic;
13-
importnet.corda.core.flows.FlowSession;
1412
importnet.corda.core.flows.StartableByRPC;
1513
importnet.corda.core.identity.Party;
1614
importnet.corda.core.transactions.SignedTransaction;
1715

16+
importjava.util.Arrays;
17+
1818
/**
1919
* Flow class to issue fiat currency. FiatCurrency is defined in the TokenSDK and is issued as a Fungible Token. This constructor takes the currecy code
2020
* for the currency to be issued, the amount of the currency to be issued and the recipient as input parameters.
@@ -45,7 +45,7 @@ public SignedTransaction call() throws FlowException {
4545
FungibleTokenfungibleToken =newFungibleToken(newAmount<>(amount,issuedTokenType),recipient,null);
4646

4747
/* Issue the required amount of the token to the recipient */
48-
returnsubFlow(newIssueTokens(ImmutableList.of(fungibleToken),ImmutableList.of(recipient)));
48+
returnsubFlow(newIssueTokens(Arrays.asList(fungibleToken),Arrays.asList(recipient)));
4949
}
5050

5151
}

‎dollartohousetoken-TokenSDK/workflows/src/main/java/net/corda/examples/dollartohousetoken/flows/HouseSaleInitiatorFlow.java‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
packagenet.corda.examples.dollartohousetoken.flows;
22

33
importco.paralleluniverse.fibers.Suspendable;
4-
importnet.corda.examples.dollartohousetoken.states.HouseState;
5-
importcom.google.common.collect.ImmutableList;
64
importcom.r3.corda.lib.tokens.contracts.states.FungibleToken;
75
importcom.r3.corda.lib.tokens.workflows.flows.move.MoveTokensUtilitiesKt;
86
importcom.r3.corda.lib.tokens.workflows.internal.flows.distribution.UpdateDistributionListFlow;
@@ -13,7 +11,9 @@
1311
importnet.corda.core.node.services.vault.QueryCriteria;
1412
importnet.corda.core.transactions.SignedTransaction;
1513
importnet.corda.core.transactions.TransactionBuilder;
14+
importnet.corda.examples.dollartohousetoken.states.HouseState;
1615

16+
importjava.util.Arrays;
1717
importjava.util.List;
1818
importjava.util.UUID;
1919

@@ -43,7 +43,7 @@ public String call() throws FlowException {
4343

4444
/* Fetch the house state from the vault using the vault query */
4545
QueryCriteriaqueryCriteria =newQueryCriteria.LinearStateQueryCriteria(
46-
null,ImmutableList.of(uuid),null,Vault.StateStatus.UNCONSUMED);
46+
null,Arrays.asList(uuid),null,Vault.StateStatus.UNCONSUMED);
4747
StateAndRef<HouseState>houseStateAndRef =getServiceHub().getVaultService().
4848
queryBy(HouseState.class,queryCriteria).getStates().get(0);
4949
HouseStatehouseState =houseStateAndRef.getState().getData();
@@ -54,7 +54,7 @@ public String call() throws FlowException {
5454
/* Create a move token proposal for the house token using the helper function provided by Token SDK. This would create the movement proposal and would
5555
* be committed in the ledgers of parties once the transaction in finalized.
5656
**/
57-
MoveTokensUtilitiesKt.addMoveNonFungibleTokens(txBuilder,getServiceHub(),houseState.toPointer(),buyer);
57+
MoveTokensUtilitiesKt.addMoveNonFungibleTokens(txBuilder,getServiceHub(),houseState.toPointer(HouseState.class),buyer);
5858

5959
/* Initiate a flow session with the buyer to send the house valuation and transfer of the fiat currency */
6060
FlowSessionbuyerSession =initiateFlow(buyer);
@@ -71,11 +71,11 @@ public String call() throws FlowException {
7171
/* Sign the transaction with your private */
7272
SignedTransactioninitialSignedTrnx =getServiceHub().signInitialTransaction(txBuilder,getOurIdentity().getOwningKey());
7373
/* Call the CollectSignaturesFlow to recieve signature of the buyer */
74-
SignedTransactionsignedTransaction =subFlow(newCollectSignaturesFlow(initialSignedTrnx,ImmutableList.of(buyerSession)));
74+
SignedTransactionsignedTransaction =subFlow(newCollectSignaturesFlow(initialSignedTrnx,Arrays.asList(buyerSession)));
7575
/* Distribution list is a list of identities that should receive updates. For this mechanism to behave correctly we call the UpdateDistributionListFlow flow */
7676
subFlow(newUpdateDistributionListFlow(signedTransaction));
7777
/* Call finality flow to notarise the transaction */
78-
SignedTransactionstx =subFlow(newFinalityFlow(signedTransaction,ImmutableList.of(buyerSession)));
78+
SignedTransactionstx =subFlow(newFinalityFlow(signedTransaction,Arrays.asList(buyerSession)));
7979
return"\nThe house is sold to "+this.buyer.getName().getOrganisation() +"\nTransaction ID: "
8080
+stx.getId();
8181
}

‎dollartohousetoken-TokenSDK/workflows/src/main/java/net/corda/examples/dollartohousetoken/flows/HouseSaleResponderFlow.java‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
packagenet.corda.examples.dollartohousetoken.flows;
22

33
importco.paralleluniverse.fibers.Suspendable;
4-
importcom.google.common.collect.ImmutableList;
54
importcom.r3.corda.lib.tokens.contracts.states.FungibleToken;
65
importcom.r3.corda.lib.tokens.contracts.types.TokenType;
76
importcom.r3.corda.lib.tokens.money.FiatCurrency;
8-
importcom.r3.corda.lib.tokens.workflows.internal.selection.TokenSelection;
9-
importcom.r3.corda.lib.tokens.workflows.types.PartyAndAmount;
7+
importcom.r3.corda.lib.tokens.selection.TokenQueryBy;
8+
importcom.r3.corda.lib.tokens.selection.TokenQueryByKt;
9+
importcom.r3.corda.lib.tokens.selection.database.config.DatabaseSelectionConfigKt;
10+
importcom.r3.corda.lib.tokens.selection.database.selector.DatabaseTokenSelection;
1011
importkotlin.Pair;
1112
importnet.corda.core.contracts.Amount;
1213
importnet.corda.core.contracts.StateAndRef;
1314
importnet.corda.core.flows.*;
15+
importnet.corda.core.identity.AbstractParty;
1416
importnet.corda.core.transactions.SignedTransaction;
1517
importorg.jetbrains.annotations.NotNull;
1618

19+
importjava.util.Arrays;
1720
importjava.util.Currency;
1821
importjava.util.List;
1922

@@ -44,14 +47,20 @@ public SignedTransaction call() throws FlowException {
4447
* The constructor takes the service hub to perform vault query, the max-number of retries, the retry sleep interval, and the retry sleep cap interval. This
4548
* is a temporary solution till in-memory token selection in implemented.
4649
* */
47-
TokenSelectiontokenSelection =newTokenSelection(getServiceHub(),8,100,2000);
50+
DatabaseTokenSelectiontokenSelection =newDatabaseTokenSelection(
51+
getServiceHub(),
52+
DatabaseSelectionConfigKt.MAX_RETRIES_DEFAULT,
53+
DatabaseSelectionConfigKt.RETRY_SLEEP_DEFAULT,
54+
DatabaseSelectionConfigKt.RETRY_CAP_DEFAULT,
55+
DatabaseSelectionConfigKt.PAGE_SIZE_DEFAULT
56+
);
4857

4958
/*
5059
* Generate the move proposal, it returns the input-output pair for the fiat currency transfer, which we need to send to the Initiator.
5160
* */
52-
PartyAndAmount<TokenType>partyAndAmount =newPartyAndAmount<>(counterpartySession.getCounterparty(),priceToken);
61+
Pair<AbstractParty,Amount<TokenType>>partyAndAmount =newPair<>(counterpartySession.getCounterparty(),priceToken);
5362
Pair<List<StateAndRef<FungibleToken>>,List<FungibleToken>>inputsAndOutputs =
54-
tokenSelection.generateMove(getRunId().getUuid(),ImmutableList.of(partyAndAmount),getOurIdentity(),null);
63+
tokenSelection.generateMove(Arrays.asList(partyAndAmount),getOurIdentity(),newTokenQueryBy(),getRunId().getUuid());
5564

5665
/* Call SendStateAndRefFlow to send the inputs to the Initiator*/
5766
subFlow(newSendStateAndRefFlow(counterpartySession,inputsAndOutputs.getFirst()));

‎dollartohousetoken-TokenSDK/workflows/src/main/java/net/corda/examples/dollartohousetoken/flows/HouseTokenCreateAndIssueFlow.java‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
packagenet.corda.examples.dollartohousetoken.flows;
22

33
importco.paralleluniverse.fibers.Suspendable;
4-
importnet.corda.examples.dollartohousetoken.states.HouseState;
5-
importcom.google.common.collect.ImmutableList;
64
importcom.r3.corda.lib.tokens.contracts.states.NonFungibleToken;
75
importcom.r3.corda.lib.tokens.contracts.types.IssuedTokenType;
86
importcom.r3.corda.lib.tokens.contracts.utilities.TransactionUtilitiesKt;
@@ -16,7 +14,9 @@
1614
importnet.corda.core.flows.StartableByRPC;
1715
importnet.corda.core.identity.Party;
1816
importnet.corda.core.transactions.SignedTransaction;
17+
importnet.corda.examples.dollartohousetoken.states.HouseState;
1918

19+
importjava.util.Arrays;
2020
importjava.util.Currency;
2121
importjava.util.UUID;
2222

@@ -56,7 +56,7 @@ public String call() throws FlowException {
5656
/* Construct the output state */
5757

5858
UniqueIdentifieruuid =UniqueIdentifier.Companion.fromString(UUID.randomUUID().toString());
59-
finalHouseStatehouseState =newHouseState(uuid,ImmutableList.of(issuer),
59+
finalHouseStatehouseState =newHouseState(uuid,Arrays.asList(issuer),
6060
valuation,noOfBedRooms,constructionArea,additionInfo,address);
6161

6262
/* Create an instance of TransactionState using the houseState token and the notary */
@@ -71,14 +71,14 @@ public String call() throws FlowException {
7171
* so that the state can evolve independently.
7272
* IssuedTokenType is a wrapper around the TokenType and the issuer.
7373
* */
74-
IssuedTokenTypeissuedHouseToken =newIssuedTokenType(issuer,houseState.toPointer());
74+
IssuedTokenTypeissuedHouseToken =newIssuedTokenType(issuer,houseState.toPointer(HouseState.class));
7575

7676
/* Create an instance of the non-fungible house token with the owner as the token holder. The last paramter is a hash of the jar containing the TokenType, use the helper function to fetch it. */
7777
NonFungibleTokenhouseToken =
78-
newNonFungibleToken(issuedHouseToken,owner,UniqueIdentifier.Companion.fromString(UUID.randomUUID().toString()),TransactionUtilitiesKt.getAttachmentIdForGenericParam(houseState.toPointer()));
78+
newNonFungibleToken(issuedHouseToken,owner,UniqueIdentifier.Companion.fromString(UUID.randomUUID().toString()),TransactionUtilitiesKt.getAttachmentIdForGenericParam(houseState.toPointer(HouseState.class)));
7979

8080
/* Issue the house token by calling the IssueTokens flow provided with the TokenSDK */
81-
SignedTransactionstx =subFlow(newIssueTokens(ImmutableList.of(houseToken)));
81+
SignedTransactionstx =subFlow(newIssueTokens(Arrays.asList(houseToken)));
8282
return"\nThe non-fungible house token is created with UUID: "+uuid +". (This is what you will use in next step)"
8383
+"\nTransaction ID: "+stx.getId();
8484

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp