Skip to content

Commit 7719719

Browse files
authored
Merge pull request #2864 from nervosnetwork/testnet
Deploy to mainnet
2 parents 1d6c32d + 1169f06 commit 7719719

File tree

8 files changed

+23
-13
lines changed

8 files changed

+23
-13
lines changed

app/controllers/api/v1/address_dao_transactions_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ def show
88
address = Address.find_address!(params[:id])
99
raise Api::V1::Exceptions::AddressNotFoundError if address.is_a?(NullAddress)
1010

11+
includes = { :cell_inputs => {:previous_cell_output => {:type_script => [], :bitcoin_vout => [], :lock_script => [] }, :block => []}, :cell_outputs => {}, :bitcoin_annotation => [], :account_books => {} }
1112
ckb_dao_transactions = address.ckb_dao_transactions
12-
.includes(:cell_inputs => [:previous_cell_output], :cell_outputs => [], :bitcoin_annotation => [])
13+
.includes(includes)
1314
.select(select_fields)
1415
.recent.page(@page).per(@page_size)
1516

app/controllers/api/v1/address_udt_transactions_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ def show
1212
udt = Udt.find_by(type_hash: params[:type_hash], published: true)
1313
raise Api::V1::Exceptions::UdtNotFoundError if udt.blank?
1414

15+
includes = { :cell_inputs => {:previous_cell_output => {:type_script => [], :bitcoin_vout => [], :lock_script => [] }, :block => []}, :cell_outputs => {}, :bitcoin_annotation => [], :account_books => {} }
1516
ckb_udt_transactions = address.ckb_udt_transactions(udt.id)
16-
.includes(:cell_inputs => [:previous_cell_output], :cell_outputs => [], :bitcoin_annotation => [])
17+
.includes(includes)
1718
.select(select_fields)
1819
.recent.page(@page).per(@page_size).fast_page
1920
json =

app/controllers/api/v1/block_transactions_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ def show
1818
where(account_books: { address_id: address.id })
1919
end
2020

21+
includes = { :cell_inputs => {:previous_cell_output => {:type_script => [], :bitcoin_vout => [], :lock_script => [] }, :block => []}, :cell_outputs => {}, :bitcoin_annotation => [], :account_books => {} }
22+
2123
if stale?(ckb_transactions)
2224
expires_in 10.seconds, public: true, must_revalidate: true, stale_while_revalidate: 5.seconds
2325
ckb_transactions = ckb_transactions
24-
.includes(:cell_inputs => [:previous_cell_output], :cell_outputs => [], :bitcoin_annotation => [])
26+
.includes(includes)
2527
.page(@page).per(@page_size).fast_page
2628

