Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
bc672b7
Add guard to auto test changes
dapi Feb 18, 2021
2eacc02
Enhancement: Use system timezone if no TIMEZONE env
dapi Mar 5, 2021
9801569
Fix: uninitialized constant OWHDWallet
dapi Mar 5, 2021
52d4975
Fix: update wallet without blockchain api
dapi Mar 10, 2021
87f6e9f
Add bitzlato gem and update jwt to 2.3.0.dev
dapi Mar 11, 2021
5145b05
Add bitzlato wallet to initializers
dapi Mar 11, 2021
26054ed
Add WalletService#create_deposit_intention!
dapi Mar 11, 2021
77bd2c7
Add /api/v2/account/deposits/intention
dapi Mar 11, 2021
3f39ace
Add Deposit#data
dapi Mar 11, 2021
8d4b473
Add poll_intenetion to Bitzlato wallet
dapi Mar 12, 2021
4c38802
Add Peatio::Bitzlato::Wallet#poll_intentions
dapi Mar 15, 2021
a942ce6
Add WalletService#poll_intentions
dapi Mar 15, 2021
448505c
Add deposits polling job
dapi Mar 15, 2021
fe7e0cc
Add transfer_links presentation for deposit
dapi Mar 16, 2021
4013d26
Add enable_intention to deposits API
dapi Mar 17, 2021
53dbe7d
Add unique index for intention_id
dapi Mar 17, 2021
b38d771
Save remote_username when polling intentions
dapi Mar 17, 2021
69620cd
Remove add_remote_usernames_to_accounts migration
dapi Mar 18, 2021
50a5e01
Save beneficiary where deposit accepted
dapi Mar 18, 2021
f4adab1
bump bitzlato plugin version
sixandfo Mar 18, 2021
ff76a2d
Bump bitzlato gem to 0.1.3
dapi Mar 18, 2021
91d94b1
Fix: remove focus from deposits_spec
dapi Mar 18, 2021
e5874c6
Use ENV to configure bitzlato client
dapi Mar 18, 2021
13ec10e
Bump bitzlato 0.1.4
dapi Mar 18, 2021
355828a
Add Bitzlato::Wallet.create_transaction!
dapi Mar 18, 2021
506343a
Fix specs for Peatio::Bitzlato
dapi Mar 18, 2021
cc9ca00
Fix specs
dapi Mar 18, 2021
68b5a32
Save links on withdraw by voucher
dapi Mar 18, 2021
0156345
Add specific ENV to specs
dapi Mar 18, 2021
ef7e569
Add withdrawal support and specs
dapi Mar 18, 2021
c07ed53
Poll withdraws
dapi Mar 18, 2021
a6e9c89
Minor fix in deposits polling
dapi Mar 22, 2021
bdf740c
Rename poll_intentions to poll_deposits
dapi Mar 22, 2021
daaaab1
Bump bitzlato 0.1.6
dapi Mar 22, 2021
ae5a9e2
Add payments polling to Bitzlato::Wallet
dapi Mar 22, 2021
216f26f
Fix minor in WalletService#build_withdrawal!
dapi Mar 22, 2021
8c97ee7
Add Bitzlato::Wallet#create_payment
dapi Mar 22, 2021
eabaf08
Integration fixes
dapi Mar 22, 2021
5bf0f25
Save deposit username as beneficiary
dapi Mar 23, 2021
388c980
Minor improvement beneficary saving from deposits
dapi Mar 23, 2021
494bb35
Confirm withdraw if payment successful
dapi Mar 24, 2021
36aa384
Fix: Use input currency for deposit intention
dapi Mar 29, 2021
4c811e4
Fix: poll deposits and withdraws for every currency in the wallet
dapi Mar 29, 2021
347694f
Improve: mimemagic to 0.3.10
dapi Mar 29, 2021
bb19c7e
Improve: currencies seeding updates existed currency
dapi Mar 29, 2021
3a55cf8
fix specs
dapi Mar 31, 2021
c1141bf
Improvement: reseeding wallets updates its data
dapi Apr 1, 2021
41601de
Improvement: wallet validation doesn't raise for non blockchain wallets
dapi Apr 1, 2021
085a26c
Temporary fix Bitzlato::Wallet
dapi Apr 1, 2021
24b013b
Improvement: Detailed error on order validation
dapi Apr 13, 2021
89577f4
Improvement: Direct withdraw confirmation
dapi Apr 13, 2021
faa3be6
Improvement: Save payment ID in bitzlato wallet
dapi Apr 14, 2021
fd786e2
Improve: Withdraw polling
dapi Apr 14, 2021
5e3bedd
Update bitzlato client
dapi Apr 14, 2021
50cb076
Improvement: Change Deposit#intention_id to string
dapi Apr 16, 2021
dcf26c8
fix specs
dapi Apr 22, 2021
3b139cb
Replate report_exception_to_screen with report_exception for cron jobs
dapi Apr 29, 2021
f6a17bb
Improvement: Add error rescue in transfers polling
dapi Apr 29, 2021
6144715
Fix: seed:markets uses symbol instead of id
dapi May 27, 2021
2f64ebb
Improve: User UID as account_id for deposit comment
dapi May 31, 2021
a63a5f7
Improvement: Localize deposit comment
dapi Jun 1, 2021
213255e
Improve: Use semver2 for application versioning
dapi Jun 1, 2021
eb53680
v3.2.1
dapi Jun 1, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .semver
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
:major: 3
:minor: 2
:patch: 1
:special: ''
:metadata: ''
14 changes: 13 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ gem 'faraday_middleware', '~> 0.13.1'
gem 'faye', '~> 1.4'
gem 'eventmachine', '~> 1.2'
gem 'em-synchrony', '~> 1.0'
gem 'jwt', '~> 2.2.0'

