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
// Replace "X" and "Y" with your desired types | |
func mapXtoY(collection []X, fn func(elem X) Y) []Y { | |
var result []Y | |
for _, item := range collection { | |
result = append(result, fn(item)) | |
} | |
return result | |
} |
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
def symbol_to_hex(symbol: str = None) -> str: | |
"""symbol_to_hex.""" | |
if len(symbol) > 3: | |
bytes_string = bytes(str(symbol).encode('utf-8')) | |
return bytes_string.hex().upper().ljust(40, '0') | |
return symbol | |
def hex_to_symbol(hex: str = None) -> str: | |
"""hex_to_symbol.""" |
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
from typing import TypedDict | |
from cryptoconditions import PreimageSha256 | |
def genCondition_Fulfillment(secret: bytes) -> TypedDict: | |
"""Generate a condition and fulfillment for escrows""" | |
fufill = PreimageSha256(preimage=secret) | |
return { | |
"condition": str.upper(fufill.condition_binary.hex()), | |
"fulfillment": str.upper(fufill.serialize_binary().hex())} |