xeroc / piston-cli

Command line tool to interact with the STEEM network
MIT License
74 stars 33 forks source link

Following using piston #75

Closed pmartynov closed 7 years ago

pmartynov commented 7 years ago

I want to follow a person using piston. What's wrong with this code? Is it something on piston side?

from graphenebase.objects import GrapheneObject, OrderedDict, String, json
from graphenebase.objects import isArgsThisClass
from piston.steem import Steem

class custom_json(GrapheneObject):
    def __init__(self, *args, **kwargs):
        if isArgsThisClass(self, args):
                self.data = args[0].data
        else:
            if len(args) == 1 and len(kwargs) == 0:
                kwargs = args[0]
            super().__init__(OrderedDict([
                ('json', String(json.dumps(kwargs["json"]))),
                ('required_auths', json.dumps(kwargs["required_auths"])),
                ('required_posting_auths', json.dumps(kwargs["required_posting_auths"])),
                ('id', String(kwargs["id"])),
            ]))

def follow(account, following, what):
    json_ = {
        'json': ['follow', {'follower': account, 'following': following, 'what': [what]}],
        'required_posting_auths': [account],
        'required_auths': [],
        'id': 'follow',
    }
    return custom_json(**json_)

steem = Steem(wif='PRIVATE POSTING KEY OF pmartynov')

follow_res = follow('pmartynov', 'xeroc', 'blog')
steem.finalizeOp(follow_res, 'pmartynov', 'posting')
pmartynov commented 7 years ago

self.rpc.verify_authority(tx) fails here with InsufficientAuthorityError for whatever reason.

xeroc commented 7 years ago

Thanks!! I saw this too late and wrote the custom_json already in https://github.com/xeroc/python-steemlib/commit/a35257fab1773a489bb3a769205249379ee703c8 but I will add the follow call!

I'll look into the verify issue

xeroc commented 7 years ago

https://github.com/xeroc/piston/commit/6590ba094046fbc2e800842c43722e10ee5446ce

works here