Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Commit

Permalink
docs: split methods to sections
Browse files Browse the repository at this point in the history
  • Loading branch information
lamartire authored and Alex committed May 7, 2019
1 parent 8c7f19f commit dad17d2
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 24 deletions.
41 changes: 28 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,34 @@ web3.setProvider(provider);

### API

#### Instance methods

| Method | Params | Returns | Description |
| --------------------- | ---------------------------------------------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `auth` | | `Promise<{ status: boolean, message?: string }>` | Open Endpass Connect application for user authorization, return promise, which returns object with auth status. See [Errors handling](#errors-handling) for more details. |
| `logout` | | `Promise<Boolean>` | Makes logout request and returns status or throw error |
| `getAccountData` | | `Promise<{ activeAccount: string, activeNet: number }>` | Returns authorized user active account. |
| `getProvider` | `provider: Web3.Provider` | `Web3Provider` | Creates Web3 provider for injection in Web3 instance. |
| `getWidgetNode` | | `Promise<Element>` | Returns widget iframe node when it is available. |
| `setProviderSettings` | `{ activeAccount: string, activeNet: number }` | | Set user settings to the injected `web3` provider. |
| `openAccount` | | `Promise<{ type: string, payload?: { activeAccount: string, activeNet: number } }>` | Open Endpass Connect application for change user active address, network or logout |
| `mountWidget` | `{ position: string }` | `Promise<Element>` | Mounts Endpass widget on given position and returns iframe element |
| `unmountWidget` | | | Removes mounted Endpass widget |
#### Authorization

| Method | Params | Returns | Description |
| -------- | ------ | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `auth` | | `Promise<{ status: boolean, message?: string }>` | Open Endpass Connect application for user authorization, return promise, which returns object with auth status. See [Errors handling](#errors-handling) for more details. |
| `logout` | | `Promise<Boolean>` | Makes logout request and returns status or throw error |

#### Account

| Method | Params | Returns | Description |
| ---------------- | ------ | ----------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| `getAccountData` | | `Promise<{ activeAccount: string, activeNet: number }>` | Returns authorized user active account. |
| `openAccount` | | `Promise<{ type: string, payload?: { activeAccount: string, activeNet: number } }>` | Open Endpass Connect application for change user active address, network or logout |

#### Provider

| Method | Params | Returns | Description |
| --------------------- | ---------------------------------------------- | -------------- | ----------------------------------------------------- |
| `getProvider` | `provider: Web3.Provider` | `Web3Provider` | Creates Web3 provider for injection in Web3 instance. |
| `setProviderSettings` | `{ activeAccount: string, activeNet: number }` | | Set user settings to the injected `web3` provider. |

#### Widget

| Method | Params | Returns | Description |
| --------------- | ---------------------- | ------------------ | ------------------------------------------------------------------ |
| `getWidgetNode` | | `Promise<Element>` | Returns widget iframe node when it is available. |
| `mountWidget` | `{ position: string }` | `Promise<Element>` | Mounts Endpass widget on given position and returns iframe element |
| `unmountWidget` | | | Removes mounted Endpass widget |

### Interactions with current account

Expand Down
6 changes: 2 additions & 4 deletions src/Connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,8 @@ export default class Connect {
* @param {String} [params.position] Position of mounting widget
* @returns {Promise<Element>} Mounted widget iframe element
*/
async mountWidget(params) {
const res = await this[privateFields.context].mountWidget(params);

return res;
mountWidget(params) {
return this[privateFields.context].mountWidget(params);
}

/**
Expand Down
8 changes: 5 additions & 3 deletions src/Context.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,13 @@ export default class Context {
return this.inpageProvider.settings;
}

/**
* @param {Object} [parameters]
* @returns {Promise<Element>}
*/
async mountWidget(parameters) {
if (this.isWidgetMounted) {
const widgetNode = await this.bridge.getWidgetNode();

return widgetNode;
return this.bridge.getWidgetNode();
}

this.widgetMessenger = new CrossWindowMessenger({
Expand Down
10 changes: 6 additions & 4 deletions src/class/Bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,14 @@ export default class Bridge {
return res;
}

async mountWidget(parameters) {
/**
* @param {Object} [parameters]
* @returns {Element}
*/
mountWidget(parameters) {
this.initWidgetMessenger();

const res = await this.widget.mount(parameters);

return res;
return this.widget.mount(parameters);
}

unmountWidget() {
Expand Down

0 comments on commit dad17d2

Please sign in to comment.