示例#1
0
    def verify(self, transaction):
        try:
            decoded = DecodedTransaction.from_transaction(transaction, self.ABI)
        except ValueError as e:
            logger.error('Transaction verification failed: %s', str(e))
            return False

        logger.debug('Expected: %s, Actual: %s', self, decoded)
        bounty_guid, = decoded.parameters

        return decoded.value == 0 and \
            guid_as_string(bounty_guid) == self.bounty_guid
示例#2
0
    def __repr__(self):
        method, args = self.abi

        # Display readable guids
        parameters = [
            guid_as_string(p) if t == 'uint128' else p
            for p, t in zip(self.parameters, args)
        ]
        return '{}({})'.format(
            method,
            ', '.join(['{}:{}'.format(v, t)
                       for v, t in zip(parameters, args)]))
示例#3
0
    def verify(self, transaction):
        try:
            decoded = DecodedTransaction.from_transaction(transaction, self.ABI)
        except ValueError as e:
            logger.error('Transaction verification failed: %s', str(e))
            return False

        logger.debug('Expected: %s, Actual: %s', self, decoded)
        bounty_guid, bid, mask, commitment = decoded.parameters

        return decoded.value == 0 and \
            guid_as_string(bounty_guid) == self.bounty_guid and \
            bid == self.bid and \
            commitment == self.commitment and \
            int_to_bool_list(mask, len(self.mask)) == self.mask
示例#4
0
    def verify(self, transaction):
        try:
            decoded = DecodedTransaction.from_transaction(
                transaction, self.ABI)
        except ValueError as e:
            logger.error('Transaction verification failed: %s', str(e))
            return False

        logger.debug('Expected: %s, Actual: %s', self, decoded)
        bounty_guid, index, nonce, verdicts, metadata = decoded.parameters

        # If there is a 1 anywhere beyond the length of items we expect, fail it
        if verdicts >> len(self.verdicts) > 0:
            return False

        return decoded.value == 0 and \
            guid_as_string(bounty_guid) == self.bounty_guid and \
            index == self.index and \
            nonce == self.nonce and \
            int_to_bool_list(verdicts, len(self.verdicts)) == self.verdicts and \
            metadata == self.metadata