diff --git a/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/bootstrap.ts b/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/bootstrap.ts index a51f87f5d..5e03fbff6 100644 --- a/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/bootstrap.ts +++ b/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/bootstrap.ts @@ -9,8 +9,9 @@ import { addCommunityRootTransaction } from './blockchain' import { Context } from './Context' import { communityDbToCommunity } from './convert' import { loadAdminUsersCache, loadCommunities, loadContributionLinkModeratorCache } from './database' -import { generateKeyPairCommunity } from './keyPair' +import { generateKeyPairCommunity } from './data/keyPair' import { CommunityContext } from './valibot.schema' +import { Balance } from './data/Balance' export async function bootstrap(): Promise { const context = await Context.create() @@ -47,6 +48,8 @@ async function bootstrapCommunities(context: Context): Promise { private static transactionLinkCodes = new Set() static doubleTransactionLinkCodes: string[] = [] - static gmwBalance: BalanceDate | undefined = undefined - static aufBalance: BalanceDate | undefined = undefined getDate(): Date { return this.peek().balanceDate @@ -45,23 +43,6 @@ export class TransactionsSyncRole extends AbstractSyncRole { }) } - updateGmwAuf(amount: Decimal, date: Date) { - if(!TransactionsSyncRole.gmwBalance) { - TransactionsSyncRole.gmwBalance = { balance: amount, date } - } else { - const oldGmwBalanceDate = TransactionsSyncRole.gmwBalance - const newBalance = legacyCalculateDecay(oldGmwBalanceDate.balance, oldGmwBalanceDate.date, date ) - TransactionsSyncRole.gmwBalance = { balance: newBalance, date } - } - if(!TransactionsSyncRole.aufBalance) { - TransactionsSyncRole.aufBalance = { balance: amount, date } - } else { - const oldAufBalanceDate = TransactionsSyncRole.aufBalance - const newBalance = legacyCalculateDecay(oldAufBalanceDate.balance, oldAufBalanceDate.date, date ) - TransactionsSyncRole.aufBalance = { balance: newBalance, date } - } - } - async pushToBlockchain(item: TransactionDb): Promise { const senderCommunityContext = this.context.getCommunityContextByUuid(item.user.communityUuid) const recipientCommunityContext = this.context.getCommunityContextByUuid( diff --git a/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/interaction/syncDbWithBlockchain/UsersSync.role.ts b/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/interaction/syncDbWithBlockchain/UsersSync.role.ts index 0d6c79b38..03563468e 100644 --- a/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/interaction/syncDbWithBlockchain/UsersSync.role.ts +++ b/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/interaction/syncDbWithBlockchain/UsersSync.role.ts @@ -1,7 +1,7 @@ import { addTransaction } from '../../blockchain' import { userDbToTransaction } from '../../convert' import { loadUsers } from '../../database' -import { generateKeyPairUserAccount } from '../../keyPair' +import { generateKeyPairUserAccount } from '../../data/keyPair' import { CreatedUserDb } from '../../valibot.schema' import { AbstractSyncRole } from './AbstractSync.role' diff --git a/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/valibot.schema.ts b/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/valibot.schema.ts index f7d66b6ff..aa4a34685 100644 --- a/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/valibot.schema.ts +++ b/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/valibot.schema.ts @@ -8,7 +8,8 @@ import { memoSchema, uuidv4Schema, } from '../../schemas/typeGuard.schema' -import { TransactionTypeId } from './TransactionTypeId' +import { TransactionTypeId } from './data/TransactionTypeId' +import { Balance } from './data/Balance' export const createdUserDbSchema = v.object({ id: v.pipe(v.number(), v.minValue(1)), @@ -81,6 +82,8 @@ export const communityContextSchema = v.object({ v.maxLength(512, 'expect string length <= 512'), v.regex(/^[a-zA-Z0-9-_]+$/, 'expect string to be a valid (alphanumeric, _, -) folder name'), ), + gmwBalance: v.instance(Balance), + aufBalance: v.instance(Balance), }) export type TransactionDb = v.InferOutput @@ -88,4 +91,5 @@ export type UserDb = v.InferOutput export type CreatedUserDb = v.InferOutput export type TransactionLinkDb = v.InferOutput export type CommunityDb = v.InferOutput +export type Balance = v.InferOutput export type CommunityContext = v.InferOutput