tezos_client 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +9 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +21 -0
  7. data/CODE_OF_CONDUCT.md +74 -0
  8. data/Gemfile +8 -0
  9. data/Gemfile.lock +147 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +107 -0
  12. data/Rakefile +8 -0
  13. data/bin/console +15 -0
  14. data/bin/setup +8 -0
  15. data/lib/tezos_client/client_interface/block_contextual.rb +16 -0
  16. data/lib/tezos_client/client_interface/client_wrapper.rb +37 -0
  17. data/lib/tezos_client/client_interface/contract.rb +17 -0
  18. data/lib/tezos_client/client_interface/key.rb +35 -0
  19. data/lib/tezos_client/client_interface/misc.rb +26 -0
  20. data/lib/tezos_client/client_interface.rb +25 -0
  21. data/lib/tezos_client/commands.rb +28 -0
  22. data/lib/tezos_client/crypto.rb +178 -0
  23. data/lib/tezos_client/currency_utils.rb +20 -0
  24. data/lib/tezos_client/encode_utils.rb +139 -0
  25. data/lib/tezos_client/liquidity_inteface/liquidity_wrapper.rb +34 -0
  26. data/lib/tezos_client/liquidity_interface.rb +127 -0
  27. data/lib/tezos_client/logger.rb +78 -0
  28. data/lib/tezos_client/operation.rb +125 -0
  29. data/lib/tezos_client/operations/origination_operation.rb +50 -0
  30. data/lib/tezos_client/operations/transaction_operation.rb +39 -0
  31. data/lib/tezos_client/rpc_interface/blocks.rb +34 -0
  32. data/lib/tezos_client/rpc_interface/context.rb +27 -0
  33. data/lib/tezos_client/rpc_interface/contracts.rb +27 -0
  34. data/lib/tezos_client/rpc_interface/helper.rb +100 -0
  35. data/lib/tezos_client/rpc_interface/monitor.rb +19 -0
  36. data/lib/tezos_client/rpc_interface/request_manager.rb +88 -0
  37. data/lib/tezos_client/rpc_interface.rb +29 -0
  38. data/lib/tezos_client/string_utils.rb +16 -0
  39. data/lib/tezos_client/version.rb +5 -0
  40. data/lib/tezos_client.rb +149 -0
  41. data/tezos_client.gemspec +48 -0
  42. data/travis-scripts/install-liquidity.sh +25 -0
  43. data/travis-scripts/install-opam.sh +4 -0
  44. data/travis-scripts/prepare-trusty.sh +16 -0
  45. metadata +242 -0
