@windingtree/wt-read-api
Version:
API to interact with the Winding Tree platform
43 lines (38 loc) • 1.16 kB
JavaScript
const { TrustClueCuratedList } = require('@windingtree/trust-clue-curated-list');
const { config } = require('../config');
const getConfiguredCuratedList = (clues, web3Provider, options) => {
if (options.curatedListAddress) {
clues['curated-list'] = {
options: {
provider: web3Provider,
address: options.curatedListAddress,
},
create: async (options) => {
return new TrustClueCuratedList(options);
},
};
}
};
const getTrustCluesConfig = (web3Provider, options = {}) => {
const clues = {};
// All of the supported trust clues
getConfiguredCuratedList(clues, web3Provider, options);
return {
provider: web3Provider,
clues: clues,
};
};
/**
* Check if `signerAddress` is in `associatedKeys` of organization.
* @param signerAddress
* @param organizationAddress
* @returns {Promise<boolean>}
*/
const isSignerAssociated = async (signerAddress, organizationAddress) => {
const organization = await config.wtLibs.getOrganization(organizationAddress);
return organization.hasAssociatedKey(signerAddress);
};
module.exports = {
getTrustCluesConfig,
isSignerAssociated,
};