KsCollection
- class KsCollection()
A lookup table of
Keystoreinstances, keyed by address (or an arbitrary label). Used to gather the keystoresrequestProxyKey()needs: one entry named'owner'for the identity making the request, plus one entry per address referenced by anauthfield in the request.
Constructor
new KsCollection();
Takes no arguments; starts out empty.
Methods
add
- KsCollection.add(ks, lookupKey)
Adds a keystore to the collection. Does nothing if lookupKey is already present – it does not overwrite.
- Arguments:
ks – A Keystore or PrivateKey instance. Throws otherwise.
lookupKey – Optional. Defaults to ks.address.
get
- KsCollection.get(lookupKey)
- Arguments:
lookupKey
- Throws:
Error if lookupKey isn’t in the collection.
- Return type:
Keystore
has
- KsCollection.has(lookupKey)
- Arguments:
lookupKey
- Return type:
boolean
getKeys
- KsCollection.getKeys()
Returns every lookup key currently in the collection (addresses and/or custom labels, e.g. ‘owner’).
- Return type:
Array
Example
const identity = require('dcp/identity');
const ksCollection = new identity.KsCollection();
ksCollection.add(identity.get(), 'owner');
ksCollection.add(bankAccountKeystore); // keyed by its own address