Skip to content

Commit

Permalink
fix: refactor code and remove npm packages to eliminate vulnerabiliti…
Browse files Browse the repository at this point in the history
…es (#139)
  • Loading branch information
jfsanchocr authored Aug 29, 2023
1 parent ac14488 commit 5bc29c1
Show file tree
Hide file tree
Showing 11 changed files with 20,455 additions and 27,557 deletions.
17,454 changes: 12,452 additions & 5,002 deletions deployer/package-lock.json

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions deployer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,22 @@
"Michael Connor <[email protected]>"
],
"dependencies": {
"big-integer": "^1.6.47",
"body-parser": "^1.19.0",
"config": "^3.2.2",
"cors": "^2.8.5",
"crypto": "^1.0.1",
"express": "^4.17.1",
"jsonfile": "^5.0.0",
"level": "^5.0.1",
"request": "^2.88.0",
"web3": "^1.2.11"
"web3": "^1.2.11",
"axios": "^0.27.2"
},
"devDependencies": {
"@babel/cli": "^7.6.4",
"@babel/core": "^7.6.4",
"@babel/node": "^7.6.3",
"@babel/preset-env": "^7.6.3",
"@babel/register": "^7.6.2",
"nodemon": "^1.19.4",
"mocha": "^6.2.2"
"nodemon": "^3.0.1",
"mocha": "^10.2.0"
}
}
26 changes: 13 additions & 13 deletions deployer/src/rest/deployer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import request from 'request';
import axios from 'axios';
import config from 'config';
import Web3 from '../web3';

Expand All @@ -13,13 +13,13 @@ async function getContractInterface(contractName) {
return new Promise((resolve, reject) => {
const options = {
url: `${url}/contract/interface`,
method: 'GET',
json: true,
body: { contractName },
method: 'get',
data: { contractName },
};
request(options, (err, res, body) => {
if (err) reject(err);
else resolve(body);
axios(options).then(response => {
resolve(response.data);
}).catch(err => {
reject(err);
});
});
}
Expand All @@ -34,13 +34,13 @@ async function getContractAddress(contractName) {
return new Promise((resolve, reject) => {
const options = {
url: `${url}/contract/address`,
method: 'GET',
json: true,
body: { contractName },
method: 'get',
data: { contractName },
};
request(options, (err, res, body) => {
if (err) reject(err);
else resolve(body);
axios(options).then(response => {
resolve(response.data);
}).catch(err => {
reject(err);
});
});
}
Expand Down
105 changes: 55 additions & 50 deletions deployer/src/rest/merkle-tree.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import request from 'request';
import axios from 'axios';
import config from 'config';
import utilsPoll from '../utils-poll';

Expand All @@ -12,13 +12,13 @@ async function startEventFilter(contractName) {
return new Promise((resolve, reject) => {
const options = {
url: `${url}/start`,
method: 'POST',
json: true,
body: { contractName },
method: 'post',
data: { contractName },
};
request(options, (err, res, body) => {
if (err) reject(err);
else resolve(body.data);
axios(options).then(response => {
resolve(response.data);
}).catch(err => {
reject(err);
});
});
}
Expand All @@ -31,13 +31,13 @@ async function getSiblingPathByLeafIndex(contractName, leafIndex) {
return new Promise((resolve, reject) => {
const options = {
url: `${url}/siblingPath/${leafIndex}`,
method: 'POST',
json: true,
body: { contractName },
method: 'post',
data: { contractName },
};
request(options, (err, res, body) => {
if (err) reject(err);
else resolve(body.data);
axios(options).then(response => {
resolve(response.data);
}).catch(err => {
reject(err);
});
});
}
Expand All @@ -50,13 +50,13 @@ async function getContractInterface(contractName) {
return new Promise((resolve, reject) => {
const options = {
url: `${url}/metadata/contractInterface`,
method: 'GET',
json: true,
body: { contractName },
method: 'get',
data: { contractName },
};
request(options, (err, res, body) => {
if (err) reject(err);
else resolve(body.data);
axios(options).then(response => {
resolve(response.data);
}).catch(err => {
reject(err);
});
});
}
Expand All @@ -69,13 +69,13 @@ async function getContractAddress(contractName) {
return new Promise((resolve, reject) => {
const options = {
url: `${url}/metadata/contractAddress`,
method: 'GET',
json: true,
body: { contractName },
method: 'get',
data: { contractName },
};
request(options, (err, res, body) => {
if (err) reject(err);
else resolve(body.data);
axios(options).then(response => {
resolve(response.data);
}).catch(err => {
reject(err);
});
});
}
Expand All @@ -85,13 +85,14 @@ async function postInterface(contractName, contractInterface) {
return new Promise((resolve, reject) => {
const options = {
url: `${url}/metadata/contractInterface`,
method: 'POST',
method: 'post',
json: true,
body: { contractName, contractInterface },
data: { contractName, contractInterface },
};
request(options, (err, res, body) => {
if (err) reject(err);
else resolve(body.data);
axios(options).then(response => {
resolve(response.data);
}).catch(err => {
reject(err);
});
});
}
Expand Down Expand Up @@ -132,13 +133,14 @@ async function postAddress(contractName, contractAddress) {
return new Promise((resolve, reject) => {
const options = {
url: `${url}/metadata/contractAddress`,
method: 'POST',
method: 'post',
json: true,
body: { contractName, contractAddress },
data: { contractName, contractAddress },
};
request(options, (err, res, body) => {
if (err) reject(err);
else resolve(body.data);
axios(options).then(response => {
resolve(response.data);
}).catch(err => {
reject(err);
});
});
}
Expand Down Expand Up @@ -181,13 +183,14 @@ async function insertTreeHeight(contractName, treeHeight) {
return new Promise((resolve, reject) => {
const options = {
url: `${url}/metadata/treeHeight`,
method: 'POST',
method: 'post',
json: true,
body: { contractName, treeHeight },
data: { contractName, treeHeight },
};
request(options, (err, res, body) => {
if (err) reject(err);
else resolve(body.data);
axios(options).then(response => {
resolve(response.data);
}).catch(err => {
reject(err);
});
});
} catch (err) {
Expand All @@ -204,13 +207,14 @@ async function insertLeaves(contractName, leaves) {
return new Promise((resolve, reject) => {
const options = {
url: `${url}/leaves`,
method: 'POST',
method: 'post',
json: true,
body: { contractName, leaves },
data: { contractName, leaves },
};
request(options, (err, res, body) => {
if (err) reject(err);
else resolve(body.data);
axios(options).then(response => {
resolve(response.data);
}).catch(err => {
reject(err);
});
});
} catch (err) {
Expand All @@ -223,13 +227,14 @@ async function update(contractName) {
return new Promise((resolve, reject) => {
const options = {
url: `${url}/update`,
method: 'PATCH',
method: 'patch',
json: true,
body: { contractName },
data: { contractName },
};
request(options, (err, res, body) => {
if (err) reject(err);
else resolve(body.data);
axios(options).then(response => {
resolve(response.data);
}).catch(err => {
reject(err);
});
});
} catch (err) {
Expand Down
26 changes: 13 additions & 13 deletions deployer/test/rest/deployer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import request from 'request';
import axios from 'axios';
import config from 'config';
import Web3 from '../../src/web3';

Expand All @@ -13,13 +13,13 @@ async function getContractInterface(contractName) {
return new Promise((resolve, reject) => {
const options = {
url: `${url}/contract/interface`,
method: 'GET',
json: true,
body: { contractName },
method: 'get',
data: { contractName },
};
request(options, (err, res, body) => {
if (err) reject(err);
else resolve(body);
axios(options).then(response => {
resolve(response.data);
}).catch(err => {
reject(err);
});
});
}
Expand All @@ -34,13 +34,13 @@ async function getContractAddress(contractName) {
return new Promise((resolve, reject) => {
const options = {
url: `${url}/contract/address`,
method: 'GET',
json: true,
body: { contractName },
method: 'get',
data: { contractName },
};
request(options, (err, res, body) => {
if (err) reject(err);
else resolve(body);
axios(options).then(response => {
resolve(response.data);
}).catch(err => {
reject(err);
});
});
}
Expand Down
Loading

0 comments on commit 5bc29c1

Please sign in to comment.