mirror of
https://github.com/corda/corda.git
synced 2024-12-18 20:47:57 +00:00
Minor: auto-format of module: samples
This commit is contained in:
parent
eec8b9e4da
commit
9948815df1
@ -52,14 +52,14 @@ dependencies {
|
||||
}
|
||||
|
||||
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
|
||||
ext.rpcUsers = [ ['username' : "demo", 'password' : "demo", 'permissions' : ["StartFlow.net.corda.flows.FinalityFlow"]] ]
|
||||
ext.rpcUsers = [['username': "demo", 'password': "demo", 'permissions': ["StartFlow.net.corda.flows.FinalityFlow"]]]
|
||||
|
||||
directory "./build/nodes"
|
||||
networkMap "Controller"
|
||||
node {
|
||||
name "Controller"
|
||||
nearestCity "London"
|
||||
advertisedServices ["corda.notary.validating"]
|
||||
advertisedServices["corda.notary.validating"]
|
||||
p2pPort 10002
|
||||
rpcPort 10003
|
||||
cordapps = []
|
||||
|
@ -25,9 +25,9 @@ class AttachmentDemoTest {
|
||||
driver(dsl = {
|
||||
val demoUser = listOf(User("demo", "demo", setOf("StartFlow.net.corda.flows.FinalityFlow")))
|
||||
val (nodeA, nodeB) = Futures.allAsList(
|
||||
startNode("Bank A", rpcUsers = demoUser),
|
||||
startNode("Bank B", rpcUsers = demoUser),
|
||||
startNode("Notary", setOf(ServiceInfo(SimpleNotaryService.Companion.type)))
|
||||
startNode("Bank A", rpcUsers = demoUser),
|
||||
startNode("Bank B", rpcUsers = demoUser),
|
||||
startNode("Notary", setOf(ServiceInfo(SimpleNotaryService.Companion.type)))
|
||||
).getOrThrow()
|
||||
|
||||
val senderThread = CompletableFuture.supplyAsync {
|
||||
@ -36,7 +36,7 @@ class AttachmentDemoTest {
|
||||
}
|
||||
}.exceptionally { it.printStackTrace() }
|
||||
|
||||
val recipientThread = CompletableFuture.supplyAsync{
|
||||
val recipientThread = CompletableFuture.supplyAsync {
|
||||
nodeB.rpcClientToNode().use(demoUser[0].username, demoUser[0].password) {
|
||||
recipient(this)
|
||||
}
|
||||
|
@ -10,16 +10,16 @@ import net.corda.core.div
|
||||
import net.corda.core.getOrThrow
|
||||
import net.corda.core.messaging.CordaRPCOps
|
||||
import net.corda.core.messaging.startFlow
|
||||
import net.corda.core.sizedInputStreamAndHash
|
||||
import net.corda.core.utilities.Emoji
|
||||
import net.corda.flows.FinalityFlow
|
||||
import net.corda.nodeapi.config.SSLConfiguration
|
||||
import net.corda.testing.ALICE_KEY
|
||||
import java.io.InputStream
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import kotlin.system.exitProcess
|
||||
import kotlin.test.assertEquals
|
||||
import java.io.*
|
||||
import net.corda.core.sizedInputStreamAndHash
|
||||
|
||||
internal enum class Role {
|
||||
SENDER,
|
||||
|
@ -70,10 +70,10 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
|
||||
webPort 10007
|
||||
cordapps = []
|
||||
rpcUsers = [
|
||||
['username' : "bankUser",
|
||||
'password' : "test",
|
||||
'permissions' : ["StartFlow.net.corda.flows.CashPaymentFlow",
|
||||
"StartFlow.net.corda.flows.IssuerFlow\$IssuanceRequester"]]
|
||||
['username' : "bankUser",
|
||||
'password' : "test",
|
||||
'permissions': ["StartFlow.net.corda.flows.CashPaymentFlow",
|
||||
"StartFlow.net.corda.flows.IssuerFlow\$IssuanceRequester"]]
|
||||
]
|
||||
}
|
||||
node {
|
||||
@ -85,9 +85,9 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
|
||||
webPort 10010
|
||||
cordapps = []
|
||||
rpcUsers = [
|
||||
['username' : "bigCorpUser",
|
||||
'password' : "test",
|
||||
'permissions' : ["StartFlow.net.corda.flows.CashPaymentFlow"]]
|
||||
['username' : "bigCorpUser",
|
||||
'password' : "test",
|
||||
'permissions': ["StartFlow.net.corda.flows.CashPaymentFlow"]]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ class BankOfCordaHttpAPITest {
|
||||
fun `issuer flow via Http`() {
|
||||
driver(dsl = {
|
||||
val (nodeBankOfCorda) = Futures.allAsList(
|
||||
startNode("BankOfCorda", setOf(ServiceInfo(SimpleNotaryService.type))),
|
||||
startNode("BigCorporation")
|
||||
startNode("BankOfCorda", setOf(ServiceInfo(SimpleNotaryService.type))),
|
||||
startNode("BigCorporation")
|
||||
).getOrThrow()
|
||||
val nodeBankOfCordaApiAddr = startWebserver(nodeBankOfCorda).getOrThrow()
|
||||
assert(BankOfCordaClientApi(nodeBankOfCordaApiAddr).requestWebIssue(IssueRequestParams(1000, "USD", "BigCorporation", "1", "BankOfCorda")))
|
||||
|
@ -4,11 +4,11 @@ import com.google.common.net.HostAndPort
|
||||
import joptsimple.OptionParser
|
||||
import net.corda.bank.api.BankOfCordaClientApi
|
||||
import net.corda.bank.api.BankOfCordaWebApi.IssueRequestParams
|
||||
import net.corda.flows.IssuerFlow
|
||||
import net.corda.core.node.services.ServiceInfo
|
||||
import net.corda.core.node.services.ServiceType
|
||||
import net.corda.core.transactions.SignedTransaction
|
||||
import net.corda.flows.CashPaymentFlow
|
||||
import net.corda.flows.IssuerFlow
|
||||
import net.corda.node.driver.driver
|
||||
import net.corda.node.services.startFlowPermission
|
||||
import net.corda.node.services.transactions.SimpleNotaryService
|
||||
@ -59,8 +59,7 @@ private class BankOfCordaDriver {
|
||||
startWebserver(bankOfCorda.get())
|
||||
waitForAllNodesToFinish()
|
||||
}, isDebug = true)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
try {
|
||||
val requestParams = IssueRequestParams(options.valueOf(quantity), options.valueOf(currency), "BigCorporation", "1", "BankOfCorda")
|
||||
when (role) {
|
||||
@ -76,10 +75,10 @@ private class BankOfCordaDriver {
|
||||
if (result)
|
||||
println("Successfully processed Cash Issue request")
|
||||
}
|
||||
Role.ISSUER -> {}
|
||||
Role.ISSUER -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e: Exception) {
|
||||
} catch (e: Exception) {
|
||||
println("Exception occurred: $e \n ${e.printStackTrace()}")
|
||||
exitProcess(1)
|
||||
}
|
||||
|
@ -20,15 +20,18 @@ class BankOfCordaWebApi(val rpc: CordaRPCOps) {
|
||||
data class IssueRequestParams(val amount: Long, val currency: String,
|
||||
val issueToPartyName: String, val issueToPartyRefAsString: String,
|
||||
val issuerBankName: String)
|
||||
|
||||
private companion object {
|
||||
val logger = loggerFor<BankOfCordaWebApi>()
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("date")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
fun getCurrentDate(): Any {
|
||||
return mapOf("date" to LocalDateTime.now().toLocalDate())
|
||||
}
|
||||
|
||||
/**
|
||||
* Request asset issuance
|
||||
*/
|
||||
|
@ -1,11 +1,11 @@
|
||||
package net.corda.bank.plugin
|
||||
|
||||
import net.corda.bank.api.BankOfCordaWebApi
|
||||
import net.corda.flows.IssuerFlow
|
||||
import net.corda.core.contracts.Amount
|
||||
import net.corda.core.crypto.Party
|
||||
import net.corda.core.node.CordaPluginRegistry
|
||||
import net.corda.core.serialization.OpaqueBytes
|
||||
import net.corda.flows.IssuerFlow
|
||||
import java.util.function.Function
|
||||
|
||||
class BankOfCordaPlugin : CordaPluginRegistry() {
|
||||
@ -13,7 +13,7 @@ class BankOfCordaPlugin : CordaPluginRegistry() {
|
||||
override val webApis = listOf(Function(::BankOfCordaWebApi))
|
||||
// A list of flow that are required for this cordapp
|
||||
override val requiredFlows: Map<String, Set<String>> =
|
||||
mapOf(IssuerFlow.IssuanceRequester::class.java.name to setOf(Amount::class.java.name, Party::class.java.name, OpaqueBytes::class.java.name, Party::class.java.name)
|
||||
)
|
||||
mapOf(IssuerFlow.IssuanceRequester::class.java.name to setOf(Amount::class.java.name, Party::class.java.name, OpaqueBytes::class.java.name, Party::class.java.name)
|
||||
)
|
||||
override val servicePlugins = listOf(Function(IssuerFlow.Issuer::Service))
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.corda.irs.api
|
||||
|
||||
import net.corda.core.contracts.filterStatesOfType
|
||||
import net.corda.core.crypto.AnonymousParty
|
||||
import net.corda.core.crypto.Party
|
||||
import net.corda.core.getOrThrow
|
||||
import net.corda.core.messaging.CordaRPCOps
|
||||
|
@ -213,6 +213,7 @@ object NodeInterestRates {
|
||||
else -> throw IllegalArgumentException("Oracle received data of different type than expected.")
|
||||
}
|
||||
}
|
||||
|
||||
val leaves = ftx.filteredLeaves
|
||||
if (!leaves.checkWithFun(::check))
|
||||
throw IllegalArgumentException()
|
||||
|
@ -304,7 +304,7 @@ class InterestRateSwap : Contract {
|
||||
}
|
||||
|
||||
@CordaSerializable
|
||||
open class FixedLeg<P: AbstractParty>(
|
||||
open class FixedLeg<P : AbstractParty>(
|
||||
var fixedRatePayer: P,
|
||||
notional: Amount<Currency>,
|
||||
paymentFrequency: Frequency,
|
||||
@ -362,6 +362,7 @@ class InterestRateSwap : Contract {
|
||||
fixedRatePayer, notional, paymentFrequency, effectiveDate, effectiveDateAdjustment, terminationDate,
|
||||
terminationDateAdjustment, dayCountBasisDay, dayCountBasisYear, dayInMonth, paymentRule, paymentDelay,
|
||||
paymentCalendar, interestPeriodAdjustment, fixedRate, rollConvention)
|
||||
|
||||
fun toAnonymous(): FixedLeg<AnonymousParty> {
|
||||
return FixedLeg(fixedRatePayer.toAnonymous(), notional, paymentFrequency, effectiveDate, effectiveDateAdjustment, terminationDate, terminationDateAdjustment,
|
||||
dayCountBasisDay, dayCountBasisYear, dayInMonth, paymentRule, paymentDelay, paymentCalendar, interestPeriodAdjustment,
|
||||
@ -370,7 +371,7 @@ class InterestRateSwap : Contract {
|
||||
}
|
||||
|
||||
@CordaSerializable
|
||||
open class FloatingLeg<P: AbstractParty>(
|
||||
open class FloatingLeg<P : AbstractParty>(
|
||||
var floatingRatePayer: P,
|
||||
notional: Amount<Currency>,
|
||||
paymentFrequency: Frequency,
|
||||
@ -458,6 +459,7 @@ class InterestRateSwap : Contract {
|
||||
paymentRule, paymentDelay, paymentCalendar, interestPeriodAdjustment, rollConvention,
|
||||
fixingRollConvention, resetDayInMonth, fixingPeriod, resetRule, fixingsPerPayment,
|
||||
fixingCalendar, index, indexSource, indexTenor)
|
||||
|
||||
fun toAnonymous(): FloatingLeg<AnonymousParty> {
|
||||
return FloatingLeg(floatingRatePayer.toAnonymous(), notional, paymentFrequency, effectiveDate, effectiveDateAdjustment, terminationDate, terminationDateAdjustment,
|
||||
dayCountBasisDay, dayCountBasisYear, dayInMonth, paymentRule, paymentDelay, paymentCalendar, interestPeriodAdjustment,
|
||||
@ -662,7 +664,7 @@ class InterestRateSwap : Contract {
|
||||
/**
|
||||
* The state class contains the 4 major data classes.
|
||||
*/
|
||||
data class State<P: AbstractParty>(
|
||||
data class State<P : AbstractParty>(
|
||||
val fixedLeg: FixedLeg<P>,
|
||||
val floatingLeg: FloatingLeg<P>,
|
||||
val calculation: Calculation,
|
||||
|
@ -73,7 +73,7 @@ object AutoOfferFlow {
|
||||
return stx
|
||||
}
|
||||
|
||||
private fun <T: AbstractParty> notUs(parties: List<T>): List<T> {
|
||||
private fun <T : AbstractParty> notUs(parties: List<T>): List<T> {
|
||||
val notUsParties: MutableList<T> = arrayListOf()
|
||||
for (party in parties) {
|
||||
if (serviceHub.myInfo.legalIdentity != party) {
|
||||
|
@ -135,7 +135,7 @@ object FixingFlow {
|
||||
* TODO: Replace [FixingSession] and [FixingSessionInitiationHandler] with generic session initiation logic once it exists.
|
||||
*/
|
||||
class FixingRoleDecider(val ref: StateRef, override val progressTracker: ProgressTracker) : FlowLogic<Unit>() {
|
||||
@Suppress("unused") // Used via reflection.
|
||||
@Suppress("unused") // Used via reflection.
|
||||
constructor(ref: StateRef) : this(ref, tracker())
|
||||
|
||||
companion object {
|
||||
|
@ -136,6 +136,7 @@ class NodeInterestRatesTest {
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
val ftx1 = wtx1.buildFilteredTransaction(::filterAllOutputs)
|
||||
assertFailsWith<IllegalArgumentException> { oracle.sign(ftx1) }
|
||||
tx.addCommand(Cash.Commands.Move(), ALICE_PUBKEY)
|
||||
@ -231,10 +232,10 @@ class NodeInterestRatesTest {
|
||||
rateTolerance: BigDecimal,
|
||||
progressTracker: ProgressTracker = RatesFixFlow.tracker(fixOf.name)) : RatesFixFlow(tx, oracle, fixOf, expectedRate, rateTolerance, progressTracker) {
|
||||
override fun filtering(elem: Any): Boolean {
|
||||
return when (elem) {
|
||||
is Command -> oracle.owningKey in elem.signers && elem.value is Fix
|
||||
else -> false
|
||||
}
|
||||
return when (elem) {
|
||||
is Command -> oracle.owningKey in elem.signers && elem.value is Fix
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ class DummyIssueAndMove(private val notary: Party, private val counterpartyNode:
|
||||
val moveTx = DummyContract.move(asset, counterPartyKey).apply {
|
||||
signWith(myKeyPair)
|
||||
}
|
||||
// We don't check signatures because we know that the notary's signature is missing
|
||||
// We don't check signatures because we know that the notary's signature is missing
|
||||
return moveTx.toSignedTransaction(checkSufficientSignatures = false)
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ object SimmFlow {
|
||||
class Requester(val otherParty: Party,
|
||||
val valuationDate: LocalDate,
|
||||
val existing: StateAndRef<PortfolioState>?)
|
||||
: FlowLogic<RevisionedState<PortfolioState.Update>>() {
|
||||
: FlowLogic<RevisionedState<PortfolioState.Update>>() {
|
||||
constructor(otherParty: Party, valuationDate: LocalDate) : this(otherParty, valuationDate, null)
|
||||
|
||||
lateinit var myIdentity: Party
|
||||
|
@ -20,7 +20,7 @@ object SimmRevaluation {
|
||||
val myIdentity = serviceHub.myInfo.legalIdentity.toAnonymous()
|
||||
if (myIdentity == curState.parties[0]) {
|
||||
val otherParty = serviceHub.identityService.partyFromAnonymous(curState.parties[1])
|
||||
require (otherParty != null) { "Other party must be known by this node" }
|
||||
require(otherParty != null) { "Other party must be known by this node" }
|
||||
subFlow(SimmFlow.Requester(otherParty!!, valuationDate, stateAndRef))
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
package net.corda.traderdemo
|
||||
|
||||
import net.corda.flows.IssuerFlow
|
||||
import net.corda.core.div
|
||||
import net.corda.core.node.services.ServiceInfo
|
||||
import net.corda.flows.IssuerFlow
|
||||
import net.corda.node.driver.driver
|
||||
import net.corda.node.services.startFlowPermission
|
||||
import net.corda.node.services.transactions.SimpleNotaryService
|
||||
import net.corda.nodeapi.User
|
||||
import net.corda.testing.BOC
|
||||
import java.nio.file.Paths
|
||||
import net.corda.core.div
|
||||
import net.corda.nodeapi.User
|
||||
|
||||
/**
|
||||
* This file is exclusively for being able to run your nodes through an IDE (as opposed to running deployNodes)
|
||||
|
@ -4,7 +4,6 @@ import com.google.common.util.concurrent.Futures
|
||||
import net.corda.contracts.testing.calculateRandomlySizedAmounts
|
||||
import net.corda.core.contracts.Amount
|
||||
import net.corda.core.contracts.DOLLARS
|
||||
import net.corda.core.contracts.Issued
|
||||
import net.corda.core.getOrThrow
|
||||
import net.corda.core.messaging.CordaRPCOps
|
||||
import net.corda.core.messaging.startFlow
|
||||
|
Loading…
Reference in New Issue
Block a user