Module: ScaleRb::ClientShare

Included in:
HttpClient, WsClient
Defined in:
lib/scale_rb/client/client_share.rb

Overview

This module is used to add extra methods to both the ScaleRb::WsClient ScaleRb::HttpClient

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



37
38
39
# File 'lib/scale_rb/client/client_share.rb', line 37

def method_missing(method, *args)
  request(method.to_s, args)
end

Instance Method Details

#get_metadata(block_hash = nil) ⇒ Object

get decoded metadata at block_hash



5
6
7
8
9
# File 'lib/scale_rb/client/client_share.rb', line 5

def (block_hash = nil)
  block_hash ||= chain_getHead
   = (block_hash)
  Metadata::Metadata.from_hex()
end

#get_storage(pallet_name, storage_name, params = [], block_hash: nil, metadata: nil) ⇒ Object

Get decoded storage at block_hash



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/scale_rb/client/client_share.rb', line 12

def get_storage(pallet_name, storage_name, params = [], block_hash: nil, metadata: nil)
  block_hash ||= chain_getHead
   ||= (block_hash)

  # storeage item
  pallet_name = convert_to_camel_case pallet_name
  storage_name = convert_to_camel_case storage_name

  # storage param
  ScaleRb.logger.debug "#{pallet_name}.#{storage_name}(#{params.inspect})"
  params = params.map { |param| c(param) }

  get_storage2(
    block_hash, # at
    pallet_name,
    storage_name,
    params,
    
  )
end

#respond_to_missing?(*_args) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/scale_rb/client/client_share.rb', line 33

def respond_to_missing?(*_args)
  true
end