Skip to content

Commit

Permalink
chore: change namings and solidity version
Browse files Browse the repository at this point in the history
  • Loading branch information
Behzad-rabiei committed Jul 19, 2024
1 parent 4bd0984 commit c9f11f6
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 52 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
}
},
"solidity.compileUsingRemoteVersion": "v0.8.26+commit.8a97fa7a"
}
Binary file modified .yarn/install-state.gz
Binary file not shown.
39 changes: 14 additions & 25 deletions contracts/ApplicationManager.sol
Original file line number Diff line number Diff line change
@@ -1,42 +1,31 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;
pragma solidity 0.8.26;

import {IApplicationManager} from "./IApplicationManager.sol";

contract ApplicationManager is IApplicationManager {
mapping(uint => Application) private applications_;
uint private nextApplicationId_;
mapping(uint => Application) private applications;
uint private nextApplicationId;

constructor() {}

function nextApplicationId() external view returns (uint) {
return nextApplicationId_;
function getNextApplicationId() external view returns (uint) {
return nextApplicationId;
}

function createApplication(Application memory _application) external {
applications_[nextApplicationId_] = _application;
emit ApplicationCreated(
nextApplicationId_,
applications_[nextApplicationId_]
);
nextApplicationId_++;
function createApplication(Application memory application) external {
applications[nextApplicationId] = application;
emit ApplicationCreated(nextApplicationId, applications[nextApplicationId]);
nextApplicationId++;
}

function updateApplication(
uint _id,
Application memory _application
) external override {}
function updateApplication(uint id, Application memory application) external override {}

function deleteApplication(uint _id) external override {}
function deleteApplication(uint id) external override {}

function getApplication(
uint _id
) external view returns (Application memory) {
return applications_[_id];
function getApplication(uint id) external view returns (Application memory) {
return applications[id];
}

function getApplications(
uint _start,
uint _limit
) external override returns (Application[] memory application) {}
function getApplications(uint start, uint limit) external override returns (Application[] memory application) {}
}
27 changes: 7 additions & 20 deletions contracts/IApplicationManager.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;
pragma solidity 0.8.26;

interface IApplicationManager {
struct Application {
Expand All @@ -11,23 +11,10 @@ interface IApplicationManager {
event ApplicationUpdated(uint id, Application application);
event ApplicationDeleted(uint id, Application application);

function nextApplicationId() external view returns (uint);

function createApplication(Application memory _application) external;

function updateApplication(
uint _id,
Application memory _application
) external;

function deleteApplication(uint _id) external;

function getApplication(
uint _id
) external view returns (Application memory);

function getApplications(
uint _start,
uint _limit
) external returns (Application[] memory application);
function getNextApplicationId() external view returns (uint);
function createApplication(Application memory application) external;
function updateApplication(uint id, Application memory application) external;
function deleteApplication(uint id) external;
function getApplication(uint id) external view returns (Application memory);
function getApplications(uint start, uint limit) external returns (Application[] memory);
}
2 changes: 1 addition & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import "@nomicfoundation/hardhat-toolbox-viem";
import "@nomiclabs/hardhat-solhint";

const config: HardhatUserConfig = {
solidity: "0.8.25",
solidity: "0.8.26",
};

export default config;
10 changes: 5 additions & 5 deletions test/ApplicationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe("ApplicationManager", () => {
describe("Deployment", () => {
it("Should set the nextxApplicationId to 0", async () => {
const { contract } = await loadFixture(deploy);
expect(await contract.read.nextApplicationId()).to.equal(
expect(await contract.read.getNextApplicationId()).to.equal(
parseUnits("0", 0),
);
});
Expand All @@ -58,21 +58,21 @@ describe("ApplicationManager", () => {
expect(await contract.write.createApplication([app])).to.be.string;
});
it("Should increment nextApplicationId", async () => {
const t0 = await contract.read.nextApplicationId();
const t0 = await contract.read.getNextApplicationId();
expect(t0).to.equal(parseUnits("0", 0));
await contract.write.createApplication([app]);
const t1 = await contract.read.nextApplicationId();
const t1 = await contract.read.getNextApplicationId();
expect(t1).to.equal(parseUnits("1", 0));
});
it("Should create a new Application", async () => {
const applicationId = await contract.read.nextApplicationId();
const applicationId = await contract.read.getNextApplicationId();
await contract.write.createApplication([app]);
expect(await contract.read.getApplication([applicationId])).to.contain(
app,
);
});
it("Should emit the ApplicationCreated event with the new application's details", async () => {
const applicationId = await contract.read.nextApplicationId();
const applicationId = await contract.read.getNextApplicationId();
const txHash = await contract.write.createApplication([app]);

const events = await contract.getEvents.ApplicationCreated();
Expand Down

0 comments on commit c9f11f6

Please sign in to comment.