Method: Hive::Broadcast.witness_set_properties
- Defined in:
- lib/hive/broadcast.rb
.witness_set_properties(options, &block) ⇒ Object
Extensible replacement for #witness_update that supports additional properties added since HF20 and beyond.
= {
wif: wif,
params: {
owner: witness_account_name,
props: {
account_creation_fee: '0.000 HIVE',
maximum_block_size: 131072,
hbd_interest_rate: 1000,
account_subsidy_budget: 50000,
account_subsidy_decay: 330782,
hbd_exchange_rate: '1.000 HIVE',
url: "https://hive.blog",
new_signing_key: 'STM8LoQjQqJHvotqBo7HjnqmUbFW9oJ2theyqonzUd9DdJ7YYHsvD'
}
}
}
Hive::Broadcast.witness_set_properties()
711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 |
# File 'lib/hive/broadcast.rb', line 711 def self.witness_set_properties(, &block) required_fields = %i(owner props) params = [:params] check_required_fields(params, *required_fields) props = params[:props] if !!(account_creation_fee = props[:account_creation_fee] rescue nil) props[:account_creation_fee] = hexlify normalize_amount(.merge amount: account_creation_fee, serialize: true) end if !!(hbd_exchange_rate = props[:hbd_exchange_rate] rescue nil) props[:hbd_exchange_rate][:base] = normalize_amount(.merge amount: hbd_exchange_rate[:base], serialize: true) props[:hbd_exchange_rate][:quote] = normalize_amount(.merge amount: hbd_exchange_rate[:quote], serialize: true) props[:hbd_exchange_rate] = hexlify props[:hbd_exchange_rate].to_json end %i(key new_signing_key).each do |key| begin if !!props[key] && props[key].length == 53 props[key] = hexlify props[key][3..-1] end rescue => e raise Hive::ArgumentError, "Unable to parse #{key}: #{e}" end end if !!(val = props[:url]) props[:url] = hexlify val unless val =~ /^[0-9A-F]+$/i end params[:props] = props.sort_by{|k,v| k} params[:extensions] ||= [] ops = [[:witness_set_properties, params]] process(.merge(ops: ops), &block) end |