Add wallet page
With setup code to connect Blue Wallet to Kosmos account wallets
This commit is contained in:
parent
f94227f9f3
commit
0a1052fcb7
3
Gemfile
3
Gemfile
@ -33,6 +33,9 @@ gem 'devise'
|
|||||||
gem 'devise_ldap_authenticatable'
|
gem 'devise_ldap_authenticatable'
|
||||||
gem 'net-ldap'
|
gem 'net-ldap'
|
||||||
|
|
||||||
|
# Utilities
|
||||||
|
gem "rqrcode", "~> 2.0"
|
||||||
|
|
||||||
# HTTP requests
|
# HTTP requests
|
||||||
gem 'faraday'
|
gem 'faraday'
|
||||||
|
|
||||||
|
@ -73,6 +73,7 @@ GEM
|
|||||||
rack-test (>= 0.6.3)
|
rack-test (>= 0.6.3)
|
||||||
regexp_parser (>= 1.5, < 3.0)
|
regexp_parser (>= 1.5, < 3.0)
|
||||||
xpath (~> 3.2)
|
xpath (~> 3.2)
|
||||||
|
chunky_png (1.4.0)
|
||||||
concurrent-ruby (1.1.9)
|
concurrent-ruby (1.1.9)
|
||||||
connection_pool (2.2.5)
|
connection_pool (2.2.5)
|
||||||
crack (0.4.5)
|
crack (0.4.5)
|
||||||
@ -213,6 +214,10 @@ GEM
|
|||||||
actionpack (>= 5.0)
|
actionpack (>= 5.0)
|
||||||
railties (>= 5.0)
|
railties (>= 5.0)
|
||||||
rexml (3.2.5)
|
rexml (3.2.5)
|
||||||
|
rqrcode (2.1.0)
|
||||||
|
chunky_png (~> 1.0)
|
||||||
|
rqrcode_core (~> 1.0)
|
||||||
|
rqrcode_core (1.2.0)
|
||||||
rspec-core (3.10.1)
|
rspec-core (3.10.1)
|
||||||
rspec-support (~> 3.10.0)
|
rspec-support (~> 3.10.0)
|
||||||
rspec-expectations (3.10.1)
|
rspec-expectations (3.10.1)
|
||||||
@ -321,6 +326,7 @@ DEPENDENCIES
|
|||||||
pg (~> 1.2.3)
|
pg (~> 1.2.3)
|
||||||
puma (~> 4.1)
|
puma (~> 4.1)
|
||||||
rails (~> 6.0.3, >= 6.0.3.4)
|
rails (~> 6.0.3, >= 6.0.3.4)
|
||||||
|
rqrcode (~> 2.0)
|
||||||
rspec-rails
|
rspec-rails
|
||||||
sass-rails (>= 6)
|
sass-rails (>= 6)
|
||||||
sidekiq
|
sidekiq
|
||||||
|
21
app/controllers/wallet_controller.rb
Normal file
21
app/controllers/wallet_controller.rb
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
require "rqrcode"
|
||||||
|
|
||||||
|
class WalletController < ApplicationController
|
||||||
|
before_action :require_user_signed_in
|
||||||
|
|
||||||
|
def index
|
||||||
|
@current_section = :wallet
|
||||||
|
|
||||||
|
@wallet_url = "lndhub://#{current_user.ln_login}:#{current_user.ln_password}@https://lndhub.kosmos.org"
|
||||||
|
|
||||||
|
qrcode = RQRCode::QRCode.new(@wallet_url)
|
||||||
|
@svg = qrcode.as_svg(
|
||||||
|
color: "000",
|
||||||
|
shape_rendering: "crispEdges",
|
||||||
|
module_size: 6,
|
||||||
|
standalone: true,
|
||||||
|
use_path: true
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
2
app/helpers/wallet_helper.rb
Normal file
2
app/helpers/wallet_helper.rb
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
module WalletHelper
|
||||||
|
end
|
@ -13,6 +13,10 @@
|
|||||||
<%= link_to "Donations", donations_path,
|
<%= link_to "Donations", donations_path,
|
||||||
class: @current_section == :contributions ? "active" : nil %>
|
class: @current_section == :contributions ? "active" : nil %>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<%= link_to "Wallet", wallet_path,
|
||||||
|
class: @current_section == :wallet ? "active" : nil %>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to "Security", security_path,
|
<%= link_to "Security", security_path,
|
||||||
class: @current_section == :security ? "active" : nil %>
|
class: @current_section == :security ? "active" : nil %>
|
||||||
|
42
app/views/wallet/index.html.erb
Normal file
42
app/views/wallet/index.html.erb
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<section>
|
||||||
|
<h2>Wallet</h2>
|
||||||
|
<p>
|
||||||
|
Send and receive BTC via the Lightning Network.
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h3>
|
||||||
|
Blue Wallet
|
||||||
|
</h3>
|
||||||
|
<p>
|
||||||
|
You can connect Blue Wallet (Android or iOS) to your Kosmos bitcoin wallet.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<a id="show-setup-code" class="ks-text-link cursor-pointer">Show setup code</a>
|
||||||
|
<a id="hide-setup-code" class="ks-text-link cursor-pointer" style="display: none;">Hide setup code</a>
|
||||||
|
</p>
|
||||||
|
<p id="setup-code" style="display: none;">
|
||||||
|
<%= raw @svg %>
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
const linkShow = document.querySelector('#show-setup-code');
|
||||||
|
const linkHide = document.querySelector('#hide-setup-code');
|
||||||
|
const setupCode = document.querySelector('#setup-code');
|
||||||
|
linkShow.addEventListener('click', function(ev) {
|
||||||
|
ev.preventDefault();
|
||||||
|
setupCode.style.display = 'block';
|
||||||
|
linkShow.style.display = 'none';
|
||||||
|
linkHide.style.display = 'block';
|
||||||
|
window.scrollTo(0, document.body.scrollHeight);
|
||||||
|
});
|
||||||
|
linkHide.addEventListener('click', function(ev) {
|
||||||
|
ev.preventDefault();
|
||||||
|
const el = document.querySelector('#setup-code');
|
||||||
|
setupCode.style.display = 'none';
|
||||||
|
linkShow.style.display = 'block';
|
||||||
|
linkHide.style.display = 'none';
|
||||||
|
});
|
||||||
|
</script>
|
@ -1,7 +1,6 @@
|
|||||||
require 'sidekiq/web'
|
require 'sidekiq/web'
|
||||||
|
|
||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
resources :donations
|
|
||||||
devise_for :users
|
devise_for :users
|
||||||
|
|
||||||
get 'welcome', to: 'welcome#index'
|
get 'welcome', to: 'welcome#index'
|
||||||
@ -18,6 +17,10 @@ Rails.application.routes.draw do
|
|||||||
|
|
||||||
resources :invitations, only: ['index', 'show', 'create', 'destroy']
|
resources :invitations, only: ['index', 'show', 'create', 'destroy']
|
||||||
|
|
||||||
|
resources :donations
|
||||||
|
|
||||||
|
get 'wallet', to: 'wallet#index'
|
||||||
|
|
||||||
namespace :admin do
|
namespace :admin do
|
||||||
root to: 'dashboard#index'
|
root to: 'dashboard#index'
|
||||||
get 'invitations', to: 'invitations#index'
|
get 'invitations', to: 'invitations#index'
|
||||||
|
15
spec/helpers/wallet_helper_spec.rb
Normal file
15
spec/helpers/wallet_helper_spec.rb
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
# Specs in this file have access to a helper object that includes
|
||||||
|
# the WalletHelper. For example:
|
||||||
|
#
|
||||||
|
# describe WalletHelper do
|
||||||
|
# describe "string concat" do
|
||||||
|
# it "concats two strings with spaces" do
|
||||||
|
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
RSpec.describe WalletHelper, type: :helper do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
7
spec/requests/wallet_spec.rb
Normal file
7
spec/requests/wallet_spec.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe "Wallets", type: :request do
|
||||||
|
describe "GET /index" do
|
||||||
|
pending "add some examples (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user