Path: blob/main/SignalServiceKit/Payments/TSPaymentModels.h
1 views
//1// Copyright 2021 Signal Messenger, LLC2// SPDX-License-Identifier: AGPL-3.0-only3//45#import <SignalServiceKit/BaseModel.h>67NS_ASSUME_NONNULL_BEGIN89@class SignalServiceAddress;1011typedef NS_ENUM(NSUInteger, TSPaymentCurrency) {12TSPaymentCurrencyUnknown = 0,13TSPaymentCurrencyMobileCoin = 1,14};1516NSString *NSStringFromTSPaymentCurrency(TSPaymentCurrency value);1718#pragma mark -1920typedef NS_ENUM(NSUInteger, TSPaymentType) {21TSPaymentTypeIncomingPayment = 0,22TSPaymentTypeOutgoingPayment,23TSPaymentTypeOutgoingPaymentNotFromLocalDevice,24TSPaymentTypeIncomingUnidentified,25TSPaymentTypeOutgoingUnidentified,26TSPaymentTypeOutgoingTransfer,27TSPaymentTypeOutgoingDefragmentation,28TSPaymentTypeOutgoingDefragmentationNotFromLocalDevice,29TSPaymentTypeOutgoingRestored,30TSPaymentTypeIncomingRestored,31};3233NSString *NSStringFromTSPaymentType(TSPaymentType value);3435#pragma mark -3637// This enum is essential to the correct functioning of38// the payments logic. Each value corresponds to a state39// of a state machine.40//41// The payments logic ushers payments through this42// state machine as quickly as possible.43//44// Each state implies which properties of a payment model45// should be present / can be trusted. See TSPaymentModel.isValid.46//47// NOTE: If you add or remove cases, you need to update48// paymentStatesToIgnore() and paymentStatesToProcess().49typedef NS_ENUM(NSUInteger, TSPaymentState) {50// Not (yet) in ledger.51TSPaymentStateOutgoingUnsubmitted = 0,52// Possibly in ledger.53TSPaymentStateOutgoingUnverified,54// In ledger.55TSPaymentStateOutgoingVerified,56// In ledger.57TSPaymentStateOutgoingSending,58// In ledger.59TSPaymentStateOutgoingSent,60// In ledger.61TSPaymentStateOutgoingComplete,62// Not in ledger.63// Should be ignored during reconciliation.64TSPaymentStateOutgoingFailed,6566// Possibly in ledger.67TSPaymentStateIncomingUnverified,68// In ledger.69TSPaymentStateIncomingVerified,70// In ledger.71TSPaymentStateIncomingComplete,72// Not in ledger.73// Should be ignored during reconciliation.74TSPaymentStateIncomingFailed,75};7677#pragma mark -7879typedef NS_ENUM(NSUInteger, TSPaymentFailure) {80TSPaymentFailureNone = 0,81TSPaymentFailureUnknown,82TSPaymentFailureInsufficientFunds,83TSPaymentFailureValidationFailed,84TSPaymentFailureNotificationSendFailed,85// The payment model is malformed or completed.86TSPaymentFailureInvalid,87TSPaymentFailureExpired,88};8990NSString *NSStringFromTSPaymentState(TSPaymentState value);9192NSString *NSStringFromTSPaymentFailure(TSPaymentFailure value);9394#pragma mark -9596@interface TSPaymentAmount : NSObject <NSSecureCoding, NSCopying>9798@property (nonatomic, readonly) TSPaymentCurrency currency;99@property (nonatomic, readonly) uint64_t picoMob;100101- (instancetype)initWithCurrency:(TSPaymentCurrency)currency picoMob:(uint64_t)picoMob;102103@end104105#pragma mark -106107@interface TSPaymentAddress : NSObject108109@property (nonatomic, readonly) TSPaymentCurrency currency;110@property (nonatomic, readonly) NSData *mobileCoinPublicAddressData;111112- (instancetype)initWithCurrency:(TSPaymentCurrency)currency113mobileCoinPublicAddressData:(NSData *)mobileCoinPublicAddressData;114115@end116117#pragma mark -118119@interface TSPaymentNotification : NSObject <NSSecureCoding, NSCopying>120121@property (nonatomic, readonly, nullable) NSString *memoMessage;122@property (nonatomic, readonly) NSData *mcReceiptData;123124- (instancetype)initWithMemoMessage:(nullable NSString *)memoMessage mcReceiptData:(NSData *)mcReceiptData;125126@end127128#pragma mark -129130@interface TSArchivedPaymentInfo : NSObject <NSSecureCoding, NSCopying>131132@property (nonatomic, readonly, nullable) NSString *amount;133@property (nonatomic, readonly, nullable) NSString *fee;134@property (nonatomic, readonly, nullable) NSString *note;135136- (instancetype)initWithAmount:(nullable NSString *)amount fee:(nullable NSString *)fee note:(nullable NSString *)note;137138@end139140NS_ASSUME_NONNULL_END141142143