mirror of
https://github.com/corda/corda.git
synced 2025-06-22 17:09:00 +00:00
@ -10,6 +10,10 @@ apply plugin: QuasarPlugin
|
|||||||
allprojects {
|
allprojects {
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.8
|
||||||
targetCompatibility = 1.8
|
targetCompatibility = 1.8
|
||||||
|
|
||||||
|
tasks.withType(JavaCompile) {
|
||||||
|
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
|
@ -229,7 +229,7 @@ public class JavaCommercialPaper implements Contract {
|
|||||||
return SecureHash.sha256("https://en.wikipedia.org/wiki/Commercial_paper");
|
return SecureHash.sha256("https://en.wikipedia.org/wiki/Commercial_paper");
|
||||||
}
|
}
|
||||||
|
|
||||||
public TransactionBuilder generateIssue(@NotNull PartyAndReference issuance, @NotNull Amount faceValue, @Nullable Instant maturityDate, @NotNull Party notary) {
|
public TransactionBuilder generateIssue(@NotNull PartyAndReference issuance, @NotNull Amount<Issued<Currency>> faceValue, @Nullable Instant maturityDate, @NotNull Party notary) {
|
||||||
State state = new State(issuance, issuance.getParty().getOwningKey(), faceValue, maturityDate);
|
State state = new State(issuance, issuance.getParty().getOwningKey(), faceValue, maturityDate);
|
||||||
TransactionState output = new TransactionState<>(state, notary);
|
TransactionState output = new TransactionState<>(state, notary);
|
||||||
return new TransactionType.General.Builder().withItems(output, new Command(new Commands.Issue(), issuance.getParty().getOwningKey()));
|
return new TransactionType.General.Builder().withItems(output, new Command(new Commands.Issue(), issuance.getParty().getOwningKey()));
|
||||||
|
@ -172,7 +172,7 @@ class Cash : FungibleAsset<Currency>() {
|
|||||||
val keysUsed = gathered.map { it.state.data.owner }.toSet()
|
val keysUsed = gathered.map { it.state.data.owner }.toSet()
|
||||||
|
|
||||||
val states = gathered.groupBy { it.state.data.deposit }.map {
|
val states = gathered.groupBy { it.state.data.deposit }.map {
|
||||||
val (deposit, coins) = it
|
val coins = it.value
|
||||||
val totalAmount = coins.map { it.state.data.amount }.sumOrThrow()
|
val totalAmount = coins.map { it.state.data.amount }.sumOrThrow()
|
||||||
TransactionState(State(totalAmount, to), coins.first().state.notary)
|
TransactionState(State(totalAmount, to), coins.first().state.notary)
|
||||||
}
|
}
|
||||||
|
@ -385,7 +385,7 @@ class CashTests {
|
|||||||
makeCash(80.SWISS_FRANCS, MINI_CORP, 2)
|
makeCash(80.SWISS_FRANCS, MINI_CORP, 2)
|
||||||
)
|
)
|
||||||
|
|
||||||
fun makeSpend(amount: Amount<Currency>, dest: PublicKey, corp: Party, depositRef: OpaqueBytes = defaultRef): WireTransaction {
|
fun makeSpend(amount: Amount<Currency>, dest: PublicKey, @Suppress("UNUSED_PARAMETER") corp: Party, @Suppress("UNUSED_PARAMETER") depositRef: OpaqueBytes = defaultRef): WireTransaction {
|
||||||
val tx = TransactionType.General.Builder()
|
val tx = TransactionType.General.Builder()
|
||||||
Cash().generateSpend(tx, amount, dest, WALLET)
|
Cash().generateSpend(tx, amount, dest, WALLET)
|
||||||
return tx.toWireTransaction()
|
return tx.toWireTransaction()
|
||||||
@ -516,8 +516,8 @@ class CashTests {
|
|||||||
Cash.State(4000.DOLLARS `issued by` defaultIssuer, MEGA_CORP_PUBKEY)
|
Cash.State(4000.DOLLARS `issued by` defaultIssuer, MEGA_CORP_PUBKEY)
|
||||||
)
|
)
|
||||||
// Test that summing everything produces the total number of dollars
|
// Test that summing everything produces the total number of dollars
|
||||||
var expected = 7000.DOLLARS `issued by` defaultIssuer
|
val expected = 7000.DOLLARS `issued by` defaultIssuer
|
||||||
var actual = states.sumCash()
|
val actual = states.sumCash()
|
||||||
assertEquals(expected, actual)
|
assertEquals(expected, actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,12 +212,12 @@ inline fun <T> Kryo.useClassLoader(cl: ClassLoader, body: () -> T) : T {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun Output.writeBytesWithLength(byteArray: ByteArray) {
|
fun Output.writeBytesWithLength(byteArray: ByteArray) {
|
||||||
this.writeInt(byteArray.size, true)
|
this.writeInt(byteArray.size, true)
|
||||||
this.writeBytes(byteArray)
|
this.writeBytes(byteArray)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun Input.readBytesWithLength(): ByteArray {
|
fun Input.readBytesWithLength(): ByteArray {
|
||||||
val size = this.readInt(true)
|
val size = this.readInt(true)
|
||||||
return this.readBytes(size)
|
return this.readBytes(size)
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package com.r3corda.core.serialization
|
|||||||
import com.google.common.primitives.Ints
|
import com.google.common.primitives.Ints
|
||||||
import com.r3corda.core.crypto.generateKeyPair
|
import com.r3corda.core.crypto.generateKeyPair
|
||||||
import com.r3corda.core.crypto.signWithECDSA
|
import com.r3corda.core.crypto.signWithECDSA
|
||||||
import com.r3corda.core.crypto.verifyWithECDSA
|
|
||||||
import org.assertj.core.api.Assertions.assertThat
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
import org.assertj.core.api.Assertions.assertThatThrownBy
|
import org.assertj.core.api.Assertions.assertThatThrownBy
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
@ -103,7 +103,7 @@ class ProtocolStateMachineImpl<R>(val logic: ProtocolLogic<R>,
|
|||||||
private fun suspend(with: StateMachineManager.FiberRequest) {
|
private fun suspend(with: StateMachineManager.FiberRequest) {
|
||||||
parkAndSerialize { fiber, serializer ->
|
parkAndSerialize { fiber, serializer ->
|
||||||
try {
|
try {
|
||||||
suspendAction!!(with)
|
suspendAction(with)
|
||||||
} catch (t: Throwable) {
|
} catch (t: Throwable) {
|
||||||
logger.warn("Captured exception which was swallowed by Quasar", t)
|
logger.warn("Captured exception which was swallowed by Quasar", t)
|
||||||
// TODO to throw or not to throw, that is the question
|
// TODO to throw or not to throw, that is the question
|
||||||
|
@ -201,7 +201,7 @@ fun runBuyer(node: Node, amount: Amount<Issued<Currency>>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val future = if (node.isPreviousCheckpointsPresent) {
|
val future = if (node.isPreviousCheckpointsPresent) {
|
||||||
val (buyer, future) = node.smm.findStateMachines(TraderDemoProtocolBuyer::class.java).single()
|
val (@Suppress("UNUSED_VARIABLE") buyer, future) = node.smm.findStateMachines(TraderDemoProtocolBuyer::class.java).single()
|
||||||
future
|
future
|
||||||
} else {
|
} else {
|
||||||
// We use a simple scenario-specific wrapper protocol to make things happen.
|
// We use a simple scenario-specific wrapper protocol to make things happen.
|
||||||
@ -381,4 +381,4 @@ class TraderDemoProtocolSeller(val myAddress: HostAndPort,
|
|||||||
return move.tx.outRef(0)
|
return move.tx.outRef(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user