Skip to content

Commit

Permalink
Merge pull request #71 from nation3/active-passport-github
Browse files Browse the repository at this point in the history
Require valid passport when setting GitHub username
  • Loading branch information
aahna-ashina authored Oct 22, 2023
2 parents 4d16d9b + 882820d commit 4c936f4
Show file tree
Hide file tree
Showing 29 changed files with 366 additions and 3,247 deletions.
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

24 changes: 0 additions & 24 deletions .eslintrc.js

This file was deleted.

1 change: 0 additions & 1 deletion .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@ jobs:
cache-dependency-path: package-lock.json
- run: npm install

- run: npx eslint '**/*.{js,ts}'
- run: npx solhint 'contracts/**/*.sol'
- run: npx prettier '**/*.{json,sol,md}' --check
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ typings/
# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
Expand Down
2 changes: 1 addition & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "solhint:recommended",
"rules": {
"compiler-version": ["error", "^0.8.17"],
"compiler-version": ["error", "^0.8.19"],
"func-visibility": ["warn", { "ignoreConstructors": true }]
}
}
18 changes: 5 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ npx hardhat compile

Run unit tests:

```
export REPORT_GAS=true
```

```
npx hardhat test
```
Expand All @@ -43,13 +39,7 @@ Check if coverage threshold has been met:
npx istanbul check-coverage --lines 90
```

## Linters

Run ESLint:

```
npx eslint '**/*.{js,ts}' --fix
```
## Linting

Run Solhint:

Expand Down Expand Up @@ -111,18 +101,20 @@ npx hardhat run scripts/deploy-<contract>.ts --network mainnet
```

```
npx hardhat verify --network mainnet <address>
npx hardhat verify --network mainnet <address> <parameters>
```

## Deployments

### Goerli

- GitHub.sol: `0x7a0e37e6e64d4fc59207c163e0176e22a4072503`
- utils/PassportUtils.sol: `0xad42FC3fE04add6B4D177188E3B41677f03703a7`
- GitHubUsernames.sol: `0x1bDa420e57059FB7C97B13DE7F7Dd719371E0291`
- Discord.sol: `0x4BD52941D5C14035F49C93ab6EB3878DDa063119`

### Sepolia

- utils/PassportUtils.sol: `0x90EC93e8B5948b1F7759692fB3082ACd3abDa3F8`
- NationCred.sol: `0xff5F7A95D6dd29a0543f661a148ba1B9ac554763`

### Mainnet
Expand Down
2 changes: 1 addition & 1 deletion contracts/Discord.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.17;
pragma solidity ^0.8.19;

contract Discord {
mapping(address => string) public usernames;
Expand Down
2 changes: 1 addition & 1 deletion contracts/Discourse.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.17;
pragma solidity ^0.8.19;

contract Discourse {
mapping(address => string) public usernames;
Expand Down
22 changes: 0 additions & 22 deletions contracts/GitHub.sol

This file was deleted.

27 changes: 27 additions & 0 deletions contracts/GitHubUsernames.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.19;

import {IPassportUtils} from "./utils/IPassportUtils.sol";

contract GitHubUsernames {
string public constant VERSION = "0.6.1";
mapping(address => string) public usernames;
IPassportUtils public passportUtils;

error PassportExpired(address citizen);

event UsernameUpdated(address citizen, string username);

constructor(address passportUtils_) {
passportUtils = IPassportUtils(passportUtils_);
}

function updateUsername(string calldata username) public {
if (passportUtils.isExpired(msg.sender)) {
revert PassportExpired(msg.sender);
} else {
usernames[msg.sender] = username;
emit UsernameUpdated(msg.sender, username);
}
}
}
22 changes: 0 additions & 22 deletions contracts/Greeter.sol

This file was deleted.

2 changes: 1 addition & 1 deletion contracts/INationCred.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.17;
pragma solidity ^0.8.19;

interface INationCred {
/**
Expand Down
3 changes: 2 additions & 1 deletion contracts/NationCred.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.17;
pragma solidity ^0.8.19;

import "./INationCred.sol";
import "@openzeppelin/contracts/interfaces/IERC721.sol";
Expand All @@ -8,6 +8,7 @@ import "@openzeppelin/contracts/interfaces/IERC721.sol";
* @notice Stores the passport IDs of active Nation3 citizens.
*/
contract NationCred is INationCred {
string public constant VERSION = "0.6.1";
address public owner;
IERC721 public passport;
uint16[] private passportIDs;
Expand Down
2 changes: 1 addition & 1 deletion contracts/governance/IVotingEscrow.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.17;
pragma solidity ^0.8.19;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/mock/PassportIssuerMock.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.17;
pragma solidity ^0.8.19;

import "../passport/IPassportIssuer.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/mock/PassportMock.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
pragma solidity ^0.8.19;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/mock/VotingEscrowMock.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.17;
pragma solidity ^0.8.19;

import "../governance/IVotingEscrow.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/passport/IPassportIssuer.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.17;
pragma solidity ^0.8.19;

interface IPassportIssuer {
function revokeUnderBalance() external view returns (uint256);
Expand Down
2 changes: 1 addition & 1 deletion contracts/utils/IPassportUtils.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.17;
pragma solidity ^0.8.19;

interface IPassportUtils {
/**
Expand Down
6 changes: 2 additions & 4 deletions contracts/utils/PassportUtils.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
//SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.17;
pragma solidity ^0.8.19;

import "./IPassportUtils.sol";
import "../passport/IPassportIssuer.sol";
import "../governance/IVotingEscrow.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "hardhat/console.sol";

contract PassportUtils is IPassportUtils {
using SafeERC20 for IERC20;

string public constant VERSION = "0.6.1";
IPassportIssuer public passportIssuer;
IVotingEscrow public votingEscrow;

Expand Down
15 changes: 4 additions & 11 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import * as dotenv from "dotenv";

import { HardhatUserConfig, task } from "hardhat/config";
import "@nomiclabs/hardhat-etherscan";
import "@nomiclabs/hardhat-waffle";
import "@typechain/hardhat";
import "hardhat-gas-reporter";
import "solidity-coverage";

dotenv.config();
import "@nomicfoundation/hardhat-toolbox";
require("dotenv").config();

// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
Expand All @@ -23,7 +16,7 @@ task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
// Go to https://hardhat.org/config/ to learn more

const config: HardhatUserConfig = {
solidity: "0.8.17",
solidity: "0.8.19",
networks: {
goerli: {
url: process.env.GOERLI_URL || "",
Expand All @@ -42,7 +35,7 @@ const config: HardhatUserConfig = {
},
},
gasReporter: {
enabled: process.env.REPORT_GAS !== undefined,
enabled: true,
currency: "USD",
},
etherscan: {
Expand Down
Loading

0 comments on commit 4c936f4

Please sign in to comment.