Class: Solrengine::Ui::TransactionStatusComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/solrengine/ui/transaction_status_component.rb

Constant Summary collapse

STATUSES =
{
  pending: { label: "Pending", icon: "M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z", classes: "text-yellow-600 dark:text-yellow-400 bg-yellow-50 dark:bg-yellow-900/20" },
  confirmed: { label: "Confirmed", icon: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z", classes: "text-green-600 dark:text-green-400 bg-green-50 dark:bg-green-900/20" },
  failed: { label: "Failed", icon: "M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z", classes: "text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20" },
  processing: { label: "Processing", icon: "M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15", classes: "text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/20" }
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status:, signature: nil, network: "mainnet-beta") ⇒ TransactionStatusComponent

Returns a new instance of TransactionStatusComponent.



15
16
17
18
19
# File 'app/components/solrengine/ui/transaction_status_component.rb', line 15

def initialize(status:, signature: nil, network: "mainnet-beta")
  @status = status.to_sym
  @signature = signature
  @network = network
end

Instance Attribute Details

#networkObject (readonly)

Returns the value of attribute network.



13
14
15
# File 'app/components/solrengine/ui/transaction_status_component.rb', line 13

def network
  @network
end

#signatureObject (readonly)

Returns the value of attribute signature.



13
14
15
# File 'app/components/solrengine/ui/transaction_status_component.rb', line 13

def signature
  @signature
end

#statusObject (readonly)

Returns the value of attribute status.



13
14
15
# File 'app/components/solrengine/ui/transaction_status_component.rb', line 13

def status
  @status
end

Instance Method Details

#explorer_urlObject



25
26
27
28
29
30
31
32
# File 'app/components/solrengine/ui/transaction_status_component.rb', line 25

def explorer_url
  return unless signature
  if network == "mainnet-beta"
    "https://solscan.io/tx/#{signature}"
  else
    "https://explorer.solana.com/tx/#{signature}?cluster=#{network}"
  end
end

#status_configObject



21
22
23
# File 'app/components/solrengine/ui/transaction_status_component.rb', line 21

def status_config
  STATUSES.fetch(status, STATUSES[:pending])
end