Module: StellarBase

Includes:
GemConfig::Base
Defined in:
lib/stellar_base.rb,
lib/stellar_base/engine.rb,
lib/stellar_base/version.rb,
app/models/stellar_base/deposit.rb,
lib/stellar_base/horizon_client.rb,
app/models/stellar_base/stellar_toml.rb,
app/jobs/stellar_base/application_job.rb,
app/services/stellar_base/gen_memo_for.rb,
app/models/stellar_base/bridge_callback.rb,
app/models/stellar_base/deposit_request.rb,
app/twins/stellar_base/application_twin.rb,
app/models/stellar_base/application_record.rb,
app/models/stellar_base/withdrawal_request.rb,
app/helpers/stellar_base/application_helper.rb,
app/jobs/stellar_base/subscribe_account_job.rb,
app/mailers/stellar_base/application_mailer.rb,
app/services/stellar_base/gen_random_string.rb,
app/services/stellar_base/subscribe_account.rb,
app/twins/stellar_base/deposit_request_twin.rb,
app/controllers/stellar_base/home_controller.rb,
app/models/stellar_base/account_subscription.rb,
app/services/stellar_base/init_stellar_client.rb,
app/concepts/stellar_base/application_contract.rb,
app/twins/stellar_base/withdrawal_request_twin.rb,
app/concepts/stellar_base/application_operation.rb,
app/controllers/stellar_base/deposit_controller.rb,
app/controllers/stellar_base/withdraw_controller.rb,
app/services/stellar_base/bridge_callbacks/check.rb,
app/services/stellar_base/configured_class_runner.rb,
app/services/stellar_base/bridge_callbacks/compare.rb,
app/services/stellar_base/bridge_callbacks/process.rb,
app/services/stellar_base/deposit_requests/trigger.rb,
app/controllers/stellar_base/application_controller.rb,
app/jobs/stellar_base/enqueue_subscribe_accounts_job.rb,
app/representers/stellar_base/application_representer.rb,
app/services/stellar_base/deposit_requests/send_asset.rb,
app/services/stellar_base/withdrawal_requests/process.rb,
app/services/stellar_base/account_subscriptions/get_tx.rb,
app/services/stellar_base/deposit_requests/find_config.rb,
app/services/stellar_base/deposit_requests/find_deposit.rb,
app/controllers/stellar_base/bridge_callbacks_controller.rb,
app/services/stellar_base/bridge_callbacks/get_operation.rb,
app/representers/stellar_base/deposit_request_representer.rb,
app/services/stellar_base/deposit_requests/create_deposit.rb,
app/services/stellar_base/deposit_requests/update_deposit.rb,
app/services/stellar_base/account_subscriptions/get_cursor.rb,
app/services/stellar_base/bridge_callbacks/get_transaction.rb,
app/concepts/stellar_base/bridge_callbacks/contracts/create.rb,
app/concepts/stellar_base/deposit_requests/contracts/create.rb,
app/services/stellar_base/account_subscriptions/save_cursor.rb,
app/services/stellar_base/withdrawal_requests/determine_fee.rb,
app/concepts/stellar_base/bridge_callbacks/operations/create.rb,
app/concepts/stellar_base/deposit_requests/operations/create.rb,
app/representers/stellar_base/withdrawal_request_representer.rb,
app/services/stellar_base/bridge_callbacks/verify_mac_payload.rb,
app/services/stellar_base/deposit_requests/init_stellar_asset.rb,
app/concepts/stellar_base/withdrawal_requests/contracts/create.rb,
app/services/stellar_base/account_subscriptions/get_operations.rb,
app/services/stellar_base/deposit_requests/init_stellar_amount.rb,
app/services/stellar_base/withdrawal_requests/call_on_withdraw.rb,
app/concepts/stellar_base/withdrawal_requests/operations/create.rb,
app/services/stellar_base/bridge_callbacks/mac_payloads/compare.rb,
app/services/stellar_base/deposit_requests/find_deposit_request.rb,
app/services/stellar_base/account_subscriptions/execute_callback.rb,
app/concepts/stellar_base/bridge_callbacks/bridge_callback_policy.rb,
app/concepts/stellar_base/deposit_requests/deposit_request_policy.rb,
app/services/stellar_base/deposit_requests/find_depositable_asset.rb,
app/services/stellar_base/withdrawal_requests/determine_max_amount.rb,
app/services/stellar_base/bridge_callbacks/initialize_horizon_client.rb,
app/services/stellar_base/bridge_callbacks/mac_payloads/check_payload.rb,
app/services/stellar_base/bridge_callbacks/mac_payloads/encode_params.rb,
app/services/stellar_base/withdrawal_requests/find_withdrawable_asset.rb,
app/services/stellar_base/withdrawal_requests/find_withdrawal_request.rb,
app/services/stellar_base/bridge_callbacks/mac_payloads/decode_mac_key.rb,
app/services/stellar_base/bridge_callbacks/mac_payloads/decode_payload.rb,
app/services/stellar_base/deposit_requests/init_stellar_issuer_account.rb,
app/concepts/stellar_base/withdrawal_requests/withdrawal_request_policy.rb,
app/services/stellar_base/deposit_requests/init_stellar_recipient_account.rb,
app/services/stellar_base/deposit_requests/init_stellar_distribution_account.rb

