Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// FIXME: check for more methods as necessary
if (!recipientAddress && extrinsic && extrinsic.method.methodName === 'transfer') {
errors.recipientAddress = 'Please enter a recipient address.';
}
if (currentAccount === recipientAddress) {
errors.currentAccount = 'You cannot send balance to yourself.';
}
if (!amountAsString) {
errors.amount = 'Please enter an amount';
}
return Object.keys(errors).length
? left(errors)
: right({ amountAsString, currentAccount, recipientAddress, extrinsic, ...rest } as Partial & UserInputs);
}
const failure: (l: string) => TaskEither = l => fromEither(left(l))
(waiting) => [
makeTicket(latch.wait, cancelWait(n, latch)),
left(waiting.offer([n, latch] as const)) as State
] as const,
(ready) => ready >= n ?
export const createErrorResponse = (errorResponse: ErrorResponse): Response =>
either.left(errorResponse);
s.status
? {
...a,
[s.channel.toLowerCase()]: s.status
}
: a,
{}
);
return right>(some(response));
} else {
winston.error(
`getMessageNotificationStatuses|Query error|${
errorOrMaybeNotification.value.body
}`
);
return left>(
new Error(`Error querying for NotificationStatus`)
);
}
}
(waiting) => [new Ticket(IO.of(none), IO.void()), {...current, queue: left(waiting)}],
(available) => {
const asyncChain = async (e: Either, f: (R) => Promise>): Promise> => {
if (e.isRight())
return await f(e.value)
return left(e.value)
}
)).chain(response => {
if (response && response.Code && response.Code === "0") {
return right(response);
} else {
return left(
new Error(`Error sending email: ${response.Code}:${response.Message}`)
);
}
});
}
export const GET: Middleware = decodeMethod(s =>
s.toLowerCase() === 'get' ? right('GET') : left('Unknown verb')
)
(errors: Errors) => left(errors),
(accounts: Accounts) => right(accounts)