File tree Expand file tree Collapse file tree 9 files changed +482
-326
lines changed Expand file tree Collapse file tree 9 files changed +482
-326
lines changed Original file line number Diff line number Diff line change 32
32
"bnc-sdk" : " 0.1.1" ,
33
33
"bowser" : " ^2.5.2" ,
34
34
"fortmatic" : " ^0.8.2" ,
35
- "ow" : " ^0.13.2" ,
36
35
"promise-cancelable" : " ^2.1.1" ,
37
36
"regenerator-runtime" : " ^0.13.3" ,
38
37
"squarelink" : " ^1.1.3" ,
Original file line number Diff line number Diff line change @@ -39,7 +39,6 @@ export default [
39
39
external : [
40
40
"bowser" ,
41
41
"bnc-sdk" ,
42
- "ow" ,
43
42
"bignumber.js" ,
44
43
"svelte-i18n" ,
45
44
"svelte" ,
Original file line number Diff line number Diff line change @@ -15,9 +15,9 @@ import {
15
15
walletInterface
16
16
} from "./stores"
17
17
18
- import { validateInit , validateConfig } from "./validation"
19
18
import { isMobileDevice } from "./utilities"
20
19
import { initializeBlocknative } from "./services"
20
+ import { validateInit , validateConfig } from "./validation"
21
21
22
22
import { version } from "../package.json"
23
23
Original file line number Diff line number Diff line change @@ -2,19 +2,13 @@ import connect from "./connect"
2
2
import network from "./network"
3
3
import balance from "./balance"
4
4
5
+ import { validateDefaultsOptions } from "../../validation"
6
+
5
7
function defaults ( options ) {
6
- if ( ! options || typeof options !== "object" ) {
7
- throw new Error ( "initModules must be called with a valid option object" )
8
- }
8
+ validateDefaultsOptions ( options )
9
9
10
10
const { networkId, minimumBalance } = options
11
11
12
- if ( ! networkId || typeof networkId !== "number" ) {
13
- throw new Error (
14
- "initModules must be called with a property of networkId that is of type Number"
15
- )
16
- }
17
-
18
12
return [ connect ( ) , network ( networkId ) , balance ( minimumBalance || "0" ) ]
19
13
}
20
14
Original file line number Diff line number Diff line change 1
1
import Fortmatic from "fortmatic"
2
2
import fortmaticIcon from "../wallet-icons/icon-fortmatic.svg"
3
3
import { networkName } from "../../../utilities"
4
+ import { validateType } from "../../../validation"
4
5
5
6
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" } )
11
8
12
9
const { apiKey, networkId } = options
13
10
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" } )
25
13
26
14
return {
27
15
name : "Fortmatic" ,
Original file line number Diff line number Diff line change 1
1
import Portis from "@portis/web3"
2
2
3
3
import { networkName } from "../../../utilities"
4
+ import { validateType } from "../../../validation"
4
5
import portisIcon from "../wallet-icons/icon-portis.svg"
5
6
6
7
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" } )
10
9
11
10
const { apiKey, networkId } = options
12
11
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" } )
24
14
25
15
return {
26
16
name : "Portis" ,
Original file line number Diff line number Diff line change 1
1
import { writable , derived } from "svelte/store"
2
2
import Cancelable from "promise-cancelable"
3
- import { validateWalletInterface } from "./validation"
4
3
import { getBlocknative } from "./services"
5
4
import { wait , makeQuerablePromise } from "./utilities"
5
+ import { validateWalletInterface , validateType } from "./validation"
6
6
7
7
export const app = writable ( {
8
8
dappId : null ,
@@ -88,9 +88,7 @@ function createUserStateStore(parameter) {
88
88
subscribe,
89
89
reset : ( ) => set ( null ) ,
90
90
setStateSyncer : stateSyncer => {
91
- if ( ! stateSyncer || typeof stateSyncer !== "object" ) {
92
- throw new Error ( "setStateSyncer must be called with a valid interface" )
93
- }
91
+ validateType ( { name : "stateSyncer" , value : stateSyncer , type : "object" } )
94
92
95
93
if ( stateSyncer . onChange ) {
96
94
stateSyncer . onChange ( set )
@@ -140,9 +138,7 @@ function createBalanceStore() {
140
138
return {
141
139
subscribe,
142
140
setStateSyncer : syncer => {
143
- if ( ! syncer || typeof syncer !== "object" ) {
144
- throw new Error ( "setStateSyncer must be called with a valid interface" )
145
- }
141
+ validateType ( { name : "syncer" , value : syncer , type : "object" } )
146
142
147
143
stateSyncer = syncer
148
144
}
You can’t perform that action at this time.
0 commit comments