-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add reference ID exchange object types (#274)
Add reference ID exchange object types
- Loading branch information
Showing
5 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Copyright (c) The Diem Core Contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
"""This module defines `ReferenceIDCommand` class provides utils for processing `ReferenceIDCommand` properly.""" | ||
|
||
import dataclasses, uuid | ||
from .types import ( | ||
ReferenceIDCommandObject, | ||
) | ||
|
||
|
||
@dataclasses.dataclass(frozen=True) | ||
class ReferenceIDCommand: | ||
"""Wrapper object of `ReferenceIDCommand` with request information | ||
Defined in DIP-10: https://github.com/diem/dip/blob/main/dips/dip-10.md | ||
""" | ||
|
||
reference_id_command_object: ReferenceIDCommandObject | ||
cid: str = dataclasses.field(default_factory=lambda: str(uuid.uuid4())) | ||
|
||
@staticmethod | ||
def init( | ||
sender: str, | ||
sender_address: str, | ||
receiver: str, | ||
reference_id: str, | ||
) -> "ReferenceIDCommand": | ||
"""init functon initializes a new `ReferenceIDCommand` for starting the DiemID to address resolution""" | ||
|
||
return ReferenceIDCommand( | ||
reference_id_command_object=ReferenceIDCommandObject( | ||
sender=sender, sender_address=sender_address, receiver=receiver, reference_id=reference_id | ||
) | ||
) | ||
|
||
def id(self) -> str: | ||
"""returns `cid` from the request object""" | ||
return self.cid | ||
|
||
def reference_id(self) -> str: | ||
"""returns `reference_id` of `ReferenceIDCommand`""" | ||
|
||
return self.reference_id_command_object.reference_id | ||
|
||
def sender(self) -> str: | ||
"""returns sender pay address""" | ||
|
||
return self.reference_id_command_object.sender | ||
|
||
def receiver(self) -> str: | ||
"""returns receiver pay address""" | ||
|
||
return self.reference_id_command_object.receiver | ||
|
||
def sender_address(self) -> str: | ||
"""returns sender address""" | ||
|
||
return self.reference_id_command_object.sender_address |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters