mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2024-11-22 09:46:58 +01:00
driver remove obsolote files
This commit is contained in:
parent
7ac7673bc6
commit
9d0f4f5f72
@ -1,13 +0,0 @@
|
||||
/* eslint-disable prefer-template */
|
||||
import { API_PATH } from './application_constants';
|
||||
|
||||
|
||||
const ApiUrls = {
|
||||
'transactions': API_PATH + 'transactions',
|
||||
'transactions_detail': API_PATH + 'transactions/%(txId)s',
|
||||
'outputs': API_PATH + 'outputs',
|
||||
'statuses': API_PATH + 'statuses'
|
||||
};
|
||||
|
||||
|
||||
export default ApiUrls;
|
@ -1,8 +0,0 @@
|
||||
export const FLASK_BASE_URL = process.env.FLASK_BASE_URL;
|
||||
export const BDB_SERVER_URL = process.env.BDB_SERVER_URL;
|
||||
export const API_PATH = `${BDB_SERVER_URL}/api/v1/`;
|
||||
|
||||
export default {
|
||||
API_PATH,
|
||||
FLASK_BASE_URL,
|
||||
};
|
@ -1,63 +0,0 @@
|
||||
import request from './request';
|
||||
import ApiUrls from '../constants/api_urls';
|
||||
|
||||
|
||||
export function requestTransaction(txId) {
|
||||
return request(ApiUrls['transactions_detail'], {
|
||||
urlTemplateSpec: {
|
||||
txId
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function postTransaction(transaction) {
|
||||
return request(ApiUrls['transactions'], {
|
||||
method: 'POST',
|
||||
jsonBody: transaction
|
||||
})
|
||||
}
|
||||
|
||||
export function listTransactions({ asset_id, operation }) {
|
||||
return request(ApiUrls['transactions'], {
|
||||
query: {
|
||||
asset_id,
|
||||
operation
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function pollStatusAndFetchTransaction(transaction) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const timer = setInterval(() => {
|
||||
requestStatus(transaction.id)
|
||||
.then((res) => {
|
||||
console.log('Fetched transaction status:', res);
|
||||
if (res.status === 'valid') {
|
||||
clearInterval(timer);
|
||||
requestTransaction(transaction.id)
|
||||
.then((res) => {
|
||||
console.log('Fetched transaction:', res);
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
});
|
||||
}, 500)
|
||||
})
|
||||
}
|
||||
|
||||
export function listOutputs({ public_key, unspent }) {
|
||||
return request(ApiUrls['outputs'], {
|
||||
query: {
|
||||
public_key,
|
||||
unspent
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function requestStatus(tx_id) {
|
||||
return request(ApiUrls['statuses'], {
|
||||
query: {
|
||||
tx_id
|
||||
}
|
||||
});
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
import { request as baseRequest, sanitize } from 'js-utility-belt/es6';
|
||||
|
||||
import ApiUrls from '../constants/api_urls';
|
||||
|
||||
|
||||
const DEFAULT_REQUEST_CONFIG = {
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Accept': 'application/json'
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Small wrapper around js-utility-belt's request that provides url resolving, default settings, and
|
||||
* response handling.
|
||||
*/
|
||||
export default function request(url, config = {}) {
|
||||
// Load default fetch configuration and remove any falsy query parameters
|
||||
const requestConfig = Object.assign({}, DEFAULT_REQUEST_CONFIG, config, {
|
||||
query: config.query && sanitize(config.query)
|
||||
});
|
||||
let apiUrl = url;
|
||||
|
||||
if (requestConfig.jsonBody) {
|
||||
requestConfig.headers = Object.assign({}, requestConfig.headers, {
|
||||
'Content-Type': 'application/json'
|
||||
});
|
||||
}
|
||||
if (!url) {
|
||||
return Promise.reject(new Error('Request was not given a url.'));
|
||||
} else if (!url.match(/^http/)) {
|
||||
apiUrl = ApiUrls[url];
|
||||
if (!apiUrl) {
|
||||
return Promise.reject(new Error(`Request could not find a url mapping for "${url}"`));
|
||||
}
|
||||
}
|
||||
|
||||
return baseRequest(apiUrl, requestConfig)
|
||||
.then((res) => res.json())
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
throw err;
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user