Skip to content

Commit 3b42435

Browse files
authored
Merge pull request #2501 from nervosnetwork/testnet
Deploy to mainnet
2 parents 77b5678 + bd49433 commit 3b42435

33 files changed

+167
-44
lines changed

.github/workflows/ruby.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ jobs:
2424
- uses: actions/checkout@v3
2525
- uses: ruby/setup-ruby@v1
2626
with:
27+
ruby-version: "3.1.2"
28+
rubygems: "3.3.22"
2729
bundler-cache: true
2830
- name: Build and test with Rake
2931
run: |
30-
sudo gem install bundler:2.0.1
32+
sudo gem install bundler:2.2.32
3133
bundle install --jobs 4 --retry 3
3234
bundle exec rails db:setup RAILS_ENV=test
3335
cp .env.test.local.travis .env.test.local

Dockerfile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ RUN apt-get update && apt-get install -y build-essential \
55
git libpq-dev libcurl4 libjemalloc2 \
66
libsecp256k1-dev libsodium-dev
77
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2
8-
# --registry=https://registry.npm.taobao.org
9-
# RUN gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/ && \
8+
RUN gem update --system 3.3.22
109
WORKDIR /usr/src/
1110
ARG RAILS_ENV=production
1211
ARG BUNDLER_VERSION=2.3.25
@@ -25,12 +24,11 @@ ADD . /usr/src/
2524

2625

2726
FROM ruby:${RUBY_VERSION}-slim
28-
# RUN sed --in-place --regexp-extended "s/(\/\/)(deb|security).debian.org/\1mirrors.ustc.edu.cn/" /etc/apt/sources.list && \
29-
# apt-get update && apt-get upgrade --yes
3027
RUN apt-get update && apt-get install -y \
3128
libpq5 libsodium23 curl \
3229
libcurl4 libjemalloc2 \
3330
&& rm -rf /var/lib/apt/lists/*
31+
RUN gem update --system 3.3.22
3432
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2
3533
ARG BUNDLER_VERSION=2.2.32
3634
RUN gem i -N bundler:$BUNDLER_VERSION foreman
@@ -42,4 +40,3 @@ ARG RAILS_ENV=production
4240
ENV RAILS_ENV=${RAILS_ENV}
4341
ENV RAILS_SERVE_STATIC_FILES true
4442
ENV RAILS_LOG_TO_STDOUT true
45-

Gemfile.lock

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,13 @@ GEM
310310
net-protocol
311311
newrelic_rpm (8.12.0)
312312
nio4r (2.7.3)
313-
nokogiri (1.18.3)
313+
nokogiri (1.18.8)
314314
mini_portile2 (~> 2.8.2)
315315
racc (~> 1.4)
316+
nokogiri (1.18.8-arm64-darwin)
317+
racc (~> 1.4)
318+
nokogiri (1.18.8-x86_64-linux-gnu)
319+
racc (~> 1.4)
316320
pagy (5.10.1)
317321
activesupport
318322
parallel (1.26.3)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module Api
2+
module V1
3+
class AddressDeployedCellsController < ApplicationController
4+
before_action :validate_pagination_params
5+
6+
def show
7+
expires_in 1.minute, public: true, must_revalidate: true, stale_while_revalidate: 10.seconds
8+
9+
json = Addresses::DeployedCells.run!(
10+
{
11+
request:, key: params[:id], sort: params[:sort],
12+
page: params[:page], page_size: params[:page_size]
13+
},
14+
)
15+
render json:
16+
end
17+
end
18+
end
19+
end

app/controllers/api/v1/cell_input_data_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def validate_query_params
2323
errors = validator.error_object[:errors]
2424
status = validator.error_object[:status]
2525

26-
render json: errors, status: status
26+
render json: errors, status:
2727
end
2828
end
2929
end

app/controllers/api/v1/cell_output_data_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def validate_query_params
2222
errors = validator.error_object[:errors]
2323
status = validator.error_object[:status]
2424

25-
render json: errors, status: status
25+
render json: errors, status:
2626
end
2727
end
2828
end

app/controllers/api/v2/fiber/graph_channels_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ def index
99
if params[:status] == "closed"
1010
@channels = @channels.where.not(closed_transaction_id: nil)
1111
end
12+
if params[:address_hash].present?
13+
address = Address.find_address!(params[:address_hash])
14+
@channels = @channels.where(address:)
15+
end
1216
@channels = @channels.page(@page).per(@page_size)
1317
end
1418
end

app/controllers/api/v2/transactions_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ def details
2222
}
2323
json = capacities.map { |address, value|
2424
{
25-
address: address,
25+
address:,
2626
transfers: [
2727
{
2828
asset: "CKB",
2929
capacity: value,
3030
token_name: "CKB",
3131
entity_type: "CKB",
32-
transfer_type: "simple_transfer"
32+
transfer_type: "simple_transfer",
3333
}
3434
]
3535
}
3636
}
3737

38-
render json: {data: json}
38+
render json: { data: json }
3939
end
4040

4141
protected
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module Addresses
2+
class DeployedCells < ActiveInteraction::Base
3+
include Api::V1::Exceptions
4+
5+
object :request, class: ActionDispatch::Request
6+
string :key, default: nil
7+
string :sort, default: "block_timestamp.desc"
8+
integer :page, default: 1
9+
integer :page_size, default: CellOutput.default_per_page
10+
11+
def execute
12+
address = Explore.run!(key:)
13+
raise AddressNotFoundError if address.is_a?(NullAddress)
14+
15+
order_by, asc_or_desc = deployed_cells_ordering
16+
deployed_cell_output_ids = Contract.joins(:deployed_cell_output).where(cell_outputs: { address: address.map(&:id) }).pluck(:deployed_cell_output_id)
17+
records = CellOutput.where(id: deployed_cell_output_ids).order(order_by => asc_or_desc).
18+
page(page).per(page_size).fast_page
19+
20+
options = FastJsonapi::PaginationMetaGenerator.new(request:, records:, page:, page_size:).call
21+
CellOutputSerializer.new(records, options).serialized_json
22+
end
23+
24+
private
25+
26+
def deployed_cells_ordering
27+
sort_by, sort_order = sort.split(".", 2)
28+
if sort_order.nil? || !sort_order.match?(/^(asc|desc)$/i)
29+
sort_order = "asc"
30+
end
31+
32+
[sort_by, sort_order]
33+
end
34+
end
35+
end

app/models/concerns/cell_outputs/extra_info.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,14 @@ def rgb_info
180180
consumed_txid: bitcoin_vout.consumed_by&.txid,
181181
)
182182
end
183+
184+
def tags
185+
tags = []
186+
tags << "fiber" if lock_script.code_hash == Settings.fiber_funding_code_hash
187+
tags << "deployment" if Contract.exists?(deployed_cell_output_id: id)
188+
tags << "multisig" if lock_script.code_hash == Settings.multisig_code_hash && lock_script.hash_type == "data1"
189+
tags
190+
end
183191
end
184192
end
185193
end

0 commit comments

Comments
 (0)