core

Source core

The core is a function catalog to handle users accountId, login provider and users utility functions.


logout

core.logout(disabledReload);

Logout the current user. Removes the active account, provider and terms of use acceptance.

Parameters

  1. disabledReload - boolean: The options used for calling

Example

core.logout();

getCurrentProvider

core.getCurrentProvider();

Get the current, in local storage, configured provider.

Returns

string: The current provider (external, internal, agent-executor)

Example

core.getCurrentProvider()
// 'internal'

isInternalProvider

core.isInternalProvider();

Check if we should use internal provider.

Returns

boolean: Check if we should use internal provider.

Example

core.isInternalProvider()
// true

getExternalProvider

core.getExternalProvider();

Checks if a injected web3 provider exists an returns it’s name

Returns

boolean: check if the current provider is external

Example

getExternalProvider()
// false

setCurrentProvider

core.setCurrentProvider(provider);

Sets the current provider that should be used.

Parameters

  1. string: provider to switch to

Example

core.setCurrentProvider('internal')

activeAccount

core.activeAccount();

Get the current selected account included the check of the current provider.

Returns

string: account id of the current user (0x0…)

Example

const accountId = activeAccount();
// '0x000....'

getAccountId

core.getAccountId();

Returns the current (in the localStorage) saved account id

Returns

string : account id of the user (0x0…)

Example

core.getAccountId()
// '0x000...'

setAccountId

core.setAccountId(accountId);

Sets an account id as active one to the local storage.

Parameters

  1. accountId - string: account id to set to the localStorage

Example

setAccountId('0x0...')

getExternalAccount

core.getExternalAccount();

Checks if an external provider is activated and returns it’s active account id

Returns

string: The external account.

Example

core.getExternalAccount()
// '0x000...'

getAgentExecutor

core.getAgentExecutor();

Checks the current url parameters if agent executor login parameters are given.

Returns

any: all agent-exeutor parameters for requesting smart-agents and decrypting the profile

Example

  • URL : hhtps://dashboard.test.evan.network/index.html?agent-executor=1234…#/dashboard.evan
core.getAgentExecutor()

// {
//   token: '', // token to request the smart-agent and to load accountId and key for decrypting profile
//   accountId: '', // accountId of the smart-agent account
//   key: '' // data-key of the profile
// }

watchAccountChange

core.watchAccountChange();

Watches for account changes and reload the page if nessecary

Example

core.watchAccountChange();

currentBrowser

core.currentBrowser();

Return the name of the current used browser => https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser

Returns

string : opera / firefox / safari / ie / edge / chrome

Example

core.currentBrowser();
// 'chrome'

getBalance

core.getBalance(accountId);

Gets the balance of the provided or current account id

Parameters

  1. accountId - string: account id to get the balance from (default core.activeAccount())

Returns

number : The balance for the specific account id

Example

core.getBalance('0x000');
// 6.0223