Skip to content

Instantly share code, notes, and snippets.

@agustinustheo
agustinustheo / add-service.sh
Last active March 26, 2023 09:07
A shell script to add a new service for Flask App
#!/bin/bash
home_path=`pwd`
service_path="/etc/systemd/system/$1.service"
if [ -f "$service_path" ]
then
echo "Service file already exists, renewing file..."
systemctl stop $1.service
systemctl disable $1.service
rm "$service_path"
@agustinustheo
agustinustheo / add-ini-wsgi-conf.sh
Last active March 27, 2023 02:11
A shell script to add an ini and WSGI configuration file.
#!/bin/bash
home_path=$(pwd)
wsgi_path="$home_path/wsgi.py"
ini_path="$home_path/$1"
if [ -f "$ini_path" ]
then
echo "INI and WSGI files already exists, renewing files..."
rm "$wsgi_path"
@agustinustheo
agustinustheo / add-nginx-wsgi-conf.sh
Last active March 27, 2023 02:10
A shell script for generating a new NGINX configuration for WSGI.
#!/bin/bash
conf_path="/etc/nginx/sites-available/$1"
available_path="/etc/nginx/sites-enabled/$1"
home_path=$(pwd)
if [ -f "$conf_path" ]
then
echo "NGINX Configuration file already exists, renewing file..."
rm "$available_path"
const EscrowContract = await hre.ethers.getContractFactory("Escrow");
const escrowContract = await EscrowContract.deploy(DAITokenAddress)
await escrowContract.deployed();
console.log('Contracts deployed!');
if (networkName == 'localhost') {
console.log('Deployed ERC20 contract address', erc20.address)
}
console.log('Deployed Escrow Contract address', escrowContract.address);
let DAITokenAddress = process.env[`${networkName.toUpperCase()}_NETWORK_DAI_TOKEN_ADDRESS`];
// If deploying to localhost, (for dev/testing purposes) need to deploy own ERC20
if (networkName == 'localhost') {
const ERC20Contract = await hre.ethers.getContractFactory("MockDaiToken");
erc20 = await ERC20Contract.deploy();
await erc20.deployed()
DAITokenAddress = erc20.address
}
const networkName = hre.network.name;
const networkUrl = hre.network.config.url;
console.log('Deploying to network', networkName, networkUrl);
const hre = require('hardhat');
require('dotenv').config();
async function main() {
// Insert your deployment script here
}
// We recommend this pattern to be able to use
// async/await everywhere and properly handle errors.
main()
.then(() => process.exit(0))
.catch((error) => {
require("@nomiclabs/hardhat-ethers");
require('dotenv').config();
/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
solidity: "0.8.4",
networks: {
rinkeby: {
url: process.env.RINKEBY_RPC_URL,
it("Unhappy Path: withdrawalEscrow - Transaction hash cannot be empty!", async function () {
const contractWithSigner = contract.connect(unhappyPathAccount);
let err = "";
try {
await contractWithSigner.withdrawalEscrow(ethers.constants.HashZero)
}
catch(e) {
err = e.message;
}
expect(err).to.equal("VM Exception while processing transaction: reverted with reason string 'Transaction hash cannot be empty!'");
it("Happy Path: withdrawalEscrow", async function () {
const contractWithSigner = contract.connect(happyPathAccount);
const trxHash = await contract.getHash(amount);
const submitEscrowTx = await contractWithSigner.submitEscrow(trxHash, amount);
await submitEscrowTx.wait();
expect(
(await erc20.balanceOf(happyPathAccount.address)).toString()
).to.equal("50000000000000000000");
const withdrawalEscrowTx = await contractWithSigner.withdrawalEscrow(trxHash);
await withdrawalEscrowTx.wait();