-
Notifications
You must be signed in to change notification settings - Fork 6
/
validator.js
58 lines (51 loc) · 2.01 KB
/
validator.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const Joi = require("joi");
const getTransactionLinkParams = Joi.object()
.keys({
txId: Joi.string().required().description("txId is required"),
network: Joi.string().required().description("network is required"),
})
.unknown();
const getWalletLinkParams = Joi.object()
.keys({
walletAddress: Joi.string().required().description("walletAddress is required"),
network: Joi.string().required().description("network is required"),
})
.unknown();
const _identifierDecimalValidator = Joi.object()
.keys({
tokenIdentifier: Joi.string().allow(null).description("tokenIdentifier is optional"),
decimals: Joi.number().integer().allow(null).description("decimals is optional"),
})
.unknown()
.with("tokenIdentifier", "decimals");
const getBalanceParams = Joi.object()
.keys({
address: Joi.string().required().description("address is required"),
network: Joi.string().required().description("network is required"),
options: _identifierDecimalValidator,
})
.unknown();
const getTransactionParams = Joi.object()
.keys({
hash: Joi.string().required().description("hash is required"),
network: Joi.string().required().description("network is required"),
decimals: Joi.number().integer().allow(null).description("decimals is optional"),
})
.unknown();
const sendTransactionParams = Joi.object()
.keys({
to: Joi.string().required().description("to is required"),
amount: Joi.number().required().description("amount is required"),
network: Joi.string().required().description("network is required"),
keyStore: Joi.string().required().description("keyStore is required"),
password: Joi.string().required().description("password is required"),
options: _identifierDecimalValidator,
})
.unknown();
module.exports = {
getTransactionLinkParams,
getWalletLinkParams,
getBalanceParams,
getTransactionParams,
sendTransactionParams,
};