Class: Sdp::PreparedTokenTransaction

Inherits:
Struct
  • Object
show all
Defined in:
lib/sdp/resources/issuance.rb

Overview

Result of a …/prepare issuance call: the unsigned transaction the caller must sign and submit before blockhash expiry, plus context. SDP nests this two different ways and from_action/from_deploy normalize both:

  • mint/burn prepare → the provisional record under :transaction, the unsigned tx under :prepared_transaction (transaction is a TokenTransaction).

  • deploy prepare → :transaction IS the unsigned tx envelope and the new mint address rides alongside under :mint (transaction is nil — there is no action record yet).

The mint/burn associated token account lives on #transaction (TokenTransaction) when SDP returns one; deploy carries no action record. There is deliberately no top-level token_account — it would only ever duplicate transaction.token_account.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#blockhashObject

Returns the value of attribute blockhash

Returns:

  • (Object)

    the current value of blockhash



89
90
91
# File 'lib/sdp/resources/issuance.rb', line 89

def blockhash
  @blockhash
end

#last_valid_block_heightObject

Returns the value of attribute last_valid_block_height

Returns:

  • (Object)

    the current value of last_valid_block_height



89
90
91
# File 'lib/sdp/resources/issuance.rb', line 89

def last_valid_block_height
  @last_valid_block_height
end

#mintObject

Returns the value of attribute mint

Returns:

  • (Object)

    the current value of mint



89
90
91
# File 'lib/sdp/resources/issuance.rb', line 89

def mint
  @mint
end

#serializedObject

Returns the value of attribute serialized

Returns:

  • (Object)

    the current value of serialized



89
90
91
# File 'lib/sdp/resources/issuance.rb', line 89

def serialized
  @serialized
end

#simulationObject

Returns the value of attribute simulation

Returns:

  • (Object)

    the current value of simulation



89
90
91
# File 'lib/sdp/resources/issuance.rb', line 89

def simulation
  @simulation
end

#transactionObject

Returns the value of attribute transaction

Returns:

  • (Object)

    the current value of transaction



89
90
91
# File 'lib/sdp/resources/issuance.rb', line 89

def transaction
  @transaction
end

Class Method Details

.from_action(hash) ⇒ Object



92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/sdp/resources/issuance.rb', line 92

def self.from_action(hash)
  hash ||= {}
  prepared = hash[:prepared_transaction] || {}
  new(
    transaction: TokenTransaction.from_hash(hash[:transaction], token_account: hash[:token_account]),
    serialized: prepared[:serialized],
    blockhash: prepared[:blockhash],
    last_valid_block_height: prepared[:last_valid_block_height],
    mint: nil,
    simulation: hash[:simulation]
  )
end

.from_deploy(hash) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/sdp/resources/issuance.rb', line 105

def self.from_deploy(hash)
  hash ||= {}
  tx = hash[:transaction] || {}
  new(
    transaction: nil,
    serialized: tx[:serialized],
    blockhash: tx[:blockhash],
    last_valid_block_height: tx[:last_valid_block_height],
    mint: hash[:mint],
    simulation: hash[:simulation]
  )
end