Skip to content
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

DApp: create & view invoices #6

Closed
wants to merge 52 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
ce5898b
fix(README.md): spacing
moconnell Aug 2, 2023
5dae679
chore: add root .gitignore
moconnell Aug 2, 2023
64bfd5a
feat(create-invoice): initial dapp commit
moconnell Aug 2, 2023
a10e452
refactor: sort imports
moconnell Aug 2, 2023
bbc3c58
chore: add vs code settings
moconnell Aug 2, 2023
26bab1d
refactor: sort imports
moconnell Aug 2, 2023
0e19893
fix: App.test.tsx
moconnell Aug 2, 2023
16159e2
chore: upgrade deps
moconnell Aug 2, 2023
04fad9c
chore: upgrade web-vitals
moconnell Aug 2, 2023
aa95990
chore: add prettier config
moconnell Aug 2, 2023
5c1f85b
fix: missing prettier dep
moconnell Aug 2, 2023
4d3c02b
add: tests for Home, SelectInvoiceType
moconnell Aug 2, 2023
7178b86
refactor: add index.ts to components folder
moconnell Aug 2, 2023
0a0a557
add: tests for component
moconnell Aug 2, 2023
8532477
add: tests for shared folder
moconnell Aug 2, 2023
47e7e90
refactor: prettier
moconnell Aug 3, 2023
87f20eb
refactor: remove obsolete snap
moconnell Aug 3, 2023
4a8e31c
refactor: log web vitals
moconnell Aug 3, 2023
9d30e56
chore(dapp): add github ci build
moconnell Aug 3, 2023
eb3118d
refactor(ci): run on push to any dapp/** branch
moconnell Aug 3, 2023
14894de
fix: add missing dev dep
moconnell Aug 3, 2023
a27a040
fix: move jest config to package.json
moconnell Aug 3, 2023
fc13778
fix(Layout.test.tsx): add Web3ContextProvider
moconnell Aug 3, 2023
bea7923
test: add Web3Context.test.tsx
moconnell Aug 3, 2023
a0659a2
chore(.gitignore): ignore node_modules
moconnell Aug 16, 2023
0a7a4e7
chore: merge branch
moconnell Aug 16, 2023
2940c21
chore(.gitignore): ignore node_modules etc.
moconnell Aug 16, 2023
b49c7a0
feat(view-invoices): initial commit
moconnell Aug 16, 2023
055ed7b
Merge remote-tracking branch 'origin/hooking-up' into 1-dapp-createvi…
moconnell Aug 16, 2023
2e4773d
Merge branch 'dapp/create-invoice' into 1-dapp-createview-invoices
moconnell Aug 16, 2023
4fa7e26
adjusted structs, create invoice on sepolia working
psparacino Aug 16, 2023
6a13577
chore: add types
moconnell Aug 16, 2023
08be26c
refactor(dapp): switch to yarn
moconnell Aug 16, 2023
d99ac03
feat(typechain): add .ts type gen
moconnell Aug 16, 2023
71f81bc
working locally on both networks. flexible deployment setup
psparacino Aug 17, 2023
b22929d
changed encData to bytes, no keccak
psparacino Aug 17, 2023
4468c76
refactor: add .yarnrc.yml
moconnell Aug 17, 2023
4b06cd1
fix(SearchContext.tsx): type error on setResult
moconnell Aug 17, 2023
3b55d6f
delete unused
moconnell Aug 17, 2023
06803d0
chore: update deps
moconnell Aug 17, 2023
be9b23f
chore: readd react-scripts pre-wizard
moconnell Aug 17, 2023
0488957
refactor(dapp): next.js
moconnell Aug 17, 2023
fff251a
Merge remote-tracking branch 'origin/invoice-creation' into 1-dapp-cr…
moconnell Aug 18, 2023
2cecc63
fix: typechain type generation
moconnell Aug 18, 2023
0fd0288
fix: nextjs errors, add lint config
moconnell Aug 18, 2023
2f9acc7
fix: dapp build
moconnell Aug 18, 2023
4ddc72c
fix(dapp): more test fixes
moconnell Aug 19, 2023
468440f
fix(dapp): test fixes
moconnell Aug 19, 2023
8faf603
fix(prettier): move config back to root
moconnell Aug 19, 2023
462fd36
feat(create-invoice): add MistContext
moconnell Aug 19, 2023
d4791a7
refactor(MistContext): add tests
moconnell Aug 19, 2023
3785151
fix(dapp): tests
moconnell Aug 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/frontend-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: "DAPP-CI"

on:
pull_request:
branches:
- "main"
- "develop"
paths:
- "mist-invoice-dapp/**"
push:
branches:
- "main"
- "develop"
- "dapp/**"
paths:
- "mist-invoice-dapp/**"

jobs:
ci:
runs-on: "ubuntu-latest"
env:
GITHUB_STEP_SUMMARY: ${{ github.workspace }}/.github/step-summary.md
WORKING_DIR: ${{ github.workspace }}/mist-invoice-dapp
steps:
- name: "Check out the repo"
uses: "actions/checkout@v3"

- name: "Install Node.js"
uses: "actions/setup-node@v3"
with:
node-version: "18"

# - name: "Copy config"
# run: |
# mv ./evm/.env.github ./evm/.env
# echo "::debug::$(less .env)"
# working-directory: ${{ env.WORKING_DIR }}

- name: "Install the dependencies"
run: "npm ci"
working-directory: ${{ env.WORKING_DIR }}

- name: "Lint the code"
run: "npm run lint"
working-directory: ${{ env.WORKING_DIR }}

- name: "Add lint summary"
run: |
echo "## Lint results" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY

- name: "Test the code and generate the coverage report"
run: "npm test -- --coverage --watchAll=false"
working-directory: ${{ env.WORKING_DIR }}

- name: "Add test summary"
run: |
echo "## Test results" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cache
coverage
node_modules
out

mist-invoice-contracts/src/types

.DS_Store
.yarn
.env
.env.local
6 changes: 6 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
semi: true,
trailingComma: "none",
singleQuote: false,
printWidth: 80
};
36 changes: 36 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
// eslint extension options
"eslint.enable": true,
"editor.codeActionsOnSave": [],
// prettier extension setting
"editor.formatOnSave": true,
"[javascript]": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.organizeImports": true,
},
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.organizeImports": true
},
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.organizeImports": true
},
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.organizeImports": true
},
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"prettier.configPath": ".prettierrc.js"
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# mist-invoice

A privacy layer on top of smart invoice.
14 changes: 13 additions & 1 deletion mist-invoice-contracts/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
PUBLIC_KEY=
PRIVATE_KEY=
PRIVATE_KEY=

SEPOLIA_MIST_POOL=
SEPOLIA_SMART_INVOICE_FACTORY=

LINEA_GOERLI_MIST_POOL=
LINEA_GOERLI_SMART_INVOICE_FACTORY=

# linea or sepolia
NETWORK=

# UPDATE THIS WITH THE LOCAL DEPLOYMENT
MIST_INVOICE_ESCROW_WRAPPER=
1 change: 1 addition & 0 deletions mist-invoice-contracts/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
16 changes: 11 additions & 5 deletions mist-invoice-contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
{
"license": "UNLICENSED",
"scripts": {
"build": "forge build & yarn typechain",
"lint": "yarn lint:sol && yarn prettier:check",
"lint:sol": "forge fmt --check && yarn solhint \"{script,src,test}/**/*.sol\"",
"prettier:check": "yarn prettier --check \"**/*.{json,md,svg,yml}\"",
"test": "forge t -vvv --ffi --fork-url http://localhost:8545",
"fork": "anvil --fork-url https://rpc.goerli.linea.build --block-base-fee-per-gas 30000000000 --chain-id 31137",
"deploy-local": "forge script script/deployMistInvoiceEscrowWrapper.s.sol --fork-url http://localhost:8545 --broadcast --ffi",
"create-invoice": "forge script script/createMistInvoice.s.sol --fork-url http://localhost:8545 --broadcast --ffi"
"fork-linea": "anvil --fork-url https://rpc.goerli.linea.build --block-base-fee-per-gas 30000000000 --chain-id 31137",
"fork-sepolia": "anvil --fork-url https://gateway.tenderly.co/public/sepolia --block-base-fee-per-gas 30000000000 --chain-id 31137",
"deploy-local-wrapper": "forge script script/deployMistInvoiceEscrowWrapper.s.sol --fork-url http://localhost:8545 --broadcast --ffi --legacy",
"create-local-linea": "forge script script/createMistInvoice.s.sol --fork-url http://localhost:8545 --broadcast --ffi --legacy",
"create-local-sepolia": "forge script script/createMistInvoice.s.sol --fork-url http://localhost:8545 --broadcast --ffi",
"typechain": "typechain --target=ethers-v6 --out-dir=src/types \"out/**/*.json\""
},
"devDependencies": {
"@typechain/ethers-v6": "^0.4.3",
"prettier": "^3.0.0",
"solhint": "^3.4.1"
"solhint": "^3.4.1",
"typechain": "^8.3.1",
"typescript": "^5.1.6"
},
"name": "mist-invoice",
"description": "A privacy layer on top of smart invoice."
}

