12 | | - | case t: TransferTransaction => |
---|
13 | | - | let data = getInteger(admin, toBase58String(t.sender.bytes)) |
---|
14 | | - | let amount = t.amount |
---|
15 | | - | let isUser = getInteger(admin, toBase58String(addressFromRecipient(t.recipient).bytes)) |
---|
16 | | - | if (!(isDefined(data))) |
---|
17 | | - | then throw("You are not a registered member. You cannot transfer this SmartAsset!") |
---|
18 | | - | else if ((data == KYCPending)) |
---|
19 | | - | then throw("KYC Pending. You cannot transfer this SmartAsset") |
---|
20 | | - | else if ((data == KYCVer1)) |
---|
21 | | - | then if ((t.recipient == gateway)) |
---|
22 | | - | then true |
---|
23 | | - | else if (if (if ((isUser == KYCVer1)) |
---|
24 | | - | then true |
---|
25 | | - | else (isUser == KYCVer2)) |
---|
26 | | - | then true |
---|
27 | | - | else (isUser == isMerchant)) |
---|
28 | | - | then if ((maxAmount >= amount)) |
---|
29 | | - | then true |
---|
30 | | - | else throw("Cannot transfer please verify your acount. Amount is too much!") |
---|
31 | | - | else if ((isUser == KYCPending)) |
---|
32 | | - | then throw("The recipient is in KYC pending status. You cannot transfer this SmartAsset") |
---|
33 | | - | else if ((isUser == banned)) |
---|
34 | | - | then throw("The recipient is banned. You cannot transfer this SmartAsset") |
---|
35 | | - | else throw("Undefined situation!") |
---|
36 | | - | else if ((data == KYCVer2)) |
---|
37 | | - | then if (isDefined(isUser)) |
---|
38 | | - | then if ((isUser == KYCVer1)) |
---|
39 | | - | then if ((maxAmount >= amount)) |
---|
40 | | - | then true |
---|
41 | | - | else throw("Cannot transfer please verify your acount. Amount is too much!") |
---|
42 | | - | else if ((isUser == KYCPending)) |
---|
43 | | - | then throw("The recipient is in KYC pending status. You cannot transfer this SmartAsset") |
---|
44 | | - | else if (if ((isUser == KYCVer2)) |
---|
45 | | - | then true |
---|
46 | | - | else (isUser == isMerchant)) |
---|
47 | | - | then true |
---|
48 | | - | else if ((isUser == banned)) |
---|
49 | | - | then throw("The recipient is banned. You cannot transfer this SmartAsset") |
---|
50 | | - | else throw("Undefined situation!") |
---|
51 | | - | else throw("The recipient is not authorized to possess this SmartAsset!") |
---|
52 | | - | else if ((data == banned)) |
---|
53 | | - | then throw("Your acount has been suspended!") |
---|
54 | | - | else if ((data == isMerchant)) |
---|
55 | | - | then if ((t.recipient == gateway)) |
---|
56 | | - | then true |
---|
57 | | - | else throw("Cannot transfer this asset to another account.") |
---|
58 | | - | else throw("Undefined situation!") |
---|
59 | | - | case mtt: MassTransferTransaction => |
---|
60 | | - | let data = getInteger(admin, toBase58String(mtt.sender.bytes)) |
---|
61 | | - | let amount = mtt.totalAmount |
---|
62 | | - | let assetId = extract(mtt.assetId) |
---|
63 | | - | let transferCount = mtt.transferCount |
---|
64 | | - | let firstRecipient = mtt.transfers[0].recipient |
---|
65 | | - | let secondRecipient = mtt.transfers[1].recipient |
---|
66 | | - | let firstAmount = mtt.transfers[0].amount |
---|
67 | | - | let secondAmount = mtt.transfers[1].amount |
---|
68 | | - | let issueTransaction = transactionById(assetId) |
---|
69 | | - | let isUser = getInteger(admin, toBase58String(addressFromRecipient(secondRecipient).bytes)) |
---|
70 | | - | if (!(isDefined(isUser))) |
---|
71 | | - | then false |
---|
72 | | - | else if ((transferCount > 2)) |
---|
73 | | - | then throw("not allowed") |
---|
74 | | - | else if (!(isDefined(data))) |
---|
75 | | - | then throw("You are not a registered member. You cannot transfer this SmartAsset!") |
---|
76 | | - | else if ((data == KYCPending)) |
---|
77 | | - | then throw("KYC Pending. You cannot transfer this SmartAsset") |
---|
78 | | - | else if ((data == KYCVer1)) |
---|
79 | | - | then if ((firstRecipient != gateway)) |
---|
80 | | - | then throw("First recipient must be the issuer") |
---|
81 | | - | else if (if ((isUser == KYCVer1)) |
---|
82 | | - | then true |
---|
83 | | - | else (isUser == KYCVer2)) |
---|
84 | | - | then if ((maxAmount >= amount)) |
---|
85 | | - | then match issueTransaction { |
---|
86 | | - | case issueTx: IssueTransaction => |
---|
87 | | - | let issuerAddress = addressFromPublicKey(issueTx.senderPublicKey) |
---|
88 | | - | let taxSize = extract(getInteger(issuerAddress, toBase58String(assetId))) |
---|
89 | | - | if ((firstRecipient == issuerAddress)) |
---|
90 | | - | then (firstAmount >= ((secondAmount / 1000) * taxSize)) |
---|
91 | | - | else false |
---|
92 | | - | case _ => |
---|
93 | | - | false |
---|
94 | | - | } |
---|
95 | | - | else throw("Cannot transfer please verify your acount. Amount is too much!") |
---|
96 | | - | else if ((isUser == KYCPending)) |
---|
97 | | - | then throw("The recipient is in KYC pending status. You cannot transfer this SmartAsset") |
---|
98 | | - | else if ((isUser == banned)) |
---|
99 | | - | then throw("The recipient is banned. You cannot transfer this SmartAsset") |
---|
100 | | - | else if ((isUser == isMerchant)) |
---|
101 | | - | then throw("Merchants cannot recieve mass payments") |
---|
102 | | - | else throw("Undefined situation!") |
---|
103 | | - | else if ((data == KYCVer2)) |
---|
104 | | - | then if (isDefined(isUser)) |
---|
105 | | - | then if ((isUser == KYCVer1)) |
---|
106 | | - | then if ((maxAmount >= amount)) |
---|
107 | | - | then match issueTransaction { |
---|
108 | | - | case issueTx: IssueTransaction => |
---|
109 | | - | let issuerAddress = addressFromPublicKey(issueTx.senderPublicKey) |
---|
110 | | - | let taxSize = extract(getInteger(issuerAddress, toBase58String(assetId))) |
---|
111 | | - | if ((firstRecipient == issuerAddress)) |
---|
112 | | - | then (firstAmount >= ((secondAmount / 1000) * taxSize)) |
---|
113 | | - | else false |
---|
114 | | - | case _ => |
---|
115 | | - | false |
---|
116 | | - | } |
---|
117 | | - | else throw("Cannot transfer please verify your acount. Amount is too much!") |
---|
118 | | - | else if ((isUser == KYCVer1)) |
---|
119 | | - | then throw("The recipient is in KYC pending status. You cannot transfer this SmartAsset") |
---|
120 | | - | else if ((isUser == KYCVer2)) |
---|
121 | | - | then match issueTransaction { |
---|
122 | | - | case issueTx: IssueTransaction => |
---|
123 | | - | let issuerAddress = addressFromPublicKey(issueTx.senderPublicKey) |
---|
124 | | - | let taxSize = extract(getInteger(issuerAddress, toBase58String(assetId))) |
---|
125 | | - | if ((firstRecipient == issuerAddress)) |
---|
126 | | - | then (firstAmount >= ((secondAmount / 1000) * taxSize)) |
---|
127 | | - | else false |
---|
128 | | - | case _ => |
---|
129 | | - | false |
---|
130 | | - | } |
---|
131 | | - | else if ((isUser == banned)) |
---|
132 | | - | then throw("The recipient is banned. You cannot transfer this SmartAsset") |
---|
133 | | - | else if ((isUser == isMerchant)) |
---|
134 | | - | then throw("Merchants cannot recieve mass payments") |
---|
135 | | - | else throw("Undefined situation!") |
---|
136 | | - | else throw("The recipient is not authorized to possess this SmartAsset!") |
---|
137 | | - | else if ((data == banned)) |
---|
138 | | - | then throw("Your acount has been suspended!") |
---|
139 | | - | else if ((data == isMerchant)) |
---|
140 | | - | then throw("Merchant account cannot perform mass transfer") |
---|
141 | | - | else throw("Undefined situation!") |
---|
142 | | - | case ex: ExchangeTransaction => |
---|
143 | | - | false |
---|
144 | | - | case b: BurnTransaction => |
---|
145 | | - | false |
---|
146 | | - | case script: SetAssetScriptTransaction => |
---|
147 | | - | if ((script.sender == admin)) |
---|
148 | | - | then true |
---|
149 | | - | else throw("Admin operation only..") |
---|