universa 0.1.5 → 0.1.6
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.common_tools-3.8.3.jar → com.icodici.common_tools-3.8.4.jar} +0 -0
- data/bin/umi/lib/{com.icodici.crypto-3.8.3.jar → com.icodici.crypto-3.8.4.jar} +0 -0
- data/bin/umi/lib/{com.icodici.umi-0.8.10.jar → com.icodici.umi-0.8.11.jar} +0 -0
- data/bin/umi/lib/com.icodici.universa_core-3.8.4.jar +0 -0
- data/lib/universa/client.rb +1 -6
- data/lib/universa/contract.rb +109 -0
- data/lib/universa/keys.rb +15 -0
- data/lib/universa/service.rb +8 -4
- data/lib/universa/umi.rb +15 -3
- data/lib/universa/version.rb +1 -1
- metadata +6 -6
- data/bin/umi/lib/com.icodici.universa_core-3.8.3.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: 776f0bcfb9e7585da4111d9993189eae6b511997bf97aa5043b21087eef47fdf
|
4
|
+
data.tar.gz: fe9ba7b8e817d8861de95a295384fd42b2ef868989d409b00ab13dbce4fb84a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c3d0054df59af8d90215705005d718d845f9aea9bde929aca654968d40f516aeba94d4149faec8c13f9d679c4724cd0ea580ad0eab21738baa05414f7678a37
|
7
|
+
data.tar.gz: b2b15a3502bace0b271963bf8003fd64e37d2892cb53b7cfce2fabada446cfd218dae9b033ea3620bae52c9eb322e3efd80c6e810873f8e186dce822e4fcd5f2
|
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.11.jar:$lib_dir/org.scala-lang.scala-library-2.12.7.jar:$lib_dir/com.icodici.universa_core-3.8.4.jar:$lib_dir/org.yaml.snakeyaml-1.18.jar:$lib_dir/net.sf.jopt-simple.jopt-simple-4.9.jar:$lib_dir/org.postgresql.postgresql-42.1.4.jar:$lib_dir/org.xerial.sqlite-jdbc-3.8.9.1.jar:$lib_dir/com.icodici.nanohttpd-2.1.0.jar:$lib_dir/com.icodici.common_tools-3.8.4.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.8.4.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"
|
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.11.jar;%APP_LIB_DIR%\org.scala-lang.scala-library-2.12.7.jar;%APP_LIB_DIR%\com.icodici.universa_core-3.8.4.jar;%APP_LIB_DIR%\org.yaml.snakeyaml-1.18.jar;%APP_LIB_DIR%\net.sf.jopt-simple.jopt-simple-4.9.jar;%APP_LIB_DIR%\org.postgresql.postgresql-42.1.4.jar;%APP_LIB_DIR%\org.xerial.sqlite-jdbc-3.8.9.1.jar;%APP_LIB_DIR%\com.icodici.nanohttpd-2.1.0.jar;%APP_LIB_DIR%\com.icodici.common_tools-3.8.4.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.8.4.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"
|
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
|
Binary file
|
Binary file
|
Binary file
|
data/lib/universa/client.rb
CHANGED
@@ -131,9 +131,6 @@ module Universa
|
|
131
131
|
.transform_values!(&:sort)
|
132
132
|
# We roughly assume the full network size as:
|
133
133
|
network_max_size = nodes.size
|
134
|
-
nodes.each {|k, v|
|
135
|
-
puts "#{k}: (#{v.size}) #{v.map(&:rate)}}"
|
136
|
-
}
|
137
134
|
# Refine result: takes most voted nodes and only these with 80% consensus
|
138
135
|
# and map it to Connection objects
|
139
136
|
min_rate = n * 0.8
|
@@ -206,9 +203,7 @@ module Universa
|
|
206
203
|
# @param [String|Symbol] name of the command
|
207
204
|
# @return [SmartHash] with the command result
|
208
205
|
def execute name, **kwargs
|
209
|
-
|
210
|
-
connection.command name.to_s, *kwargs.to_a.flatten
|
211
|
-
}
|
206
|
+
connection.command name.to_s, *kwargs.to_a.flatten
|
212
207
|
end
|
213
208
|
|
214
209
|
protected
|
data/lib/universa/contract.rb
CHANGED
@@ -1,9 +1,70 @@
|
|
1
1
|
module Universa
|
2
2
|
|
3
|
+
# Adapter for Universa ChangeOwnerPermission
|
4
|
+
class ChangeOwnerPermission < RemoteAdapter
|
5
|
+
remote_class "com.icodici.universa.contract.permissions.ChangeOwnerPermission"
|
6
|
+
end
|
7
|
+
|
8
|
+
# Adapter for Universa Role
|
9
|
+
class Role < RemoteAdapter
|
10
|
+
remote_class "com.icodici.universa.contract.roles.Role"
|
11
|
+
end
|
12
|
+
|
13
|
+
# Adapter for Universa Binder class. Provides some ruby-style helpers
|
14
|
+
class Binder < RemoteAdapter
|
15
|
+
remote_class "net.sergeych.tools.Binder"
|
16
|
+
|
17
|
+
# Set object for a key
|
18
|
+
#
|
19
|
+
# @param [Object] key, key.to_s will be used (so use Symbols or Strings freely)
|
20
|
+
# @param [Object] value
|
21
|
+
def []=(key,value)
|
22
|
+
set(key.to_s, value)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Get object by key.
|
26
|
+
# @param [Object] key, key.to_s will be used (so use Symbols or Strings freely)
|
27
|
+
# @return [Object] or nil
|
28
|
+
def [](key)
|
29
|
+
get(key.to_s)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
3
33
|
# Universa contract adapter.
|
4
34
|
class Contract < RemoteAdapter
|
5
35
|
remote_class "com.icodici.universa.contract.Contract"
|
6
36
|
|
37
|
+
# Create simple contract with preset critical parts:
|
38
|
+
#
|
39
|
+
# - expiration set to 90 days unless specified else
|
40
|
+
# - issuer role is set to the address of the issuer key, short ot long
|
41
|
+
# - creator role is set as link to issuer
|
42
|
+
# - owner role is set as link to issuer
|
43
|
+
# - change owner permission is set to link to owner
|
44
|
+
#
|
45
|
+
# The while contract is then signed by the issuer key. Not that it will not seal it: caller almost always
|
46
|
+
# will add more data before it, then must call #seal().
|
47
|
+
#
|
48
|
+
# @param [PrivateKey] issuer_key also will be used to sign it
|
49
|
+
# @param [Time] expires_at defaults to 90 days
|
50
|
+
# @param [Boolean] use_short_address set to true to use short address of the issuer key in the role
|
51
|
+
# @return [Contract] simple contact, not sealed
|
52
|
+
def self.create issuer_key, expires_at: (Time.now + 90 * 24 * 60 * 60), use_short_address: false
|
53
|
+
contract = Contract.new
|
54
|
+
contract.set_expires_at expires_at
|
55
|
+
contract.set_issuer_keys(use_short_address ? issuer_key.short_address : issuer_key.long_address)
|
56
|
+
contract.register_role(contract.issuer.link_as("owner"))
|
57
|
+
contract.register_role(contract.issuer.link_as("creator"))
|
58
|
+
contract.add_permission ChangeOwnerPermission.new(contract.owner.link_as "@owner")
|
59
|
+
contract.add_signer_key issuer_key
|
60
|
+
contract
|
61
|
+
end
|
62
|
+
|
63
|
+
# Load from transaction pack
|
64
|
+
def self.from_packed packed
|
65
|
+
self.invoke_static "fromPackedTransaction", packed
|
66
|
+
end
|
67
|
+
|
7
68
|
# seal the contract
|
8
69
|
# @return [String] contract packed to the binary string
|
9
70
|
def seal
|
@@ -16,6 +77,54 @@ module Universa
|
|
16
77
|
get_keys_to_sign_with
|
17
78
|
end
|
18
79
|
|
80
|
+
# Shortcut ofr get_creator
|
81
|
+
# @return [Role] universa role of the creator
|
82
|
+
def creator
|
83
|
+
get_creator
|
84
|
+
end
|
85
|
+
|
86
|
+
# @return [Role] issuer role
|
87
|
+
def issuer
|
88
|
+
get_issuer
|
89
|
+
end
|
90
|
+
|
91
|
+
# @return [Role] owner role
|
92
|
+
def owner
|
93
|
+
get_owner
|
94
|
+
end
|
95
|
+
|
96
|
+
# Shortcut for is_ok
|
97
|
+
def ok?
|
98
|
+
is_ok
|
99
|
+
end
|
100
|
+
|
101
|
+
# shortcut for getHashId
|
102
|
+
def hash_id
|
103
|
+
get_id
|
104
|
+
end
|
105
|
+
|
106
|
+
# shortcut for get_expires_at
|
107
|
+
def expires_at
|
108
|
+
get_expires_at
|
109
|
+
end
|
110
|
+
|
111
|
+
# @return definition data
|
112
|
+
def definition
|
113
|
+
get_definition.get_data
|
114
|
+
end
|
115
|
+
|
116
|
+
def packed
|
117
|
+
get_packed_transaction
|
118
|
+
end
|
119
|
+
|
120
|
+
# trace found errors (call it afer check()): the Java version will not be able to trace to the
|
121
|
+
# process stdout, so we reqrite it here
|
122
|
+
def trace_errors
|
123
|
+
getErrors.each {|e|
|
124
|
+
puts "(#{e.object || ''}): #{e.error}"
|
125
|
+
}
|
126
|
+
end
|
127
|
+
|
19
128
|
end
|
20
129
|
|
21
130
|
end
|
data/lib/universa/keys.rb
CHANGED
@@ -47,6 +47,21 @@ module Universa
|
|
47
47
|
def to_s
|
48
48
|
@string ||= toString()
|
49
49
|
end
|
50
|
+
|
51
|
+
# Unpack from binary bytes
|
52
|
+
# @param [String] binary_string with binary packed bytes
|
53
|
+
def self.from_packed(binary_string)
|
54
|
+
binary_string.force_encoding 'binary'
|
55
|
+
KeyAddress.new(binary_string)
|
56
|
+
end
|
57
|
+
|
58
|
+
# returns binary representation. It is not a string representation!
|
59
|
+
# @return [String] binary string representation
|
60
|
+
def packed
|
61
|
+
s = get_packed
|
62
|
+
s.force_encoding 'binary'
|
63
|
+
s
|
64
|
+
end
|
50
65
|
end
|
51
66
|
|
52
67
|
end
|
data/lib/universa/service.rb
CHANGED
@@ -14,7 +14,7 @@ module Universa
|
|
14
14
|
def initialize
|
15
15
|
@config = SmartHash.new path: nil
|
16
16
|
@known_proxies = {}
|
17
|
-
[Contract, PrivateKey, PublicKey, KeyAddress].each {|klass| register_proxy klass}
|
17
|
+
[Contract, PrivateKey, PublicKey, KeyAddress, Binder, Role, ChangeOwnerPermission].each {|klass| register_proxy klass}
|
18
18
|
end
|
19
19
|
|
20
20
|
# Implementation of {Service.configure}
|
@@ -92,7 +92,7 @@ module Universa
|
|
92
92
|
# User called constructor
|
93
93
|
remote_class_name = self.class.remote_class_name
|
94
94
|
remote_class_name&.length or raise Error, "provide remote_class_name"
|
95
|
-
@remote = Service.umi.instantiate remote_class_name
|
95
|
+
@remote = Service.umi.instantiate remote_class_name, *args, adapter: self
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
@@ -119,13 +119,13 @@ module Universa
|
|
119
119
|
#
|
120
120
|
# @return [String] remote class name
|
121
121
|
def self.remote_class_name
|
122
|
-
raise Error, "provde remote class name"
|
122
|
+
@remote_class_name or raise Error, "provde remote class name"
|
123
123
|
end
|
124
124
|
|
125
125
|
# Registers remote class name to be used with this adapted. Call it early in descendant class
|
126
126
|
# declaration.
|
127
127
|
def self.remote_class name
|
128
|
-
|
128
|
+
@remote_class_name = name
|
129
129
|
end
|
130
130
|
|
131
131
|
# debugging label
|
@@ -138,6 +138,10 @@ module Universa
|
|
138
138
|
def to_s
|
139
139
|
toString()
|
140
140
|
end
|
141
|
+
|
142
|
+
def self.invoke_static(method_name, *args)
|
143
|
+
Service.umi.invoke_static @remote_class_name, method_name, *args
|
144
|
+
end
|
141
145
|
end
|
142
146
|
|
143
147
|
end
|
data/lib/universa/umi.rb
CHANGED
@@ -106,10 +106,13 @@ module Universa
|
|
106
106
|
ensure_open
|
107
107
|
ref._umi == self or raise InterchangeError
|
108
108
|
@convert_case and method = method.to_s.camelize_lower
|
109
|
+
# p ["invoke", ref._remote_id, method, *prepare_args(args)]
|
109
110
|
result = call("invoke", ref._remote_id, method, *prepare_args(args))
|
110
111
|
encode_result result
|
111
|
-
|
112
|
-
|
112
|
+
end
|
113
|
+
|
114
|
+
def invoke_static(class_name, method, *args)
|
115
|
+
encode_result call("invoke", class_name, method, *prepare_args(args))
|
113
116
|
end
|
114
117
|
|
115
118
|
# Close child process. No remote calls should occur after it.
|
@@ -236,6 +239,8 @@ module Universa
|
|
236
239
|
x._as_umi_arg(self)
|
237
240
|
else
|
238
241
|
case x
|
242
|
+
when Time
|
243
|
+
{ __type: 'unixtime', seconds: x.to_i}
|
239
244
|
when String
|
240
245
|
x.encoding == Encoding::BINARY ? {__type: 'binary', base64: Base64.encode64(x)} : x
|
241
246
|
else
|
@@ -280,6 +285,13 @@ module Universa
|
|
280
285
|
result = @endpoint.sync_call(command, *args, **EMPTY_KWARGS)
|
281
286
|
log "<< #{result}"
|
282
287
|
result
|
288
|
+
rescue Farcall::RemoteError => e
|
289
|
+
case e.remote_class
|
290
|
+
when 'NoSuchMethodException'
|
291
|
+
raise NoMethodError, e.message
|
292
|
+
else
|
293
|
+
raise
|
294
|
+
end
|
283
295
|
end
|
284
296
|
|
285
297
|
def log msg
|
@@ -362,7 +374,7 @@ module Universa
|
|
362
374
|
method_name[0] == '_' || LOCAL_METHODS.include?(method_name) ? super : true
|
363
375
|
end
|
364
376
|
|
365
|
-
#Internal use only. Call remote method as needed. This is where all the magick comes from: it call remote method instead of the
|
377
|
+
# Internal use only. Call remote method as needed. This is where all the magick comes from: it call remote method instead of the
|
366
378
|
# local one, exactly like it is local.
|
367
379
|
def method_missing(method_name, *args, &block)
|
368
380
|
if method_name[0] == '_'
|
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: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sergeych
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: farcall
|
@@ -134,11 +134,11 @@ files:
|
|
134
134
|
- bin/umi/lib/com.fasterxml.jackson.core.jackson-databind-2.8.11.1.jar
|
135
135
|
- bin/umi/lib/com.fasterxml.jackson.datatype.jackson-datatype-jdk8-2.8.11.jar
|
136
136
|
- bin/umi/lib/com.fasterxml.jackson.datatype.jackson-datatype-jsr310-2.8.11.jar
|
137
|
-
- bin/umi/lib/com.icodici.common_tools-3.8.
|
138
|
-
- bin/umi/lib/com.icodici.crypto-3.8.
|
137
|
+
- bin/umi/lib/com.icodici.common_tools-3.8.4.jar
|
138
|
+
- bin/umi/lib/com.icodici.crypto-3.8.4.jar
|
139
139
|
- bin/umi/lib/com.icodici.nanohttpd-2.1.0.jar
|
140
|
-
- bin/umi/lib/com.icodici.umi-0.8.
|
141
|
-
- bin/umi/lib/com.icodici.universa_core-3.8.
|
140
|
+
- bin/umi/lib/com.icodici.umi-0.8.11.jar
|
141
|
+
- bin/umi/lib/com.icodici.universa_core-3.8.4.jar
|
142
142
|
- bin/umi/lib/com.madgag.spongycastle.core-1.58.0.0.jar
|
143
143
|
- bin/umi/lib/com.squareup.jnagmp.jnagmp-2.0.0.jar
|
144
144
|
- bin/umi/lib/com.typesafe.play.play-functional_2.12-2.6.10.jar
|
Binary file
|