Esempio n. 1
0
async def sign_unfreeze(
        freeze: SignFreezeSchema = Body(
            ...,
            example={
                "msg": {
                    "symbol": "BNB",
                    "amount": 1,
                },
                "wallet_name": "wallet_1"
            }),
        req_wallet: WalletConfig = Depends(get_wallet),
        current_user: UserSettings = Depends(get_current_user)):
    """Sign an unfreeze message, returning the hex data

    """
    assert_wallet_has_permission(req_wallet, WalletPermission.FREEZE)
    assert_user_has_wallet_permission(current_user, freeze.wallet_name,
                                      WalletPermission.FREEZE)

    # create the message
    msg = UnFreezeMsg(wallet=req_wallet.wallet, **freeze.msg.dict())

    log_sign_transaction(current_user, req_wallet, msg)

    return {'signed_msg': msg.to_hex_data()}
async def sign_cancel_order(
        cancel_order: SignCancelOrderSchema = Body(
            ...,
            example={
                "msg": {
                    "order_id": "<order_id>",
                    "symbol": "ANN-457_BNB"
                },
                "wallet_name": "wallet_1"
            }),
        req_wallet: WalletConfig = Depends(get_wallet),
        current_user: UserSettings = Depends(get_current_user)):
    """Sign a cancel order message, returning the hex data

    """
    assert_wallet_has_permission(req_wallet, WalletPermission.TRADE)
    assert_user_has_wallet_permission(current_user, cancel_order.wallet_name,
                                      WalletPermission.TRADE)

    # create the message
    msg = CancelOrderMsg(wallet=req_wallet.wallet, **cancel_order.msg.dict())

    log_sign_transaction(current_user, req_wallet, msg)

    return {'signed_msg': msg.to_hex_data()}
async def sign_order(signed_order: SignOrderSchema = Body(
    ...,
    example={
        "msg": {
            "order_type": "LIMIT",
            "price": 0.000396,
            "quantity": 10,
            "side": "buy",
            "symbol": "ANN-457_BNB",
            "time_in_force": "GTE"
        },
        "wallet_name": "wallet_1"
    },
),
                     req_wallet: WalletConfig = Depends(get_wallet),
                     current_user: UserSettings = Depends(get_current_user)):
    """Sign a new order message, returning the hex data

    """
    assert_wallet_has_permission(req_wallet, WalletPermission.TRADE)
    assert_user_has_wallet_permission(current_user, signed_order.wallet_name,
                                      WalletPermission.TRADE)

    # create the message
    msg = NewOrderMsg(wallet=req_wallet.wallet, **signed_order.msg.dict())

    log_sign_transaction(current_user, req_wallet, msg)

    return {'signed_msg': msg.to_hex_data()}
Esempio n. 4
0
async def sign_transfer(
        transfer: SignTransferSchema = Body(
            ...,
            example={
                "msg": {
                    "symbol": "BNB",
                    "amount": 1,
                    "to_address": "<to address>"
                },
                "wallet_name": "wallet_1",
                "memo": "Thanks for the beer"
            }),
        req_wallet: WalletConfig = Depends(get_wallet),
        current_user: UserSettings = Depends(get_current_user)):
    """Sign a transfer message, returning the hex data

    """
    assert_wallet_has_permission(req_wallet, WalletPermission.TRANSFER)
    assert_user_has_wallet_permission(current_user, transfer.wallet_name,
                                      WalletPermission.TRANSFER)

    # create the message
    msg = TransferMsg(wallet=req_wallet.wallet, **transfer.msg.dict())

    log_sign_transaction(current_user, req_wallet, msg)

    return {'signed_msg': msg.to_hex_data()}