peatio 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/peatio/block.rb +17 -2
- data/lib/peatio/blockchain/abstract.rb +5 -1
- data/lib/peatio/blockchain/registry.rb +1 -1
- data/lib/peatio/transaction.rb +72 -9
- data/lib/peatio/version.rb +1 -1
- data/lib/peatio/wallet/abstract.rb +4 -0
- data/lib/peatio/wallet/registry.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19e4587348d9e3ef0967a19ca63089397f8a3acc49b5b565eae0a23cc071bc23
|
4
|
+
data.tar.gz: 2ce821a3fd697ab8afa53161d197e601961b14d3f9314d778757894e8c0f75b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7c9015c4cc3eb3c6cf0b67ab9925ebff6a968c3a6a3f05a5ad947e602c11859460e74eb626d4ac304bd7bf622bbfbb0ae1e1538aabfa555099586bf89dfabcd
|
7
|
+
data.tar.gz: a671c3f89623f0f74d8ba80363ab5c9d856c30ebf295a1a2e823b48f58a12cf2f28184a138bd92d11e214fcb08d2eff3109efe36909f5d4c62658221e04b5103
|
data/Gemfile.lock
CHANGED
data/lib/peatio/block.rb
CHANGED
@@ -1,10 +1,25 @@
|
|
1
|
-
module Peatio
|
1
|
+
module Peatio #:nodoc:
|
2
|
+
|
3
|
+
# This class represents blockchain block which contains transactions.
|
4
|
+
#
|
5
|
+
# Using instant of this class in return for Peatio::Blockchain#fetch_block!
|
6
|
+
# @see Peatio::Blockchain#fetch_block! example implementation
|
7
|
+
# (inside peatio source https://github.com/rubykube/peatio)
|
8
|
+
#
|
9
|
+
# @author
|
10
|
+
# Maksym Naichuk <naichuk.maks@gmail.com> (https://github.com/mnaichuk)
|
2
11
|
class Block
|
3
12
|
include Enumerable
|
4
13
|
|
5
14
|
delegate :each, to: :@transactions
|
6
15
|
|
7
|
-
|
16
|
+
# @!attribute [r] number
|
17
|
+
# return [String] block number
|
18
|
+
attr_reader :number
|
19
|
+
|
20
|
+
# @!attribute [r] transactions
|
21
|
+
# return [Array<Peatio::Transaction>]
|
22
|
+
attr_reader :transactions
|
8
23
|
|
9
24
|
def initialize(number, transactions)
|
10
25
|
@number = number
|
@@ -5,7 +5,7 @@ module Peatio #:nodoc:
|
|
5
5
|
#
|
6
6
|
# Subclass and override abstract methods to implement
|
7
7
|
# a peatio plugable blockchain.
|
8
|
-
#
|
8
|
+
# Then you need to register your blockchain implementation.
|
9
9
|
#
|
10
10
|
# @see Bitcoin::Blockchain Bitcoin as example of Abstract imlementation
|
11
11
|
# (inside peatio source https://github.com/rubykube/peatio).
|
@@ -100,6 +100,10 @@ module Peatio #:nodoc:
|
|
100
100
|
# Custom keys could be added by defining them in Currency #options.
|
101
101
|
#
|
102
102
|
# @return [Hash] merged settings.
|
103
|
+
#
|
104
|
+
# @note Be careful with your blockchain state after configure.
|
105
|
+
# Clean everything what could be related to other blockchain configuration.
|
106
|
+
# E.g. client state.
|
103
107
|
def configure(settings = {})
|
104
108
|
abstract_method
|
105
109
|
end
|
data/lib/peatio/transaction.rb
CHANGED
@@ -1,18 +1,74 @@
|
|
1
1
|
require 'active_support/concern'
|
2
2
|
require 'active_model'
|
3
3
|
|
4
|
-
module Peatio
|
4
|
+
module Peatio #:nodoc:
|
5
|
+
|
6
|
+
# This class represents blockchain transaction.
|
7
|
+
#
|
8
|
+
# Using the instant of this class the peatio application will send/recieve
|
9
|
+
# income/outcome transactions from a peatio pluggable blockchain.
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
#
|
13
|
+
# Peatio::Transaction.new(
|
14
|
+
# {
|
15
|
+
# hash: '0x5d0ef9697a2f3ea561c9fbefb48e380a4cf3d26ad2be253177c472fdd0e8b486',
|
16
|
+
# txout: 1,
|
17
|
+
# to_address: '0x9af4f143cd5ecfba0fcdd863c5ef52d5ccb4f3e5',
|
18
|
+
# amount: 0.01,
|
19
|
+
# block_number: 7732274,
|
20
|
+
# currency_id: 'eth',
|
21
|
+
# status: 'success'
|
22
|
+
# }
|
23
|
+
# )
|
24
|
+
#
|
25
|
+
# @author
|
26
|
+
# Maksym Naichuk <naichuk.maks@gmail.com> (https://github.com/mnaichuk)
|
5
27
|
class Transaction
|
6
28
|
include ActiveModel::Model
|
7
29
|
|
8
|
-
|
30
|
+
# List of statuses supported by peatio.
|
31
|
+
#
|
32
|
+
# @note Statuses list:
|
33
|
+
#
|
34
|
+
# pending - the transaction is unconfirmed in the blockchain.
|
35
|
+
#
|
36
|
+
# success - the transaction is a successfull,
|
37
|
+
# the transaction amount has been successfully transferred
|
38
|
+
#
|
39
|
+
# failed - the transaction is failed in the blockchain.
|
40
|
+
|
41
|
+
STATUSES = %i[success pending failed].freeze
|
42
|
+
|
43
|
+
# @!attribute [rw] hash
|
44
|
+
# return [String] transaction hash
|
45
|
+
attr_accessor :hash
|
46
|
+
|
47
|
+
# @!attribute [rw] txout
|
48
|
+
# return [Integer] transaction number in send-to-many request
|
49
|
+
attr_accessor :txout
|
50
|
+
|
51
|
+
# @!attribute [rw] to_address
|
52
|
+
# return [String] transaction recepient address
|
53
|
+
attr_accessor :to_address
|
54
|
+
|
55
|
+
# @!attribute [rw] amount
|
56
|
+
# return [Decimal] amount of the transaction
|
57
|
+
attr_accessor :amount
|
58
|
+
|
59
|
+
# @!attribute [rw] block_number
|
60
|
+
# return [Integer] transaction block number
|
61
|
+
attr_accessor :block_number
|
9
62
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
:block_number,
|
14
|
-
:currency_id
|
63
|
+
# @!attribute [rw] currency_id
|
64
|
+
# return [String] transaction currency id
|
65
|
+
attr_accessor :currency_id
|
15
66
|
|
67
|
+
# @!attribute [w] status
|
68
|
+
#
|
69
|
+
# @see Peatio::Transaction::STATUSES for list of statuses by peatio
|
70
|
+
#
|
71
|
+
# return [String] transaction status
|
16
72
|
attr_writer :status
|
17
73
|
|
18
74
|
validates :hash, :txout,
|
@@ -31,9 +87,16 @@ module Peatio
|
|
31
87
|
|
32
88
|
validates :status, inclusion: { in: STATUSES }
|
33
89
|
|
34
|
-
#
|
90
|
+
# Status for specific transaction.
|
91
|
+
#
|
92
|
+
# @!method status
|
93
|
+
#
|
94
|
+
# @example
|
95
|
+
#
|
96
|
+
# status.failed? # true if transaction status 'failed'
|
97
|
+
# status.success? # true if transaction status 'success'
|
35
98
|
def status
|
36
|
-
@status
|
99
|
+
@status&.inquiry
|
37
100
|
end
|
38
101
|
end
|
39
102
|
end
|
data/lib/peatio/version.rb
CHANGED
@@ -72,6 +72,10 @@ module Peatio
|
|
72
72
|
# Custom keys could be added by defining them in Currency #options.
|
73
73
|
#
|
74
74
|
# @return [Hash] merged settings.
|
75
|
+
#
|
76
|
+
# @note Be careful with your wallet state after configure.
|
77
|
+
# Clean everything what could be related to other wallet configuration.
|
78
|
+
# E.g. client state.
|
75
79
|
def configure(settings = {})
|
76
80
|
abstract_method
|
77
81
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peatio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Louis B.
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-05-
|
12
|
+
date: 2019-05-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|