taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 4f1f0d96fc3ad5061b610c3075262b00332e1d0d
parent 231eeef55c993c08aa9129d652efcb7a83ba53b3
Author: Sebastian <sebasjm@gmail.com>
Date:   Mon, 20 Jan 2025 02:19:54 -0300

limit operation type as enum

Diffstat:
Mpackages/taler-util/src/types-taler-exchange.ts | 57++++++++++++++++++++++++---------------------------------
Mpackages/taler-util/src/types-taler-kyc-aml.ts | 7++++---
2 files changed, 28 insertions(+), 36 deletions(-)

diff --git a/packages/taler-util/src/types-taler-exchange.ts b/packages/taler-util/src/types-taler-exchange.ts @@ -1510,7 +1510,7 @@ export interface MeasureInformation { // (reserve) "CLOSE", "AGGREGATE", // "TRANSACTION" or "REFUND". // New in protocol **v21**. - operation_type?: string; + operation_type?: LimitOperationType; // Can this measure be undertaken voluntarily? // Optional, default is false. @@ -1780,7 +1780,7 @@ export interface AccountKycStatus { limits?: AccountLimit[]; } -export type LimitOperationType = +export type LimitOperationType2 = | "WITHDRAW" | "DEPOSIT" | "MERGE" @@ -1789,7 +1789,16 @@ export type LimitOperationType = | "REFUND" | "CLOSE" | "TRANSACTION"; - +export enum LimitOperationType { + withdraw = "WITHDRAW", + deposit = "DEPOSIT", + merge = "MERGE", + aggregate = "AGGREGATE", + balance = "BALANCE", + refund = "REFUND", + close = "CLOSE", + transaction = "TRANSACTION", +} export interface AccountLimit { // Operation that is limited. operation_type: LimitOperationType; @@ -2016,17 +2025,9 @@ export interface AmlDecisionRequest { decision_time: Timestamp; } -export type KycRuleType = - | "WITHDRAW" - | "DEPOSIT" - | "AGGREGATE" - | "MERGE" - | "BALANCE" - | "CLOSE"; - export interface KycRule { // Type of operation to which the rule applies. - operation_type: KycRuleType; + operation_type: LimitOperationType; // The measures will be taken if the given // threshold is crossed over the given timeframe. @@ -2246,7 +2247,7 @@ export interface ZeroLimitedOperation { // (p2p) "MERGE", (wallet) "BALANCE", // (reserve) "CLOSE", "AGGREGATE", // "TRANSACTION" or "REFUND". - operation_type: string; + operation_type: LimitOperationType; } interface ExtensionManifest { @@ -2533,7 +2534,7 @@ export const codecForMeasureInformation = (): Codec<MeasureInformation> => .property("prog_name", codecForString()) .property("check_name", codecForString()) .property("context", codecForAny()) - .property("operation_type", codecOptional(codecForString())) + .property("operation_type", codecOptional(codecForOperationType)) .property("voluntary", codecOptional(codecForBoolean())) .build("TalerExchangeApi.MeasureInformation"); @@ -2593,17 +2594,7 @@ export const codecForLegitimizationRuleSet = (): Codec<LegitimizationRuleSet> => export const codecForKycRules = (): Codec<KycRule> => buildCodecForObject<KycRule>() - .property( - "operation_type", - codecForEither( - codecForConstString("WITHDRAW"), - codecForConstString("DEPOSIT"), - codecForConstString("MERGE"), - codecForConstString("BALANCE"), - codecForConstString("CLOSE"), - codecForConstString("AGGREGATE"), - ), - ) + .property("operation_type", codecForOperationType) .property("threshold", codecForAmountString()) .property("timeframe", codecForDuration) .property("measures", codecForList(codecForString())) @@ -2652,14 +2643,14 @@ export const codecForAccountKycStatus = (): Codec<AccountKycStatus> => .build("TalerExchangeApi.AccountKycStatus"); export const codecForOperationType = codecForEither( - codecForConstString("WITHDRAW"), - codecForConstString("DEPOSIT"), - codecForConstString("MERGE"), - codecForConstString("BALANCE"), - codecForConstString("CLOSE"), - codecForConstString("AGGREGATE"), - codecForConstString("TRANSACTION"), - codecForConstString("REFUND"), + codecForConstString(LimitOperationType.withdraw), + codecForConstString(LimitOperationType.deposit), + codecForConstString(LimitOperationType.merge), + codecForConstString(LimitOperationType.balance), + codecForConstString(LimitOperationType.close), + codecForConstString(LimitOperationType.aggregate), + codecForConstString(LimitOperationType.transaction), + codecForConstString(LimitOperationType.refund), ); export const codecForAccountLimit = (): Codec<AccountLimit> => diff --git a/packages/taler-util/src/types-taler-kyc-aml.ts b/packages/taler-util/src/types-taler-kyc-aml.ts @@ -21,6 +21,7 @@ import { codecForAny, codecForList, codecOptional, + LimitOperationType, } from "./index.js"; import { AmountString, @@ -266,7 +267,7 @@ export interface KycRule { // (p2p) "MERGE", (wallet) "BALANCE", // (reserve) "CLOSE", "AGGREGATE", // "TRANSACTION" or "REFUND". - operation_type: string; + operation_type: LimitOperationType; // The measures will be taken if the given // threshold is crossed over the given timeframe. @@ -331,7 +332,7 @@ export interface MeasureInformation { // (reserve) "CLOSE", "AGGREGATE", // "TRANSACTION" or "REFUND". // New in protocol **v21**. - operation_type?: string; + operation_type?: LimitOperationType; // Can this measure be undertaken voluntarily? // Optional, default is false. @@ -341,7 +342,7 @@ export interface MeasureInformation { export const codecForAmlProgramInput = (): Codec<AmlProgramInput> => buildCodecForObject<AmlProgramInput>() - .property("aml_history", codecOptional( codecForList(codecForAny()))) + .property("aml_history", codecOptional(codecForList(codecForAny()))) .property("kyc_history", codecOptional(codecForList(codecForAny()))) .property("attributes", codecOptional(codecForAccountProperties())) .property("context", codecOptional(codecForAny()))