EvanBCCService

Source bcc

Core blockchain-core angular-core wrapper. Initializes and extends new runtimes from dapp-browser, when user unlocked successfully its account, to handle correct user encryption keys and object instances

  • passwordModalPromise - any: wait for password dialog to be resolved;
  • updateBCCPromise - any: wait for bcc is updated to be resolved;

BCCCore or BCCProfile exported runtime values. Mapped from e.g BCC.coreInstance.executor => this.executor


initialize

bccService.initialize(passwordFunction);

Initialize the bcc service using a password unlocking function.

Parameters

  1. passwordFunction - Function: function that is used to unlock current lightwallet vault

Returns

Promise returns void: resolved when bcc was updated for the current profile

Example

await this.bcc.initialize((accountId) => this.bcc.globalPasswordDialog(accountId));

copyCoreToInstance

bccService.copyCoreToInstance();

Copy BCC core object instances into the service this scope.


copyCoreToInstance

bccService.copyProfileToInstance();

Copy BCC profile object instances into the service this scope.


getSigner

bccService.getSigner(provider);

Returns the existing executor or creates a new one, for the active current provider.

Parameters

  1. provider - string (default = this.core.getCurrentProvider()): The provider

Returns

Promise returns SignerInternal: The signer.

Example

const signer = this.getSigner(provider);

getRightsAndRolesObj

bccService.getRightsAndRolesObj();

Returns a new rights and roles object instance.

Parameters

  1. options - object: The options used for calling
    • from - string (optional): The address the call “transaction” should be made from
  2. callback - Function (optional): This callback will be fired..
  3. somethingElse - string (optional): this can be set if required, defaults to "latest"

Returns

RightsAndRoles: The rights and roles object

Example

rightsAndRoles = this.getRightsAndRolesObj();

updateBCC

bccService.updateBCC(activeAccount, provider, disableKeys);

Setup / update initial blockchain-core structure for current account id and signer.

Parameters

  1. activeAccount - string: current active account
  2. provider - string: internal / external
  3. disableKeys - boolean (optional): disable keyProvider.setKeys / this.setExchangeKeys, used for disabling key setting, only early ui states

Returns

Promise returns void: solved when bcc is updated

Example

await bccService.updateBCC();

updateTermsOfUse

bccService.updateTermsOfUse(activeAccount);

Check the terms of use has changed and if the current user accepted it.

Parameters

  1. activeAccount - string: current active account

Returns

Promise returns void: resolved when done

Example

await bccService.updateTermsOfUse();

getProfileForAccount

bccService.getProfileForAccount(accountId);

Returns an new blockchain-core profile instance. !Attention : It’s only builded for load values to check for public and private keys (e.g. used by onboarding or global-password) Executor is the normal one from the global core!!!

Parameters

  1. accountId - string: account id to create a new profile instance for

Returns

Profile: The profile for account.

Example

bccService.getProfileForAccount('0x000')

setExchangeKeys

bccService.setExchangeKeys(accountId);

run keyExchange.setPublicKey

Parameters

  1. accountId - string: Account id to set the exchange keys for

Returns

Promise returns void: resolved when done

Example

await this.setExchangeKeys(activeAccount);

getMetamaskWeb3

bccService.getMetamaskWeb3();

Returns a new web3 instances. If a web3 currentProvider is provided, it will be used.

Returns

Promise returns Web3: window.web3

Example

getWeb3(provider = this.core.getCurrentProvider()) {
  if (provider === 'metamask') {
    return this.getMetamaskWeb3();
  } else {
    return this.web3;
  }
}

getWeb3

bccService.getWeb3(provider);

Get the existing web3 or metamask web3.

Parameters

  1. provider - string (default = this.core.getCurrentProvider()): The provider

Returns

Promise returns void: resolved when done

Example

this.getWeb3();

getDomainName

dapp.getDomainName(...subLabels);

builds a full domain name for the current bcc config

Parameters

  1. Array<string> - subLabels: used to enhance nameResolver config

Returns

The domain name : The domain name.

Example

ensDomain = `bcc.${ getDomainName() }!dapp-content`
// returns: bcc.evan!dapp-content

globalPasswordDialog

initializedModule.globalPasswordDialog(accountId);

angular-core default password dialog function that is used for lightwallet unlocking.

Parameters

  1. accountId - string: account id to load password for

Returns

Promise returns string: the password

Example

await this.bccService.initialize((accountId) => this.bccService.globalPasswordDialog(accountId));