-
-
Notifications
You must be signed in to change notification settings - Fork 37
Adds Docker support for easy project setup. #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
929e7b5
ee9abf1
8bfcf16
f8ebb47
b73a9ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| node_modules | ||
| **/node_modules | ||
| npm-debug.log* | ||
| frontend/dist | ||
| frontend/build | ||
| frontend/.env | ||
| frontend/.env.local | ||
| contracts/out | ||
| contracts/cache | ||
| contracts/broadcast | ||
| contracts/.env | ||
| .git | ||
| .gitignore | ||
| .gitmodules | ||
| *.md | ||
| docs/ | ||
| .vscode | ||
| .idea | ||
| .DS_Store | ||
| Thumbs.db |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,11 @@ | ||
| { | ||
| "lib/forge-std": { | ||
| "rev": "3b20d60d14b343ee4f908cb8079495c07f5e8981" | ||
| }, | ||
| "lib\\openzeppelin-contracts": { | ||
| "tag": { | ||
| "name": "v5.5.0", | ||
| "rev": "fcbae5394ae8ad52d8e580a3477db99814b9d565" | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,14 @@ | ||
| // SPDX-License-Identifier: Unlicense | ||
| pragma solidity ^0.8.13; | ||
| pragma solidity ^0.8.20; | ||
|
|
||
|
|
||
| import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; | ||
| import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
|
|
||
| interface IERC20 { | ||
| function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); | ||
| function balanceOf(address account) external view returns (uint256); | ||
| function allowance(address owner, address spender) external view returns (uint256); | ||
| } | ||
|
|
||
| contract Chainvoice { | ||
| // ========== Errors ========== | ||
| // Existing | ||
| using SafeERC20 for IERC20; | ||
|
Comment on lines
+2
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Split contract/security changes out of this Docker PR. This PR is scoped as Docker/dev-environment setup, but it also changes on-chain payment logic and dependencies. Please move contract logic/security changes into a dedicated PR for focused audit/review and safer rollback. As per coding guidelines "Flag pull requests that mix unrelated changes or multiple concerns in a single submission." 🤖 Prompt for AI Agents |
||
| // Errors | ||
| error MixedTokenBatch(); | ||
| error InvalidBatchSize(); | ||
| error AlreadySettled(); | ||
|
|
@@ -103,16 +102,6 @@ contract Chainvoice { | |
| // Constants | ||
| uint256 public constant MAX_BATCH = 50; | ||
|
|
||
| // ========== Internal Utils ========== | ||
| function _isERC20(address token) internal view returns (bool) { | ||
| if (token == address(0)) return false; | ||
| if (token.code.length == 0) return false; | ||
| (bool success, ) = token.staticcall( | ||
| abi.encodeWithSignature("balanceOf(address)", address(this)) | ||
| ); | ||
| return success; | ||
| } | ||
|
|
||
| // ========== Single-invoice create ========== | ||
| function createInvoice( | ||
| address to, | ||
|
|
@@ -258,12 +247,11 @@ contract Chainvoice { | |
| } | ||
| accumulatedFees += fee; | ||
|
|
||
| bool transferSuccess = IERC20(invoice.tokenAddress).transferFrom( | ||
| IERC20(invoice.tokenAddress).safeTransferFrom( | ||
| msg.sender, | ||
| invoice.from, | ||
| invoice.amountDue | ||
| ); | ||
|
Nihallllll marked this conversation as resolved.
|
||
| if (!transferSuccess) revert TokenTransferFailed(); | ||
| } | ||
|
|
||
| emit InvoicePaid( | ||
|
|
@@ -331,8 +319,7 @@ contract Chainvoice { | |
|
|
||
| for (uint256 i = 0; i < n; i++) { | ||
| InvoiceDetails storage inv = invoices[invoiceIds[i]]; | ||
| bool ok = erc20.transferFrom(msg.sender, inv.from, inv.amountDue); | ||
| if (!ok) revert TokenTransferFailed(); | ||
| erc20.safeTransferFrom(msg.sender, inv.from, inv.amountDue); | ||
| emit InvoicePaid(inv.id, inv.from, inv.to, inv.amountDue, token); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| version: '3.8' | ||
|
|
||
| services: | ||
| frontend: | ||
| build: | ||
| context: ./frontend | ||
| dockerfile: Dockerfile | ||
| container_name: chainvoice-frontend | ||
| ports: | ||
| - "5173:5173" | ||
| volumes: | ||
| - ./frontend:/app | ||
| - /app/node_modules | ||
| env_file: | ||
| - ./frontend/.env | ||
| restart: unless-stopped | ||
| networks: | ||
| - chainvoice-network | ||
|
|
||
| blockchain: | ||
| image: ghcr.io/foundry-rs/foundry:latest | ||
| container_name: chainvoice-blockchain | ||
| command: anvil --host 0.0.0.0 --chain-id 31337 --accounts 10 --balance 10000 | ||
| ports: | ||
| - "8545:8545" | ||
| restart: unless-stopped | ||
| networks: | ||
| - chainvoice-network | ||
|
|
||
| networks: | ||
| chainvoice-network: | ||
| driver: bridge |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| node_modules | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| dist | ||
| build | ||
| .next | ||
| out | ||
| .env | ||
| .env.local | ||
| .env.*.local | ||
| .git | ||
| .gitignore | ||
| .gitattributes | ||
| .vscode | ||
| .idea | ||
| *.swp | ||
| *.swo | ||
| *~ | ||
| .DS_Store | ||
| Thumbs.db | ||
| coverage | ||
| .nyc_output | ||
| *.test.js | ||
| *.spec.js | ||
| README.md | ||
| *.md | ||
| Dockerfile | ||
| docker-compose.yml | ||
| .dockerignore |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| FROM node:20-alpine | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY package.json package-lock.json ./ | ||
|
|
||
| RUN npm ci --legacy-peer-deps | ||
|
|
||
| COPY . . | ||
|
|
||
| EXPOSE 5173 | ||
|
|
||
| CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"] |
Uh oh!
There was an error while loading. Please reload this page.