|
8 | 8 | import com.r3.corda.lib.tokens.contracts.types.TokenType; |
9 | 9 | import com.r3.corda.lib.tokens.contracts.utilities.TransactionUtilitiesKt; |
10 | 10 | import com.r3.corda.lib.tokens.workflows.flows.rpc.*; |
| 11 | +import com.r3.corda.lib.tokens.workflows.utilities.FungibleTokenBuilder; |
11 | 12 | import net.corda.examples.tokenizedhouse.states.FungibleHouseTokenState; |
12 | 13 | import kotlin.Unit; |
13 | 14 | import net.corda.core.contracts.*; |
@@ -52,7 +53,7 @@ public SignedTransaction call() throws FlowException { |
52 | 53 | new UniqueIdentifier(), 0, this.symbol); |
53 | 54 |
|
54 | 55 | //wrap it with transaction state specifying the notary |
55 | | - TransactionState transactionState = new TransactionState(evolvableTokenType, notary); |
| 56 | + TransactionState<FungibleHouseTokenState> transactionState = new TransactionState<>(evolvableTokenType, notary); |
56 | 57 |
|
57 | 58 | //call built in sub flow CreateEvolvableTokens. This can be called via rpc or in unit testing |
58 | 59 | return subFlow(new CreateEvolvableTokens(transactionState)); |
@@ -86,17 +87,13 @@ public SignedTransaction call() throws FlowException { |
86 | 87 | //get the RealEstateEvolvableTokenType object |
87 | 88 | FungibleHouseTokenState evolvableTokenType = stateAndRef.getState().getData(); |
88 | 89 |
|
89 | | - //get the pointer pointer to the house |
90 | | - TokenPointer tokenPointer = evolvableTokenType.toPointer(evolvableTokenType.getClass()); |
91 | | - |
92 | | - //assign the issuer to the house type who will be issuing the tokens |
93 | | - IssuedTokenType issuedTokenType = new IssuedTokenType(getOurIdentity(), tokenPointer); |
94 | | - |
95 | | - //specify how much amount to issue to holder |
96 | | - Amount<IssuedTokenType> amount = new Amount(quantity, issuedTokenType); |
97 | | - |
98 | | - //create fungible amount specifying the new owner |
99 | | - FungibleToken fungibleToken = new FungibleToken(amount, holder, TransactionUtilitiesKt.getAttachmentIdForGenericParam(tokenPointer)); |
| 90 | + //create fungible token for the house token type |
| 91 | + FungibleToken fungibleToken = new FungibleTokenBuilder() |
| 92 | + .ofTokenType(evolvableTokenType.toPointer(FungibleHouseTokenState.class)) // get the token pointer |
| 93 | + .issuedBy(getOurIdentity()) |
| 94 | + .heldBy(holder) |
| 95 | + .withAmount(quantity) |
| 96 | + .buildFungibleToken(); |
100 | 97 |
|
101 | 98 | //use built in flow for issuing tokens on ledger |
102 | 99 | return subFlow(new IssueTokens(ImmutableList.of(fungibleToken))); |
@@ -131,11 +128,8 @@ public SignedTransaction call() throws FlowException { |
131 | 128 | //get the RealEstateEvolvableTokenType object |
132 | 129 | FungibleHouseTokenState tokenstate = stateAndRef.getState().getData(); |
133 | 130 |
|
134 | | - //get the pointer pointer to the house |
135 | | - TokenPointer<FungibleHouseTokenState> tokenPointer = tokenstate.toPointer(FungibleHouseTokenState.class); |
136 | | - |
137 | 131 | //specify how much amount to transfer to which holder |
138 | | - Amount<TokenType> amount = new Amount(quantity, tokenPointer); |
| 132 | + Amount<TokenType> amount = new Amount<>(quantity, tokenstate.toPointer(FungibleHouseTokenState.class)); |
139 | 133 | //PartyAndAmount partyAndAmount = new PartyAndAmount(holder, amount); |
140 | 134 |
|
141 | 135 | //use built in flow to move fungible tokens to holder |
@@ -191,11 +185,9 @@ public Unit call() throws FlowException { |
191 | 185 | // //get the RealEstateEvolvableTokenType object |
192 | 186 | // FungibleHouseTokenState evolvableTokenType = stateAndRef.getState().getData(); |
193 | 187 | // |
194 | | -// //get the pointer pointer to the house |
195 | | -// TokenPointer tokenPointer = evolvableTokenType.toPointer(evolvableTokenType.getClass()); |
196 | | -// |
197 | 188 | // //specify how much amount quantity of tokens of type token parameter |
198 | | -// Amount amount = new Amount(quantity, tokenPointer); |
| 189 | +// Amount<TokenType> amount = |
| 190 | +// new Amount<>(quantity, evolvableTokenType.toPointer(FungibleHouseTokenState.class)); |
199 | 191 | // |
200 | 192 | // //call built in redeem flow to redeem tokens with issuer |
201 | 193 | // return subFlow(new RedeemFungibleTokens(amount, issuer)); |
|
0 commit comments