Git Product home page Git Product logo

webu.scala's Introduction

WebuJ-Scala Library

Build Status GitHub version

webuj-scala is an idiomatic Scala wrapper around WebuJ for HappyUC. WebuJ is a lightweight, reactive, somewhat type safe Java and Android library for integrating with nodes on HappyUC blockchains.

WebuJ features RxJava extensions, and webuj-scala wraps that syntax in Scala goodness. For example, the webuj-scala observable methods provide simple and efficient application code. Scala's value classes are used to provide much stronger type safety than WebuJ, without incurring a runtime penalty.

Use As a Library

Add this to your SBT project's build.sbt:

resolvers += "micronautics/scala on bintray" at "http://dl.bintray.com/micronautics/scala"

libraryDependencies += "com.micronautics" %% "webuj-scala" % "0.2.2" withSources()

Only Scala 2.12 with JDK 8 is supported at present; this is a limitation of the Scala ecosystem as of November 7, 2017.

Run the Demo Program

The demo program performs the following:

  • Follows the outline of the WebuJ Getting Started documentation, adapted for WebuJ-Scala, including synchronous and asynchronous versions of the available methods.
  • Compiles an example Solidity program that defines a smart contract.
  • Creates a JVM wrapper from an example smart contract.

To run the demo:

  1. Start up an HappyUC client if you don’t already have one running, such as ghuc. The bin/runGhuc script invokes ghuc with the following options, which are convenient for development but not secure enough for production:
    • The HappyUC data directory is set to ~/.happyuc, or a subdirectory that depends on the network chosen; the directory will be created if required.
    • HTTP-RPC server at localhost:8545 is enabled, and all APIs are allowed.
    • HappyUC's experimental Whisper message facility is enabled.
    • Inter-process communication will be via a virtual file called ghuc.ipc, located at ~/.happyuc or a subdirectory.
    • WS-RPC server at localhost:8546 is enabled, and all APIs are allowed.
    • Info verbosity is specified.
    • A log file for the ghuc output will be written, or overwritten, in logs/ghuc.log; the log/ directory will be created if it does not already exist.
    $ mkdir logs/
    $ ghuc \
       #--datadir .happyuc/devnet --dev \      # boots quickly but has no deployed contracts from others
       --datadir .happyuc/rinkeby --rinkeby \  # takes about 15 minutes to boot, but has contracts
       --ipcpath ghuc.ipc \
       --metrics \
       --rpc \
       --rpcapi huc,net,webuj,clique,debug,huc,miner,personal,rpc,ssh,txpool \
       --shh \
       --ws \
       --wsapi huc,net,webuj,clique,debug,huc,miner,personal,rpc,ssh,txpool \
       --verbosity 2
    
    You will see the message No coinbase set and no accounts found as default. Coinbase is the index into personal.listAccounts which determines the account to send Huc too. You can specify this value with the option --coinbase 0.
  2. The shell that you just used will continuously scroll output so long as ghuc continues to run, so type the following into another shell:
    $ bin/demo
    
    The demo has two major components:
    1. Creates a JVM wrapper for the sample smart contract.
    2. The second portion of the demo consists of the following:
  3. The bin/webuj script runs the WebuJ command-line console. The script builds a fat jar the first time it is run, so the command runs quickly on subsequent invocations.
  4. More scripts are provided in the bin/ directory, including:
    • bin/attachHttp - Attach to a running ghuc instance via HTTP and open a JavaScript console
    • bin/attachIpc - Attach to a running ghuc instance via IPC and open a JavaScript console. This script might need to be edited if a network other than devnet is used.
    • bin/getApis - Reports the available APIs exposed by this ghuc instance.
    • bin/isGhucListening - Verifies that ghuc is listening on HTTP port 8545

Developers

API Documentation

Publishing

  1. Update the version string in build.sbt and in this README.md before attempting to publish to Bintray.
  2. Commit changes with a descriptive comment:
    $ git add -a && git commit -m "Comment here"
    
  3. Publish a new version of this library, including committing changes and updating the Scaladoc with this command:
    $ sbt publishAndTag
    

Updating Scaladoc

If you just want to republish the Scaladoc for this project, without creating a new version, use this command:

$ sbt scaladoc

Updating Scaladoc and Committing Changes Without Publishing a New Version

This task rebuilds the docs, commits the git repository, and publishes the updated Scaladoc without publishing a new version:

$ sbt commitAndDoc

Sponsor

This project is sponsored by Micronautics Research Corporation, the company that delivers online Scala training via ScalaCourses.com. You can learn Scala by taking the Introduction to Scala, and Intermediate Scala courses.

Micronautics Research also offers HappyUC and Scala consulting. Please contact us to discuss your organization’s needs.

License

This software is published under the Apache 2.0 License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.