Class: NEAR::Transaction
- Inherits:
-
Object
- Object
- NEAR::Transaction
- Defined in:
- lib/near/transaction.rb
Overview
Represents a NEAR transaction.
Constant Summary collapse
- MAX_SIZE =
The maximum byte size of a NEAR transaction.
1_572_864
Instance Attribute Summary collapse
-
#actions ⇒ Array<Hash>
readonly
The transaction actions.
-
#data ⇒ Hash
readonly
The transaction data, if available.
-
#hash ⇒ String
readonly
The transaction hash.
- #nonce ⇒ Integer readonly
- #priority_fee ⇒ Integer readonly
- #public_key ⇒ String readonly
-
#receiver ⇒ NEAR::Account
readonly
The transaction receiver account.
-
#receiver_id ⇒ String
readonly
The transaction receiver ID.
- #signature ⇒ String readonly
-
#signer ⇒ NEAR::Account
readonly
The transaction signer account.
-
#signer_id ⇒ String
readonly
The transaction signer ID.
Class Method Summary collapse
Instance Method Summary collapse
-
#each_action {|NEAR::Action| ... } ⇒ Enumerator
If no block is given.
- #initialize(hash, data: nil) ⇒ void constructor
- #inspect ⇒ String
- #to_h ⇒ Hash
- #to_s ⇒ String
Constructor Details
#initialize(hash, data: nil) ⇒ void
24 25 26 27 |
# File 'lib/near/transaction.rb', line 24 def initialize(hash, data: nil) @hash = hash.to_s @data = data.to_h if data end |
Instance Attribute Details
#actions ⇒ Array<Hash> (readonly)
The transaction actions.
109 110 111 |
# File 'lib/near/transaction.rb', line 109 def actions @actions end |
#data ⇒ Hash (readonly)
The transaction data, if available.
39 40 41 |
# File 'lib/near/transaction.rb', line 39 def data @data end |
#hash ⇒ String (readonly)
The transaction hash.
33 34 35 |
# File 'lib/near/transaction.rb', line 33 def hash @hash end |
#nonce ⇒ Integer (readonly)
93 94 95 |
# File 'lib/near/transaction.rb', line 93 def nonce @nonce end |
#priority_fee ⇒ Integer (readonly)
100 101 102 |
# File 'lib/near/transaction.rb', line 100 def priority_fee @priority_fee end |
#public_key ⇒ String (readonly)
79 80 81 |
# File 'lib/near/transaction.rb', line 79 def public_key @public_key end |
#receiver ⇒ NEAR::Account (readonly)
The transaction receiver account.
63 64 65 |
# File 'lib/near/transaction.rb', line 63 def receiver @receiver end |
#receiver_id ⇒ String (readonly)
The transaction receiver ID.
72 73 74 |
# File 'lib/near/transaction.rb', line 72 def receiver_id @receiver_id end |
#signature ⇒ String (readonly)
86 87 88 |
# File 'lib/near/transaction.rb', line 86 def signature @signature end |
#signer ⇒ NEAR::Account (readonly)
The transaction signer account.
45 46 47 |
# File 'lib/near/transaction.rb', line 45 def signer @signer end |
#signer_id ⇒ String (readonly)
The transaction signer ID.
54 55 56 |
# File 'lib/near/transaction.rb', line 54 def signer_id @signer_id end |
Class Method Details
.parse(json) ⇒ NEAR::Transaction
15 16 17 18 |
# File 'lib/near/transaction.rb', line 15 def self.parse(json) tx_data = json['transaction'] NEAR::Transaction.new(tx_data['hash'], data: tx_data) end |
Instance Method Details
#each_action {|NEAR::Action| ... } ⇒ Enumerator
Returns if no block is given.
119 120 121 122 123 124 |
# File 'lib/near/transaction.rb', line 119 def each_action(&) return enum_for(:each_action) unless block_given? self.data['actions'].each do |action| yield NEAR::Action.parse(action) end end |
#inspect ⇒ String
136 137 138 |
# File 'lib/near/transaction.rb', line 136 def inspect "#<#{self.class.name} hash: #{@hash.inspect}, signer: #{self.signer}, receiver: #{self.receiver}, actions: #{self.actions.size}>" end |
#to_h ⇒ Hash
132 |
# File 'lib/near/transaction.rb', line 132 def to_h; @data; end |
#to_s ⇒ String
128 |
# File 'lib/near/transaction.rb', line 128 def to_s; @hash; end |