Class: Coinbase::SmartContract
- Inherits:
-
Object
- Object
- Coinbase::SmartContract
- Defined in:
- lib/coinbase/smart_contract.rb
Overview
A representation of a SmartContract on the blockchain.
Class Method Summary collapse
- .contract_events_api ⇒ Object
-
.list_events(network_id:, protocol_name:, contract_address:, contract_name:, event_name:, from_block_height:, to_block_height:) ⇒ Enumerable<Coinbase::ContractEvent>
Returns a list of ContractEvents for the provided network, contract, and event details.
- .list_events_page(network_id, protocol_name, contract_address, contract_name, event_name, from_block_height, to_block_height, page) ⇒ Object
Instance Method Summary collapse
-
#address ⇒ String
Returns the address of the SmartContract.
-
#contract_name ⇒ String
Returns the contract name of the SmartContract.
-
#initialize(model) ⇒ SmartContract
constructor
Returns a new SmartContract object.
-
#inspect ⇒ String
Same as to_s.
-
#network_id ⇒ String
Returns the network ID of the SmartContract.
-
#protocol_name ⇒ String
Returns the protocol name of the SmartContract.
-
#to_s ⇒ String
Returns a string representation of the SmartContract.
Constructor Details
#initialize(model) ⇒ SmartContract
Returns a new SmartContract object.
36 37 38 |
# File 'lib/coinbase/smart_contract.rb', line 36 def initialize(model) @model = model end |
Class Method Details
.contract_events_api ⇒ Object
80 81 82 |
# File 'lib/coinbase/smart_contract.rb', line 80 def self.contract_events_api Coinbase::Client::ContractEventsApi.new(Coinbase.configuration.api_client) end |
.list_events(network_id:, protocol_name:, contract_address:, contract_name:, event_name:, from_block_height:, to_block_height:) ⇒ Enumerable<Coinbase::ContractEvent>
Returns a list of ContractEvents for the provided network, contract, and event details.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/coinbase/smart_contract.rb', line 15 def self.list_events( network_id:, protocol_name:, contract_address:, contract_name:, event_name:, from_block_height:, to_block_height: ) Coinbase::Pagination.enumerate( lambda { |page| list_events_page(network_id, protocol_name, contract_address, contract_name, event_name, from_block_height, to_block_height, page) } ) do |contract_event| Coinbase::ContractEvent.new(contract_event) end end |
.list_events_page(network_id, protocol_name, contract_address, contract_name, event_name, from_block_height, to_block_height, page) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/coinbase/smart_contract.rb', line 84 def self.list_events_page( network_id, protocol_name, contract_address, contract_name, event_name, from_block_height, to_block_height, page ) contract_events_api.list_contract_events( Coinbase.normalize_network(network_id), protocol_name, contract_address, contract_name, event_name, from_block_height, to_block_height, { next_page: page } ) end |
Instance Method Details
#address ⇒ String
Returns the address of the SmartContract.
60 61 62 |
# File 'lib/coinbase/smart_contract.rb', line 60 def address @model.address end |
#contract_name ⇒ String
Returns the contract name of the SmartContract.
54 55 56 |
# File 'lib/coinbase/smart_contract.rb', line 54 def contract_name @model.contract_name end |
#inspect ⇒ String
Same as to_s.
76 77 78 |
# File 'lib/coinbase/smart_contract.rb', line 76 def inspect to_s end |
#network_id ⇒ String
Returns the network ID of the SmartContract.
42 43 44 |
# File 'lib/coinbase/smart_contract.rb', line 42 def network_id Coinbase.to_sym(@model.network_id) end |
#protocol_name ⇒ String
Returns the protocol name of the SmartContract.
48 49 50 |
# File 'lib/coinbase/smart_contract.rb', line 48 def protocol_name @model.protocol_name end |
#to_s ⇒ String
Returns a string representation of the SmartContract.
66 67 68 69 70 71 72 |
# File 'lib/coinbase/smart_contract.rb', line 66 def to_s "Coinbase::SmartContract{ network_id: '#{network_id}', protocol_name: '#{protocol_name}', contract_name: '#{contract_name}', address: '#{address}'}" end |