Skip to content

Commit

Permalink
Latest fixes and new coins
Browse files Browse the repository at this point in the history
  • Loading branch information
demuskov committed Apr 7, 2018
1 parent 6d1e24b commit 34e11a7
Show file tree
Hide file tree
Showing 25 changed files with 3,084 additions and 275 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ gem 'phonelib', '~> 0.3.5'
gem 'twilio-ruby', '~> 3.11'
gem 'unread', github: 'gravio-net/unread'
gem 'carrierwave', '~> 0.10.0'
gem 'simple_captcha2', github: 'gravio-net/simple-captcha', branch: '0.2.2.1'
gem 'simple_captcha', github: 'gravio-net/simple-captcha', branch: '0.2.2.1'
gem 'rest-client', '~> 1.6.8'

group :development, :test do
Expand Down
12 changes: 9 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ GIT
mina (~> 0.3.0)
rest-client (~> 1.6.7)

GIT
remote: git://github.com/gravio-net/simple-captcha.git
revision: 6bbc83d9a0f91541f4090798a606db51b0dec71c
branch: 0.2.2.1
specs:
simple_captcha (0.2.2)
rails (>= 3.1, < 4.1)

GIT
remote: git://github.com/gravio-net/unread.git
revision: b8fa0502e9558c93388a104bcbe20376cf43027d
Expand Down Expand Up @@ -370,8 +378,6 @@ GEM
shoulda-matchers (2.5.0)
activesupport (>= 3.0.0)
signature (0.1.7)
simple_captcha2 (0.2.2)
rails (>= 3.1, < 4.1)
simple_form (3.1.0)
actionpack (~> 4.0)
activemodel (~> 4.0)
Expand Down Expand Up @@ -504,7 +510,7 @@ DEPENDENCIES
sass-rails
selenium-webdriver
shoulda-matchers
simple_captcha2
simple_captcha!
simple_form (~> 3.1.0)
slim-rails
test-unit
Expand Down
21 changes: 21 additions & 0 deletions app/assets/javascripts/funds/models/withdraw.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,27 @@ class Withdraw extends PeatioModel.Model
when 'lunex' then 'lunexcoins'
when 'pruf' then 'prufuscoins'
when 'want' then 'wantcoins'
when 'mmo' then 'mmocoins'
when 'cbt' then 'carebitcoins'
when 'xt3' then 'xt3chcoins'
when 'btcf' then 'btcfcoins'
when 'zcr' then 'zcorecoins'
when 'slrc' then 'solariumcoins'
when 'aevo' then 'aevocoins'
when 'ppx' then 'platopaycoins'
when 'yoba' then 'yobacoins'
when 'nbx' then 'nibexcoins'
when 'elli' then 'elliotcoins'
when 'kgx' then 'kingstoncoins'
when 'akn' then 'akencoins'
when 'aka' then 'akromacoins'
when 'rvn' then 'ravencoins'
when 'posq' then 'posqcoins'
when 'radius' then 'radiuscoins'
when 'dsc' then 'discountcoins'
when 'varius' then 'variuscoins'
when 'cyr' then 'cyphercoins'
when 'bbrc' then 'blooddonationcoins'
#currency

window.Withdraw = Withdraw
23 changes: 23 additions & 0 deletions app/assets/javascripts/locales/en.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,29 @@





























Expand Down
7 changes: 7 additions & 0 deletions app/assets/stylesheets/market.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,13 @@ left_side_tabs_wrapper {
&.kgx { tr.quote-kgx { display: block; } }
&.akn { tr.quote-akn { display: block; } }
&.aka { tr.quote-aka { display: block; } }
&.rvn { tr.quote-rvn { display: block; } }
&.posq { tr.quote-posq { display: block; } }
&.radius { tr.quote-radius { display: block; } }
&.dsc { tr.quote-dsc { display: block; } }
&.varius { tr.quote-varius { display: block; } }
&.cyr { tr.quote-cyr { display: block; } }
&.bbrc { tr.quote-bbrc { display: block; } }
/*markets*/
}
}
Expand Down
42 changes: 42 additions & 0 deletions app/controllers/private/assets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,27 @@ def index
@lunex_proof = Proof.current :lunex
@pruf_proof = Proof.current :pruf
@want_proof = Proof.current :want
@mmo_proof = Proof.current :mmo
@cbt_proof = Proof.current :cbt
@xt3_proof = Proof.current :xt3
@btcf_proof = Proof.current :btcf
@zcr_proof = Proof.current :zcr
@slrc_proof = Proof.current :slrc
@aevo_proof = Proof.current :aevo
@ppx_proof = Proof.current :ppx
@yoba_proof = Proof.current :yoba
@nbx_proof = Proof.current :nbx
@elli_proof = Proof.current :elli
@kgx_proof = Proof.current :kgx
@akn_proof = Proof.current :akn
@aka_proof = Proof.current :aka
@rvn_proof = Proof.current :rvn
@posq_proof = Proof.current :posq
@radius_proof = Proof.current :radius
@dsc_proof = Proof.current :dsc
@varius_proof = Proof.current :varius
@cyr_proof = Proof.current :cyr
@bbrc_proof = Proof.current :bbrc
#proof

if current_user
Expand Down Expand Up @@ -228,6 +249,27 @@ def index
@lunex_account = current_user.accounts.with_currency(:lunex).first
@pruf_account = current_user.accounts.with_currency(:pruf).first
@want_account = current_user.accounts.with_currency(:want).first
@mmo_account = current_user.accounts.with_currency(:mmo).first
@cbt_account = current_user.accounts.with_currency(:cbt).first
@xt3_account = current_user.accounts.with_currency(:xt3).first
@btcf_account = current_user.accounts.with_currency(:btcf).first
@zcr_account = current_user.accounts.with_currency(:zcr).first
@slrc_account = current_user.accounts.with_currency(:slrc).first
@aevo_account = current_user.accounts.with_currency(:aevo).first
@ppx_account = current_user.accounts.with_currency(:ppx).first
@yoba_account = current_user.accounts.with_currency(:yoba).first
@nbx_account = current_user.accounts.with_currency(:nbx).first
@elli_account = current_user.accounts.with_currency(:elli).first
@kgx_account = current_user.accounts.with_currency(:kgx).first
@akn_account = current_user.accounts.with_currency(:akn).first
@aka_account = current_user.accounts.with_currency(:aka).first
@rvn_account = current_user.accounts.with_currency(:rvn).first
@posq_account = current_user.accounts.with_currency(:posq).first
@radius_account = current_user.accounts.with_currency(:radius).first
@dsc_account = current_user.accounts.with_currency(:dsc).first
@varius_account = current_user.accounts.with_currency(:varius).first
@cyr_account = current_user.accounts.with_currency(:cyr).first
@bbrc_account = current_user.accounts.with_currency(:bbrc).first
#account
end
end
Expand Down
6 changes: 6 additions & 0 deletions app/controllers/webhooks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,11 @@ def mix
render :json => { :status => "queued" }
end
end
def aka
if params[:type] == "transaction" && params[:hash].present?
AMQPQueue.enqueue(:deposit_coin, txid: params[:hash], channel_key: "akromacoin")
render :json => { :status => "queued" }
end
end
end

