Class Name | BusinessCenterProfile |
---|---|
Extends | Logger |
Source | business-center-profile.ts |
Examples | business-center-profile.spec.ts |
The BusinessCenterProfile
module allows to create profiles in a business center.
These profiles are like business cards for specific contexts and can be used to share data like contact data or certificates under this business centers context.
// update/set contact card locally
await profile.setContactCard(JSON.parse(JSON.stringify(sampleProfile)));
// store to business center
await profile.storeForBusinessCenter(businessCenterDomain, accounts[0]);
// load from business center
await profile.loadForBusinessCenter(businessCenterDomain, accounts[0]);
const loadedProfile = await profile.getContactCard();
new BusinessCenterProfile(options);
Creates a new BusinessCenterProfile instance.
options
-BusinessCenterProfileOptions
: options for BusinessCenterProfile constructor.bcAddress
-string
: ENS address (domain name) of the business center, the module instance is scoped tocryptoProvider
-CryptoProvider
:CryptoProvider
instancedefaultCryptoAlgo
-string
: crypto algorith name fromCryptoProvider
ipld
-Ipld
:Ipld
instancenameResolver
-NameResolver
:NameResolver
instanceipldData
-any
(optional): preloaded profile datalog
-Function
(optional): function to use for logging:(message, level) => {...}
logLevel
-LogLevel
(optional): messages with this level will be logged withlog
logLog
-LogLogInterface
(optional): container for collecting log messageslogLogLevel
-LogLevel
(optional): messages with this level will be pushed tologLog
BusinessCenterProfile
instance
const businessCenterProfile = new BusinessCenterProfile({
ipld,
nameResolver,
defaultCryptoAlgo: 'aes',
bcAddress: businessCenterDomain,
cryptoProvider,
});;
businessCenterProfile.setContactCard();
Set contact card on current profile.
contactCard
-any
: contact card to store
Promise
returns any
: updated tree
const updated = await businessCenterProfile.setContactCard(contactCard);
businessCenterProfile.getContactCard();
Get contact card from.
(none)
Promise
returns any
: contact card
const loadedProfile = await businessCenterProfile.getContactCard();
businessCenterProfile.storeForBusinessCenter(businessCenterDomain, identity);
Stores profile to business centers profile store.
businessCenerDomain
-string
: ENS domain name of a business centerexecutorAddress
-string
: Identity or account making the transaction
Promise
returns void
: resolved when done
await businessCenterProfile.setContactCard(contactCard);
await businessCenterProfile.storeForBusinessCenter(businessCenterDomain, identities[0]);
businessCenterProfile.loadForBusinessCenter(businessCenterDomain, identity);
Function description
businessCenerDomain
-string
: ENS domain name of a business centerexecutorAddress
-string
: identity or account making the transaction
Promise
returns void
: resolved when done
await newProfilebusinessCenterProfile.loadForBusinessCenter(businessCenterDomain, identities[0]);
const contactCard = await businessCenterProfile.getContactCard();
businessCenterProfile.storeToIpld();
Store profile in ipfs as an ipfs file that points to a ipld dag.
(none)
Promise
returns string
: hash of the ipfs file
await businessCenterProfile.storeToIpld();
businessCenterProfile.loadFromIpld(tree, ipldIpfsHash);
Load profile from ipfs via ipld dag via ipfs file hash.
ipldIpfsHash
-string
: ipfs file hash that points to a file with ipld a hash
Promise
returns BusinessCenterProfile
: this profile
businessCenterProfile.loadFromIpld(ipldIpfsHash);
businessCenterProfile.getMyBusinessCenterContracts(domain, contractType, subject);
Gets all registered contracts for a specific contract type on a businesscenter
businessCenterDomain
-string
: The business center domaincontractType
-string
: The contract typesubject
-string
: Subject to get the contracts for
Promise
returns any
: Array with all registered bc contracts
businessCenterProfile.loadFromIpld(ipldIpfsHash);