tick
This commit is contained in:
@ -13,25 +13,26 @@ prisma_client = Prisma()
|
||||
async def init_db():
|
||||
await prisma_client.connect()
|
||||
|
||||
async def store_transaction(wallet_id, transaction_type, sell_currency, sell_amount, sell_value, buy_currency, buy_amount, buy_value, solana_signature, details=None):
|
||||
async def store_transaction(transaction_data):
|
||||
"""
|
||||
Store a transaction record in the database.
|
||||
Store a transaction record in the database using a dictionary.
|
||||
"""
|
||||
await prisma_client.transaction.create(
|
||||
data={
|
||||
'wallet_id': wallet_id,
|
||||
'timestamp': datetime.now().isoformat(),
|
||||
'type': transaction_type,
|
||||
'sell_currency': sell_currency,
|
||||
'sell_amount': sell_amount,
|
||||
'sell_value': sell_value,
|
||||
'buy_currency': buy_currency,
|
||||
'buy_amount': buy_amount,
|
||||
'buy_value': buy_value,
|
||||
'solana_signature': solana_signature,
|
||||
'details': json.dumps(details or {})
|
||||
}
|
||||
)
|
||||
default_data = {
|
||||
'wallet_id': None,
|
||||
'timestamp': datetime.now().isoformat(),
|
||||
'type': None,
|
||||
'sell_currency': None,
|
||||
'sell_amount': 0.0,
|
||||
'sell_value': 0.0,
|
||||
'buy_currency': None,
|
||||
'buy_amount': 0.0,
|
||||
'buy_value': 0.0,
|
||||
'solana_signature': None,
|
||||
'details': json.dumps({}),
|
||||
'status': prisma_client.transactionStatus.ORIGINAL
|
||||
}
|
||||
default_data.update(transaction_data)
|
||||
await prisma_client.transaction.create(data=default_data)
|
||||
|
||||
async def update_holdings(wallet_id, currency, amount_change):
|
||||
holding = await prisma_client.holding.find_first(
|
||||
|
Reference in New Issue
Block a user