-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ledger-api: Kill legacy identifier #2211
Conversation
6653eef
to
60bcbf7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kill it with fire! 🔥
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
eee4617
to
7427e78
Compare
610336f
to
b662cfa
Compare
b662cfa
to
653ff3b
Compare
...scala/bindings/src/main/scala/com/digitalasset/ledger/client/binding/binding/Primitive.scala
Outdated
Show resolved
Hide resolved
...scala/bindings/src/main/scala/com/digitalasset/ledger/client/binding/binding/Primitive.scala
Outdated
Show resolved
Hide resolved
* gRPC Identifier was built with the very old and ambiguous two-argument | ||
* form. Use [[LegacyTemplateId]] instead if you want to extract | ||
* the two-argument form. | ||
/** Package ID, module name, and entity name. | ||
*/ | ||
def unapply[Tpl](t: TemplateId[Tpl]): Option[(String, String, String)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def unapply[Tpl](t: TemplateId[Tpl]): Option[(String, String, String)] | |
def unapply[Tpl](t: TemplateId[Tpl]): Some[(String, String, String)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't put Some
here too it won't be visible.
...scala/bindings/src/main/scala/com/digitalasset/ledger/client/binding/binding/Primitive.scala
Outdated
Show resolved
Hide resolved
// TODO SC DEL-6727 use this instead with daml-lf value interface | ||
// rpcvalue.Identifier unapply t.unwrap | ||
t.unwrap match { | ||
case rpcvalue.Identifier(packageId, _, moduleName, entityName) | ||
case rpcvalue.Identifier(packageId, moduleName, entityName) | ||
if moduleName.nonEmpty && entityName.nonEmpty => | ||
Some((packageId, moduleName, entityName)) | ||
case _ => None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case _ => None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the reasoning behind your suggestion but I'd suggest to keep the default case and throw a telling exception there: MatchError
s tend to be very vague and it would be easier to understand the issue if the exception had a meaningful message based on the context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no possibility of a MatchError
in the set of changes I've suggested. That is to say, the prior case becomes exhaustive when you remove the condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now there isn't, which is what makes the situation exceptional. In general, I hardly see good reasons to leave generic MatchError
s with very error messages leaving a lot to be said being possibly thrown at runtime when a more meaningful and contextualized. If there is not possibility that the match couldn't fail, wouldn't it be possible to simply do something like
val unwrapped = t.unwrap
Some((unwrapped.packageId, unwrapped.moduleName, unwrapped.entityName))
Seems more direct and readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems more direct and readable.
You are right but I can't express that in GH change suggestions :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val rpcvalue.Identifier(packageId, moduleName, entityName) = t.unwrap
Some((packageId, moduleName, entityName))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The one line change to the haskell Convert,hs looks good to me.
653ff3b
to
7a0d73f
Compare
case _ => None | ||
} | ||
override def unapply[Tpl](t: TemplateId[Tpl]): Some[(String, String, String)] = { | ||
val rpcvalue.Identifier(packageId, moduleName, entityName) = t.unwrap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No we don't check anymore that moduleName
and entityName
are non-empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what I understand, the test was used to check if it is a new/old identifier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, but a templateId is only valid if the individual strings coming from the wire aren't empty. But maybe this is not the place to check this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check is done inside the ledger API.
We probably do not need to duplicate the test in Scala binding side.
7a0d73f
to
958fc45
Compare
958fc45
to
2898f71
Compare
We drop support of (deprecated) legacy identifier in the ledger API.
This fixes #2208
Pull Request Checklist
NOTE: CI is not automatically run on non-members pull-requests for security
reasons. The reviewer will have to comment with
/AzurePipelines run
totrigger the build.