Beispiel #1
0
class Oracle(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(), nullable=False)
    address = db.Column(db.String(), nullable=False)
    active = db.Column(db.Integer, nullable=False)

    def __repr__():
        return f"Oracle('{self.id}', '{self.name}', '{self.address}, '{self.active}')"
Beispiel #2
0
class Contracts_types(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    contract_name = db.Column(db.String(), nullable=False)
    source_path = db.Column(db.String(), nullable=False)
    json_path = db.Column(db.String(), nullable=False)
    gas_needed_for_deployment = db.Column(db.Integer, nullable=False)

    def __repr__():
        return f"Contracts_types('{self.id}', '{self.contract_name}', '{self.gas_needed_for_deployment}')"
Beispiel #3
0
class Shipping_tracking(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    uuid = db.Column(db.String(), unique=True)
    shipper = db.Column(db.String(), nullable=False)
    tracking_number = db.Column(db.String(), nullable=False)
    status = db.Column(db.String(), nullable=False)
    last_location = db.Column(db.String(), nullable=False)

    def __repr__():
        return f"Shipping_tracking('{self.id}', '{self.uuid}', '{self.status}' , '{self.tracking_number})"
Beispiel #4
0
class Contracts(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    uuid = db.Column(db.String(), unique=True)
    name = db.Column(db.String(), nullable=True)
    title = db.Column(db.String(), nullable=False)
    owner = db.Column(db.String(), nullable=False)
    # here will be setted the contract address, the string will be empty and will be update to the real value once the contract will be deployed
    contract_address = db.Column(db.String(), nullable=False, default='')
    buyer_address = db.Column(db.String(), nullable=False)
    seller_address = db.Column(db.String(), nullable=False)
    oracle_address = db.Column(db.Integer, nullable=False)
    deployer_address = db.Column(db.Integer, nullable=False)
    contract_time = db.Column(db.Integer, nullable=False)
    shipping_eta = db.Column(db.Integer, nullable=False)
    item_price = db.Column(db.Float, nullable=False)
    shipping_price = db.Column(db.Float, nullable=False)
    status = db.Column(db.Integer, nullable=False)
    request_created = db.Column(db.DateTime,
                                nullable=False,
                                default=datetime.utcnow)
    # this will be update once the contract will be actually deployed on the network
    deployed_date = db.Column(db.DateTime, nullable=True)
    tracked = db.Column(db.Integer, nullable=True)

    def __repr__():
        return f"Contracts('{self.id}', '{self.uuid}', '{self.title}, '{self.status}')"
Beispiel #5
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(20), unique=True, nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    image_file = db.Column(db.String(20),
                           nullable=False,
                           default='default.jpg')
    password = db.Column(db.String(60), nullable=False)
    # wac_credits represent the ammount of ether that the user has sent to the deployer(consider name change)
    wac_credits = db.Column(BIGINT(unsigned=True), default=0)
    receiving_address = db.Column(db.String(), default='')
    recharge_address = db.Column(db.String(), unique=True, nullable=True)

    def get_reset_token(self, expires_sec=1800):
        s = Serializer(current_app.config['SECRET_KEY'], expires_sec)
        return s.dumps({'user_id': self.id}).decode('utf-8')

    @staticmethod
    def verify_reset_token(token):
        s = Serializer(current_app.config['SECRET_KEY'])
        try:
            user_id = s.loads(token)['user_id']
        except:
            return None
        return User.query.get(user_id)

    def __repr__(self):
        return f"User('{self.username}', '{self.email}', '{self.image_file}')"
Beispiel #6
0
class Contracts_info(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    contract_address = db.Column(db.String(), unique=True, nullable=False)
    contract_start = db.Column(db.DateTime, nullable=False)
    contract_end = db.Column(db.DateTime, nullable=False)
    time_item_delivered = db.Column(db.DateTime, nullable=False)
    has_buyer_paid = db.Column(db.Boolean, nullable=False)
    item_price = db.Column(db.Float, nullable=False)
    shipping_price = db.Column(db.Float, nullable=False)
    paid_ammount = db.Column(db.Float, nullable=False)
    refounded = db.Column(db.Boolean, nullable=False)
    ranking = db.Column(db.Integer, nullable=False)
    latest_update = db.Column(db.DateTime, nullable=False)

    def __repr__():
        return f"Contract_info('{self.id}', '{self.name}', '{self.address}, '{self.active}')"
Beispiel #7
0
class Button_data(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    uuid = db.Column(db.String(), unique=True)
    # the user that has created this button
    creator_mail = db.Column(db.String(), nullable=False)
    # the link to the insertion, this can be ommited
    name = db.Column(db.String(), nullable=True)
    title = db.Column(db.String(), nullable=False)
    seller_address = db.Column(db.String(), nullable=False)
    contract_time = db.Column(db.Integer, nullable=False)
    shipping_eta = db.Column(db.Integer, nullable=False)
    item_price = db.Column(db.Float, nullable=False)
    shipping_price = db.Column(db.Float, nullable=False)
    clicked = db.Column(db.Integer, nullable=False)
    button_code = db.Column(db.String(), nullable=False)
    link = db.Column(db.String(), nullable=False)
    currency = db.Column(db.String(), nullable=False)

    def __repr__():
        return f"Button_data('{self.id}', '{self.uuid}', '{self.title}, '{self.seller_address}')"
Beispiel #8
0
class Shipping_info(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    uuid = db.Column(db.String(), unique=True)
    seller_email = db.Column(db.String(), nullable=False)
    buyer_email = db.Column(db.String(), nullable=True)
    buyer_name = db.Column(db.String(), nullable=False)
    buyer_surname = db.Column(db.String(), nullable=False)
    buyer_address = db.Column(db.String(), nullable=False)
    city = db.Column(db.String(), nullable=False)
    street = db.Column(db.String(), nullable=False)
    country = db.Column(db.String(), nullable=False)
    state = db.Column(db.String(), nullable=False)
    postal_code = db.Column(db.String(), nullable=False)

    def __repr__():
        return f"Shipping_info('{self.id}', '{self.uuid}', '{self.seller_mail}, '{self.street}')"