Skip to content
Discussions/App Development/Party name check in DABLForum ↗

Party name check in DABL

App Development7 posts567 views5 likesLast activity Jul 2020
FR
FrankieOP
Jul 2020

In DABL, other users can join existing ledger and app if they know the ledger ID and app name. When they want to trade with other party they need to know that party’s ID. However DABL doesn’t seem to check if the party exists or not. I have a template like this and a number of time I put wrong buyer party id and it didn’t error out. Is it the right way to do it in DABL and is there anyway to verify if a party exists in DABL?

template SellerRequest
with
owner : Text
buyer : Text
exchange : Text
instrumentCode : Text
volume : Int
price : Decimal
where
signatory partyFromText owner
observer partyFromText buyer, partyFromText exchange

BE
bernhard
Jul 2020

I would generally advise you not to store parties as Text and convert them in DAML using partyFromText, but to store parties as Party:

template SellerRequest
  with
    owner : Party
    buyer : Party
    exchange : Party
    instrumentCode : Text 
    volume : Int
    price : Decimal
  where
    signatory owner
    observer buyer, exchange

The reason you are not getting an error in DABL is that DABL has “implicit party allocation” enabled. In other words, when it encounters a party it doesn’t recognise in a signatory or observer clause, it allocates it. Most other ledgers would throw an error in this case.

As long as that feature is enabled, there is no way for non-admin users to ascertain that a party does or doesn’t exist. From a DAML Ledger perspective, all parties exist in DABL. It’s only at the authorization level that DABL limits which parties it issues tokens for.

The only way to prevent all such errors would be to deactivate implicit party allocation on DABL, which doesn’t seem like a bad idea. @dtanabe might be able to comment on whether that’s feasible or even planned.

FR
Frankie
Jul 2020

@bernhard, I can see your point. The main reason I used Text instead of Party on DABL was that I found that the UI did not show and allow me to select the party if the party joined my ledger from another account. I guess that is part of the privacy setup. Maybe @dtanabe can help on this one as well.

BE
bernhard
Jul 2020
Frankie:

I found that the UI did not show and allow me to select the party if the party joined my ledger from another account

That sounds like a bug / missing feature. @dtanabe?

AL
Alex_Matson
Jul 2020
Frankie:

@bernhard, I can see your point. The main reason I used Text instead of Party on DABL was that I found that the UI did not show and allow me to select the party if the party joined my ledger from another account. I guess that is part of the privacy setup. Maybe @dtanabe can help on this one as well.

Hi Frankie — You’re right that you won’t see the other users’ parties due to the privacy model. By default, only the creator of the ledger will see all the parties that have been created on it.

However, you don’t need to resort to a Text field — if Party types are used, then the dropdown also allows you to manually type in (or copy+paste) another party’s ID. Let me know if you have any issues with that!

Another advantage to using Party types is the ID format that you type in is validated by the input. Note that there’s a distinction between checking the party ID is valid, and that the party ID exists on the ledger. The Party input will do the former, i.e., checks that the party ID string follows the DABL convention of ledger-party-uuid. This can help save you from small input mistakes, like if some numbers are missing or there are extra characters that shouldn’t be there. It won’t do the latter, since we’re using implicit party allocation as mentioned by Bernhard. Hope that helps some!

FR
Frankie
Jul 2020

It works! Thanks @Alex_Matson. It is a nice feature. Just a little bit hard to notice. :grin:

AL
Alex_Matson
Jul 2020

Thank you for the feedback! I realized this feature is not yet documented, so I’ll make a note to go in and include it for better discoverability

← Back to Discussions