Class: Peatio::Wallet::Abstract Abstract
- Inherits:
-
Object
- Object
- Peatio::Wallet::Abstract
- Defined in:
- lib/peatio/wallet/abstract.rb
Overview
Represents basic wallet interface.
Subclass and override abstract methods to implement a peatio plugable wallet. Than you need to register your wallet implementation.
Constant Summary collapse
- SUPPORTED_SETTINGS =
List of configurable settings.
%i[wallet currency].freeze
Instance Attribute Summary collapse
-
#settings ⇒ Hash
readonly
abstract
Current wallet settings for performing API calls.
Instance Method Summary collapse
-
#configure(settings = {}) ⇒ Hash
abstract
Merges given configuration parameters with defined during initialization and returns the result.
-
#create_address!(options = {}) ⇒ Hash
abstract
Performs API call for address creation and returns it.
-
#create_transaction!(transaction, options = {}) ⇒ Peatio::Transaction
abstract
Performs API call for creating transaction and returns updated transaction.
-
#initialize ⇒ Abstract
constructor
abstract
Abstract constructor.
-
#load_balance! ⇒ BigDecimal
Fetches address balance of specific currency.
-
#prepare_deposit_collection!(deposit_transaction, spread_transactions, deposit_currency) ⇒ Array<Peatio::Transaction>
Performs API call(s) for preparing for deposit collection.
Constructor Details
#initialize ⇒ Abstract
Abstract constructor.
57 58 59 |
# File 'lib/peatio/wallet/abstract.rb', line 57 def initialize(*) abstract_method end |
Instance Attribute Details
#settings ⇒ Hash (readonly)
Current wallet settings for performing API calls.
32 33 34 |
# File 'lib/peatio/wallet/abstract.rb', line 32 def settings @settings end |
Instance Method Details
#configure(settings = {}) ⇒ Hash
Merges given configuration parameters with defined during initialization and returns the result.
With :address required key other settings could be customized using Wallet#settings.
75 76 77 |
# File 'lib/peatio/wallet/abstract.rb', line 75 def configure(settings = {}) abstract_method end |
#create_address!(options = {}) ⇒ Hash
Performs API call for address creation and returns it.
95 96 97 |
# File 'lib/peatio/wallet/abstract.rb', line 95 def create_address!( = {}) abstract_method end |
#create_transaction!(transaction, options = {}) ⇒ Peatio::Transaction
Performs API call for creating transaction and returns updated transaction.
to_address, amount & currency_id.
121 122 123 |
# File 'lib/peatio/wallet/abstract.rb', line 121 def create_transaction!(transaction, = {}) abstract_method end |
#load_balance! ⇒ BigDecimal
Optional. Don’t override this method if your blockchain
Fetches address balance of specific currency.
doesn’t provide functionality to get balance by address.
if error was raised on wallet API call ClientError is raised. if wallet API call was successful but we can’t detect balance for address Error is raised.
136 137 138 |
# File 'lib/peatio/wallet/abstract.rb', line 136 def load_balance! raise Peatio::Wallet::UnavailableAddressBalanceError end |
#prepare_deposit_collection!(deposit_transaction, spread_transactions, deposit_currency) ⇒ Array<Peatio::Transaction>
Optional. Override this method only if you need additional step
Performs API call(s) for preparing for deposit collection. E.g deposits ETH for collecting ERC20 tokens in case of Ethereum blockchain.
before deposit collection.
describes received deposit.
spread between wallets.
deposit collection preparing. By default return empty [Array]
155 156 157 158 159 |
# File 'lib/peatio/wallet/abstract.rb', line 155 def prepare_deposit_collection!(deposit_transaction, spread_transactions, deposit_currency) # This method is mostly used for coins which needs additional fees # to be deposited before deposit collection. [] end |