# We use 2.3.0.dev for bitzlato client
# Fill free to update to rubygem version when it will be released
gem 'jwt', github: 'jwt/ruby-jwt'

gem 'email_validator', '~> 1.6.0'
gem 'validate_url', '~> 1.0.4'
gem 'god', '~> 0.13.7', require: false
Expand Down Expand Up @@ -71,6 +75,10 @@ group :development do
gem 'annotate', '~> 3.1.0'
gem 'ruby-prof', '~> 0.17.0', require: false
gem 'listen', '>= 3.0.5', '< 3.2'

gem 'rspec'
gem 'guard'
gem 'guard-rspec', github: 'caspark/guard-rspec' # Use from github to remove rspec < 4.0 dependencies
end

group :test do
Expand All @@ -90,3 +98,7 @@ Dir.glob File.expand_path('../Gemfile.plugin', __FILE__) do |file|
end

gem "pg", "~> 1.2"

gem "http_accept_language", "~> 2.1"

gem "semver2", "~> 3.4"
59 changes: 56 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,30 @@ GIT
rails (>= 4.1)
vault (~> 0.14)

GIT
remote: https://github.com/caspark/guard-rspec
revision: 407ef8c62f3abad575bb66d53c02ba062a5ee8af
specs:
guard-rspec (4.7.3)
guard (~> 2.1)
guard-compat (~> 1.1)

GIT
remote: https://github.com/finfex/bitzlato
revision: 53b9c814a0be82f7d39c36abc4b9f37770bff405
branch: main
specs:
bitzlato (0.1.8)
faraday (>= 0.17)
json (~> 2.0)
jwt (~> 2.3.0.dev)

