lib/stellar/transaction_envelope.rb in stellar-base-0.23.1 vs lib/stellar/transaction_envelope.rb in stellar-base-0.24.0.pre.1

- old
+ new

@@ -1,48 +1,22 @@ module Stellar class TransactionEnvelope - class << self - def v0(tx:, signatures:) - v0_envelope = TransactionV0Envelope.new(tx: tx, signatures: signatures) - new(:envelope_type_tx_v0, v0_envelope) - end - - def v1(tx:, signatures:) - v1_envelope = TransactionV1Envelope.new(tx: tx, signatures: signatures) - new(:envelope_type_tx, v1_envelope) - end - - def fee_bump(tx:, signatures:) - fee_bump_envelope = FeeBumpTransactionEnvelope.new(tx: tx, signatures: signatures) - new(:envelope_type_tx_fee_bump, fee_bump_envelope) - end - end - # Delegates any undefined method to the currently set arm def method_missing(method, *args, &block) - case switch - when EnvelopeType.envelope_type_tx_v0 - v0!.public_send(method, *args) - when EnvelopeType.envelope_type_tx - v1!.public_send(method, *args) - when EnvelopeType.envelope_type_tx_fee_bump - fee_bump!.public_send(method, *args) - else - super - end + value&.public_send(method, *args) || super end def respond_to_missing?(method, include_private = false) - ["tx", "signatures"].include?(method) || super + %w[tx signatures].include?(method) || super end # Checks to ensure that every signature for the envelope is # a valid signature of one of the provided `key_pairs` # # NOTE: this does not do any authorization checks, which requires access to # the current ledger state. # - # @param *key_pairs [Array<Stellar::KeyPair>] The key pairs to check the envelopes signatures against + # @param key_pairs [Array<Stellar::KeyPair>] The key pairs to check the envelopes signatures against # # @return [Boolean] true if all signatures are from the provided key_pairs and validly sign the tx's hash def signed_correctly?(*key_pairs) hash = tx.hash return false if signatures.empty?