コード例 #1
0
ファイル: resources.py プロジェクト: weilbith/relay
    def post(self, args):
        orderbook = self.trustlines.orderbook
        order = Order(
            exchange_address=args["exchangeContractAddress"],
            maker_address=args["maker"],
            taker_address=args["taker"],
            maker_token=args["makerTokenAddress"],
            taker_token=args["takerTokenAddress"],
            fee_recipient=args["feeRecipient"],
            maker_token_amount=args["makerTokenAmount"],
            taker_token_amount=args["takerTokenAmount"],
            maker_fee=args["makerFee"],
            taker_fee=args["takerFee"],
            expiration_timestamp_in_sec=args["expirationUnixTimestampSec"],
            salt=args["salt"],
            v=args["ecSignature"]["v"],
            r=args["ecSignature"]["r"],
            s=args["ecSignature"]["s"],
        )

        if not order.validate_signature():
            abort(422, message="Invalid ECDSA")

        if not orderbook.validate_exchange_address(order):
            abort(422, message="Invalid Exchange Address")

        if not orderbook.validate_timestamp(order):
            abort(422, message="Order already timed out")

        try:
            self.trustlines.orderbook.add_order(order)
        except OrderInvalidException:
            abort(422, message="Invalid Order")
コード例 #2
0
def test_invalid_signature(invalid_signature_order: Order):
    assert not invalid_signature_order.validate_signature()
    assert not invalid_signature_order.validate()
コード例 #3
0
def test_valid_order(valid_order: Order):
    assert valid_order.validate_addresses()
    assert valid_order.validate_signature()
    assert valid_order.validate()