Class: Chain::Asset::ClientModule

Inherits:
ClientModule show all
Defined in:
lib/chain/asset.rb

Instance Attribute Summary

Attributes inherited from ClientModule

#client

Instance Method Summary collapse

Methods inherited from ClientModule

#initialize

Constructor Details

This class inherits a constructor from Chain::ClientModule

Instance Method Details

#create(opts) ⇒ Asset

Parameters:

  • opts (Hash)

    Options hash specifiying asset creation details.

Options Hash (opts):

  • alias (String)

    User specified, unique identifier.

  • root_xpubs (Array<String>)

    The list of keys used to create the issuance program for the asset.

  • quorum (Integer)

    The number of keys required to issue units of the asset.

  • tags (Hash)

    User-specified, arbitrary/unstructured data local to the asset’s originating core.

  • definition (Hash)

    User-specified, arbitrary/unstructured data visible across blockchain networks.

Returns:



61
62
63
64
# File 'lib/chain/asset.rb', line 61

def create(opts)
  opts = {client_token: SecureRandom.uuid}.merge(opts)
  client.conn.singleton_batch_request('create-asset', [opts]) { |item| Asset.new(item) }
end

#create_batch(opts) ⇒ BatchResponse<Asset>

Parameters:

  • opts (Array<Hash>)

    An array of options hashes. See #create for a description of the hash structure.

Returns:



68
69
70
71
# File 'lib/chain/asset.rb', line 68

def create_batch(opts)
  opts = opts.map { |i| {client_token: SecureRandom.uuid}.merge(i) }
  client.conn.batch_request('create-asset', opts) { |item| Asset.new(item) }
end

#query(opts = {}) ⇒ Query

Parameters:

  • opts (Hash) (defaults to: {})

    Filtering information

Options Hash (opts):

Returns:



92
93
94
# File 'lib/chain/asset.rb', line 92

def query(opts = {})
  Query.new(client, opts)
end

#update_tags(opts) ⇒ Hash

Returns a success message.

Parameters:

  • opts (Hash)

    Options hash specifiying asset creation details.

Options Hash (opts):

  • id (String)

    The ID of the asset. Either an ID or alias should be provided, but not both.

  • alias (String)

    The alias of the asset. Either an ID or alias should be provided, but not both.

  • tags (Hash)

    A new set of tags, which will replace the existing tags.

Returns:

  • (Hash)

    a success message.



78
79
80
# File 'lib/chain/asset.rb', line 78

def update_tags(opts)
  client.conn.singleton_batch_request('update-asset-tags', [opts])
end

#update_tags_batch(opts) ⇒ BatchResponse<Hash>

Parameters:

  • opts (Array<Hash>)

    An array of options hashes. See #update_tags for a description of the hash structure.

Returns:



84
85
86
# File 'lib/chain/asset.rb', line 84

def update_tags_batch(opts)
  client.conn.batch_request('update-asset-tags', opts)
end