diff --git a/.gitignore b/.gitignore index f865301c4b..72b3220eaa 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ tmp /config/secrets /config/seed /config/bench/*.yml +/config/registries.local.yml # Ignore translations.js /public/javascripts/translations.js diff --git a/config/initializers/blockchain_api.rb b/config/initializers/blockchain_api.rb deleted file mode 100644 index 5d6fcfa046..0000000000 --- a/config/initializers/blockchain_api.rb +++ /dev/null @@ -1,3 +0,0 @@ -Peatio::Blockchain.registry[:bitcoin] = Bitcoin::Blockchain -Peatio::Blockchain.registry[:geth] = Ethereum::Blockchain -Peatio::Blockchain.registry[:parity] = Ethereum::Blockchain diff --git a/config/initializers/registries.rb b/config/initializers/registries.rb new file mode 100644 index 0000000000..9efa6b1454 --- /dev/null +++ b/config/initializers/registries.rb @@ -0,0 +1,16 @@ +registries = { + wallets: Peatio::Wallet.registry, + blockchains: Peatio::Blockchain.registry, + upstreams: Peatio::Upstream.registry +} + +%w(config/registries.local.yml config/registries.yml).each do |config_file| + next unless File.exists? config_file + YAML.load_file(config_file).each_pair do |registry_name, items| + registry = registries[registry_name.to_sym] || raise("Unknown registry (#{registry_name}) defined in #{config_file}") + items.each do |item_name, item_class| + registry[item_name.to_sym] = item_name.classify + end + end + break +end diff --git a/config/initializers/upstreams.rb b/config/initializers/upstreams.rb deleted file mode 100644 index 055e92f356..0000000000 --- a/config/initializers/upstreams.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'peatio/upstream/opendax' - -Peatio::Upstream.registry[:opendax] = Peatio::Upstream::Opendax diff --git a/config/initializers/wallet_api.rb b/config/initializers/wallet_api.rb deleted file mode 100644 index fc1287ef8f..0000000000 --- a/config/initializers/wallet_api.rb +++ /dev/null @@ -1,7 +0,0 @@ -Peatio::Wallet.registry[:bitcoind] = Bitcoin::Wallet -Peatio::Wallet.registry[:geth] = Ethereum::Wallet -Peatio::Wallet.registry[:parity] = Ethereum::Wallet -Peatio::Wallet.registry[:gnosis] = Gnosis::Wallet -Peatio::Wallet.registry[:ow_hdwallet] = OWHDWallet::Wallet -Peatio::Wallet.registry[:opendax] = OWHDWallet::Wallet -Peatio::Wallet.registry[:opendax_cloud] = OpendaxCloud::Wallet diff --git a/config/registries.yml b/config/registries.yml new file mode 100644 index 0000000000..f6f341f952 --- /dev/null +++ b/config/registries.yml @@ -0,0 +1,16 @@ +wallets: + bitcoind: Bitcoin::Wallet + geth: Ethereum::Wallet + parity: Ethereum::Wallet + gnosis: Gnosis::Wallet + opendax: OWHDWallet::Wallet + ow_hdwallet: OWHDWallet::Wallet + opendax_cloud: OpendaxCloud::Wallet + +blockchains: + bitcoin: Bitcoin::Blockchain + geth: Ethereum::Blockchain + parity: Ethereum::Blockchain + +upstreams: + opendax: Peatio::Upstream::Opendax