universa 3.9.15.pre.p1 → 3.9.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/umi/bin/umi +1 -1
- data/bin/umi/bin/umi.bat +1 -1
- data/bin/umi/lib/com.icodici.umi-0.8.37.jar +0 -0
- data/lib/universa/binder.rb +2 -2
- data/lib/universa/client.rb +29 -6
- data/lib/universa/contract.rb +52 -0
- data/lib/universa/fs_store/entry.rb +1 -1
- data/lib/universa/keys.rb +34 -1
- data/lib/universa/service.rb +21 -0
- data/lib/universa/stored_contract.rb +3 -1
- data/lib/universa/umi.rb +22 -3
- data/lib/universa/version.rb +1 -1
- metadata +5 -5
- data/bin/umi/lib/com.icodici.umi-0.8.33.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bc5b6550d105950c9c59fef72324f3af743e0b6ccc3a0891ff64a8010065bae
|
4
|
+
data.tar.gz: db76654eae0a780974b7f4b187f23263e8cdc9ff02bebae8f0ed780eb2d196a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e6b607b71fdbb33cad3d2a9685f0f0e6d454ff427a482147d3211ecac5391af977d4a56ed33d31cf45da21e83b8442a13bebf32ec6e80c7faf6af36bef35eba
|
7
|
+
data.tar.gz: ee82130ccfc7e36de600b2a811e0252c2626b81020650b3f867a849e292cbca325d9aad5ca45dbcf0e75d5d5a2a236e1b5b697ad6e2bd6028c147a51bea39197
|
data/bin/umi/bin/umi
CHANGED
@@ -344,7 +344,7 @@ declare -r lib_dir="$(realpath "${app_home}/../lib")"
|
|
344
344
|
declare -a app_mainclass=(com.icodici.farcallscala.Main)
|
345
345
|
|
346
346
|
declare -r script_conf_file="${app_home}/../conf/application.ini"
|
347
|
-
declare -r app_classpath="$lib_dir/com.icodici.umi-0.8.
|
347
|
+
declare -r app_classpath="$lib_dir/com.icodici.umi-0.8.37.jar:$lib_dir/org.scala-lang.scala-library-2.12.7.jar:$lib_dir/com.icodici.universa_core-3.9.14.jar:$lib_dir/org.yaml.snakeyaml-1.18.jar:$lib_dir/com.icodici.nanohttpd-2.1.0.jar:$lib_dir/com.icodici.common_tools-3.9.14.jar:$lib_dir/com.eclipsesource.minimal-json.minimal-json-0.9.4.jar:$lib_dir/net.java.dev.jna.jna-4.5.1.jar:$lib_dir/org.checkerframework.checker-qual-2.3.2.jar:$lib_dir/com.icodici.crypto-3.9.14.jar:$lib_dir/com.madgag.spongycastle.core-1.58.0.0.jar:$lib_dir/com.squareup.jnagmp.jnagmp-2.0.0.jar:$lib_dir/com.typesafe.play.play-json_2.12-2.6.10.jar:$lib_dir/com.typesafe.play.play-functional_2.12-2.6.10.jar:$lib_dir/org.scala-lang.scala-reflect-2.12.7.jar:$lib_dir/org.typelevel.macro-compat_2.12-1.1.1.jar:$lib_dir/joda-time.joda-time-2.9.9.jar:$lib_dir/com.fasterxml.jackson.core.jackson-core-2.8.11.jar:$lib_dir/com.fasterxml.jackson.core.jackson-annotations-2.8.11.jar:$lib_dir/com.fasterxml.jackson.datatype.jackson-datatype-jdk8-2.8.11.jar:$lib_dir/com.fasterxml.jackson.core.jackson-databind-2.8.11.1.jar:$lib_dir/com.fasterxml.jackson.datatype.jackson-datatype-jsr310-2.8.11.jar:$lib_dir/org.scala-sbt.ipcsocket.ipcsocket-1.0.0.jar:$lib_dir/net.java.dev.jna.jna-platform-4.5.0.jar:$lib_dir/net.sf.jopt-simple.jopt-simple-4.9.jar"
|
348
348
|
|
349
349
|
# java_cmd is overrode in process_args when -java-home is used
|
350
350
|
declare java_cmd=$(get_java_cmd)
|
data/bin/umi/bin/umi.bat
CHANGED
@@ -80,7 +80,7 @@ rem "-J" is stripped, "-D" is left as is, and everything is appended to JAVA_OPT
|
|
80
80
|
set _JAVA_PARAMS=
|
81
81
|
set _APP_ARGS=
|
82
82
|
|
83
|
-
set "APP_CLASSPATH=%APP_LIB_DIR%\com.icodici.umi-0.8.
|
83
|
+
set "APP_CLASSPATH=%APP_LIB_DIR%\com.icodici.umi-0.8.37.jar;%APP_LIB_DIR%\org.scala-lang.scala-library-2.12.7.jar;%APP_LIB_DIR%\com.icodici.universa_core-3.9.14.jar;%APP_LIB_DIR%\org.yaml.snakeyaml-1.18.jar;%APP_LIB_DIR%\com.icodici.nanohttpd-2.1.0.jar;%APP_LIB_DIR%\com.icodici.common_tools-3.9.14.jar;%APP_LIB_DIR%\com.eclipsesource.minimal-json.minimal-json-0.9.4.jar;%APP_LIB_DIR%\net.java.dev.jna.jna-4.5.1.jar;%APP_LIB_DIR%\org.checkerframework.checker-qual-2.3.2.jar;%APP_LIB_DIR%\com.icodici.crypto-3.9.14.jar;%APP_LIB_DIR%\com.madgag.spongycastle.core-1.58.0.0.jar;%APP_LIB_DIR%\com.squareup.jnagmp.jnagmp-2.0.0.jar;%APP_LIB_DIR%\com.typesafe.play.play-json_2.12-2.6.10.jar;%APP_LIB_DIR%\com.typesafe.play.play-functional_2.12-2.6.10.jar;%APP_LIB_DIR%\org.scala-lang.scala-reflect-2.12.7.jar;%APP_LIB_DIR%\org.typelevel.macro-compat_2.12-1.1.1.jar;%APP_LIB_DIR%\joda-time.joda-time-2.9.9.jar;%APP_LIB_DIR%\com.fasterxml.jackson.core.jackson-core-2.8.11.jar;%APP_LIB_DIR%\com.fasterxml.jackson.core.jackson-annotations-2.8.11.jar;%APP_LIB_DIR%\com.fasterxml.jackson.datatype.jackson-datatype-jdk8-2.8.11.jar;%APP_LIB_DIR%\com.fasterxml.jackson.core.jackson-databind-2.8.11.1.jar;%APP_LIB_DIR%\com.fasterxml.jackson.datatype.jackson-datatype-jsr310-2.8.11.jar;%APP_LIB_DIR%\org.scala-sbt.ipcsocket.ipcsocket-1.0.0.jar;%APP_LIB_DIR%\net.java.dev.jna.jna-platform-4.5.0.jar;%APP_LIB_DIR%\net.sf.jopt-simple.jopt-simple-4.9.jar"
|
84
84
|
set "APP_MAIN_CLASS=com.icodici.farcallscala.Main"
|
85
85
|
set "SCRIPT_CONF_FILE=%APP_HOME%\conf\application.ini"
|
86
86
|
|
Binary file
|
data/lib/universa/binder.rb
CHANGED
data/lib/universa/client.rb
CHANGED
@@ -67,14 +67,37 @@ module Universa
|
|
67
67
|
(0...size).to_a.sample(number).map {|n| self[n]}
|
68
68
|
end
|
69
69
|
|
70
|
-
# Perform fast consensus state check with a given trust level,
|
71
|
-
#
|
72
|
-
# trust level is, the faster the answer will be found.
|
70
|
+
# Perform fast consensus state check with a given trust level, determining whether the item is approved or not.
|
71
|
+
# Blocks for 1 minute or until the network solution will be collected for a given trust level.
|
73
72
|
#
|
74
|
-
# @param [Contract | HashId] obj contract to check
|
73
|
+
# @param [Contract | HashId | String | Binary] obj contract to check
|
75
74
|
# @param [Object] trust level, should be between 0.1 (10% of network) and 0.9 (90% of the network)
|
76
|
-
# @return
|
77
|
-
def
|
75
|
+
# @return true if the contract state is approved by the network with a given trust level, false otherwise.
|
76
|
+
def is_approved? obj, trust: 0.3
|
77
|
+
hash_id = case obj
|
78
|
+
when HashId
|
79
|
+
obj
|
80
|
+
when Contract
|
81
|
+
obj.hash_id
|
82
|
+
when String
|
83
|
+
if obj.encoding == Encoding::ASCII_8BIT
|
84
|
+
HashId.from_digest(obj)
|
85
|
+
else
|
86
|
+
HashId.from_string(obj)
|
87
|
+
end
|
88
|
+
else
|
89
|
+
raise ArgumentError "wrong type of object to check approval"
|
90
|
+
end
|
91
|
+
@client.isApprovedByNetwork(hash_id, trust.to_f, 60000)
|
92
|
+
end
|
93
|
+
# Perform fast consensus state check with a given trust level, as the fraction of the whole network size.
|
94
|
+
# It checks the network nodes randomly until get enough positive or negative states. The lover the required
|
95
|
+
# trust level is, the faster the answer will be found.
|
96
|
+
#
|
97
|
+
# @param [Contract | HashId] obj contract to check
|
98
|
+
# @param [Object] trust level, should be between 0.1 (10% of network) and 0.9 (90% of the network)
|
99
|
+
# @return [ContractState] of some final node check It does not calculates average time (yet)
|
100
|
+
def get_state obj, trust: 0.3
|
78
101
|
raise ArgumentError, "trusst must be in 0.1..0.9 range" if trust < 0.1 || trust > 0.9
|
79
102
|
result = Concurrent::IVar.new
|
80
103
|
negative_votes = Concurrent::AtomicFixnum.new((size * 0.1).round + 1)
|
data/lib/universa/contract.rb
CHANGED
@@ -12,6 +12,7 @@ module Universa
|
|
12
12
|
remote_class "com.icodici.universa.contract.permissions.RevokePermission"
|
13
13
|
end
|
14
14
|
|
15
|
+
# Adapter for plitjoin permission
|
15
16
|
class SplitJoinPermission < RemoteAdapter
|
16
17
|
remote_class "com.icodici.universa.contract.permissions.SplitJoinPermission"
|
17
18
|
end
|
@@ -19,9 +20,53 @@ module Universa
|
|
19
20
|
# Adapter for Universa Role
|
20
21
|
class Role < RemoteAdapter
|
21
22
|
remote_class "com.icodici.universa.contract.roles.Role"
|
23
|
+
|
24
|
+
class RequireMode
|
25
|
+
ALL_OF = "ALL_OF"
|
26
|
+
ANY_OF = "ANY_OF"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Adaoter for link role
|
31
|
+
class RoleLink < RemoteAdapter
|
32
|
+
remote_class "com.icodici.universa.contract.roles.RoleLink"
|
33
|
+
end
|
34
|
+
|
35
|
+
# adapter for a simple (key owner) role
|
36
|
+
class SimpleRole < RemoteAdapter
|
37
|
+
remote_class "com.icodici.universa.contract.roles.SimpleRole"
|
38
|
+
end
|
39
|
+
|
40
|
+
# adapter for a role that is a list of roles
|
41
|
+
class ListRole < RemoteAdapter
|
42
|
+
remote_class "com.icodici.universa.contract.roles.ListRole"
|
43
|
+
end
|
44
|
+
|
45
|
+
# Adapter for permission to modify data
|
46
|
+
class ModifyDataPermission < RemoteAdapter
|
47
|
+
remote_class "com.icodici.universa.contract.permissions.ModifyDataPermission"
|
22
48
|
end
|
23
49
|
|
24
50
|
|
51
|
+
# Wrapper for Java API Reference class
|
52
|
+
|
53
|
+
class Reference < RemoteAdapter
|
54
|
+
remote_class "com.icodici.universa.contract.Reference"
|
55
|
+
|
56
|
+
remote_field :name, :type, :transactional_id, :contract_id, :required, :origin, :signed_by, :fields, :roles,
|
57
|
+
:matchingItems
|
58
|
+
|
59
|
+
alias matching_items matchingItems
|
60
|
+
|
61
|
+
ALL_OF = 'all_of'
|
62
|
+
ANY_OF = 'any_of'
|
63
|
+
SIMPLE_CONDITION = 'simple_condition'
|
64
|
+
|
65
|
+
TYPE_TRANSACTIONAL = 1
|
66
|
+
TYPE_EXISTING_DEFINITION = 2
|
67
|
+
TYPE_EXISTING_STATE = 3
|
68
|
+
end
|
69
|
+
|
25
70
|
# adapter for Universa TransactionPack
|
26
71
|
class TransactionPack < RemoteAdapter
|
27
72
|
remote_class "com.icodici.universa.contract.TransactionPack"
|
@@ -57,6 +102,13 @@ module Universa
|
|
57
102
|
invoke_static 'with_digest', string_id
|
58
103
|
end
|
59
104
|
|
105
|
+
# Create a random HashId
|
106
|
+
# @return [HashId] random HashId
|
107
|
+
def self.create_random
|
108
|
+
invoke_static 'create_random'
|
109
|
+
end
|
110
|
+
|
111
|
+
|
60
112
|
# Get binary representation. It is shorter than string representation but contain non-printable characters and
|
61
113
|
# can cause problems if treated like a string. Use {#to_s} to get string representation instead.
|
62
114
|
#
|
@@ -11,7 +11,7 @@ module Universa::FSStore
|
|
11
11
|
# @!method amount
|
12
12
|
# @return [BigDecimal] +contract.state.data.amount+ or nil. See {Contract#amount} for more.
|
13
13
|
#
|
14
|
-
class Entry < Universa::
|
14
|
+
class Entry < Universa::StoredContractBase
|
15
15
|
|
16
16
|
extend Forwardable
|
17
17
|
|
data/lib/universa/keys.rb
CHANGED
@@ -35,7 +35,7 @@ module Universa
|
|
35
35
|
end
|
36
36
|
|
37
37
|
# A +com.icodici.crypto.PublicKey+ extension. As the key is immutable,
|
38
|
-
# caching is used to avoid
|
38
|
+
# caching is used to avoid unnecessary UMI calls.
|
39
39
|
class PublicKey < RemoteAdapter
|
40
40
|
remote_class 'com.icodici.crypto.PublicKey'
|
41
41
|
|
@@ -50,6 +50,39 @@ module Universa
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
+
# A +com.icodici.crypto.SymmetricKey+ extension. As the key is immutable,
|
54
|
+
# caching is used to avoid unnecessary UMI calls.
|
55
|
+
class SymmetricKey < RemoteAdapter
|
56
|
+
remote_class 'com.icodici.crypto.SymmetricKey'
|
57
|
+
|
58
|
+
# Derive key from password using PBKDF2 standard
|
59
|
+
# @param [String] password to derive key from
|
60
|
+
# @param [Object] rounds derivation rounds
|
61
|
+
# @param [Object] salt optional salt used to disallow detect password match by key match
|
62
|
+
# @return [SymmetricKey] instance
|
63
|
+
def self.from_password(password, rounds, salt=nil)
|
64
|
+
salt.force_encoding(Encoding::BINARY) if salt
|
65
|
+
invoke_static 'fromPassword', password, rounds, salt
|
66
|
+
end
|
67
|
+
|
68
|
+
# How many bits contains the key
|
69
|
+
# @return [Integer] size in bits
|
70
|
+
def size_in_bits
|
71
|
+
@bit_strength ||= getBitStrength()
|
72
|
+
end
|
73
|
+
|
74
|
+
# @return [Integer] size in bytes
|
75
|
+
def size
|
76
|
+
@size ||= getSize()
|
77
|
+
end
|
78
|
+
|
79
|
+
# Get the key as binary string
|
80
|
+
# @return [String] key bytes (binary string)
|
81
|
+
def key
|
82
|
+
@key ||= getKey()
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
53
86
|
# The +com.icodici.crypto.KeyAddress+ extension. As it is immutable, caching is
|
54
87
|
# used to avoid unnecessary UMI calls.
|
55
88
|
class KeyAddress < RemoteAdapter
|
data/lib/universa/service.rb
CHANGED
@@ -143,6 +143,27 @@ module Universa
|
|
143
143
|
def self.invoke_static(method_name, *args)
|
144
144
|
Service.umi.invoke_static @remote_class_name, method_name, *args
|
145
145
|
end
|
146
|
+
|
147
|
+
def self.remote_field *names
|
148
|
+
names.each {|name|
|
149
|
+
class_eval <<-End
|
150
|
+
def #{name}
|
151
|
+
Service.umi.get_field(self,"#{name}")
|
152
|
+
end
|
153
|
+
def #{name}=(value)
|
154
|
+
Service.umi.set_field(self,"#{name}", value)
|
155
|
+
end
|
156
|
+
End
|
157
|
+
}
|
158
|
+
end
|
159
|
+
|
160
|
+
def self.static_method name
|
161
|
+
class_eval <<-End
|
162
|
+
def self.#{name} *args
|
163
|
+
invoke_static "#{name.to_s}", *args
|
164
|
+
end
|
165
|
+
End
|
166
|
+
end
|
146
167
|
end
|
147
168
|
|
148
169
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Universa
|
2
2
|
|
3
|
+
# under construction, pls on not use yet
|
4
|
+
#
|
3
5
|
# this is a base class for a contract stored in some contract chain. The implementation
|
4
6
|
# must inherit and implement its {#load} and {#save} methods at least. To do it,
|
5
7
|
# inherit and implement {ChainStore} to work with it.
|
@@ -9,7 +11,7 @@ module Universa
|
|
9
11
|
# - contract could be assigned only once, no matter how, so its fields could be cached.
|
10
12
|
# - origin, hash_id and parent are cached. So other contract parameters should be.
|
11
13
|
#
|
12
|
-
class
|
14
|
+
class StoredContractBase
|
13
15
|
|
14
16
|
# {ChainStore} instance to which it is connected
|
15
17
|
attr :chain_store
|
data/lib/universa/umi.rb
CHANGED
@@ -122,6 +122,19 @@ module Universa
|
|
122
122
|
encode_result call("invoke", class_name, method.to_s.camelize_lower, *prepare_args(args))
|
123
123
|
end
|
124
124
|
|
125
|
+
def get_field(remote_object, name)
|
126
|
+
encode_result call("get_field", remote_object._remote_id, name)
|
127
|
+
end
|
128
|
+
|
129
|
+
def set_field(remote_object, name, value)
|
130
|
+
call("set_field", remote_object._remote_id, name, prepare(value))
|
131
|
+
value
|
132
|
+
end
|
133
|
+
|
134
|
+
def invoke_static(class_name, method, *args)
|
135
|
+
encode_result call("invoke", class_name, method.to_s.camelize_lower, *prepare_args(args))
|
136
|
+
end
|
137
|
+
|
125
138
|
# Close child process. No remote calls should occur after it.
|
126
139
|
def close
|
127
140
|
@queue.push :poison_pill
|
@@ -247,7 +260,9 @@ module Universa
|
|
247
260
|
|
248
261
|
# convert single argument to UMI value to pass
|
249
262
|
def prepare(x)
|
263
|
+
# p [:pre, x]
|
250
264
|
if x.respond_to?(:_as_umi_arg)
|
265
|
+
# p ["uniarg"]
|
251
266
|
x._as_umi_arg(self)
|
252
267
|
else
|
253
268
|
case x
|
@@ -266,13 +281,16 @@ module Universa
|
|
266
281
|
when String
|
267
282
|
x.encoding == Encoding::BINARY ? {__type: 'binary', base64: Base64.encode64(x)} : x
|
268
283
|
when Ref
|
284
|
+
# p [:ref]
|
269
285
|
x._as_umi_arg(self)
|
270
286
|
when RemoteAdapter
|
287
|
+
# p [:ra, x.__getobj__._as_umi_arg(self)]
|
271
288
|
# this need special treatment with direct call:
|
272
289
|
x.__getobj__._as_umi_arg(self)
|
273
290
|
when Hash
|
291
|
+
# p [:hash]
|
274
292
|
result = {}
|
275
|
-
x.each {
|
293
|
+
x.each {|k, v| result[k] = prepare(v)}
|
276
294
|
result
|
277
295
|
else
|
278
296
|
x
|
@@ -283,7 +301,7 @@ module Universa
|
|
283
301
|
# Convert remote call result from UMI structures to ruby types
|
284
302
|
def encode_result value
|
285
303
|
case value
|
286
|
-
when
|
304
|
+
when Hash
|
287
305
|
type = value.__type
|
288
306
|
case type
|
289
307
|
when 'RemoteObject';
|
@@ -293,7 +311,8 @@ module Universa
|
|
293
311
|
when 'unixtime';
|
294
312
|
Time.at(value.seconds)
|
295
313
|
else
|
296
|
-
|
314
|
+
# Deep hash conversion
|
315
|
+
value.transform_values! {|v| encode_result(v)}
|
297
316
|
end
|
298
317
|
when Hashie::Array
|
299
318
|
value.map {|x| encode_result x}
|
data/lib/universa/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: universa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.9.15
|
4
|
+
version: 3.9.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sergeych
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: farcall
|
@@ -139,7 +139,7 @@ files:
|
|
139
139
|
- bin/umi/lib/com.icodici.common_tools-3.9.14.jar
|
140
140
|
- bin/umi/lib/com.icodici.crypto-3.9.14.jar
|
141
141
|
- bin/umi/lib/com.icodici.nanohttpd-2.1.0.jar
|
142
|
-
- bin/umi/lib/com.icodici.umi-0.8.
|
142
|
+
- bin/umi/lib/com.icodici.umi-0.8.37.jar
|
143
143
|
- bin/umi/lib/com.icodici.universa_core-3.9.14.jar
|
144
144
|
- bin/umi/lib/com.madgag.spongycastle.core-1.58.0.0.jar
|
145
145
|
- bin/umi/lib/com.squareup.jnagmp.jnagmp-2.0.0.jar
|
@@ -192,9 +192,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
192
192
|
version: '0'
|
193
193
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
194
194
|
requirements:
|
195
|
-
- - "
|
195
|
+
- - ">="
|
196
196
|
- !ruby/object:Gem::Version
|
197
|
-
version:
|
197
|
+
version: '0'
|
198
198
|
requirements: []
|
199
199
|
rubygems_version: 3.0.3
|
200
200
|
signing_key:
|
Binary file
|