-
Notifications
You must be signed in to change notification settings - Fork 50
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
Adds better error messages for FlowStakingCollection
and ledger transactions
#455
Conversation
212cb12
to
0f697ad
Compare
|
||
if let machineAccount = self.stakingCollectionRef.createMachineAccountForExistingNode(nodeID: nodeID, payer: account) { | ||
let sigAlgo = SignatureAlgorithm(rawValue: machineAccountKeySignatureAlgorithm) | ||
?? panic("Could not get a signature algorithm from the raw enum value provided") | ||
?? panic("Cannot create machine account with provided key: Must provide a signature algorithm raw value that corresponds to " |
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 think I do want to put this error message construction in a contract somewhere. Any ideas about where it could go? Potentially in the Crypto contract? Or maybe just in the Service Account contract? Another option would be to create a new contract in the service account that just contains multiple different common error message constructions.
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.
At first glance, the Crypto contract makes the most sense to me. A version of the enum constructor that panics on invalid input with an error message like 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.
I agree, Crypto makes the most sense, maybe adding a getter for these enums which reverts with the appropriate message
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 created an issue for it: https://github.com/onflow/cadence/issues/3617
FlowStakingCollection
and ledger transactions
|
||
if let machineAccount = self.stakingCollectionRef.createMachineAccountForExistingNode(nodeID: nodeID, payer: account) { | ||
let sigAlgo = SignatureAlgorithm(rawValue: machineAccountKeySignatureAlgorithm) | ||
?? panic("Could not get a signature algorithm from the raw enum value provided") | ||
?? panic("Cannot create machine account with provided key: Must provide a signature algorithm raw value that corresponds to " |
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.
At first glance, the Crypto contract makes the most sense to me. A version of the enum constructor that panics on invalid input with an error message like 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.
Great error messages!
|
||
if let machineAccount = self.stakingCollectionRef.createMachineAccountForExistingNode(nodeID: nodeID, payer: account) { | ||
let sigAlgo = SignatureAlgorithm(rawValue: machineAccountKeySignatureAlgorithm) | ||
?? panic("Could not get a signature algorithm from the raw enum value provided") | ||
?? panic("Cannot create machine account with provided key: Must provide a signature algorithm raw value that corresponds to " |
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 agree, Crypto makes the most sense, maybe adding a getter for these enums which reverts with the appropriate message
Updates all the transactions and their dependencies that we use for ledger devices to use more descriptive error messages.
I decided to put some constructors for common error messages in the contract so we didn't have to hard code them in every transaction. I think I would like to start following this pattern from now on for other contracts. I'm open to suggestions on how they should work and be formatted, so please let me know if you have any feedback.