Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zgorizzo69 committed May 25, 2021
1 parent 4fbbb39 commit 0b6b977
Show file tree
Hide file tree
Showing 11 changed files with 1,355 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sol linguist-language=Solidity
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "contracts"]
path = contracts
url = https://github.com/ubiquity/uad-contracts
branch = main
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# dynamic-uad-ui

after git clone the project make sure to run

`$ git submodule update --init --recursive --remote`

You need to create `.env` file inside the contracts folder with at least the ALCHEMY_API_KEY filled.

then run `$ yarn start`
it will create a file inside `frontend/src` called **uad-contracts-deployment.json** where you can find all the address of the deployed contracts

it will launch a local node on port **8545** you can check the log in the root file `local.node.log`
after the node is launched it will build and run the front on port **3000**

make sure to switch to the hardhat network on metamask

- **chain ID:** 31337
- **RPC URL:** http://127.0.0.1:8545

to get the types from the smart contracts you can import from `contracts/artifacts/types`

```
import { UbiquityAlgorithmicDollar } from "../artifacts/types/UbiquityAlgorithmicDollar";
const token = (await ethers.getContractAt("UbiquityAlgorithmicDollar", uAD.address)) as UbiquityAlgorithmicDollar;
const [sender] = await ethers.getSigners();
const tx = await token.transfer("0x000000000", 100);
```
1 change: 1 addition & 0 deletions contracts
Submodule contracts added at 330b16
6 changes: 6 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"license": "MIT",
"scripts": {
"start": "echo 'front'"
}
}
1 change: 1 addition & 0 deletions frontend/src/uad-contracts-deployment.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


23 changes: 23 additions & 0 deletions hooks/process-deployment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env node

const args = process.argv.slice(2);

const fs = require("fs");
const path = require("path");

// console.log({
// "process.cwd()": process.cwd(),
// "path.resolve(deployment)": path.resolve(args[0])
// });

const deployment = require(path.resolve(args[0]));

try {
const localhost = deployment[31337].localhost;
fs.writeFileSync(path.resolve(args[1]), JSON.stringify(localhost));
} catch (e) {
console.error(e);
process.exit(1);
}

process.exit(0);
24 changes: 24 additions & 0 deletions hooks/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

if [ -f ./contracts/.env ]
then
export $(cat ./contracts/.env | sed 's/#.*//g' | xargs)
else
echo "Please add a .env inside the contracts folder."
exit 1
fi
rm -f ./frontend/src/uad-contracts-deployment.json
cd ./contracts || echo "ERROR: ./contracts/ doesn't exist?"

yarn && yarn compile
kill $(lsof -t -i:8545) || true
yarn hardhat node --fork https://eth-mainnet.alchemyapi.io/v2/$ALCHEMY_API_KEY --fork-block-number 12150000 --show-accounts --export-all tmp-uad-contracts-deployment.json > ../local.node.log 2>&1 &
sleep 10
while : ; do
[[ -f "tmp-uad-contracts-deployment.json" ]] && break
echo "Pausing until uad-contracts-deployment.json exists."
sleep 5
done
node ../hooks/process-deployment.js ./tmp-uad-contracts-deployment.json ../frontend/src/uad-contracts-deployment.json
rm -f ./tmp-uad-contracts-deployment.json
exit 0
31 changes: 31 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"license": "MIT",
"scripts": {
"prestart": "cd ./frontend/ && yarn install && cd ..",
"start": "./hooks/start.sh",
"poststart": "cd ./frontend/ && yarn start",
"stop": "kill $(lsof -t -i:8545) || true",
"poststop": "echo 'exited successfully'"
},
"dependencies": {
"nodemon": "^2.0.7",
"npm-run-all": "^4.1.5"
},
"nodemonConfig": {
"ignore": [
"**/*/cache/",
"**/*/artifacts/",
"**/*/frontend/",
"**/*/node_modules/**/*"
],
"events": {
"config": "exit",
"exit": "",
"restart": "clear && printf '\\033[3J'",
"start": "clear && printf '\\033[3J'"
}
},
"devDependencies": {
"@types/node": "^15.0.2"
}
}
Loading

0 comments on commit 0b6b977

Please sign in to comment.