示例#1
0
    def push_action(
            self, action, data="{}",
            permission=None, expiration_sec=None, 
            skip_sign=0, dont_broadcast=0, force_unique=0,
            max_cpu_usage=0, max_net_usage=0,
            ref_block=None, delay_sec=0):
        '''Push a transaction with a single action.

        Call *EOSIO cleos* with the *push action* command. Store the result,
        which is an object of the class :class:`.cleos.PushAction`,  as
        the value of the *action* attribute.

        Args:
            action (str or json or filename): Definition of the action to 
                execute on the contract.
            data (str): The arguments to the contract, defaults to empty json.
            permission: defaults to self.

        See definitions of the remaining parameters: \
        :func:`.cleos.common_parameters`.

        Attributes:
            account_name (str): The EOSIO name of the contract's account.
            console (str): *["processed"]["action_traces"][0]["console"]* \
                component of EOSIO cleos responce.
            data (str): *["processed"]["action_traces"][0]["act"]["data"]* \
                component of EOSIO cleos responce.
        '''
        stop_if_account_is_not_set(self)
        data = manager.data_json(data)
        if not permission:
            permission = self

        result = cleos.PushAction(
            self, action, data,
            permission, expiration_sec, 
            skip_sign, dont_broadcast, force_unique,
            max_cpu_usage, max_net_usage,
            ref_block,
            is_verbose=False, json=True)
        
        logger.INFO('''
            * push action ``{}``:
            '''.format(action))

        logger.INFO('''
            {}
        '''.format(re.sub(' +',' ', data)))

        self.action = result
        try:
            self._console = result.console
            logger.DEBUG(self._console)
        except:
            pass

        self.action = result
示例#2
0
    def push_action(account_object,
                    action,
                    data,
                    permission=None,
                    expiration_sec=30,
                    skip_signature=0,
                    dont_broadcast=0,
                    forceUnique=0,
                    max_cpu_usage=0,
                    max_net_usage=0,
                    ref_block=None,
                    json=False):
        data = _data_json(data)

        result = cleos.PushAction(account_object,
                                  action,
                                  data,
                                  permission,
                                  expiration_sec,
                                  skip_signature,
                                  dont_broadcast,
                                  forceUnique,
                                  max_cpu_usage,
                                  max_net_usage,
                                  ref_block,
                                  is_verbose=False,
                                  json=True)

        logger.INFO('''
            * Push action ``{}``:
            '''.format(action))

        logger.INFO('''
            {}
        '''.format(re.sub(' +', ' ', data)))

        account_object.action = result
        try:
            account_object._console = result.console
            logger.DEBUG(account_object._console)
        except:
            pass
        if json:
            logger.OUT(result.out_msg)

        account_object.action = result