endpoint / CLI for accepting exchange ToS
This commit is contained in:
parent
afda237e5f
commit
c6d80b0128
@ -210,6 +210,16 @@ class AndroidWalletMessageHandler {
|
|||||||
const wallet = await this.wp.promise;
|
const wallet = await this.wp.promise;
|
||||||
return await wallet.getHistory();
|
return await wallet.getHistory();
|
||||||
}
|
}
|
||||||
|
case "getExchangeTos": {
|
||||||
|
const wallet = await this.wp.promise;
|
||||||
|
const exchangeBaseUrl = args.exchangeBaseUrl;
|
||||||
|
return wallet.getExchangeTos(exchangeBaseUrl);
|
||||||
|
}
|
||||||
|
case "setExchangeTosAccepted": {
|
||||||
|
const wallet = await this.wp.promise;
|
||||||
|
await wallet.acceptExchangeTermsOfService(args.exchangeBaseUrl, args.acceptedEtag);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
case "retryPendingNow": {
|
case "retryPendingNow": {
|
||||||
const wallet = await this.wp.promise;
|
const wallet = await this.wp.promise;
|
||||||
await wallet.runPending(true);
|
await wallet.runPending(true);
|
||||||
|
@ -373,6 +373,41 @@ exchangesCli
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
exchangesCli
|
||||||
|
.subcommand("exchangesAcceptTosCmd", "accept-tos", {
|
||||||
|
help: "Accept terms of service.",
|
||||||
|
})
|
||||||
|
.requiredArgument("url", clk.STRING, {
|
||||||
|
help: "Base URL of the exchange.",
|
||||||
|
})
|
||||||
|
.requiredArgument("etag", clk.STRING, {
|
||||||
|
help: "ToS version tag to accept",
|
||||||
|
})
|
||||||
|
.action(async (args) => {
|
||||||
|
await withWallet(args, async (wallet) => {
|
||||||
|
await wallet.acceptExchangeTermsOfService(
|
||||||
|
args.exchangesAcceptTosCmd.url,
|
||||||
|
args.exchangesAcceptTosCmd.etag
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
exchangesCli
|
||||||
|
.subcommand("exchangesTosCmd", "tos", {
|
||||||
|
help: "Show terms of service.",
|
||||||
|
})
|
||||||
|
.requiredArgument("url", clk.STRING, {
|
||||||
|
help: "Base URL of the exchange.",
|
||||||
|
})
|
||||||
|
.action(async (args) => {
|
||||||
|
await withWallet(args, async (wallet) => {
|
||||||
|
const tosResult = await wallet.getExchangeTos(
|
||||||
|
args.exchangesTosCmd.url,
|
||||||
|
);
|
||||||
|
console.log(JSON.stringify(tosResult, undefined, 2));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const advancedCli = walletCli.subcommand("advancedArgs", "advanced", {
|
const advancedCli = walletCli.subcommand("advancedArgs", "advanced", {
|
||||||
help:
|
help:
|
||||||
"Subcommands for advanced operations (only use if you know what you're doing!).",
|
"Subcommands for advanced operations (only use if you know what you're doing!).",
|
||||||
|
@ -513,3 +513,21 @@ export interface ManualWithdrawalDetails {
|
|||||||
*/
|
*/
|
||||||
paytoUris: string[];
|
paytoUris: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface GetExchangeTosResult {
|
||||||
|
/**
|
||||||
|
* Markdown version of the current ToS.
|
||||||
|
*/
|
||||||
|
tos: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Version tag of the current ToS.
|
||||||
|
*/
|
||||||
|
currentEtag: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Version tag of the last ToS that the user has accepted,
|
||||||
|
* if any.
|
||||||
|
*/
|
||||||
|
acceptedEtag: string | undefined;
|
||||||
|
}
|
||||||
|
@ -72,6 +72,7 @@ import {
|
|||||||
ExchangeListItem,
|
ExchangeListItem,
|
||||||
ExchangesListRespose,
|
ExchangesListRespose,
|
||||||
ManualWithdrawalDetails,
|
ManualWithdrawalDetails,
|
||||||
|
GetExchangeTosResult,
|
||||||
} from "./types/walletTypes";
|
} from "./types/walletTypes";
|
||||||
import { Logger } from "./util/logging";
|
import { Logger } from "./util/logging";
|
||||||
|
|
||||||
@ -500,6 +501,20 @@ export class Wallet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getExchangeTos(exchangeBaseUrl: string): Promise<GetExchangeTosResult> {
|
||||||
|
const exchange = await this.updateExchangeFromUrl(exchangeBaseUrl);
|
||||||
|
const tos = exchange.termsOfServiceText;
|
||||||
|
const currentEtag = exchange.termsOfServiceLastEtag;
|
||||||
|
if (!tos || !currentEtag) {
|
||||||
|
throw Error("exchange is in invalid state");
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
acceptedEtag: exchange.termsOfServiceAcceptedEtag,
|
||||||
|
currentEtag,
|
||||||
|
tos,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get detailed balance information, sliced by exchange and by currency.
|
* Get detailed balance information, sliced by exchange and by currency.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user