This repository has been archived by the owner on Feb 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from LayerXcom/cross-chian-atomic-swap/use-tok…
…en-sdk Use Token SDK in a sample cordapp of cross-chain atomic swap
- Loading branch information
Showing
39 changed files
with
560 additions
and
2,082 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...c/main/kotlin/jp/co/layerx/cordage/crosschainatomicswap/contract/CorporateBondContract.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package jp.co.layerx.cordage.crosschainatomicswap.contract | ||
|
||
import com.r3.corda.lib.tokens.contracts.EvolvableTokenContract | ||
import net.corda.core.contracts.Contract | ||
import net.corda.core.transactions.LedgerTransaction | ||
|
||
class CorporateBondContract: EvolvableTokenContract(), Contract { | ||
override fun additionalCreateChecks(tx: LedgerTransaction) { | ||
} | ||
|
||
override fun additionalUpdateChecks(tx: LedgerTransaction) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 0 additions & 71 deletions
71
...pp/src/main/kotlin/jp/co/layerx/cordage/crosschainatomicswap/contract/SecurityContract.kt
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
.../src/main/kotlin/jp/co/layerx/cordage/crosschainatomicswap/flow/CorporateBondIssueFlow.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package jp.co.layerx.cordage.crosschainatomicswap.flow | ||
|
||
import co.paralleluniverse.fibers.Suspendable | ||
import com.r3.corda.lib.tokens.contracts.utilities.heldBy | ||
import com.r3.corda.lib.tokens.contracts.utilities.issuedBy | ||
import com.r3.corda.lib.tokens.workflows.flows.rpc.IssueTokens | ||
import jp.co.layerx.cordage.crosschainatomicswap.state.CorporateBond | ||
import net.corda.core.contracts.Amount | ||
import net.corda.core.contracts.UniqueIdentifier | ||
import net.corda.core.flows.FlowLogic | ||
import net.corda.core.flows.StartableByRPC | ||
import net.corda.core.identity.Party | ||
import net.corda.core.node.services.queryBy | ||
import net.corda.core.node.services.vault.QueryCriteria | ||
import net.corda.core.transactions.SignedTransaction | ||
|
||
@StartableByRPC | ||
class CorporateBondIssueFlow( | ||
private val linearId: UniqueIdentifier, | ||
private val quantity: Long, | ||
private val holder: Party | ||
) : FlowLogic<SignedTransaction>() { | ||
|
||
@Suspendable | ||
override fun call(): SignedTransaction { | ||
val criteria = QueryCriteria.LinearStateQueryCriteria(linearId = listOf(linearId)) | ||
val corporateBond = serviceHub.vaultService.queryBy<CorporateBond>(criteria).states.single().state.data | ||
val tokenPointer = corporateBond.toPointer<CorporateBond>() | ||
val corporateBondToken = Amount(quantity, tokenPointer issuedBy ourIdentity) heldBy holder | ||
return subFlow(IssueTokens(listOf(corporateBondToken))) | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...c/main/kotlin/jp/co/layerx/cordage/crosschainatomicswap/flow/CorporateBondRegisterFlow.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package jp.co.layerx.cordage.crosschainatomicswap.flow | ||
|
||
import co.paralleluniverse.fibers.Suspendable | ||
import com.r3.corda.lib.tokens.workflows.flows.rpc.CreateEvolvableTokens | ||
import jp.co.layerx.cordage.crosschainatomicswap.state.CorporateBond | ||
import net.corda.core.contracts.TransactionState | ||
import net.corda.core.flows.FlowLogic | ||
import net.corda.core.flows.StartableByRPC | ||
import net.corda.core.identity.Party | ||
import net.corda.core.transactions.SignedTransaction | ||
import java.math.BigDecimal | ||
|
||
@StartableByRPC | ||
class CorporateBondRegisterFlow( | ||
private val name: String, | ||
private val unitPriceEther: BigDecimal, | ||
private val observer: Party | ||
) : FlowLogic<SignedTransaction>() { | ||
|
||
@Suspendable | ||
override fun call(): SignedTransaction { | ||
val corporateBond = CorporateBond(name, unitPriceEther, listOf(ourIdentity)) | ||
return subFlow(CreateEvolvableTokens(TransactionState( | ||
data = corporateBond, | ||
notary = serviceHub.networkMapCache.notaryIdentities.first() | ||
), listOf(observer))) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.