Class: Coinbase::Client::ContractEventsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/coinbase/client/api/contract_events_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ ContractEventsApi

Returns a new instance of ContractEventsApi.



19
20
21
# File 'lib/coinbase/client/api/contract_events_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/coinbase/client/api/contract_events_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#list_contract_events(network_id, protocol_name, contract_address, contract_name, event_name, from_block_height, to_block_height, opts = {}) ⇒ ContractEventList

Get contract events Retrieve events for a specific contract

Parameters:

  • network_id (String)

    Unique identifier for the blockchain network

  • protocol_name (String)

    Case-sensitive name of the blockchain protocol

  • contract_address (String)

    EVM address of the smart contract (42 characters, including '0x', in lowercase)

  • contract_name (String)

    Case-sensitive name of the specific contract within the project

  • event_name (String)

    Case-sensitive name of the event to filter for in the contract's logs

  • from_block_height (Integer)

    Lower bound of the block range to query (inclusive)

  • to_block_height (Integer)

    Upper bound of the block range to query (inclusive)

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :next_page (String)

    Pagination token for retrieving the next set of results

Returns:



34
35
36
37
# File 'lib/coinbase/client/api/contract_events_api.rb', line 34

def list_contract_events(network_id, protocol_name, contract_address, contract_name, event_name, from_block_height, to_block_height, opts = {})
  data, _status_code, _headers = list_contract_events_with_http_info(network_id, protocol_name, contract_address, contract_name, event_name, from_block_height, to_block_height, opts)
  data
end

#list_contract_events_with_http_info(network_id, protocol_name, contract_address, contract_name, event_name, from_block_height, to_block_height, opts = {}) ⇒ Array<(ContractEventList, Integer, Hash)>

Get contract events Retrieve events for a specific contract

Parameters:

  • network_id (String)

    Unique identifier for the blockchain network

  • protocol_name (String)

    Case-sensitive name of the blockchain protocol

  • contract_address (String)

    EVM address of the smart contract (42 characters, including &#39;0x&#39;, in lowercase)

  • contract_name (String)

    Case-sensitive name of the specific contract within the project

  • event_name (String)

    Case-sensitive name of the event to filter for in the contract&#39;s logs

  • from_block_height (Integer)

    Lower bound of the block range to query (inclusive)

  • to_block_height (Integer)

    Upper bound of the block range to query (inclusive)

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :next_page (String)

    Pagination token for retrieving the next set of results

Returns:

  • (Array<(ContractEventList, Integer, Hash)>)

    ContractEventList data, response status code and response headers



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/coinbase/client/api/contract_events_api.rb', line 51

def list_contract_events_with_http_info(network_id, protocol_name, contract_address, contract_name, event_name, from_block_height, to_block_height, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ContractEventsApi.list_contract_events ...'
  end
  # verify the required parameter 'network_id' is set
  if @api_client.config.client_side_validation && network_id.nil?
    fail ArgumentError, "Missing the required parameter 'network_id' when calling ContractEventsApi.list_contract_events"
  end
  # verify the required parameter 'protocol_name' is set
  if @api_client.config.client_side_validation && protocol_name.nil?
    fail ArgumentError, "Missing the required parameter 'protocol_name' when calling ContractEventsApi.list_contract_events"
  end
  # verify the required parameter 'contract_address' is set
  if @api_client.config.client_side_validation && contract_address.nil?
    fail ArgumentError, "Missing the required parameter 'contract_address' when calling ContractEventsApi.list_contract_events"
  end
  # verify the required parameter 'contract_name' is set
  if @api_client.config.client_side_validation && contract_name.nil?
    fail ArgumentError, "Missing the required parameter 'contract_name' when calling ContractEventsApi.list_contract_events"
  end
  # verify the required parameter 'event_name' is set
  if @api_client.config.client_side_validation && event_name.nil?
    fail ArgumentError, "Missing the required parameter 'event_name' when calling ContractEventsApi.list_contract_events"
  end
  # verify the required parameter 'from_block_height' is set
  if @api_client.config.client_side_validation && from_block_height.nil?
    fail ArgumentError, "Missing the required parameter 'from_block_height' when calling ContractEventsApi.list_contract_events"
  end
  # verify the required parameter 'to_block_height' is set
  if @api_client.config.client_side_validation && to_block_height.nil?
    fail ArgumentError, "Missing the required parameter 'to_block_height' when calling ContractEventsApi.list_contract_events"
  end
  # resource path
  local_var_path = '/v1/networks/{network_id}/smart_contracts/{contract_address}/events'.sub('{' + 'network_id' + '}', CGI.escape(network_id.to_s)).sub('{' + 'contract_address' + '}', CGI.escape(contract_address.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'protocol_name'] = protocol_name
  query_params[:'contract_name'] = contract_name
  query_params[:'event_name'] = event_name
  query_params[:'from_block_height'] = from_block_height
  query_params[:'to_block_height'] = to_block_height
  query_params[:'next_page'] = opts[:'next_page'] if !opts[:'next_page'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ContractEventList'

  # auth_names
  auth_names = opts[:debug_auth_names] || []

  new_options = opts.merge(
    :operation => :"ContractEventsApi.list_contract_events",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ContractEventsApi#list_contract_events\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end