dracoder-web3-package 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +5 -18
  2. package/package.json +3 -2
package/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  const { Web3 } = require("web3");
4
+ const { isAddress } = require("web3-validator");
4
5
  const { abiToken } = require("./helpers/factory_data");
5
6
 
6
7
  const METAMASK_NOT_INSTALLED_MESSAGE = {
@@ -59,15 +60,15 @@ const clientTokenTransfer = async ({
59
60
  throw error;
60
61
  }
61
62
 
62
- if (!web3.utils.isAddress(account)) {
63
+ if (!isAddress(account)) {
63
64
  throw new Error("Not valid account");
64
65
  }
65
66
 
66
- if (!web3.utils.isAddress(tokenAddress)) {
67
+ if (!isAddress(tokenAddress)) {
67
68
  throw new Error("Is not a Token Address");
68
69
  }
69
70
 
70
- if (!web3.utils.isAddress(walletAddressToTransferTo)) {
71
+ if (!isAddress(walletAddressToTransferTo)) {
71
72
  throw new Error("Is not a Wallet Address to transfer to");
72
73
  }
73
74
 
@@ -149,21 +150,7 @@ const isMetamaskInstalled = () => {
149
150
  };
150
151
 
151
152
  const checkWalletFormat = (account) => {
152
- let web3;
153
- if (!checkIfMetamaskIsAvailable()) {
154
- return METAMASK_NOT_INSTALLED_MESSAGE;
155
- }
156
- try {
157
- web3 = new Web3(Metamask);
158
- } catch (error) {
159
- return {
160
- ok: false,
161
- message: "Web3 can not be loaded. Metamask must be installed",
162
- error: error,
163
- };
164
- }
165
-
166
- if (!web3.utils.isAddress(account)) {
153
+ if (!isAddress(account)) {
167
154
  return {
168
155
  ok: false,
169
156
  message: "Wrong address format",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dracoder-web3-package",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "Dracoder package used for web3 provider integration.",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -16,7 +16,8 @@
16
16
  "author": "Dracoder S.L.",
17
17
  "license": "MIT",
18
18
  "dependencies": {
19
- "web3": "^4.4.0"
19
+ "web3": "^4.4.0",
20
+ "web3-validator": "^2.0.6"
20
21
  },
21
22
  "devDependencies": {
22
23
  "@babel/core": "^7.15.0",