Skip to content

Commit

Permalink
feat: frontend for erc20 on sepolia
Browse files Browse the repository at this point in the history
  • Loading branch information
jatZama committed Dec 11, 2024
1 parent d07b5c7 commit 6a31584
Show file tree
Hide file tree
Showing 67 changed files with 10,505 additions and 8,414 deletions.
3 changes: 3 additions & 0 deletions .czrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"path": "cz-conventional-changelog"
}
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# EditorConfig http://EditorConfig.org

# top-most EditorConfig file
root = true

# All files
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.sol]
indent_size = 4
6 changes: 3 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VITE_ACL_ADDRESS=0xFee8407e2f5e3Ee68ad77cAE98c434e637f516e5
VITE_KMS_ADDRESS=0x9D6891A6240D6130c54ae243d8005063D05fE14b
VITE_GATEWAY_URL=https://gateway.sepolia.zama.ai/
export MNEMONIC="exchange vintage ocean narrow danger return culture ignore trim solve clock hidden buddy wise emotion"
export SEPOLIA_RPC_URL="https://sepolia.infura.io/v3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
export ETHERSCAN_API_KEY="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: "CI"

env:
DOTENV_CONFIG_PATH: "./.env.example"

on:
workflow_dispatch:
pull_request:
push:
branches:
- main

jobs:
ci:
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: "actions/checkout@v3"

- name: "Install Pnpm"
uses: "pnpm/action-setup@v2"
with:
version: "8"

- name: "Install Node.js"
uses: "actions/setup-node@v3"
with:
cache: "pnpm"
node-version: "lts/*"

- name: "Install the dependencies"
run: "pnpm install"

- name: "Lint the code"
run: "pnpm lint"

- name: "Add lint summary"
run: |
echo "## Lint results" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
- name: "Compile the contracts and generate the TypeChain bindings"
run: "pnpm typechain"

- name: "Test the contracts and generate the coverage report"
run: "pnpm coverage:mock"

- name: "Add test summary"
run: |
echo "## Test results" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
50 changes: 28 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
# directories
.coverage_artifacts
.coverage_cache
.coverage_contracts
artifacts
build
cache
coverage
dist
dist-ssr
*.local
node_modules
types
deployments
kms-fhe-keys/
network-fhe-keys/
fhevmTemp/
abi/

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
# files
*.env
*.log
.env.docker
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
.env
.pnp.*
coverage.json
package-lock.json
yarn.lock

res/
running_node/

docker-compose/docker-compose-full.yml
10 changes: 10 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
image: "gitpod/workspace-node:latest"

tasks:
- init: "pnpm install"

vscode:
extensions:
- "esbenp.prettier-vscode"
- "NomicFoundation.hardhat-solidity"
- "ritwickdey.LiveServer"
22 changes: 22 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# directories
.coverage_artifacts
.coverage_cache
.coverage_contracts
artifacts
build
cache
coverage
dist
node_modules
types

# files
*.env
*.log
.DS_Store
.pnp.*
coverage.json
package-lock.json
pnpm-lock.yaml
yarn.lock
README.md
23 changes: 23 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
bracketSpacing: true
plugins:
- "@trivago/prettier-plugin-sort-imports"
- "prettier-plugin-solidity"
printWidth: 120
proseWrap: "always"
singleQuote: false
tabWidth: 2
trailingComma: "all"

overrides:
- files: "*.sol"
options:
compiler: "0.8.24"
parser: "solidity-parse"
tabWidth: 4
- files: "*.ts"
options:
importOrder: ["<THIRD_PARTY_MODULES>", "^[./]"]
importOrderParserPlugins: ["typescript"]
importOrderSeparation: true
importOrderSortSpecifiers: true
parser: "typescript"
11 changes: 11 additions & 0 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
istanbulReporter: ["html", "lcov"],
providerOptions: {
mnemonic: process.env.MNEMONIC,
},
skipFiles: ["test", "fhevmTemp"],
mocha: {
fgrep: "[skip-on-coverage]",
invert: true,
},
};
24 changes: 24 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"extends": "solhint:recommended",
"plugins": ["prettier"],
"rules": {
"const-name-snakecase": "off",
"no-global-import": "off",
"reason-string": "off",
"state-visibility": "off",
"custom-errors": "off",
"code-complexity": ["error", 8],
"compiler-version": ["error", ">=0.8.4"],
"func-visibility": ["error", { "ignoreConstructors": true }],
"max-line-length": ["error", 120],
"named-parameters-mapping": "off",
"no-console": "off",
"not-rely-on-time": "off",
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
]
}
}
3 changes: 3 additions & 0 deletions .solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# directories
**/artifacts
**/node_modules
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["esbenp.prettier-vscode", "NomicFoundation.hardhat-solidity"]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"prettier.documentSelectors": ["**/*.sol"],
"solidity.formatter": "prettier"
}
56 changes: 56 additions & 0 deletions CustomProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { ProviderWrapper } from "hardhat/plugins";
import type { EIP1193Provider, RequestArguments } from "hardhat/types";

interface Test {
request: EIP1193Provider["request"];
}

class CustomProvider extends ProviderWrapper implements Test {
public lastBlockSnapshot: number;
public lastCounterRand: number;
public lastBlockSnapshotForDecrypt: number;

constructor(protected readonly _wrappedProvider: EIP1193Provider) {
super(_wrappedProvider);
this.lastBlockSnapshot = 0; // Initialize the variable
this.lastCounterRand = 0;
this.lastBlockSnapshotForDecrypt = 0;
}

async request(args: RequestArguments): ReturnType<EIP1193Provider["request"]> {
if (args.method === "evm_revert") {
const result = await this._wrappedProvider.request(args);
const blockNumberHex = (await this._wrappedProvider.request({ method: "eth_blockNumber" })) as string;
this.lastBlockSnapshot = parseInt(blockNumberHex);
this.lastBlockSnapshotForDecrypt = parseInt(blockNumberHex);

const callData = {
to: "0x000000000000000000000000000000000000005d",
data: "0x1f20d85c",
};
this.lastCounterRand = (await this._wrappedProvider.request({
method: "eth_call",
params: [callData, "latest"],
})) as number;
return result;
}
if (args.method === "get_lastBlockSnapshot") {
return [this.lastBlockSnapshot, this.lastCounterRand];
}
if (args.method === "get_lastBlockSnapshotForDecrypt") {
return this.lastBlockSnapshotForDecrypt;
}
if (args.method === "set_lastBlockSnapshot") {
this.lastBlockSnapshot = Array.isArray(args.params!) && args.params[0];
return this.lastBlockSnapshot;
}
if (args.method === "set_lastBlockSnapshotForDecrypt") {
this.lastBlockSnapshotForDecrypt = Array.isArray(args.params!) && args.params[0];
return this.lastBlockSnapshotForDecrypt;
}
const result = this._wrappedProvider.request(args);
return result;
}
}

export default CustomProvider;
16 changes: 16 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
MIT License

Copyright (c) 2023 Paul Razvan Berg

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Loading

0 comments on commit 6a31584

Please sign in to comment.