Skip to content

Commit 32ee77e

Browse files
committed
feat: add block reward type
1 parent e362679 commit 32ee77e

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

lib/ckb/types/block_reward.rb

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# frozen_string_literal: true
2+
3+
module CKB
4+
module Types
5+
class BlockReward
6+
attr_accessor :total, :primary, :secondary, :tx_fee, :proposal_reward
7+
8+
# @param total [String] number
9+
# @param primary [String] number
10+
# @param secondary [String] number
11+
# @param tx_fee [String] number
12+
# @param proposal_reward [String] number
13+
def initialize(total:, primary:, secondary:, tx_fee:, proposal_reward:)
14+
@total = total
15+
@primary = primary
16+
@secondary = secondary
17+
@tx_fee = tx_fee
18+
@proposal_reward = proposal_reward
19+
end
20+
21+
def to_h
22+
{
23+
total: @total,
24+
primary: @primary,
25+
secondary: @secondary,
26+
tx_fee: @tx_fee,
27+
proposal_reward: @proposal_reward
28+
}
29+
end
30+
31+
def self.from_h(hash)
32+
return if hash.nil?
33+
34+
new(
35+
total: hash[:total],
36+
primary: hash[:primary],
37+
secondary: hash[:secondary],
38+
tx_fee: hash[:tx_fee],
39+
proposal_reward: hash[:proposal_reward]
40+
)
41+
end
42+
end
43+
end
44+
end

lib/ckb/types/types.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
require_relative "lock_hash_index_state"
2727
require_relative "live_cell"
2828
require_relative "cell_transaction"
29+
require_relative "block_reward"
2930

3031
module CKB
3132
module Types

0 commit comments

Comments
 (0)