Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
signalapp
GitHub Repository: signalapp/Signal-iOS
Path: blob/main/SignalServiceKit/Payments/TSPaymentModels.h
1 views
1
//
2
// Copyright 2021 Signal Messenger, LLC
3
// SPDX-License-Identifier: AGPL-3.0-only
4
//
5
6
#import <SignalServiceKit/BaseModel.h>
7
8
NS_ASSUME_NONNULL_BEGIN
9
10
@class SignalServiceAddress;
11
12
typedef NS_ENUM(NSUInteger, TSPaymentCurrency) {
13
TSPaymentCurrencyUnknown = 0,
14
TSPaymentCurrencyMobileCoin = 1,
15
};
16
17
NSString *NSStringFromTSPaymentCurrency(TSPaymentCurrency value);
18
19
#pragma mark -
20
21
typedef NS_ENUM(NSUInteger, TSPaymentType) {
22
TSPaymentTypeIncomingPayment = 0,
23
TSPaymentTypeOutgoingPayment,
24
TSPaymentTypeOutgoingPaymentNotFromLocalDevice,
25
TSPaymentTypeIncomingUnidentified,
26
TSPaymentTypeOutgoingUnidentified,
27
TSPaymentTypeOutgoingTransfer,
28
TSPaymentTypeOutgoingDefragmentation,
29
TSPaymentTypeOutgoingDefragmentationNotFromLocalDevice,
30
TSPaymentTypeOutgoingRestored,
31
TSPaymentTypeIncomingRestored,
32
};
33
34
NSString *NSStringFromTSPaymentType(TSPaymentType value);
35
36
#pragma mark -
37
38
// This enum is essential to the correct functioning of
39
// the payments logic. Each value corresponds to a state
40
// of a state machine.
41
//
42
// The payments logic ushers payments through this
43
// state machine as quickly as possible.
44
//
45
// Each state implies which properties of a payment model
46
// should be present / can be trusted. See TSPaymentModel.isValid.
47
//
48
// NOTE: If you add or remove cases, you need to update
49
// paymentStatesToIgnore() and paymentStatesToProcess().
50
typedef NS_ENUM(NSUInteger, TSPaymentState) {
51
// Not (yet) in ledger.
52
TSPaymentStateOutgoingUnsubmitted = 0,
53
// Possibly in ledger.
54
TSPaymentStateOutgoingUnverified,
55
// In ledger.
56
TSPaymentStateOutgoingVerified,
57
// In ledger.
58
TSPaymentStateOutgoingSending,
59
// In ledger.
60
TSPaymentStateOutgoingSent,
61
// In ledger.
62
TSPaymentStateOutgoingComplete,
63
// Not in ledger.
64
// Should be ignored during reconciliation.
65
TSPaymentStateOutgoingFailed,
66
67
// Possibly in ledger.
68
TSPaymentStateIncomingUnverified,
69
// In ledger.
70
TSPaymentStateIncomingVerified,
71
// In ledger.
72
TSPaymentStateIncomingComplete,
73
// Not in ledger.
74
// Should be ignored during reconciliation.
75
TSPaymentStateIncomingFailed,
76
};
77
78
#pragma mark -
79
80
typedef NS_ENUM(NSUInteger, TSPaymentFailure) {
81
TSPaymentFailureNone = 0,
82
TSPaymentFailureUnknown,
83
TSPaymentFailureInsufficientFunds,
84
TSPaymentFailureValidationFailed,
85
TSPaymentFailureNotificationSendFailed,
86
// The payment model is malformed or completed.
87
TSPaymentFailureInvalid,
88
TSPaymentFailureExpired,
89
};
90
91
NSString *NSStringFromTSPaymentState(TSPaymentState value);
92
93
NSString *NSStringFromTSPaymentFailure(TSPaymentFailure value);
94
95
#pragma mark -
96
97
@interface TSPaymentAmount : NSObject <NSSecureCoding, NSCopying>
98
99
@property (nonatomic, readonly) TSPaymentCurrency currency;
100
@property (nonatomic, readonly) uint64_t picoMob;
101
102
- (instancetype)initWithCurrency:(TSPaymentCurrency)currency picoMob:(uint64_t)picoMob;
103
104
@end
105
106
#pragma mark -
107
108
@interface TSPaymentAddress : NSObject
109
110
@property (nonatomic, readonly) TSPaymentCurrency currency;
111
@property (nonatomic, readonly) NSData *mobileCoinPublicAddressData;
112
113
- (instancetype)initWithCurrency:(TSPaymentCurrency)currency
114
mobileCoinPublicAddressData:(NSData *)mobileCoinPublicAddressData;
115
116
@end
117
118
#pragma mark -
119
120
@interface TSPaymentNotification : NSObject <NSSecureCoding, NSCopying>
121
122
@property (nonatomic, readonly, nullable) NSString *memoMessage;
123
@property (nonatomic, readonly) NSData *mcReceiptData;
124
125
- (instancetype)initWithMemoMessage:(nullable NSString *)memoMessage mcReceiptData:(NSData *)mcReceiptData;
126
127
@end
128
129
#pragma mark -
130
131
@interface TSArchivedPaymentInfo : NSObject <NSSecureCoding, NSCopying>
132
133
@property (nonatomic, readonly, nullable) NSString *amount;
134
@property (nonatomic, readonly, nullable) NSString *fee;
135
@property (nonatomic, readonly, nullable) NSString *note;
136
137
- (instancetype)initWithAmount:(nullable NSString *)amount fee:(nullable NSString *)fee note:(nullable NSString *)note;
138
139
@end
140
141
NS_ASSUME_NONNULL_END
142
143