Merge branch 'master' into tudor_merge_os_master

This commit is contained in:
tudor.malene@gmail.com
2018-10-02 15:50:20 +01:00
510 changed files with 10259 additions and 5920 deletions

View File

@ -3,15 +3,6 @@ apply plugin: 'application'
apply plugin: 'net.corda.plugins.cordformation'
apply plugin: 'net.corda.plugins.quasar-utils'
repositories {
mavenLocal()
mavenCentral()
jcenter()
maven {
url 'http://oss.sonatype.org/content/repositories/snapshots'
}
}
configurations {
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime

View File

@ -3,7 +3,7 @@ package net.corda.docs
import net.corda.client.rpc.CordaRPCClient
import net.corda.core.messaging.startFlow
import net.corda.core.utilities.getOrThrow
import net.corda.docs.tutorial.flowstatemachines.ExampleSummingFlow
import net.corda.docs.kotlin.tutorial.flowstatemachines.ExampleSummingFlow
import net.corda.node.services.Permissions
import net.corda.testing.core.ALICE_NAME
import net.corda.testing.driver.DriverParameters

View File

@ -1,8 +1,10 @@
// We purposefully have this template here as part of progressing through the tutorial
package com.template;
import net.corda.core.contracts.CommandData;
import net.corda.core.contracts.Contract;
import net.corda.core.transactions.LedgerTransaction;
import org.jetbrains.annotations.NotNull;
public class TemplateContract implements Contract {
// This is used to identify our contract when building a transaction.
@ -13,9 +15,9 @@ public class TemplateContract implements Contract {
* and output states does not throw an exception.
*/
@Override
public void verify(LedgerTransaction tx) {}
public void verify(@NotNull LedgerTransaction tx) {}
public interface Commands extends CommandData {
class Action implements Commands {}
}
}
}

View File

@ -1,20 +1,17 @@
package net.corda.docs;
package net.corda.docs.java;
// START 1
import net.corda.client.rpc.CordaRPCClient;
import net.corda.client.rpc.CordaRPCConnection;
import net.corda.core.messaging.CordaRPCOps;
import net.corda.core.utilities.NetworkHostAndPort;
import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.ExecutionException;
class ClientRpcExample {
private static final Logger logger = LoggerFactory.getLogger(ClientRpcExample.class);
class ExampleRpcClientJava {
private static final Logger logger = LoggerFactory.getLogger(ExampleRpcClient.class);
public static void main(String[] args) throws ActiveMQException, InterruptedException, ExecutionException {
public static void main(String[] args) {
if (args.length != 3) {
throw new IllegalArgumentException("Usage: TemplateClient <node address> <username> <password>");
}

View File

@ -1,4 +1,4 @@
package net.corda.docs;
package net.corda.docs.java;
import co.paralleluniverse.fibers.Suspendable;
import com.google.common.collect.ImmutableList;
@ -37,7 +37,7 @@ import static net.corda.core.contracts.ContractsDSL.requireThat;
import static net.corda.core.crypto.Crypto.generateKeyPair;
@SuppressWarnings("unused")
public class FlowCookbookJava {
public class FlowCookbook {
// ``InitiatorFlow`` is our first flow, and will communicate with
// ``ResponderFlow``, below.
// We mark ``InitiatorFlow`` as an ``InitiatingFlow``, allowing it to be

View File

@ -0,0 +1,133 @@
package net.corda.docs.java;
import co.paralleluniverse.fibers.Suspendable;
import net.corda.core.flows.*;
import net.corda.core.identity.Party;
@SuppressWarnings("ALL")
// DOCSTART LaunchSpaceshipFlow
@InitiatingFlow
class LaunchSpaceshipFlow extends FlowLogic<Void> {
@Suspendable
@Override
public Void call() throws FlowException {
boolean shouldLaunchSpaceship = receive(Boolean.class, getPresident()).unwrap(s -> s);
if (shouldLaunchSpaceship) {
launchSpaceship();
}
return null;
}
public void launchSpaceship() {
}
public Party getPresident() {
throw new AbstractMethodError();
}
}
@InitiatedBy(LaunchSpaceshipFlow.class)
@InitiatingFlow
class PresidentSpaceshipFlow extends FlowLogic<Void> {
private final Party launcher;
public PresidentSpaceshipFlow(Party launcher) {
this.launcher = launcher;
}
@Suspendable
@Override
public Void call() {
boolean needCoffee = true;
send(getSecretary(), needCoffee);
boolean shouldLaunchSpaceship = false;
send(launcher, shouldLaunchSpaceship);
return null;
}
public Party getSecretary() {
throw new AbstractMethodError();
}
}
@InitiatedBy(PresidentSpaceshipFlow.class)
class SecretaryFlow extends FlowLogic<Void> {
private final Party president;
public SecretaryFlow(Party president) {
this.president = president;
}
@Suspendable
@Override
public Void call() {
// ignore
return null;
}
}
// DOCEND LaunchSpaceshipFlow
@SuppressWarnings("ALL")
// DOCSTART LaunchSpaceshipFlowCorrect
@InitiatingFlow
class LaunchSpaceshipFlowCorrect extends FlowLogic<Void> {
@Suspendable
@Override
public Void call() throws FlowException {
FlowSession presidentSession = initiateFlow(getPresident());
boolean shouldLaunchSpaceship = presidentSession.receive(Boolean.class).unwrap(s -> s);
if (shouldLaunchSpaceship) {
launchSpaceship();
}
return null;
}
public void launchSpaceship() {
}
public Party getPresident() {
throw new AbstractMethodError();
}
}
@InitiatedBy(LaunchSpaceshipFlowCorrect.class)
@InitiatingFlow
class PresidentSpaceshipFlowCorrect extends FlowLogic<Void> {
private final FlowSession launcherSession;
public PresidentSpaceshipFlowCorrect(FlowSession launcherSession) {
this.launcherSession = launcherSession;
}
@Suspendable
@Override
public Void call() {
boolean needCoffee = true;
FlowSession secretarySession = initiateFlow(getSecretary());
secretarySession.send(needCoffee);
boolean shouldLaunchSpaceship = false;
launcherSession.send(shouldLaunchSpaceship);
return null;
}
public Party getSecretary() {
throw new AbstractMethodError();
}
}
@InitiatedBy(PresidentSpaceshipFlowCorrect.class)
class SecretaryFlowCorrect extends FlowLogic<Void> {
private final FlowSession presidentSession;
public SecretaryFlowCorrect(FlowSession presidentSession) {
this.presidentSession = presidentSession;
}
@Suspendable
@Override
public Void call() {
// ignore
return null;
}
}
// DOCEND LaunchSpaceshipFlowCorrect

View File

@ -4,6 +4,7 @@ import net.corda.core.flows.SignTransactionFlow;
import net.corda.core.utilities.ProgressTracker;
import org.jetbrains.annotations.Nullable;
@SuppressWarnings("ALL")
public class TutorialFlowStateMachines {
// DOCSTART 1
private final ProgressTracker progressTracker = new ProgressTracker(

View File

@ -1,6 +1,6 @@
@file:Suppress("unused")
package net.corda.docs
package net.corda.docs.kotlin
// START 1
import net.corda.client.rpc.CordaRPCClient
@ -8,9 +8,9 @@ import net.corda.core.utilities.NetworkHostAndPort.Companion.parse
import net.corda.core.utilities.loggerFor
import org.slf4j.Logger
class ExampleRpcClient {
class ClientRpcExample {
companion object {
val logger: Logger = loggerFor<ExampleRpcClient>()
val logger: Logger = loggerFor<ClientRpcExample>()
}
fun main(args: Array<String>) {

View File

@ -1,6 +1,6 @@
@file:Suppress("unused")
package net.corda.docs
package net.corda.docs.kotlin
import net.corda.client.rpc.CordaRPCClient
import net.corda.core.contracts.Amount

View File

@ -1,4 +1,6 @@
package net.corda.docs
@file:Suppress("unused", "MemberVisibilityCanBePrivate")
package net.corda.docs.kotlin
import co.paralleluniverse.fibers.Suspendable
import net.corda.core.contracts.Amount

View File

@ -1,6 +1,6 @@
@file:Suppress("UNUSED_VARIABLE", "unused", "DEPRECATION")
package net.corda.docs
package net.corda.docs.kotlin
import co.paralleluniverse.fibers.Suspendable
import net.corda.core.contracts.*

View File

@ -1,4 +1,4 @@
package net.corda.docs
package net.corda.docs.kotlin
import co.paralleluniverse.fibers.Suspendable
import net.corda.core.contracts.*

View File

@ -1,6 +1,6 @@
@file:Suppress("DEPRECATION")
@file:Suppress("DEPRECATION", "MemberVisibilityCanBePrivate", "unused")
package net.corda.docs
package net.corda.docs.kotlin
import co.paralleluniverse.fibers.Suspendable
import net.corda.core.flows.FlowLogic

View File

@ -1,4 +1,6 @@
package net.corda.docs
@file:Suppress("unused")
package net.corda.docs.kotlin
import co.paralleluniverse.fibers.Suspendable
import net.corda.core.contracts.*
@ -23,7 +25,7 @@ enum class WorkflowState {
REJECTED
}
const val TRADE_APPROVAL_PROGRAM_ID = "net.corda.docs.TradeApprovalContract"
const val TRADE_APPROVAL_PROGRAM_ID = "net.corda.docs.kotlin.TradeApprovalContract"
/**
* Minimal contract to encode a simple workflow with one initial state and two possible eventual states.

View File

@ -1,4 +1,4 @@
package net.corda.docs.tutorial.contract
package net.corda.docs.kotlin.tutorial.contract
import net.corda.core.contracts.*
import net.corda.core.crypto.NullKeys

View File

@ -1,4 +1,4 @@
package net.corda.docs.tutorial.flowstatemachines
package net.corda.docs.kotlin.tutorial.flowstatemachines
import co.paralleluniverse.fibers.Suspendable
import net.corda.core.concurrent.CordaFuture

View File

@ -1,4 +1,6 @@
package net.corda.docs.tutorial.flowstatemachines
@file:Suppress("unused", "MemberVisibilityCanBePrivate")
package net.corda.docs.kotlin.tutorial.flowstatemachines
import co.paralleluniverse.fibers.Suspendable
import net.corda.core.contracts.Amount

View File

@ -1,6 +1,9 @@
package net.corda.docs.tutorial.helloworld
@file:Suppress("MemberVisibilityCanBePrivate")
package net.corda.docs.kotlin.tutorial.helloworld
import co.paralleluniverse.fibers.Suspendable
import com.template.TemplateContract
import net.corda.core.flows.FinalityFlow
import net.corda.core.flows.FlowLogic
import net.corda.core.flows.InitiatingFlow
@ -13,6 +16,8 @@ import net.corda.core.identity.Party
import net.corda.core.transactions.TransactionBuilder
import net.corda.core.utilities.ProgressTracker
import com.template.TemplateContract.TEMPLATE_CONTRACT_ID
// Replace TemplateFlow's definition with:
@InitiatingFlow
@StartableByRPC
@ -44,4 +49,4 @@ class IOUFlow(val iouValue: Int,
subFlow(FinalityFlow(signedTx))
}
}
// DOCEND 01
// DOCEND 01

View File

@ -1,4 +1,4 @@
package net.corda.docs.tutorial.helloworld
package net.corda.docs.kotlin.tutorial.helloworld
import net.corda.core.contracts.ContractState

View File

@ -1,6 +1,6 @@
@file:Suppress("UNUSED_VARIABLE")
package net.corda.docs.tutorial.tearoffs
package net.corda.docs.kotlin.tutorial.tearoffs
import net.corda.core.contracts.Command
import net.corda.core.contracts.StateRef

View File

@ -1,4 +1,4 @@
package net.corda.docs.tutorial.twoparty
package net.corda.docs.kotlin.tutorial.twoparty
import net.corda.core.contracts.CommandData
import net.corda.core.contracts.Contract

View File

@ -1,4 +1,4 @@
package net.corda.docs.tutorial.twoparty
package net.corda.docs.kotlin.tutorial.twoparty
// DOCSTART 01
import co.paralleluniverse.fibers.Suspendable

View File

@ -1,12 +1,12 @@
package net.corda.docs.tutorial.twoparty
package net.corda.docs.kotlin.tutorial.twoparty
import co.paralleluniverse.fibers.Suspendable
import net.corda.core.flows.FlowLogic
import net.corda.core.flows.FlowSession
import net.corda.core.flows.InitiatedBy
import net.corda.core.flows.SignTransactionFlow
import net.corda.docs.tutorial.helloworld.IOUFlow
import net.corda.docs.tutorial.helloworld.IOUState
import net.corda.docs.kotlin.tutorial.helloworld.IOUFlow
import net.corda.docs.kotlin.tutorial.helloworld.IOUState
// DOCSTART 01
// Add these imports:

View File

@ -1,4 +1,4 @@
package net.corda.docs.tutorial.twoparty
package net.corda.docs.kotlin.tutorial.twoparty
import net.corda.core.contracts.ContractState
import net.corda.core.identity.Party

View File

@ -1,20 +0,0 @@
package net.corda.docs.tutorial.helloworld
import net.corda.core.contracts.CommandData
import net.corda.core.contracts.Contract
import net.corda.core.transactions.LedgerTransaction
const val TEMPLATE_CONTRACT_ID = "com.template.TemplateContract"
open class TemplateContract : Contract {
// A transaction is considered valid if the verify() function of the contract of each of the transaction's input
// and output states does not throw an exception.
override fun verify(tx: LedgerTransaction) {
// Verification logic goes here.
}
// Used to indicate the transaction's intent.
interface Commands : CommandData {
class Action : Commands
}
}

View File

@ -25,7 +25,7 @@ import static net.corda.testing.node.MockServicesKt.makeTestIdentityService;
import static net.corda.testing.node.NodeTestUtils.ledger;
import static net.corda.testing.node.NodeTestUtils.transaction;
public class CommercialPaperTest {
public class TutorialTestDSL {
private static final TestIdentity alice = new TestIdentity(ALICE_NAME, 70L);
// DOCSTART 14
private static final TestIdentity bigCorp = new TestIdentity(new CordaX500Name("BigCorp", "New York", "GB"));

View File

@ -4,20 +4,12 @@ import net.corda.core.contracts.Amount
import net.corda.core.contracts.ContractState
import net.corda.core.identity.Party
import net.corda.core.node.services.queryBy
import net.corda.core.node.services.vault.DEFAULT_PAGE_NUM
import net.corda.core.node.services.vault.DEFAULT_PAGE_SIZE
import net.corda.core.node.services.vault.PageSpecification
import net.corda.core.node.services.vault.QueryCriteria
import net.corda.core.node.services.vault.builder
import net.corda.core.node.services.vault.*
import net.corda.core.utilities.OpaqueBytes
import net.corda.core.utilities.getOrThrow
import net.corda.docs.java.tutorial.helloworld.IOUFlow
import net.corda.finance.CHF
import net.corda.finance.DOLLARS
import net.corda.finance.GBP
import net.corda.finance.POUNDS
import net.corda.finance.SWISS_FRANCS
import net.corda.finance.USD
import net.corda.docs.kotlin.TopupIssuerFlow
import net.corda.finance.*
import net.corda.finance.contracts.getCashBalances
import net.corda.finance.flows.CashIssueFlow
import net.corda.node.services.vault.VaultSchemaV1
@ -112,4 +104,4 @@ class CustomVaultQueryTest {
return Pair(balancesNodesA, balancesNodesB)
}
}
}

View File

@ -4,6 +4,8 @@ import net.corda.core.identity.Party
import net.corda.core.toFuture
import net.corda.core.utilities.OpaqueBytes
import net.corda.core.utilities.getOrThrow
import net.corda.docs.kotlin.ForeignExchangeFlow
import net.corda.docs.kotlin.ForeignExchangeRemoteFlow
import net.corda.finance.DOLLARS
import net.corda.finance.GBP
import net.corda.finance.POUNDS

View File

@ -9,6 +9,10 @@ import net.corda.core.node.services.queryBy
import net.corda.core.node.services.vault.QueryCriteria
import net.corda.core.toFuture
import net.corda.core.utilities.getOrThrow
import net.corda.docs.kotlin.SubmitCompletionFlow
import net.corda.docs.kotlin.SubmitTradeApprovalFlow
import net.corda.docs.kotlin.TradeApprovalContract
import net.corda.docs.kotlin.WorkflowState
import net.corda.testing.core.ALICE_NAME
import net.corda.testing.core.BOB_NAME
import net.corda.testing.node.MockNetwork

View File

@ -1,4 +1,6 @@
package net.corda.docs.tutorial.testdsl
@file:Suppress("MemberVisibilityCanBePrivate")
package net.corda.docs.kotlin.tutorial.testdsl
import com.nhaarman.mockito_kotlin.doReturn
import com.nhaarman.mockito_kotlin.whenever
@ -13,11 +15,7 @@ import net.corda.finance.contracts.CommercialPaper
import net.corda.finance.contracts.ICommercialPaperState
import net.corda.finance.contracts.asset.CASH
import net.corda.finance.contracts.asset.Cash
import net.corda.testing.core.ALICE_NAME
import net.corda.testing.core.BOB_NAME
import net.corda.testing.core.DUMMY_NOTARY_NAME
import net.corda.testing.core.SerializationEnvironmentRule
import net.corda.testing.core.TestIdentity
import net.corda.testing.core.*
import net.corda.testing.internal.rigorousMock
import net.corda.testing.node.MockServices
import net.corda.testing.node.ledger
@ -26,7 +24,7 @@ import org.junit.Rule
import org.junit.Test
import java.time.Instant
class CommercialPaperTest {
class TutorialTestDSL {
private companion object {
val alice = TestIdentity(ALICE_NAME, 70)
val bob = TestIdentity(BOB_NAME, 80)