42 changes: 42 additions & 0 deletions app/models/admin/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,27 @@ def initialize(user)
can :manage, ::Deposits::Lunexcoin
can :manage, ::Deposits::Prufuscoin
can :manage, ::Deposits::Wantcoin
can :manage, ::Deposits::Mmocoin
can :manage, ::Deposits::Carebitcoin
can :manage, ::Deposits::Xt3chcoin
can :manage, ::Deposits::Btcfcoin
can :manage, ::Deposits::Zcorecoin
can :manage, ::Deposits::Solariumcoin
can :manage, ::Deposits::Aevocoin
can :manage, ::Deposits::Platopaycoin
can :manage, ::Deposits::Yobacoin
can :manage, ::Deposits::Nibexcoin
can :manage, ::Deposits::Elliotcoin
can :manage, ::Deposits::Kingstoncoin
can :manage, ::Deposits::Akencoin
can :manage, ::Deposits::Akromacoin
can :manage, ::Deposits::Ravencoin
can :manage, ::Deposits::Posqcoin
can :manage, ::Deposits::Radiuscoin
can :manage, ::Deposits::Discountcoin
can :manage, ::Deposits::Variuscoin
can :manage, ::Deposits::Cyphercoin
can :manage, ::Deposits::Blooddonationcoin
#deposit

can :menu, Withdraw
Expand Down Expand Up @@ -243,6 +264,27 @@ def initialize(user)
can :manage, ::Withdraws::Lunexcoin
can :manage, ::Withdraws::Prufuscoin
can :manage, ::Withdraws::Wantcoin
can :manage, ::Withdraws::Mmocoin
can :manage, ::Withdraws::Carebitcoin
can :manage, ::Withdraws::Xt3chcoin
can :manage, ::Withdraws::Btcfcoin
can :manage, ::Withdraws::Zcorecoin
can :manage, ::Withdraws::Solariumcoin
can :manage, ::Withdraws::Aevocoin
can :manage, ::Withdraws::Platopaycoin
can :manage, ::Withdraws::Yobacoin
can :manage, ::Withdraws::Nibexcoin
can :manage, ::Withdraws::Elliotcoin
can :manage, ::Withdraws::Kingstoncoin
can :manage, ::Withdraws::Akencoin
can :manage, ::Withdraws::Akromacoin
can :manage, ::Withdraws::Ravencoin
can :manage, ::Withdraws::Posqcoin
can :manage, ::Withdraws::Radiuscoin
can :manage, ::Withdraws::Discountcoin
can :manage, ::Withdraws::Variuscoin
can :manage, ::Withdraws::Cyphercoin
can :manage, ::Withdraws::Blooddonationcoin
#withdraw

end
Expand Down
18 changes: 13 additions & 5 deletions app/models/deposit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,21 @@ def aggregate_funds
# we have aggregate scheme with single address
# so we need to thansfer incoming funds to the internal address
if channel.currency_obj.base_account != nil
if channel.currency_obj.code == "eth" || channel.currency_obj.code == "mix"
if channel.currency_obj.proto == 'ETH'
# collect all deposits on the single account
payment_tx = PaymentTransaction::Normal.where(txid: txid).first
# unlock account
CoinRPC[channel.currency_obj.code].personal_unlockAccount(payment_tx.address, "", "0x30")
# get nonce
local_nonce = CoinRPC[channel.currency_obj.code].parity_nextNonce(payment_tx.address).to_i(16)
local_nonce = 0
if channel.currency_obj.code == "aka"
# unlock account
CoinRPC[channel.currency_obj.code].personal_unlockAccount(payment_tx.address, "", 0)
# get nonce
local_nonce = CoinRPC[channel.currency_obj.code].eth_getTransactionCount(payment_tx.address, "latest").to_i(16)
else
# unlock account
CoinRPC[channel.currency_obj.code].personal_unlockAccount(payment_tx.address, "", "0x30")
# get nonce
local_nonce = CoinRPC[channel.currency_obj.code].parity_nextNonce(payment_tx.address).to_i(16)
end

# calc amount
gas_limit = channel.currency_obj.gas_limit
Expand Down
5 changes: 4 additions & 1 deletion app/models/payment_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ def max_confirm?
end

