Skip to content

Commit

Permalink
Merge pull request #1 from dl-tokene/feature/hardhat-ts
Browse files Browse the repository at this point in the history
Rewrite the project to utilize the Hardhat framework with TS
  • Loading branch information
KyrylR authored Feb 6, 2024
2 parents c0fa49f + ba8a40d commit d67aee0
Show file tree
Hide file tree
Showing 59 changed files with 11,049 additions and 28,196 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ charset = utf-8
end_of_line = lf
indent_style = space
insert_final_newline = true
[*.js]
[*.ts]
indent_size = 2
max_line_length = 120
[*.sol]
indent_size = 4
max_line_length = 99
max_line_length = 99
11 changes: 7 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# Deployer private key
PRIVATE_KEY = "YOUR PRIVATE KEY"

# RPC Endpoints
INFURA_KEY = "INFURA PROJECT ID"

# Additional keys
ETHERSCAN_KEY = "ETHERSCAN API KEY"
BSCSCAN_KEY = "BSCSCAN API KEY"
COINMARKETCAP_KEY = "COINMARKETCAP API KEY"

# Bridge configuration
BRIDGE_OWNER = "bridge contract owner"
BRIDGE_VALIDATORS = "addresses separated by ',' that can sign withdrawals to bridge contract"
BRIDGE_THRESHHOLD = int, number of signatures needed to check withdraw by bridge contract, example: 1

# Available targets: 'ethers-v5', 'truffle-v5' and 'web3-v1'
# By default 'ethers-v5'
TYPECHAIN_TARGET = "TYPECHAIN TARGET"
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Bug Report
description: File a bug report
labels: ['bug']
assignees:
- Arvolear
body:
- type: markdown
attributes:
value: Thanks for taking the time to fill out this bug report!
- type: input
id: version
attributes:
label: "Project version"
placeholder: "1.2.3"
validations:
required: true
- type: textarea
id: what-happened
attributes:
label: What happened?
description: A brief description of what happened and what you expected to happen
validations:
required: true
- type: textarea
id: reproduction-steps
attributes:
label: "Minimal reproduction steps"
description: "The minimal steps needed to reproduce the bug"
validations:
required: true
13 changes: 13 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Feature request
description: Suggest a new feature
labels: ['feature']
assignees:
- Arvolear
body:
- type: textarea
id: feature-description
attributes:
label: "Describe the feature"
description: "A description of what you would like to see in the project"
validations:
required: true
4 changes: 4 additions & 0 deletions .github/ISSUE_TEMPLATE/other-issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
name: Other issue
about: Other kind of issue
---
15 changes: 15 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: setup

description: setup

runs:
using: composite
steps:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "16.18.x"
cache: npm
- name: Install packages
run: npm install
shell: bash
21 changes: 21 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "checks"

