Skip to content

#contract deployment using web3-lib.ts #84

@Dargon789

Description

@Dargon789

Reviewer's Guide

This pull request adds two ERC20 token implementations (a reflective fee-based token and an OpenZeppelin upgradeable token), accompanied by unit tests, TypeScript deployment utilities, and commits all generated contract artifacts, metadata, and configuration files.

Sequence diagram for contract deployment using web3-lib.ts

sequenceDiagram
    participant D as "Developer"
    participant W as "web3-lib.ts"
    participant Remix as "remix IDE"
    participant Eth as "Ethereum Node"
    D->>W: Call deploy(contractName, args, from, gas)
    W->>Remix: Get contract artifact JSON
    Remix-->>W: Return ABI and bytecode
    W->>Eth: Send contract deployment transaction
    Eth-->>W: Return deployed contract address
    W-->>D: Return contract instance
Loading

Sequence diagram for contract deployment using ethers-lib.ts

sequenceDiagram
    participant D as "Developer"
    participant E as "ethers-lib.ts"
    participant Remix as "remix IDE"
    participant Eth as "Ethereum Node"
    D->>E: Call deploy(contractName, args, accountIndex)
    E->>Remix: Get contract artifact JSON
    Remix-->>E: Return ABI and bytecode
    E->>Eth: Send contract deployment transaction
    Eth-->>E: Return deployed contract address
    E-->>D: Return contract instance
Loading

Class diagram for Token.sol reflective ERC20 implementation

classDiagram
    class Token {
        +string _name
        +string _symbol
        +uint8 _decimals
        +uint256 _tTotal
        +uint256 _rTotal
        +uint256 _tFeeTotal
        +uint8 _taxFee
        +uint8 _liquidityFee
        +uint8 _burnFee
        +uint8 _walletFee
        +uint8 _buybackFee
        +address feeWallet
        +address pcsV2Pair
        +IUniswapV2Router02 pcsV2Router
        +constructor(address tokenOwner, string tokenName, string tokenSymbol, uint8 decimal, uint256 amountOfTokenWei, uint8 setMxTxPer, uint8 setMxWalletPer, address payable _feeWallet)
        +transfer(address recipient, uint256 amount)
        +transferFrom(address sender, address recipient, uint256 amount)
        +approve(address spender, uint256 amount)
        +setAllFeePercent(uint8 taxFee, uint8 liquidityFee, uint8 burnFee, uint8 walletFee, uint8 buybackFee)
        +setMaxTxPercent(uint256 maxTxPercent)
        +setMaxWalletPercent(uint256 maxWalletPercent)
        +setSwapAndLiquifyEnabled(bool _enabled)
        +setFeeWallet(address payable newFeeWallet)
        +excludeFromFee(address account)
        +includeInFee(address account)
        +excludeFromReward(address account)
        +includeInReward(address account)
        +recoverBEP20(address tokenAddress, uint256 tokenAmount)
        +swapAndLiquify(uint256 contractTokenBalance)
        +buyBackTokens(uint256 amount)
        +swapTokensForBNB(uint256 tokenAmount)
        +swapBNBForTokens(uint256 amount)
        +addLiquidity(uint256 tokenAmount, uint256 ethAmount)
    }
    Token --|> IERC20
    Token --|> Ownable
    Token --|> Context
    Token o-- IUniswapV2Router02
    Token o-- IUniswapV2Factory
    Token o-- SafeMath
    Token o-- SafeERC20
    Token o-- Address
Loading

Class diagram for MyToken.sol upgradeable ERC20 implementation

classDiagram
    class MyToken {
        +constructor()
        +initialize(address initialOwner)
        +pause()
        +unpause()
        +mint(address to, uint256 amount)
        +_authorizeUpgrade(address newImplementation)
        +_update(address from, address to, uint256 value)
    }
    MyToken --|> Initializable
    MyToken --|> ERC20Upgradeable
    MyToken --|> ERC20BurnableUpgradeable
    MyToken --|> ERC20PausableUpgradeable
    MyToken --|> OwnableUpgradeable
    MyToken --|> ERC20PermitUpgradeable
    MyToken --|> UUPSUpgradeable
Loading

File-Level Changes

Change Details Files
Implement reflective ERC20 token with fees, liquidity and Uniswap integration
  • Add Token.sol with SafeMath, SafeERC20 and fee logic
  • Integrate UniswapV2Router for swap and liquify and buyback
  • Implement adjustable tax, burn, wallet, and buyback fees
contracts/Token.sol
Implement OpenZeppelin upgradeable ERC20 token with advanced features
  • Add MyToken.sol with burnable, pausable, mint, permit and UUPS support
  • Use Initializable pattern and upgrade authorization override
contracts/MyToken.sol
Add TypeScript deployment utilities and scripts
  • Create web3-lib.ts and ethers-lib.ts for generic contract deployment
  • Add deploy_with_web3.ts and deploy_with_ethers.ts entrypoint scripts
scripts/web3-lib.ts
scripts/ethers-lib.ts
scripts/deploy_with_web3.ts
scripts/deploy_with_ethers.ts
Add basic Solidity unit tests with custom transaction context
  • Add remix_tests_test.sol with assertion checks
  • Include custom sender and value test cases
tests/remix_tests_test.sol
Commit generated contract artifacts, metadata and build-info
  • Include JSON artifacts and metadata for all contracts
  • Add build-info outputs under artifacts folders
contracts/artifacts
contracts/artifacts/build-info
tests/artifacts
Add configuration and supporting files
  • Include scenario.json configuration
  • Add supplemental scenario setup files
contracts/scenario.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Originally posted by @sourcery-ai[bot] in #83 (comment)

Sub-issues

Metadata

Metadata

Assignees

Labels

Projects

Status

Backlog

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions