Module: Bluzelle
- Defined in:
- lib/bluzelle.rb
Defined Under Namespace
Classes: APIError, Client, OptionsError
Class Method Summary collapse
Class Method Details
.new_client(options) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/bluzelle.rb', line 42 def self.new_client raise OptionsError, 'address is required' unless .fetch('address', nil) raise OptionsError, 'mnemonic is required' unless .fetch('mnemonic', nil) gas_info = .fetch('gas_info', {}) unless gas_info.class.equal?(Hash) raise OptionsError, 'gas_info should be a dict of {gas_price, max_fee, max_gas}' end gas_info_keys = %w[gas_price max_fee max_gas] gas_info_keys.each do |k| v = gas_info.fetch(k, 0) unless v.class.equal?(Integer) raise OptionsError, 'gas_info[%s] should be an int' % k end gas_info[k] = v end ['debug'] = false unless .fetch('debug', false) ['chain_id'] = DEFAULT_CHAIN_ID unless .fetch('chain_id', nil) ['endpoint'] = DEFAULT_ENDPOINT unless .fetch('endpoint', nil) c = Client.new c.setup_logging c.set_private_key c.verify_address c.set_account c end |