diff options
author | Florian Dold <florian@dold.me> | 2023-10-10 15:08:59 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-10-10 15:08:59 +0200 |
commit | 47fdfc64a2e6a99a44f87974e608bdac5de83759 (patch) | |
tree | 3c4bcc4e7ee813a9c7e28c7205f573eac42e2332 /packages/taler-wallet-core | |
parent | adda4f8ce38ce030f55855bc0d66443d08153480 (diff) | |
download | wallet-core-47fdfc64a2e6a99a44f87974e608bdac5de83759.tar.xz |
wallet-core: return mock currency specification for KUDOS and TESTKUDOS
Diffstat (limited to 'packages/taler-wallet-core')
-rw-r--r-- | packages/taler-wallet-core/src/wallet-api-types.ts | 16 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/wallet.ts | 52 |
2 files changed, 51 insertions, 17 deletions
diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts b/packages/taler-wallet-core/src/wallet-api-types.ts index 375e0a1b2..fadc7aa7f 100644 --- a/packages/taler-wallet-core/src/wallet-api-types.ts +++ b/packages/taler-wallet-core/src/wallet-api-types.ts @@ -61,8 +61,8 @@ import { GetAmountRequest, GetBalanceDetailRequest, GetContractTermsDetailsRequest, - GetCurrencyInfoRequest, - GetCurrencyInfoResponse, + GetCurrencySpecificationRequest, + GetCurrencySpecificationResponse, GetExchangeTosRequest, GetExchangeTosResult, GetPlanForOperationRequest, @@ -218,7 +218,7 @@ export enum WalletApiOperation { TestingWaitRefreshesFinal = "testingWaitRefreshesFinal", TestingWaitTransactionState = "testingWaitTransactionState", TestingSetTimetravel = "testingSetTimetravel", - GetScopedCurrencyInfo = "getScopedCurrencyInfo", + GetCurrencySpecification = "getCurrencySpecification", ListStoredBackups = "listStoredBackups", CreateStoredBackup = "createStoredBackup", DeleteStoredBackup = "deleteStoredBackup", @@ -627,10 +627,10 @@ export type ListCurrenciesOp = { response: WalletCurrencyInfo; }; -export type GetScopedCurrencyInfoOp = { - op: WalletApiOperation.GetScopedCurrencyInfo; - request: GetCurrencyInfoRequest; - response: GetCurrencyInfoResponse; +export type GetCurrencySpecificationOp = { + op: WalletApiOperation.GetCurrencySpecification; + request: GetCurrencySpecificationRequest; + response: GetCurrencySpecificationResponse; }; // group: Deposits @@ -1136,7 +1136,7 @@ export type WalletOperations = { [WalletApiOperation.TestingWaitRefreshesFinal]: TestingWaitRefreshesFinal; [WalletApiOperation.TestingSetTimetravel]: TestingSetTimetravelOp; [WalletApiOperation.TestingWaitTransactionState]: TestingWaitTransactionStateOp; - [WalletApiOperation.GetScopedCurrencyInfo]: GetScopedCurrencyInfoOp; + [WalletApiOperation.GetCurrencySpecification]: GetCurrencySpecificationOp; [WalletApiOperation.CreateStoredBackup]: CreateStoredBackupsOp; [WalletApiOperation.ListStoredBackups]: ListStoredBackupsOp; [WalletApiOperation.DeleteStoredBackup]: DeleteStoredBackupOp; diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index ead0ee407..42293735e 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -117,7 +117,7 @@ import { sampleWalletCoreTransactions, validateIban, codecForSharePaymentRequest, - GetCurrencyInfoResponse, + GetCurrencySpecificationResponse, codecForGetCurrencyInfoRequest, CreateStoredBackupResponse, StoredBackupList, @@ -1427,16 +1427,50 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>( await waitTransactionState(ws, req.transactionId, req.txState); return {}; } - case WalletApiOperation.GetScopedCurrencyInfo: { + case WalletApiOperation.GetCurrencySpecification: { // Ignore result, just validate in this mock implementation - codecForGetCurrencyInfoRequest().decode(payload); - const resp: GetCurrencyInfoResponse = { - decimalSeparator: ",", - isCurrencyNameLeading: false, - numFractionalDigits: 2, - numTinyDigits: 1, + const req = codecForGetCurrencyInfoRequest().decode(payload); + // Hard-coded mock for KUDOS and TESTKUDOS + if (req.scope.currency === "KUDOS") { + const kudosResp: GetCurrencySpecificationResponse = { + currencySpecification: { + decimal_separator: ",", + name: "Kudos (Taler Demonstrator)", + fractional_input_digits: 2, + fractional_normal_digits: 2, + fractional_trailing_zero_digits: 2, + is_currency_name_leading: true, + alt_unit_names: { + "0": "ク", + }, + }, + }; + } else if (req.scope.currency === "TESTKUDOS") { + const testkudosResp: GetCurrencySpecificationResponse = { + currencySpecification: { + decimal_separator: ",", + name: "Test (Taler Unstable Demonstrator)", + fractional_input_digits: 0, + fractional_normal_digits: 0, + fractional_trailing_zero_digits: 0, + is_currency_name_leading: true, + alt_unit_names: {}, + }, + }; + return testkudosResp; + } + const defaultResp: GetCurrencySpecificationResponse = { + currencySpecification: { + decimal_separator: ",", + name: "Unknown", + fractional_input_digits: 2, + fractional_normal_digits: 2, + fractional_trailing_zero_digits: 2, + is_currency_name_leading: true, + alt_unit_names: {}, + }, }; - return resp; + return defaultResp; } case WalletApiOperation.ImportBackupRecovery: { const req = codecForAny().decode(payload); |