Beispiel #1
0
def make_memo(memo: str, memo_type: str) -> Optional[Memo]:
    if not memo:
        return None
    if memo_type == Transaction.MEMO_TYPES.id:
        return IdMemo(int(memo))
    elif memo_type == Transaction.MEMO_TYPES.hash:
        return HashMemo(memo_base64_to_hex(memo))
    elif memo_type == Transaction.MEMO_TYPES.text:
        return TextMemo(memo)
    else:
        raise ValueError()
Beispiel #2
0
    def generate_uri(self, address: str, memo: str):

        """
        Returns Transaction as envelope
        """

        return stellar_uri.PayStellarUri(destination=address,
                                         memo=TextMemo(text=memo),
                                         asset=Asset.native(),
                                         network_passphrase=self.network_phrase,
                                         message='Deposit to Discord',
                                         ).to_uri()
Beispiel #3
0
 def check_memo(memo):
     try:
         TextMemo(text=memo)
         return True
     except MemoInvalidException:
         return False
Beispiel #4
0
def test_memo_str_text_memo():
    assert utils.memo_str(TextMemo("test")) == ("test",
                                                Transaction.MEMO_TYPES.text)