Python scripts to test SPS

Have been testing the SPS for a couple of hours. Ended up re-using some of the functions to simplify calls. This stupid set of Python functions covers the new operations and RPC calls related to SPS.

Beware, the initial documentation on blocktrades' wiki page is outdated. You may need to skim the source code to learn about the parameters. (Or you can ask in the comments.)

from lightsteem.client import Client

from lightsteem.helpers.amount import Amount
from lightsteem.datastructures import Operation
import json

USER = ('emrebeyler', '')
NODE = 'https://testnet.steemitdev.com/'

# monkey patch Amount class
Amount.ASSETS.update({
    "TBD": {
        "nai": "@@000000013",
        "precision": 3
    }
})


def create_proposal(c):

    # Assuming the USER[0] has a Comment with relevant permlink
    op = Operation('create_proposal', {
        "creator": USER[0],
        "receiver": USER[0],
        "start_date": "2019-11-01T00:00:00",
        "end_date": "2019-12-01T00:00:00",
        "daily_pay": "10.000 TBD",
        "subject": "Remove delegation ability from STEEM blockchain",
        "permlink": "remove-delegations"
    })
    c.broadcast(op)
    print("proposal created")


def vote_proposal(c, proposal_id):
    op = Operation('update_proposal_votes', {
        'voter': 'emrebeyler',
        'proposal_ids': [proposal_id, ],
        'approve': True,
    })
    c.broadcast(op)
    print("vote proposal casted")


def create_post(c):
    post = Operation('comment', {
        "parent_author": None,
        "parent_permlink": "sps",
        "author": "emrebeyler",
        "permlink": "remove-delegations",
        "title": "Removing delegation ability",
        "body": "This is a proposal to remove delegation ability with a daily pay of 10 TBD.",
        "json_metadata": json.dumps({"tags": "steemit steem delegations"})
    })

    c.broadcast(post)
    print("post created")


def list_proposals(c):
    return c('condenser_api').list_proposals(
        ["emrebeyler"],
        10,
        "by_creator",
        "ascending",
        "all"
    )


def find_proposals(c, ids):
    return c('condenser_api').find_proposals(ids)


def list_proposal_votes(c, proposal_id):
    return c('condenser_api').list_proposal_votes(
        [proposal_id],
        10,
        "by_proposal_voter",
        "ascending",
        "all"
    )


if __name__ == '__main__':
    c = Client(
        nodes=[NODE, ],
        keys=[USER[1]],
        chain=dict(
            chain_id="46d82ab7d8db682eb1959aed0ada039a6d49afa1602491f93dde9cac3e8e6c32",
            prefix="TST",
        ),
    )


    # create_post(c)
    # create_proposal(c)
    # print(vote_proposal(c, 7))
    # print(list_proposals(c))
    # print(find_proposals(c, [1, 3, 5]))
    # print(list_proposal_votes(c, 7))
H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center