Class: CardanoWallet::Shared::Transactions
- Defined in:
- lib/cardano_wallet/shared.rb
Overview
API for Transactions
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#construct(wid, payments = nil, withdrawal = nil, metadata = nil, delegations = nil, mint = nil, validity_interval = nil, encoding = nil) ⇒ Object
Construct transaction.
-
#decode(wid, transaction) ⇒ Object
Decode transaction.
-
#get(wid, tx_id, query = {}) ⇒ Object
Get tx by id.
-
#list(wid, query = {}) ⇒ Object
List all wallet’s transactions.
-
#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
#construct(wid, payments = nil, withdrawal = nil, metadata = nil, delegations = nil, mint = nil, validity_interval = nil, encoding = nil) ⇒ Object
Construct transaction
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/cardano_wallet/shared.rb', line 55 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("/shared-wallets/#{wid}/transactions-construct", body: payload.to_json, headers: { 'Content-Type' => 'application/json' }) end |
#decode(wid, transaction) ⇒ Object
Decode transaction
81 82 83 84 85 86 87 |
# File 'lib/cardano_wallet/shared.rb', line 81 def decode(wid, transaction) payload = {} payload[:transaction] = transaction self.class.post("/shared-wallets/#{wid}/transactions-decode", body: payload.to_json, headers: { 'Content-Type' => 'application/json' }) end |
#get(wid, tx_id, query = {}) ⇒ Object
Get tx by id
119 120 121 122 |
# File 'lib/cardano_wallet/shared.rb', line 119 def get(wid, tx_id, query = {}) query_formatted = query.empty? ? '' : Utils.to_query(query) self.class.get("/shared-wallets/#{wid}/transactions/#{tx_id}#{query_formatted}") end |
#list(wid, query = {}) ⇒ Object
List all wallet’s transactions
129 130 131 132 |
# File 'lib/cardano_wallet/shared.rb', line 129 def list(wid, query = {}) query_formatted = query.empty? ? '' : Utils.to_query(query) self.class.get("/shared-wallets/#{wid}/transactions#{query_formatted}") end |
#sign(wid, passphrase, transaction, encoding = nil) ⇒ Object
Sign transaction
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/cardano_wallet/shared.rb', line 95 def sign(wid, passphrase, transaction, encoding = nil) payload = { 'passphrase' => passphrase, 'transaction' => transaction } payload[:encoding] = encoding if encoding self.class.post("/shared-wallets/#{wid}/transactions-sign", body: payload.to_json, headers: { 'Content-Type' => 'application/json' }) end |
#submit(wid, transaction) ⇒ Object
Submit transaction
110 111 112 113 114 115 |
# File 'lib/cardano_wallet/shared.rb', line 110 def submit(wid, transaction) payload = { 'transaction' => transaction } self.class.post("/shared-wallets/#{wid}/transactions-submit", body: payload.to_json, headers: { 'Content-Type' => 'application/json' }) end |