Class: CardanoWallet::Shelley::Transactions
- Defined in:
- lib/cardano_wallet/shelley.rb
Overview
API for Transactions
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#balance(wid, payload) ⇒ Object
Balance transaction.
-
#construct(wid, payments = nil, withdrawal = nil, metadata = nil, delegations = nil, mint = nil, validity_interval = nil, encoding = nil) ⇒ Object
Construct transaction.
-
#create(wid, passphrase, payments, withdrawal = nil, metadata = nil, ttl = nil) ⇒ Object
Create a transaction from the wallet.
-
#decode(wid, transaction) ⇒ Object
Decode transaction.
-
#forget(wid, txid) ⇒ Object
Forget a transaction.
-
#get(wid, tx_id, query = {}) ⇒ Object
Get tx by id.
-
#list(wid, query = {}) ⇒ Object
List all wallet’s transactions.
-
#payment_fees(wid, payments, withdrawal = nil, metadata = nil, ttl = nil) ⇒ Object
Estimate fees for transaction.
-
#sign(wid, passphrase, transaction, encoding = nil) ⇒ Object
Sign transaction.
-
#submit(wid, transaction) ⇒ Object
Submit transaction.
Methods inherited from Base
#byron, #initialize, #misc, #shared, #shelley, #utils
Constructor Details
This class inherits a constructor from CardanoWallet::Base
Instance Method Details
#balance(wid, payload) ⇒ Object
Balance transaction
306 307 308 309 310 |
# File 'lib/cardano_wallet/shelley.rb', line 306 def balance(wid, payload) self.class.post("/wallets/#{wid}/transactions-balance", body: payload.to_json, headers: { 'Content-Type' => 'application/json' }) end |
#construct(wid, payments = nil, withdrawal = nil, metadata = nil, delegations = nil, mint = nil, validity_interval = nil, encoding = nil) ⇒ Object
Construct transaction
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
# File 'lib/cardano_wallet/shelley.rb', line 334 def construct(wid, payments = nil, withdrawal = nil, = nil, delegations = nil, mint = nil, validity_interval = nil, encoding = nil) payload = {} payload[:payments] = payments if payments payload[:withdrawal] = withdrawal if withdrawal payload[:metadata] = if payload[:mint_burn] = mint if mint payload[:delegations] = delegations if delegations payload[:validity_interval] = validity_interval if validity_interval payload[:encoding] = encoding if encoding self.class.post("/wallets/#{wid}/transactions-construct", body: payload.to_json, headers: { 'Content-Type' => 'application/json' }) end |
#create(wid, passphrase, payments, withdrawal = nil, metadata = nil, ttl = nil) ⇒ Object
Create a transaction from the wallet
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
# File 'lib/cardano_wallet/shelley.rb', line 416 def create(wid, passphrase, payments, withdrawal = nil, = nil, ttl = nil) 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 payload = { payments: payments_formatted, passphrase: passphrase } payload[:withdrawal] = withdrawal if withdrawal payload[:metadata] = if payload[:time_to_live] = { quantity: ttl, unit: 'second' } if ttl self.class.post("/wallets/#{wid}/transactions", body: payload.to_json, headers: { 'Content-Type' => 'application/json' }) end |
#decode(wid, transaction) ⇒ Object
Decode transaction
316 317 318 319 320 321 322 |
# File 'lib/cardano_wallet/shelley.rb', line 316 def decode(wid, transaction) payload = {} payload[:transaction] = transaction self.class.post("/wallets/#{wid}/transactions-decode", body: payload.to_json, headers: { 'Content-Type' => 'application/json' }) end |
#forget(wid, txid) ⇒ Object
Forget a transaction
464 465 466 |
# File 'lib/cardano_wallet/shelley.rb', line 464 def forget(wid, txid) self.class.delete("/wallets/#{wid}/transactions/#{txid}") end |
#get(wid, tx_id, query = {}) ⇒ Object
Get tx by id
386 387 388 389 |
# File 'lib/cardano_wallet/shelley.rb', line 386 def get(wid, tx_id, query = {}) query_formatted = query.empty? ? '' : Utils.to_query(query) self.class.get("/wallets/#{wid}/transactions/#{tx_id}#{query_formatted}") end |
#list(wid, query = {}) ⇒ Object
List all wallet’s transactions
396 397 398 399 |
# File 'lib/cardano_wallet/shelley.rb', line 396 def list(wid, query = {}) query_formatted = query.empty? ? '' : Utils.to_query(query) self.class.get("/wallets/#{wid}/transactions#{query_formatted}") end |
#payment_fees(wid, payments, withdrawal = nil, metadata = nil, ttl = nil) ⇒ Object
Estimate fees for transaction
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
# File 'lib/cardano_wallet/shelley.rb', line 443 def payment_fees(wid, payments, withdrawal = nil, = nil, ttl = nil) 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 payload = { payments: payments_formatted } payload[:withdrawal] = withdrawal if withdrawal payload[:metadata] = if payload[:time_to_live] = { quantity: ttl, unit: 'second' } if ttl self.class.post("/wallets/#{wid}/payment-fees", body: payload.to_json, headers: { 'Content-Type' => 'application/json' }) end |
#sign(wid, passphrase, transaction, encoding = nil) ⇒ Object
Sign transaction
362 363 364 365 366 367 368 369 370 371 |
# File 'lib/cardano_wallet/shelley.rb', line 362 def sign(wid, passphrase, transaction, encoding = nil) payload = { 'passphrase' => passphrase, 'transaction' => transaction } payload[:encoding] = encoding if encoding self.class.post("/wallets/#{wid}/transactions-sign", body: payload.to_json, headers: { 'Content-Type' => 'application/json' }) end |
#submit(wid, transaction) ⇒ Object
Submit transaction
377 378 379 380 381 382 |
# File 'lib/cardano_wallet/shelley.rb', line 377 def submit(wid, transaction) payload = { 'transaction' => transaction } self.class.post("/wallets/#{wid}/transactions-submit", body: payload.to_json, headers: { 'Content-Type' => 'application/json' }) end |