Class: CardanoWallet::Byron::Transactions
- Inherits:
-
CardanoWallet::Base
- Object
- CardanoWallet::Base
- CardanoWallet::Byron::Transactions
- Defined in:
- lib/cardano_wallet/byron.rb
Overview
Byron transactions
Instance Attribute Summary
Attributes inherited from CardanoWallet::Base
Instance Method Summary collapse
-
#construct(wid, payments = nil, metadata = nil, mint = nil, validity_interval = nil) ⇒ Object
Construct transaction.
-
#create(wid, passphrase, payments) ⇒ Object
Create a transaction from the Byron wallet.
-
#forget(wid, txid) ⇒ Object
Forget a transaction.
-
#get(wid, tx_id) ⇒ Object
Get tx by id.
-
#list(wid, query = {}) ⇒ Object
List all Byron wallet’s transactions.
-
#payment_fees(wid, payments) ⇒ Object
Estimate fees for transaction.
-
#sign(wid, passphrase, transaction) ⇒ Object
Sign transaction.
-
#submit(wid, transaction) ⇒ Object
Submit transaction.
Methods inherited from CardanoWallet::Base
#byron, #initialize, #misc, #shared, #shelley, #utils
Constructor Details
This class inherits a constructor from CardanoWallet::Base
Instance Method Details
#construct(wid, payments = nil, metadata = nil, mint = nil, validity_interval = nil) ⇒ Object
Construct transaction
259 260 261 262 263 264 265 266 267 268 269 |
# File 'lib/cardano_wallet/byron.rb', line 259 def construct(wid, payments = nil, = nil, mint = nil, validity_interval = nil) payload = {} payload[:payments] = payments if payments payload[:metadata] = if payload[:mint] = mint if mint payload[:validity_interval] = validity_interval if validity_interval self.class.post("/byron-wallets/#{wid}/transactions-construct", body: payload.to_json, headers: { 'Content-Type' => 'application/json' }) end |
#create(wid, passphrase, payments) ⇒ Object
Create a transaction from the Byron wallet.
326 327 328 329 330 331 332 333 334 335 336 337 |
# File 'lib/cardano_wallet/byron.rb', line 326 def create(wid, passphrase, payments) Utils.verify_param_is_array!(payments) payments_formatted = if payments.any? { |p| p.key?(:address) || p.key?('address') } payments else Utils.format_payments(payments) end self.class.post("/byron-wallets/#{wid}/transactions", body: { payments: payments_formatted, passphrase: passphrase }.to_json, headers: { 'Content-Type' => 'application/json' }) end |
#forget(wid, txid) ⇒ Object
Forget a transaction.
361 362 363 |
# File 'lib/cardano_wallet/byron.rb', line 361 def forget(wid, txid) self.class.delete("/byron-wallets/#{wid}/transactions/#{txid}") end |
#get(wid, tx_id) ⇒ Object
Get tx by id
300 301 302 |
# File 'lib/cardano_wallet/byron.rb', line 300 def get(wid, tx_id) self.class.get("/byron-wallets/#{wid}/transactions/#{tx_id}") end |
#list(wid, query = {}) ⇒ Object
List all Byron wallet’s transactions.
309 310 311 312 |
# File 'lib/cardano_wallet/byron.rb', line 309 def list(wid, query = {}) query_formatted = query.empty? ? '' : Utils.to_query(query) self.class.get("/byron-wallets/#{wid}/transactions#{query_formatted}") end |
#payment_fees(wid, payments) ⇒ Object
Estimate fees for transaction
347 348 349 350 351 352 353 354 355 356 357 |
# File 'lib/cardano_wallet/byron.rb', line 347 def payment_fees(wid, payments) Utils.verify_param_is_array!(payments) payments_formatted = if payments.any? { |p| p.key?(:address) || p.key?('address') } payments else Utils.format_payments(payments) end self.class.post("/byron-wallets/#{wid}/payment-fees", body: { payments: payments_formatted }.to_json, headers: { 'Content-Type' => 'application/json' }) end |
#sign(wid, passphrase, transaction) ⇒ Object
Sign transaction
276 277 278 279 280 281 282 283 284 285 |
# File 'lib/cardano_wallet/byron.rb', line 276 def sign(wid, passphrase, transaction) payload = { 'passphrase' => passphrase, 'transaction' => transaction } self.class.post("/byron-wallets/#{wid}/transactions-sign", body: payload.to_json, headers: { 'Content-Type' => 'application/json' }) end |
#submit(wid, transaction) ⇒ Object
Submit transaction
291 292 293 294 295 296 |
# File 'lib/cardano_wallet/byron.rb', line 291 def submit(wid, transaction) payload = { 'transaction' => transaction } self.class.post("/byron-wallets/#{wid}/transactions-submit", body: payload.to_json, headers: { 'Content-Type' => 'application/json' }) end |