GIT
remote: https://github.com/jwt/ruby-jwt
revision: 2cea14fdae439773fafc59640178e5cf7a0af8a4
specs:
jwt (2.3.0.dev)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -164,6 +188,7 @@ GEM
ffi (1.15.0)
figaro (1.1.1)
thor (~> 0.14)
formatador (0.2.5)
globalid (0.4.2)
activesupport (>= 4.2.0)
god (0.13.7)
Expand All @@ -189,9 +214,20 @@ GEM
rack
grape_on_rails_routes (0.3.2)
rails (>= 3.1.1)
guard (2.16.2)
formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
lumberjack (>= 1.0.12, < 2.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-compat (1.2.1)
hashdiff (1.0.1)
hashie (3.6.0)
hiredis (0.6.3)
http_accept_language (2.1.1)
http_parser.rb (0.6.0)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
Expand All @@ -206,7 +242,7 @@ GEM
faraday_middleware (~> 0.13.1)
faye (~> 1.2)
peatio (>= 2.4.2)
jwt (2.2.2)
json (2.5.1)
jwt-multisig (1.0.5)
activesupport (>= 4.0)
jwt (~> 2.2)
Expand All @@ -232,6 +268,7 @@ GEM
loofah (2.9.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
lumberjack (1.2.8)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
Expand All @@ -254,12 +291,16 @@ GEM
mustermann-grape (1.0.1)
mustermann (>= 1.0.0)
mysql2 (0.5.3)
nenv (0.3.0)
net-http-persistent (3.0.1)
connection_pool (~> 2.2)
nio4r (2.5.7)
nokogiri (1.11.2)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
notiffany (0.1.3)
nenv (~> 0.1)
shellany (~> 0.0)
parallel (1.20.1)
parser (3.0.0.0)
ast (~> 2.4.1)
Expand Down Expand Up @@ -380,6 +421,10 @@ GEM
reline (0.2.4)
io-console (~> 0.5)
rexml (3.2.4)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.0)
rspec-support (~> 3.9.0)
rspec-expectations (3.9.0)
Expand Down Expand Up @@ -420,8 +465,10 @@ GEM
safe_yaml (1.0.5)
scout_apm (2.6.10)
parser
semver2 (3.4.2)
sentry-raven (2.9.0)
faraday (>= 0.7.6, < 1.0)
shellany (0.0.1)
sprockets (4.0.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand Down Expand Up @@ -463,6 +510,7 @@ DEPENDENCIES
annotate (~> 3.1.0)
arel-is-blank (~> 1.0.0)
better-faraday (~> 1.0.5)
bitzlato!
bootsnap (>= 1.1.0)
bullet (~> 5.9)
bump (~> 0.7)
Expand Down Expand Up @@ -490,12 +538,15 @@ DEPENDENCIES
grape-swagger-ui (~> 2.2.8)
grape_logging (~> 1.8.0)
grape_on_rails_routes (~> 0.3.2)
guard
guard-rspec!
hashie (~> 3.6.0)
hiredis (~> 0.6.0)
http_accept_language (~> 2.1)
influxdb (~> 0.7.0)
irb
irix (~> 2.6.0)
jwt (~> 2.2.0)
jwt!
jwt-multisig (~> 1.0.0)
jwt-rack (~> 0.1.0)
kaminari (~> 1.2.1)
Expand All @@ -521,12 +572,14 @@ DEPENDENCIES
ransack (~> 2.3.2)
rbtree (~> 0.4.2)
redis (~> 4.1.2)
rspec
rspec-rails (~> 3.8, >= 3.8.2)
rspec-retry (~> 0.6)
rubocop-rspec (~> 1.32)
ruby-prof (~> 0.17.0)
safe_yaml (~> 1.0.5)
scout_apm (~> 2.4)
semver2 (~> 3.4)
sentry-raven (~> 2.9.0)
timecop (~> 0.9)
validate_url (~> 1.0.4)
Expand All @@ -539,4 +592,4 @@ RUBY VERSION
ruby 2.6.6p146

BUNDLED WITH
2.1.4
2.2.15
1 change: 1 addition & 0 deletions Gemfile.plugin
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ gem 'peatio-bitcoincash', '~> 2.6.1'
gem 'peatio-ripple', '~> 2.6.1'
gem 'peatio-bitgo', '~> 2.6.6'
gem 'peatio-electrum', '~> 2.6.2'
gem 'bitzlato', github: 'finfex/bitzlato', branch: 'main'
75 changes: 75 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

## Uncomment and set this to only include directories you want to watch
# directories %w(app lib config test spec features) \
# .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}

## Note: if you are using the `directories` clause above and you are not
## watching the project directory ('.'), then you will want to move
## the Guardfile to a watched dir and symlink it back, e.g.
#
# $ mkdir config
# $ mv Guardfile config/
# $ ln -s config/Guardfile .
#
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
#
notification :tmux, display_message: true if ENV.has_key?('TMUX')

# Note: The cmd option is now required due to the increasing number of ways
# rspec may be run, below are examples of the most common uses.
# * bundler: 'bundle exec rspec'
# * bundler binstubs: 'bin/rspec'
# * spring: 'bin/rspec' (This will use spring if running and you have
# installed the spring binstubs per the docs)
# * zeus: 'zeus rspec' (requires the server to be started separately)
# * 'just' rspec: 'rspec'

guard :rspec, cmd: "bundle exec rspec" do
require "guard/rspec/dsl"
dsl = Guard::RSpec::Dsl.new(self)

# Feel free to open issues for suggestions and improvements

# RSpec files
rspec = dsl.rspec
watch(rspec.spec_helper) { rspec.spec_dir }
watch(rspec.spec_support) { rspec.spec_dir }
watch(rspec.spec_files)

# Ruby files
ruby = dsl.ruby
dsl.watch_spec_files_for(ruby.lib_files)

# Rails files
rails = dsl.rails(view_extensions: %w(erb haml slim))
dsl.watch_spec_files_for(rails.app_files)
dsl.watch_spec_files_for(rails.views)

watch(rails.controllers) do |m|
[
rspec.spec.call("routing/#{m[1]}_routing"),
rspec.spec.call("controllers/#{m[1]}_controller"),
rspec.spec.call("acceptance/#{m[1]}")
]
end

# Rails config changes
watch(rails.spec_helper) { rspec.spec_dir }
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }

# Capybara features specs
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }

# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
end

# Rake tasks
dsl.watch_spec_files_for(dsl.rake.rake_files)
end
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,3 @@ Peatio is released under the terms of the [MIT license](http://peatio.mit-licens

[Peatio](http://en.wikipedia.org/wiki/Pixiu) (Chinese: 貔貅) is a Chinese mythical hybrid creature
considered to be a very powerful protector to practitioners of Feng Shui.

33 changes: 32 additions & 1 deletion app/api/v2/account/deposits.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,40 @@ module API
module V2
module Account
class Deposits < Grape::API

before { deposits_must_be_permitted! }

desc 'Create deposit intention',
success: API::V2::Entities::Deposit
params do
requires :currency,
type: String,
values: { value: -> { Currency.visible.codes(bothcase: true) }, message: 'account.currency.doesnt_exist' },
desc: 'Currency code'
requires :amount,
type: BigDecimal,
desc: 'The deposit amount.'
end

post '/deposits/intention' do
currency = Currency.find(params[:currency])

unless currency.deposit_enabled?
error!({ errors: ['management.currency.deposit_disabled'] }, 422)
end

wallet = Wallet.deposit_wallet(currency.id)

unless wallet.present?
error!({ errors: ['account.wallet.not_found'] }, 422)
end

deposit = WalletService
.new(wallet)
.create_deposit_intention!(current_user, currency, params[:amount])

present deposit, with: API::V2::Entities::Deposit
end

desc 'Get your deposits history.',
is_array: true,
success: API::V2::Entities::Deposit
Expand Down
13 changes: 12 additions & 1 deletion app/api/v2/entities/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Account < Base

expose(
:deposit_address,
if: ->(account, _options) { account.currency.coin? },
if: ->(account, _options) { account.currency.coin? && !Wallet.deposit_wallet(account.currency_id)&.settings&.fetch('enable_intention', false) },
using: API::V2::Entities::PaymentAddress,
documentation: {
desc: 'User deposit address',
Expand All @@ -44,6 +44,17 @@ class Account < Base
wallet = Wallet.deposit_wallet(account.currency_id)
::PaymentAddress.find_by(wallet: wallet, member: options[:current_user], remote: false)
end

expose(
:enable_intention,
if: ->(account, _options) { Wallet.deposit_wallet(account.currency_id)&.settings&.fetch('enable_intention', false) },
documentation: {
desc: 'Show intention form instead of payment address generation',
type: JSON
}
) do |account, options|
true
end
end
end
end
Expand Down
14 changes: 14 additions & 0 deletions app/api/v2/entities/deposit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ class Deposit < Base
}
)

expose(
:transfer_links,
documentation: {
type: JSON,
desc: 'Links to p2p page to make deposit transfer',
example: -> {
[
{ title: 'telegram', url: 'https://t.me/BTC_STAGE_BOT?start=b_0f8c3db61f223ea9df072fd37e0b6315' },
{ title: 'web', url: 'https://s-www.lgk.one/p2p/?start=b_0f8c3db61f223ea9df072fd37e0b6315' }
]
}
},
if: ->(deposit) { deposit.transfer_links.present? }
)

expose(
:created_at,
Expand Down
Loading