Python Beem Blurt Project #5 - Working on Delegation

in #programming4 years ago

the_art_of_delegation1200x600.png

I started working on Blurt delegation with beem.
Plan is to display

  • incoming delegations: where they are coming from
    in.png

  • outgoing delegations: where they are going to
    out.png

  • expiring delegations: when delegations expire (since it takes 5 days)
    exp.png

Main part is done like this to get all 3 delegation data

    def get_delegation(self):
        # find delegations for username
        data = {}

        if self.username:
            # find outgoing delegatons
            data['outgoing'] = self.account.get_vesting_delegations()
            for value in data['outgoing']:
                # vests to BP conversion
                # vests = Amount(value['vesting_shares'])
                # bp = self.blurt.vests_to_bp(vests.amount)
                # value['bp'] = f'{bp:.3f}'
                value['bp'] = self.vests_to_bp(value['vesting_shares'])

            # find expiring delegatons
            data['expiring'] = self.account.get_expiring_vesting_delegations()
            for value in data['expiring']:
                # vests to BP conversion
                # vests = Amount(value['vesting_shares'])
                # bp = self.blurt.vests_to_bp(vests.amount)
                # value['bp'] = f'{bp:.3f}'
                value['bp'] = self.vests_to_bp(value['vesting_shares'])

            # find incoming delegatons
            data['incoming'] = []
            incoming_temp = dict()
            for operation in self.account.history(
                    only_ops=["delegate_vesting_shares"]):

                if self.username == operation["delegator"]:
                    continue

                if operation["vesting_shares"] == '0.000000 VESTS':
                    incoming_temp.pop(operation["delegator"])
                    continue
                else:
                    incoming_temp[operation["delegator"]] = operation

            for key, value in incoming_temp.items():
                value['bp'] = self.vests_to_bp(value['vesting_shares'])
                data['incoming'].append(value)

        return data

    def vests_to_bp(self, vests):
        # VESTS to BP conversion
        bp = 0.000
        v = Amount(vests)
        bp = self.blurt.vests_to_bp(v.amount)
        bp = f'{bp:.3f}'

        return bp

I think backend is working, but frontend for this is not done... 😂

Every time I work on frontend, I get distracted and feel like I want to change something, but design takes a looong time for me. It is very exausting.
So just added a bear.
ezgif.com_gif_maker.gif
I think I like it like that for now...


Get Rewarded For Browsing! Are you Brave?

happy tears
➡️ Website
➡️ Twitter

Sort:  

This is turning into an extremely useful dapp

😳😳😳 idk...
I am like using like jquery and stuff that is old 😬
I need to modernize it and still a long way to go 🙄

After all, what works, works. I like using php on my backends, but let's keep that a secret mkay?😂

No way!!! PHP?
I thought you were using fancy language like go or something..

On the frontend I like the new shiny stuff, but in the backend I like to have a mature framework like Laravel

Coin Marketplace

STEEM 0.22
TRX 0.25
JST 0.039
BTC 95576.96
ETH 3327.61
USDT 1.00
SBD 3.30