Class: Sequence::Transaction::Builder
- Inherits:
-
Object
- Object
- Sequence::Transaction::Builder
- Defined in:
- lib/sequence/transaction.rb
Overview
A configuration object for creating and submitting transactions.
Instance Method Summary collapse
- #actions ⇒ Object
- #add_action(opts = {}) ⇒ Object
-
#initialize {|_self| ... } ⇒ Builder
constructor
A new instance of Builder.
-
#issue(amount:, flavor_id:, destination_account_id:, token_tags: {}, action_tags: {}) ⇒ Builder
Issue new tokens to a destination account.
-
#retire(amount:, flavor_id:, source_account_id:, filter: nil, filter_params: nil, action_tags: {}) ⇒ Builder
Take tokens from a source account and retire them.
- #to_h ⇒ Object
- #to_json(opts = nil) ⇒ Object
- #transaction_tags ⇒ Object
-
#transaction_tags=(tags) ⇒ Builder
Add tags to the transaction.
-
#transfer(amount:, flavor_id:, source_account_id:, destination_account_id:, filter: nil, filter_params: nil, token_tags: {}, action_tags: {}) ⇒ Builder
Move tokens from a source account to a destination account.
Constructor Details
#initialize {|_self| ... } ⇒ Builder
Returns a new instance of Builder.
80 81 82 |
# File 'lib/sequence/transaction.rb', line 80 def initialize(&block) yield(self) if block end |
Instance Method Details
#actions ⇒ Object
85 86 87 |
# File 'lib/sequence/transaction.rb', line 85 def actions @actions ||= [] end |
#add_action(opts = {}) ⇒ Object
105 106 107 108 109 110 111 |
# File 'lib/sequence/transaction.rb', line 105 def add_action(opts = {}) if opts[:amount].nil? raise ArgumentError, ':amount must be provided' end actions << opts self end |
#issue(amount:, flavor_id:, destination_account_id:, token_tags: {}, action_tags: {}) ⇒ Builder
Issue new tokens to a destination account.
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/sequence/transaction.rb', line 134 def issue( amount:, flavor_id:, destination_account_id:, token_tags: {}, action_tags: {} ) add_action( type: :issue, amount: amount, flavor_id: flavor_id, destination_account_id: destination_account_id, token_tags: , action_tags: , ) end |
#retire(amount:, flavor_id:, source_account_id:, filter: nil, filter_params: nil, action_tags: {}) ⇒ Builder
Take tokens from a source account and retire them.
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/sequence/transaction.rb', line 206 def retire( amount:, flavor_id:, source_account_id:, filter: nil, filter_params: nil, action_tags: {} ) add_action( type: :retire, amount: amount, flavor_id: flavor_id, source_account_id: source_account_id, filter: filter, filter_params: filter_params, action_tags: , ) end |
#to_h ⇒ Object
95 96 97 |
# File 'lib/sequence/transaction.rb', line 95 def to_h { actions: actions, transaction_tags: } end |
#to_json(opts = nil) ⇒ Object
100 101 102 |
# File 'lib/sequence/transaction.rb', line 100 def to_json(opts = nil) to_h.to_json(opts) end |
#transaction_tags ⇒ Object
90 91 92 |
# File 'lib/sequence/transaction.rb', line 90 def @transaction_tags || {} end |
#transaction_tags=(tags) ⇒ Builder
Add tags to the transaction
117 118 119 120 |
# File 'lib/sequence/transaction.rb', line 117 def () @transaction_tags = self end |
#transfer(amount:, flavor_id:, source_account_id:, destination_account_id:, filter: nil, filter_params: nil, token_tags: {}, action_tags: {}) ⇒ Builder
Move tokens from a source account to a destination account.
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/sequence/transaction.rb', line 169 def transfer( amount:, flavor_id:, source_account_id:, destination_account_id:, filter: nil, filter_params: nil, token_tags: {}, action_tags: {} ) add_action( type: :transfer, amount: amount, flavor_id: flavor_id, source_account_id: source_account_id, destination_account_id: destination_account_id, filter: filter, filter_params: filter_params, token_tags: , action_tags: , ) end |