Class: Coinbase::FaucetTransaction
- Inherits:
-
Object
- Object
- Coinbase::FaucetTransaction
- Defined in:
- lib/coinbase/faucet_transaction.rb
Overview
A representation of a transaction from a faucet. a user-controlled Wallet to another address. The fee is assumed to be paid in the native Asset of the Network. Transfers should be created through Wallet#transfer or Address#transfer.
Instance Method Summary collapse
-
#initialize(model) ⇒ FaucetTransaction
constructor
Returns a new FaucetTransaction object.
-
#inspect ⇒ String
Same as to_s.
-
#network ⇒ Coinbase::Network
Returns the Network of the Transaction.
- #reload ⇒ Object
-
#status ⇒ Symbol
Returns the status of the Faucet transaction.
-
#to_s ⇒ String
Returns a String representation of the FaucetTransaction.
-
#transaction ⇒ Coinbase::Transaction
Returns the Faucet transaction.
-
#transaction_hash ⇒ String
Returns the transaction hash.
-
#transaction_link ⇒ String
Returns the link to the transaction on the blockchain explorer.
-
#wait!(interval_seconds = 0.2, timeout_seconds = 20) ⇒ Transfer
Waits until the FaucetTransaction is completed or failed by polling on the given interval.
Constructor Details
#initialize(model) ⇒ FaucetTransaction
Returns a new FaucetTransaction object. Do not use this method directly - instead, use Address#faucet.
11 12 13 |
# File 'lib/coinbase/faucet_transaction.rb', line 11 def initialize(model) @model = model end |
Instance Method Details
#inspect ⇒ String
Same as to_s.
93 94 95 |
# File 'lib/coinbase/faucet_transaction.rb', line 93 def inspect to_s end |
#network ⇒ Coinbase::Network
Returns the Network of the Transaction.
41 42 43 |
# File 'lib/coinbase/faucet_transaction.rb', line 41 def network transaction.network end |
#reload ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/coinbase/faucet_transaction.rb', line 66 def reload @model = Coinbase.call_api do addresses_api.get_faucet_transaction( network.normalized_id, transaction.to_address_id, transaction_hash ) end @transaction = Coinbase::Transaction.new(@model.transaction) self end |
#status ⇒ Symbol
Returns the status of the Faucet transaction.
23 24 25 |
# File 'lib/coinbase/faucet_transaction.rb', line 23 def status transaction.status end |
#to_s ⇒ String
Returns a String representation of the FaucetTransaction.
82 83 84 85 86 87 88 89 |
# File 'lib/coinbase/faucet_transaction.rb', line 82 def to_s Coinbase.pretty_print_object( self.class, status: transaction.status, transaction_hash: transaction_hash, transaction_link: transaction_link ) end |
#transaction ⇒ Coinbase::Transaction
Returns the Faucet transaction.
17 18 19 |
# File 'lib/coinbase/faucet_transaction.rb', line 17 def transaction @transaction ||= Coinbase::Transaction.new(@model.transaction) end |
#transaction_hash ⇒ String
Returns the transaction hash.
29 30 31 |
# File 'lib/coinbase/faucet_transaction.rb', line 29 def transaction_hash transaction.transaction_hash end |
#transaction_link ⇒ String
Returns the link to the transaction on the blockchain explorer.
35 36 37 |
# File 'lib/coinbase/faucet_transaction.rb', line 35 def transaction_link transaction.transaction_link end |
#wait!(interval_seconds = 0.2, timeout_seconds = 20) ⇒ Transfer
Waits until the FaucetTransaction is completed or failed by polling on the given interval.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/coinbase/faucet_transaction.rb', line 50 def wait!(interval_seconds = 0.2, timeout_seconds = 20) start_time = Time.now loop do reload return self if transaction.terminal_state? raise Timeout::Error, 'Faucet transaction timed out' if Time.now - start_time > timeout_seconds self.sleep interval_seconds end self end |