2729
options = FastJsonapi::PaginationMetaGenerator.new(

app/controllers/api/v1/ckb_transactions_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ def query
8383
total_count = TableRecordCount.find_by(table_name: "ckb_transactions")&.count
8484
CkbTransaction.recent.normal.page(@page).per(@page_size).fast_page
8585
end
86-
ckb_transactions = ckb_transactions.select(:id, :tx_hash, :block_id, :tags,
86+
87+
includes = { :cell_inputs => {:previous_cell_output => {:type_script => [], :bitcoin_vout => [], :lock_script => [] }, :block => []}, :cell_outputs => {}, :bitcoin_annotation => [], :account_books => {} }
88+
ckb_transactions = ckb_transactions.includes(includes).select(:id, :tx_hash, :block_id, :tags,
8789
:block_number, :block_timestamp, :is_cellbase, :updated_at, :created_at)
8890
json =
8991
Rails.cache.realize(ckb_transactions.cache_key,

app/controllers/api/v1/contract_transactions_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ def show
2525
where(account_books: { address_id: address.id })
2626
end
2727

28+
includes = { :cell_inputs => {:previous_cell_output => {:type_script => [], :bitcoin_vout => [], :lock_script => [] }, :block => []}, :cell_outputs => {}, :bitcoin_annotation => [], :account_books => {} }
29+
2830
ckb_transactions = ckb_transactions
29-
.includes(:cell_inputs => [:previous_cell_output], :cell_outputs => [], :bitcoin_annotation => [])
31+
.includes(includes)
3032
.select(select_fields)
3133
.page(@page).per(@page_size).fast_page
3234
options = FastJsonapi::PaginationMetaGenerator.new(request:, records: ckb_transactions,

app/interactions/addresses/ckb_transactions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def execute
3737

3838
ckb_transaction_ids = account_books.map(&:ckb_transaction_id)
3939

40-
includes = { :cell_inputs => [:previous_cell_output], :cell_outputs => {}, :bitcoin_annotation => [], :account_books => {} }
40+
includes = { :cell_inputs => {:previous_cell_output => {:type_script => [], :bitcoin_vout => [], :lock_script => [] }, :block => []}, :cell_outputs => {}, :bitcoin_annotation => [], :account_books => {} }
4141
includes[:bitcoin_transfers] = {} if is_bitcoin
4242

4343
records = CkbTransaction.where(id: ckb_transaction_ids)

app/interactions/udts/ckb_transactions.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ def execute
3030
where(account_books: { address_id: address.map(&:id) }).distinct
3131
end
3232

33+
includes = { :cell_inputs => {:previous_cell_output => {:type_script => [], :bitcoin_vout => [], :lock_script => [] }, :block => []}, :cell_outputs => {}, :bitcoin_annotation => [], :account_books => {} }
34+
3335
records = ckb_transactions
34-
.includes(:cell_inputs => [:previous_cell_output], :cell_outputs => [], :bitcoin_annotation => [])
36+
.includes(includes)
3537
.select(select_fields)
3638
.page(page).per(page_size)
3739
options = FastJsonapi::PaginationMetaGenerator.new(

app/models/concerns/ckb_transactions/display_cells.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ def display_inputs(previews: false)
99
if is_cellbase
1010
cellbase_display_inputs
1111
else
12-
cell_inputs_for_display = cell_inputs.order(id: :asc)
13-
cell_inputs_for_display = cell_inputs_for_display.limit(10) if previews
12+
cell_inputs_for_display = cell_inputs.sort_by(&:id)
13+
cell_inputs_for_display = cell_inputs_for_display.first(10) if previews
1414
normal_tx_display_inputs(cell_inputs_for_display)
1515
end
1616
end
@@ -19,8 +19,8 @@ def display_outputs(previews: false)
1919
if is_cellbase
2020
cellbase_display_outputs
2121
else
22-
cell_outputs_for_display = cell_outputs.order(id: :asc)
23-
cell_outputs_for_display = cell_outputs_for_display.limit(10) if previews
22+
cell_outputs_for_display = cell_outputs.sort_by(&:id)
23+
cell_outputs_for_display = cell_outputs_for_display.first(10) if previews
2424
normal_tx_display_outputs(cell_outputs_for_display)
2525
end
2626
end
@@ -41,7 +41,7 @@ def cellbase_display_inputs
4141
end
4242

4343
def cellbase_display_outputs
44-
cell_outputs_for_display = cell_outputs.order(id: :asc)
44+
cell_outputs_for_display = cell_outputs.sort_by(&:id)
4545
cellbase = Cellbase.new(block)
4646
cell_outputs_for_display.map do |output|
4747
consumed_tx_hash = output.live? ? nil : output.consumed_by.tx_hash
@@ -104,7 +104,7 @@ def normal_tx_display_inputs(cell_inputs_for_display)
104104
display_input.merge!(attributes_for_dao_input(previous_cell_output))
105105
end
106106
if previous_cell_output.nervos_dao_deposit?
107-
display_input.merge!(attributes_for_dao_input(cell_outputs.order(:cell_index)[cell_input.index], false))
107+
display_input.merge!(attributes_for_dao_input(cell_outputs.sort_by(&:cell_index)[cell_input.index], false))
108108
end
109109
if previous_cell_output.udt?
110110
display_input.merge!(attributes_for_udt_cell(previous_cell_output))

0 commit comments

Comments
 (0)