scale_rb 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/Gemfile.lock +1 -1
- data/lib/client/http_client.rb +5 -2
- data/lib/metadata/metadata_v10.rb +1 -0
- data/lib/metadata/metadata_v11.rb +1 -0
- data/lib/metadata/metadata_v12.rb +1 -0
- data/lib/metadata/metadata_v13.rb +1 -0
- data/lib/metadata/metadata_v14.rb +1 -0
- data/lib/metadata/metadata_v9.rb +1 -0
- data/lib/portable_codec.rb +6 -0
- data/lib/scale_rb/version.rb +1 -1
- data/lib/storage_helper.rb +11 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c6c07616c5b65f7aee2b0504956231534d94cd3df9eba9320e4a22d2a38aed2
|
4
|
+
data.tar.gz: f2f3572c5d7ed389d5772c6245fb2e02eb75d57cf5ff28b78a8db82642d47402
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1709366a718feafae82a60b5a5aeb05e5e78fbc3160c151de66b2be25e62ad3f6031c50db0097cc1880c00ec263962f45b4cf3fcb6f4ccd0d13ab48ce9b84976
|
7
|
+
data.tar.gz: 231963a7fc17cc7d25ec5aded79120f11733e97d81edf58f4f2fc31edbb11865b435bd286b9817db744d98bad8751433eb68e809d567f9590d5ee70c5687b97d
|
data/Gemfile.lock
CHANGED
data/lib/client/http_client.rb
CHANGED
@@ -104,9 +104,10 @@ module ScaleRb
|
|
104
104
|
# },
|
105
105
|
# ..
|
106
106
|
#
|
107
|
+
# TODO: part of the key is provided, but not all
|
107
108
|
def get_storage(url, pallet_name, item_name, key, value, registry, at = nil)
|
108
109
|
# map, but no key's value provided. get all storages under the partial storage key
|
109
|
-
if
|
110
|
+
if key && (key[:value].nil? || key[:value].empty?)
|
110
111
|
partial_storage_key = StorageHelper.encode_storage_key(pallet_name, item_name).to_hex
|
111
112
|
get_storages_by_partial_key(
|
112
113
|
url,
|
@@ -124,10 +125,11 @@ module ScaleRb
|
|
124
125
|
end
|
125
126
|
|
126
127
|
def get_storage2(url, pallet_name, item_name, value_of_key, metadata, at = nil)
|
127
|
-
raise '
|
128
|
+
raise 'Metadata should not be nil' if metadata.nil?
|
128
129
|
|
129
130
|
registry = Metadata.build_registry(metadata)
|
130
131
|
item = Metadata.get_storage_item(pallet_name, item_name, metadata)
|
132
|
+
raise "No such storage item: `#{pallet_name}`.`#{item_name}`" if item.nil?
|
131
133
|
|
132
134
|
modifier = item._get(:modifier) # Default | Optional
|
133
135
|
fallback = item._get(:fallback)
|
@@ -135,6 +137,7 @@ module ScaleRb
|
|
135
137
|
|
136
138
|
plain = type._get(:plain)
|
137
139
|
map = type._get(:map)
|
140
|
+
# debug
|
138
141
|
|
139
142
|
key, value =
|
140
143
|
if plain
|
@@ -11,6 +11,7 @@ module Metadata
|
|
11
11
|
|
12
12
|
def get_storage_item(module_name, item_name, metadata)
|
13
13
|
modula = get_module(module_name, metadata)
|
14
|
+
raise "Module `#{module_name}` not found" if modula.nil?
|
14
15
|
modula._get(:storage)._get(:items).find do |item|
|
15
16
|
item._get(:name) == item_name
|
16
17
|
end
|
@@ -11,6 +11,7 @@ module Metadata
|
|
11
11
|
|
12
12
|
def get_storage_item(module_name, item_name, metadata)
|
13
13
|
modula = get_module(module_name, metadata)
|
14
|
+
raise "Module `#{module_name}` not found" if modula.nil?
|
14
15
|
modula._get(:storage)._get(:items).find do |item|
|
15
16
|
item._get(:name) == item_name
|
16
17
|
end
|
@@ -11,6 +11,7 @@ module Metadata
|
|
11
11
|
|
12
12
|
def get_storage_item(module_name, item_name, metadata)
|
13
13
|
modula = get_module(module_name, metadata)
|
14
|
+
raise "Module `#{module_name}` not found" if modula.nil?
|
14
15
|
modula._get(:storage)._get(:items).find do |item|
|
15
16
|
item._get(:name) == item_name
|
16
17
|
end
|
@@ -11,6 +11,7 @@ module Metadata
|
|
11
11
|
|
12
12
|
def get_storage_item(module_name, item_name, metadata)
|
13
13
|
modula = get_module(module_name, metadata)
|
14
|
+
raise "Module `#{module_name}` not found" if modula.nil?
|
14
15
|
modula._get(:storage)._get(:items).find do |item|
|
15
16
|
item._get(:name) == item_name
|
16
17
|
end
|
@@ -16,6 +16,7 @@ module Metadata
|
|
16
16
|
|
17
17
|
def get_storage_item(pallet_name, item_name, metadata)
|
18
18
|
pallet = get_module(pallet_name, metadata)
|
19
|
+
raise "Pallet `#{pallet_name}` not found" if pallet.nil?
|
19
20
|
pallet._get(:storage)._get(:items).find do |item|
|
20
21
|
item._get(:name) == item_name
|
21
22
|
end
|
data/lib/metadata/metadata_v9.rb
CHANGED
@@ -11,6 +11,7 @@ module Metadata
|
|
11
11
|
|
12
12
|
def get_storage_item(module_name, item_name, metadata)
|
13
13
|
modula = get_module(module_name, metadata)
|
14
|
+
raise "Module `#{module_name}` not found" if modula.nil?
|
14
15
|
modula._get(:storage)._get(:items).find do |item|
|
15
16
|
item._get(:name) == item_name
|
16
17
|
end
|
data/lib/portable_codec.rb
CHANGED
@@ -134,6 +134,9 @@ module PortableCodec
|
|
134
134
|
raise TypeNotFound, "id: #{id}" if type.nil?
|
135
135
|
|
136
136
|
type_def = type._get(:def)
|
137
|
+
# debug
|
138
|
+
# p type_def
|
139
|
+
# p value
|
137
140
|
|
138
141
|
return encode_primitive(type_def, value) if type_def._key?(:primitive)
|
139
142
|
return encode_compact(value) if type_def._key?(:compact)
|
@@ -188,6 +191,9 @@ module PortableCodec
|
|
188
191
|
fields = composite_type._get(:fields)
|
189
192
|
# reduce composite level when composite only has one field without name
|
190
193
|
if fields.length == 1 && fields.first._get(:name).nil?
|
194
|
+
# debug
|
195
|
+
# p fields.first._get(:type)
|
196
|
+
# p value
|
191
197
|
encode(fields.first._get(:type), value, registry)
|
192
198
|
else
|
193
199
|
values =
|
data/lib/scale_rb/version.rb
CHANGED
data/lib/storage_helper.rb
CHANGED
@@ -12,11 +12,11 @@ module StorageHelper
|
|
12
12
|
|
13
13
|
if key && registry
|
14
14
|
|
15
|
-
|
15
|
+
key_types, key_values =
|
16
16
|
if key[:hashers].length == 1
|
17
17
|
[
|
18
18
|
[key[:type]],
|
19
|
-
|
19
|
+
key[:value]
|
20
20
|
]
|
21
21
|
else
|
22
22
|
[
|
@@ -25,7 +25,13 @@ module StorageHelper
|
|
25
25
|
]
|
26
26
|
end
|
27
27
|
|
28
|
-
|
28
|
+
# debug
|
29
|
+
# p "encode_storage_key -----------------------"
|
30
|
+
# p key_types
|
31
|
+
# p key_values
|
32
|
+
# p "encode_storage_key -----------------------"
|
33
|
+
raise "Key's value doesn't match key's type, key's value: #{key_values.inspect}, but key's type: #{key_types.inspect}. Please check your key's value." if key_types.class != key_values.class || key_types.length != key_values.length
|
34
|
+
storage_key + PortableCodec._encode_types_with_hashers(key_types, key_values, registry, key[:hashers])
|
29
35
|
else
|
30
36
|
storage_key
|
31
37
|
end
|
@@ -35,9 +41,10 @@ module StorageHelper
|
|
35
41
|
# type: portable type id
|
36
42
|
# optional: boolean
|
37
43
|
# fallback: hex string
|
44
|
+
# returns nil or data
|
38
45
|
def decode_storage(data, type, optional, fallback, registry)
|
39
46
|
data ||= (optional ? nil : fallback)
|
40
|
-
PortableCodec.decode(type, data.to_bytes, registry)[0]
|
47
|
+
PortableCodec.decode(type, data.to_bytes, registry)[0] if data
|
41
48
|
end
|
42
49
|
|
43
50
|
# storage_item: the storage item from metadata
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scale_rb
|
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
|
- Aki Wu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: blake2b_rs
|