Skip to content

Commit

Permalink
Adapt PR from #5 being merged
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jan 8, 2018
1 parent b79ca39 commit db323de
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 301 deletions.
54 changes: 0 additions & 54 deletions app/api.js

This file was deleted.

3 changes: 1 addition & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"electron-unhandled": "^1.0.0",
"electron-updater": "^2.18.2",
"electron-util": "^0.3.0",
"get-port": "^3.2.0",
"got": "^8.0.1"
"get-port": "^3.2.0"
},
"xo": false
}
16 changes: 10 additions & 6 deletions app/renderer/api.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
class Api {
export default class Api {
constructor({endpoint, passphrase}) {
if (!(endpoint && passphrase)) {
throw new Error('The `endpoint` and `passphrase` options are required');
}

this.endpoint = endpoint;
this.passphrase = passphrase;
}

_request(data) {
return fetch(this.endpoint, {
async _request(data) {
const response = await fetch(this.endpoint, {
method: 'post',
body: JSON.stringify(data)
}).then(res => res.json());
});

return response.json();
}

async _userpass() {
Expand Down Expand Up @@ -48,5 +54,3 @@ class Api {
return this.request({method: 'ticker'});
}
}

export default Api;
5 changes: 3 additions & 2 deletions app/renderer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ function initMarketmaker() {

electron.ipcRenderer.send('start-marketmaker', {passphrase: PASSPHRASE});

electron.ipcRenderer.on('marketmaker-started', async (event, port) => {
electron.ipcRenderer.on('marketmaker-started', async (event, port) => { // eslint-disable-line no-unused-vars
const api = new Api({
endpoint: `http://localhost:${port}`,
endpoint: `http://localhost:7783`,
// - endpoint: `http://localhost:${port}`,
passphrase: PASSPHRASE
});

Expand Down
Loading

0 comments on commit db323de

Please sign in to comment.