Class: Solrengine::Ui::SendTransactionFormComponent

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

Constant Summary collapse

PUBLIC_RPC_URLS =
{
  "mainnet-beta" => "https://api.mainnet-beta.solana.com",
  "mainnet"      => "https://api.mainnet-beta.solana.com",
  "devnet"       => "https://api.devnet.solana.com",
  "testnet"      => "https://api.testnet.solana.com"
}.freeze
CHAIN_IDS =
{
  "mainnet-beta" => "solana:mainnet",
  "mainnet"      => "solana:mainnet",
  "devnet"       => "solana:devnet",
  "testnet"      => "solana:testnet"
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wallet_address: nil, network: "devnet", rpc_url: nil) ⇒ SendTransactionFormComponent

Returns a new instance of SendTransactionFormComponent.



22
23
24
25
26
# File 'app/components/solrengine/ui/send_transaction_form_component.rb', line 22

def initialize(wallet_address: nil, network: "devnet", rpc_url: nil, **)
  @wallet_address = wallet_address
  @network = network.to_s
  @rpc_url = rpc_url || PUBLIC_RPC_URLS.fetch(@network, PUBLIC_RPC_URLS["devnet"])
end

Instance Attribute Details

#networkObject (readonly)

Returns the value of attribute network.



20
21
22
# File 'app/components/solrengine/ui/send_transaction_form_component.rb', line 20

def network
  @network
end

#rpc_urlObject (readonly)

Returns the value of attribute rpc_url.



20
21
22
# File 'app/components/solrengine/ui/send_transaction_form_component.rb', line 20

def rpc_url
  @rpc_url
end

#wallet_addressObject (readonly)

Returns the value of attribute wallet_address.



20
21
22
# File 'app/components/solrengine/ui/send_transaction_form_component.rb', line 20

def wallet_address
  @wallet_address
end

Instance Method Details

#chainObject



32
33
34
# File 'app/components/solrengine/ui/send_transaction_form_component.rb', line 32

def chain
  CHAIN_IDS.fetch(network, "solana:devnet")
end

#connected?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/components/solrengine/ui/send_transaction_form_component.rb', line 28

def connected?
  wallet_address.present?
end