on:
push:
branches:
- main
pull_request:
branches:
- main
- dev

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup
- name: Run tests
run: npm run test
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"plugins": ["prettier-plugin-solidity"],
"overrides": [
{
"files": "*.sol",
Expand Down
File renamed without changes.
Empty file removed contracts/.gitkeep
Empty file.
8 changes: 4 additions & 4 deletions contracts/bridge/Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ contract Bridge is
ERC1155Handler,
NativeHandler
{
function __Bridge_init(address[] calldata signers_, uint256 signaturesThreshold_)
external
initializer
{
function __Bridge_init(
address[] calldata signers_,
uint256 signaturesThreshold_
) external initializer {
__Signers_init(signers_, signaturesThreshold_);
}

Expand Down
9 changes: 4 additions & 5 deletions contracts/handlers/NativeHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ pragma solidity ^0.8.9;
import "../interfaces/handlers/INativeHandler.sol";

abstract contract NativeHandler is INativeHandler {
function depositNative(string calldata receiver_, string calldata network_)
external
payable
override
{
function depositNative(
string calldata receiver_,
string calldata network_
) external payable override {
require(msg.value > 0, "NativeHandler: zero value");

emit DepositedNative(msg.value, receiver_, network_);
Expand Down
6 changes: 1 addition & 5 deletions contracts/interfaces/tokens/IERC1155MintableBurnable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,5 @@ interface IERC1155MintableBurnable is IERC1155 {
string calldata tokenURI_
) external;

function burnFrom(
address payer_,
uint256 tokenId_,
uint256 amount_
) external;
function burnFrom(address payer_, uint256 tokenId_, uint256 amount_) external;
}
6 changes: 1 addition & 5 deletions contracts/interfaces/tokens/IERC721MintableBurnable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ pragma solidity ^0.8.9;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

interface IERC721MintableBurnable is IERC721 {
function mintTo(
address receiver_,
uint256 tokenId_,
string calldata tokenURI_
) external;
function mintTo(address receiver_, uint256 tokenId_, string calldata tokenURI_) external;

function burnFrom(address payer_, uint256 tokenId_) external;
}
8 changes: 4 additions & 4 deletions contracts/mocks/utils/SignersMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ pragma solidity ^0.8.9;
import "../../utils/Signers.sol";

contract SignersMock is Signers {
function __SignersMock_init(address[] calldata signers_, uint256 signaturesThreshold_)
public
initializer
{
function __SignersMock_init(
address[] calldata signers_,
uint256 signaturesThreshold_
) public initializer {
__Signers_init(signers_, signaturesThreshold_);
}

Expand Down
9 changes: 3 additions & 6 deletions contracts/tokens/ERC1155MintableBurnable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,9 @@ contract ERC1155MintableBurnable is
_burn(payer_, tokenId_, amount_);
}

function uri(uint256 tokenId)
public
view
override(ERC1155URIStorage, ERC1155)
returns (string memory)
{
function uri(
uint256 tokenId
) public view override(ERC1155URIStorage, ERC1155) returns (string memory) {
return super.uri(tokenId);
}

Expand Down
6 changes: 1 addition & 5 deletions contracts/tokens/ERC20MintableBurnable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "../interfaces/tokens/IERC20MintableBurnable.sol";

contract ERC20MintableBurnable is IERC20MintableBurnable, Ownable, ERC20 {
constructor(
string memory name_,
string memory symbol_,
address owner_
) ERC20(name_, symbol_) {
constructor(string memory name_, string memory symbol_, address owner_) ERC20(name_, symbol_) {
transferOwnership(owner_);
}

Expand Down
18 changes: 6 additions & 12 deletions contracts/tokens/ERC721MintableBurnable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,15 @@ contract ERC721MintableBurnable is
_burn(tokenId_);
}

function tokenURI(uint256 tokenId)
public
view
override(ERC721URIStorage, ERC721)
returns (string memory)
{
function tokenURI(
uint256 tokenId
) public view override(ERC721URIStorage, ERC721) returns (string memory) {
return super.tokenURI(tokenId);
}

function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721Enumerable, ERC721, IERC165)
returns (bool)
{
function supportsInterface(
bytes4 interfaceId
) public view override(ERC721Enumerable, ERC721, IERC165) returns (bool) {
return super.supportsInterface(interfaceId);
}

Expand Down
10 changes: 5 additions & 5 deletions contracts/utils/Signers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ abstract contract Signers is OwnableUpgradeable {

EnumerableSet.AddressSet internal _signers;

function __Signers_init(address[] calldata signers_, uint256 signaturesThreshold_)
public
onlyInitializing
{
function __Signers_init(
address[] calldata signers_,
uint256 signaturesThreshold_
) public onlyInitializing {
__Ownable_init();

addSigners(signers_);
Expand All @@ -29,7 +29,7 @@ abstract contract Signers is OwnableUpgradeable {
for (uint256 i = 0; i < signers_.length; i++) {
require(_signers.contains(signers_[i]), "Signers: invalid signer");

uint256 bitKey = 2**(uint256(uint160(signers_[i])) >> 152);
uint256 bitKey = 2 ** (uint256(uint160(signers_[i])) >> 152);

require(bitMap & bitKey == 0, "Signers: duplicate signers");

Expand Down
24 changes: 24 additions & 0 deletions deploy/1_bridge.migration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Deployer, Reporter } from "@solarity/hardhat-migrate";

import { Bridge__factory, ERC1967Proxy__factory } from "@ethers-v6";

const OWNER = process.env.BRIDGE_OWNER!;
const validators = process.env.BRIDGE_VALIDATORS!.split(",");
const threshold = parseInt(process.env.BRIDGE_THRESHHOLD!, 10);

export = async (deployer: Deployer) => {
const bridgeImplementation = await deployer.deploy(Bridge__factory);
const proxy = await deployer.deploy(ERC1967Proxy__factory, [
await bridgeImplementation.getAddress(),
bridgeImplementation.interface.encodeFunctionData("__Bridge_init", [validators, threshold]),
]);

const bridge = await deployer.deployed(Bridge__factory, await proxy.getAddress());

await bridge.transferOwnership(OWNER);

Reporter.reportContracts(
["Bridge Implementation", await bridgeImplementation.getAddress()],
["Bridge Proxy", await proxy.getAddress()],
);
};
18 changes: 0 additions & 18 deletions deploy/migrations/1_Bridge.migration.js

This file was deleted.

Loading

0 comments on commit d67aee0

Please sign in to comment.