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
Be careful with your wallet state after configure. Clean everything what could be related to other wallet configuration. E.g. client state.
Merges given configuration parameters with defined during initialization and returns the result.
With :address required key other settings could be customized using Wallet#settings.
79 80 81 |
# File 'lib/peatio/wallet/abstract.rb', line 79 def configure(settings = {}) abstract_method end |
#create_address!(options = {}) ⇒ Hash
Performs API call for address creation and returns it.
99 100 101 |
# File 'lib/peatio/wallet/abstract.rb', line 99 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.
125 126 127 |
# File 'lib/peatio/wallet/abstract.rb', line 125 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.
140 141 142 |
# File 'lib/peatio/wallet/abstract.rb', line 140 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]
159 160 161 162 163 |
# File 'lib/peatio/wallet/abstract.rb', line 159 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 |