Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/codecov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
node-version:
- 14.x
- 16.x
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/solhint-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
node-version:
- 14.x
- 16.x
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
node-version:
- 14.x
- 16.x
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ artifacts
.DS_Store
node_modules
cache
yarn.lock
.env
.idea
package-lock.json
Expand Down
7 changes: 6 additions & 1 deletion contracts/AvalaunchMarketplace.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ contract AvalaunchMarketplace is Initializable {
event PortionListed(address indexed portionOwner, address indexed saleAddress, uint256 portionId);
event PortionRemoved(address indexed portionOwner, address indexed saleAddress, uint256 portionId);
event PortionSold(address indexed portionSeller, address indexed portionBuyer, address indexed saleAddress, uint256 portionId);
event ItemSold(address indexed itemBuyer, uint256 indexed itemId);
event SaleApproved(address indexed sale);
event ApprovedSaleRemoved(address indexed sale);
event FactorySet(ISalesFactory indexed factory);
Expand Down Expand Up @@ -104,13 +105,15 @@ contract AvalaunchMarketplace is Initializable {
* @param sigExpTimestamp is signature expiration timestamp
* @param portions is array of portion ids function caller wants to buy
* @param priceSum is sum of all portion prices
* @param itemId is unique identifier of marketplace item
* @param signature is admin signed data hash which confirms validity of action
*/
function buyPortions(
address sale,
address owner,
uint256 sigExpTimestamp,
uint256 priceSum,
uint256 itemId,
uint256[] calldata portions,
bytes calldata signature
) external payable {
Expand All @@ -120,7 +123,7 @@ contract AvalaunchMarketplace is Initializable {
require(address(msg.sender) != owner, "Can't purchase your own portions.");
{
// Compute signed message hash
bytes32 msgHash = keccak256(abi.encodePacked(owner, msg.sender/*buyer*/, sale, portions, priceSum, sigExpTimestamp, "buyPortions"));
bytes32 msgHash = keccak256(abi.encodePacked(owner, msg.sender/*buyer*/, sale, portions, priceSum, itemId, sigExpTimestamp, "buyPortions"));
// Make sure provided signature is signed by admin and containing valid data
verifySignature(msgHash, signature);
}
Expand Down Expand Up @@ -151,6 +154,8 @@ contract AvalaunchMarketplace is Initializable {
bytes("Your portion(s) just got sold! Greetings from Avalaunch Team :)")
);
require(success);
// Trigger event
emit ItemSold(msg.sender, itemId);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions deployments/contract-addresses.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@
"LatestSale": "0x69CCb83b538902abFa576E7429c40B12bB066177",
"AvalaunchCollateral": "0x739B226fa938BF0cA5F1BF49E4F89104fE226073",
"AvalaunchCollateralProxy": "0x3F6715c77B978fb7824a64BBBB502bbB09EcA00b",
"Sale-Implementation": "0x5c8eAd5829c53FBBB1740b3ab2B0fF1670555f7A",
"AvalaunchMarketplace": "0xCF6000A4419a6Ea448f3F951ed6B5273c7406cD1",
"Sale-Implementation": "0x5C69d6694605791D334D596b833D8d04922Cd648",
"AvalaunchMarketplace": "0x60ff7152dBAaD8702f037900505eb33aCbaEdB79",
"AvalaunchMarketplaceProxy": "0xda7C53E855f188038FBAeC9fca07130ac5842468"
}
}
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"version": "1.0.0",
"description": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "npx hardhat test --network hardhat",
"coverage": "npx hardhat coverage --network hardhat --testfiles test/",
"lint": "npx solhint contracts/**/*.sol"
},
"keywords": [],
"author": "",
Expand All @@ -19,7 +21,8 @@
"hardhat-contract-sizer": "2.5.0",
"hardhat-gas-reporter": "1.0.8",
"hardhat-web3": "1.0.1",
"scrypt": "github:barrysteyn/node-scrypt#fb60a8d3c158fe115a624b5ffa7480f3a24b03fb"
"scrypt": "github:barrysteyn/node-scrypt#fb60a8d3c158fe115a624b5ffa7480f3a24b03fb",
"solhint": "^3.4.0"
},
"devDependencies": {
"@chainlink/contracts": "0.0.10",
Expand Down
20 changes: 20 additions & 0 deletions scripts/deployment/deploy_marketplace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const hre = require("hardhat");
const { saveContractAddress} = require('../utils');

async function main() {
const marketplaceFactory = await hre.ethers.getContractFactory("AvalaunchMarketplace");
const marketplace = await marketplaceFactory.deploy();
await marketplace.deployed();

console.log(`Marketplace implementation address: ${marketplace.address}`);
saveContractAddress(hre.network.name, "AvalaunchMarketplace", marketplace.address);
}

// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
11 changes: 6 additions & 5 deletions test/V2Tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ async function signRemovePortionsFromMarket(user, contractAddress, portions, sig
return await deployer.signMessage(ethers.utils.arrayify(digest));
}

async function signBuyPortions(seller, buyer, sale, portions, pricesum, sigExpTime) {
async function signBuyPortions(seller, buyer, sale, portions, pricesum, itemId, sigExpTime) {

const digest = ethers.utils.solidityKeccak256(
['address', 'address', 'address', 'uint256[]', 'uint256', 'uint256', 'string'],
[seller, buyer, sale, portions, pricesum, sigExpTime, "buyPortions"]
['address', 'address', 'address', 'uint256[]', 'uint256', 'uint256', 'uint256', 'string'],
[seller, buyer, sale, portions, pricesum, itemId, sigExpTime, "buyPortions"]
);

return await deployer.signMessage(ethers.utils.arrayify(digest));
Expand Down Expand Up @@ -570,10 +570,11 @@ describe("Avalaunch Sale V2/Marketplace Tests", async () => {

it("Should buy portion", async () => {
const portions = [0];
const itemId = 7;
const sigExpTime = await getCurrentBlockTimestamp() + 500;
const priceSum = ethers.utils.parseEther('0.1');
const sig = await signBuyPortions(alice.address, bob.address, sale.address, portions, priceSum, sigExpTime);
await marketplace.connect(bob).buyPortions(sale.address, alice.address, sigExpTime, priceSum, portions, sig, {value: priceSum});
const sig = await signBuyPortions(alice.address, bob.address, sale.address, portions, priceSum, itemId, sigExpTime);
await marketplace.connect(bob).buyPortions(sale.address, alice.address, sigExpTime, priceSum, itemId, portions, sig, {value: priceSum});
//console.log(await sale.userToParticipation(bob.address));
expect(await marketplace.listedUserPortionsPerSale(alice.address, sale.address, 0)).to.equal(false);
});
Expand Down
Loading