Class: CardanoWallet::Shared::Transactions

Inherits:
Base
  • Object
show all
Defined in:
lib/cardano_wallet/shared.rb

Overview

API for Transactions

Examples:

@cw = CardanoWallet.new
@cw.shared.transactions # API for Shared transactions

See Also:

Instance Attribute Summary

Attributes inherited from Base

#opt

Instance Method Summary collapse

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

Parameters:

  • wid (String)

    source wallet id

  • payments (Array of Hashes) (defaults to: nil)

    full payments payload with assets

  • withdrawal (String or Array) (defaults to: nil)

    ‘self’ or mnemonic sentence

  • metadata (Hash) (defaults to: nil)
  • mint (Array of Hashes) (defaults to: nil)

    mint object

  • delegations (Array of Hashes) (defaults to: nil)

    delegations object

  • validity_interval (Hash) (defaults to: nil)

    validity_interval object

  • encoding (String) (defaults to: nil)

    output encoding (“base16” or “base64”)

See Also:



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

Parameters:

  • wid (String)

    source wallet id

  • transaction (String)

    CBOR base64|base16 encoded transaction

See Also:



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

Examples:

list(wid, {start: "2012-09-25T10:15:00Z", order: "descending"})

See Also:



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

Parameters:

  • wid (String)

    source wallet id

  • passphrase (String)

    wallet’s passphrase

  • transaction (String)

    CBOR transaction data

  • encoding (String) (defaults to: nil)

    output encoding (“base16” or “base64”)

See Also:



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

Parameters:

  • wid (String)

    source wallet id

  • transaction (String)

    CBOR transaction data

See Also:



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