Skip to content

Commit

Permalink
add view function
Browse files Browse the repository at this point in the history
  • Loading branch information
weiqiushi committed Dec 28, 2023
1 parent cac2d1b commit 03058b4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
4 changes: 4 additions & 0 deletions contracts/public_data_storage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ contract PublicDataStorage {
emit DepositData(msg.sender, dataMixedHash, balance_add, system_reward);
}

function getPublicData(bytes32 dataMixedHash) public view returns(PublicData memory) {
return public_datas[dataMixedHash];
}

function getOwner(bytes32 dataMixedHash) public view returns(address) {
PublicData memory info = public_datas[dataMixedHash];
if (info.owner != address(0)) {
Expand Down
21 changes: 11 additions & 10 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@ import { ethers, network } from "hardhat";
import * as fs from "node:fs";

async function main() {
const dmcContract = await (await ethers.deployContract("DMCToken", [ethers.parseEther("1000000")])).waitForDeployment();
const dmcContract = await (await ethers.deployContract("DMCToken", [ethers.parseEther("100000000")])).waitForDeployment();
let dmcAddress = await dmcContract.getAddress();
console.log("DMCToken deployed to:", dmcAddress);
const gwtContract = await (await ethers.deployContract("GWTToken", [dmcAddress])).waitForDeployment();

let gwtAddress = await gwtContract.getAddress();
console.log("GWT deployed to:", gwtAddress);
/*
const exchangeContract = await (await ethers.deployContract("StorageExchange", [gwtAddress])).waitForDeployment();
let exchangeAddress = await exchangeContract.getAddress();
console.log("Exchange deployed to:", exchangeAddress);
*/
const sortedScoreList = await (await ethers.deployContract("SortedScoreList")).waitForDeployment();
let sortedScoreListAddress = await sortedScoreList.getAddress();
console.log("SortedScoreList deployed to:", sortedScoreListAddress);
const publicDataStorage = await (await ethers.deployContract("PublicDataStorage", [gwtAddress], {libraries: {"SortedScoreList": sortedScoreListAddress}})).waitForDeployment();

let listLibrary = await (await ethers.getContractFactory("SortedScoreList")).deploy();
let proofLibrary = await (await ethers.getContractFactory("PublicDataProof")).deploy();


const publicDataStorage = await (await ethers.deployContract("PublicDataStorage", [gwtAddress], {libraries: {
"SortedScoreList": await listLibrary.getAddress(),
"PublicDataProof": await proofLibrary.getAddress()
}})).waitForDeployment();

let publicDataStorageAddress = await publicDataStorage.getAddress();
console.log("PublicDataStorage deployed to:", publicDataStorageAddress);

Expand Down

0 comments on commit 03058b4

Please sign in to comment.