Skip to content

Commit ee27a5b

Browse files
Danylo PatsoraMaksym Naichuk
authored andcommitted
Feature: Add fee attribute to Transaction
1 parent a94e3dd commit ee27a5b

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

lib/peatio/transaction.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module Peatio #:nodoc:
1818
# txout: 1,
1919
# to_address: '0x9af4f143cd5ecfba0fcdd863c5ef52d5ccb4f3e5',
2020
# amount: 0.01,
21+
# fee: 0.0004,
2122
# block_number: 7732274,
2223
# currency_id: 'eth',
2324
# status: 'success'
@@ -67,6 +68,10 @@ class Transaction
6768
# return [Decimal] amount of the transaction
6869
attr_accessor :amount
6970

71+
# @!attribute [rw] fee
72+
# return [Decimal] fee of the transaction
73+
attr_accessor :fee
74+
7075
# @!attribute [rw] block_number
7176
# return [Integer] transaction block number
7277
attr_accessor :block_number
@@ -98,6 +103,9 @@ class Transaction
98103
validates :amount,
99104
numericality: { greater_than_or_equal_to: 0 }
100105

106+
validates :fee,
107+
numericality: { greater_than_or_equal_to: 0 }, allow_blank: true
108+
101109
validates :status, inclusion: { in: STATUSES }
102110

103111
def initialize(attributes={})

lib/peatio/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Peatio
2-
VERSION = "2.6.3"
2+
VERSION = "2.6.4"
33
end

spec/peatio/transaction_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from_addresses: ['from_address'],
99
to_address: 'to_address',
1010
amount: 10,
11+
fee: 0.005,
1112
block_number: 1042,
1213
currency_id: 'btc',
1314
status: 'pending' }
@@ -75,6 +76,11 @@
7576
expect(Peatio::Transaction.new(transaction_attrs).valid?).to be_falsey
7677
end
7778

79+
it 'validates fee to be number' do
80+
transaction_attrs[:fee] = 'abc'
81+
expect(Peatio::Transaction.new(transaction_attrs).valid?).to be_falsey
82+
end
83+
7884
it 'validates block_number to be number' do
7985
transaction_attrs[:block_number] = 'abc'
8086
expect(Peatio::Transaction.new(transaction_attrs).valid?).to be_falsey
@@ -100,6 +106,7 @@
100106
txout: 2,
101107
to_address: 'to_address',
102108
amount: 10,
109+
fee: 0.08,
103110
block_number: 1042,
104111
currency_id: 'btc',
105112
status: 'pending' }
@@ -122,6 +129,7 @@
122129
txout: 2,
123130
to_address: 'to_address',
124131
amount: 10,
132+
fee: 0.08,
125133
block_number: 1042,
126134
currency_id: 'btc',
127135
status: 'pending' }

0 commit comments

Comments
 (0)