Class: BitShares::Api

Inherits:
Array
  • Object
show all
Defined in:
lib/bitshares/api.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, arr) ⇒ Api

Returns a new instance of Api.



5
6
7
8
# File 'lib/bitshares/api.rb', line 5

def initialize name, arr
	@name = name
	self.concat arr
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/bitshares/api.rb', line 3

def name
  @name
end

Class Method Details

.[](name) ⇒ Object



130
131
132
133
134
135
136
# File 'lib/bitshares/api.rb', line 130

def [] name
	@apis ||= init
	@apis.each do |api|
		return api if api.name == name
	end
	nil
end

.get_id_by_name(name) ⇒ Object



117
118
119
120
121
122
123
# File 'lib/bitshares/api.rb', line 117

def get_id_by_name name
	@apis ||= init
	@apis.each do |api|
		return(api.id) if api.include? name
	end
	nil
end

.initObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/bitshares/api.rb', line 20

def init
	return @apis unless @apis.nil?

	@apis = []
	@apis << API.new('database',
	%w(
		get_objects
		set_subscribe_callback
		set_pending_transaction_callback
		set_block_applied_callback
		cancel_all_subscriptions
		get_block_header
		get_block
		get_transaction
		get_recent_transaction_by_id
		get_chain_properties
		get_global_properties
		get_config
		get_chain_id
		get_dynamic_global_properties
		get_key_references
		get_accounts
		get_full_accounts
		get_account_by_name
		get_account_references
		lookup_account_names
		lookup_accounts
		get_account_count
		get_account_balances
		get_named_account_balances
		get_balance_objects
		get_vested_balances
		get_vesting_balances
		get_assets
		list_assets
		lookup_asset_symbols
		get_order_book
		get_limit_orders
		get_call_orders
		get_settle_orders
		get_margin_positions
		subscribe_to_market
		unsubscribe_from_market
		get_ticker
		get_24_volume
		get_trade_history
		get_witnesses
		get_witness_by_account
		lookup_witness_accounts
		get_witness_count
		get_committee_members
		get_committee_member_by_account
		lookup_committee_member_accounts
		get_workers_by_account
		lookup_vote_ids
		get_transaction_hex
		get_required_signatures
		get_potential_signatures
		get_potential_address_signatures
		verify_authority
		verify_account_authority
		validate_transaction
		get_required_fees
		get_proposed_transactions
		get_blinded_balances
	))

	@apis << API.new('history',
	%w(
		get_account_history
		get_fill_order_history
		get_market_history
		get_market_history_buckets
	))

	@apis << API.new('network_broadcast',
	%w(
		broadcast_transaction
		broadcast_transaction_with_callback
		broadcast_block
	))

	@apis << API.new('crypto',
	%w(
		blind_sign
		unblind_signature
		blind
		blind_sum
		range_get_info
		range_proof_sign
		verify_sum
		verify_range
		verify_range_proof_rewind
	))
	@apis
end

.rpc(method, params) ⇒ Object



125
126
127
128
# File 'lib/bitshares/api.rb', line 125

def rpc method, params
	@apis ||= init
	RPC.new get_id_by_name(method), method, params
end

Instance Method Details

#idObject



10
11
12
# File 'lib/bitshares/api.rb', line 10

def id
	@id ||= RPC.new(1, @name, [[]]).send
end

#rpc(method, params) ⇒ Object



14
15
16
# File 'lib/bitshares/api.rb', line 14

def rpc method, params
	RPC.new id, method, params
end