mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'master' of github.com:gradido/gradido into 1734-emails-get-wallet-link
# Conflicts: # backend/src/graphql/resolver/TransactionResolver.ts
This commit is contained in:
commit
f94dc967c0
@ -1,6 +1,5 @@
|
|||||||
import { ObjectType, Field } from 'type-graphql'
|
import { ObjectType, Field } from 'type-graphql'
|
||||||
import Decimal from 'decimal.js-light'
|
import Decimal from 'decimal.js-light'
|
||||||
import CONFIG from '@/config'
|
|
||||||
|
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
export class Balance {
|
export class Balance {
|
||||||
@ -11,7 +10,6 @@ export class Balance {
|
|||||||
balanceGDT: number | null
|
balanceGDT: number | null
|
||||||
count: number
|
count: number
|
||||||
linkCount: number
|
linkCount: number
|
||||||
decayStartBlock?: Date
|
|
||||||
lastBookedDate?: Date | null
|
lastBookedDate?: Date | null
|
||||||
}) {
|
}) {
|
||||||
this.balance = data.balance
|
this.balance = data.balance
|
||||||
@ -20,7 +18,6 @@ export class Balance {
|
|||||||
this.balanceGDT = data.balanceGDT || null
|
this.balanceGDT = data.balanceGDT || null
|
||||||
this.count = data.count
|
this.count = data.count
|
||||||
this.linkCount = data.linkCount
|
this.linkCount = data.linkCount
|
||||||
this.decayStartBlock = data.decayStartBlock || CONFIG.DECAY_START_TIME
|
|
||||||
this.lastBookedDate = data.lastBookedDate || null
|
this.lastBookedDate = data.lastBookedDate || null
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,9 +43,6 @@ export class Balance {
|
|||||||
@Field(() => Number)
|
@Field(() => Number)
|
||||||
linkCount: number
|
linkCount: number
|
||||||
|
|
||||||
@Field(() => Date)
|
|
||||||
decayStartBlock: Date
|
|
||||||
|
|
||||||
// may be null as there may be no transaction
|
// may be null as there may be no transaction
|
||||||
@Field(() => Date, { nullable: true })
|
@Field(() => Date, { nullable: true })
|
||||||
lastBookedDate: Date | null
|
lastBookedDate: Date | null
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
import { Context, getUser } from '@/server/context'
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
||||||
|
|
||||||
import { Resolver, Query, Arg, Args, Authorized, Mutation, Ctx, Int } from 'type-graphql'
|
import { Resolver, Query, Arg, Args, Authorized, Mutation, Ctx, Int } from 'type-graphql'
|
||||||
import {
|
import {
|
||||||
getCustomRepository,
|
getCustomRepository,
|
||||||
@ -137,7 +135,7 @@ export class AdminResolver {
|
|||||||
@Mutation(() => Date, { nullable: true })
|
@Mutation(() => Date, { nullable: true })
|
||||||
async deleteUser(
|
async deleteUser(
|
||||||
@Arg('userId', () => Int) userId: number,
|
@Arg('userId', () => Int) userId: number,
|
||||||
@Ctx() context: any,
|
@Ctx() context: Context,
|
||||||
): Promise<Date | null> {
|
): Promise<Date | null> {
|
||||||
const user = await dbUser.findOne({ id: userId })
|
const user = await dbUser.findOne({ id: userId })
|
||||||
// user exists ?
|
// user exists ?
|
||||||
@ -145,7 +143,7 @@ export class AdminResolver {
|
|||||||
throw new Error(`Could not find user with userId: ${userId}`)
|
throw new Error(`Could not find user with userId: ${userId}`)
|
||||||
}
|
}
|
||||||
// moderator user disabled own account?
|
// moderator user disabled own account?
|
||||||
const moderatorUser = context.user
|
const moderatorUser = getUser(context)
|
||||||
if (moderatorUser.id === userId) {
|
if (moderatorUser.id === userId) {
|
||||||
throw new Error('Moderator can not delete his own account!')
|
throw new Error('Moderator can not delete his own account!')
|
||||||
}
|
}
|
||||||
@ -309,10 +307,10 @@ export class AdminResolver {
|
|||||||
@Mutation(() => Boolean)
|
@Mutation(() => Boolean)
|
||||||
async confirmPendingCreation(
|
async confirmPendingCreation(
|
||||||
@Arg('id', () => Int) id: number,
|
@Arg('id', () => Int) id: number,
|
||||||
@Ctx() context: any,
|
@Ctx() context: Context,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const pendingCreation = await AdminPendingCreation.findOneOrFail(id)
|
const pendingCreation = await AdminPendingCreation.findOneOrFail(id)
|
||||||
const moderatorUser = context.user
|
const moderatorUser = getUser(context)
|
||||||
if (moderatorUser.id === pendingCreation.userId)
|
if (moderatorUser.id === pendingCreation.userId)
|
||||||
throw new Error('Moderator can not confirm own pending creation')
|
throw new Error('Moderator can not confirm own pending creation')
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
import { Context, getUser } from '@/server/context'
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
||||||
|
|
||||||
import { Resolver, Query, Ctx, Authorized } from 'type-graphql'
|
import { Resolver, Query, Ctx, Authorized } from 'type-graphql'
|
||||||
import { Balance } from '@model/Balance'
|
import { Balance } from '@model/Balance'
|
||||||
import { calculateDecay } from '@/util/decay'
|
import { calculateDecay } from '@/util/decay'
|
||||||
@ -16,8 +14,8 @@ import { TransactionLinkRepository } from '@repository/TransactionLink'
|
|||||||
export class BalanceResolver {
|
export class BalanceResolver {
|
||||||
@Authorized([RIGHTS.BALANCE])
|
@Authorized([RIGHTS.BALANCE])
|
||||||
@Query(() => Balance)
|
@Query(() => Balance)
|
||||||
async balance(@Ctx() context: any): Promise<Balance> {
|
async balance(@Ctx() context: Context): Promise<Balance> {
|
||||||
const { user } = context
|
const user = getUser(context)
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
|
|
||||||
const gdtResolver = new GdtResolver()
|
const gdtResolver = new GdtResolver()
|
||||||
|
|||||||
@ -1,6 +1,3 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
||||||
|
|
||||||
import { Resolver, Query, Authorized } from 'type-graphql'
|
import { Resolver, Query, Authorized } from 'type-graphql'
|
||||||
import { RIGHTS } from '@/auth/RIGHTS'
|
import { RIGHTS } from '@/auth/RIGHTS'
|
||||||
import CONFIG from '@/config'
|
import CONFIG from '@/config'
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
import { Context, getUser } from '@/server/context'
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
||||||
|
|
||||||
import { Resolver, Query, Args, Ctx, Authorized, Arg } from 'type-graphql'
|
import { Resolver, Query, Args, Ctx, Authorized, Arg } from 'type-graphql'
|
||||||
import CONFIG from '@/config'
|
import CONFIG from '@/config'
|
||||||
import { GdtEntryList } from '@model/GdtEntryList'
|
import { GdtEntryList } from '@model/GdtEntryList'
|
||||||
@ -16,9 +14,9 @@ export class GdtResolver {
|
|||||||
async listGDTEntries(
|
async listGDTEntries(
|
||||||
@Args()
|
@Args()
|
||||||
{ currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated,
|
{ currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated,
|
||||||
@Ctx() context: any,
|
@Ctx() context: Context,
|
||||||
): Promise<GdtEntryList> {
|
): Promise<GdtEntryList> {
|
||||||
const userEntity = context.user
|
const userEntity = getUser(context)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const resultGDT = await apiGet(
|
const resultGDT = await apiGet(
|
||||||
@ -28,15 +26,15 @@ export class GdtResolver {
|
|||||||
throw new Error(resultGDT.data)
|
throw new Error(resultGDT.data)
|
||||||
}
|
}
|
||||||
return new GdtEntryList(resultGDT.data)
|
return new GdtEntryList(resultGDT.data)
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
throw new Error('GDT Server is not reachable.')
|
throw new Error('GDT Server is not reachable.')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Authorized([RIGHTS.GDT_BALANCE])
|
@Authorized([RIGHTS.GDT_BALANCE])
|
||||||
@Query(() => Number)
|
@Query(() => Number)
|
||||||
async gdtBalance(@Ctx() context: any): Promise<number | null> {
|
async gdtBalance(@Ctx() context: Context): Promise<number | null> {
|
||||||
const { user } = context
|
const user = getUser(context)
|
||||||
try {
|
try {
|
||||||
const resultGDTSum = await apiPost(`${CONFIG.GDT_API_URL}/GdtEntries/sumPerEmailApi`, {
|
const resultGDTSum = await apiPost(`${CONFIG.GDT_API_URL}/GdtEntries/sumPerEmailApi`, {
|
||||||
email: user.email,
|
email: user.email,
|
||||||
@ -45,9 +43,9 @@ export class GdtResolver {
|
|||||||
throw new Error('Call not successful')
|
throw new Error('Call not successful')
|
||||||
}
|
}
|
||||||
return Number(resultGDTSum.data.sum) || 0
|
return Number(resultGDTSum.data.sum) || 0
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log('Could not query GDT Server', err)
|
console.log('Could not query GDT Server')
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,3 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
||||||
|
|
||||||
import { Resolver, Query, Authorized, Arg, Mutation, Args } from 'type-graphql'
|
import { Resolver, Query, Authorized, Arg, Mutation, Args } from 'type-graphql'
|
||||||
import {
|
import {
|
||||||
getKlickTippUser,
|
getKlickTippUser,
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
import { Context, getUser } from '@/server/context'
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
||||||
|
|
||||||
import { Resolver, Args, Arg, Authorized, Ctx, Mutation, Query, Int } from 'type-graphql'
|
import { Resolver, Args, Arg, Authorized, Ctx, Mutation, Query, Int } from 'type-graphql'
|
||||||
import { TransactionLink } from '@model/TransactionLink'
|
import { TransactionLink } from '@model/TransactionLink'
|
||||||
import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink'
|
import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink'
|
||||||
@ -38,9 +36,9 @@ export class TransactionLinkResolver {
|
|||||||
@Mutation(() => TransactionLink)
|
@Mutation(() => TransactionLink)
|
||||||
async createTransactionLink(
|
async createTransactionLink(
|
||||||
@Args() { amount, memo }: TransactionLinkArgs,
|
@Args() { amount, memo }: TransactionLinkArgs,
|
||||||
@Ctx() context: any,
|
@Ctx() context: Context,
|
||||||
): Promise<TransactionLink> {
|
): Promise<TransactionLink> {
|
||||||
const { user } = context
|
const user = getUser(context)
|
||||||
|
|
||||||
const createdDate = new Date()
|
const createdDate = new Date()
|
||||||
const validUntil = transactionLinkExpireDate(createdDate)
|
const validUntil = transactionLinkExpireDate(createdDate)
|
||||||
@ -72,9 +70,9 @@ export class TransactionLinkResolver {
|
|||||||
@Mutation(() => Boolean)
|
@Mutation(() => Boolean)
|
||||||
async deleteTransactionLink(
|
async deleteTransactionLink(
|
||||||
@Arg('id', () => Int) id: number,
|
@Arg('id', () => Int) id: number,
|
||||||
@Ctx() context: any,
|
@Ctx() context: Context,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const { user } = context
|
const user = getUser(context)
|
||||||
|
|
||||||
const transactionLink = await dbTransactionLink.findOne({ id })
|
const transactionLink = await dbTransactionLink.findOne({ id })
|
||||||
if (!transactionLink) {
|
if (!transactionLink) {
|
||||||
@ -113,9 +111,9 @@ export class TransactionLinkResolver {
|
|||||||
async listTransactionLinks(
|
async listTransactionLinks(
|
||||||
@Args()
|
@Args()
|
||||||
{ currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated,
|
{ currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated,
|
||||||
@Ctx() context: any,
|
@Ctx() context: Context,
|
||||||
): Promise<TransactionLink[]> {
|
): Promise<TransactionLink[]> {
|
||||||
const { user } = context
|
const user = getUser(context)
|
||||||
// const now = new Date()
|
// const now = new Date()
|
||||||
const transactionLinks = await dbTransactionLink.find({
|
const transactionLinks = await dbTransactionLink.find({
|
||||||
where: {
|
where: {
|
||||||
@ -136,9 +134,9 @@ export class TransactionLinkResolver {
|
|||||||
@Mutation(() => Boolean)
|
@Mutation(() => Boolean)
|
||||||
async redeemTransactionLink(
|
async redeemTransactionLink(
|
||||||
@Arg('code', () => String) code: string,
|
@Arg('code', () => String) code: string,
|
||||||
@Ctx() context: any,
|
@Ctx() context: Context,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const { user } = context
|
const user = getUser(context)
|
||||||
const transactionLink = await dbTransactionLink.findOneOrFail({ code })
|
const transactionLink = await dbTransactionLink.findOneOrFail({ code })
|
||||||
const linkedUser = await dbUser.findOneOrFail({ id: transactionLink.userId })
|
const linkedUser = await dbUser.findOneOrFail({ id: transactionLink.userId })
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
/* eslint-disable new-cap */
|
/* eslint-disable new-cap */
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
||||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||||
|
|
||||||
import CONFIG from '@/config'
|
import CONFIG from '@/config'
|
||||||
|
|
||||||
|
import { Context, getUser } from '@/server/context'
|
||||||
import { Resolver, Query, Args, Authorized, Ctx, Mutation } from 'type-graphql'
|
import { Resolver, Query, Args, Authorized, Ctx, Mutation } from 'type-graphql'
|
||||||
import { getCustomRepository, getConnection } from '@dbTools/typeorm'
|
import { getCustomRepository, getConnection } from '@dbTools/typeorm'
|
||||||
|
|
||||||
@ -151,10 +150,10 @@ export class TransactionResolver {
|
|||||||
async transactionList(
|
async transactionList(
|
||||||
@Args()
|
@Args()
|
||||||
{ currentPage = 1, pageSize = 25, order = Order.DESC }: Paginated,
|
{ currentPage = 1, pageSize = 25, order = Order.DESC }: Paginated,
|
||||||
@Ctx() context: any,
|
@Ctx() context: Context,
|
||||||
): Promise<TransactionList> {
|
): Promise<TransactionList> {
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
const user = context.user
|
const user = getUser(context)
|
||||||
|
|
||||||
// find current balance
|
// find current balance
|
||||||
const lastTransaction = await dbTransaction.findOne(
|
const lastTransaction = await dbTransaction.findOne(
|
||||||
@ -251,10 +250,10 @@ export class TransactionResolver {
|
|||||||
@Mutation(() => String)
|
@Mutation(() => String)
|
||||||
async sendCoins(
|
async sendCoins(
|
||||||
@Args() { email, amount, memo }: TransactionSendArgs,
|
@Args() { email, amount, memo }: TransactionSendArgs,
|
||||||
@Ctx() context: any,
|
@Ctx() context: Context,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
// TODO this is subject to replay attacks
|
// TODO this is subject to replay attacks
|
||||||
const senderUser = context.user
|
const senderUser = getUser(context)
|
||||||
if (senderUser.pubKey.length !== 32) {
|
if (senderUser.pubKey.length !== 32) {
|
||||||
throw new Error('invalid sender public key')
|
throw new Error('invalid sender public key')
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
||||||
|
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
|
import { Context, getUser } from '@/server/context'
|
||||||
import { Resolver, Query, Args, Arg, Authorized, Ctx, UseMiddleware, Mutation } from 'type-graphql'
|
import { Resolver, Query, Args, Arg, Authorized, Ctx, UseMiddleware, Mutation } from 'type-graphql'
|
||||||
import { getConnection, getCustomRepository } from '@dbTools/typeorm'
|
import { getConnection, getCustomRepository } from '@dbTools/typeorm'
|
||||||
import CONFIG from '@/config'
|
import CONFIG from '@/config'
|
||||||
@ -192,9 +190,9 @@ export class UserResolver {
|
|||||||
@Authorized([RIGHTS.VERIFY_LOGIN])
|
@Authorized([RIGHTS.VERIFY_LOGIN])
|
||||||
@Query(() => User)
|
@Query(() => User)
|
||||||
@UseMiddleware(klicktippNewsletterStateMiddleware)
|
@UseMiddleware(klicktippNewsletterStateMiddleware)
|
||||||
async verifyLogin(@Ctx() context: any): Promise<User> {
|
async verifyLogin(@Ctx() context: Context): Promise<User> {
|
||||||
// TODO refactor and do not have duplicate code with login(see below)
|
// TODO refactor and do not have duplicate code with login(see below)
|
||||||
const userEntity = context.user
|
const userEntity = getUser(context)
|
||||||
const user = new User(userEntity)
|
const user = new User(userEntity)
|
||||||
// user.pubkey = userEntity.pubKey.toString('hex')
|
// user.pubkey = userEntity.pubKey.toString('hex')
|
||||||
// Elopage Status & Stored PublisherId
|
// Elopage Status & Stored PublisherId
|
||||||
@ -218,7 +216,7 @@ export class UserResolver {
|
|||||||
@UseMiddleware(klicktippNewsletterStateMiddleware)
|
@UseMiddleware(klicktippNewsletterStateMiddleware)
|
||||||
async login(
|
async login(
|
||||||
@Args() { email, password, publisherId }: UnsecureLoginArgs,
|
@Args() { email, password, publisherId }: UnsecureLoginArgs,
|
||||||
@Ctx() context: any,
|
@Ctx() context: Context,
|
||||||
): Promise<User> {
|
): Promise<User> {
|
||||||
email = email.trim().toLowerCase()
|
email = email.trim().toLowerCase()
|
||||||
const dbUser = await DbUser.findOneOrFail({ email }, { withDeleted: true }).catch(() => {
|
const dbUser = await DbUser.findOneOrFail({ email }, { withDeleted: true }).catch(() => {
|
||||||
@ -250,7 +248,7 @@ export class UserResolver {
|
|||||||
user.language = dbUser.language
|
user.language = dbUser.language
|
||||||
|
|
||||||
// Elopage Status & Stored PublisherId
|
// Elopage Status & Stored PublisherId
|
||||||
user.hasElopage = await this.hasElopage({ pubKey: dbUser.pubKey.toString('hex') })
|
user.hasElopage = await this.hasElopage({ ...context, user: dbUser })
|
||||||
if (!user.hasElopage && publisherId) {
|
if (!user.hasElopage && publisherId) {
|
||||||
user.publisherId = publisherId
|
user.publisherId = publisherId
|
||||||
// TODO: Check if we can use updateUserInfos
|
// TODO: Check if we can use updateUserInfos
|
||||||
@ -540,9 +538,9 @@ export class UserResolver {
|
|||||||
passwordNew,
|
passwordNew,
|
||||||
coinanimation,
|
coinanimation,
|
||||||
}: UpdateUserInfosArgs,
|
}: UpdateUserInfosArgs,
|
||||||
@Ctx() context: any,
|
@Ctx() context: Context,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const userEntity = context.user
|
const userEntity = getUser(context)
|
||||||
|
|
||||||
if (firstName) {
|
if (firstName) {
|
||||||
userEntity.firstName = firstName
|
userEntity.firstName = firstName
|
||||||
@ -619,7 +617,7 @@ export class UserResolver {
|
|||||||
|
|
||||||
@Authorized([RIGHTS.HAS_ELOPAGE])
|
@Authorized([RIGHTS.HAS_ELOPAGE])
|
||||||
@Query(() => Boolean)
|
@Query(() => Boolean)
|
||||||
async hasElopage(@Ctx() context: any): Promise<boolean> {
|
async hasElopage(@Ctx() context: Context): Promise<boolean> {
|
||||||
const userEntity = context.user
|
const userEntity = context.user
|
||||||
if (!userEntity) {
|
if (!userEntity) {
|
||||||
return false
|
return false
|
||||||
|
|||||||
@ -59,7 +59,6 @@ export const transactionsQuery = gql`
|
|||||||
balanceGDT
|
balanceGDT
|
||||||
count
|
count
|
||||||
balance
|
balance
|
||||||
decayStartBlock
|
|
||||||
transactions {
|
transactions {
|
||||||
id
|
id
|
||||||
typeId
|
typeId
|
||||||
|
|||||||
@ -1,9 +1,24 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
import { Role } from '@/auth/Role'
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
import { User as dbUser } from '@entity/User'
|
||||||
|
import { Transaction as dbTransaction } from '@entity/Transaction'
|
||||||
|
import Decimal from 'decimal.js-light'
|
||||||
|
import { ExpressContext } from 'apollo-server-express'
|
||||||
|
|
||||||
const context = (args: any) => {
|
export interface Context {
|
||||||
|
token: string | null
|
||||||
|
setHeaders: { key: string; value: string }[]
|
||||||
|
role?: Role
|
||||||
|
user?: dbUser
|
||||||
|
// hack to use less DB calls for Balance Resolver
|
||||||
|
lastTransaction?: dbTransaction
|
||||||
|
transactionCount?: number
|
||||||
|
linkCount?: number
|
||||||
|
sumHoldAvailableAmount?: Decimal
|
||||||
|
}
|
||||||
|
|
||||||
|
const context = (args: ExpressContext): Context => {
|
||||||
const authorization = args.req.headers.authorization
|
const authorization = args.req.headers.authorization
|
||||||
let token = null
|
let token: string | null = null
|
||||||
if (authorization) {
|
if (authorization) {
|
||||||
token = authorization.replace(/^Bearer /, '')
|
token = authorization.replace(/^Bearer /, '')
|
||||||
}
|
}
|
||||||
@ -14,4 +29,9 @@ const context = (args: any) => {
|
|||||||
return context
|
return context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getUser = (context: Context): dbUser => {
|
||||||
|
if (context.user) return context.user
|
||||||
|
throw new Error('No user given in context!')
|
||||||
|
}
|
||||||
|
|
||||||
export default context
|
export default context
|
||||||
|
|||||||
@ -1704,9 +1704,9 @@ camelcase@^6.2.0:
|
|||||||
integrity sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==
|
integrity sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==
|
||||||
|
|
||||||
caniuse-lite@^1.0.30001264:
|
caniuse-lite@^1.0.30001264:
|
||||||
version "1.0.30001265"
|
version "1.0.30001325"
|
||||||
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001265.tgz#0613c9e6c922e422792e6fcefdf9a3afeee4f8c3"
|
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001325.tgz"
|
||||||
integrity sha512-YzBnspggWV5hep1m9Z6sZVLOt7vrju8xWooFAgN6BA5qvy98qPAPb7vNUzypFaoh2pb3vlfzbDO8tB57UPGbtw==
|
integrity sha512-sB1bZHjseSjDtijV1Hb7PB2Zd58Kyx+n/9EotvZ4Qcz2K3d0lWB8dB4nb8wN/TsOGFq3UuAm0zQZNQ4SoR7TrQ==
|
||||||
|
|
||||||
chalk@^2.0.0:
|
chalk@^2.0.0:
|
||||||
version "2.4.2"
|
version "2.4.2"
|
||||||
|
|||||||
@ -9,6 +9,7 @@ const mocks = {
|
|||||||
},
|
},
|
||||||
$tc: jest.fn((tc) => tc),
|
$tc: jest.fn((tc) => tc),
|
||||||
$t: jest.fn((t) => t),
|
$t: jest.fn((t) => t),
|
||||||
|
$d: jest.fn((d) => d),
|
||||||
}
|
}
|
||||||
|
|
||||||
const propsData = {
|
const propsData = {
|
||||||
|
|||||||
@ -50,7 +50,6 @@ export default {
|
|||||||
name: 'DecayInformation-StartBlock',
|
name: 'DecayInformation-StartBlock',
|
||||||
props: {
|
props: {
|
||||||
balanceDate: { type: String },
|
balanceDate: { type: String },
|
||||||
decayStartBlock: { type: Date },
|
|
||||||
amount: {
|
amount: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
import DecayInformationLong from '../DecayInformations/DecayInformation-Long'
|
import DecayInformationLong from '../DecayInformations/DecayInformation-Long'
|
||||||
import DecayInformationBeforeStartblock from '../DecayInformations/DecayInformation-BeforeStartblock'
|
import DecayInformationBeforeStartblock from '../DecayInformations/DecayInformation-BeforeStartblock'
|
||||||
import DecayInformationDecayStartblock from '../DecayInformations/DecayInformation-DecayStartblock'
|
import DecayInformationDecayStartblock from '../DecayInformations/DecayInformation-DecayStartblock'
|
||||||
|
import CONFIG from '@/config'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@ -34,14 +35,10 @@ export default {
|
|||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
decayStartBlock: {
|
|
||||||
type: Date,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isStartBlock() {
|
isStartBlock() {
|
||||||
return new Date(this.decay.start).getTime() === this.decayStartBlock.getTime()
|
return new Date(this.decay.start).getTime() === CONFIG.DECAY_START_TIME.getTime()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,7 +26,6 @@
|
|||||||
<transaction-send
|
<transaction-send
|
||||||
class="list-group-item"
|
class="list-group-item"
|
||||||
v-bind="transactions[index]"
|
v-bind="transactions[index]"
|
||||||
:decayStartBlock="decayStartBlock"
|
|
||||||
:previousBookedBalance="previousBookedBalance(index)"
|
:previousBookedBalance="previousBookedBalance(index)"
|
||||||
v-on="$listeners"
|
v-on="$listeners"
|
||||||
/>
|
/>
|
||||||
@ -36,7 +35,6 @@
|
|||||||
<transaction-receive
|
<transaction-receive
|
||||||
class="list-group-item"
|
class="list-group-item"
|
||||||
v-bind="transactions[index]"
|
v-bind="transactions[index]"
|
||||||
:decayStartBlock="decayStartBlock"
|
|
||||||
:previousBookedBalance="previousBookedBalance(index)"
|
:previousBookedBalance="previousBookedBalance(index)"
|
||||||
v-on="$listeners"
|
v-on="$listeners"
|
||||||
/>
|
/>
|
||||||
@ -46,7 +44,6 @@
|
|||||||
<transaction-creation
|
<transaction-creation
|
||||||
class="list-group-item"
|
class="list-group-item"
|
||||||
v-bind="transactions[index]"
|
v-bind="transactions[index]"
|
||||||
:decayStartBlock="decayStartBlock"
|
|
||||||
:previousBookedBalance="previousBookedBalance(index)"
|
:previousBookedBalance="previousBookedBalance(index)"
|
||||||
v-on="$listeners"
|
v-on="$listeners"
|
||||||
/>
|
/>
|
||||||
@ -105,7 +102,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
decayStartBlock: { type: Date },
|
|
||||||
transactions: { default: () => [] },
|
transactions: { default: () => [] },
|
||||||
pageSize: { type: Number, default: 25 },
|
pageSize: { type: Number, default: 25 },
|
||||||
timestamp: { type: Number, default: 0 },
|
timestamp: { type: Number, default: 0 },
|
||||||
|
|||||||
@ -13,6 +13,7 @@ const mocks = {
|
|||||||
locale: 'en',
|
locale: 'en',
|
||||||
},
|
},
|
||||||
$t: jest.fn((t) => t),
|
$t: jest.fn((t) => t),
|
||||||
|
$d: jest.fn((d) => d),
|
||||||
$tc: jest.fn((tc) => tc),
|
$tc: jest.fn((tc) => tc),
|
||||||
$apollo: {
|
$apollo: {
|
||||||
mutate: mockAPIcall,
|
mutate: mockAPIcall,
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
</b-col>
|
</b-col>
|
||||||
<b-col cols="7">
|
<b-col cols="7">
|
||||||
<div class="gdd-transaction-list-item-date">
|
<div class="gdd-transaction-list-item-date">
|
||||||
{{ dateString }}
|
{{ $d(new Date(this.date), 'long') }}
|
||||||
</div>
|
</div>
|
||||||
</b-col>
|
</b-col>
|
||||||
</b-row>
|
</b-row>
|
||||||
@ -28,12 +28,5 @@ export default {
|
|||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
|
||||||
dateString() {
|
|
||||||
return this.diffNow
|
|
||||||
? this.$moment(this.date).locale(this.$i18n.locale).fromNow()
|
|
||||||
: this.$d(new Date(this.date), 'long')
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -27,12 +27,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<b-collapse :class="visible ? 'bg-secondary' : ''" class="pb-4 pt-5" v-model="visible">
|
<b-collapse :class="visible ? 'bg-secondary' : ''" class="pb-4 pt-5" v-model="visible">
|
||||||
<decay-information
|
<decay-information :typeId="typeId" :decay="decay" :amount="amount" />
|
||||||
:typeId="typeId"
|
|
||||||
:decay="decay"
|
|
||||||
:amount="amount"
|
|
||||||
:decayStartBlock="decayStartBlock"
|
|
||||||
/>
|
|
||||||
</b-collapse>
|
</b-collapse>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -82,10 +77,6 @@ export default {
|
|||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
decayStartBlock: {
|
|
||||||
type: Date,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
previousBookedBalance: {
|
previousBookedBalance: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
|
|||||||
@ -12,6 +12,7 @@ const mocks = {
|
|||||||
locale: 'en',
|
locale: 'en',
|
||||||
},
|
},
|
||||||
$t: jest.fn((t) => t),
|
$t: jest.fn((t) => t),
|
||||||
|
$d: jest.fn((d) => d),
|
||||||
$tc: jest.fn((tc) => tc),
|
$tc: jest.fn((tc) => tc),
|
||||||
$apollo: {
|
$apollo: {
|
||||||
query: apolloQueryMock,
|
query: apolloQueryMock,
|
||||||
|
|||||||
@ -33,12 +33,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<b-collapse :class="visible ? 'bg-secondary' : ''" class="pb-4 pt-5" v-model="visible">
|
<b-collapse :class="visible ? 'bg-secondary' : ''" class="pb-4 pt-5" v-model="visible">
|
||||||
<decay-information
|
<decay-information :typeId="typeId" :decay="decay" :amount="amount" />
|
||||||
:typeId="typeId"
|
|
||||||
:decay="decay"
|
|
||||||
:amount="amount"
|
|
||||||
:decayStartBlock="decayStartBlock"
|
|
||||||
/>
|
|
||||||
</b-collapse>
|
</b-collapse>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -87,10 +82,6 @@ export default {
|
|||||||
typeId: {
|
typeId: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
decayStartBlock: {
|
|
||||||
type: Date,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
transactionLinkId: {
|
transactionLinkId: {
|
||||||
type: Number,
|
type: Number,
|
||||||
required: false,
|
required: false,
|
||||||
|
|||||||
@ -33,12 +33,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<b-collapse :class="visible ? 'bg-secondary' : ''" class="pb-4 pt-5" v-model="visible">
|
<b-collapse :class="visible ? 'bg-secondary' : ''" class="pb-4 pt-5" v-model="visible">
|
||||||
<decay-information
|
<decay-information :typeId="typeId" :decay="decay" :amount="amount" />
|
||||||
:typeId="typeId"
|
|
||||||
:decay="decay"
|
|
||||||
:amount="amount"
|
|
||||||
:decayStartBlock="decayStartBlock"
|
|
||||||
/>
|
|
||||||
</b-collapse>
|
</b-collapse>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -88,10 +83,6 @@ export default {
|
|||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
decayStartBlock: {
|
|
||||||
type: Date,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
transactionLinkId: {
|
transactionLinkId: {
|
||||||
type: Number,
|
type: Number,
|
||||||
required: false,
|
required: false,
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
const pkg = require('../../package')
|
const pkg = require('../../package')
|
||||||
|
|
||||||
const constants = {
|
const constants = {
|
||||||
|
DECAY_START_TIME: new Date('2021-05-13 17:46:31'), // GMT+0
|
||||||
CONFIG_VERSION: {
|
CONFIG_VERSION: {
|
||||||
DEFAULT: 'DEFAULT',
|
DEFAULT: 'DEFAULT',
|
||||||
EXPECTED: 'v1.2022-03-18',
|
EXPECTED: 'v1.2022-03-18',
|
||||||
|
|||||||
9
frontend/src/config/index.spec.js
Normal file
9
frontend/src/config/index.spec.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import CONFIG from './index'
|
||||||
|
|
||||||
|
describe('config/index', () => {
|
||||||
|
describe('decay start block', () => {
|
||||||
|
it('has the correct date set', () => {
|
||||||
|
expect(CONFIG.DECAY_START_TIME).toEqual(new Date('2021-05-13 17:46:31'))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@ -52,7 +52,6 @@ export const transactionsQuery = gql`
|
|||||||
balanceGDT
|
balanceGDT
|
||||||
count
|
count
|
||||||
linkCount
|
linkCount
|
||||||
decayStartBlock
|
|
||||||
lastBookedDate
|
lastBookedDate
|
||||||
}
|
}
|
||||||
transactions {
|
transactions {
|
||||||
|
|||||||
@ -26,7 +26,6 @@
|
|||||||
:transactionCount="transactionCount"
|
:transactionCount="transactionCount"
|
||||||
:transactionLinkCount="transactionLinkCount"
|
:transactionLinkCount="transactionLinkCount"
|
||||||
:pending="pending"
|
:pending="pending"
|
||||||
:decayStartBlock="decayStartBlock"
|
|
||||||
@update-transactions="updateTransactions"
|
@update-transactions="updateTransactions"
|
||||||
@set-tunneled-email="setTunneledEmail"
|
@set-tunneled-email="setTunneledEmail"
|
||||||
></router-view>
|
></router-view>
|
||||||
@ -63,7 +62,6 @@ export default {
|
|||||||
transactionLinkCount: 0,
|
transactionLinkCount: 0,
|
||||||
pending: true,
|
pending: true,
|
||||||
visible: false,
|
visible: false,
|
||||||
decayStartBlock: new Date(),
|
|
||||||
tunneledEmail: null,
|
tunneledEmail: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -110,7 +108,6 @@ export default {
|
|||||||
this.balance = Number(transactionList.balance.balance)
|
this.balance = Number(transactionList.balance.balance)
|
||||||
this.transactionCount = transactionList.balance.count
|
this.transactionCount = transactionList.balance.count
|
||||||
this.transactionLinkCount = transactionList.balance.linkCount
|
this.transactionLinkCount = transactionList.balance.linkCount
|
||||||
this.decayStartBlock = new Date(transactionList.balance.decayStartBlock)
|
|
||||||
this.pending = false
|
this.pending = false
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|||||||
@ -109,7 +109,7 @@
|
|||||||
"link-expired": "Der Link ist nicht mehr gültig. Die Gültigkeit ist am {date} abgelaufen.",
|
"link-expired": "Der Link ist nicht mehr gültig. Die Gültigkeit ist am {date} abgelaufen.",
|
||||||
"link-overview": "Linkübersicht",
|
"link-overview": "Linkübersicht",
|
||||||
"links_count": "Aktive Links",
|
"links_count": "Aktive Links",
|
||||||
"links_sum": "Summe deiner versendeten Gradidos",
|
"links_sum": "Offene Links und QR-Codes",
|
||||||
"no-account": "Du besitzt noch kein Gradido Konto",
|
"no-account": "Du besitzt noch kein Gradido Konto",
|
||||||
"no-redeem": "Du darfst deinen eigenen Link nicht einlösen!",
|
"no-redeem": "Du darfst deinen eigenen Link nicht einlösen!",
|
||||||
"not-copied": "Konnte den Link nicht kopieren: {err}",
|
"not-copied": "Konnte den Link nicht kopieren: {err}",
|
||||||
|
|||||||
@ -109,7 +109,7 @@
|
|||||||
"link-expired": "The link is no longer valid. The validity expired on {date}.",
|
"link-expired": "The link is no longer valid. The validity expired on {date}.",
|
||||||
"link-overview": "Link overview",
|
"link-overview": "Link overview",
|
||||||
"links_count": "Active links",
|
"links_count": "Active links",
|
||||||
"links_sum": "Total of your sent Gradidos",
|
"links_sum": "Open links and QR codes",
|
||||||
"no-account": "You don't have a Gradido account yet",
|
"no-account": "You don't have a Gradido account yet",
|
||||||
"no-redeem": "You not allowed to redeem your own link!",
|
"no-redeem": "You not allowed to redeem your own link!",
|
||||||
"not-copied": "Could not copy link: {err}",
|
"not-copied": "Could not copy link: {err}",
|
||||||
|
|||||||
@ -18,7 +18,6 @@
|
|||||||
:transactions="transactions"
|
:transactions="transactions"
|
||||||
:pageSize="5"
|
:pageSize="5"
|
||||||
:timestamp="timestamp"
|
:timestamp="timestamp"
|
||||||
:decayStartBlock="decayStartBlock"
|
|
||||||
:transaction-count="transactionCount"
|
:transaction-count="transactionCount"
|
||||||
:transactionLinkCount="transactionLinkCount"
|
:transactionLinkCount="transactionLinkCount"
|
||||||
:pending="pending"
|
:pending="pending"
|
||||||
@ -49,7 +48,6 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
balance: { type: Number, default: 0 },
|
balance: { type: Number, default: 0 },
|
||||||
GdtBalance: { type: Number, default: 0 },
|
GdtBalance: { type: Number, default: 0 },
|
||||||
decayStartBlock: { type: Date },
|
|
||||||
transactions: {
|
transactions: {
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
|
|||||||
@ -10,7 +10,6 @@
|
|||||||
:transactionLinkCount="transactionLinkCount"
|
:transactionLinkCount="transactionLinkCount"
|
||||||
:transactions="transactions"
|
:transactions="transactions"
|
||||||
:show-pagination="true"
|
:show-pagination="true"
|
||||||
:decayStartBlock="decayStartBlock"
|
|
||||||
@update-transactions="updateTransactions"
|
@update-transactions="updateTransactions"
|
||||||
v-on="$listeners"
|
v-on="$listeners"
|
||||||
/>
|
/>
|
||||||
@ -45,7 +44,6 @@ export default {
|
|||||||
},
|
},
|
||||||
transactionCount: { type: Number, default: 0 },
|
transactionCount: { type: Number, default: 0 },
|
||||||
transactionLinkCount: { type: Number, default: 0 },
|
transactionLinkCount: { type: Number, default: 0 },
|
||||||
decayStartBlock: { type: Date },
|
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user