@@ -0,0 +1,50 @@
1
+ class TezosClient
2
+ class OriginationOperation < Operation
3
+
4
+ def initialize_operation_args
5
+ operation_args = default_args.merge(
6
+ **@init_args,
7
+ manager: manager,
8
+ operation_kind: operation_kind,
9
+ branch: branch,
10
+ counter: counter)
11
+
12
+ if has_script?
13
+ operation_args[:script] = json_script
14
+ end
15
+ @operation_args = operation_args
16
+ end
17
+
18
+ def has_script?
19
+ @init_args.key? :script
20
+ end
21
+
22
+ def json_script
23
+ liquidity_interface.origination_script(
24
+ @init_args.slice(:from, :script, :init_params)
25
+ )
26
+ end
27
+
28
+ def manager
29
+ @init_args.fetch(:manager) { @init_args.fetch(:from) }
30
+ end
31
+
32
+
33
+ def operation_kind
34
+ :origination
35
+ end
36
+
37
+ private
38
+
39
+ def default_args
40
+ {
41
+ amount: 0,
42
+ spendable: false,
43
+ delegatable: false,
44
+ gas_limit: 0.1,
45
+ storage_limit: 0.006,
46
+ fee: 0.05
47
+ }
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,39 @@
1
+ class TezosClient
2
+ class TransactionOperation < Operation
3
+ include EncodeUtils
4
+
5
+ def initialize_operation_args
6
+ @operation_args = default_args.merge(
7
+ **@init_args,
8
+ operation_kind: operation_kind,
9
+ branch: branch,
10
+ counter: counter
11
+ )
12
+ if has_parameters?
13
+ @operation_args[:parameters] = parameters
14
+ end
15
+ end
16
+
17
+ def has_parameters?
18
+ @init_args.key? :parameters
19
+ end
20
+
21
+ def parameters
22
+ (@init_args[:parameters].is_a? String) ? encode_args(@init_args[:parameters]) : @init_args[:parameters]
23
+ end
24
+
25
+ def operation_kind
26
+ :transaction
27
+ end
28
+
29
+ private
30
+
31
+ def default_args
32
+ {
33
+ gas_limit: 0.04,
34
+ storage_limit: 0.006,
35
+ fee: 0.05
36
+ }
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ class TezosClient
4
+ class RpcInterface
5
+ module Blocks
6
+ def block(block_hash = "head")
7
+ get "chains/main/blocks/#{block_hash}"
8
+ end
9
+
10
+ def blocks(length: 50, head: nil, min_date: nil)
11
+ query = {
12
+ length: length,
13
+ head: head,
14
+ min_date: min_date&.utc&.iso8601
15
+ }.compact
16
+
17
+ res = get "chains/main/blocks/", query: query
18
+ res[0]
19
+ end
20
+
21
+ def block_header(block_hash = "head")
22
+ get "chains/main/blocks/#{block_hash}/header"
23
+ end
24
+
25
+ def block_operations(block_hash = "head")
26
+ get "chains/main/blocks/#{block_hash}/operations"
27
+ end
28
+
29
+ def block_operation_hashes(block_hash = "head")
30
+ get "chains/main/blocks/#{block_hash}/operation_hashes"
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ class TezosClient
4
+ class RpcInterface
5
+ module Context
6
+ def constants
7
+ get "/chains/main/blocks/head/context/constants"
8
+ end
9
+
10
+ def head_hash
11
+ get "/chains/main/blocks/head/hash"
12
+ end
13
+
14
+ def chain_id
15
+ get "/chains/main/chain_id"
16
+ end
17
+
18
+ def protocols
19
+ get "/protocols"
20
+ end
21
+
22
+ def protocol
23
+ get "/protocols/main"
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ class TezosClient
4
+ class RpcInterface
5
+ using CurrencyUtils
6
+
7
+ module Contracts
8
+ def contract_link(contract_id)
9
+ "/chains/main/blocks/head/context/contracts/#{contract_id}"
10
+ end
11
+
12
+ def balance(contract_id)
13
+ res = get("#{contract_link(contract_id)}/balance")
14
+ res.to_i.from_satoshi
15
+ end
16
+
17
+ def contract_counter(contract_id)
18
+ res = get("#{contract_link(contract_id)}/counter")
19
+ res.to_i
20
+ end
21
+
22
+ def contract_manager_key(contract_id)
23
+ get "#{contract_link(contract_id)}/manager_key"
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ class TezosClient
4
+ class RpcInterface
5
+ module Helper
6
+ using CurrencyUtils
7
+
8
+ def transaction_operation(args)
9
+ operation = {
10
+ kind: "transaction",
11
+ amount: args.fetch(:amount).to_satoshi.to_s,
12
+ source: args.fetch(:from),
13
+ destination: args.fetch(:to),
14
+ gas_limit: args.fetch(:gas_limit).to_satoshi.to_s,
15
+ storage_limit: args.fetch(:storage_limit).to_satoshi.to_s,
16
+ counter: args.fetch(:counter).to_s,
17
+ fee: args.fetch(:fee).to_satoshi.to_s
18
+ }
19
+ operation[:parameters] = args[:parameters] if args[:parameters]
20
+ operation
21
+ end
22
+
23
+ def origination_operation(args)
24
+ operation = {
25
+ kind: "origination",
26
+ delegatable: args.fetch(:delegatable),
27
+ spendable: args.fetch(:spendable),
28
+ balance: args.fetch(:amount).to_satoshi.to_s,
29
+ source: args.fetch(:from),
30
+ gas_limit: args.fetch(:gas_limit).to_satoshi.to_s,
31
+ storage_limit: args.fetch(:storage_limit).to_satoshi.to_s,
32
+ counter: args.fetch(:counter).to_s,
33
+ fee: args.fetch(:fee).to_satoshi.to_s,
34
+ managerPubkey: args.fetch(:manager)
35
+ }
36
+
37
+ operation[:script] = args[:script] if args[:script]
38
+ operation
39
+ end
40
+
41
+ def operation(args)
42
+ operation_kind = args.fetch(:operation_kind) { raise ArgumentError, ":operation_kind argument missing" }
43
+ send("#{operation_kind}_operation", args)
44
+ end
45
+
46
+ %w(origination transaction).each do |operation_kind|
47
+ # preapply_transaction, preapply_origination ...
48
+ define_method "preapply_#{operation_kind}" do |args|
49
+ preapply_operation(operation_kind: operation_kind, **args)
50
+ end
51
+
52
+ # run_transaction, run_origination ...
53
+ define_method "run_#{operation_kind}" do |args|
54
+ run_operation(operation_kind: operation_kind, **args)
55
+ end
56
+
57
+ # forge_transaction, forge_origination ...
58
+ define_method "forge_#{operation_kind}" do |args|
59
+ forge_operation(operation_kind: operation_kind, **args)
60
+ end
61
+ end
62
+
63
+
64
+ def preapply_operation(args)
65
+ content = {
66
+ protocol: args.fetch(:protocol),
67
+ branch: args.fetch(:branch),
68
+ contents: [operation(args)],
69
+ signature: args.fetch(:signature)
70
+ }
71
+
72
+ res = post("chains/main/blocks/head/helpers/preapply/operations",
73
+ [content])
74
+ res[0]["contents"][0]
75
+ end
76
+
77
+ def run_operation(args)
78
+ content = {
79
+ branch: args.fetch(:branch),
80
+ contents: [operation(args)],
81
+ signature: args.fetch(:signature)
82
+ }
83
+ res = post("chains/main/blocks/head/helpers/scripts/run_operation", content)
84
+ res["contents"][0]
85
+ end
86
+
87
+ def forge_operation(args)
88
+ content = {
89
+ branch: args.fetch(:branch),
90
+ contents: [operation(args)]
91
+ }
92
+ post("chains/main/blocks/head/helpers/forge/operations", content)
93
+ end
94
+
95
+ def broadcast_operation(data)
96
+ post("injection/operation?chain=main", data)
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "date"
4
+
5
+ class TezosClient
6
+ class RpcInterface
7
+ module Monitor
8
+ def bootstrapped
9
+ res = get "/monitor/bootstrapped"
10
+ res["timestamp"] = DateTime.parse(res["timestamp"])
11
+ res
12
+ end
13
+
14
+ def monitor_block(&block_reader)
15
+ monitor("monitor/heads/main", &block_reader)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ class TezosClient
4
+ class RpcInterface
5
+ module RequestManager
6
+ def get(path, query: {})
7
+ url = "http://#{@host}:#{@port}/#{path}"
8
+
9
+ response = HTTParty.get(url, headers: { "Content-Type" => "application/json" }, query: query)
10
+ formatted_response = format_response(response.parsed_response)
11
+
12
+ log("-------")
13
+ log(">>> GET #{response.request.uri.to_s} \n")
14
+ log("<<< code: #{response.code} \n #{formatted_response.pretty_inspect}")
15
+ log("-------")
16
+ unless response.success?
17
+ raise "#{url} failed with code #{response.code}: #{formatted_response.pretty_inspect}"
18
+ end
19
+
20
+ formatted_response
21
+ end
22
+
23
+ def post(path, content)
24
+ url = "http://#{@host}:#{@port}/#{path}"
25
+ response = HTTParty.post(url,
26
+ body: content.to_json,
27
+ headers: { "Content-Type" => "application/json" })
28
+
29
+ formatted_response = format_response(response.parsed_response)
30
+
31
+ log("-------")
32
+ log(">>> POST #{url} \n #{content.pretty_inspect}")
33
+ log("<<< code: #{response.code} \n #{formatted_response.pretty_inspect}")
34
+ log("-------")
35
+
36
+ unless response.success?
37
+ raise "#{url} failed with code #{response.code}:\n #{formatted_response.pretty_inspect}"
38
+ end
39
+
40
+ formatted_response
41
+ end
42
+
43
+ def monitor(path, &event_handler)
44
+ uuid = SecureRandom.uuid
45
+
46
+ url = "http://#{@host}:#{@port}/#{path}"
47
+
48
+ event_reader = monitor_event_reader(uuid, event_handler)
49
+
50
+ Thread.new do
51
+ log("Monitor #{uuid}: Start monitoring GET #{url}")
52
+ RestClient::Request.execute(method: :get,
53
+ read_timeout: 60 * 60 * 24 * 365,
54
+ url: url,
55
+ block_response: event_reader,
56
+ content_type: :json,
57
+ accept: :json)
58
+ rescue => e
59
+ log "#{uuid}: failed with error #{e}"
60
+ end
61
+ end
62
+
63
+ private
64
+
65
+ def monitor_event_reader(uuid, event_handler)
66
+ proc do |event_response|
67
+ event_response.read_body do |event_json|
68
+ event = format_response(JSON.parse(event_json))
69
+ log("Monitor #{uuid}: received chunk #{event.pretty_inspect}")
70
+ event_handler.call(event)
71
+ end
72
+ end
73
+ end
74
+
75
+ def format_response(response)
76
+ if response.is_a? Array
77
+ response.map do |el|
78
+ (el.is_a? Hash) ? el.with_indifferent_access : el
79
+ end
80
+ elsif response.is_a? Hash
81
+ response.with_indifferent_access
82
+ else
83
+ response
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "httparty"
4
+ require "rest-client"
5
+
6
+ require_relative "rpc_interface/monitor"
7
+ require_relative "rpc_interface/contracts"
8
+ require_relative "rpc_interface/context"
9
+ require_relative "rpc_interface/helper"
10
+ require_relative "rpc_interface/request_manager"
11
+ require_relative "rpc_interface/blocks"
12
+
13
+ class TezosClient
14
+ class RpcInterface
15
+ include Logger
16
+ include Monitor
17
+ include Contracts
18
+ include Context
19
+ include Helper
20
+ include RequestManager
21
+ include Blocks
22
+
23
+ def initialize(host: "127.0.0.1", port: "8732")
24
+ @host = host
25
+ @port = port
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+
4
+ class TezosClient
5
+ module StringUtils
6
+ refine String do
7
+ def to_hex
8
+ unpack("H*")[0]
9
+ end
10
+
11
+ def to_bin
12
+ [self].pack("H*")
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class TezosClient
4
+ VERSION = "0.2.0"
5
+ end
@@ -0,0 +1,149 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pp"
4
+ require "active_support/core_ext/hash/indifferent_access"
5
+ require "active_support/core_ext/string/inflections"
6
+ require "timeout"
7
+
8
+ require "tezos_client/version"
9
+ require "tezos_client/string_utils"
10
+ require "tezos_client/currency_utils"
11
+ require "tezos_client/crypto"
12
+ require "tezos_client/commands"
13
+ require "tezos_client/logger"
14
+ require "tezos_client/encode_utils"
15
+ require "tezos_client/operation"
16
+ require "tezos_client/operations/origination_operation"
17
+ require "tezos_client/operations/transaction_operation"
18
+
19
+ require "tezos_client/client_interface"
20
+ require "tezos_client/rpc_interface"
21
+ require "tezos_client/liquidity_interface"
22
+
23
+
24
+ class TezosClient
25
+ using CurrencyUtils
26
+ using StringUtils
27
+
28
+ include Logger
29
+
30
+ include Commands
31
+ include Crypto
32
+
33
+ attr_accessor :client_interface
34
+ attr_accessor :rpc_interface
35
+ attr_accessor :liquidity_interface
36
+
37
+ RANDOM_SIGNATURE = "edsigu165B7VFf3Dpw2QABVzEtCxJY2gsNBNcE3Ti7rRxtDUjqTFRpg67EdAQmY6YWPE5tKJDMnSTJDFu65gic8uLjbW2YwGvAZ"
38
+
39
+ def initialize(rpc_node_address: "127.0.0.1", rpc_node_port: 8732)
40
+ @rpc_node_address = rpc_node_address
41
+ @rpc_node_port = rpc_node_port
42
+
43
+ @client_config_file = ENV["TEZOS_CLIENT_CONFIG_FILE"]
44
+ @client_interface = ClientInterface.new(
45
+ config_file: @client_config_file
46
+ )
47
+
48
+ @rpc_interface = RpcInterface.new(
49
+ host: @rpc_node_address,
50
+ port: @rpc_node_port
51
+ )
52
+
53
+ @liquidity_interface = LiquidityInterface.new(
54
+ rpc_node_address: @rpc_node_address,
55
+ rpc_node_port: @rpc_node_port
56
+ )
57
+ end
58
+
59
+ # Originates a contract on the tezos blockchain
60
+ #
61
+ # @param from [String] Address originating the contract
62
+ # @param amount [Numeric] amount to send to the contract
63
+ # @param secret_key [String] Secret key of the origination address
64
+ # @param args [Hash] keyword options for the origination
65
+ # @option args [String] :script path of the liquidity script
66
+ # @option args [Array, String] :init_params params to pass to the storage initialization process
67
+ # @option args [Boolean] :spendable decide wether the contract is spendable or not
68
+ # @option args [Boolean] :delegatable decide wether the contract is delegatable or not
69
+ #
70
+ # @return [Hash] result of the origination containing :operation_id, :operation_result and :originated_contract
71
+ #
72
+ def originate_contract(from:, amount:, secret_key:, **args)
73
+ res = OriginationOperation.new(
74
+ liquidity_interface: liquidity_interface,
75
+ rpc_interface: rpc_interface,
76
+ from: from,
77
+ secret_key: secret_key,
78
+ amount: amount,
79
+ **args
80
+ ).test_and_broadcast
81
+
82
+ res.merge(originated_contract: res[:operation_result][:originated_contracts][0])
83
+ end
84
+
85
+ # Transfer funds to an account
86
+ #
87
+ # @param from [String] Address originating the transfer
88
+ # @param to [String] Address receiving the transfer
89
+ # @param amount [Numeric] amount to send to the account
90
+ # @param secret_key [String] Secret key of the origination address
91
+ # @param args [Hash] keyword options for the transfer
92
+ #
93
+ # @return [Hash] result of the transfer containing :operation_id and :operation_result
94
+ #
95
+ def transfer(from:, amount:, to:, secret_key:, **args)
96
+ TransactionOperation.new(
97
+ liquidity_interface: liquidity_interface,
98
+ rpc_interface: rpc_interface,
99
+ from: from,
100
+ to: to,
101
+ secret_key: secret_key,
102
+ amount: amount,
103
+ **args
104
+ ).test_and_broadcast
105
+ end
106
+
107
+ def call_contract(args)
108
+ parameters = args.fetch(:parameters)
109
+
110
+ json_params = liquidity_interface.call_parameters(
111
+ script: args.fetch(:script),
112
+ parameters: parameters
113
+ )
114
+
115
+ transfer_args = args.merge(parameters: json_params)
116
+
117
+ transfer(transfer_args)
118
+ end
119
+
120
+ def monitor_operation(operation_id, timeout: 120)
121
+ including_block = nil
122
+
123
+ monitoring_thread = rpc_interface.monitor_block do |block_header|
124
+ log "recently received block: #{block_header.pretty_inspect}"
125
+ hash = block_header["hash"]
126
+ if block_include_operation?(operation_id, hash)
127
+ log "operations #{operation_id} found in block #{hash}"
128
+ including_block = hash
129
+ end
130
+ end
131
+
132
+ Timeout.timeout(timeout) do
133
+ loop do
134
+ sleep(0.1)
135
+ break unless including_block.nil?
136
+ end
137
+ end
138
+
139
+ monitoring_thread.terminate
140
+
141
+ including_block
142
+ end
143
+
144
+ def block_include_operation?(operation_id, block_id)
145
+ operations = rpc_interface.get("chains/main/blocks/#{block_id}/operation_hashes")
146
+ operations.flatten.include? operation_id
147
+ end
148
+
149
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("lib", __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "tezos_client/version"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "tezos_client"
9
+ spec.version = TezosClient::VERSION
10
+ spec.authors = ["Pierre Michard"]
11
+ spec.email = ["pierre@moneytrack.io"]
12
+
13
+ spec.summary = "Wrapper to the tezos client."
14
+ spec.description = ""
15
+ spec.homepage = "http://moneytrack.io"
16
+ spec.license = "MIT"
17
+
18
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
19
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
20
+ if spec.respond_to?(:metadata)
21
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
22
+ else
23
+ raise "RubyGems 2.0 or newer is required to protect against " \
24
+ "public gem pushes."
25
+ end
26
+
27
+ # Specify which files should be added to the gem when it is released.
28
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
29
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
30
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
31
+ end
32
+ spec.bindir = "exe"
33
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
+ spec.require_paths = ["lib"]
35
+
36
+ spec.add_development_dependency "bundler", "~> 1.16"
37
+ spec.add_development_dependency "rake", "~> 10.0"
38
+ spec.add_development_dependency "rspec", "~> 3.0"
39
+ spec.add_development_dependency "rubocop-rails_config"
40
+ spec.add_development_dependency "webmock"
41
+ spec.add_development_dependency "vcr", "~> 4.0.0"
42
+
43
+ spec.add_dependency "base58", "~> 0.2.3"
44
+ spec.add_dependency "httparty", "~> 0.16.2"
45
+ spec.add_dependency "rbnacl", "~> 5.0.0"
46
+ spec.add_dependency "rest-client", "~>2.0.0"
47
+ spec.add_dependency "activesupport", "~> 5.2.0"
48
+ end
@@ -0,0 +1,25 @@
1
+ #!/bin/sh
2
+ #set -ex
3
+ # This script is used in .travis.yml for continuous integration on travis.
4
+ # BTW, it also show some needed system packages to build liquidity
5
+ # Travis CI is done on Ubuntu trusty
6
+
7
+ [ -d liquidity ] || git clone --depth=50 https://github.com/OCamlPro/liquidity.git liquidity
8
+ cd liquidity
9
+ git pull
10
+ git checkout next
11
+
12
+ # currently, we only target OCaml 4.06.1 because we reuse the parser of OCaml
13
+ opam switch create liquidity 4.06.1
14
+
15
+ eval $(opam config env)
16
+ opam update
17
+ eval $(opam config env)
18
+
19
+ make build-deps
20
+ make clone-tezos
21
+ tezos/scripts/install_build_deps.raw.sh
22
+ # make -C tezos build-deps
23
+
24
+ make
25
+ make install
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ set -ex
3
+ wget https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh
4
+ yes "" | sh install.sh
@@ -0,0 +1,16 @@
1
+ #!/bin/sh
2
+ # This script is used in .travis.yml for continuous integration on travis.
3
+ # BTW, it also show some needed system packages to build liquidity.
4
+ # Travis CI is done on Ubuntu trusty
5
+
6
+ sudo apt-get update -qq
7
+ sudo apt-get install -y -qq libgmp-dev pandoc # ocaml ocaml-native-compilers
8
+
9
+ # do this in a second step to only install libsecp256k1-dev libsecp256k1-0
10
+ # for ubuntu, these packages are not available in trusty
11
+ sudo add-apt-repository "deb http://cz.archive.ubuntu.com/ubuntu artful main universe"
12
+ sudo apt-get update -qq
13
+ sudo apt-get install -y -qq \
14
+ libsecp256k1-dev libsecp256k1-0 libsodium-dev libssl-dev \
15
+ bubblewrap libev-dev libhidapi-dev
16
+