Skip to content

Commit

Permalink
Merge pull request #139 from SmartInvoiceXYZ/develop
Browse files Browse the repository at this point in the history
Deploy prod
  • Loading branch information
geovgy authored Oct 21, 2023
2 parents 119a26f + 1b26f19 commit 614b81d
Show file tree
Hide file tree
Showing 63 changed files with 37,338 additions and 26,609 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"node": true,
"es6": true
},
"extends": ["airbnb", "prettier", "react-app", "plugin:mocha/recommended"],
"extends": ["airbnb", "prettier", "plugin:mocha/recommended"],
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module"
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.15.0
lts/gallium
9 changes: 9 additions & 0 deletions config-overrides.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = function override(config) {
config.module.rules.push({
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto',
});

return config;
};
32 changes: 15 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"contracts:deploy-factory": "yarn workspace @smart-invoice/contracts deploy-factory",
"lint": "eslint --ignore-path .gitignore \"./packages/**/*.{ts,tsx,js,jsx}\"",
"format": "prettier --ignore-path .gitignore --write \"{*,**/*}.{ts,tsx,js,jsx,json,md,sol}\"",
"prepare": "husky install"
"prepare": "husky install",
"postinstall": "patch-package"
},
"workspaces": {
"nohoist": [
Expand All @@ -46,23 +47,19 @@
"async-prompt": "^1.0.1",
"babel-eslint": "^10.1.0",
"dotenv": "^8.2.0",
"eslint": "^7.11.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-prettier": "8.1.0",
"eslint-config-react-app": "^6.0.0",
"eslint-plugin-flowtype": "^5.6.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-mocha": "^8.1.0",
"eslint-plugin-react": "7.23.1",
"eslint-plugin-react-hooks": "4.2.0",
"eslint-plugin-simple-import-sort": "7.0.0",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-mocha": "^10.1.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-simple-import-sort": "^10.0.0",
"ethers": "^5.1.0",
"husky": "^6.0.0",
"it-all": "^1.0.2",
"lint-staged": "^10.3.0",
"prettier": "^2.1.1",
"prettier-plugin-solidity": "^1.0.0-beta.10"
"lint-staged": "^14.0.1",
"prettier": "^3.0.3",
"prettier-plugin-solidity": "^1.1.3"
},
"lint-staged": {
"*.{ts,tsx,js,jsx}": [
Expand All @@ -74,7 +71,8 @@
]
},
"dependencies": {
"@typescript-eslint/parser": "^5.27.0",
"typescript": "^4.7.2"
"@typescript-eslint/parser": "^6.7.0",
"patch-package": "^8.0.0",
"typescript": "^4.9.5"
}
}
154 changes: 77 additions & 77 deletions packages/contracts/tasks/verify-blockscout.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,83 @@ async function getLongVersion(shortVersion) {
return fullVersion.replace(/(soljson-)(.*)(.js)/, "$2");
}

const fetchFlatSource = async contractName => {
const sourcePath = `flat/${contractName}.sol`;
if (!fs.existsSync(sourcePath)) {
throw new Error(
`Could not find ${contractName} source file at ${sourcePath}`,
);
}

const flatSource = fs.readFileSync(sourcePath, {
encoding: "utf8",
flag: "r",
});

// Make sure we don't have multiple SPDX-License-Identifier statements
if ((flatSource.match(/SPDX-License-Identifier:/g) || []).length > 1) {
throw new Error(
"Found duplicate SPDX-License-Identifiers in the Solidity code, please provide the correct license with --license <license identifier>",
);
}

return flatSource;
};

const hasSourceCode = verificationResult =>
verificationResult.data &&
verificationResult.data.result &&
verificationResult.data.result.SourceCode &&
verificationResult.data.result.SourceCode.length > 0;

const verificationStatus = async (apiUrl, address) => {
// eslint-disable-next-line no-constant-condition
while (true) {
// eslint-disable-next-line no-await-in-loop
await delay(1000);

try {
const qs = querystring.stringify({
module: "contract",
action: "getsourcecode",
address,
ignoreProxy: 1,
});

// eslint-disable-next-line no-await-in-loop
const verificationResult = await axios.get(`${apiUrl}?${qs}`);
if (hasSourceCode(verificationResult)) {
return VerificationStatus.VERIFIED;
}
} catch (error) {
throw new Error(`Failed to connect to Blockscout API at url ${apiUrl}`);
}
}
};

const verifyContract = async (apiUrl, postQueries) => {
const res = await axios.post(`${apiUrl}`, querystring.stringify(postQueries));
if (!res.data) {
throw new Error(`Failed to connect to verification API at url ${apiUrl}`);
}

if (
res.data.message
.toLowerCase()
.includes(VerificationStatus.ALREADY_VERIFIED.toLowerCase())
) {
return VerificationStatus.ALREADY_VERIFIED;
}

if (res.data.status !== "1") {
throw new Error(res.data.result);
}
if (hasSourceCode(res)) return VerificationStatus.VERIFIED;

const contractAddress = postQueries.addressHash;
return verificationStatus(apiUrl, contractAddress);
};

