Skip to content

Commit 07d6769

Browse files
committed
Use validateType function
1 parent 5e57ada commit 07d6769

File tree

2 files changed

+8
-30
lines changed

2 files changed

+8
-30
lines changed

src/modules/select/wallets/fortmatic.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,15 @@
11
import Fortmatic from "fortmatic"
22
import fortmaticIcon from "../wallet-icons/icon-fortmatic.svg"
33
import { networkName } from "../../../utilities"
4+
import { validateType } from "../../../validation"
45

56
function fortmatic(options) {
6-
if (!options || typeof options !== "object") {
7-
throw new Error(
8-
"An options object is required to initialize fortmatic module"
9-
)
10-
}
7+
validateType({ name: "Fortmatic options", value: options, type: "object" })
118

129
const { apiKey, networkId } = options
1310

14-
if (!apiKey || typeof apiKey !== "string") {
15-
throw new Error(
16-
"A apiKey of type string is required to initialize fortmatic module"
17-
)
18-
}
19-
20-
if (!networkId || typeof networkId !== "number") {
21-
throw new Error(
22-
"A networkId of type number is required to initialize fortmatic module"
23-
)
24-
}
11+
validateType({ name: "apiKey", value: apiKey, type: "string" })
12+
validateType({ name: "networkId", value: networkId, type: "number" })
2513

2614
return {
2715
name: "Fortmatic",

src/modules/select/wallets/portis.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
11
import Portis from "@portis/web3"
22

33
import { networkName } from "../../../utilities"
4+
import { validateType } from "../../../validation"
45
import portisIcon from "../wallet-icons/icon-portis.svg"
56

67
function portis(options) {
7-
if (!options || typeof options !== "object") {
8-
throw new Error("An options object is required to initialize portis module")
9-
}
8+
validateType({ name: "Portis options", value: options, type: "object" })
109

1110
const { apiKey, networkId } = options
1211

13-
if (!apiKey || typeof apiKey !== "string") {
14-
throw new Error(
15-
"A apiKey of type string is required to initialize portis module"
16-
)
17-
}
18-
19-
if (!networkId || typeof networkId !== "number") {
20-
throw new Error(
21-
"A network of type number is required to initialize portis module"
22-
)
23-
}
12+
validateType({ name: "apiKey", value: apiKey, type: "string" })
13+
validateType({ name: "networkId", value: networkId, type: "number" })
2414

2515
return {
2616
name: "Portis",

0 commit comments

Comments
 (0)