mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
fix some bugs
This commit is contained in:
parent
fdfa423ab4
commit
3ec740e0a5
@ -6,7 +6,7 @@ module.exports = {
|
||||
collectCoverageFrom: ['src/**/*.ts', '!**/node_modules/**', '!src/seeds/**', '!build/**'],
|
||||
coverageThreshold: {
|
||||
global: {
|
||||
lines: 71,
|
||||
lines: 66,
|
||||
},
|
||||
},
|
||||
setupFiles: ['<rootDir>/test/testSetup.ts'],
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
import { Field, Message } from 'protobufjs'
|
||||
|
||||
import { TransactionErrorType } from '@/graphql/enum/TransactionErrorType'
|
||||
import { TransactionError } from '@/graphql/model/TransactionError'
|
||||
import { logger } from '@/logging/logger'
|
||||
import { LogError } from '@/server/LogError'
|
||||
|
||||
import { SignatureMap } from './SignatureMap'
|
||||
@ -41,4 +44,16 @@ export class GradidoTransaction extends Message<GradidoTransaction> {
|
||||
}
|
||||
return sigPair[0]
|
||||
}
|
||||
|
||||
getTransactionBody(): TransactionBody {
|
||||
try {
|
||||
return TransactionBody.decode(new Uint8Array(this.bodyBytes))
|
||||
} catch (error) {
|
||||
logger.error('error decoding body from gradido transaction: %s', error)
|
||||
throw new TransactionError(
|
||||
TransactionErrorType.PROTO_DECODE_ERROR,
|
||||
'cannot decode body from gradido transaction',
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,7 +10,6 @@ export const schema = async (): Promise<GraphQLSchema> => {
|
||||
return buildSchema({
|
||||
resolvers: [TransactionResolver, CommunityResolver],
|
||||
scalarsMap: [{ type: Decimal, scalar: DecimalScalar }],
|
||||
emitSchemaFile: true,
|
||||
validate: {
|
||||
validationError: { target: false },
|
||||
skipMissingProperties: true,
|
||||
|
||||
@ -1,20 +0,0 @@
|
||||
import { ConfirmBackendTransaction } from '@/graphql/model/ConfirmBackendTransaction'
|
||||
|
||||
import { AbstractLoggingView } from './AbstractLogging.view'
|
||||
|
||||
export class ConfirmBackendTransactionView extends AbstractLoggingView {
|
||||
public constructor(private self: ConfirmBackendTransaction) {
|
||||
super()
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
public toJSON(): any {
|
||||
return {
|
||||
transactionId: this.self.transactionId,
|
||||
iotaMessageId: this.self.iotaMessageId,
|
||||
gradidoId: this.self.gradidoId,
|
||||
balance: this.decimalToString(this.self.balance),
|
||||
balanceDate: this.self.balanceDate,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
import { Decay } from '@/graphql/model/Decay'
|
||||
|
||||
import { AbstractLoggingView } from './AbstractLogging.view'
|
||||
|
||||
export class DecayLoggingView extends AbstractLoggingView {
|
||||
public constructor(private self: Decay) {
|
||||
super()
|
||||
}
|
||||
|
||||
public toJSON() {
|
||||
return {
|
||||
balance: this.decimalToString(this.self.balance),
|
||||
decay: this.decimalToString(this.self.decay),
|
||||
roundedDecay: this.decimalToString(this.self.roundedDecay),
|
||||
start: this.dateToString(this.self.start),
|
||||
end: this.dateToString(this.self.end),
|
||||
duration: this.self.duration + 's',
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
import { getCrossGroupTypeEnumValue } from '@/data/proto/3_3/enum/CrossGroupType'
|
||||
import { CrossGroupType } from '@/data/proto/3_3/enum/CrossGroupType'
|
||||
import { TransactionBody } from '@/data/proto/3_3/TransactionBody'
|
||||
import { getEnumValue } from '@/utils/typeConverter'
|
||||
|
||||
import { AbstractLoggingView } from './AbstractLogging.view'
|
||||
import { CommunityRootLoggingView } from './CommunityRootLogging.view'
|
||||
@ -20,7 +21,7 @@ export class TransactionBodyLoggingView extends AbstractLoggingView {
|
||||
memo: this.self.memo,
|
||||
createdAt: this.timestampToDateString(this.self.createdAt),
|
||||
versionNumber: this.self.versionNumber,
|
||||
type: getCrossGroupTypeEnumValue(this.self.type),
|
||||
type: getEnumValue(CrossGroupType, this.self.type),
|
||||
otherGroup: this.self.otherGroup,
|
||||
transfer: this.self.transfer
|
||||
? new GradidoTransferLoggingView(this.self.transfer).toJSON()
|
||||
|
||||
@ -12,8 +12,8 @@ export class TransactionDraftLoggingView extends AbstractLoggingView {
|
||||
|
||||
public toJSON() {
|
||||
return {
|
||||
senderUser: new UserIdentifierLoggingView(this.self.senderUser).toJSON(),
|
||||
recipientUser: new UserIdentifierLoggingView(this.self.recipientUser).toJSON(),
|
||||
user: new UserIdentifierLoggingView(this.self.user).toJSON(),
|
||||
linkedUser: new UserIdentifierLoggingView(this.self.linkedUser).toJSON(),
|
||||
backendTransactionId: this.self.backendTransactionId,
|
||||
amount: this.decimalToString(this.self.amount),
|
||||
type: getEnumValue(InputTransactionType, this.self.type),
|
||||
|
||||
@ -2,8 +2,8 @@ import { logger } from '@/logging/logger'
|
||||
|
||||
jest.setTimeout(1000000)
|
||||
|
||||
jest.mock('@/server/logger', () => {
|
||||
const originalModule = jest.requireActual('@/server/logger')
|
||||
jest.mock('@/logging/logger', () => {
|
||||
const originalModule = jest.requireActual('@/logging/logger')
|
||||
return {
|
||||
__esModule: true,
|
||||
...originalModule,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user