-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathbackground.py
More file actions
74 lines (60 loc) · 1.93 KB
/
Copy pathbackground.py
File metadata and controls
74 lines (60 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Copyright (c) The Diem Core Contributors
# SPDX-License-Identifier: Apache-2.0
import sys
from time import sleep
import dramatiq
from pubsub.types import LRWPubSubEvent
from wallet.services.order import (
execute_order,
cover_order,
)
from .utils import retry
from ..logging import debug_log, log_execution
from ..services.kyc import verify_kyc
from ..services.transaction import (
submit_onchain,
process_incoming_transaction,
)
from diem_utils.types.currencies import DiemCurrency
TIME_BEFORE_KYC_APPROVAL = 5
@dramatiq.actor(store_results=True)
@debug_log(None)
def async_start_kyc(user_id: int) -> None:
sys.stdout.write("hhhhhhhhh")
log_execution("Enter async_start_kyc")
sleep(TIME_BEFORE_KYC_APPROVAL)
verify_kyc(user_id)
@dramatiq.actor(store_results=True)
@debug_log(None)
def async_execute_order(order_id, payment_method) -> None:
log_execution("Enter async_execute_order")
execute_order(order_id, payment_method)
@dramatiq.actor(store_results=True)
@debug_log(None)
def async_cover_order(order_id) -> None:
log_execution("Enter async_cover")
cover_order(order_id)
@dramatiq.actor(store_results=True)
@debug_log(None)
def async_external_transaction(transaction_id: int) -> None:
log_execution("Enter async_external_transaction")
submit_onchain(transaction_id=transaction_id)
@dramatiq.actor(store_results=True)
@retry(Exception, delay=1)
def process_incoming_txn(txn: LRWPubSubEvent) -> None:
metadata = txn.metadata
blockchain_version = txn.version
sender_address = txn.sender
receiver_address = txn.receiver
sequence = txn.sequence
amount = txn.amount
currency = DiemCurrency[txn.currency]
process_incoming_transaction(
blockchain_version=blockchain_version,
sender_address=sender_address,
receiver_address=receiver_address,
sequence=sequence,
amount=amount,
currency=currency,
metadata=metadata,
)