2025-01-16 12:46:03 +03:00
|
|
|
import json
|
2024-08-19 20:41:54 +03:00
|
|
|
import random
|
|
|
|
|
import string
|
2024-08-22 17:36:10 +03:00
|
|
|
from zpywallet import HDWallet
|
|
|
|
|
from zpywallet.network import EthereumMainNet
|
2026-08-23 10:38:34 +03:00
|
|
|
from eth_account.hdaccount import Language, generate_mnemonic, Mnemonic
|
2024-08-19 20:41:54 +03:00
|
|
|
|
2025-01-16 12:46:03 +03:00
|
|
|
import configs
|
2026-03-12 15:36:36 +03:00
|
|
|
from constants import WalletAccountColors
|
2026-08-06 10:58:13 +03:00
|
|
|
from constants.messaging import STATUS_CAT_STICKERS, Sticker
|
2026-08-18 16:42:04 +03:00
|
|
|
from constants.networks import WalletNetworkNaming
|
2026-03-12 15:36:36 +03:00
|
|
|
|
|
|
|
|
COMMUNITY_TAGS = [
|
|
|
|
|
'Activism', 'Art', 'Blockchain', 'Books & blogs', 'Career', 'Collaboration', 'Commerce', 'Culture',
|
|
|
|
|
'DAO', 'DIY', 'DeFi', 'Design', 'Education', 'Entertainment', 'Environment', 'Ethereum', 'Event',
|
|
|
|
|
'Fantasy', 'Fashion', 'Food', 'Gaming', 'Global', 'Health', 'Hobby', 'Innovation', 'Language',
|
|
|
|
|
'Lifestyle', 'Local', 'Love', 'Markets', 'Movies & TV', 'Music', 'NFT', 'NSFW', 'News', 'Non-profit',
|
|
|
|
|
'Org', 'Pets', 'Play', 'Podcast', 'Politics', 'Privacy', 'Product', 'Psyche', 'Security', 'Social',
|
|
|
|
|
'Software dev', 'Sports', 'Tech', 'Travel', 'Vehicles', 'Web3'
|
|
|
|
|
]
|
2024-10-15 18:31:37 +03:00
|
|
|
|
2024-08-19 20:41:54 +03:00
|
|
|
|
|
|
|
|
def random_name_string():
|
|
|
|
|
return ''.join((random.choice(
|
|
|
|
|
string.ascii_letters + string.digits + random.choice('_- '))
|
|
|
|
|
for _ in range(5, 25))
|
|
|
|
|
).strip(' ')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def random_password_string():
|
|
|
|
|
return ''.join((random.choice(
|
|
|
|
|
string.ascii_letters + string.digits + string.punctuation)
|
2024-10-16 10:22:28 +03:00
|
|
|
for _ in range(10, 101))
|
2024-08-19 20:41:54 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def random_ens_string():
|
|
|
|
|
return ''.join(
|
|
|
|
|
random.choices(string.digits + string.ascii_lowercase, k=8))
|
2024-08-22 17:36:10 +03:00
|
|
|
|
|
|
|
|
|
2026-02-09 16:26:20 +03:00
|
|
|
def random_network():
|
2026-08-18 16:42:04 +03:00
|
|
|
return WalletNetworkNaming.LAYER1_ETHEREUM_TESTNET.value
|
2025-07-23 12:45:17 +03:00
|
|
|
|
|
|
|
|
|
2026-02-09 16:26:20 +03:00
|
|
|
def random_network_for_minting():
|
2026-08-18 16:42:04 +03:00
|
|
|
return WalletNetworkNaming.LAYER1_ETHEREUM_HOODI.value
|
2026-02-09 16:26:20 +03:00
|
|
|
|
|
|
|
|
|
2024-10-15 18:31:37 +03:00
|
|
|
def random_community_name():
|
|
|
|
|
return ''.join(random.choices(string.ascii_letters +
|
|
|
|
|
string.digits, k=30))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def random_community_description():
|
|
|
|
|
return ''.join(random.choices(string.ascii_letters +
|
|
|
|
|
string.digits, k=140))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def random_community_introduction():
|
|
|
|
|
return ''.join(random.choices(string.ascii_letters +
|
|
|
|
|
string.digits, k=200))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def random_community_leave_message():
|
|
|
|
|
return ''.join(random.choices(string.ascii_letters +
|
|
|
|
|
string.digits, k=80))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def random_community_tags():
|
|
|
|
|
num_tags = random.randint(1, 3)
|
2026-03-12 15:36:36 +03:00
|
|
|
return random.sample(COMMUNITY_TAGS, num_tags)
|
2024-10-15 18:31:37 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def random_color():
|
|
|
|
|
random_number = random.randint(0, 0xFFFFFF)
|
|
|
|
|
hex_color = f'#{random_number:06x}'
|
|
|
|
|
return hex_color
|
|
|
|
|
|
|
|
|
|
|
2024-08-22 17:36:10 +03:00
|
|
|
def random_mnemonic():
|
2024-08-30 18:02:28 +03:00
|
|
|
words = ''
|
|
|
|
|
while not Mnemonic().is_mnemonic_valid(mnemonic=words):
|
2026-08-23 10:38:34 +03:00
|
|
|
new_words = generate_mnemonic(
|
|
|
|
|
num_words=random.choice([12, 18, 24]),
|
|
|
|
|
lang=Language.ENGLISH,
|
|
|
|
|
)
|
2024-08-30 18:02:28 +03:00
|
|
|
words = new_words
|
2024-08-22 17:36:10 +03:00
|
|
|
return words
|
|
|
|
|
|
|
|
|
|
|
2024-10-24 18:45:38 +03:00
|
|
|
def random_wallet_acc_keypair_name():
|
2024-08-28 15:54:29 +03:00
|
|
|
return ''.join((random.choice(
|
|
|
|
|
string.ascii_letters + string.digits)
|
|
|
|
|
for _ in range(5, 21)))
|
|
|
|
|
|
|
|
|
|
|
2024-08-22 17:36:10 +03:00
|
|
|
def get_wallet_address_from_mnemonic(mnemonic_data) -> str:
|
|
|
|
|
w = HDWallet.from_mnemonic(mnemonic=mnemonic_data, passphrase='', network=EthereumMainNet)
|
|
|
|
|
child_w = w.get_child_for_path("m/44'/60'/0'/0/0")
|
|
|
|
|
address_from_mnemonic = child_w.address()
|
|
|
|
|
return address_from_mnemonic
|
2024-11-06 21:49:46 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def random_text_message():
|
|
|
|
|
return ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(1, 141))
|
2025-01-16 12:46:03 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def random_emoji_with_unicode() -> tuple:
|
|
|
|
|
with open(configs.testpath.TEST_FILES / 'emojis_unicodes_list.json', "r", encoding="utf-8") as file:
|
|
|
|
|
data = json.load(file)
|
|
|
|
|
random_item = random.choice(data)
|
|
|
|
|
return random_item['shortname'], random_item['unicode']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def random_wallet_account_color():
|
|
|
|
|
color = random.choice(WalletAccountColors.wallet_account_colors())
|
|
|
|
|
return color.lower()
|
2026-07-24 13:46:37 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def keycard_card_id(prefix: str = 'test-card') -> str:
|
|
|
|
|
suffix = ''.join(random.choices(string.ascii_lowercase + string.digits, k=6))
|
|
|
|
|
return f'{prefix}-{suffix}'
|
2026-08-06 10:58:13 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def random_sticker() -> Sticker:
|
|
|
|
|
return random.choice(STATUS_CAT_STICKERS)
|