linting, add claus peters suggestions

This commit is contained in:
einhorn_b 2023-08-29 16:30:33 +02:00
parent 52abda3479
commit 67d48a2eec
8 changed files with 49 additions and 29 deletions

View File

@ -1,6 +1,6 @@
import { MaxLength, MinLength, IsString } from 'class-validator'
import { Decimal } from 'decimal.js-light'
import { ArgsType, Field, Int } from 'type-graphql'
import { ArgsType, Field } from 'type-graphql'
import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from '@/graphql/resolver/const/const'
import { IsPositiveDecimal } from '@/graphql/validator/Decimal'
@ -9,7 +9,11 @@ import { IsPositiveDecimal } from '@/graphql/validator/Decimal'
export class TransactionSendArgs {
@Field(() => String)
@IsString()
identifier: string
recipientCommunityIdentifier: string
@Field(() => String)
@IsString()
recipientIdentifier: string
@Field(() => Decimal)
@IsPositiveDecimal()
@ -19,7 +23,4 @@ export class TransactionSendArgs {
@MaxLength(MEMO_MAX_CHARS)
@MinLength(MEMO_MIN_CHARS)
memo: string
@Field(() => Int)
targetCommunity: number
}

View File

@ -308,15 +308,18 @@ export class TransactionResolver {
@Authorized([RIGHTS.SEND_COINS])
@Mutation(() => Boolean)
async sendCoins(
@Args() { identifier, amount, memo, targetCommunity }: TransactionSendArgs,
@Args()
{ /* recipientCommunityIdentifier, */ recipientIdentifier, amount, memo }: TransactionSendArgs,
@Ctx() context: Context,
): Promise<boolean> {
logger.info(`sendCoins(identifier=${identifier}, amount=${amount}, memo=${memo})`)
logger.info(
`sendCoins(recipientIdentifier=${recipientIdentifier}, amount=${amount}, memo=${memo})`,
)
const senderUser = getUser(context)
// validate recipient user
const recipientUser = await findUserByIdentifier(identifier)
const recipientUser = await findUserByIdentifier(recipientIdentifier)
if (!recipientUser) {
throw new LogError('The recipient user was not found', recipientUser)
}

View File

@ -6,7 +6,7 @@
@click.prevent="updateCommunity(community)"
:key="community.id"
:title="community.description"
:active="value.id === community.id"
:active="value.uuid === community.uuid"
>
{{ community.name }}
</b-dropdown-item>
@ -20,7 +20,12 @@ import { COMMUNITY_NAME } from '@/config'
export default {
name: 'CommunitySwitch',
props: {
value: { type: Object, default: { id: 0, name: COMMUNITY_NAME } },
value: {
type: Object,
default: function () {
return { uuid: '', name: COMMUNITY_NAME }
},
},
},
data() {
return {
@ -29,13 +34,12 @@ export default {
},
methods: {
updateCommunity(community) {
this.value = community
this.$emit('input', this.value)
this.$emit('input', community)
},
setDefaultCommunity() {
// set default community, the only one which isn't foreign
// we assume it is only one entry with foreign = false
if (!this.value.id && this.communities.length) {
if (this.value.uuid === '' && this.communities.length) {
const foundCommunity = this.communities.find((community) => !community.foreign)
if (foundCommunity) {
this.updateCommunity(foundCommunity)

View File

@ -76,7 +76,12 @@ export default {
amount: { type: Number, required: true },
memo: { type: String, required: true },
userName: { type: String, default: '' },
targetCommunity: { type: Object, default: { id: 0, name: COMMUNITY_NAME }},
targetCommunity: {
type: Object,
default: function () {
return { uuid: '', name: COMMUNITY_NAME }
},
},
},
data() {
return {

View File

@ -55,8 +55,8 @@
</b-row>
<b-row>
<b-col class="font-weight-bold">
<community-switch
v-model="form.targetCommunity"
<community-switch
v-model="form.targetCommunity"
:disabled="isBalanceDisabled"
/>
</b-col>
@ -161,7 +161,12 @@ export default {
amount: { type: Number, default: 0 },
memo: { type: String, default: '' },
selected: { type: String, default: 'send' },
targetCommunity: { type: Object, default: { id: 0, name: COMMUNITY_NAME } },
targetCommunity: {
type: Object,
default: function () {
return { uuid: '', name: COMMUNITY_NAME }
},
},
},
data() {
return {
@ -172,7 +177,7 @@ export default {
targetCommunity: this.targetCommunity,
},
radioSelected: this.selected,
userName: ''
userName: '',
}
},
methods: {
@ -195,7 +200,7 @@ export default {
this.form.identifier = ''
this.form.amount = ''
this.form.memo = ''
this.form.targetCommunity = { id: 0, name: COMMUNITY_NAME }
this.form.targetCommunity = { uuid: '', name: COMMUNITY_NAME }
this.$refs.formValidator.validate()
if (this.$route.query && !isEmpty(this.$route.query))
this.$router.replace({ query: undefined })

View File

@ -72,16 +72,16 @@ export const createUser = gql`
export const sendCoins = gql`
mutation(
$identifier: String!
$recipientCommunityIdentifier: String!
$recipientIdentifier: String!
$amount: Decimal!
$memo: String!
$targetCommunity: Int!
) {
sendCoins(
identifier: $identifier,
amount: $amount,
memo: $memo,
targetCommunity: $targetCommunity
recipientCommunityIdentifier: $recipientCommunityIdentifier
recipientIdentifier: $recipientIdentifier
amount: $amount
memo: $memo
)
}
`

View File

@ -75,7 +75,7 @@ export const listGDTEntriesQuery = gql`
export const selectCommunities = gql`
query {
communities {
id
uuid
name
description
foreign

View File

@ -123,9 +123,11 @@ export default {
.mutate({
mutation: sendCoins,
variables: {
...this.transactionData,
// from target community we need only the id
targetCommunity: this.transactionData.targetCommunity.id,
// from target community we need only the uuid
recipientCommunityIdentifier: this.transactionData.targetCommunity.uuid,
recipientIdentifier: this.transactionData.identifier,
amount: this.transactionData.amount,
memo: this.transactionData.memo,
},
})
.then(() => {