michelson 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d375c9dfbd52ea9537facce50afe35db8e8e81a1
4
- data.tar.gz: 85be77944a3c4105c1d067aeb50036b760caafa1
3
+ metadata.gz: ed3b5fbe9328e38ec213aa5d36c106711cdd5e1e
4
+ data.tar.gz: 0e5d7cd932220b76b7951a1db682c266cd3242c3
5
5
  SHA512:
6
- metadata.gz: f3336d0616873ec272eba9facd94583b911a5fcc32f88bba85b206f6431ced1f18616c2bb0c0497132490afe34c7c05d263c3977780b4f53a743aa1a3315d129
7
- data.tar.gz: 5c1a4facf31b9017505065140d786fd9e0f42106308f7eca71c074690b489e06974e57d9f2d2a4e8184c9d981c107078b777037f39c57827d4a14c635a78adf8
6
+ metadata.gz: 22d4c310be5fd21d7caa94fa87ab9f3b50c7a4c1a208c2f35682173d2894be1fca582e9c6eddab10ea81b5f6ffbf46c5e52c96696976b8b8cc7d86e7ef148601
7
+ data.tar.gz: a0e72f64c2dbd6a8e47cf9c9a009204c8e967411834c9119462113f88e3d335685b444f6371e9a72b9cb5faa080a7c05c98aabd1757c243158e71b2e1c1356d6
data/README.md CHANGED
@@ -9,9 +9,103 @@ michelson gem / library - test simulator / runtime for type-safe 'n' functional
9
9
  * rdoc :: [rubydoc.info/gems/michelson](http://rubydoc.info/gems/michelson)
10
10
 
11
11
 
12
+
12
13
  ## Usage
13
14
 
14
- To be done
15
+ **What's Michelson? What's Liquidity?**
16
+
17
+ The Liquidity language lets you program contracts with (higher-level type-safe functional) OCaml or ReasonML syntax (see <http://www.liquidity-lang.org>)
18
+ compiling to (lower-level) Michelson stack machine bytecode (see <https://www.michelson-lang.com>).
19
+
20
+ Using the michelson test simulator / runtime for type-safe 'n' functional (crypto) contracts you can now use a "Yes, It's Just Ruby" syntax.
21
+
22
+
23
+ ### By Example
24
+
25
+ **Let's Count - 0, 1, 2, 3**
26
+
27
+ ``` ruby
28
+ type :Storage, Integer
29
+
30
+ init [],
31
+ def storage()
32
+ 0
33
+ end
34
+
35
+ entry [Integer],
36
+ def inc( by, storage )
37
+ [[], storage + by]
38
+ end
39
+ ```
40
+
41
+ And for (local) testing you can run the "Yes, It's Just Ruby" version with the michelson testnet "simulator" library. Try:
42
+
43
+ ``` ruby
44
+ storage = storage()
45
+ # => calling storage()...
46
+ # => returning:
47
+ # => 0
48
+ _, storage = inc( 2, storage )
49
+ # => calling inc( 2, 0 )...
50
+ # => returning:
51
+ # => [[], 2]
52
+ _, storage = inc( 1, storage )
53
+ # => calling inc( 1, 2 )...
54
+ # => returning:
55
+ # => [[], 3]
56
+ ```
57
+
58
+
59
+ **Let's Vote**
60
+
61
+ ``` ruby
62
+ type :Storage, Map‹String→Integer›
63
+
64
+ init [],
65
+ def storage()
66
+ {"ocaml" => 0, "reason" => 0, "ruby" => 0}
67
+ end
68
+
69
+ entry [String],
70
+ def vote( choice, votes )
71
+ amount = Current.amount
72
+ if amount < 5.tz
73
+ failwith( "Not enough money, at least 5tz to vote" )
74
+ else
75
+ match Map.find(choice, votes), {
76
+ None: ->() { failwith( "Bad vote" ) },
77
+ Some: ->(x) { votes = Map.add(choice, x + 1, votes); [[], votes] }}
78
+ end
79
+ end
80
+ ```
81
+
82
+ And again for (local) testing you can run the "Yes, It's Just Ruby" version with the michelson testnet "simulator" library. Try:
83
+
84
+ ``` ruby
85
+ storage = storage()
86
+ #=> calling storage()...
87
+ #=> returning:
88
+ #=> {"ocaml"=>0, "reason"=>0, "ruby"=>0}
89
+ _, storage = vote( "ruby", storage )
90
+ #=> calling vote( "ruby", {"ocaml"=>0, "reason"=>0, "ruby"=>0} )...
91
+ #=> !! RuntimeError: failwith - Not enough money, at least 5tz to vote
92
+
93
+ Current.amount = 10.tz
94
+
95
+ _, storage = vote( "ruby", storage )
96
+ #=> calling vote( "ruby", {"ocaml"=>0, "reason"=>0, "ruby"=>0} )...
97
+ #=> returning:
98
+ #=> [[], {"ocaml"=>0, "reason"=>0, "ruby"=>1}]
99
+ _, storage = vote( "reason", storage )
100
+ #=> calling vote( "reason", {"ocaml"=>0, "reason"=>0, "ruby"=>1} )...
101
+ #=> returning:
102
+ #=> [[], {"ocaml"=>0, "reason"=>1, "ruby"=>1}]
103
+ _, storage = vote( "python", storage )
104
+ #=> calling vote( "python", {"ocaml"=>0, "reason"=>1, "ruby"=>1} )...
105
+ #=> !! RuntimeError: failwith - Bad vote
106
+ ```
107
+
108
+ And so on and so forth.
15
109
 
16
110
 
17
111
  ## License
@@ -4,7 +4,7 @@ require 'pp'
4
4
 
5
5
  ## our own code
6
6
  require 'michelson/version' # note: let version always go first
7
-
7
+ require 'michelson/michelson'
8
8
 
9
9
 
10
10
  puts Michelson.banner ## say hello
@@ -4,8 +4,8 @@
4
4
  module Michelson
5
5
 
6
6
  MAJOR = 0
7
- MINOR = 0
8
- PATCH = 1
7
+ MINOR = 1
8
+ PATCH = 0
9
9
  VERSION = [MAJOR,MINOR,PATCH].join('.')
10
10
 
11
11
  def self.version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: michelson
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer