Socket
Socket
Sign inDemoInstall

@energyweb/credential-governance

Package Overview
Dependencies
150
Maintainers
8
Versions
80
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @energyweb/credential-governance

Smart contract and client code specific to EnergyWeb credential governance (including roles)


Version published
Maintainers
8
Install size
42.2 MB
Created

Changelog

Source

2.2.0 (2022-08-23)

Bug Fixes

  • @energyweb/vc-verification: validate eip191Jwt (fa98998)
  • restructure vc-verification package (b84a39e)

Features

  • export claimsrevocationregistry address (9194435)

Readme

Source

Energy Web Foundation Logo

Credential Governance

Description

This package consists of EVM smart contract related to EnergyWeb Name Service and libraries to resolve / read namespaces & defintions.

@energyweb/credential-governance is a typescript module.

{credential-governance} is a component of the Energy Web Decentralized Operating System

Usage

DomainReader

The DomainReader class can be used as shown to read a domain definition.

import {
  DomainReader,
  VOLTA_ENS_REGISTRY_ADDRESS,
} from "@energyweb/credential-governance";
import { providers, utils } from "ethers";

(async () => {
  const provider = new providers.JsonRpcProvider(
    "https://volta-rpc.energyweb.org"
  );
  const reader = new DomainReader({
    ensRegistryAddress: VOLTA_ENS_REGISTRY_ADDRESS,
    provider,
  });
  const roleDefinition = await reader.read({
    node: utils.namehash("manufacturer.roles.flex.apps.exampleco.iam.ewc"),
  });
})();

DomainTransactionFactoryV2

The DomainTransactionFactory class can be used to add and update definitions specific to namespaces.

import {
  DomainTransactionFactoryV2,
  VOLTA_RESOLVER_V2_ADDRESS,
} from "@energyweb/credential-governance";

(async () => {
  const domainTransactionFactory = new DomainTransactionFactoryV2({
    domainResolverAddress: VOLTA_RESOLVER_V2_ADDRESS,
  });

  const domain = 'sampleDomain';
  const role: IRoleDefinitionV2 = {
    requestorFields: [
      {
        fieldType: 'fieldType',
        label: 'label',
        required: true,
        minLength: 5,
        minDate: new Date(),
        maxDate: new Date(),
      },
    ],
    issuer: {
      issuerType: 'DID',
      did: [`did:ethr:volta:0x7aA65E31d404A8857BA083f6195757a730b51CFe`],
    },
    revoker: {
      revokerType: 'DID',
      did: [`did:ethr:volta:0x7aA65E31d404A8857BA083f6195757a730b51CFe`],
    },
    metadata: [],
    roleName: 'myRole1',
    roleType: 'sample',
    version: 1,
    enrolmentPreconditions: [],
  };

  const call = domainDefTxFactoryV2.newRole({
    domain: domain,
    roleDefinition: role,
  });
  await (await owner.sendTransaction(call)).wait();
})();

Contract Descriptions

RoleDefinitionResolverV2.sol

This is an implementation of an ENS resolver that represents a role definition. It extends the ENS Public Resolver with additional resolver profiles, specifically for the use case of issuance, revocation and verify role claims using a smart contract. In other words, this custom ENS resolver allows some properties of a role definition to be (usefully) readable by another smart contract.

DomainNotifier.sol

This EVM contracts notifies the updation of ENS namespaces resolved data.

Installation

This is a Node.js module available through the npm registry.

Requirements

Before installing, download and install Node.js. Node.js 16.10.0 or higher is required.

Installation is done using the following commands:

$ npm install

Build

$ npm run build

Run

$ npm run start

Testing

Unit Tests

$ npm run test-rpc

Keywords

FAQs

Last updated on 23 Aug 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc