blockchain-core frontend bundle

Source AsyncComponent

The blockchain-core frontend bundle is similar to the blockchain-core runtime and its build to handle several UI steps including blockchain-core instance without account interactions, blockchain-core instance including account id for profile interactions and blockchain-core instance to interact with business centers. It exposes the following Runtime parameters and several functions to create, handle and overwrite them:

Installation

npm i @evan.network/ui-angular-libs

Usage

  • tsconfig.json
{
  "compilerOptions": {
    "declaration": true,
    "module": "es2015",
    "target": "es5",
    "baseUrl": "./src",
    "stripInternal": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "outDir": "../build",
    "rootDir": "./src",
    "lib": [
      "es2015",
      "dom"
    ],
    "skipLibCheck": true,
    "types": [],
    "paths": {
      "bcc": [
        "../node_modules/@evan.network/api-blockchain-core/bundlesbcc"
      ]
    }
  },
  "angularCompilerOptions": {
    "annotateForClosureCompiler": true,
    "strictMetadataEmit": true,
    "skipTemplateCodegen": true,
    "flatModuleOutFile": "dashboard.js",
    "flatModuleId": "dashboard"
  },
  "files": [
    "./index.ts"
  ]
}
  • module.ts
import * as bcc from 'bcc';

Interface: SolcInterface

Used to describe smart contract resolve for bundles, …

Parameters

  1. getContracts - any: Returns compiled contracts object.

Example

solc.getContracts();
// {
//   "AbstractDescribed": {
//     "interface": "[...]"
//   },
//   "AbstractENS": {
//     "interface": "[...]"
//   },
//   ...
// }

Interface: CoreBundle

Core bundle specification (the full result of the blockchain-core frontend bundle file).

Parameters

  1. createCore - Function;
  2. createAndSetCore - Function;
  3. ContractLoader - ContractLoader;
  4. CryptoProvider - CryptoProvider;
  5. Description - Description;
  6. DfsInterface - DfsInterface;
  7. EventHub - EventHub;
  8. Executor - Executor;
  9. Ipfs - Ipfs;
  10. NameResolver - NameResolver;
  11. Unencrypted - Unencrypted;
  12. CoreRuntime - CoreInstance;
  13. isAccountOnboarded - Function;
  14. IpfsRemoteConstructor - IpfsRemoteConstructor: require(‘ipfs-api’);
  15. keystore - KeyStore: require(‘eth-lightwallet/lib/keystore’);
  16. Mnemonic - Mnemonic: require(‘bitcore-mnemonic’);
  17. KeyProviderInterface - KeyProviderInterface;
  18. KeyProvider - KeyProvider;

Interface: CoreBundleOptions

Used to create a new CoreInstance.

Parameters

  1. web3 - Web3: web3 instance;
  2. solc - SolcInterface: solc to get contracts;
  3. config - config: blockchain-core configuration;
  4. executor - Executor (optional): blockchain-core executor instance;
  5. contractLoader - ContractLoader (optional): blockchain-core contract loader instance;
  6. description - Description (optional): blockchain-core description instance;
  7. dfs - DfsInterface (optional): blockchain-core dfs interface instance;
  8. dfsRemoteNode - IpfsRemoteConstructor (optional): require(‘ipfs-api’)
  9. nameResolver - NameResolver (optional): blockchain-core name resolver instance;
  10. ipfsCache - IpfsCache (optional): ipfs cache specification;

Interface: CoreInstance

Initialized core bundle for blockchain interaction without account specification.

Parameters

  1. web3 - Web3: web3 instance;
  2. description - Description (optional): blockchain-core description instance;
  3. nameResolver - NameResolver (optional): blockchain-core name resolver instance;
  4. dfs - DfsInterface (optional): blockchain-core dfs interface instance;
  5. contractLoader - ContractLoader (optional): blockchain-core contract loader instance;
  6. executor - Executor (optional): blockchain-core executor instance;
  7. solc - SolcInterface: solc to get contracts;
  8. contracts - SmartContracts: precompiled smart-contracts specification;
  9. config - config: blockchain-core configuration;

Interface: ProfileBundle

Options to initialize a new ProfileInstance.

Parameters

  1. create - source Function;
  2. createAndSet - Function;
  3. ProfileRuntime - ProfileInstance;
  4. Aes - Aes;
  5. Claims - Claims;
  6. Ipld - Ipld;
  7. KeyExchange - KeyExchange;
  8. Logger - Logger;
  9. Mailbox - Mailbox;
  10. Onboarding - Onboarding;
  11. Profile - Profile;
  12. RightsAndRoles - RightsAndRoles;
  13. Sharing - Sharing;
  14. SignerExternal - SignerExternal;
  15. SignerInternal - SignerInternal;

Interface: ProfileBundleOptions

Options to initialize a new ProfileInstance.

Parameters

  1. CoreBundle - CoreBundle;
  2. coreOptions - CoreBundleOptions;
  3. accountId - string: account id to initialize the profile instance for;
  4. signer - SignerInternal or SignerExternal;
  5. keyProvider - KeyProvider;

Interface: ProfileInstance

Bundled runtime for blockchain-core interaction for a specific account.

Parameters

  1. ipldInstance - Ipld;
  2. keyExchange - KeyExchange;
  3. mailbox - Mailbox;
  4. claims - Claims;
  5. profile - Profile;
  6. sharing - Sharing;
  7. dataContract - DataContract;
  8. keyProvider - KeyProvider;
  9. coreInstance - CoreInstance;

Interface: BCBundleOptions

Bundle Options for the BCInstance.

Parameters

  1. ensDomain - string: ens domain for the business center that should be initialized;
  2. ProfileBundle - ProfileBundle;

Interface: BCInstance

Bundled runtime for blockchain-core interaction for a specific account and business center.

Parameters

  1. ensDomain - string: ens domain for the business center that should be initialized;
  2. bcAddress - string: contract addess of the business center;
  3. businessCenter - source any: business center contract instance (CoreRuntime.contractLoader.loadContract(‘BusinessCenter’, bcAddress));
  4. bcRoles - RightsAndRoles;
  5. ipld - Ipld;
  6. bcProfiles - BusinessCenterProfile;
  7. description - any: loaded description from the ens address of the bc;
  8. dataContract - DataContract;

createCore

bcc.createCore(options);

Creates a new CoreInstance

Parameters

  1. options - CoreBundleOptions: The core options

Returns

CoreInstance: new CoreInstance instance

Example

bcc.createCore(options);

createAndSetCore

bcc.createAndSetCore(options);

Creates a new CoreInstance and update the CoreInstance export.

Parameters

  1. options - CoreBundleOptions: The core options

Returns

CoreInstance: new CoreInstance instance

Example

bcc.createCore(options);

Usage Example: https://github.com/evannetwork/ui-dapp-browser/blob/develop/src/appbcc.ts


setCore

bcc.setCore(coreInstance);

Overwrite the current CoreInstance

Parameters

  1. coreInstance - CoreInstance: core instance to overwrite

Example

bcc.setCore(CoreInstance)

Usage Example: https://github.com/evannetwork/ui-dapp-browser/blob/develop/src/appbcc.ts


create

bcc.create(options);

Creates a new ProfileInstance

Parameters

  1. options - ProfileBundleOptions: profile bundle options

Returns

ProfileInstance : the new profile instance

createAndSet

bcc.createAndSet(options);

Create a new ProfileInstance and update the ProfileInstance export.

Parameters

  1. options - ProfileBundleOptions: profile bundle options

Returns

ProfileInstance : the new profile instance

createBC

bcc.createBC(options);

Create a new BCInstance.

Parameters

  1. options - BCBundleOptions: options for the business center

Returns

BCInstance : the new bc instance

createAndSetBC

bcc.createAndSetBC(options);

Creates and set BCInstance.

Parameters

  1. options - BCBundleOptions: options for the business center

Returns

BCInstance : the new bc instance

isAccountOnboarded

bcc.isAccountOnboarded(accountId);

Function description

Parameters

  1. accountId - string: account id to test

Returns

Promise returns boolean: True if account onboarded, False otherwise

Example

bcc.isAccountOnboarded('0x000...');
// returns true / false