<h2>Milestone 2<aclass="headerlink"href="#milestone-2"title="Permalink to this headline">¶</a></h2>
<ul>
<li><pclass="first">Big improvements to the interest rate swap app:</p>
<blockquote>
<div><ulclass="simple">
<li>A new web app demonstrating the IRS contract has been added. This can be used as an example for how to interact with
the Corda API from the web.</li>
<li>Simplifications to the way the demo is used from the command line.</li>
<li><aclass="reference internal"href="contract-irs.html"><spanclass="doc">Detailed documentation on how the contract works and can be used</span></a> has been written.</li>
<li>Better integration testing of the app.</li>
</ul>
</div></blockquote>
</li>
<li><pclass="first">Smart contracts have been redesigned around reusable components, referred to as “clauses”. The cash, commercial paper
and obligation contracts now share a common issue clause.</p>
</li>
<li><pclass="first">New code in the experimental module (note that this module is a place for work-in-progress code which has not yet gone
through code review and which may, in general, not even function correctly):</p>
<blockquote>
<div><ul>
<li><pclass="first">Thanks to the prolific Sofus Mortensen @ Nordea Bank, an experimental generic contract DSL that is based on the famous
2001 “Composing contracts” paper has been added. We thank Sofus for this great and promising research, which is so
relevant in the wake of TheDAO hack.</p>
</li>
<li><pclass="first">The contract code from the recent trade finance demos is now in experimental. This code comes thanks to a
collaboration of the members; all credit to:</p>
<blockquote>
<div><ulclass="simple">
<li>Mustafa Ozturk @ Natixis</li>
<li>David Nee @ US Bank</li>
<li>Johannes Albertsen @ Dankse Bank</li>
<li>Rui Hu @ Nordea</li>
<li>Daniele Barreca @ Unicredit</li>
<li>Sukrit Handa @ Scotiabank</li>
<li>Giuseppe Cardone @ Banco Intesa</li>
<li>Robert Santiago @ BBVA</li>
</ul>
</div></blockquote>
</li>
</ul>
</div></blockquote>
</li>
<li><pclass="first">The usability of the command line demo programs has been improved.</p>
</li>
<li><pclass="first">All example code and existing contracts have been ported to use the new Java/Kotlin unit testing domain-specific
languages (DSLs) which make it easy to construct chains of transactions and verify them together. This cleans up
and unifies the previous ad-hoc set of similar DSLs. A tutorial on how to use it has been added to the documentation.
We believe this largely completes our testing story for now around smart contracts. Feedback from bank developers
during the Trade Finance project has indicated that the next thing to tackle is docs and usability improvements in
the protocols API.</p>
</li>
<li><pclass="first">Significant work done towards defining the “CorDapp” concept in code, with dynamic loading of API services and more to
come.</p>
</li>
<li><pclass="first">Inter-node communication now uses SSL/TLS and AMQP/1.0, albeit without all nodes self-signing at the moment. A real
PKI for the p2p network will come later.</p>
</li>
<li><pclass="first">Logging is now saved to files with log rotation provided by Log4J.</p>
</li>
</ul>
<p>API changes:</p>
<ulclass="simple">
<li>Some utility methods and extension functions that are specific to certain contract types have moved packages: just
delete the import lines that no longer work and let IntelliJ replace them with the correct package paths.</li>
<li>The <codeclass="docutils literal"><spanclass="pre">arg</span></code> method in the test DSL is now called <codeclass="docutils literal"><spanclass="pre">command</span></code> to be consistent with the rest of the data model.</li>
<li>The messaging APIs have changed somewhat to now use a new <codeclass="docutils literal"><spanclass="pre">TopicSession</span></code> object. These APIs will continue to change
<li><codeclass="docutils literal"><spanclass="pre">NotaryService</span></code> is now extensible.</li>
<li>Every <codeclass="docutils literal"><spanclass="pre">ContractState</span></code> now has to specify a <em>participants</em> field, which is a list of parties that are able to
consume this state in a valid transaction. This is used for e.g. making sure all relevant parties obtain the updated
state when changing a notary.</li>
<li>Introduced <codeclass="docutils literal"><spanclass="pre">TransactionState</span></code>, which wraps <codeclass="docutils literal"><spanclass="pre">ContractState</span></code>, and is used when defining a transaction output.
The notary field is moved from <codeclass="docutils literal"><spanclass="pre">ContractState</span></code> into <codeclass="docutils literal"><spanclass="pre">TransactionState</span></code>.</li>
<li>Every transaction now has a <em>type</em> field, which specifies custom build & validation rules for that transaction type.
Currently two types are supported: General (runs the default build and validation logic) and NotaryChange (
contract code is not run during validation, checks that the notary field is the only difference between the
inputs and outputs).
<codeclass="docutils literal"><spanclass="pre">TransactionBuilder()</span></code> is now abstract, you should use <codeclass="docutils literal"><spanclass="pre">TransactionType.General.Builder()</span></code> for building transactions.</li>
</ul>
</div></blockquote>
</li>
<li><pclass="first">The cash contract has moved from <codeclass="docutils literal"><spanclass="pre">com.r3corda.contracts</span></code> to <codeclass="docutils literal"><spanclass="pre">com.r3corda.contracts.cash</span></code></p>
</li>
<li><pclass="first"><codeclass="docutils literal"><spanclass="pre">Amount</span></code> class is now generic, to support non-currency types such as physical assets. Where you previously had just
<codeclass="docutils literal"><spanclass="pre">Amount</span></code>, you should now use <codeclass="docutils literal"><spanclass="pre">Amount<Currency></span></code>.</p>
</li>
<li><pclass="first">Refactored the Cash contract to have a new FungibleAsset superclass, to model all countable assets that can be merged
and split (currency, barrels of oil, etc.)</p>
</li>
<li><pclass="first">Messaging:</p>
<blockquote>
<div><ulclass="simple">
<li><codeclass="docutils literal"><spanclass="pre">addMessageHandler</span></code> now has a different signature as part of error handling changes.</li>
<li>If you want to return nothing to a protocol, use <codeclass="docutils literal"><spanclass="pre">Ack</span></code> instead of <codeclass="docutils literal"><spanclass="pre">Unit</span></code> from now on.</li>
</ul>
</div></blockquote>
</li>
<li><pclass="first">In the IRS contract, dateOffset is now an integer instead of an enum.</p>
</li>
<li><pclass="first">In contracts, you now use <codeclass="docutils literal"><spanclass="pre">tx.getInputs</span></code> and <codeclass="docutils literal"><spanclass="pre">tx.getOutputs</span></code> instead of <codeclass="docutils literal"><spanclass="pre">getInStates</span></code> and <codeclass="docutils literal"><spanclass="pre">getOutStates</span></code>. This is
just a renaming.</p>
</li>
<li><pclass="first">A new <codeclass="docutils literal"><spanclass="pre">NonEmptySet</span></code> type has been added for cases where you wish to express that you have a collection of unique
objects which cannot be empty.</p>
</li>
<li><pclass="first">Please use the global <codeclass="docutils literal"><spanclass="pre">newSecureRandom()</span></code> function rather than instantiating your own SecureRandom’s from now on, as
the custom function forces the use of non-blocking random drivers on Linux.</p>
Built with <ahref="http://sphinx-doc.org/">Sphinx</a> using a <ahref="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <ahref="https://readthedocs.org">Read the Docs</a>.