scale.rb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 455155ae80fa2688bd42bf2dfdf5d0206e53ff8a645d2f8b0936bb7657fad3a9
4
+ data.tar.gz: 60c09397cb38825bfd9e67cfb52a770578e7b9d6b43d6e1db6acecc9af9dac78
5
+ SHA512:
6
+ metadata.gz: 2a71f2efdfbe7e376bc07c47ad35b9d1768f8b2c97c6047ae16b36ca583fbe75d23937f6e6342c624701bff2fa7f8b2a3118d9d9e5fd3db33571d9133e590713
7
+ data.tar.gz: 4c165871d267f740ec0f980a3fb88b5a56c0c83d3163b0268279597eec96c7e33a454ad29f9f1f5e4e0cd9e513425aabea148df7b0eee0e3a5191c358a935a90
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /.rakeTasks
10
+ /.idea
data/Dockerfile ADDED
@@ -0,0 +1,18 @@
1
+ FROM ruby:2.6-alpine3.11
2
+
3
+ ENV BUILD_PACKAGES curl-dev build-base
4
+
5
+ RUN echo "http://mirrors.ustc.edu.cn/alpine/v3.11/main/" > /etc/apk/repositories && \
6
+ apk update && \
7
+ apk upgrade && \
8
+ apk add git $BUILD_PACKAGES
9
+
10
+ WORKDIR /usr/src/app
11
+
12
+ COPY . .
13
+ RUN gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/ && \
14
+ gem install bundler:1.17.3 && \
15
+ bundle config mirror.https://rubygems.org https://gems.ruby-china.com && \
16
+ bundle install
17
+
18
+ CMD ["sh"]
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in scale.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,49 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ scale.rb (0.1.0)
5
+ substrate_common.rb (~> 0.1.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ base58 (0.2.3)
11
+ blake2b (0.10.0)
12
+ coderay (1.1.2)
13
+ diff-lcs (1.3)
14
+ method_source (0.9.2)
15
+ pry (0.12.2)
16
+ coderay (~> 1.1.0)
17
+ method_source (~> 0.9.0)
18
+ rake (13.0.1)
19
+ rspec (3.9.0)
20
+ rspec-core (~> 3.9.0)
21
+ rspec-expectations (~> 3.9.0)
22
+ rspec-mocks (~> 3.9.0)
23
+ rspec-core (3.9.0)
24
+ rspec-support (~> 3.9.0)
25
+ rspec-expectations (3.9.0)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.9.0)
28
+ rspec-mocks (3.9.0)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.9.0)
31
+ rspec-support (3.9.0)
32
+ substrate_common.rb (0.1.3)
33
+ base58
34
+ blake2b
35
+ xxhash
36
+ xxhash (0.4.0)
37
+
38
+ PLATFORMS
39
+ ruby
40
+
41
+ DEPENDENCIES
42
+ bundler (~> 1.17)
43
+ pry
44
+ rake (~> 13.0)
45
+ rspec (~> 3.2)
46
+ scale.rb!
47
+
48
+ BUNDLED WITH
49
+ 1.17.3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Wu Minzhe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,149 @@
1
+ ![grants_badge](./grants_badge.png)
2
+
3
+ # scale.rb
4
+
5
+ **Ruby SCALE Codec Library and Substrate Json-rpc Api Client.**
6
+
7
+ SCALE is a lightweight, efficient, binary serialization and deserialization codec used by substrate. Most of the input and output data of the substrate API are encoded in SCALE data format.
8
+
9
+ This is a SCALE codec library and substrate json-rpc api client implemented in ruby language for general use. It contains the implementation of low-level data formats, various substrate types, metadata support and json-rpc client.
10
+
11
+ This work is the prerequisite of our subsequent series of projects. We hope to familiarize and quickly access Polkadot and Substrate through ruby. We plan to develop the back end of our applications in ruby language, and then interact with nodes or synchronize data through this library.
12
+
13
+ Please refer to the [official doc](https://substrate.dev/docs/en/overview/low-level-data-format) for more details about SCALE low-level data format.
14
+
15
+ Because the feature of ruby 2.6 is used, the ruby version is required to be >= 2.6. it will be compatible with older ruby versions when released.
16
+
17
+ ## Installation
18
+
19
+ Add this line to your application's Gemfile:
20
+
21
+ ```ruby
22
+ gem 'scale.rb'
23
+ ```
24
+
25
+ And then execute:
26
+
27
+ $ bundle
28
+
29
+ Or install it yourself as:
30
+
31
+ $ gem install scale
32
+
33
+ ## Usage
34
+
35
+ 1. decode
36
+
37
+ ```ruby
38
+ require "scale"
39
+
40
+ # decode a compact integer
41
+ scale_bytes = Scale::Bytes.new("0x1501") # create scale_bytes object from scale encoded hex string
42
+ o = Scale::Types::Compact.decode(scale_bytes) # use scale type to decode scale_bytes object
43
+ p o.value # 69
44
+ ```
45
+
46
+ 2. encode
47
+
48
+ ```ruby
49
+ require "scale"
50
+
51
+ o = Scale::Types::Compact.new(69)
52
+ p o.encode # "1501"
53
+ ```
54
+ Please go to `spec` dir for more examples.
55
+
56
+ ## Types supported
57
+
58
+ scale.rb now support types:
59
+
60
+ - [x] Compact
61
+ - [x] Bool
62
+ - [x] U8, U16, U32, U64, U128
63
+ - [x] Enum
64
+ - [x] Option
65
+ - [x] Struct
66
+ - [x] Tuple
67
+ - [x] Vec
68
+ - [x] Set
69
+ - [x] Bytes
70
+ - [x] Hex
71
+ - [x] String
72
+ - [x] H160, H256, H512
73
+ - [x] AccountId
74
+ - [x] Balance
75
+ - [x] BalanceOf
76
+ - [x] BlockNumber
77
+ - [x] AccountIndex
78
+ - [x] Era
79
+
80
+ ## Running tests
81
+
82
+ 1. Download or clone the code to local, and enter the code root directory
83
+ 2. Run all tests
84
+
85
+ ```
86
+ rspec
87
+ ```
88
+
89
+ 2. Run low level format tests
90
+
91
+ ```
92
+ rspec spec/low_level_spec.rb
93
+ ```
94
+
95
+
96
+ ## Docker
97
+
98
+ 1. update to latest image
99
+
100
+ `docker pull itering/scale`
101
+
102
+ 2. Run image:
103
+
104
+ `docker run -it itering/scale`
105
+
106
+ This will enter the container with a linux shell opened.
107
+
108
+ ```shell
109
+ /usr/src/app #
110
+ ```
111
+
112
+ 3. Type `rspec` to run all tests
113
+
114
+ ```shell
115
+ /usr/src/app # rspec
116
+ ...................
117
+
118
+ Finished in 0.00883 seconds (files took 0.09656 seconds to load)
119
+ 19 examples, 0 failures
120
+ ```
121
+
122
+ 4. Or type `./bin/console` to enter the ruby interactive environment and run any decode or encode code
123
+
124
+ ```shell
125
+ /usr/src/app # ./bin/console
126
+ [1] pry(main)> scale_bytes = Scale::Bytes.new("0x1501")
127
+ => #<Scale::Bytes:0x000055daa883ba70 @bytes=[21, 1], @data="0x1501", @offset=0>
128
+ [2] pry(main)> o = Scale::Types::Compact.decode(scale_bytes)
129
+ => #<Scale::Types::Compact:0x000055daa89b0db0 @value=69>
130
+ [3] pry(main)> p o.value
131
+ 69
132
+ => 69
133
+ [4] pry(main)>
134
+ ```
135
+
136
+
137
+ ## Development
138
+
139
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
140
+
141
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
142
+
143
+ ## Contributing
144
+
145
+ Bug reports and pull requests are welcome on GitHub at https://github.com/itering/scale.rb.
146
+
147
+ ## License
148
+
149
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "scale"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ require "pry"
11
+ Pry.start
12
+
13
+ # require "irb"
14
+ # IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/grants_badge.png ADDED
Binary file
@@ -0,0 +1,127 @@
1
+ module Scale
2
+ module Types
3
+
4
+ class Metadata
5
+ include SingleValue
6
+ def self.decode(scale_bytes)
7
+ bytes = scale_bytes.get_next_bytes(4)
8
+ if bytes.bytes_to_utf8 == 'meta'
9
+ metadata_v_name = type_of("Enum", enum_values: [
10
+ "Scale::Types::MetadataV0",
11
+ "Scale::Types::MetadataV1",
12
+ "Scale::Types::MetadataV2",
13
+ "Scale::Types::MetadataV3",
14
+ "Scale::Types::MetadataV4",
15
+ "Scale::Types::MetadataV5",
16
+ "Scale::Types::MetadataV6",
17
+ "Scale::Types::MetadataV7",
18
+ "Scale::Types::MetadataV8",
19
+ "Scale::Types::MetadataV9",
20
+ "Scale::Types::MetadataV10"
21
+ ]).decode(scale_bytes).value
22
+
23
+ Metadata.new(metadata_v_name.constantize.decode(scale_bytes).value)
24
+ end
25
+ end
26
+ end
27
+
28
+ class MetadataModule
29
+ include SingleValue
30
+ def self.decode(scale_bytes)
31
+ name = String.decode(scale_bytes).value
32
+ prefix = String.decode(scale_bytes).value
33
+
34
+ result = {
35
+ name: name,
36
+ prefix: prefix
37
+ }
38
+
39
+ has_storage = Bool.decode(scale_bytes).value
40
+ if has_storage
41
+ storages = type_of("Vec<MetadataModuleStorage>").decode(scale_bytes).value
42
+ result[:storage] = storages.map(&:value)
43
+ end
44
+
45
+ has_calls = Bool.decode(scale_bytes).value
46
+ if has_calls
47
+ calls = type_of("Vec<MetadataModuleCall>").decode(scale_bytes).value
48
+ result[:calls] = calls.map(&:value)
49
+ end
50
+
51
+ has_events = Bool.decode(scale_bytes).value
52
+ if has_events
53
+ events = type_of("Vec<MetadataModuleEvent>").decode(scale_bytes).value
54
+ result[:events] = events.map(&:value)
55
+ end
56
+
57
+ MetadataModule.new(result)
58
+ end
59
+ end
60
+
61
+ class MetadataModuleStorage
62
+ include SingleValue
63
+ def self.decode(scale_bytes)
64
+
65
+ result = {
66
+ name: String.decode(scale_bytes).value,
67
+ modifier: type_of("Enum", enum_values: ["Optional", "Default"]).decode(scale_bytes).value
68
+ }
69
+
70
+ is_key_value = Bool.decode(scale_bytes).value
71
+ if is_key_value
72
+ result[:type] = {
73
+ Map: {
74
+ key: adjust(String.decode(scale_bytes).value),
75
+ value: adjust(String.decode(scale_bytes).value),
76
+ linked: Bool.decode(scale_bytes).value
77
+ }
78
+ }
79
+ else
80
+ result[:type] = {
81
+ Plain: adjust(String.decode(scale_bytes).value)
82
+ }
83
+ end
84
+
85
+ result[:fallback] = Hex.decode(scale_bytes).value
86
+ result[:documentation] = type_of("Vec<String>").decode(scale_bytes).value.map(&:value)
87
+
88
+ MetadataModuleStorage.new(result)
89
+ end
90
+ end
91
+
92
+ class MetadataModuleCall
93
+ include SingleValue
94
+ def self.decode(scale_bytes)
95
+ result = {}
96
+ result[:name] = String.decode(scale_bytes).value
97
+ result[:args] = type_of("Vec<MetadataModuleCallArgument>").decode(scale_bytes).value.map(&:value)
98
+ result[:documentation] = type_of("Vec<String>").decode(scale_bytes).value.map(&:value)
99
+ MetadataModuleCall.new(result)
100
+ end
101
+ end
102
+
103
+ class MetadataModuleCallArgument
104
+ include SingleValue
105
+ def self.decode(scale_bytes)
106
+ result = {}
107
+ result[:name] = String.decode(scale_bytes).value
108
+ result[:type] = adjust(String.decode(scale_bytes).value)
109
+
110
+ MetadataModuleCallArgument.new(result)
111
+ end
112
+ end
113
+
114
+ class MetadataModuleEvent
115
+ include SingleValue
116
+ def self.decode(scale_bytes)
117
+ result = {}
118
+ result[:name] = String.decode(scale_bytes).value
119
+ result[:args] = type_of("Vec<String>").decode(scale_bytes).value.map(&:value)
120
+ result[:documentation] = type_of("Vec<String>").decode(scale_bytes).value.map(&:value)
121
+
122
+ MetadataModuleEvent.new(result)
123
+ end
124
+ end
125
+
126
+ end
127
+ end
@@ -0,0 +1,22 @@
1
+ module Scale
2
+ module Types
3
+
4
+ class MetadataV10
5
+ include SingleValue
6
+ def self.decode(scale_bytes)
7
+ modules = type_of("Vec<MetadataV8Module>").decode(scale_bytes).value;
8
+ result = {
9
+ magicNumber: 1635018093,
10
+ metadata: {
11
+ V10: {
12
+ modules: modules.map(&:value)
13
+ }
14
+ }
15
+ }
16
+
17
+ MetadataV10.new(result)
18
+ end
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ module Scale
2
+ module Types
3
+
4
+ class MetadataV3
5
+ include SingleValue
6
+ def self.decode(scale_bytes)
7
+ modules = type_of("Vec<MetadataModule>").decode(scale_bytes).value;
8
+ result = {
9
+ magicNumber: 1635018093,
10
+ metadata: {
11
+ V3: {
12
+ modules: modules.map(&:value)
13
+ }
14
+ }
15
+ }
16
+
17
+ MetadataV3.new(result)
18
+ end
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,123 @@
1
+ module Scale
2
+ module Types
3
+
4
+ class MetadataV7
5
+ include SingleValue
6
+ def self.decode(scale_bytes)
7
+ modules = type_of("Vec<MetadataV7Module>").decode(scale_bytes).value;
8
+ result = {
9
+ magicNumber: 1635018093,
10
+ metadata: {
11
+ V7: {
12
+ modules: modules.map(&:value)
13
+ }
14
+ }
15
+ }
16
+
17
+ MetadataV7.new(result)
18
+ end
19
+ end
20
+
21
+ class MetadataV7Module
22
+ include SingleValue
23
+ def self.decode(scale_bytes)
24
+ name = String.decode(scale_bytes).value
25
+
26
+ result = {
27
+ name: name,
28
+ }
29
+
30
+ has_storage = Bool.decode(scale_bytes).value
31
+ if has_storage
32
+ storage = MetadataV7ModuleStorage.decode(scale_bytes).value
33
+ result[:storage] = storage
34
+ result[:prefix] = storage[:prefix]
35
+ end
36
+
37
+ has_calls = Bool.decode(scale_bytes).value
38
+ if has_calls
39
+ calls = type_of("Vec<MetadataModuleCall>").decode(scale_bytes).value
40
+ result[:calls] = calls.map(&:value)
41
+ end
42
+
43
+ has_events = Bool.decode(scale_bytes).value
44
+ if has_events
45
+ events = type_of("Vec<MetadataModuleEvent>").decode(scale_bytes).value
46
+ result[:events] = events.map(&:value)
47
+ end
48
+
49
+ result[:constants] = type_of("Vec<MetadataV7ModuleConstants>").decode(scale_bytes).value.map(&:value)
50
+
51
+ MetadataV7Module.new(result)
52
+ end
53
+ end
54
+
55
+ class MetadataV7ModuleStorage
56
+ include SingleValue
57
+ def self.decode(scale_bytes)
58
+ prefix = String.decode(scale_bytes).value
59
+ items = type_of("Vec<MetadataV7ModuleStorageEntry>").decode(scale_bytes).value.map(&:value)
60
+ result = {
61
+ prefix: prefix,
62
+ items: items
63
+ }
64
+
65
+ MetadataV7ModuleStorage.new(result)
66
+ end
67
+ end
68
+
69
+ class MetadataV7ModuleStorageEntry
70
+ include SingleValue
71
+ def self.decode(scale_bytes)
72
+ result = {
73
+ name: String.decode(scale_bytes).value,
74
+ modifier: type_of("Enum", enum_values: ["Optional", "Default"]).decode(scale_bytes).value
75
+ }
76
+ storage_function_type = type_of("Enum", enum_values: ["Plain", "Map", "DoubleMap"]).decode(scale_bytes).value
77
+ if storage_function_type == "Plain"
78
+ result[:type] = {
79
+ Plain: adjust(String.decode(scale_bytes).value)
80
+ }
81
+ elsif storage_function_type == "Map"
82
+ result[:type] = {
83
+ Map: {
84
+ hasher: StorageHasher.decode(scale_bytes).value,
85
+ key: adjust(String.decode(scale_bytes).value),
86
+ value: adjust(String.decode(scale_bytes).value),
87
+ linked: Bool.decode(scale_bytes).value
88
+ }
89
+ }
90
+ elsif storage_function_type == "DoubleMap"
91
+ result[:type] = {
92
+ DoubleMap: {
93
+ hasher: StorageHasher.decode(scale_bytes).value,
94
+ key1: adjust(String.decode(scale_bytes).value),
95
+ key2: adjust(String.decode(scale_bytes).value),
96
+ value: adjust(String.decode(scale_bytes).value),
97
+ key2Hasher: StorageHasher.decode(scale_bytes).value
98
+ }
99
+ }
100
+ end
101
+
102
+ result[:fallback] = Hex.decode(scale_bytes).value
103
+ result[:docs] = type_of("Vec<String>").decode(scale_bytes).value.map(&:value)
104
+
105
+ MetadataV7ModuleStorageEntry.new(result)
106
+ end
107
+ end
108
+
109
+ class MetadataV7ModuleConstants
110
+ include SingleValue
111
+ def self.decode(scale_bytes)
112
+ result = {
113
+ name: String.decode(scale_bytes).value,
114
+ type: String.decode(scale_bytes).value, # convert
115
+ value: Hex.decode(scale_bytes).value,
116
+ docs: type_of("Vec<String>").decode(scale_bytes).value.map(&:value)
117
+ }
118
+ MetadataV7ModuleConstants.new result
119
+ end
120
+ end
121
+
122
+ end
123
+ end
@@ -0,0 +1,69 @@
1
+ module Scale
2
+ module Types
3
+
4
+ class MetadataV8
5
+ include SingleValue
6
+ def self.decode(scale_bytes)
7
+ modules = type_of("Vec<MetadataV8Module>").decode(scale_bytes).value;
8
+ result = {
9
+ magicNumber: 1635018093,
10
+ metadata: {
11
+ V8: {
12
+ modules: modules.map(&:value)
13
+ }
14
+ }
15
+ }
16
+
17
+ MetadataV8.new(result)
18
+ end
19
+ end
20
+
21
+ class MetadataV8Module
22
+ include SingleValue
23
+ def self.decode(scale_bytes)
24
+ name = String.decode(scale_bytes).value
25
+
26
+ result = {
27
+ name: name,
28
+ }
29
+
30
+ has_storage = Bool.decode(scale_bytes).value
31
+ if has_storage
32
+ storage = MetadataV7ModuleStorage.decode(scale_bytes).value
33
+ result[:storage] = storage
34
+ result[:prefix] = storage[:prefix]
35
+ end
36
+
37
+ has_calls = Bool.decode(scale_bytes).value
38
+ if has_calls
39
+ calls = type_of("Vec<MetadataModuleCall>").decode(scale_bytes).value
40
+ result[:calls] = calls.map(&:value)
41
+ end
42
+
43
+ has_events = Bool.decode(scale_bytes).value
44
+ if has_events
45
+ events = type_of("Vec<MetadataModuleEvent>").decode(scale_bytes).value
46
+ result[:events] = events.map(&:value)
47
+ end
48
+
49
+ result[:constants] = type_of("Vec<MetadataV7ModuleConstants>").decode(scale_bytes).value.map(&:value)
50
+ result[:errors] = type_of("Vec<MetadataModuleError>").decode(scale_bytes).value.map(&:value)
51
+
52
+ MetadataV8Module.new(result)
53
+ end
54
+ end
55
+
56
+ class MetadataModuleError
57
+ include SingleValue
58
+ def self.decode(scale_bytes)
59
+ result = {
60
+ name: String.decode(scale_bytes).value,
61
+ docs: type_of("Vec<String>").decode(scale_bytes).value.map(&:value)
62
+ }
63
+
64
+ MetadataModuleError.new(result)
65
+ end
66
+ end
67
+
68
+ end
69
+ end
@@ -0,0 +1,22 @@
1
+ module Scale
2
+ module Types
3
+
4
+ class MetadataV9
5
+ include SingleValue
6
+ def self.decode(scale_bytes)
7
+ modules = type_of("Vec<MetadataV8Module>").decode(scale_bytes).value;
8
+ result = {
9
+ magicNumber: 1635018093,
10
+ metadata: {
11
+ V9: {
12
+ modules: modules.map(&:value)
13
+ }
14
+ }
15
+ }
16
+
17
+ MetadataV9.new(result)
18
+ end
19
+ end
20
+
21
+ end
22
+ end