Class: Klaytn::Client
Direct Known Subclasses
Constant Summary
Constants inherited from Base
Base::FUNCTION_NOT_FOUND, Base::INVALID_CLIENT, Base::MISSING_ABI, Base::MISSING_ACCOUNT_POOL_KRN, Base::MISSING_ACCOUNT_WALLET, Base::MISSING_CONTRACT, Base::MISSING_JSONRPC_METHOD, Base::MISSING_KAS_CREDS
Instance Attribute Summary collapse
-
#basic_auth ⇒ Object
readonly
Returns the value of attribute basic_auth.
-
#chain_id ⇒ Object
readonly
Returns the value of attribute chain_id.
-
#contract_address ⇒ Object
readonly
Returns the value of attribute contract_address.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Client
constructor
A new instance of Client.
- #setup_basic_auth(opts) ⇒ Object
- #setup_chain_id(opts) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Client
Returns a new instance of Client.
5 6 7 8 9 10 11 12 |
# File 'lib/klaytn/client.rb', line 5 def initialize(opts = {}) raise INVALID_CLIENT if opts == {} @contract_address = opts[:contract_address] @chain_id = setup_chain_id(opts) @headers = Authentication.new.headers(chain_id) @basic_auth = setup_basic_auth(opts) end |
Instance Attribute Details
#basic_auth ⇒ Object (readonly)
Returns the value of attribute basic_auth.
3 4 5 |
# File 'lib/klaytn/client.rb', line 3 def basic_auth @basic_auth end |
#chain_id ⇒ Object (readonly)
Returns the value of attribute chain_id.
3 4 5 |
# File 'lib/klaytn/client.rb', line 3 def chain_id @chain_id end |
#contract_address ⇒ Object (readonly)
Returns the value of attribute contract_address.
3 4 5 |
# File 'lib/klaytn/client.rb', line 3 def contract_address @contract_address end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
3 4 5 |
# File 'lib/klaytn/client.rb', line 3 def headers @headers end |
Instance Method Details
#setup_basic_auth(opts) ⇒ Object
18 19 20 21 |
# File 'lib/klaytn/client.rb', line 18 def setup_basic_auth(opts) raise MISSING_KAS_CREDS unless opts[:kas_access_key].present? && opts[:kas_secret_access_key].present? Authentication.new.auth_params(opts[:kas_access_key], opts[:kas_secret_access_key]) end |
#setup_chain_id(opts) ⇒ Object
14 15 16 |
# File 'lib/klaytn/client.rb', line 14 def setup_chain_id(opts) opts[:chain_id] || 1001 # default to baobab testnet end |