Skip to content

Commit

Permalink
Merge pull request #1 from Depth-Hoar/test-for-getters
Browse files Browse the repository at this point in the history
Escrow ownership fixed
  • Loading branch information
Depth-Hoar committed Oct 21, 2022
2 parents 59fbe40 + f473d61 commit 9ebba5d
Show file tree
Hide file tree
Showing 8 changed files with 518 additions and 29 deletions.
4 changes: 1 addition & 3 deletions contracts/Escrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ pragma solidity 0.8.15;
contract Factory {
address[] public allEscrowContracts;
uint256 public escrowCount;
address public factoryOwner;

constructor() {
factoryOwner = msg.sender;
escrowCount = 0;
}

function createContract() public {
address newContract = address(new Escrow(factoryOwner, escrowCount++));
address newContract = address(new Escrow(msg.sender, escrowCount++));
allEscrowContracts.push(newContract);
}

Expand Down
17 changes: 2 additions & 15 deletions frontend/src/abis/Factory.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/src/abis/contract-address.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"Factory": "0xEB62fE709C12a65A06B3587Ee6106f374aFA8280"
"Factory": "0xCEd5BBAb616b5aC169CB33D2a3ECca42F47efBf1"
}
4 changes: 2 additions & 2 deletions frontend/src/abis/escrow-abi/Escrow.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{
"inputs": [
{
"internalType": "address payable",
"name": "_Owner",
"internalType": "address",
"name": "_escrowOwner",
"type": "address"
},
{
Expand Down
1 change: 1 addition & 0 deletions frontend/src/pages/page-contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function Contract({ blockchain }) {
};

const Escrow = array[0];
console.log(Escrow);

const initEscrow = async (e) => {
e.preventDefault();
Expand Down
3 changes: 2 additions & 1 deletion hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ module.exports = {
defaultNetwork: "hardhat",
networks: {
hardhat: {
blockGasLimit: 100000000429720 // whatever you want here
blockGasLimit: 10000 // whatever you want here
},
goerli: {
url: `https://eth-goerli.alchemyapi.io/v2/${process.env.ALCHEMY_API_KEY}`,
accounts: [`0x${privateKey}`],
// blockGasLimit: 10000 // whatever you want here
},
}
}
23 changes: 16 additions & 7 deletions test/escrow.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
const { expect } = require('chai');
const { ethers } = require('hardhat');
const hre = require("hardhat");
const { escrowJson } = require('./escrowJson');

describe('Factory', function () {

it('should initiate the factory contract and create a single new Escrow contract', async function () {
const Factory = await ethers.getContractFactory('Factory');
factory = await Factory.deploy();
[factoryOwner, escrowOwner] = await ethers.getSigners();
const Factory = await ethers.getContractFactory('Factory');
factory = await Factory.connect(factoryOwner).deploy();
await factory.deployed();
await factory.createContract();
await factory.connect(escrowOwner).createContract();
const allEscrowContracts = await factory.getAllContracts();
expect(allEscrowContracts.length).to.equal(1);

// await escrow.connect(buyer).depositToEscrow({value: ethers.utils.parseEther('10')});
});

});
Expand All @@ -18,11 +23,15 @@ describe('Factory', function () {
describe('Escrow', function () {

beforeEach(async () => {
[escrowOwner, seller, buyer, externalWallet] = await ethers.getSigners();
const EscrowContract = await ethers.getContractFactory('Escrow');
escrow = await EscrowContract.deploy(escrowOwner.address, 0);
[factoryOwner, escrowOwner, seller, buyer, externalWallet] = await ethers.getSigners();
const Factory = await ethers.getContractFactory('Factory');
factory = await Factory.connect(factoryOwner).deploy();
await factory.deployed();
escrowContractInstants = await factory.connect(escrowOwner).createContract();
const allEscrowContracts = await factory.getAllContracts();
escrow = new ethers.Contract(allEscrowContracts[0], escrowJson, escrowOwner);
await escrow.deployed();
await escrow.initEscrow(seller.address, buyer.address, 10, 100000000);
await escrow.connect(escrowOwner).initEscrow(seller.address, buyer.address, 10, 100000000);
});

it('should initialize a new escrow and return escrowID as 1', async function() {
Expand Down
Loading

1 comment on commit 9ebba5d

@vercel
Copy link

@vercel vercel bot commented on 9ebba5d Oct 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

escrow-sol – ./

escrow-sol-git-main-depth-hoar.vercel.app
escrow-sol-depth-hoar.vercel.app
escrow-sol.vercel.app

Please sign in to comment.