Skip to content

Commit ff241a6

Browse files
committed
v0.0.5 fetchWithRetry everywhere except healthcheck
1 parent c6c4a45 commit ff241a6

9 files changed

Lines changed: 88 additions & 74 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "circuitscan",
3-
"version": "0.1.4",
3+
"version": "0.1.5",
44
"main": "cli.js",
55
"type": "module",
66
"author": "numtel <ben@latenightsketches.com>",
@@ -26,7 +26,7 @@
2626
"commander": "^12.0.0",
2727
"hardhat": "npm:hardhat-plugin-noop@0.0.1",
2828
"solc": "^0.8.26",
29-
"viem": "^2.17.8"
29+
"viem": "^2.22.17"
3030
},
3131
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
3232
}

src/StatusLogger.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {cursorUp, cursorLeft} from 'ansi-escapes';
22

3-
import {formatBytes} from './utils.js';
3+
import {formatBytes, fetchWithRetry} from './utils.js';
44

55
export class NotFoundError extends Error {}
66

@@ -57,7 +57,7 @@ export class StatusLogger {
5757
}
5858

5959
async fetchData() {
60-
const response = await fetch(this.url);
60+
const response = await fetchWithRetry(this.url);
6161
if (!response.ok) {
6262
if (response.status === 404 || response.status === 403) {
6363
throw new NotFoundError;

src/circom/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {isHex} from 'viem';
55

66
import {
77
formatBytes,
8+
fetchWithRetry,
89
instanceSizes,
910
loadConfig,
1011
viemChain,
@@ -78,7 +79,7 @@ async function deploy(file, chainId, options) {
7879
throw new Error('INVALID_DEPLOYER_PRIVATE_KEY')
7980
try {
8081
const compiled = await compileFile(file, options);
81-
const contractSource = await (await fetch(`${options.config.blobUrl}build/${compiled.pkgName}/verifier.sol`)).text();
82+
const contractSource = await (await fetchWithRetry(`${options.config.blobUrl}build/${compiled.pkgName}/verifier.sol`)).text();
8283
const deployResult = await deployAndVerifyContractFromSource(contractSource, chain, privateKey, options);
8384
await verifyCircuit(
8485
'verifyCircom',

src/circomMulti/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {readFileSync} from 'node:fs';
22

33
import {
44
loadConfig,
5+
fetchWithRetry,
56
DEFAULT_CONFIG,
67
} from '../utils.js';
78

@@ -24,7 +25,7 @@ async function verifyMulti(file, options) {
2425
};
2526
console.log(`# Verifying groth16 multi-verifier...`);
2627

27-
const response = await fetch(options.config.serverURL, {
28+
const response = await fetchWithRetry(options.config.serverURL, {
2829
method: 'POST',
2930
headers: {
3031
'Content-Type': 'application/json',

src/circuitscan.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ function healthcheckFetch(ip, timeout) {
235235

236236
async function terminateInstance(requestId, apiKey, options) {
237237
const event = {payload: {requestId}, apiKey};
238-
const response = await fetchWithRetry(process.env.LOCAL_TERMINATOR || (options && options.config && options.config.terminatorURL), {
238+
const response = await fetch(process.env.LOCAL_TERMINATOR || (options && options.config && options.config.terminatorURL), {
239239
method: 'POST',
240240
headers: {
241241
'Content-Type': 'application/json',

src/noir/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {join, extname, resolve} from 'node:path';
44
import {isHex} from 'viem';
55

66
import {
7+
fetchWithRetry,
78
instanceSizes,
89
loadConfig,
910
viemChain,
@@ -69,7 +70,7 @@ async function deploy(chainId, packageDir, options) {
6970
if(!options.browserWallet && (!privateKey || !isHex(privateKey) || privateKey.length !== 66))
7071
throw new Error('INVALID_DEPLOYER_PRIVATE_KEY')
7172
const compiled = await compileFile(packageDir, options);
72-
const contractSource = await (await fetch(`${options.config.blobUrl}build/${compiled.pkgName}/verifier.sol`)).text();
73+
const contractSource = await (await fetchWithRetry(`${options.config.blobUrl}build/${compiled.pkgName}/verifier.sol`)).text();
7374
const deployResult = await deployAndVerifyContractFromSource(contractSource, chain, privateKey, options);
7475
await verifyCircuit(
7576
'verifyNoir',

src/solidity.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import solc from 'solc';
44
import { Etherscan } from '@nomicfoundation/hardhat-verify/etherscan.js';
55
import { Sourcify } from '@nomicfoundation/hardhat-verify/sourcify.js';
66

7-
import {delay} from './utils.js';
7+
import {delay, fetchWithRetry} from './utils.js';
88
import {findChain} from './etherscanChains.js';
99

1010
export async function deployAndVerifyContractFromSource(contractSource, chain, privateKey, options) {
@@ -69,7 +69,7 @@ export async function browserDeploy(solcOutput, options) {
6969
};
7070
console.log(`# Uploading contract bytecode...`);
7171

72-
const response = await fetch(options.config.serverURL, {
72+
const response = await fetchWithRetry(options.config.serverURL, {
7373
method: 'POST',
7474
headers: {
7575
'Content-Type': 'application/json',
@@ -92,7 +92,7 @@ export async function browserDeploy(solcOutput, options) {
9292
const deployment = await new Promise((resolve, reject) => {
9393
const interval = setInterval(async () => {
9494
try {
95-
const response = await fetch(`${options.config.blobUrl}browser-deployed/${body.reference}.json`);
95+
const response = await fetchWithRetry(`${options.config.blobUrl}browser-deployed/${body.reference}.json`);
9696
if (!response.ok) {
9797
if (response.status === 404 || response.status === 403) {
9898
throw new NotFoundError;

src/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
1212
export async function loadConfig(options) {
1313
options.instance = options.instance || '4';
1414
try {
15-
const response = await fetch(options.config || process.env.CIRCUITSCAN_CONFIG || DEFAULT_CONFIG);
15+
const response = await fetchWithRetry(options.config || process.env.CIRCUITSCAN_CONFIG || DEFAULT_CONFIG);
1616
const data = await response.json();
1717
options.config = data;
1818
} catch(error) {
@@ -71,7 +71,7 @@ export function generateRandomString(length) {
7171
}
7272

7373
export async function fetchJson(url, body) {
74-
const response = await fetch(url, {
74+
const response = await fetchWithRetry(url, {
7575
method: 'POST',
7676
headers: {
7777
'Content-Type': 'application/json'

yarn.lock

Lines changed: 72 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# yarn lockfile v1
33

44

5-
"@adraffy/ens-normalize@1.10.0":
6-
version "1.10.0"
7-
resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz#d2a39395c587e092d77cbbc80acf956a54f38bf7"
8-
integrity sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==
5+
"@adraffy/ens-normalize@^1.10.1":
6+
version "1.11.0"
7+
resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.11.0.tgz#42cc67c5baa407ac25059fcd7d405cc5ecdb0c33"
8+
integrity sha512-/3DDPKHqqIqxUULp8yP4zODUY1i+2xvVWsv8A79xGWdCAG+8sb0hRh0Rk2QyOJUnnbyPUAZYcpBuRe3nS2OIUg==
99

1010
"@ethersproject/abi@^5.1.2":
1111
version "5.7.0"
@@ -189,24 +189,17 @@
189189
resolved "https://registry.yarnpkg.com/@fastify/busboy/-/busboy-2.1.1.tgz#b9da6a878a371829a0502c9b6c1c143ef6663f4d"
190190
integrity sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==
191191

192-
"@noble/curves@1.4.0":
193-
version "1.4.0"
194-
resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.4.0.tgz#f05771ef64da724997f69ee1261b2417a49522d6"
195-
integrity sha512-p+4cb332SFCrReJkCYe8Xzm0OWi4Jji5jVdIZRL/PmacmDkFNw6MrrV+gGpiPxLHbV+zKFRywUWbaseT+tZRXg==
196-
dependencies:
197-
"@noble/hashes" "1.4.0"
198-
199-
"@noble/curves@~1.4.0":
200-
version "1.4.2"
201-
resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.4.2.tgz#40309198c76ed71bc6dbf7ba24e81ceb4d0d1fe9"
202-
integrity sha512-TavHr8qycMChk8UwMld0ZDRvatedkzWfH8IiaeGCfymOP5i0hSCozz9vHOL0nkwk7HRMlFnAiKpS2jrUmSybcw==
192+
"@noble/curves@1.8.1", "@noble/curves@^1.6.0", "@noble/curves@~1.8.1":
193+
version "1.8.1"
194+
resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.8.1.tgz#19bc3970e205c99e4bdb1c64a4785706bce497ff"
195+
integrity sha512-warwspo+UYUPep0Q+vtdVB4Ugn8GGQj8iyB3gnRWsztmUHTI3S1nhdiWNsPUGL0vud7JlRRk1XEu7Lq1KGTnMQ==
203196
dependencies:
204-
"@noble/hashes" "1.4.0"
197+
"@noble/hashes" "1.7.1"
205198

206-
"@noble/hashes@1.4.0", "@noble/hashes@~1.4.0":
207-
version "1.4.0"
208-
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.4.0.tgz#45814aa329f30e4fe0ba49426f49dfccdd066426"
209-
integrity sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==
199+
"@noble/hashes@1.7.1", "@noble/hashes@^1.5.0", "@noble/hashes@~1.7.1":
200+
version "1.7.1"
201+
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.7.1.tgz#5738f6d765710921e7a751e00c20ae091ed8db0f"
202+
integrity sha512-B8XBPsn4vT/KJAGqDzbwztd+6Yte3P4V7iafm24bxgDe/mlRuK6xmWPuCNrKt2vDafZ8MfJLlchDG/vYafQEjQ==
210203

211204
"@nomicfoundation/hardhat-verify@^2.0.8":
212205
version "2.0.8"
@@ -223,32 +216,32 @@
223216
table "^6.8.0"
224217
undici "^5.14.0"
225218

226-
"@scure/base@~1.1.6":
227-
version "1.1.7"
228-
resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.7.tgz#fe973311a5c6267846aa131bc72e96c5d40d2b30"
229-
integrity sha512-PPNYBslrLNNUQ/Yad37MHYsNQtK67EhWb6WtSvNLLPo7SdVZgkUjD6Dg+5On7zNwmskf8OX7I7Nx5oN+MIWE0g==
219+
"@scure/base@~1.2.2", "@scure/base@~1.2.4":
220+
version "1.2.4"
221+
resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.2.4.tgz#002eb571a35d69bdb4c214d0995dff76a8dcd2a9"
222+
integrity sha512-5Yy9czTO47mqz+/J8GM6GIId4umdCk1wc1q8rKERQulIoc8VP9pzDcghv10Tl2E7R96ZUx/PhND3ESYUQX8NuQ==
230223

231-
"@scure/bip32@1.4.0":
232-
version "1.4.0"
233-
resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.4.0.tgz#4e1f1e196abedcef395b33b9674a042524e20d67"
234-
integrity sha512-sVUpc0Vq3tXCkDGYVWGIZTRfnvu8LoTDaev7vbwh0omSvVORONr960MQWdKqJDCReIEmTj3PAr73O3aoxz7OPg==
224+
"@scure/bip32@1.6.2", "@scure/bip32@^1.5.0":
225+
version "1.6.2"
226+
resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.6.2.tgz#093caa94961619927659ed0e711a6e4bf35bffd0"
227+
integrity sha512-t96EPDMbtGgtb7onKKqxRLfE5g05k7uHnHRM2xdE6BP/ZmxaLtPek4J4KfVn/90IQNrU1IOAqMgiDtUdtbe3nw==
235228
dependencies:
236-
"@noble/curves" "~1.4.0"
237-
"@noble/hashes" "~1.4.0"
238-
"@scure/base" "~1.1.6"
229+
"@noble/curves" "~1.8.1"
230+
"@noble/hashes" "~1.7.1"
231+
"@scure/base" "~1.2.2"
239232

240-
"@scure/bip39@1.3.0":
241-
version "1.3.0"
242-
resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.3.0.tgz#0f258c16823ddd00739461ac31398b4e7d6a18c3"
243-
integrity sha512-disdg7gHuTDZtY+ZdkmLpPCk7fxZSu3gBiEGuoC1XYxv9cGx3Z6cpTggCgW6odSOOIXCiDjuGejW+aJKCY/pIQ==
233+
"@scure/bip39@1.5.4", "@scure/bip39@^1.4.0":
234+
version "1.5.4"
235+
resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.5.4.tgz#07fd920423aa671be4540d59bdd344cc1461db51"
236+
integrity sha512-TFM4ni0vKvCfBpohoh+/lY05i9gRbSwXWngAsF4CABQxoaOHijxuaZ2R6cStDQ5CHtHO9aGJTr4ksVJASRRyMA==
244237
dependencies:
245-
"@noble/hashes" "~1.4.0"
246-
"@scure/base" "~1.1.6"
238+
"@noble/hashes" "~1.7.1"
239+
"@scure/base" "~1.2.4"
247240

248-
abitype@1.0.5:
249-
version "1.0.5"
250-
resolved "https://registry.yarnpkg.com/abitype/-/abitype-1.0.5.tgz#29d0daa3eea867ca90f7e4123144c1d1270774b6"
251-
integrity sha512-YzDhti7cjlfaBhHutMaboYB21Ha3rXR9QTkNJFzYC4kC8YclaiwPBBBJY8ejFdu2wnJeZCVZSMlQJ7fi8S6hsw==
241+
abitype@1.0.8, abitype@^1.0.6:
242+
version "1.0.8"
243+
resolved "https://registry.yarnpkg.com/abitype/-/abitype-1.0.8.tgz#3554f28b2e9d6e9f35eb59878193eabd1b9f46ba"
244+
integrity sha512-ZeiI6h3GnW06uYDLx0etQtX/p8E24UaHHBj57RSjK7YBFe7iuVn07EDpOeP451D06sF27VOz9JJPlIKJmXgkEg==
252245

253246
ajv@^8.0.1:
254247
version "8.16.0"
@@ -507,6 +500,11 @@ escape-string-regexp@^1.0.5:
507500
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
508501
integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==
509502

503+
eventemitter3@5.0.1:
504+
version "5.0.1"
505+
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-5.0.1.tgz#53f5ffd0a492ac800721bb42c66b841de96423c4"
506+
integrity sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==
507+
510508
fast-deep-equal@^3.1.3:
511509
version "3.1.3"
512510
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
@@ -659,10 +657,10 @@ is-unicode-supported@^0.1.0:
659657
resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7"
660658
integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==
661659

662-
isows@1.0.4:
663-
version "1.0.4"
664-
resolved "https://registry.yarnpkg.com/isows/-/isows-1.0.4.tgz#810cd0d90cc4995c26395d2aa4cfa4037ebdf061"
665-
integrity sha512-hEzjY+x9u9hPmBom9IIAqdJCwNLax+xrPb51vEPpERoFlIxgmZcHzsT5jKG06nvInKOBGvReAVz80Umed5CczQ==
660+
isows@1.0.6:
661+
version "1.0.6"
662+
resolved "https://registry.yarnpkg.com/isows/-/isows-1.0.6.tgz#0da29d706fa51551c663c627ace42769850f86e7"
663+
integrity sha512-lPHCayd40oW98/I0uvgaHKWCSvkzY27LjWLbtzOm64yQ+G3Q5npjjbdppU65iZXkK1Zt+kH9pfegli0AYfwYYw==
666664

667665
js-sha3@0.8.0:
668666
version "0.8.0"
@@ -793,6 +791,19 @@ os-tmpdir@~1.0.2:
793791
resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274"
794792
integrity sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==
795793

794+
ox@0.6.7:
795+
version "0.6.7"
796+
resolved "https://registry.yarnpkg.com/ox/-/ox-0.6.7.tgz#afd53f2ecef68b8526660e9d29dee6e6b599a832"
797+
integrity sha512-17Gk/eFsFRAZ80p5eKqv89a57uXjd3NgIf1CaXojATPBuujVc/fQSVhBeAU9JCRB+k7J50WQAyWTxK19T9GgbA==
798+
dependencies:
799+
"@adraffy/ens-normalize" "^1.10.1"
800+
"@noble/curves" "^1.6.0"
801+
"@noble/hashes" "^1.5.0"
802+
"@scure/bip32" "^1.5.0"
803+
"@scure/bip39" "^1.4.0"
804+
abitype "^1.0.6"
805+
eventemitter3 "5.0.1"
806+
796807
p-limit@^3.0.2:
797808
version "3.1.0"
798809
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b"
@@ -971,19 +982,19 @@ uri-js@^4.4.1:
971982
dependencies:
972983
punycode "^2.1.0"
973984

974-
viem@^2.17.8:
975-
version "2.17.8"
976-
resolved "https://registry.yarnpkg.com/viem/-/viem-2.17.8.tgz#79da50ef86fb429d3b36d4ef2f49be5b2999420f"
977-
integrity sha512-AnLX26/8UAVguXvTc+o5jvehAUfoujomH+WLPNCo0Y0ukb9Z4qWpunkHvPyazeExP2V7EevVJB79mstZh0fLsQ==
985+
viem@^2.22.17:
986+
version "2.22.17"
987+
resolved "https://registry.yarnpkg.com/viem/-/viem-2.22.17.tgz#71cb5793d898e7850d440653b0043803c2d00c8d"
988+
integrity sha512-eqNhlPGgRLR29XEVUT2uuaoEyMiaQZEKx63xT1py9OYsE+ZwlVgjnfrqbXad7Flg2iJ0Bs5Hh7o0FfRWUJGHvg==
978989
dependencies:
979-
"@adraffy/ens-normalize" "1.10.0"
980-
"@noble/curves" "1.4.0"
981-
"@noble/hashes" "1.4.0"
982-
"@scure/bip32" "1.4.0"
983-
"@scure/bip39" "1.3.0"
984-
abitype "1.0.5"
985-
isows "1.0.4"
986-
ws "8.17.1"
990+
"@noble/curves" "1.8.1"
991+
"@noble/hashes" "1.7.1"
992+
"@scure/bip32" "1.6.2"
993+
"@scure/bip39" "1.5.4"
994+
abitype "1.0.8"
995+
isows "1.0.6"
996+
ox "0.6.7"
997+
ws "8.18.0"
987998

988999
workerpool@6.2.1:
9891000
version "6.2.1"
@@ -1004,10 +1015,10 @@ wrappy@1:
10041015
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
10051016
integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==
10061017

1007-
ws@8.17.1:
1008-
version "8.17.1"
1009-
resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.1.tgz#9293da530bb548febc95371d90f9c878727d919b"
1010-
integrity sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==
1018+
ws@8.18.0:
1019+
version "8.18.0"
1020+
resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.0.tgz#0d7505a6eafe2b0e712d232b42279f53bc289bbc"
1021+
integrity sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==
10111022

10121023
y18n@^5.0.5:
10131024
version "5.0.8"

0 commit comments

Comments
 (0)