@Nimra_Fatima
I’m guessing you’re missing indentation for the choice RevokeIssuer in the Issuer template (and/or possibly elsewhere). I get similar error to the one you mentioned (error: parse error on input ‘controller’) for example if I make the choice RevokeIssuer of the Issuer template insufficiently indented (e.g. if I place it on the same indentation level with the “where” keyword). Choice declarations and bodies are part of a template body and therefore must be indented from the “where” keyword, which declares the template body.
If my guess is incorrect, then please, as @cocreature suggested, post your code in a preformatted text block by wrapping it with triple backticks on both ends. Alternatively you can upload the Daml file for your module in your post.
module UserAdmin where
import Token
import Payment
template Issuer
with
userAdmin: Party
issuer: Party
where
signatory userAdmin
nonconsuming choice MintToken: ContractId Token
with
description: Text
initialPrice: Decimal
currency: Text
royaltyRate: Decimal
controller issuer
do
issued <- getTime
create Token
with
lastPrice = initialPrice
owner = issuer
..
choice
RevokeIssuer: ()
controller userAdmin
do return ()
template IssuerRequest
with
userAdmin: Party
issuer: Party
reason: Text
where
signatory issuer
choice
GrantIssuerRights: ContractId Issuer
controller userAdmin
do
create Issuer with ..
RejectIssuerRequest: ()
do return()
template Owner
with
userAdmin: Party
owner: Party
where
signatory userAdmin
nonconsuming choice AcceptTokenAsNewOwner: (ContractId Token, ContractId Payable, ContractId Payable)
with
offerId: ContractId TokenOffer
controller owner
do
exercise offerId AcceptToken
nonconsuming AcceptTokenByKey: (ContractId Token, ContractId Payable, ContractId Payable)
with
issuer: Party
currentOwner: Party
description: Text
do
exerciseByKey @TokenOffer (issuer, currentOwner, description) AcceptToken
controller userAdmin can
RevokeOwnerRights: ()
do return()
template OwnerRequest
with
userAdmin: Party
owner: Party
reason: Text
where
signatory owner
choice
GrantOwnerRights: ContractId Owner
controller userAdmin
do
create Owner with ..
RejectOwnerRequest: ()
do return()
it shows me the error of RejectIssuerRequest() in IssuerRequest Template
There are a few issues in there:
- The indentation still seems messed up. I suspect this is probably breaking during copy paste somewhere and your actual code is fine in that regard.
-
RejectIssuerRequest
is missing the controller. -
AcceptTokenByKey
is missing thechoice
keyword and the controller. -
RevokeOwnerRights
still usescontroller … can
. -
RejectOwnerRequest
is missing the choice keyword and the controller.
Here is the fixed up version
module UserAdmin where
import Token
import Payment
template Issuer
with
userAdmin: Party
issuer: Party
where
signatory userAdmin
nonconsuming choice MintToken: ContractId Token
with
description: Text
initialPrice: Decimal
currency: Text
royaltyRate: Decimal
controller issuer
do
issued <- getTime
create Token
with
lastPrice = initialPrice
owner = issuer
..
choice RevokeIssuer: ()
controller userAdmin
do return ()
template IssuerRequest
with
userAdmin: Party
issuer: Party
reason: Text
where
signatory issuer
choice GrantIssuerRights: ContractId Issuer
controller userAdmin
do create Issuer with ..
choice RejectIssuerRequest: ()
controller userAdmin
do return ()
template Owner
with
userAdmin: Party
owner: Party
where
signatory userAdmin
nonconsuming choice AcceptTokenAsNewOwner: (ContractId Token, ContractId Payable, ContractId Payable)
with
offerId: ContractId TokenOffer
controller owner
do exercise offerId AcceptToken
nonconsuming choice AcceptTokenByKey: (ContractId Token, ContractId Payable, ContractId Payable)
with
issuer: Party
currentOwner: Party
description: Text
controller owner
do exerciseByKey @TokenOffer (issuer, currentOwner, description) AcceptToken
choice RevokeOwnerRights : ()
controller userAdmin
do return ()
template OwnerRequest
with
userAdmin: Party
owner: Party
reason: Text
where
signatory owner
choice GrantOwnerRights: ContractId Owner
controller userAdmin
do create Owner with ..
choice RejectOwnerRequest: ()
controller owner
do return()
@cocreature
@a_putkov
@Gary_Verhaegen
thank you so much