async def aggregations(self, ctx, counter_asset: str, counter_issuer: str, resolution: int): base = Asset(code="XLM").native() counter = Asset(code=counter_asset.upper(), issuer=counter_issuer) resolution_actual = self.process_resolution(resolution=resolution) data = self.server.trade_aggregations( base=base, counter=counter, resolution=resolution_actual).call() # Embed agg_details = Embed( title=f':bar_chart: Aggregated Trades result :bar_chart: ', colour=Colour.lighter_gray()) agg_details.add_field(name=f':gem: Base Asset Details :gem:', value=f'***__XLM__***') agg_details.add_field(name=f':gem: Counter Asset Details :gem:', value=f'***__{counter_asset.upper()}__***\n' f'```{counter_issuer}```', inline=False) agg_details.add_field(name=f':gem: Resolution :gem:', value=f'{resolution} Minutes', inline=False) agg_details.add_field( name=f':sunrise: Horizon Link :sunrise:', value=f'[Trades for Query]({data["_links"]["self"]["href"]})', inline=False) await ctx.author.send(embed=agg_details) records = data['_embedded']["records"] if resolution and records: rec = Embed(title=f'Aggregated Trades', colour=Colour.lighter_gray()) rev_records = reversed(records) counter = 0 for r in rev_records: if counter <= 2: milliseconds = int(r["timestamp"]) / 1000 actual = datetime.utcfromtimestamp(milliseconds) rec.add_field( name=f':clock1: {actual} :clock1: ', value=f'***Σ Trades***: `{r["trade_count"]}`\n' f'***Average:*** `{r["avg"]}`\n' f'***Open:*** `{r["open"]}`\n' f'***High:*** `{r["high"]}`\n' f'***Low:*** `{r["low"]}`\n' f'***Close:*** `{r["close"]}`\n' f'***Base Vol:*** `{r["base_volume"]}`\n' f'***Counter Vol:*** `{r["counter_volume"]}`\n', inline=False) counter += 1 await ctx.author.send(embed=rec)
async def trades(self, ctx): """ Trades entry point to horizon endpoints """ if ctx.invoked_subcommand is None: title = ':currency_exchange: __Horizon Trades Queries__ :currency_exchange: ' description = 'Representation of all available commands available to interact with ***Trades*** Endpoint on ' \ 'Stellar Horizon Server. Commands can be used 1/30 seconds/ per user.' list_of_commands = [{ "name": f':map: Trades for Account :map:', "value": f'```{self.command_string}trades account <address>```\n' f'`Aliases: acc, addr' }, { "name": f':id: Trades by Offer ID :id: ', "value": f'```{self.command_string}trades offer <offer id>```' }] await custom_messages.embed_builder(ctx=ctx, title=title, data=list_of_commands, description=description, destination=1, c=Colour.lighter_gray())
async def paths(self, ctx): """ Effects entry point to horizon endpoints """ if ctx.invoked_subcommand is None: title = ':railway_track: __Horizon Paths Queries__ :railway_track:' description = 'Representation of all available commands available to interact with ***Paths*** Endpoint on ' \ 'Stellar Horizon Server.Commands can be used 1/30 seconds/ per user.' list_of_commands = [ { "name": f':service_dog: Find Strict Send Payment Paths', "value": f'```{self.command_string}paths send <to address> <amount> <asset code> <asset issuer>```\n' f'***__Note__***: Issuer can be None if asset is Native' }, { "name": f':mag_right: Find Strict Receive Payment Paths :mag:', "value": f'```{self.command_string}paths find <from address> <amount> <asset code> <asset issuer>```\n' f'***__Note__***: Issuer can be None if asset is Native' }, ] await custom_messages.embed_builder(ctx=ctx, title=title, data=list_of_commands, description=description, destination=1, c=Colour.lighter_gray())
async def offers(self, ctx): """ Effects entry point to horizon endpoints """ if ctx.invoked_subcommand is None: title = ':handshake: __Horizon Offers Queries__ :handshake: ' description = 'Representation of all available commands available to interact with ***Effects***' \ ' Endpoint on Stellar Horizon Server. Commands can be used 1/30 seconds/ per user.' list_of_commands = [{ "name": f':id: Single Offer Query :id:', "value": f'```{self.command_string}offers single <offer id>```\n' f'`Aliases: id`' }, { "name": f' :map: Offers by Account :map: ', "value": f'```{self.command_string}offers account <Account public address>```\n' f'`Aliases: addr`' }] await custom_messages.embed_builder(ctx=ctx, title=title, data=list_of_commands, description=description, destination=1, c=Colour.lighter_gray())
async def operations(self, ctx): """ Effects entry point to horizon endpoints """ title = ':wrench: __Horizon Operations Queries__ :wrench: ' description = 'Representation of all available commands available to interact with' \ ' ***Operations*** Endpoint on Stellar Horizon Server. Commands ' \ 'can be used 1/30 seconds/ per user.\n' \ '`Aliases: op`' list_of_commands = [ {"name": f' :map: Operation by Account :map: ', "value": f'```{self.command_string}operations account <Account public address>```\n' f'`Aliases: acc, addr`'}, {"name": f':tools: Single Operation :tools: ', "value": f'```{self.command_string}operations operation <operation id>```\n' f'`Aliases: id`'}, {"name": f' :hash: Operations for transaction hash :hash:', "value": f'```{self.command_string}operations transaction <transaction hash>```\n' f'`Aliases: hash, tx`'}, {"name": f' :ledger: Operation by Ledger :ledger: ', "value": f'```{self.command_string}operations ledger <ledger id>```'} ] if ctx.invoked_subcommand is None: await custom_messages.embed_builder(ctx=ctx, title=title, data=list_of_commands, description=description, destination=1, c=Colour.lighter_gray())
async def send_paths_records_details(destination, data): record_info = Embed(title=':record_button: Record Info :record_button: ', colour=Colour.lighter_gray()) record_info.add_field(name=f':gem: Source Asset :gem:', value=f'`{data["source_asset_code"]}`', inline=False) record_info.add_field(name=f':gem: Destination Asset :gem:', value=f'`{data["destination_asset_code"]}`', inline=False) record_info.add_field( name=f':money_with_wings: Destination Amount :money_with_wings: ', value=f'`{data["destination_amount"]} {data["destination_asset_code"]}`' ) counter = 0 path_str = str() for p in data["path"]: if p["asset_type"] == 'native': path_str += f'***{counter}.*** `XLM`\n========\n' else: path_str += f'***{counter}.*** `{p["asset_code"]}`\n ```{p["asset_issuer"]}```========\n' counter += 1 record_info.add_field(name=':railway_track: Paths :railway_track: ', value=path_str, inline=False) await destination.send(embed=record_info)
async def accounts(self, ctx): title = ':office_worker: __Horizon Accounts Queries__ :office_worker:' description = 'Representation of all available commands available to interact with ***Account*** Endpoint on ' \ 'Stellar Horizon Server. Commands can be used 1/30 seconds/ per user.\n' \ '`Aliases: account,acc`' list_of_commands = [{ "name": f':new: Create New Account :new: ', "value": f'```{self.command_string}accounts create```\n' f'`aliases: new`' }, { "name": f':mag_right: Query Account Details :mag:', "value": f'```{self.command_string}accounts get <Valid Stellar Address>```\n' f'`aliases: details,query,find`' }] if ctx.invoked_subcommand is None: await custom_messages.embed_builder(ctx=ctx, title=title, data=list_of_commands, description=description, destination=1, c=Colour.lighter_gray())
async def trade(self, ctx): """ Effects entry point to horizon endpoints """ if ctx.invoked_subcommand is None: title = ':bar_chart: __Horizon Trade Aggregations Queries__ :bar_chart: ' description = 'Representation of all available commands available to interact with ***Trade Aggregations*** ' \ 'Endpoint on Stellar Horizon Server. Commands can be used 1/30 seconds/ per user.' list_of_commands = [ { "name": f':chart_with_upwards_trend: XLM vs Asset Trades', "value": f'`{self.command_string}trade aggregations <counter asset> <counter issuer> <resolution> `\n' f'***__Note__***: Resolutions allowed 1, 5, and 15 minutes\n' f'`Aliases: agg`' }, ] await custom_messages.embed_builder(ctx=ctx, title=title, data=list_of_commands, description=description, destination=1, c=Colour.lighter_gray())
async def new_acc_details(author, details: dict): new_account = Embed( title= f':white_check_mark: Wallet Details registered in Crypto Link :white_check_mark: ', description= "Public level 3 wallet details, have been successfully stored in " "Crypto Link database. ", colour=Colour.lighter_gray(), timestamp=datetime.utcnow()) new_account.add_field(name=f'Your discord details', value=f'```{author}\n' f'{author.id}```', inline=True) new_account.add_field(name=f':map: Public Address :map: ', value=f'```{details["publicAddress"]}```', inline=False) new_account.add_field( name=f':warning: Important :warning: ', value= f'Crypto Link does not store your private key, therefore it can not be recovered.' f' You can update your account details with dedicated commands for 3 level.', inline=False) new_account.add_field( name=f':exclamation: Important :exclamation: ', value= f' Make Sure that registered public address is active on Stellar Network.', inline=False) new_account.set_footer( text='This message will self destruct in 120 seconds') await author.send(embed=new_account, delete_after=120)
async def account(self, ctx, account_address: str): """ Get last three transactions for the account """ try: data = self.hor_transactions.for_account(account_id=account_address).order(desc=True).call() records = data['_embedded']['records'] if records: account_info = Embed(title=f':map: Account Transactions Information :map:', colour=Colour.lighter_gray()) account_info.add_field(name=f':sunrise: Horizon Link :sunrise:', value=f'[Account Transactions]({data["_links"]["self"]["href"]})') account_info.add_field(name=f'Last :three: entries', value=f':arrow_double_down: ', inline=False) await ctx.author.send(embed=account_info) counter = 0 for record in records: if counter <= 2: memo = process_memo(record=record) date_fm = format_date(record["created_at"]) sig_str = '\n'.join([f'`{sig}`' for sig in record['signatures']]) await tx_info_for_account(destination=ctx.message.author, record=record, signers=sig_str, memo=memo, date=date_fm) counter += 1 else: message = f'Account ```{account_address}``` does not exist or has not been activated yet.' await custom_messages.system_message(ctx=ctx, color_code=1, message=message, destination=0, sys_msg_title=':map: Account not found :map:') except BadRequestError as e: extras = e.extras await horizon_error_msg(destination=ctx.message.author, error=extras["reason"])
async def send_details_for_asset(destination, coin, data, date): """ Additional informational embed if account has present assets """ asset_details = Embed( title=f':coin: Details for asset {coin["asset_code"]} :coin:', description=f'Last Activity on {date} (UTC)' f' (Ledger:{data["last_modified_ledger"]}', colour=Colour.lighter_gray()) asset_details.add_field(name=f':map: Issuer Address :map: ', value=f'```{coin["asset_issuer"]}```', inline=False) asset_details.add_field(name=f' :moneybag: Balance :moneybag:', value=f'`{coin["balance"]} {coin["asset_code"]}`', inline=False) asset_details.add_field( name=f':handshake: Trustline Status :handshake: ', value=f'Authorizer: {coin["is_authorized"]}\n' f'Maintain Liabilities: {coin["is_authorized_to_maintain_liabilities"]}', inline=False) asset_details.add_field( name=f':man_judge: Liabilities :man_judge: ', value=f'Buying Liabilities: {coin["buying_liabilities"]}\n' f'Selling Liabilities: {coin["selling_liabilities"]}', inline=False) asset_details.add_field( name=':chains: Trustline links :chains: ', value= f'[Issuer Details](https://stellar.expert/explorer/testnet/account/{coin["asset_issuer"]}?order=desc)\n' f'[Asset Details](https://stellar.expert/explorer/testnet/asset/{coin["asset_code"]}-{coin["asset_issuer"]}?order=desc)' ) await destination.send(embed=asset_details)
async def assets(self, ctx): title = ':gem: __Horizon Assets Queries__ :gem:' description = 'Representation of all available commands available to interact with ***Assets*** Endpoint on ' \ 'Stellar Horizon Server. Commands can be used 1/30 seconds/ per user.' list_of_commands = [{ "name": f':gem: Query by exact details :gem: ', "value": f'```{self.command_string}assets get <asset code> <issuer address>```' }, { "name": f':regional_indicator_c: Query by code :regional_indicator_c: ', "value": f'```{self.command_string}assets code <alphanumeric string>```' }, { "name": f':map: Query by Issuer Address :map:', "value": f'```{self.command_string}assets issuer <Issuer address>```' }] if ctx.invoked_subcommand is None: await custom_messages.embed_builder(ctx=ctx, title=title, data=list_of_commands, description=description, destination=1, c=Colour.lighter_gray())
async def offer_details(destination, offer: dict): """ Send offer details """ offer_details = Embed(title=f':id: {offer["id"]} :id:', colour=Colour.lighter_gray()) offer_details.add_field(name=f':calendar: Last Modified :calendar: ', value=f'{offer["last_modified_time"]}', inline=False) offer_details.add_field(name=f':white_circle: Paging Token :white_circle:', value=f'{offer["paging_token"]}', inline=False) offer_details.add_field(name=f':map: Seller Details :map:', value=f'```{offer["seller"]}```', inline=False) # Processing offer selling_string = '' if offer["selling"]["asset_type"] != 'native': selling_string += f'{offer["amount"]} {offer["selling"]["asset_code"]} @ ' else: selling_string += f'{offer["amount"]} XLM @ ' if offer['buying']['asset_type'] != 'native': selling_string += f' {offer["price"]} {offer["buying"]["asset_code"]}' else: selling_string += f' {offer["price"]}/XLM @' offer_details.add_field(name=f':handshake: Offer Details :handshake: ', value=f'`{selling_string}`', inline=False) # Processing Issuers asset_issuers = '' if offer['buying']['asset_type'] != 'native': asset_issuers += f':gem: {offer["buying"]["asset_code"]} (Buying) :gem:\n' \ f'```{offer["buying"]["asset_issuer"]}```' else: asset_issuers += f':coin: XLM :coin: \n' \ f'```Native Currency```' if offer['selling']['asset_type'] != 'native': asset_issuers += f'\n:gem: Selling {offer["selling"]["asset_code"]} (Selling) :gem:\n' \ f'```{offer["selling"]["asset_issuer"]}```\n' else: asset_issuers += f':coin: XLM :coin: \n' \ f'```Native Currency```' offer_details.add_field(name=f':bank: Asset Issuers :bank:', value=asset_issuers, inline=False) offer_details.add_field( name=f':sunrise: Horizon Links :sunrise:', value=f'[Offer Maker]({offer["_links"]["offer_maker"]["href"]}) \n' f'[Offer Link]({offer["_links"]["self"]["href"]})', inline=False) await destination.send(embed=offer_details)
async def book(self, ctx): """ Effects entry point to horizon endpoints """ if ctx.invoked_subcommand is None: title = ':book: __Horizon Order Book Queries__ :book: ' description = 'Representation of all available commands available to interact with ***Order Book' \ '*** Endpoint on Stellar Horizon Server Commands can be used 1/30 seconds/ per user.' list_of_commands = [ { "name": f':currency_exchange: Query Order Book for pair :currency_exchange: ', "value": f'```{self.command_string}book details <selling asset> <buying asset>```\n' f'__Note__: Assets can be represented as a code or issuer address,' f'`Aliases: get`' }, ] await custom_messages.embed_builder(ctx=ctx, title=title, data=list_of_commands, description=description, destination=1, c=Colour.lighter_gray())
async def ledger(self, ctx, ledger_id: int): try: data = self.hor_transactions.for_ledger(sequence=ledger_id).call() if data: records = data['_embedded']['records'] ledger_info = Embed(title=f':ledger: Ledger {ledger_id} Information :ledger:', description='Bellow is represent information for requested ledger.', colour=Colour.lighter_gray()) ledger_info.add_field(name=f':sunrise: Horizon Link :sunrise:', value=f'[Ledger]({data["_links"]["self"]["href"]})') await ctx.author.send(embed=ledger_info) for record in records: sig_str = '\n'.join([f'`{sig}`' for sig in record['signatures']]) await tx_info_for_ledger(destination=ctx.message.author, ledger_id=ledger_id, record=record, signatures=sig_str, date=format_date(record["created_at"])) else: message = f'Ledger with :id: {ledger_id} could not be found' await custom_messages.system_message(ctx=ctx, color_code=1, message=message, destination=0, sys_msg_title=':ledger: Ledger not found :ledger:') except BadRequestError as e: extras = e.extras await horizon_error_msg(destination=ctx.message.author, error=extras["reason"])
async def send_asset_details(destination, data, request): toml_access = data['_embedded']['records'][0]['_links']['toml']['href'] record = data['_embedded']['records'][0] asset_info = Embed( title=f':bank: Issuer Details :bank:', description=f'Bellow is represent information for requested {request}.', colour=Colour.lighter_gray()) asset_info.add_field(name=f':sunrise: Horizon Link :sunrise:', value=f'[Horizon]({data["_links"]["self"]["href"]})') if not toml_access: toml_data = None toml_link = 'None' else: toml_data = "Access link" toml_link = toml_access asset_info = Embed( title=" :bank: __Issuer Details__ :bank:", description='Here are the details for specified Asset Query', colour=Colour.lighter_gray()) asset_info.add_field( name=f':regional_indicator_c: Asset Code :regional_indicator_c:', value=f'{record["asset_code"]}') asset_info.add_field(name=f':gem: Asset Type :gem:', value=f'{record["asset_type"]}') asset_info.add_field(name=f':scroll: TOML :scroll: ', value=f'[{toml_data}]({toml_link})') asset_info.add_field(name=f':map: Asset Issuer :map: ', value=f'```{record["asset_issuer"]}```', inline=False) asset_info.add_field(name=f':moneybag: Issued Amount :moneybag: ', value=f'`{record["amount"]} {record["asset_code"]}`', inline=True) asset_info.add_field(name=f':cowboy: Account Count :cowboy: ', value=f'`{record["num_accounts"]}`') asset_info.add_field( name= f':triangular_flag_on_post: Account Flags :triangular_flag_on_post: ', value=f'Immutable: {record["flags"]["auth_immutable"]} \n' f'Required: {record["flags"]["auth_required"]}\n' f'Revocable: {record["flags"]["auth_revocable"]}\n') asset_info.add_field(name=f':white_circle: Paging Token :white_circle:', value=f'```{record["paging_token"]}```', inline=False) await destination.send(embed=asset_info)
async def ledger(self, ctx): if ctx.invoked_subcommand is None: title = ':ledger: __Horizon Ledger Operations__ :ledger:' description = 'Representation of all available commands available to interact with ***Ledger*** endpoint on ' \ 'Stellar Horizon Server. Commands can be used 1/30 seconds/ per user.' list_of_commands = [ {"name": f':information_source: Get information for ledger number :information_source: ', "value": f'```{self.command_string}ledger <ledger number>```'} ] await custom_messages.embed_builder(ctx=ctx, title=title, data=list_of_commands, description=description, destination=1, c=Colour.lighter_gray())
async def send_trades_details(destination, trade_data: dict): """ Send Messages for Trades """ if trade_data["base_asset_type"] != 'native': base_asset = f"{trade_data['base_asset_code']}" base_issuer = f'{trade_data["base_asset_issuer"]}' else: base_asset = 'XLM' base_issuer = f'Stellar' if trade_data["counter_asset_type"] != 'native': counter_asset = f"{trade_data['counter_asset_code']}" counter_issuer = f'{trade_data["counter_asset_issuer"]}' else: counter_asset = 'XLM' counter_issuer = f'Stellar' trade_report = Embed( title=f':id: {trade_data["id"]}', description=f'__**Base seller**__: {trade_data["base_is_seller"]}', colour=Colour.lighter_gray()) trade_report.add_field(name=f':calendar: Close Time :calendar: ', value=f'`{trade_data["ledger_close_time"]}`') trade_report.add_field(name=f':white_circle: Paging Token :white_circle:', value=f'`{trade_data["paging_token"]}`') trade_report.add_field(name=f':map: Offer ID :map:', value=f'`{trade_data["offer_id"]}`', inline=True) trade_report.add_field( name=f':mag_right: Trade Details :mag_right: ', value=f'`{trade_data["base_amount"]} {base_asset}` :currency_exchange: ' f'`{trade_data["counter_amount"]} {counter_asset}`', inline=False) trade_report.add_field(name=f':men_wrestling: Parties :men_wrestling:', value=f'Base:\n' f'```{trade_data["base_account"]}```\n' f'Counter:\n' f'```{trade_data["counter_account"]}```', inline=False) trade_report.add_field( name=f':gem: Asset Details :gem:', value=f':bank: **__ (Base) {base_asset} Issuer Details__** :bank:\n' f'```{base_issuer}```' f':bank: **__ (Counter) {counter_asset} Issuer Details__** :bank:\n' f'```{counter_issuer}```', inline=False) trade_report.add_field( name=f':sunrise: Horizon Links :sunrise:', value=f'[Base]({trade_data["_links"]["base"]["href"]})\n' f'[Counter]({trade_data["_links"]["counter"]["href"]})\n' f'[Operation]({trade_data["_links"]["operation"]["href"]})\n') await destination.send(embed=trade_report)
async def send_operations_basic_details(destination, key_query: str, hrz_link: str): effects_info = Embed( title=f':wrench: {key_query} Operations :wrench: ', description= f'Bellow are last three Operations which happened for {key_query}', colour=Colour.lighter_gray()) effects_info.add_field(name=f':sunrise: Horizon Access :sunrise: ', value=f'[{key_query} Operations]({hrz_link})') effects_info.add_field(name=f':three: Last Three Effects :three: ', value=f':arrow_double_down: ', inline=False) await destination.send(embed=effects_info)
async def ask_for_dev_fee_amount(destination): """ Prompt to user to provide dev fee """ dev_fee_info = Embed(title=":robot: Dev Fee Amount/Value :robot: ", color=Colour.lighter_gray()) dev_fee_info.add_field( name=f':money_with_wings: Value :money_with_wings: ', value= f'Please provide amount in format 0.0000000 you are willing to contribute to ' f'development. Crypto Link will than automatically append Payment operation to the ' f'current transactions.', inline=False) await destination.send(embed=dev_fee_info)
async def send_offers(destination, address, offers_link): address_details = Embed( title=f':clipboard: Offers By Address :clipboard: ', colour=Colour.lighter_gray()) address_details.add_field(name=f':map: Address :map:', value=f'```{address}```', inline=False) address_details.add_field(name=f':sunrise: Horizon Link :sunrise:', value=f'[Offers for account]({offers_link})', inline=False) address_details.add_field(name=f':three: Last 3 Updated Offers :three:', value=f':arrow_double_down:', inline=False) await destination.send(embed=address_details)
async def send_effects(destination, data, usr_query, key_query): horizon_query = data['_links']['self']['href'] effects_info = Embed( title=f':fireworks: {key_query} Effects :fireworks: ', description= f'Bellow are last three effects which happened for {usr_query}', colour=Colour.lighter_gray()) effects_info.add_field(name=f':sunrise: Horizon Access :sunrise: ', value=f'[{key_query} Effects]({horizon_query})') effects_info.add_field(name=f':three: Last Three Effects :three: ', value=f':arrow_double_down: ', inline=False) await destination.send(embed=effects_info)
async def horizon(self, ctx): """ Entry point for horizon queries """ if ctx.invoked_subcommand is None: title = ':sunrise: __Stellar Horizon Access__ :sunrise: ' description = 'Available commands to access Horizon from Discord. All commands have implemented a 30' \ ' seconds cool-down, in order to prevent system-abuse and over-spamming.' list_of_commands = [ {"name": f':office_worker: Accounts :office_worker:', "value": f'`{self.command_string}horizon accounts`'}, {"name": f':money_with_wings: Payments :money_with_wings:', "value": f'`{self.command_string}horizon payments`'}, {"name": f':gem: Assets :gem: ', "value": f'`{self.command_string}horizon assets`'}, {"name": f':fireworks: Effects :fireworks: ', "value": f'`{self.command_string}horizon effects`'}, {"name": f':ledger: Ledger :ledger: ', "value": f'`{self.command_string}horizon ledger`'}, {"name": f':clipboard: Offers :clipboard: ', "value": f'`{self.command_string}horizon offers`'}, {"name": f':wrench: Operations :wrench: ', "value": f'`{self.command_string}horizon operations`'}, {"name": f':book: Order Book :book: ', "value": f'`{self.command_string}horizon book`'}, {"name": f':railway_track: Paths :railway_track: ', "value": f'`{self.command_string}horizon paths`'}, {"name": f':bar_chart: Trade Aggregation :chart_with_upwards_trend: ', "value": f'`{self.command_string}horizon aggregations`'}, {"name": f':currency_exchange: Trades :currency_exchange:', "value": f'`{self.command_string}horizon trades`'}, {"name": f':incoming_envelope: Transactions :incoming_envelope: ', "value": f'`{self.command_string}horizon transactions`'} ] await custom_messages.embed_builder(ctx=ctx, title=title, data=list_of_commands, description=description, destination=1, c=Colour.lighter_gray())
async def dev_fee_option_notification(destination): """ Prompt user if he is willing to give dev fee """ dev_fee_info = Embed( title=":robot: Optional Dev Fee for Crypto Link Team:robot: ", color=Colour.lighter_gray()) dev_fee_info.add_field( name=f':money_with_wings: Dev fee :money_with_wings: ', value= f'If you would like to support us in what we are doing please answer with' f'***__Yes__*** and system will ask you for custom amount you are willing to donate' f' for Crypto Link development..' f'If you choose **__No__** than dev fee will be skipped.', inline=False) await destination.send(embed=dev_fee_info)
async def send_paths_entry_details(destination, details: dict): query_info = Embed( title=f':mag_right: Strict {details["type"]} Payment Search :mag:', description='Bellow is information for 3 results returned from network', colour=Colour.lighter_gray()) query_info.add_field(name=f':map: {details["direction"]} Address :map:', value=f'```{details["address"]}```', inline=False) query_info.add_field( name=f':moneybag: Source Asset :moneybag: ', value=f'`{details["amount"]} {details["asset"].upper()}`', inline=False) query_info.add_field(name=f':bank: Issuer :bank:', value=f'```{details["issuer"]}```', inline=False) await destination.send(embed=query_info)
async def send_details_for_stellar(destination, coin, data, date, signers): acc_details = Embed(title=':mag_right: Details for Stellar Account :mag:', description=f'Last Activity {date} (UTC)', colour=Colour.lighter_gray()) acc_details.add_field(name=':calendar: Last Activity :calendar: ', value=f'`{date}`', inline=False) acc_details.add_field(name=':map: Account Address :map: ', value=f'```{data["account_id"]}```', inline=False) acc_details.add_field( name=':pen_fountain: Account Signers :pen_fountain: ', value=signers, inline=False) acc_details.add_field(name=f' :moneybag: Balance :moneybag:', value=f'`{coin["balance"]} XLM`', inline=False) acc_details.add_field( name=' :genie: Sponsorship Activity :genie:', value=f':money_mouth: {data["num_sponsored"]} (sponsored)\n' f':money_with_wings: {data["num_sponsoring"]} (sponsoring) ', inline=False) acc_details.add_field( name=f':man_judge: Liabilities :man_judge: ', value=f'Buying Liabilities: {coin["buying_liabilities"]}\n' f'Selling Liabilities: {coin["selling_liabilities"]}', inline=False) acc_details.add_field( name=f':scales: Thresholds :scales: ', value=f'High: {data["thresholds"]["high_threshold"]}\n' f'Medium: {data["thresholds"]["med_threshold"]}\n' f'Low: {data["thresholds"]["low_threshold"]}', inline=False) acc_details.add_field( name=f':triangular_flag_on_post: Flags :triangular_flag_on_post:', value=f'Auth Required: {data["flags"]["auth_required"]}\n' f'Auth Revocable: {data["flags"]["auth_revocable"]}\n' f'Auth Immutable:{data["flags"]["auth_immutable"]}') acc_details.add_field( name=f':sunrise: Horizon Link :sunrise:', value= f'[Data]({data["_links"]["data"]["href"]}) | [Offers]({data["_links"]["offers"]["href"]})\n' f'[Transactions]({data["_links"]["transactions"]["href"]}) | [Effects]({data["_links"]["effects"]["href"]})\n' f'[Operations]({data["_links"]["operations"]["href"]}) | [Payments]({data["_links"]["payments"]["href"]})\n' f'[Trades]({data["_links"]["trades"]["href"]})', inline=False) await destination.send(embed=acc_details)
async def send_trades_basic_details(destination, trades_enpoint: str, query_details: dict, hrz_link: str): address_details = Embed( title= f':currency_exchange: Trades for {trades_enpoint.capitalize()} :currency_exchange:', colour=Colour.lighter_gray()) address_details.add_field(name=query_details["by"], value=f'```{query_details["query"]}```', inline=False) address_details.add_field(name=f':sunrise: Horizon Link :sunrise:', value=f'[Trades for Account]({hrz_link})', inline=False) address_details.add_field( name=f':three: Last 3 trades for Account :three:', value=f':arrow_double_down:', inline=False) await destination.send(embed=address_details)
async def transactions(self, ctx): if ctx.invoked_subcommand is None: title = ':incoming_envelope: __Horizon Transactions Operations__ :incoming_envelope:' description = 'Representation of all available commands available to interact with ***Transactions*** ' \ 'Endpoint on Stellar Horizon Server. Commands can be used 1/30 seconds/ per user.\n' \ '`Aliases: tx`' list_of_commands = [ {"name": f':hash: Query by transaction Hash :hash:', "value": f'```{self.command_string}transactions single <Transaction Hash>```\n' f'`Aliases: hash`'}, {"name": f':map: Query by account address :map:', "value": f'```{self.command_string}transactions account <Valid Stellar Address>```\n' f'`Aliases: addr, acc`'}, {"name": f':ledger: Query by ledger :ledger:', "value": f'`{self.command_string}transactions ledger <Ledger Number>`'}, ] await custom_messages.embed_builder(ctx=ctx, title=title, data=list_of_commands, description=description, destination=1, c=Colour.lighter_gray())
async def send_effect_details(destination, effect: dict): effect_type = sub('[^a-zA-Z0-9\n\.]', ' ', effect["type"]) eff_embed = Embed( title=f':fireworks: {effect_type.capitalize()} :fireworks: ', colour=Colour.lighter_gray()) eff_embed.add_field(name=f':calendar: Created :calendar: ', value=f'`{effect["created_at"]}`', inline=False) eff_embed.add_field(name=f':white_circle: Paging Token :white_circle:', value=f'`{effect["paging_token"]}`') eff_embed.add_field(name=f':map: Account :map:', value=f'```{effect["account"]}```', inline=False) eff_embed.add_field(name=f':id: ID :id:', value=f'`{effect["id"]}`', inline=False) eff_embed.add_field( name=f':sunrise: Horizon Link :sunrise: ', value=f'[Effect Link]({effect["_links"]["operation"]["href"]})', inline=False) await destination.send(embed=eff_embed)
async def effects(self, ctx): """ Effects entry point to horizon endpoints """ title = ':fireworks: __Horizon Effects Queries__ :fireworks: ' description = 'Representation of all available commands available to interact with ***Effects*** Endpoint on ' \ 'Stellar Horizon Server. Commands can be used 1/30 seconds/ per user.\n' \ '`Aliases: ef, effect`' list_of_commands = [{ "name": f':map: Query effects for account :map:', "value": f'```{self.command_string}effects account <public account address>```\n' f'`aliases: acc, addr, address`' }, { "name": f' :ledger: Query effects for ledger :ledger: ', "value": f'```{self.command_string}effects ledger <ledger id>```' }, { "name": f':wrench: Query effects for operations :wrench: ', "value": f'```{self.command_string}effects operations <operation id>```\n' f'`aliases: op`' }, { "name": f':hash: Query effects for transactions :hash: ', "value": f'```{self.command_string}effects transaction <transaction hash>```\n' f'`aliases: tx, hash`' }] if ctx.invoked_subcommand is None: await custom_messages.embed_builder(ctx=ctx, title=title, data=list_of_commands, description=description, destination=1, c=Colour.lighter_gray())