-
Notifications
You must be signed in to change notification settings - Fork 1
Conversation
@@ -0,0 +1,61 @@ | |||
// Tbdex exception codes are each thrown in exactly one place. | |||
// Each code is prefixed with the name of the file in which it is thrown. |
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.
Not every code is tested as of this PR. In subsequent PRs, we can flesh out tests to cover more cases.
}; | ||
} | ||
|
||
static Future<Rfq> parse(String rawMessage, { requireAllPrivateData = false }) async { |
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.
In tbdex-js we only use this functionality in the server, so swift doesn't implement anything that isn't consumed by the client, and scopes anything needed for testing to the test files. Do you want to follow the same pattern here?
My suggestion is to:
- omit
parse
,verifyAllPrivateData
andverifyPresentPrivateData
as these are not consumed by a client - collapse
verifyPayinDetailsHash
,verifyPayoutDetailsHash
, andverifyClaimsHash
into averifyHash
that accepts args - scope
verifyHash
to tests
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'd prefer to keep the requireAllPrivateData
functionality. My understanding for tbdex-swift was that we omitted that functionality because we were up against a deadline and omitting it from swift was a good trade off to cut down on eng work.
Since I've already paid the upfront cost of implementing this is dart, I don't see any drawback to keeping it in. Even though we won't necessarily use that functionality for didpay, other package consumers might find it useful for their dart apps. E.g. someone writes p2p tbdex client in dart that has both pfi and wallet functionality.
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.
My understanding for tbdex-swift was that we omitted that functionality because we were up against a deadline and omitting it from swift was a good trade off to cut down on eng work.
cool thanks for clarifying @diehuxx
@frankhinek @angiejones can you confirm? thats not what my understanding was and it would be ideal to align sdks semantically. if we are adding pfi functionality broadly including in swift i'd like to create issues asap.
lib/src/protocol/parser.dart
Outdated
|
||
abstract class Parser { | ||
static Message parseMessage(String rawMessage) { | ||
final jsonObject = jsonDecode(rawMessage) as Map<String, dynamic>?; | ||
if (jsonObject == null) { | ||
throw Exception('ugh'); |
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.
should we throw a TbdexParseException
here?
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.
woops, we definitely should. 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.
thanks for getting to this!!
Add
privateData
to RFQ and make exceptions more precise and easier to catch. From the dart docs for the Exception class,The pattern of "error codes" is borrowed from dwn-sdk-js. The pattern of custom error classes --
TbdexParseException
,TbdexValidatorException
, etc. -- makes it easier to catch specific exceptions from an action like.parse()
or.validate()
.