Skip to content

Commit

Permalink
feat: create IVersionable interface (#76)
Browse files Browse the repository at this point in the history
* chore: add version
* chore: add version test
* chore: upgrade packages
* chore: remove deployed contracts
* chore: sync files with all repos
* chore: update scripts
* chore: update package-lock.json
* chore: update comments
* docs: update `README.md`
---------
Co-authored-by: Igor Senych <[email protected]>
Co-authored-by: Igor Senych <[email protected]>
  • Loading branch information
ihoroleksiienko authored Nov 11, 2024
1 parent 7eab765 commit cc2e1e3
Show file tree
Hide file tree
Showing 15 changed files with 1,070 additions and 1,745 deletions.
27 changes: 14 additions & 13 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
SOLIDITY_VERSION = 0.8.24
OPTIMIZER_ENABLED = true
OPTIMIZER_RUNS = 1000
GAS_REPORTER_ENABLED = false
HARDHAT_MNEMONIC = test test test test test test test test test test test junk
GANACHE_RPC = http://127.0.0.1:7545
GANACHE_MNEMONIC = test test test test test test test test test test test junk
CW_TESTNET_RPC =
CW_TESTNET_PK =
CW_TESTNET_MNEMONIC =
CW_MAINNET_RPC =
CW_MAINNET_PK =
CW_MAINNET_MNEMONIC =
SOLIDITY_VERSION = 0.8.24
OPTIMIZER_ENABLED = true
OPTIMIZER_RUNS = 1000
GAS_REPORTER_ENABLED = false
CONTRACT_SIZER_ENABLED = false
HARDHAT_MNEMONIC = test test test test test test test test test test test junk
GANACHE_RPC = http://127.0.0.1:7545
GANACHE_MNEMONIC = test test test test test test test test test test test junk
CW_TESTNET_RPC =
CW_TESTNET_PK =
CW_TESTNET_MNEMONIC =
CW_MAINNET_RPC =
CW_MAINNET_PK =
CW_MAINNET_MNEMONIC =
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
</p>

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
![example branch parameter](https://github.com/cloudwalk/brlc-periphery/actions/workflows/build.yml/badge.svg?branch=main)
![example branch parameter](https://github.com/cloudwalk/brlc-periphery/actions/workflows/test.yml/badge.svg?branch=main)
![example branch parameter](https://github.com/cloudwalk/brlc-card-payment-processor/actions/workflows/build.yml/badge.svg?branch=main)
![example branch parameter](https://github.com/cloudwalk/brlc-card-payment-processor/actions/workflows/test.yml/badge.svg?branch=main)

This repository contains Card Payment Processor smart contracts.</br>
This repository contains CardPaymentProcessor smart contracts.

## Project Setup
1. Clone the repo.
2. Create the `.env` file based on the `.env.example` one:
* Windows:
* Windows:
```sh
copy .env.example .env
```
* MacOS/Linux:
* MacOS/Linux:
```sh
cp .env.example .env
```
3. Update settings in the newly created `.env` file if needed (e.g. another solidity version, number of optimization runs, private keys (PK) for networks, network RPC URLs, etc.).
3. Optionally update the settings in the newly created `.env` file (e.g., Solidity version, number of optimization runs, network RPC URLs, private keys (PK) for networks, etc.).

## Build and test

Expand All @@ -36,10 +36,6 @@ npx hardhat compile
npx hardhat test
```

## Networks and deployments

Information about deployments across all the networks can be found [here](./docs/deployed-contracts.json).

## Licensing

This project is released under the MIT License, see [LICENSE](./LICENSE).
4 changes: 3 additions & 1 deletion contracts/CardPaymentProcessor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { BlocklistableUpgradeable } from "./base/BlocklistableUpgradeable.sol";
import { PausableExtUpgradeable } from "./base/PausableExtUpgradeable.sol";
import { RescuableUpgradeable } from "./base/RescuableUpgradeable.sol";
import { AccessControlExtUpgradeable } from "./base/AccessControlExtUpgradeable.sol";
import { Versionable } from "./base/Versionable.sol";

import { CardPaymentProcessorStorage } from "./CardPaymentProcessorStorage.sol";
import { ICardPaymentProcessor } from "./interfaces/ICardPaymentProcessor.sol";
Expand All @@ -27,7 +28,8 @@ contract CardPaymentProcessor is
RescuableUpgradeable,
UUPSUpgradeable,
ICardPaymentProcessor,
ICardPaymentCashback
ICardPaymentCashback,
Versionable
{
using SafeERC20 for IERC20;

Expand Down
21 changes: 21 additions & 0 deletions contracts/base/Versionable.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../interfaces/IVersionable.sol";

/**
* @title Versionable contract
* @author CloudWalk Inc. (See https://cloudwalk.io)
* @dev Defines the contract version.
*/
abstract contract Versionable is IVersionable {
// ------------------ Pure functions -------------------------- //

/**
* @inheritdoc IVersionable
*/
function $__VERSION() external pure returns (Version memory) {
return Version(2, 0, 0);
}
}
24 changes: 24 additions & 0 deletions contracts/interfaces/IVersionable.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
* @title IVersionable interface
* @author CloudWalk Inc. (See https://cloudwalk.io)
* @dev Defines the function of getting the contract version.
*/
interface IVersionable {
/**
* @dev The struct for the contract version.
*/
struct Version {
uint16 major; // -- The major version of contract
uint16 minor; // -- The minor version of contract
uint16 patch; // -- The patch version of contract
}

/**
* @dev Returns the version of the contract.
*/
function $__VERSION() external pure returns (Version memory);
}
22 changes: 0 additions & 22 deletions docs/deployed-contracts.json

This file was deleted.

3 changes: 3 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ const config: HardhatUserConfig = {
},
gasReporter: {
enabled: process.env.GAS_REPORTER_ENABLED === "true"
},
contractSizer: {
runOnCompile: process.env.CONTRACT_SIZER_ENABLED === "true"
}
};

Expand Down
Loading

0 comments on commit cc2e1e3

Please sign in to comment.