commit wip

This commit is contained in:
Claus-Peter Huebner 2023-08-23 01:19:19 +02:00
parent ec9c78dbef
commit 43bd594dc3
3 changed files with 44 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import { LogError } from '@/server/LogError'
import { backendLogger as logger } from '@/server/logger'
import { SendCoinsArgs } from './model/SendCoinsArgs'
import { commitSendCoins } from './query/commitSendCoins'
import { revertSendCoins } from './query/revertSendCoins'
import { voteForSendCoins } from './query/voteForSendCoins'
@ -66,4 +67,21 @@ export class SendCoinsClient {
throw new LogError(`X-Com: revertSendCoins failed for endpoint=${this.endpoint}`, err)
}
}
commitSendCoins = async (args: SendCoinsArgs): Promise<boolean> => {
logger.debug(`X-Com: commitSendCoins against endpoint='${this.endpoint}'...`)
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const { data } = await this.client.rawRequest(commitSendCoins, { args })
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (!data?.commitSendCoins?.acknowledged) {
logger.warn('X-Com: commitSendCoins without response data from endpoint', this.endpoint)
return false
}
logger.debug(`X-Com: commitSendCoins successful from endpoint=${this.endpoint}`)
return true
} catch (err) {
throw new LogError(`X-Com: commitSendCoins failed for endpoint=${this.endpoint}`, err)
}
}
}

View File

@ -0,0 +1,25 @@
import { gql } from 'graphql-request'
export const commitSendCoins = gql`
mutation (
$communityReceiverIdentifier: String!
$userReceiverIdentifier: String!
$amount: Decimal!
$memo: String!
$communitySenderIdentifier: String!
$userSenderIdentifier: String!
$userSenderName: String!
) {
commitSendCoins(
communityReceiverIdentifier: $communityReceiverIdentifier
userReceiverIdentifier: $userReceiverIdentifier
amount: $amount
memo: $memo
communitySenderIdentifier: $communitySenderIdentifier
userSenderIdentifier: $userSenderIdentifier
userSenderName: $userSenderName
) {
acknowledged
}
}
`

View File

@ -1 +1 @@
export { Transaction } from './0071-add-pending_transactions-table/PendingTransaction'
export { PendingTransaction } from './0071-add-pending_transactions-table/PendingTransaction'