Skip to content

Commit 32ebddf

Browse files
committed
updated to no retries for contract deployments
1 parent 280c2b3 commit 32ebddf

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

utils/functions/fetchWithRetry.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,33 @@ const basePath = process.cwd();
22
const fetch = require("node-fetch");
33
const { AUTH } = require(`${basePath}/src/config.js`);
44

5+
function fetchNoRetry(url, options) {
6+
return new Promise((resolve, reject) => {
7+
options.headers.Authorization = AUTH;
8+
9+
fetch(url, options)
10+
.then((res) => {
11+
const status = res.status;
12+
13+
if (status === 200) {
14+
return res.json();
15+
} else {
16+
throw `ERROR STATUS: ${status}`;
17+
}
18+
})
19+
.then((json) => {
20+
if (json.response === "OK") {
21+
return resolve(json);
22+
} else {
23+
throw `NOK: ${json.error}`;
24+
}
25+
})
26+
.catch((error) => {
27+
console.error(`CATCH ERROR: ${error}`);
28+
});
29+
});
30+
}
31+
532
function fetchWithRetry(url, options) {
633
return new Promise((resolve, reject) => {
734
const fetch_retry = () => {
@@ -34,4 +61,4 @@ function fetchWithRetry(url, options) {
3461
});
3562
}
3663

37-
module.exports = { fetchWithRetry };
64+
module.exports = { fetchNoRetry, fetchWithRetry };

utils/nftport/deployContract.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const fs = require("fs");
44
const yesno = require('yesno');
55

66
const {
7-
fetchWithRetry,
7+
fetchNoRetry,
88
} = require(`${basePath}/utils/functions/fetchWithRetry.js`);
99
const {
1010
CHAIN,
@@ -51,7 +51,7 @@ const deployContract = async () => {
5151
},
5252
body: JSON.stringify(contract),
5353
};
54-
const response = await fetchWithRetry(url, options);
54+
const response = await fetchNoRetry(url, options);
5555
fs.writeFileSync(`${basePath}/build/contract/_deployContractResponse.json`, JSON.stringify(response, null, 2));
5656
if(response.response === "OK") {
5757
console.log(`Contract ${CONTRACT_NAME} deployment started.`);

utils/nftport/retrieveContract.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const basePath = process.cwd();
22
const fs = require("fs");
33

44
const {
5-
fetchWithRetry,
5+
fetchNoRetry,
66
} = require(`${basePath}/utils/functions/fetchWithRetry.js`);
77
const { CHAIN, CONTRACT_NAME } = require(`${basePath}/src/config.js`);
88

@@ -22,7 +22,7 @@ const retrieveContract = async () => {
2222
"Content-Type": "application/json",
2323
},
2424
};
25-
const response = await fetchWithRetry(url, options);
25+
const response = await fetchNoRetry(url, options);
2626
fs.writeFileSync(
2727
`${basePath}/build/contract/_contract.json`,
2828
JSON.stringify(response, null, 2)

0 commit comments

Comments
 (0)