@@ -119,6 +119,18 @@ export const getContract = ({ contractName, namespace }: IAddContractProps) => `
119
119
TOKEN-INFO-MANAGER
120
120
])
121
121
122
+ (defschema schema-set-compliance-parameters
123
+ supply-limit:decimal
124
+ max-investors:integer
125
+ max-balance-per-investor:decimal
126
+ )
127
+
128
+ (defcap SET-COMPLIANCE-PARAMETERS:bool (compliance:object{schema-set-compliance-parameters})
129
+ @doc "Event emitted when a compliance parameters is updated."
130
+ @event
131
+ true
132
+ )
133
+
122
134
;; compliance-compatible functions
123
135
124
136
(defun set-max-balance-per-investor (max-balance-per-investor:decimal)
@@ -151,7 +163,7 @@ export const getContract = ({ contractName, namespace }: IAddContractProps) => `
151
163
(update compliance-parameters ""
152
164
compliance-params
153
165
)
154
- (emit-event (SET-COMPLIANCE-PARAMETERS (read-msg ' compliance-parameters )))
166
+ (emit-event (SET-COMPLIANCE-PARAMETERS compliance-params))
155
167
)
156
168
)
157
169
@@ -209,18 +221,6 @@ export const getContract = ({ contractName, namespace }: IAddContractProps) => `
209
221
true
210
222
)
211
223
212
- (defschema schema-set-compliance-parameters
213
- supply-limit: decimal
214
- max-investors: integer
215
- max-balance-per-investor: decimal
216
- )
217
-
218
- (defcap SET-COMPLIANCE-PARAMETERS:bool (compliance:object{schema-set-compliance-parameters})
219
- @doc "Event emitted when a compliance parameters is updated."
220
- @event
221
- true
222
- )
223
-
224
224
(defcap RECOVERY-SUCCESS:bool (lost-wallet:string new-wallet:string investor-kadenaID:string)
225
225
@doc "Event emitted when a recovery process is successful."
226
226
@event
@@ -257,27 +257,16 @@ export const getContract = ({ contractName, namespace }: IAddContractProps) => `
257
257
true
258
258
)
259
259
260
- (defcap ROLE_UPDATED :bool (user-address:string roles:[string])
261
- @doc ""
260
+ (defcap AGENT-ROLES-UPDATED :bool (user-address:string roles:[string])
261
+ @doc "Event emitted when agent role is updated "
262
262
@event
263
263
true
264
264
)
265
265
266
-
267
-
268
266
;; grant caps
269
267
270
268
(defcap INTERNAL:bool () true)
271
269
(defcap MINT:bool () true)
272
- (defcap RECONCILE:bool (to:string amount:decimal)
273
- @doc "Event emitted when there are tokens minted to an investor"
274
- @event
275
- true
276
- )
277
-
278
-
279
-
280
-
281
270
(defcap BURN:bool () true)
282
271
(defcap FORCED-TRANSFER:bool () true )
283
272
(defcap UPDATE-SUPPLY:bool () true )
@@ -343,7 +332,7 @@ export const getContract = ({ contractName, namespace }: IAddContractProps) => `
343
332
true
344
333
)
345
334
346
- (defcap IDENTITY-REGISTERED:bool (investor-address:string identity:string)
335
+ (defcap IDENTITY-REGISTERED:bool (investor-address:string investor-guard:guard identity:string)
347
336
@doc "This event is emitted when an Identity is registered into the Identity Registry. \
348
337
\ The event is emitted by the 'register-identity' function. \
349
338
\ \`investor-address\` is the address of the investor's wallet. \
@@ -591,11 +580,12 @@ export const getContract = ({ contractName, namespace }: IAddContractProps) => `
591
580
592
581
(defun forced-transfer:bool (from:string to:string amount:decimal)
593
582
@doc "Force transfer tokens from one address to another."
594
- (with-capability (FORCED-TRANSFER from to amount )
583
+ (with-capability (FORCED-TRANSFER)
595
584
(with-capability (TRANSFER from to amount)
596
585
(only-agent TRANSFER-MANAGER)
597
586
(transfer-internal from to amount)
598
587
))
588
+ true
599
589
)
600
590
601
591
(defun mint :string (to:string amount:decimal)
@@ -645,11 +635,14 @@ export const getContract = ({ contractName, namespace }: IAddContractProps) => `
645
635
(defun batch-forced-transfer:bool (from-list:[string] to-list:[string] amounts:[decimal])
646
636
@doc "Perform batch forced transfer of tokens."
647
637
(only-agent TRANSFER-MANAGER)
648
- (map (lambda (idx:integer)
649
- (with-capability (TRANSFER (at idx from-list) (at idx to-list) (at idx amounts))
650
- (transfer-internal (at idx from-list) (at idx to-list) (at idx amounts))
638
+ (with-capability (FORCED-TRANSFER)
639
+ (map (lambda (idx:integer)
640
+ (with-capability (TRANSFER (at idx from-list) (at idx to-list) (at idx amounts))
641
+
642
+ (transfer-internal (at idx from-list) (at idx to-list) (at idx amounts))
643
+ )
651
644
)
652
- ) (enumerate 0 (- (length from-list) 1)) ) true
645
+ ) (enumerate 0 (- (length from-list) 1)) ) true
653
646
)
654
647
655
648
(defun batch-mint:bool (to-list:[string] amounts:[decimal])
@@ -667,21 +660,23 @@ export const getContract = ({ contractName, namespace }: IAddContractProps) => `
667
660
(defun batch-burn:bool (user-addresses:[string] amounts:[decimal])
668
661
@doc "Burn tokens from multiple addresses."
669
662
(only-agent SUPPLY-MODIFIER)
670
- (map (lambda (idx:integer)
671
- (with-capability (TRANSFER (at idx user-addresses) (zero-address) (at idx amounts))
672
- (burn-internal (at idx user-addresses) (at idx amounts))
663
+ (with-capability (BURN)
664
+ (map (lambda (idx:integer)
665
+ (with-capability (TRANSFER (at idx user-addresses) (zero-address) (at idx amounts))
666
+ (burn-internal (at idx user-addresses) (at idx amounts))
667
+ )
668
+ ) (enumerate 0 (- (length user-addresses) 1)) ) true
673
669
)
674
- ) (enumerate 0 (- (length user-addresses) 1)) ) true
675
670
)
676
671
677
- (defun batch-register-identity:bool (user-addresses:[string] identities:[string] countries:[integer])
672
+ (defun batch-register-identity:bool (user-addresses:[string] user-guards:[guard] identities:[string] countries:[integer])
678
673
@doc "Allows batch registration of identities. \
679
674
\ Requires that none of the users has an identity contract already registered. \
680
675
\ Only a wallet set as agent of the smart contract can call this function. \
681
676
\ Emits \`IDENTITY-REGISTERED\` events for each user address in the batch."
682
677
(only-agent WHITELIST-MANAGER)
683
678
(map (lambda (idx:integer)
684
- (register-identity-internal (at idx user-addresses) (at idx identities) (at idx countries))
679
+ (register-identity-internal (at idx user-addresses) (at idx user-guards) (at idx identities) (at idx countries))
685
680
) (enumerate 0 (- (length user-addresses) 1)) ) true
686
681
)
687
682
@@ -736,7 +731,6 @@ export const getContract = ({ contractName, namespace }: IAddContractProps) => `
736
731
(enforce-contains-identity to)
737
732
(with-capability (TRANSFER (zero-address) to amount)
738
733
(credit to amount)
739
-
740
734
(with-capability (UPDATE-SUPPLY)
741
735
(update-supply amount)
742
736
)
@@ -851,14 +845,25 @@ export const getContract = ({ contractName, namespace }: IAddContractProps) => `
851
845
@managed amount TRANSFER-mgr
852
846
853
847
(if (try false (enforce-guard (at 'guard (read users sender))))
854
- true
848
+ true ;; user signed for the transaction
849
+ ;;else
855
850
(if (try false (require-capability (MINT)))
851
+ ;; mint is in action
856
852
true
853
+ ;;else
857
854
(if (try false (require-capability (BURN)))
855
+ ;;burn is in action
858
856
true
857
+ ;; else
859
858
(if (try false (require-capability (FORCED-TRANSFER)))
859
+ ;; forced-transfer is in action
860
+ ;; else fail
861
+ true
862
+ (enforce false "TRANSFER failed")
860
863
)
861
- )))
864
+ )
865
+ )
866
+ )
862
867
863
868
(enforce (!= sender "") "valid sender")
864
869
(enforce (!= sender receiver) "same sender and receiver")
@@ -891,18 +896,18 @@ export const getContract = ({ contractName, namespace }: IAddContractProps) => `
891
896
(with-default-read users account
892
897
{"balance": -1.0}
893
898
{ "balance" := balance}
894
- (if (= balance -1.0)
895
- (update users account
896
- { "balance" : amount})
897
- (update users account
898
- { "balance" : (+ balance amount)})
899
- )
900
- (if (= account (zero-address))
901
- "Credit to Zero Address"
902
899
(if (= balance -1.0)
903
- [(add-investor-count)]
904
- "Credit successful"
900
+ (update users account
901
+ { "balance" : amount})
902
+ (update users account
903
+ { "balance" : (+ balance amount)})
905
904
)
905
+ (if (= account (zero-address))
906
+ "Credit to Zero Address"
907
+ (if (= balance -1.0)
908
+ (add-investor-count)
909
+ "Credit successful"
910
+ )
906
911
)
907
912
)
908
913
)
@@ -1118,15 +1123,14 @@ export const getContract = ({ contractName, namespace }: IAddContractProps) => `
1118
1123
@doc "Update agent roles"
1119
1124
(install-capability (ONLY-OWNER ""))
1120
1125
(install-capability (ONLY-AGENT AGENT-ADMIN))
1121
-
1122
1126
(if (try false (only-owner ""))
1123
1127
true
1124
1128
(only-agent AGENT-ADMIN))
1125
1129
(verify-agent-roles roles)
1126
1130
(update agents agent
1127
1131
{ 'roles: roles }
1128
1132
)
1129
- (emit-event (ROLE_UPDATED agent roles))
1133
+ (emit-event (AGENT-ROLES-UPDATED agent roles))
1130
1134
true
1131
1135
)
1132
1136
@@ -1147,23 +1151,31 @@ export const getContract = ({ contractName, namespace }: IAddContractProps) => `
1147
1151
(enumerate 0 (- (length roles) 1)))
1148
1152
))
1149
1153
1150
- (defun register-identity:bool (user-address:string identity:string country:integer)
1154
+ (defun register-identity:bool (user-address:string user-guard:guard identity:string country:integer)
1151
1155
@doc "Register an identity contract corresponding to a user address. \
1152
1156
\ Requires that the user doesn't have an identity contract already registered. \
1153
1157
\ Only a wallet set as agent of the smart contract can call this function. \
1154
1158
\ Emits an \`IDENTITY-REGISTERED\` event."
1155
1159
(only-agent WHITELIST-MANAGER)
1156
- (register-identity-internal user-address identity country)
1160
+ (register-identity-internal user-address user-guard identity country)
1157
1161
)
1158
1162
1159
- (defun register-identity-internal:bool (user-address:string identity:string country:integer)
1163
+ (defun register-identity-internal:bool (user-address:string user-guard:guard identity:string country:integer)
1160
1164
@doc "Register an identity contract corresponding to a user address. \
1161
1165
\ Requires that the user doesn't have an identity contract already registered. \
1162
1166
\ Only a wallet set as agent of the smart contract can call this function. \
1163
1167
\ Emits an \`IDENTITY-REGISTERED\` event."
1164
1168
(is-principal user-address)
1165
1169
(write identities user-address { "kadenaID":identity, "country":country, "active":true })
1166
- (emit-event (IDENTITY-REGISTERED user-address identity))
1170
+ (with-default-read users user-address
1171
+ { "balance": -2.0 }
1172
+ { "balance":=balance }
1173
+ (if (= balance -2.0)
1174
+ (create-account user-address user-guard)
1175
+ ""
1176
+ )
1177
+ )
1178
+ (emit-event (IDENTITY-REGISTERED user-address user-guard identity))
1167
1179
)
1168
1180
1169
1181
@@ -1303,5 +1315,6 @@ export const getContract = ({ contractName, namespace }: IAddContractProps) => `
1303
1315
(RWA.token-mapper.add-token-ref TOKEN-ID ${ namespace } .${ contractName } )
1304
1316
1305
1317
1318
+
1306
1319
(${ namespace } .${ contractName } .init "${ contractName } " "MVP" 0 "kadenaID" "0.0" [RWA.max-balance-compliance RWA.supply-limit-compliance] false (keyset-ref-guard "${ namespace } .admin-keyset"))
1307
1320
` ;
0 commit comments