Method: Hive::Broadcast.account_update2

Defined in:
lib/hive/broadcast.rb

.account_update2(options, &block) ⇒ Object

Parameters:

  • options (Hash)

    options

Options Hash (options):

  • :wif (String)

    Active wif

  • :params (Hash)
    • :account (String) Account being updated.

    • :metadata (Hash) Metadata of the account, becomes `json_metadata`.

    • :json_metadata (String) String version of `metadata` (use one or the other).

  • :pretend (Boolean)

    Just validate, do not broadcast.

See Also:


1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
# File 'lib/hive/broadcast.rb', line 1277

def self.(options, &block)
  required_fields = %i(account)
  params = options[:params]
  
  check_required_fields(params, *required_fields)
  
  if !!params[:metadata] && !!params[:json_metadata]
    raise Hive::ArgumentError, 'Assign either metadata or json_metadata, not both.'
  end
  
   = params.delete(:metadata) || {}
   ||= (JSON[params[:json_metadata]] || nil) || {}
  params[:json_metadata] = .to_json
  
  ops = [[:account_update2, params]]
  
  process(options.merge(ops: ops), &block)
end