Method: Hive::Broadcast.account_create_with_delegation

Defined in:
lib/hive/broadcast.rb

.account_create_with_delegation(options, &block) ⇒ Object

Parameters:

  • options (Hash)

    options

Options Hash (options):

  • :wif (String)

    Active wif

  • :params (Hash)
    • :fee (String)

    • :delegation (String)

    • :creator (String)

    • :new_account_name (String)

    • :owner (String)

    • :active (String)

    • :posting (String)

    • :memo_key (String)

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

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

    • :extensions (Array)

  • :pretend (Boolean)

    Just validate, do not broadcast.

See Also:


1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
# File 'lib/hive/broadcast.rb', line 1200

def self.(options, &block)
  required_fields = %i(fee delegation creator new_account_name owner active posting memo_key)
  params = options[:params]
  
  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
  
  check_required_fields(params, *required_fields)
  
  params[:fee] = normalize_amount(options.merge amount: params[:fee])
  params[:delegation] = normalize_amount(options.merge amount: params[:delegation])
  params[:extensions] ||= []
  
  ops = [[:account_create_with_delegation, params]]
  
  process(options.merge(ops: ops), &block)
end