Skip to content

Commit ecd149e

Browse files
authored
proxy to shakedex api for https (#317)
1 parent 97f76f2 commit ecd149e

File tree

4 files changed

+30
-13
lines changed

4 files changed

+30
-13
lines changed

app/background/shakedex/client.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ export const clientStub = ipcRendererInjector => makeClient(ipcRendererInjector,
1313
'downloadProofs',
1414
'restoreOneListing',
1515
'restoreOneFill',
16+
'getExchangeAuctions',
17+
'listAuction',
1618
]);

app/background/shakedex/service.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@ import path from "path";
2121
import {app} from "electron";
2222
import bdb from "bdb";
2323
import {auctionSchema, finalizeLockScheme, fulfillmentSchema, nameLockSchema, paramSchema} from "../../utils/shakedex";
24+
import {Client} from "bcurl";
2425

2526
let db;
2627

28+
const client = new Client({
29+
host: 'api.shakedex.com',
30+
ssl: true,
31+
});
32+
2733
export async function openDB() {
2834
if (db) {
2935
return;
@@ -71,6 +77,23 @@ export async function iteratePrefix(prefix, cb) {
7177
await iter.each(cb);
7278
}
7379

80+
export async function getExchangeAuctions(currentPage = 1) {
81+
return await client.get(`api/v1/auctions?page=${currentPage}&per_page=20`);
82+
}
83+
84+
export async function listAuction(auction) {
85+
const resp = await fetch(`https://api.shakedex.com/api/v1/auctions`, {
86+
method: 'POST',
87+
headers: {
88+
'Content-Type': 'application/json'
89+
},
90+
body: JSON.stringify({
91+
auction,
92+
}),
93+
});
94+
return resp.json();
95+
}
96+
7497
export async function fulfillSwap(auction, bid, passphrase) {
7598
const context = getContext(passphrase);
7699
const proof = new SwapProof({
@@ -392,6 +415,8 @@ const methods = {
392415
downloadProofs,
393416
restoreOneListing,
394417
restoreOneFill,
418+
getExchangeAuctions,
419+
listAuction,
395420
};
396421

397422
export async function start(server) {

app/ducks/exchange.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export const getExchangeAuctions = () => async (dispatch, getState) => {
117117
} = getState();
118118

119119
try {
120-
auctions = await client.get(`api/v1/auctions?page=${currentPage}&per_page=20`);
120+
auctions = await shakedex.getExchangeAuctions(currentPage);
121121
} catch (e) {
122122
dispatch({
123123
type: GET_EXCHANGE_AUCTIONS_ERR,
@@ -488,17 +488,7 @@ export const launchExchangeAuction = (nameLock, overrideParams) => async (dispat
488488

489489
export const submitToShakedex = (auction) => async dispatch => {
490490
try {
491-
// use fetch here since bcurl crashes
492-
const res = await fetch(`https://api.shakedex.com/api/v1/auctions`, {
493-
method: 'POST',
494-
headers: {
495-
'Content-Type': 'application/json'
496-
},
497-
body: JSON.stringify({
498-
auction,
499-
}),
500-
});
501-
const json = await res.json();
491+
const json = await shakedex.listAuction(auction);
502492
if (json.error) {
503493
dispatch(showError(json.error.message));
504494
return;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "bob-wallet",
33
"productName": "Bob",
44
"author": "Kyokan Group, Inc.",
5-
"version": "0.7.0-rc.3",
5+
"version": "0.7.0-rc.4",
66
"description": "A Handshake wallet and auction manager.",
77
"scripts": {
88
"build": "./scripts/package.sh",

0 commit comments

Comments
 (0)