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

feat(evm): Create ethers v6 adapters for Nibiru and publish TS library #2197

Merged
merged 9 commits into from
Feb 10, 2025

Conversation

Unique-Divine
Copy link
Member

@Unique-Divine Unique-Divine commented Feb 4, 2025

Purpose / Abstract

This pull request implements the
@nibiruchain/evm-core package

Usage API

yarn add @nibiruchain/evm-core
import {
  funtokenPrecompile,
  wasmPrecompile,
} from "@nibiruchain/evm-core/ethers";
import { ethers } from "ethers";

// Set up ethers v6 provider. Most apps will use a Browser provider based on the
// window.ethereum object.
const provider = ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();

const wasmCaller = wasmPrecompile(provider)

How I Tested This

I tested the usage of this package against a local network by creating a tarball and importing that locally to the package.json.

From Nibiru/evm-core-ts, I run

npm pack

This creates a "nibiruchain-evm-core*.tgz" file. Then in a separate JS project, I import the tgz file as a local dependency named @nibiruchain/evm-core. This lets me get as close as possible to what an external will get when importing the package from npm, as installing a tarball dependency uses the compiled version of the package (only *.js and *.d.ts files)

@Unique-Divine Unique-Divine requested a review from a team as a code owner February 4, 2025 23:12
Copy link
Contributor

coderabbitai bot commented Feb 4, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The pull request adds a new changelog entry for ethers v6 adapters for Nibiru and updates several build and configuration files. In the evm-core-ts project, new files such as a .gitignore, README, Justfile, package.json, and Prettier config have been introduced. Numerous TypeScript interfaces, typechain definitions, and autogenerated factory classes for Ethereum contracts are added or updated. Precompile contract files with HexAddr types, documentation enhancements, Solidity formatting improvements, ABI artifact updates, and a new file-skipping mechanism in the Go-based ABI generator are also included.

Changes