def refresh_confirmations
if deposit.currency == 'eth' || deposit.currency == 'mix'
if deposit.currency == 'eth' || deposit.currency == 'mix' || deposit.currency == 'aka'
raw = CoinRPC[deposit.currency].eth_getTransactionByHash(txid)
if raw == nil
raw = CoinRPC[deposit.currency].eth_getTransaction(txid)
end
self.confirmations = CoinRPC[deposit.currency].eth_blockNumber.to_i(16) - raw[:blockNumber].to_i(16)
else
raw = CoinRPC[deposit.currency].gettransaction(txid)
Expand Down
11 changes: 8 additions & 3 deletions app/models/worker/deposit_coin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def process(payload, metadata, delivery_info)
txid = payload[:txid]

channel = DepositChannel.find_by_key(channel_key)
if channel.currency_obj.code == 'eth' || channel.currency_obj.code == 'mix'
if channel.currency_obj.proto == 'ETH'
raw = get_raw_eth channel, txid
raw.symbolize_keys!
deposit_eth!(channel, txid, 1, raw)
Expand Down Expand Up @@ -74,7 +74,8 @@ def deposit!(channel, txid, txout, raw, detail)
amount: detail[:amount].to_s.to_d,
confirmations: raw[:confirmations],
receive_at: Time.at(raw[:time]).to_datetime,
currency: channel.currency
currency: channel.currency,
aasm_state: "confirmed"
request = ListingRequest.where(address: detail[:address]).first
if request.amount
request.amount = request.amount + detail[:amount].to_f
Expand Down Expand Up @@ -124,7 +125,11 @@ def get_raw(channel, txid)
end

def get_raw_eth(channel, txid)
CoinRPC[channel.currency_obj.code].eth_getTransactionByHash(txid)
raw = CoinRPC[channel.currency_obj.code].eth_getTransactionByHash(txid)
if raw == nil
raw = CoinRPC[channel.currency_obj.code].eth_getTransaction(txid)
end
return raw
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/worker/deposit_coin_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def process(payload, metadata, delivery_info)
member = Member.where('id = ?', account.member_id).first

currency = payload[:currency]
if currency == 'eth' || currency == 'mix'
if currency == 'eth' || currency == 'mix' || currency == 'aka'
address = CoinRPC[currency].personal_newAccount("")
else
address = CoinRPC[currency].getnewaddress("payment", member.email + member.id.to_s)
Expand Down
16 changes: 12 additions & 4 deletions app/models/worker/withdraw_coin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,22 @@ def process(payload, metadata, delivery_info)

begin

if withdraw.currency == 'eth' || withdraw.currency == 'mix'
if withdraw.currency == 'eth' || withdraw.currency == 'mix' || withdraw.currency == 'aka'
balance = open("#{withdraw.channel.currency_obj.rest}/cgi-bin/total.cgi").read.rstrip.to_f
raise Account::BalanceError, 'Insufficient coins' if balance < withdraw.sum

fee = [withdraw.fee.to_f || withdraw.channel.try(:fee) || 0.0005, 0.1].min
CoinRPC[withdraw.currency].personal_unlockAccount(withdraw.channel.currency_obj.base_account, "", "0x30")
# get nonce
local_nonce = CoinRPC[withdraw.currency].parity_nextNonce(withdraw.channel.currency_obj.base_account).to_i(16)

local_nonce = 0
if withdraw.channel.currency_obj.code == "aka"
CoinRPC[withdraw.currency].personal_unlockAccount(withdraw.channel.currency_obj.base_account, "", 0)
# get nonce
local_nonce = CoinRPC[withdraw.currency].eth_getTransactionCount(withdraw.channel.currency_obj.base_account, "latest").to_i(16)
else
CoinRPC[withdraw.currency].personal_unlockAccount(withdraw.channel.currency_obj.base_account, "", "0x30")
# get nonce
local_nonce = CoinRPC[withdraw.currency].parity_nextNonce(withdraw.channel.currency_obj.base_account).to_i(16)
end

# calc amount
gas_limit = withdraw.channel.currency_obj.gas_limit
Expand Down
Loading

0 comments on commit 34e11a7

Please sign in to comment.