Skip to content

Commit

Permalink
Merge pull request #926 from cyberway/develop
Browse files Browse the repository at this point in the history
Merge develop to master
  • Loading branch information
s-medvedev authored Oct 17, 2019
2 parents a330398 + 049d4fe commit c5be710
Show file tree
Hide file tree
Showing 4 changed files with 369 additions and 19 deletions.
9 changes: 8 additions & 1 deletion golos.publication/golos.publication.abi
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,13 @@
{"name": "rsharesfn", "type": "wide_t"}
]
},
{
"name": "pool_erase_event",
"base": "",
"fields": [
{"name": "created", "type": "uint64"}
]
},
{
"name": "reward_weight_event",
"base": "",
Expand All @@ -957,7 +964,7 @@
],
"events": [
{"name": "poolstate", "type": "pool_event"},
{"name": "poolerase", "type": "uint64"},
{"name": "poolerase", "type": "pool_erase_event"},
{"name": "poststate", "type": "post_event"},
{"name": "votestate", "type": "vote_event"},
{"name": "rewardweight", "type": "reward_weight_event"},
Expand Down
4 changes: 2 additions & 2 deletions golos.publication/golos.publication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1351,8 +1351,8 @@ void publication::syncpool(std::optional<symbol> tokensymbol) {
auto date_of_oldest_mssg = last_pool->created;
tables::message_table message_table(_self, _self.value);
auto oldest_mssg_itr = message_table.begin();
if (oldest_mssg_itr != message_table.end() && oldest_mssg_itr->date < date_of_oldest_mssg) {
date_of_oldest_mssg = oldest_mssg_itr->date;
if (oldest_mssg_itr != message_table.end() && oldest_mssg_itr->pool_date < date_of_oldest_mssg) {
date_of_oldest_mssg = oldest_mssg_itr->pool_date;
}
auto pool = pools.begin();
while (pool->created < date_of_oldest_mssg) {
Expand Down
52 changes: 47 additions & 5 deletions scripts/testnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _cleos(arguments, *, output=True):
except subprocess.CalledProcessError as e:
import sys
(exception, traceback) = (e, sys.exc_info()[2])

msg = str(exception) + ' with output:\n' + exception.output
raise Exception(msg).with_traceback(traceback)

Expand All @@ -47,7 +47,7 @@ def cleos(arguments, *, keys=None):
return _cleos("push transaction -j --skip-sign '%s'" % trx, output=False)
else:
return _cleos(arguments)


def pushAction(code, action, actor, args, *, additional='', delay=None, expiration=None, providebw=None, keys=None):
additional += ' --delay-sec %d' % delay if delay else ''
Expand Down Expand Up @@ -76,6 +76,38 @@ def removeRootKeys():
def unlockWallet():
cleos('wallet unlock --password %s' % args.wallet_password)

def parseAuthority(auth):
if type(auth) == type([]):
return [parseAuthority(a) for a in auth]
d = auth.split('@',2)
if len(d) == 1:
d.extend(['active'])
return {'actor':d[0], 'permission':d[1]}

def createAction(contract, action, actors, args):
data = cleos("convert pack_action_data {contract} {action} {args}".format(
contract=contract, action=action, args=jsonArg(args))).rstrip()
return {
'account':contract,
'name':action,
'authorization':parseAuthority(actors if type(actors)==type([]) else [actors]),
'data':data
}

class Trx:
def __init__(self, expiration=None):
additional = '--skip-sign --dont-broadcast'
if expiration:
additional += ' --expiration {exp}'.format(exp=expiration)
self.trx = pushAction('cyber', 'checkwin', 'cyber', {}, additional=additional)
self.trx['actions'] = []

def addAction(self, contract, action, actors, args):
self.trx['actions'].append(createAction(contract, action, actors, args))

def getTrx(self):
return self.trx

# --------------------- EOSIO functions ---------------------------------------

def createAuthority(keys, accounts):
Expand Down Expand Up @@ -162,9 +194,19 @@ def createPost(author, permlink, category, header, body, *, beneficiaries=[], pr
'jsonmetadata':''
}, providebw=providebw, keys=keys)

def createComment(author, permlink, pauthor, ppermlink, header, body, *, beneficiaries=[]):
return pushAction('gls.publish', 'createmssg', author,
[author, permlink, pauthor, ppermlink, beneficiaries, 0, False, header, body, 'ru', [], ''])
def createComment(author, permlink, pauthor, ppermlink, header, body, *, beneficiaries=[], providebw=None, keys=None):
return pushAction('gls.publish', 'createmssg', author, {
'message_id':{'author':author, 'permlink':permlink},
'parent_id':{'author':pauthor, 'permlink':ppermlink},
'beneficiaries':beneficiaries,
'tokenprop':0,
'vestpayment':False,
'headermssg':header,
'bodymssg':body,
'languagemssg':'ru',
'tags':[],
'jsonmetadata':''
}, providebw=providebw, keys=keys)

def upvotePost(voter, author, permlink, weight, *, providebw=None, keys=None):
return pushAction('gls.publish', 'upvote', voter, {'voter':voter, 'message_id':{'author':author, 'permlink':permlink}, 'weight':weight}, providebw=providebw, keys=keys)
Expand Down
Loading

0 comments on commit c5be710

Please sign in to comment.