-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathTransaction.fs
72 lines (63 loc) · 2.27 KB
/
Transaction.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
namespace GWallet.Backend
open Newtonsoft.Json
type ITransactionDetails =
abstract member OriginMainAddress: string
abstract member Amount: decimal
abstract member Currency: Currency
abstract member DestinationAddress: string
type internal SignedTransactionDetails =
{
#if !NATIVE_SEGWIT
[<JsonProperty(PropertyName = "OriginAddress")>]
#endif
OriginMainAddress: string
Amount: decimal
Currency: Currency
DestinationAddress: string
}
interface ITransactionDetails with
member self.OriginMainAddress = self.OriginMainAddress
member self.Amount = self.Amount
member self.Currency = self.Currency
member self.DestinationAddress = self.DestinationAddress
type UnsignedTransactionProposal =
{
#if !NATIVE_SEGWIT
[<JsonProperty(PropertyName = "OriginAddress")>]
#endif
OriginMainAddress: string
Amount: TransferAmount;
DestinationAddress: string;
}
interface ITransactionDetails with
member self.OriginMainAddress = self.OriginMainAddress
member self.Amount = self.Amount.ValueToSend
member self.Currency = self.Amount.Currency
member self.DestinationAddress = self.DestinationAddress
// NOTE: I wanted to mark this type below `internal`, however that breaks JSON serialization
// in two possible ways: 1. silently (just returning {}), 2. with an exception
type UnsignedTransaction<'T when 'T:> IBlockchainFeeInfo> =
{
Proposal: UnsignedTransactionProposal;
Metadata: 'T;
Cache: DietCache;
}
member self.ToAbstract(): UnsignedTransaction<IBlockchainFeeInfo> =
{
Metadata = self.Metadata :> IBlockchainFeeInfo;
Cache = self.Cache;
Proposal = self.Proposal;
}
type SignedTransaction<'T when 'T:> IBlockchainFeeInfo> =
{
TransactionInfo: UnsignedTransaction<'T>;
RawTransaction: string;
}
member self.ToAbstract(): SignedTransaction<IBlockchainFeeInfo> =
{
TransactionInfo = self.TransactionInfo.ToAbstract();
RawTransaction = self.RawTransaction;
}
type ImportedTransaction<'T when 'T:> IBlockchainFeeInfo> =
| Unsigned of UnsignedTransaction<'T>
| Signed of SignedTransaction<'T>