mirror of
https://github.com/IT4Change/gradido.git
synced 2026-03-01 12:44:43 +00:00
precision fixes for dlt migration and live transactions
This commit is contained in:
parent
7912c2517c
commit
56e4d6387c
@ -91,11 +91,13 @@ export class TransactionDraft {
|
||||
if (!senderUserTopic) {
|
||||
throw new Error(`missing topicId for community ${sendingUser.community.id}`)
|
||||
}
|
||||
const createdAtOnlySeconds = transactionLink.createdAt
|
||||
createdAtOnlySeconds.setMilliseconds(0)
|
||||
const draft = new TransactionDraft()
|
||||
draft.user = new AccountIdentifier(senderUserTopic, new CommunityAccountIdentifier(sendingUser.gradidoID))
|
||||
draft.linkedUser = new AccountIdentifier(senderUserTopic, transactionLink.code)
|
||||
draft.type = TransactionType.GRADIDO_DEFERRED_TRANSFER
|
||||
draft.createdAt = transactionLink.createdAt.toISOString()
|
||||
draft.createdAt = createdAtOnlySeconds.toISOString()
|
||||
draft.amount = transactionLink.amount.toString()
|
||||
draft.memo = transactionLink.memo
|
||||
draft.timeoutDuration = CODE_VALID_DAYS_DURATION * 24 * 60 * 60
|
||||
@ -117,11 +119,13 @@ export class TransactionDraft {
|
||||
if (!recipientUserTopic) {
|
||||
throw new Error(`missing topicId for community ${recipientUser.community.id}`)
|
||||
}
|
||||
const createdAtOnlySeconds = createdAt
|
||||
createdAtOnlySeconds.setMilliseconds(0)
|
||||
const draft = new TransactionDraft()
|
||||
draft.user = new AccountIdentifier(senderUserTopic, transactionLink.code)
|
||||
draft.linkedUser = new AccountIdentifier(recipientUserTopic, new CommunityAccountIdentifier(recipientUser.gradidoID))
|
||||
draft.type = TransactionType.GRADIDO_REDEEM_DEFERRED_TRANSFER
|
||||
draft.createdAt = createdAt.toISOString()
|
||||
draft.createdAt = createdAtOnlySeconds.toISOString()
|
||||
draft.amount = amount
|
||||
return draft
|
||||
}
|
||||
|
||||
@ -26,6 +26,7 @@ export const defaultHieroAccount = new HieroAccountId(0, 0, 2)
|
||||
|
||||
function addToBlockchain(builder: GradidoTransactionBuilder, blockchain: InMemoryBlockchain, createdAtTimestamp: Timestamp): boolean {
|
||||
const transaction = builder.build()
|
||||
// TOD: use actual transaction id if exist in dlt_transactions table
|
||||
const transactionId = new HieroTransactionId(createdAtTimestamp, defaultHieroAccount)
|
||||
const interactionSerialize = new InteractionSerialize(transactionId)
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ import { LOG4JS_BASE_CATEGORY } from '../../config/const'
|
||||
import { getLogger } from 'log4js'
|
||||
import { MySql2Database } from 'drizzle-orm/mysql2'
|
||||
import { communitiesTable, transactionLinksTable, transactionsTable, usersTable } from './drizzle.schema'
|
||||
import { asc, sql, eq, isNotNull } from 'drizzle-orm'
|
||||
import { asc, sql, eq, isNotNull, inArray } from 'drizzle-orm'
|
||||
import { alias } from 'drizzle-orm/mysql-core'
|
||||
import { GradidoUnit } from 'gradido-blockchain-js'
|
||||
import {
|
||||
@ -70,6 +70,7 @@ export async function loadTransactions(db: MySql2Database, offset: number, count
|
||||
transactionLink: transactionLinksTable,
|
||||
})
|
||||
.from(transactionsTable)
|
||||
.where(inArray(transactionsTable.typeId, [TransactionTypeId.CREATION, TransactionTypeId.RECEIVE]))
|
||||
.leftJoin(usersTable, eq(transactionsTable.userId, usersTable.id))
|
||||
.leftJoin(linkedUsers, eq(transactionsTable.linkedUserId, linkedUsers.id))
|
||||
.leftJoin(transactionLinksTable, eq(transactionsTable.transactionLinkId, transactionLinksTable.id))
|
||||
@ -102,6 +103,7 @@ export async function loadTransactions(db: MySql2Database, offset: number, count
|
||||
})
|
||||
} catch (e) {
|
||||
if (e instanceof v.ValiError) {
|
||||
logger.error(`table row: ${JSON.stringify(row, null, 2)}`)
|
||||
logger.error(v.flatten(e.issues))
|
||||
}
|
||||
throw e
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user