aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/assert.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-08-30 17:12:28 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-08-30 17:12:28 +0800
commit60ad5024ce697c043c55005ffee0ab5319fc6f45 (patch)
tree35ecb160b921eeb35207a002de14d5c83cb69543 /src/utils/assert.ts
parent5149fcdd74f85a452bb45510721bd7ab20de9f98 (diff)
downloaddexon-sol-tools-60ad5024ce697c043c55005ffee0ab5319fc6f45.tar
dexon-sol-tools-60ad5024ce697c043c55005ffee0ab5319fc6f45.tar.gz
dexon-sol-tools-60ad5024ce697c043c55005ffee0ab5319fc6f45.tar.bz2
dexon-sol-tools-60ad5024ce697c043c55005ffee0ab5319fc6f45.tar.lz
dexon-sol-tools-60ad5024ce697c043c55005ffee0ab5319fc6f45.tar.xz
dexon-sol-tools-60ad5024ce697c043c55005ffee0ab5319fc6f45.tar.zst
dexon-sol-tools-60ad5024ce697c043c55005ffee0ab5319fc6f45.zip
Add assert.isWeb3Provider
Diffstat (limited to 'src/utils/assert.ts')
-rw-r--r--src/utils/assert.ts4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/utils/assert.ts b/src/utils/assert.ts
index a26b19311..eb084129c 100644
--- a/src/utils/assert.ts
+++ b/src/utils/assert.ts
@@ -61,6 +61,10 @@ export const assert = {
isBoolean(variableName: string, value: boolean): void {
this.assert(_.isBoolean(value), this.typeAssertionMessage(variableName, 'boolean', value));
},
+ isWeb3Provider(variableName: string, value: Web3.Provider): void {
+ const isWeb3Provider = _.isFunction((value as any).send) || _.isFunction((value as any).sendAsync);
+ this.assert(isWeb3Provider, this.typeAssertionMessage(variableName, 'Web3.Provider', value));
+ },
doesConformToSchema(variableName: string, value: any, schema: Schema): void {
const schemaValidator = new SchemaValidator();
const validationResult = schemaValidator.validate(value, schema);