diff --git a/backend/src/apis/dltConnector/model/TransactionDraft.ts b/backend/src/apis/dltConnector/model/TransactionDraft.ts index fdbce026f..0fae08297 100755 --- a/backend/src/apis/dltConnector/model/TransactionDraft.ts +++ b/backend/src/apis/dltConnector/model/TransactionDraft.ts @@ -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 } diff --git a/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/blockchain.ts b/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/blockchain.ts index 38db2af38..273451e14 100644 --- a/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/blockchain.ts +++ b/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/blockchain.ts @@ -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) diff --git a/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/database.ts b/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/database.ts index f66536c0a..459996642 100644 --- a/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/database.ts +++ b/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/database.ts @@ -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