const verifySubtask = async ({ address }, { network, run }) => {
const chainId = parseInt(await network.provider.send("eth_chainId"), 16);

Expand Down Expand Up @@ -204,83 +281,6 @@ ${contractURL}`,
);
};

const verifyContract = async (apiUrl, postQueries) => {
const res = await axios.post(`${apiUrl}`, querystring.stringify(postQueries));
if (!res.data) {
throw new Error(`Failed to connect to verification API at url ${apiUrl}`);
}

if (
res.data.message
.toLowerCase()
.includes(VerificationStatus.ALREADY_VERIFIED.toLowerCase())
) {
return VerificationStatus.ALREADY_VERIFIED;
}

if (res.data.status !== "1") {
throw new Error(res.data.result);
}
if (hasSourceCode(res)) return VerificationStatus.VERIFIED;

const contractAddress = postQueries.addressHash;
return verificationStatus(apiUrl, contractAddress);
};

const fetchFlatSource = async contractName => {
const sourcePath = `flat/${contractName}.sol`;
if (!fs.existsSync(sourcePath)) {
throw new Error(
`Could not find ${contractName} source file at ${sourcePath}`,
);
}

const flatSource = fs.readFileSync(sourcePath, {
encoding: "utf8",
flag: "r",
});

// Make sure we don't have multiple SPDX-License-Identifier statements
if ((flatSource.match(/SPDX-License-Identifier:/g) || []).length > 1) {
throw new Error(
"Found duplicate SPDX-License-Identifiers in the Solidity code, please provide the correct license with --license <license identifier>",
);
}

return flatSource;
};

const hasSourceCode = verificationResult =>
verificationResult.data &&
verificationResult.data.result &&
verificationResult.data.result.SourceCode &&
verificationResult.data.result.SourceCode.length > 0;

const verificationStatus = async (apiUrl, address) => {
// eslint-disable-next-line no-constant-condition
while (true) {
// eslint-disable-next-line no-await-in-loop
await delay(1000);

try {
const qs = querystring.stringify({
module: "contract",
action: "getsourcecode",
address,
ignoreProxy: 1,
});

// eslint-disable-next-line no-await-in-loop
const verificationResult = await axios.get(`${apiUrl}?${qs}`);
if (hasSourceCode(verificationResult)) {
return VerificationStatus.VERIFIED;
}
} catch (error) {
throw new Error(`Failed to connect to Blockscout API at url ${apiUrl}`);
}
}
};

subtask(TASK_VERIFY_VERIFY_BLOCKSCOUT)
.addParam("address", undefined, undefined, types.string)
.addOptionalParam("constructorArguments", undefined, [], types.any)
Expand Down
15 changes: 15 additions & 0 deletions packages/dapp/craco.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
webpack: {
configure: (webpackConfig, { env, paths }) => {
const babelRules = webpackConfig.module.rules[1];
const extJsRule = babelRules.oneOf.find(
rule =>
rule.loader && rule.loader.includes('babel-loader') && rule.exclude,
);
extJsRule.include =
/node_modules\/(@metamask|@noble|@wagmi|@walletconnect|unws|viem|wagmi)/;
extJsRule.type = 'javascript/auto';
return webpackConfig;
},
},
};
53 changes: 31 additions & 22 deletions packages/dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@emotion/react": "^11.1.4",
"@emotion/styled": "^11.3.0",
"@ethersproject/address": "^5.6.1",
"@rainbow-me/rainbowkit": "^1.0.4",
"@rainbow-me/rainbowkit": "^1.0.11",
"@react-pdf/renderer": "^2.3.0",
"base-58": "^0.0.1",
"dotenv": "^16.0.1",
Expand All @@ -19,42 +19,51 @@
"firebase": "^9.8.4",
"focus-visible": "^5.2.0",
"framer-motion": "^4.1.3",
"ipfs-http-client": "34.0.0",
"ipfs-http-client": "50.1.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router-dom": "^5.2.0",
"react-router-dom": "^5.3.4",
"react-scripts": "4.0.3",
"react-table": "^7.8.0",
"styled-components": "^5.3.5",
"urql": "^2.0.2",
"viem": "^1.2.9",
"wagmi": "^1.3.7",
"web3": "^1.3.5"
"urql": "^2.2.3",
"viem": "^1.12.2",
"wagmi": "~1.4.2",
"web3": "1.10.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts --max_old_space_size=4096 build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"start": "craco start",
"build": "craco --max_old_space_size=4096 build",
"test": "craco test",
"eject": "craco eject",
"lint": "eslint \"./src/**/*.{js,jsx}\""
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not op_mini all"
"chrome >= 67",
"edge >= 79",
"firefox >= 68",
"opera >= 54",
"safari >= 14"
],
"devDependencies": {
"eslint-plugin-flowtype": "^5.6.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-react": "7.23.1",
"eslint-plugin-react-hooks": "4.2.0",
"@craco/craco": "6.4.5",
"eslint-config-react-app": "^6.0.0",
"eslint-plugin-flowtype": "^5.2.0",
"ethers": "^5.1.0",
"husky": "^6.0.0"
},
"resolutions": {
"react-error-overlay": "6.0.9"
}
},
"eslintConfig": {
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"react-app"
]
},
"cracoConfig": "./craco.config.js"
}
Loading

1 comment on commit 614b81d

@vercel
Copy link

@vercel vercel bot commented on 614b81d Oct 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.