Files Change Summary
CHANGELOG.md Added new chore entry (#2197) for creating ethers v6 adapters for Nibiru.
contrib/make/simulation.mk Updated SIMAPP path from ./simapp./app/simapp.
evm-core-ts/ (*.gitignore, README.md, justfile, package.json, prettier.config.js) Introduced project setup and configuration files for the @nibiruchain/evm-core library—including build, type generation, formatting, and publishing recipes, plus metadata and usage instructions.
evm-core-ts/src/ethers/index.ts Added typed contract methods (e.g. wasmPrecompile, oraclePrecompile, funtokenPrecompile, chainlinkLike) to enhance interaction with precompiled contracts.
evm-core-ts/src/ethers/typechain/*.ts New and updated TypeScript interfaces and type declarations (e.g. ChainLinkAggregatorV3Interface, ERC20Minter, IFunToken, INibiruEvm, IOracle, IWasm, NibiruOracleChainLinkLike, common types) for type-safe contract interactions.
evm-core-ts/src/ethers/typechain/factories/*.ts and related index files Added autogenerated factory classes to facilitate connection to and creation of contract instances.
evm-core-ts/src/precompile/* and evm-core-ts/src/src.ts Introduced precompile contract constants and ABI definitions for FunToken, Oracle, and Wasm, including a new HexAddr type alias.
evm-core-ts/tsconfig.json Added new TypeScript configuration with ESNext settings and specific exclusion patterns.
x/evm/embeds/ (README.md, abi/ERC20.json, artifacts/*, contracts/MKR.sol) Updated documentation for ABI usage, added an ERC20 ABI file, reformatted Solidity contracts, and updated DS* contract artifacts with new bytecode.
x/evm/embeds/gen-abi/main.go Introduced a skip list mechanism and the helper function inSkipList to filter out specified files during ABI generation.
x/evm/embeds/package.json Updated package version from "0.0.2" to "0.0.3".

Sequence Diagram(s)

sequenceDiagram
    participant FS as File System
    participant GA as Gen-ABI Script
    participant SK as SkipList Checker

    FS->>GA: Traverse file (filename)
    GA->>SK: Check if filename exists in skipList
    alt File in skip list
        SK-->>GA: Yes, skip file
        GA->>FS: Continue to next file
    else File not in skip list
        SK-->>GA: No, process file
        GA->>GA: Generate ABI from file
    end
Loading

Poem

I'm a bunny hopping through the code,
Leaping o'er files on a merry new road,
With skip lists to guide my curious feet,
And type-safe contracts making each beat sweet,
I nibble on changes with a joyful glow,
Celebrating each commit as I hop to and fro!
🐇✨ Happy coding in our tech burrow!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b4e8c0 and f792ba2.

📒 Files selected for processing (45)
  • CHANGELOG.md (1 hunks)
  • contrib/make/simulation.mk (1 hunks)
  • evm-core-ts/.gitignore (1 hunks)
  • evm-core-ts/README.md (1 hunks)
  • evm-core-ts/justfile (1 hunks)
  • evm-core-ts/package.json (1 hunks)
  • evm-core-ts/prettier.config.js (1 hunks)
  • evm-core-ts/src/ethers/index.ts (1 hunks)
  • evm-core-ts/src/ethers/typechain/ChainLinkAggregatorV3Interface.ts (1 hunks)
  • evm-core-ts/src/ethers/typechain/ERC20Minter.ts (1 hunks)
  • evm-core-ts/src/ethers/typechain/IFunToken.ts (1 hunks)
  • evm-core-ts/src/ethers/typechain/INibiruEvm.ts (1 hunks)
  • evm-core-ts/src/ethers/typechain/IOracle.ts (1 hunks)
  • evm-core-ts/src/ethers/typechain/IWasm.ts (1 hunks)
  • evm-core-ts/src/ethers/typechain/NibiruOracleChainLinkLike.ts (1 hunks)
  • evm-core-ts/src/ethers/typechain/common.ts (1 hunks)
  • evm-core-ts/src/ethers/typechain/factories/ChainLinkAggregatorV3Interface__factory.ts (1 hunks)
  • evm-core-ts/src/ethers/typechain/factories/ERC20Minter__factory.ts (1 hunks)
  • evm-core-ts/src/ethers/typechain/factories/IFunToken__factory.ts (1 hunks)
  • evm-core-ts/src/ethers/typechain/factories/INibiruEvm__factory.ts (1 hunks)
  • evm-core-ts/src/ethers/typechain/factories/IOracle__factory.ts (1 hunks)
  • evm-core-ts/src/ethers/typechain/factories/IWasm__factory.ts (1 hunks)
  • evm-core-ts/src/ethers/typechain/factories/NibiruOracleChainLinkLike__factory.ts (1 hunks)
  • evm-core-ts/src/ethers/typechain/factories/index.ts (1 hunks)
  • evm-core-ts/src/ethers/typechain/index.ts (1 hunks)
  • evm-core-ts/src/precompile/funtoken.ts (1 hunks)
  • evm-core-ts/src/precompile/index.ts (1 hunks)
  • evm-core-ts/src/precompile/oracle.ts (1 hunks)
  • evm-core-ts/src/precompile/precompile.ts (1 hunks)
  • evm-core-ts/src/precompile/wasm.ts (1 hunks)
  • evm-core-ts/src/src.ts (1 hunks)
  • evm-core-ts/tsconfig.json (1 hunks)
  • x/evm/embeds/README.md (1 hunks)
  • x/evm/embeds/abi/ERC20.json (1 hunks)
  • x/evm/embeds/artifacts/contracts/MKR.sol/DSAuth.json (1 hunks)
  • x/evm/embeds/artifacts/contracts/MKR.sol/DSAuthEvents.json (1 hunks)
  • x/evm/embeds/artifacts/contracts/MKR.sol/DSMath.json (1 hunks)
  • x/evm/embeds/artifacts/contracts/MKR.sol/DSNote.json (1 hunks)
  • x/evm/embeds/artifacts/contracts/MKR.sol/DSStop.json (1 hunks)
  • x/evm/embeds/artifacts/contracts/MKR.sol/DSThing.json (1 hunks)
  • x/evm/embeds/artifacts/contracts/MKR.sol/DSToken.json (1 hunks)
  • x/evm/embeds/artifacts/contracts/MKR.sol/DSTokenBase.json (1 hunks)
  • x/evm/embeds/contracts/MKR.sol (15 hunks)
  • x/evm/embeds/gen-abi/main.go (2 hunks)
  • x/evm/embeds/package.json (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Unique-Divine Unique-Divine changed the title refactor: Move simapp -> app/simapp evm: Create ethers v6 adapters for Nibiru Feb 4, 2025
@Unique-Divine Unique-Divine marked this pull request as draft February 4, 2025 23:15
Copy link

codecov bot commented Feb 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.78%. Comparing base (2b4e8c0) to head (f792ba2).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2197   +/-   ##
=======================================
  Coverage   64.78%   64.78%           
=======================================
  Files         277      277           
  Lines       22281    22281           
=======================================
  Hits        14435    14435           
  Misses       6861     6861           
  Partials      985      985           

@Unique-Divine Unique-Divine changed the title evm: Create ethers v6 adapters for Nibiru feat(evm): Create ethers v6 adapters for Nibiru and publish TS library Feb 9, 2025
@Unique-Divine Unique-Divine marked this pull request as ready for review February 10, 2025 13:13
@Unique-Divine Unique-Divine merged commit af38373 into main Feb 10, 2025
17 of 18 checks passed
@Unique-Divine Unique-Divine deleted the ud/simapp-from-app branch February 10, 2025 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant