You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
702 B
Python

from flask import Blueprint
from arrow import get as arrow_get
3 years ago
from suchwowx import config
bp = Blueprint('filters', 'filters')
3 years ago
@bp.app_template_filter('shorten_address')
def shorten_address(a):
3 years ago
_p = a[0:6]
_s = a[-4:]
return f'{_p}...{_s}'
3 years ago
@bp.app_template_filter('humanize')
def humanize(d):
if not d:
return 'never'
return arrow_get(d).humanize()
3 years ago
@bp.app_template_filter()
def show_snowtrace(s) -> str:
"""
Return proper links to Etherscan based upon the currently configured network.
"""
if config.CONTRACT_TESTNET:
return f'https://testnet.snowtrace.io/search?f=0&q={s}'
else:
return f'https://snowtrace.io/search?f=0&q={s}'