Пример #1
0
    def table(
            self, table_name, scope="", 
            binary=False, 
            limit=10, lower="", upper="", index="",
            key_type="", encode_type="", reverse=False, show_payer=False
            ):
        '''Retrieve the contents of a database table

        Args:
            table (str): The name of the table as specified by the contract abi.        
            scope (str or .interface.Account): The scope within the account in 
                which the table is found.
            binary (bool): Return the value as BINARY rather than using abi to 
                interpret as JSON. Default is *False*.
            limit (int): The maximum number of rows to return. Default is 10.
            lower (str): JSON representation of lower bound value of key, 
                defaults to first.
            upper (str): JSON representation of upper bound value value of key, 
                defaults to last.
            index (int or str): Index number, 1 - primary (first), 2 - secondary 
                index (in order defined by multi_index), 3 - third index, etc.
                Number or name of index can be specified, 
                e.g. 'secondary' or '2'.
            key_type (str): The key type of --index, primary only supports 
                (i64), all others support (i64, i128, i256, float64, float128, 
                ripemd160, sha256).
                Special type 'name' indicates an account name.
            encode_type (str): The encoding type of key_type 
                (i64 , i128 , float64, float128) only support decimal 
                encoding e.g. 'dec'i256 - supports both 'dec' and 'hex', 
                ripemd160 and sha256 is 'hex' only.
            reverse (bool): Iterate in reverse order.
            show_payer (bool): Show RAM payer.

        Returns:
            :class:`.cleos_set.SetTable` object
        '''
        stop_if_account_is_not_set(self)            
        logger.INFO('''
        * Table ``{}`` for ``{}``
        '''.format(table_name, scope))

        result = cleos_get.GetTable(
                    self, table_name, scope,
                    binary, 
                    limit, lower, upper, index, 
                    key_type, encode_type, reverse, show_payer,
                    is_verbose=False)

        try:
            account_map = manager.account_map()
            scope = account_map[str(scope)]
        except:
            pass

        logger.OUT(result.out_msg)

        return result
Пример #2
0
    def table(self,
              table_name,
              scope="",
              binary=False,
              limit=10,
              key="",
              lower="",
              upper=""):
        '''Retrieve the contents of a database table

        Args:
            scope (str or .interface.Account): The scope within the account in 
                which the table is found.
            table (str): The name of the table as specified by the contract abi.
            binary (bool): Return the value as BINARY rather than using abi to 
                interpret as JSON. Default is *False*.
            limit (int): The maximum number of rows to return. Default is 10.
            lower (str): JSON representation of lower bound value of key, 
                defaults to first.
            upper (str): JSON representation of upper bound value value of key, 
                defaults to last.

        Returns:
            :class:`.cleos_set.SetTable` object
        '''
        logger.INFO('''
        * Table ``{}`` for ``{}``
        '''.format(table_name, scope))

        result = cleos_get.GetTable(self,
                                    table_name,
                                    scope,
                                    binary,
                                    limit,
                                    key,
                                    lower,
                                    upper,
                                    is_verbose=False)

        try:
            account_map = manager.account_map()
            scope = account_map[str(scope)]
        except:
            pass

        logger.OUT(result.out_msg)

        return result