scale.rb 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57a926d8c88b0299b3aa8c24ab8452b6e02b65e540017ea208c2cef029a9dd66
4
- data.tar.gz: 28f3039ccd89246f9613f46ecd442a7a10a4dd750d3ffdd55a24ed8bd246cb83
3
+ metadata.gz: f8538580b5cc0d84add3684e3af10bbbba86bc741abb66bc5d38594c7de17894
4
+ data.tar.gz: a652f2dd8b436840f8b4e004fdf3fe81c699200fb68a11ea2ca52ae4a3e64062
5
5
  SHA512:
6
- metadata.gz: e685ed147def9c29297934e1a805856c19a397527842cd2e61c6422219228b569a18cc6837c98592f3ce47b12db7d8f28f8bcc547dbaad2d41a58cb45d5419c6
7
- data.tar.gz: d1645de7d187cdcd2e68157f5907a63229241be265eca0d05332fabc402b94156bc86fb7ab7146475b47fcdb92e2f7d4ef7561c8004c861c82517437feb5a57d
6
+ metadata.gz: a5a71617b20e22dc876b71414c6bdf78cfdc23b94444f010d902eb382bb8f26d92e06de9eedca805aca9ba408035a981a106fa1d944081a3426864d6351b6b58
7
+ data.tar.gz: 8a65c9e78531472b74f93eb48da5c0e54c7b05430342467afa03ead952643cc41901a4a8f6b908ba6e3e8721b9aa26e6e426d6664ffb8ab93390e7c0febfd74c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- scale.rb (0.2.3)
4
+ scale.rb (0.2.4)
5
5
  activesupport (>= 4.0.0)
6
6
  json (~> 2.3.0)
7
7
  substrate_common.rb (~> 0.1.8)
data/lib/scale/block.rb CHANGED
@@ -124,20 +124,33 @@ module Scale
124
124
  class EventRecord
125
125
  include SingleValue
126
126
 
127
- def self.decode(scale_bytes, metadata)
127
+ # 0x0c000000000000001027000001010000010000000400be07e2c28688db5368445c33d32b3c7bcad15dab1ec802ba8cccc1c22b86574f6992da89ff412eaf9bafac4024
128
+ def self.decode(scale_bytes)
129
+ metadata = Scale::TypeRegistry.instance.metadata
130
+
131
+ result = {}
128
132
  phase = scale_bytes.get_next_bytes(1).first
129
133
 
130
134
  if phase == 0
131
- extrinsic_idx = U32.decode(scale_bytes).value
135
+ result[:extrinsic_idx] = U32.decode(scale_bytes).value
132
136
  end
133
137
 
134
- type = scale_bytes.get_next_bytes(2).bytes_to_hex
135
-
136
-
137
- end
138
+ type = scale_bytes.get_next_bytes(2).bytes_to_hex[2..]
139
+ event = metadata.event_index[type][1]
140
+ mod = metadata.event_index[type][0]
141
+
142
+ result[:params] = []
143
+ event[:args].each do |arg_type|
144
+ value = Scale::Types.get(arg_type).decode(scale_bytes).value
145
+ result[:params] << {
146
+ type: arg_type,
147
+ value: value
148
+ }
149
+ end
138
150
 
139
- def encode
151
+ result[:topics] = Scale::Types.get('Vec<Hash>').decode(scale_bytes).value.map(&:value)
140
152
 
153
+ EventRecord.new(result)
141
154
  end
142
155
  end
143
156
 
data/lib/scale/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Scale
2
- VERSION = "0.2.3".freeze
2
+ VERSION = "0.2.4".freeze
3
3
  end
data/lib/scale.rb CHANGED
@@ -29,7 +29,7 @@ module Scale
29
29
 
30
30
  class TypeRegistry
31
31
  include Singleton
32
- attr_accessor :types
32
+ attr_accessor :types, :metadata
33
33
 
34
34
  def load(spec_name = nil, spec_version = nil)
35
35
  @spec_name = spec_name
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scale.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wu Minzhe