Defined Under Namespace

Modules: AccountSubscriptions, ApplicationHelper, BridgeCallbacks, DepositRequests, WithdrawalRequests Classes: AccountSubscription, ApplicationContract, ApplicationController, ApplicationJob, ApplicationMailer, ApplicationOperation, ApplicationRecord, ApplicationRepresenter, ApplicationTwin, BridgeCallback, BridgeCallbacksController, ConfiguredClassRunner, Deposit, DepositController, DepositRequest, DepositRequestRepresenter, DepositRequestTwin, Engine, EnqueueSubscribeAccountsJob, GenMemoFor, GenRandomString, HomeController, HorizonClient, InitStellarClient, SaveCursor, StellarToml, SubscribeAccount, SubscribeAccountJob, WithdrawController, WithdrawalRequest, WithdrawalRequestRepresenter, WithdrawalRequestTwin

Constant Summary collapse

VERSION =
"0.9.0".freeze

Class Method Summary collapse

Class Method Details

.configure_sidekiq_death_handler!Object



106
107
108
109
110
111
112
113
# File 'lib/stellar_base.rb', line 106

def self.configure_sidekiq_death_handler!
  Sidekiq.configure_server do |config|
    config.death_handlers << ->(job, _ex) do
      return unless job['unique_digest']
      SidekiqUniqueJobs::Digests.del(digest: job['unique_digest'])
    end
  end
end

.convert_config_deposit!Object



70
71
72
73
74
75
76
# File 'lib/stellar_base.rb', line 70

def self.convert_config_deposit!
  depositable_assets = configuration.depositable_assets
  return if depositable_assets.is_a?(Array) || depositable_assets.nil?

  configuration.depositable_assets =
    convert_config!(depositable_assets)
end

.convert_config_withdraw!Object



78
79
80
81
82
83
84
# File 'lib/stellar_base.rb', line 78

def self.convert_config_withdraw!
  withdrawable_assets = configuration.withdrawable_assets
  return if withdrawable_assets.is_a?(Array) || withdrawable_assets.nil?

  configuration.withdrawable_assets =
    convert_config!(withdrawable_assets)
end

.included_module?(module_name) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/stellar_base.rb', line 50

def self.included_module?(module_name)
  configuration.modules&.include?(module_name)
end

.on_deposit_trigger(network:, deposit_address:, tx_id:, amount:) ⇒ Object



46
47
48
# File 'lib/stellar_base.rb', line 46

def self.on_deposit_trigger(network:, deposit_address:, tx_id:, amount:)
  DepositRequests::Trigger.(network, deposit_address, tx_id, amount)
end

.set_stellar_network!Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/stellar_base.rb', line 54

def self.set_stellar_network!
  stellar_network = configuration.stellar_network

  case stellar_network
  when "public"
    Stellar.default_network = Stellar::Networks::PUBLIC
  when "testnet"
    Stellar.default_network = Stellar::Networks::TESTNET
  else
    raise(
      ArgumentError,
      "'#{stellar_network}' not a valid stellar_network config",
    )
  end
end