Fix forward required in GraphQL mutations (#446)
If no forward variable is set, the API responds with > Cannot read properties of undefined (reading 'map') Co-authored-by: ekzyis <ek@stacker.news>
This commit is contained in:
parent
107a7f9e77
commit
ded3bd680f
|
@ -83,12 +83,12 @@ export function advPostSchemaMembers (client) {
|
|||
.compact((v) => !v.nym && !v.pct)
|
||||
.test({
|
||||
name: 'sum',
|
||||
test: forwards => forwards.map(fwd => Number(fwd.pct)).reduce((sum, cur) => sum + cur, 0) <= 100,
|
||||
test: forwards => forwards ? forwards.map(fwd => Number(fwd.pct)).reduce((sum, cur) => sum + cur, 0) <= 100 : true,
|
||||
message: 'the total forward percentage exceeds 100%'
|
||||
})
|
||||
.test({
|
||||
name: 'uniqueStackers',
|
||||
test: forwards => new Set(forwards.map(fwd => fwd.nym)).size === forwards.length,
|
||||
test: forwards => forwards ? new Set(forwards.map(fwd => fwd.nym)).size === forwards.length : true,
|
||||
message: 'duplicate stackers cannot be specified to receive forwarded sats'
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue