Class: Coinbase::Configuration
- Inherits:
-
Object
- Object
- Coinbase::Configuration
- Defined in:
- lib/coinbase.rb
Overview
Configuration object for the Coinbase SDK.
Instance Attribute Summary collapse
-
#api_key_name ⇒ Object
Returns the value of attribute api_key_name.
-
#api_key_private_key ⇒ Object
Returns the value of attribute api_key_private_key.
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#backup_file_path ⇒ Object
Returns the value of attribute backup_file_path.
-
#base_sepolia_client ⇒ Object
readonly
Returns the value of attribute base_sepolia_client.
-
#base_sepolia_rpc_url ⇒ Object
Returns the value of attribute base_sepolia_rpc_url.
-
#debug_api ⇒ Object
Returns the value of attribute debug_api.
Instance Method Summary collapse
-
#api_client ⇒ Coinbase::Client::ApiClient
Returns the API client.
-
#from_json(file_path = 'coinbase_cloud_api_key.json') ⇒ Object
Sets configuration values based on the provided CDP API Key JSON file.
-
#initialize ⇒ Configuration
constructor
Initializes the configuration object.
Constructor Details
#initialize ⇒ Configuration
Initializes the configuration object.
53 54 55 56 57 58 59 |
# File 'lib/coinbase.rb', line 53 def initialize @base_sepolia_rpc_url = 'https://sepolia.base.org' @base_sepolia_client = Jimson::Client.new(@base_sepolia_rpc_url) @api_url = 'https://api.cdp.coinbase.com' @debug_api = false @backup_file_path = 'seeds.json' end |
Instance Attribute Details
#api_key_name ⇒ Object
Returns the value of attribute api_key_name.
50 51 52 |
# File 'lib/coinbase.rb', line 50 def api_key_name @api_key_name end |
#api_key_private_key ⇒ Object
Returns the value of attribute api_key_private_key.
50 51 52 |
# File 'lib/coinbase.rb', line 50 def api_key_private_key @api_key_private_key end |
#api_url ⇒ Object
Returns the value of attribute api_url.
50 51 52 |
# File 'lib/coinbase.rb', line 50 def api_url @api_url end |
#backup_file_path ⇒ Object
Returns the value of attribute backup_file_path.
50 51 52 |
# File 'lib/coinbase.rb', line 50 def backup_file_path @backup_file_path end |
#base_sepolia_client ⇒ Object (readonly)
Returns the value of attribute base_sepolia_client.
49 50 51 |
# File 'lib/coinbase.rb', line 49 def base_sepolia_client @base_sepolia_client end |
#base_sepolia_rpc_url ⇒ Object
Returns the value of attribute base_sepolia_rpc_url.
49 50 51 |
# File 'lib/coinbase.rb', line 49 def base_sepolia_rpc_url @base_sepolia_rpc_url end |
#debug_api ⇒ Object
Returns the value of attribute debug_api.
50 51 52 |
# File 'lib/coinbase.rb', line 50 def debug_api @debug_api end |
Instance Method Details
#api_client ⇒ Coinbase::Client::ApiClient
Returns the API client.
85 86 87 |
# File 'lib/coinbase.rb', line 85 def api_client @api_client ||= Coinbase::Client::ApiClient.new(Middleware.config) end |
#from_json(file_path = 'coinbase_cloud_api_key.json') ⇒ Object
Sets configuration values based on the provided CDP API Key JSON file. file in the root directory by default.
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/coinbase.rb', line 64 def from_json(file_path = 'coinbase_cloud_api_key.json') # Expand paths to respect shortcuts like ~. file_path = File.(file_path) raise InvalidConfiguration, 'Invalid configuration file type' unless file_path.end_with?('.json') file = File.read(file_path) data = JSON.parse(file) @api_key_name = data['name'] @api_key_private_key = data['privateKey'] end |