diff options
Diffstat (limited to 'packages/taler-harness/src/harness')
-rw-r--r-- | packages/taler-harness/src/harness/harness.ts | 44 |
1 files changed, 16 insertions, 28 deletions
diff --git a/packages/taler-harness/src/harness/harness.ts b/packages/taler-harness/src/harness/harness.ts index 5c2133064..c08f3fa1d 100644 --- a/packages/taler-harness/src/harness/harness.ts +++ b/packages/taler-harness/src/harness/harness.ts @@ -28,6 +28,7 @@ import { AmountJson, Amounts, AmountString, + codecForMerchantReserveCreateConfirmation, Configuration, CoreApiResponse, createEddsaKeyPair, @@ -38,6 +39,7 @@ import { hash, j2s, Logger, + MerchantReserveCreateConfirmation, MerchantTemplateAddDetails, parsePaytoUri, stringToBytes, @@ -81,7 +83,11 @@ import { RemoteWallet, WalletNotificationWaiter, } from "@gnu-taler/taler-wallet-core/remote"; -import { createPlatformHttpLib } from "@gnu-taler/taler-util/http"; +import { + createPlatformHttpLib, + readSuccessResponseJsonOrErrorCode, + readSuccessResponseJsonOrThrow, +} from "@gnu-taler/taler-util/http"; const logger = new Logger("harness.ts"); @@ -1568,13 +1574,18 @@ export class MerchantApiClient { async createTippingReserve( req: CreateMerchantTippingReserveRequest, - ): Promise<CreateMerchantTippingReserveConfirmation> { + ): Promise<MerchantReserveCreateConfirmation> { const url = new URL("private/reserves", this.baseUrl); - const resp = await axios.post(url.href, req, { + const resp = await this.http.fetch(url.href, { + method: "POST", + body: req, headers: this.makeAuthHeader(), }); - // FIXME: validate - return resp.data; + const respData = readSuccessResponseJsonOrThrow( + resp, + codecForMerchantReserveCreateConfirmation(), + ); + return respData; } async getPrivateInstanceInfo(): Promise<any> { @@ -1719,21 +1730,6 @@ export namespace MerchantPrivateApi { }; } - export async function createTippingReserve( - merchantService: MerchantServiceInterface, - instance: string, - req: CreateMerchantTippingReserveRequest, - ): Promise<CreateMerchantTippingReserveConfirmation> { - const reqUrl = new URL( - `private/reserves`, - merchantService.makeInstanceBaseUrl(instance), - ); - // FIXME: Don't use axios! - const resp = await axios.post(reqUrl.href, req); - // FIXME: validate - return resp.data; - } - export async function queryTippingReserves( merchantService: MerchantServiceInterface, instance: string, @@ -1773,14 +1769,6 @@ export interface CreateMerchantTippingReserveRequest { wire_method: string; } -export interface CreateMerchantTippingReserveConfirmation { - // Public key identifying the reserve - reserve_pub: string; - - // Wire account of the exchange where to transfer the funds - payto_uri: string; -} - export class MerchantService implements MerchantServiceInterface { static fromExistingConfig(gc: GlobalTestState, name: string) { const cfgFilename = gc.testDir + `/merchant-${name}.conf`; |