95 changes: 78 additions & 17 deletions mist-invoice-contracts/script/createMistInvoice.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,97 @@ import "forge-std/console.sol";

contract InvoiceCreationScript is Script {
struct MistData {
bytes merkleRoot;
bytes clientRandom;
bytes providerRandom;
bytes clientKey;
bytes providerKey;
bytes32 merkleRoot;
bytes32 clientRandom;
bytes32 providerRandom;
bytes32 clientKey;
bytes32 providerKey;
}

function getSepoliaDummyData() public view returns (bytes memory) {
address _client = 0x1111111111111111111111111111111111111111;
uint8 _resolverType = 1; // For simplicity
address _resolver = 0x2222222222222222222222222222222222222222;
address _token = 0x3333333333333333333333333333333333333333;
uint256 _terminationTime = block.timestamp + 30 days;
bytes32 _details = keccak256(abi.encodePacked("Details for mist invoice"));
address _wrappedNativeToken = 0xb16F35c0Ae2912430DAc15764477E179D9B9EbEa; // WETH on sepolia
bool _requireVerification = true;

address _factory = 0xaE57F3689a23792649c597DD3B652b788f0414E4; //sepolia factory

return abi.encode(
_client,
_resolverType,
_resolver,
_token,
_terminationTime,
_details,
_wrappedNativeToken,
_requireVerification,
_factory
);
}

function getLineaDummyData() public view returns (bytes memory) {
address _client = 0x1111111111111111111111111111111111111111;
uint8 _resolverType = 1; // For simplicity
address _resolver = 0x2222222222222222222222222222222222222222;
address _token = 0x3333333333333333333333333333333333333333;
uint256 _terminationTime = block.timestamp + 30 days;
bytes32 _details = keccak256(abi.encodePacked("Details for mist invoice"));
address _wrappedNativeToken = 0x2C1b868d6596a18e32E61B901E4060C872647b6C; // WETH on linea
bool _requireVerification = true;

address _factory = 0xa9c2372FdFA2ef145A0d13784C74DE96f0e3eaff; //linea factory

return abi.encode(
_client,
_resolverType,
_resolver,
_token,
_terminationTime,
_details,
_wrappedNativeToken,
_requireVerification,
_factory
);
}

function run() external {
// Read environment variables and select EOA for transaction signing
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
address deployerAddress = vm.envAddress("PUBLIC_KEY");
string memory network = vm.envString("NETWORK");

bytes memory _data;

if (keccak256(bytes(network)) == keccak256(bytes("sepolia"))) {
_data = getSepoliaDummyData();
} else if (keccak256(bytes(network)) == keccak256(bytes("linea"))) {
_data = getLineaDummyData();
} else {
revert("Invalid network selection");
}

vm.startBroadcast(deployerPrivateKey);

// THIS IS THE SEPOLIA MIST POOL, NEEDS TO BE UPDATED TO LINEA-GOERLI
MistInvoiceEscrowWrapper mistWrapper = MistInvoiceEscrowWrapper(0xda430a73106D31120Ec5128Bb1008bcd00d25A9C);
address mistWrapperDeployment = vm.envAddress("MIST_INVOICE_ESCROW_WRAPPER");
MistInvoiceEscrowWrapper mistWrapper = MistInvoiceEscrowWrapper(mistWrapperDeployment);

// Dummy data
MistData memory _mistData = MistData(
bytes("dummyMerkleRoot"),
bytes("dummyClientRandom"),
bytes("dummyProviderRandom"),
bytes("dummyClientKey"),
bytes("dummyProviderKey")
);
MistData memory _mistData = MistData({
merkleRoot: keccak256(abi.encodePacked("dummyMerkleRoot")),
clientRandom: keccak256(abi.encodePacked("dummyClientRandom")),
providerRandom: keccak256(abi.encodePacked("dummyProviderRandom")),
clientKey: keccak256(abi.encodePacked("dummyClientKey")),
providerKey: keccak256(abi.encodePacked("dummyProviderKey"))
});

uint256[] memory _amounts = new uint256[](1);
_amounts[0] = 1000;
bytes memory _data = bytes("dummyData");
bytes32 _type = bytes32(0x73706c69742d657363726f770000000000000000000000000000000000000000);

bytes32 _type = bytes32("escrow");

MistInvoiceEscrowWrapper.MistData memory mistDataForWrapper = MistInvoiceEscrowWrapper.MistData({
merkleRoot: _mistData.merkleRoot,
Expand All @@ -49,7 +111,6 @@ contract InvoiceCreationScript is Script {

console.log("Mist Invoice Address: %s", invoiceAddress);


vm.stopBroadcast();
}
}
23 changes: 16 additions & 7 deletions mist-invoice-contracts/script/deployMistInvoiceEscrowWrapper.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,26 @@ contract DeployScript is Script {
function run() external {
//read env variables and choose EOA for transaction signing
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
address deployerAddress = vm.envAddress("PUBLIC_KEY");

vm.startBroadcast(deployerPrivateKey);
// THIS IS THE SEPOLIA MIST POOL, NEEDS TO BE UPDATED TO LINEA-GOERLI
address MIST_POOL = 0x6bA81b91c72755459CfdF3c5ad25eFe636DCd493;
string memory network = vm.envString("NETWORK");

address MIST_POOL;
address SMART_INVOICE_FACTORY;

// verified
address LINEA_GOERLI_SMART_INVOICE_FACTORY = 0xa9c2372FdFA2ef145A0d13784C74DE96f0e3eaff;
if (keccak256(bytes(network)) == keccak256(bytes("sepolia"))) {
MIST_POOL = vm.envAddress("SEPOLIA_MIST_POOL");
SMART_INVOICE_FACTORY = vm.envAddress("SEPOLIA_SMART_INVOICE_FACTORY");
} else if (keccak256(bytes(network)) == keccak256(bytes("linea"))) {
MIST_POOL = vm.envAddress("LINEA_GOERLI_MIST_POOL");
SMART_INVOICE_FACTORY = vm.envAddress("LINEA_GOERLI_SMART_INVOICE_FACTORY");
} else {
revert("Invalid network selection");
}

vm.startBroadcast(deployerPrivateKey);

// deploy mist invoice escrow
MistInvoiceEscrowWrapper mistWrapper = new MistInvoiceEscrowWrapper(LINEA_GOERLI_SMART_INVOICE_FACTORY, MIST_POOL);
MistInvoiceEscrowWrapper mistWrapper = new MistInvoiceEscrowWrapper(SMART_INVOICE_FACTORY, MIST_POOL);

console.log("MistInvoiceEscrowWrapper Address: %s", address(mistWrapper));

Expand Down
Loading