Skip to content

Latest commit

 

History

History
93 lines (59 loc) · 2.65 KB

File metadata and controls

93 lines (59 loc) · 2.65 KB

Plugin

This project was generated with Angular CLI version 6.0.8.

The project requires NodeJS to be installed:

  1. Install webpack globally npm -g webpack.
  2. Move to project folder and run npm i.
  3. Run sh build-dev.sh or sh build-prod.sh to build the project. The build artifacts will be stored in the dist/ directory.

Development server

Run ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Code scaffolding

Run ng generate component component-name to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module.

Build

The project requires NodeJS to be installed.

  1. Install webpack globally npm -g webpack.
  2. Move to project folder and run npm i.
  3. Run sh build-dev.sh or sh build-prod.sh to build the project. The build artifacts will be stored in the dist/ directory.

Running unit tests

Run ng test to execute the unit tests via Karma.

Running end-to-end tests

Run ng e2e to execute the end-to-end tests via Protractor.

Further help

To get more help on the Angular CLI use ng help or go check out the Angular CLI README.

Integration

To integrate EOS Plugin into your project:

  1. Install eosjs library via npm and retrieve Eos instance from it.

  2. Get plugin instance by eosPluginLoaded event, like:

document.addEventListener('eosPluginLoaded', () => {})
  1. Request and cache identity like:
window.eosPlugin.requestIdentity({ host: 'jungle.eos.smartz.io', port: 443 })

This call opens the prompt window where user can select predifined network account. Returns an identity with publicKey and accounts information. The plugin caches user selection for future operations.

  1. Get cached or request identity like:
window.eosPlugin.getIdentity({ host: 'jungle.eos.smartz.io', port: 443 })
  1. Use EOS instance like:
window.eosPlugin.eos({ host: 'jungle.eos.smartz.io', port: 443 }, Eos, eosInstanceOptions)

Usage example:

import * as Eos from 'eosjs';

const network = {
  host: 'jungle.eos.smartz.io',
  port: 443
};

document.addEventListener('eosPluginLoaded', () => {
  const identity = window.eosPlugin.getIdentity(network);

  if (identity) {
    const { publicKey, accounts } = identity;

    const eos = window.eosPlugin.eos(network, Eos);

    eos.transaction(tr => {
      // transaction code here
    });
  }
});