Class: Coinbase::SponsoredSend
- Inherits:
-
Object
- Object
- Coinbase::SponsoredSend
- Defined in:
- lib/coinbase/sponsored_send.rb
Overview
A representation of an onchain Sponsored Send. Sponsored Sends should be constructed via higher level abstractions like Transfer.
Defined Under Namespace
Modules: Status
Instance Method Summary collapse
-
#initialize(model) ⇒ SponsoredSend
constructor
Returns a new SponsoredSend object.
-
#inspect ⇒ String
Same as to_s.
-
#sign(key) ⇒ String
Signs the Transaction with the provided key and returns the hex signing payload.
-
#signature ⇒ Object
Returns the signature of the typed data.
-
#signed? ⇒ Boolean
Returns whether the Transaction has been signed.
-
#status ⇒ Symbol
Returns the status of the Transaction.
-
#terminal_state? ⇒ Boolean
Returns whether the Sponsored Send is in a terminal state.
-
#to_s ⇒ String
Returns a String representation of the SponsoredSend.
-
#transaction_hash ⇒ String
Returns the Transaction Hash of the Transaction.
-
#transaction_link ⇒ String
Returns the link to the transaction on the blockchain explorer.
-
#typed_data_hash ⇒ String
Returns the Keccak256 hash of the typed data.
Constructor Details
#initialize(model) ⇒ SponsoredSend
Returns a new SponsoredSend object. Do not use this method directly.
36 37 38 39 40 |
# File 'lib/coinbase/sponsored_send.rb', line 36 def initialize(model) raise unless model.is_a?(Coinbase::Client::SponsoredSend) @model = model end |
Instance Method Details
#inspect ⇒ String
Same as to_s.
106 107 108 |
# File 'lib/coinbase/sponsored_send.rb', line 106 def inspect to_s end |
#sign(key) ⇒ String
Signs the Transaction with the provided key and returns the hex signing payload.
56 57 58 59 60 61 |
# File 'lib/coinbase/sponsored_send.rb', line 56 def sign(key) raise unless key.is_a?(Eth::Key) raise Coinbase::AlreadySignedError if signed? @signature = Eth::Util.prefix_hex(key.sign(Eth::Util.hex_to_bin(typed_data_hash))) end |
#signature ⇒ Object
Returns the signature of the typed data.
50 51 52 |
# File 'lib/coinbase/sponsored_send.rb', line 50 def signature @signature ||= @model.signature end |
#signed? ⇒ Boolean
Returns whether the Transaction has been signed.
65 66 67 |
# File 'lib/coinbase/sponsored_send.rb', line 65 def signed? !signature.nil? end |
#status ⇒ Symbol
Returns the status of the Transaction.
71 72 73 |
# File 'lib/coinbase/sponsored_send.rb', line 71 def status @model.status end |
#terminal_state? ⇒ Boolean
Returns whether the Sponsored Send is in a terminal state.
77 78 79 |
# File 'lib/coinbase/sponsored_send.rb', line 77 def terminal_state? Status::TERMINAL_STATES.include?(status) end |
#to_s ⇒ String
Returns a String representation of the SponsoredSend.
95 96 97 98 99 100 101 102 |
# File 'lib/coinbase/sponsored_send.rb', line 95 def to_s Coinbase.pretty_print_object( self.class, status: status, transaction_hash: transaction_hash, transaction_link: transaction_link ) end |
#transaction_hash ⇒ String
Returns the Transaction Hash of the Transaction.
83 84 85 |
# File 'lib/coinbase/sponsored_send.rb', line 83 def transaction_hash @model.transaction_hash end |
#transaction_link ⇒ String
Returns the link to the transaction on the blockchain explorer.
89 90 91 |
# File 'lib/coinbase/sponsored_send.rb', line 89 def transaction_link @model.transaction_link end |
#typed_data_hash ⇒ String
Returns the Keccak256 hash of the typed data. This payload must be signed by the sender to be used as an approval in the EIP-3009 transaction.
45 46 47 |
# File 'lib/coinbase/sponsored_send.rb', line 45 def typed_data_hash @model.typed_data_hash end |