Skip to main content

ElvFabric

Tools for operating content on the Content Fabric

Constructor

new ElvFabric({ configUrl })

Instantiate the ElvFabric Object

Parameters

NameTypeRequiredDescription
configUrlstring

The Content Fabric configuration URL

AccessGroupManager

AccessGroupManager(
  group,
  addr
)

AccessGroupManager Check if an address is a manager of the access group

Returns: result of contract method call

Parameters

NameTypeRequiredDescription
groupstring

Group ID (hex or igrp format)

addrstring

User address

AccessGroupManagers

AccessGroupManagers(group) → Array

AccessGroupManagers Returns a list of group managers

Returns: group members

Parameters

NameTypeRequiredDescription
groupstring

Group ID (hex or igrp format)

AccessGroupMember

AccessGroupMember(
  group,
  addr
)

AccessGroupMemeber Check if an address is a member of the access group

Returns: result of contract method call

Parameters

NameTypeRequiredDescription
groupstring

Group ID (hex or igrp format)

addrstring

User address

AccessGroupMembers

AccessGroupMembers(group) → Array

AccessGroupMembers Returns a list of group members

Returns: group members

Parameters

NameTypeRequiredDescription
groupstring

Group ID (hex or igrp format)

copyObject

copyObject(
  objectId,
  meta
)

Make a copy of an object and set content metadata on the new object

Parameters

NameTypeRequiredDescription
objectIdstring
metaobject

Metadata tree to merge into the object

copyObjectBatch

copyObjectBatch(ids)

Make a copy of a list of object and set content metadata on the new ones.

Parameters

NameTypeRequiredDescription
idsobject

Map of object IDs to metadata

GetContractMeta

GetContractMeta(
  address,
  key
)

GetContractMeta

Returns: value stored in the contract metadata

Parameters

NameTypeRequiredDescription
addressstring

contract address

keystring

metadata key

getMeta

getMeta(objectId)

Get content metadata for an object

Parameters

NameTypeRequiredDescription
objectIdstring

GetMetaBatch

GetMetaBatch(csvFile)

GetMetaBatch

Parameters

NameTypeRequiredDescription
csvFilestring

File specifying a list of content IDs and metadata fields to read. Note that the first two columns has to be id,hash

GetMetaByIds

GetMetaByIds(
  ids,
  fields
)

GetMetaByIds

Parameters

NameTypeRequiredDescription
idsObject.<string, Object>

Map of content object IDs to their metadata objects

fieldsArray.<string>

Metadata field paths to extract for each object

ReadCsvObjectsMerged

ReadCsvObjectsMerged(
  csvFile,
  ignore
)

Read a CSV file and parse into a JSON object merging with the object's existing fabric metadata.

Applies string substitutions on input:

  • ${UUID}

CSV file format: id,field1,field2 iq_1111,value1,value2 iq_2222,value1,value2

Output format: { "iq_1111" : { "field1": "value1", "field2": "value2" }, "iq_2222" : { "field1": "value1", "field2": "value2" } }

Returns: object Map of object IDs to metadata

Parameters

NameTypeRequiredDescription
csvFilestring

path to CSV file

ignoreArray

a list of prefixes to ignore eg "eluv."

SetContractMeta

SetContractMeta(
  address,
  key,
  value
)

SetContractMeta

Returns: result of contract method call

Parameters

NameTypeRequiredDescription
addressstring

contract address

keystring

metadata key

valuestring

metadata value

SetContractMetaAsync

SetContractMetaAsync(
  address,
  key,
  value
) → object

SetContractMetaAsync - async version of client SetContractMeta() Submits the putMeta transaction WITHOUT waiting for completionand returns the ethers transaction response so the caller can wait on it

Returns: ethers transaction response - caller can call .wait()

Parameters

NameTypeRequiredDescription
addressstring

contract address

keystring

metadata key

valuestring

metadata value

setMeta

setMeta(
  objectId,
  meta,
  merge
)

Set content metadata for an object

Parameters

NameTypeRequiredDescription
objectIdstring
metaobject

Metadata tree to merge into the object

mergeboolean

Merge == true will merge instead of replace

setMetaBatch

setMetaBatch(ids)

Set content metadata for a bach of objects.

Parameters

NameTypeRequiredDescription
idsobject

Map of object IDs to metadata

SetMetaBatch

SetMetaBatch(
  csvFile,
  duplicate
)

SetMetaBatch

Parameters

NameTypeRequiredDescription
csvFilestring

File specifying a list of content IDs and metadata fields

duplicateboolean

Clone objects and set metadata on the clone instead