Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR just for the sake of reviewing #44

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 9 additions & 150 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,143 +1,39 @@
[![Biconomy](https://img.shields.io/badge/Made_with_%F0%9F%8D%8A_by-Biconomy-ff4e17?style=flat)](https://biconomy.io) [![License MIT](https://img.shields.io/badge/License-MIT-blue?&style=flat)](./LICENSE) [![Foundry](https://img.shields.io/badge/Built%20with-Foundry-FFBD10.svg)](https://getfoundry.sh/)



# Smart Contract Template Base 🚀

[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/bcnmy/sc-template)

This repository serves as a comprehensive foundation for smart contract projects, streamlining the development process with a focus on best practices, security, and efficiency.

## 📚 Table of Contents

- [🚀 Introduction](#smart-contract-template-base-)
- [🌟 Features](#features)
- [🏁 Getting Started](#getting-started)
- [🔧 Essential Scripts](#️-essential-scripts)
- [🔒 Security Audits](#-security-audits)
- [🏆 Biconomy Champions League](#-biconomy-champions-league-)
- [📖 Documentation and Resources](#documentation-and-resources)
- [📄 License](#license)
- [🤝 Connect with Biconomy](#connect-with-biconomy-)

## Features

- **Smart Contract Template Base**: A robust foundation for future smart contract projects.
- **Foundry Support**: Equipped with Foundry tools and an adapted folder structure for seamless development.
- **Best Practices**: Adheres to industry best practices in smart contract programming to ensure code quality and security.
- **Continuous Integration & Deployment**: Utilizes GitHub Actions for automated testing and deployment, ensuring code reliability.
- **Strict Linting**: Implements Solhint based on the Solidity style guide, enhancing code quality and consistency.
- **Comprehensive Testing**: Includes a wide range of tests (unit, fuzz, fork) for both Foundry environment.
- **Environment Configuration**: Comes with `.env.example` for easy setup of API keys and environmental variables.
- **Code Formatting**: Uses Prettier to maintain a consistent code style across the project.
- **Configurations for Foundry**: Provides essential settings and scripts for building, testing, and deployment, tailored for both development environments.
# Biconomy Paymaster Contracts
- Sponsorship (Verifying) Paymaster
- Token Payment Paymaster

## Getting Started

To kickstart your smart contract development with this template, follow these steps:

### Prerequisites

- Node.js (v18.x or later)
- Yarn (or npm)
- Pnpm
- Foundry (Refer to [Foundry installation instructions](https://getfoundry.sh/docs/installation))

### Installation

1. **Clone the repository:**

```bash
git clone https://github.com/bcnmy/sc-template.git
cd sc-template
git clone https://github.com/bcnmy/gasdaddy.git
cd gasdaddy
```

2. **Install dependencies:**

```bash
yarn install
pnpm i
```

3. **Setup environment variables:**

Copy `.env.example` to `.env` and fill in your details.

## 🛠️ Essential Scripts

Execute key operations for Foundry with these scripts. Append `:forge` to run them in the respective environment.

### 🏗️ Build Contracts

```bash
yarn build
```

Compiles contracts for both Foundry.

### 🧪 Run Tests

```bash
yarn test
```

Carries out tests to verify contract functionality.

### ⛽ Gas Report

```bash
yarn test:gas
```

Creates detailed reports for test coverage.

### 📊 Coverage Report

```bash
yarn coverage
```

Creates detailed reports for test coverage.

### 📄 Documentation

```bash
yarn docs
```

Generate documentation from NatSpec comments.
4. **Use forge to build, test and deploy**

### 🚀 Deploy Contracts

```bash
yarn deploy
```

Deploys contracts onto the blockchain network.

### 🎨 Lint Code

```bash
yarn lint
```

Checks code for style and potential errors.

### 🖌️ Auto-fix Linting Issues

```bash
yarn lint:fix
```

Automatically fixes linting problems found.

### 🚀 Generating Storage Layout

```bash
yarn check
```



🔄 Add `:forge` to any script above to target only Foundry
As usual :grin:

## 🔒 Security Audits

Expand All @@ -147,43 +43,6 @@ yarn check
| Firm Name | DD-MM-YYYY | [View Report](./audits) |
| Firm Name | DD-MM-YYYY | [View Report](./audits) |

## 🏆 Biconomy Champions League 🏆

Welcome to the Champions League, a place where your contributions to Biconomy are celebrated and immortalized in our Hall of Fame. This elite group showcases individuals who have significantly advanced our mission, from enhancing code efficiency to strengthening security, and enriching our documentation.

### Champions Roster

| 🍊 Contributor | 🛡️ Domain |
| -------------- | ----------------- |
| @user1 | Code Optimization |
| @user2 | Security |
| @user3 | Documentation |
| ... | ... |

### Entering the League

Your journey to becoming a champion can start in any domain:

- **Code Wizards**: Dive into our [Gas Optimization](./GAS_OPTIMIZATION.md) efforts.
- **Security Guardians**: Enhance our safety following the [Security Guidelines](./SECURITY.md).
- **Documentation Scribes**: Elevate our knowledge base with your contributions.

The **Champions League** is not just a recognition, it's a testament to the impactful work done by our community. Whether you're optimizing gas usage or securing our contracts, your contributions help shape the future of Biconomy.

> **To Join**: Leave a lasting impact in your chosen area. Our Hall of Fame is regularly updated to honor our most dedicated contributors.

Let's build a legacy together, championing innovation and excellence in the blockchain space.

## Documentation and Resources

For a comprehensive understanding of our project and to contribute effectively, please refer to the following resources:

- [**Contributing Guidelines**](./CONTRIBUTING.md): Learn how to contribute to our project, from code contributions to documentation improvements.
- [**Code of Conduct**](./CODE_OF_CONDUCT.md): Our commitment to fostering an open and welcoming environment.
- [**Security Policy**](./SECURITY.md): Guidelines for reporting security vulnerabilities.
- [**Gas Optimization Program**](./GAS_OPTIMIZATION.md): Contribute towards optimizing gas efficiency of our smart contracts.
- [**Changelog**](./CHANGELOG.md): Stay updated with the changes and versions.

## License

This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.
Expand Down
1 change: 1 addition & 0 deletions contracts/base/BasePaymaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
/* solhint-disable reason-string */

import { SoladyOwnable } from "../utils/SoladyOwnable.sol";
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";

Check warning on line 7 in contracts/base/BasePaymaster.sol

View workflow job for this annotation

GitHub Actions / Lint sources

global import of path @openzeppelin/contracts/utils/introspection/IERC165.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)
import { IPaymaster } from "account-abstraction/interfaces/IPaymaster.sol";
import { IEntryPoint } from "account-abstraction/interfaces/IEntryPoint.sol";
import "account-abstraction/core/UserOperationLib.sol";

Check warning on line 10 in contracts/base/BasePaymaster.sol

View workflow job for this annotation

GitHub Actions / Lint sources

global import of path account-abstraction/core/UserOperationLib.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)

/**
* Helper class for creating a paymaster.
* provides helper methods for staking.
Expand All @@ -15,7 +16,7 @@
*/

abstract contract BasePaymaster is IPaymaster, SoladyOwnable {
IEntryPoint public immutable entryPoint;

Check warning on line 19 in contracts/base/BasePaymaster.sol

View workflow job for this annotation

GitHub Actions / Lint sources

Immutable variables name are set to be in capitalized SNAKE_CASE

uint256 internal constant _PAYMASTER_VALIDATION_GAS_OFFSET = UserOperationLib.PAYMASTER_VALIDATION_GAS_OFFSET;
uint256 internal constant _PAYMASTER_POSTOP_GAS_OFFSET = UserOperationLib.PAYMASTER_POSTOP_GAS_OFFSET;
Expand Down Expand Up @@ -106,7 +107,7 @@
//sanity check: make sure this EntryPoint was compiled against the same
// IEntryPoint of this paymaster
function _validateEntryPointInterface(IEntryPoint entryPointArg) internal virtual {
require(

Check warning on line 110 in contracts/base/BasePaymaster.sol

View workflow job for this annotation

GitHub Actions / Lint sources

GC: Use Custom Errors instead of require statements
IERC165(address(entryPointArg)).supportsInterface(type(IEntryPoint).interfaceId),
"IEntryPoint interface mismatch"
);
Expand Down Expand Up @@ -153,14 +154,14 @@
{
(mode, context, actualGasCost, actualUserOpFeePerGas); // unused params
// subclass must override this method if validatePaymasterUserOp returns a context
revert("must override");

Check warning on line 157 in contracts/base/BasePaymaster.sol

View workflow job for this annotation

GitHub Actions / Lint sources

GC: Use Custom Errors instead of revert statements
}

/**
* Validate the call is made from a valid entrypoint
*/
function _requireFromEntryPoint() internal virtual {
require(msg.sender == address(entryPoint), "Sender not EntryPoint");

Check warning on line 164 in contracts/base/BasePaymaster.sol

View workflow job for this annotation

GitHub Actions / Lint sources

GC: Use Custom Errors instead of require statements
}

/**
Expand All @@ -168,7 +169,7 @@
*/
function _isContract(address addr) internal view returns (bool) {
uint256 size;
assembly ("memory-safe") {

Check warning on line 172 in contracts/base/BasePaymaster.sol

View workflow job for this annotation

GitHub Actions / Lint sources

Avoid to use inline assembly. It is acceptable only in rare cases
size := extcodesize(addr)
}
return size > 0;
Expand Down
Loading
Loading