-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add reference ID exchange object types #274
Conversation
beef99c
to
cff14cd
Compare
@@ -134,3 +160,18 @@ class CommandResponseObject: | |||
error: typing.Optional[OffChainErrorObject] = datafield(default=None) | |||
# The Command identifier to which this is a response. | |||
cid: typing.Optional[str] = datafield(default=None) | |||
# An result JSON object that may be defined when status == "success" | |||
result: typing.Optional[OffChainResultObject] = datafield(default=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.
use dict # pyre-ignore
for type definition.
when decoding the response object, result is unknown, as caller should base on request command type to decide what is response type, thus it is unknown when we decode CommandResponseObject.
For example: PaymentCommand response should not have result = ReferenceIDCommandResponse.
It is more flexible to let caller to decode the dict to specific type.
@@ -124,6 +137,19 @@ class OffChainErrorObject: | |||
message: typing.Optional[str] = datafield(default=None) | |||
|
|||
|
|||
@dataclass(frozen=True) | |||
class OffChainResultObject: |
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.
change this to ReferenceIDCommandResultObject, may also update https://github.com/diem/dip/pull/164/files "CommandResultObject" to use same name,
When there are multiple result objects, it is better we don't mix their fields.
} | ||
) | ||
# ReferenceIDCommandResponse: Receiver's onchain account identifier | ||
receiver_address: typing.Optional[str] = datafield(default=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.
this field is required, not optional
@@ -134,3 +160,18 @@ class CommandResponseObject: | |||
error: typing.Optional[OffChainErrorObject] = datafield(default=None) | |||
# The Command identifier to which this is a response. | |||
cid: typing.Optional[str] = datafield(default=None) | |||
# An result JSON object that may be defined when status == "success" | |||
result: dict # pyre-ignore |
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.
typing.Optional[dict]
c307257
to
1c61c6d
Compare
may add a test to test_offchain_types for decoding CommandResponseObject with result dict |
@xli want to take a look at the test? |
Adding data types for reference ID exchange as defined by DIP10