support exchange API version 7:0:0
This commit is contained in:
parent
bf1b350d44
commit
26d961ad63
@ -77,6 +77,7 @@ async function setExchangeError(
|
||||
baseUrl: string,
|
||||
err: OperationError,
|
||||
): Promise<void> {
|
||||
console.log(`last error for exchange ${baseUrl}:`, err);
|
||||
const mut = (exchange: ExchangeRecord) => {
|
||||
exchange.lastError = err;
|
||||
return exchange;
|
||||
|
@ -229,7 +229,10 @@ async function refreshMelt(
|
||||
return;
|
||||
}
|
||||
|
||||
const reqUrl = new URL("refresh/melt", refreshSession.exchangeBaseUrl);
|
||||
const reqUrl = new URL(
|
||||
`coins/${coin.coinPub}/melt`,
|
||||
refreshSession.exchangeBaseUrl,
|
||||
);
|
||||
const meltReq = {
|
||||
coin_pub: coin.coinPub,
|
||||
confirm_sig: refreshSession.confirmSig,
|
||||
@ -244,7 +247,10 @@ async function refreshMelt(
|
||||
console.log(`got status ${resp.status} for refresh/melt`);
|
||||
try {
|
||||
const respJson = await resp.json();
|
||||
console.log(`body of refresh/melt error response:`, JSON.stringify(respJson, undefined, 2));
|
||||
console.log(
|
||||
`body of refresh/melt error response:`,
|
||||
JSON.stringify(respJson, undefined, 2),
|
||||
);
|
||||
} catch (e) {
|
||||
console.log(`body of refresh/melt error response is not JSON`);
|
||||
}
|
||||
@ -344,7 +350,10 @@ async function refreshReveal(
|
||||
link_sigs: linkSigs,
|
||||
};
|
||||
|
||||
const reqUrl = new URL("refresh/reveal", refreshSession.exchangeBaseUrl);
|
||||
const reqUrl = new URL(
|
||||
`refreshes/${refreshSession.hash}/reveal`,
|
||||
refreshSession.exchangeBaseUrl,
|
||||
);
|
||||
logger.trace("reveal request:", req);
|
||||
|
||||
let resp;
|
||||
@ -523,7 +532,9 @@ async function processRefreshSession(
|
||||
refreshGroupId: string,
|
||||
coinIndex: number,
|
||||
) {
|
||||
logger.trace(`processing refresh session for coin ${coinIndex} of group ${refreshGroupId}`);
|
||||
logger.trace(
|
||||
`processing refresh session for coin ${coinIndex} of group ${refreshGroupId}`,
|
||||
);
|
||||
let refreshGroup = await ws.db.get(Stores.refreshGroups, refreshGroupId);
|
||||
if (!refreshGroup) {
|
||||
return;
|
||||
|
@ -423,7 +423,7 @@ async function processPurchaseApplyRefundImpl(
|
||||
console.log("sending refund permission", perm);
|
||||
// FIXME: not correct once we support multiple exchanges per payment
|
||||
const exchangeUrl = purchase.payReq.coins[0].exchange_url;
|
||||
const reqUrl = new URL("refund", exchangeUrl);
|
||||
const reqUrl = new URL(`coins/${perm.coin_pub}/refund`, exchangeUrl);
|
||||
const resp = await ws.http.postJson(reqUrl.href, req);
|
||||
console.log("sent refund permission");
|
||||
switch (resp.status) {
|
||||
|
@ -402,12 +402,11 @@ async function updateReserve(
|
||||
return;
|
||||
}
|
||||
|
||||
const reqUrl = new URL("reserve/status", reserve.exchangeBaseUrl);
|
||||
reqUrl.searchParams.set("reserve_pub", reservePub);
|
||||
const reqUrl = new URL(`reserves/${reservePub}`, reserve.exchangeBaseUrl);
|
||||
let resp;
|
||||
try {
|
||||
resp = await ws.http.get(reqUrl.href);
|
||||
console.log("got reserve/status response", await resp.json());
|
||||
console.log("got reserves/${RESERVE_PUB} response", await resp.json());
|
||||
if (resp.status === 404) {
|
||||
const m = "reserve not known to the exchange yet"
|
||||
throw new OperationFailedError(m, {
|
||||
|
@ -20,7 +20,7 @@
|
||||
*
|
||||
* Uses libtool's current:revision:age versioning.
|
||||
*/
|
||||
export const WALLET_EXCHANGE_PROTOCOL_VERSION = "6";
|
||||
export const WALLET_EXCHANGE_PROTOCOL_VERSION = "7:0:0";
|
||||
|
||||
/**
|
||||
* Cache breaker that is appended to queries such as /keys and /wire
|
||||
|
@ -197,7 +197,7 @@ async function processPlanchet(
|
||||
wd.reserve_pub = planchet.reservePub;
|
||||
wd.reserve_sig = planchet.withdrawSig;
|
||||
wd.coin_ev = planchet.coinEv;
|
||||
const reqUrl = new URL("reserve/withdraw", exchange.baseUrl).href;
|
||||
const reqUrl = new URL(`reserves/${planchet.reservePub}/withdraw`, exchange.baseUrl).href;
|
||||
const resp = await ws.http.postJson(reqUrl, wd);
|
||||
if (resp.status !== 200) {
|
||||
throw Error(`unexpected status ${resp.status} for withdraw`);
|
||||
|
Loading…
Reference in New Issue
Block a user