Skip to content

Commit

Permalink
Merge pull request #1732 from nervosnetwork/develop
Browse files Browse the repository at this point in the history
Deploy to testnet
  • Loading branch information
zmcNotafraid authored Apr 2, 2024
2 parents a7e6dcc + 0caa4af commit 7a7176f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,7 @@ AUTH_ACCESS_EXPIRE=1296000
SECRET_KEY_BASE=""

# -------------------------------- Bitcoin segment --------------------------------
BITCOIN_NODE_URL=""
BITCOIN_NODE_URL=""

# Dynamic CORS configuration
PARTNER_DOMAINS="/localhost:\d*/"
8 changes: 8 additions & 0 deletions app/serializers/address_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ class AddressSerializer
display_name: udt_account.display_name,
uan: udt_account.uan,
}
elsif udt_account.udt_type == "xudt"
{
symbol: udt_account.symbol,
decimal: udt_account.decimal.to_s,
amount: udt_account.amount.to_s,
type_hash: udt_account.type_hash,
udt_type: udt_account.udt_type,
}
elsif udt_account.udt_type == "omiga_inscription"
info = udt_account.udt.omiga_inscription_info
{
Expand Down
14 changes: 5 additions & 9 deletions config/initializers/cors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@

Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do
origins "https://explorer.nervos.org",
"https://explorer-testnet.nervos.org",
"https://aggron.explorer.nervos.org",
"https://pudge.explorer.nervos.org",
"https://staging.explorer.nervos.org",
/\Ahttps:\/\/ckb-explorer-.*-magickbase.vercel.app\z/,
"http://localhost:3000",
(ENV["STAGING_DOMAIN"]).to_s
resource "*", headers: :any, methods: [:get, :post, :put, :head, :options]
origins ["https://explorer.nervos.org",
"https://pudge.explorer.nervos.org",
/\Ahttps:\/\/ckb-explorer-.*-magickbase.vercel.app\z/] +
ENV["PARTNER_DOMAINS"].to_s.split(",").map(&:strip).map { |x| x.start_with?("/") ? Regexp.new(x[1..-2]) : x }
resource "*", headers: :any, methods: %i[get post put head options]
end
end
6 changes: 3 additions & 3 deletions config/initializers/rack_attack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class Rack::Attack
# Throttle all requests by IP (60rpm)
#
# Key: "rack::attack:#{Time.now.to_i/:period}:req/ip:#{req.ip}"
throttle("req/ip", limit: 1500, period: 5.minutes) do |req|
req.env['HTTP_CF_CONNECTING_IP'] || req.ip # unless req.path.start_with?('/assets')
throttle("req/ip", limit: 3000, period: 5.minutes) do |req|
req.env["HTTP_CF_CONNECTING_IP"] || req.ip # unless req.path.start_with?('/assets')
end

### Custom Throttle Response ###
Expand All @@ -49,7 +49,7 @@ class Rack::Attack
headers = {
"RateLimit-Limit" => match_data[:limit].to_s,
"RateLimit-Remaining" => "0",
"RateLimit-Reset" => (now + (match_data[:period] - now % match_data[:period])).to_s
"RateLimit-Reset" => (now + (match_data[:period] - now % match_data[:period])).to_s,
}

[429, headers, ["Throttled\n"]]
Expand Down

0 comments on commit 7a7176f

Please sign in to comment.