Skip to content

Commit

Permalink
feat(evm-core-ts): improve compatibility with older "moduleResolution…
Browse files Browse the repository at this point in the history
…" settings (#2229)

* feat(evm-core-ts): Improve compatibility with older "moduleResolution" settings. It is recommended to use "bundler".

* chore: changelog
  • Loading branch information
Unique-Divine authored Mar 10, 2025
1 parent 22354ca commit 8ddfa5e
Show file tree
Hide file tree
Showing 21 changed files with 114 additions and 62 deletions.
1 change: 1 addition & 0 deletions evm-core-ts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ the `@nibiruchain/evm-core` package on `npm`.

## [0.0.x]

- v0.0.4: [#2229](https://github.com/NibiruChain/nibiru/pull/2229) - Improve compatibility with older "moduleResolution" settings. It is recommended to use "bundler".
- v0.0.2: [#2204](https://github.com/NibiruChain/nibiru/pull/2204) - Add ERC20
caller to the "ethers" export.
- v0.0.1: [#2197](https://github.com/NibiruChain/nibiru/pull/2197) - Export
Expand Down
23 changes: 17 additions & 6 deletions evm-core-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
{
"name": "@nibiruchain/evm-core",
"description": "Lightweight Nibiru EVM TypeScript library for type-safe interactions with precompiled contracts, essential constants, and other core utilites.",
"version": "0.0.3",
"version": "0.0.4",
"private": false,
"include": ["src"],
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"include": [
"src",
"dist"
],
"scripts": {
"build": "rm -rf dist && bun run tsc --project tsconfig.json --outDir dist"
},
Expand All @@ -12,6 +18,7 @@
],
"dependencies": {},
"devDependencies": {
"@ianvs/prettier-plugin-sort-imports": "^4.4.1",
"@nibiruchain/solidity": "^0.0.2",
"@typechain/ethers-v6": "^0.5.1",
"@types/bun": "latest",
Expand All @@ -23,13 +30,17 @@
"typescript": "^5.0.0"
},
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.js",
"default": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./ethers": {
"import": "./dist/ethers/index.js",
"require": "./dist/ethers/index.js",
"default": "./dist/ethers/index.js",
"types": "./dist/ethers/index.d.ts"
},
".": {
"import": "./dist/src.js",
"types": "./dist/src.d.ts"
}
}
}
24 changes: 24 additions & 0 deletions evm-core-ts/prettier.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,30 @@ const config = {
semi: false,
singleQuote: false,
arrowParens: "always",

plugins: ["@ianvs/prettier-plugin-sort-imports"],
/** Using the "@ianvs/prettier-plugin-sort-imports" plugin, the `importOrder` field
* controls the order in which imports are sorted.
*
* 1. "<BUILT_IN_MODULES>" - Built-in Node.js modules like "fs", "path", and
* "http" that don't require an npm installation.
*
* 2. "<THIRD_PARTY_MODULES>" - Module like "react", "lodash", or "bun"
*
* 3. "^@/(.*)$" - For paths beginning with "@"
* 4. "^~/(.*)$" - For paths beginning with "~"
* 5. "^[.]" - Relative imports like "./file" or "../state/utils".
* */
importOrder: [
"<BUILT_IN_MODULES>",
"<THIRD_PARTY_MODULES>",
"", // creates a blank line in the import block
"^@/(.*)$",
"^~/(.*)$",
"", // creates a blank line in the import block
"^[.]",
],

}

export default config
32 changes: 16 additions & 16 deletions evm-core-ts/src/ethers/index.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import { type ContractRunner, Contract, type InterfaceAbi } from "ethers"
import { Contract, type ContractRunner, type InterfaceAbi } from "ethers"

import {
ADDR_WASM_PRECOMPILE,
ADDR_ORACLE_PRECOMPILE,
ADDR_FUNTOKEN_PRECOMPILE,
ABI_WASM_PRECOMPILE,
ABI_ORACLE_PRECOMPILE,
ABI_FUNTOKEN_PRECOMPILE,
ABI_ORACLE_PRECOMPILE,
ABI_WASM_PRECOMPILE,
ADDR_FUNTOKEN_PRECOMPILE,
ADDR_ORACLE_PRECOMPILE,
ADDR_WASM_PRECOMPILE,
} from "../precompile"
import {
ERC20Minter__factory,
NibiruOracleChainLinkLike__factory,
type ERC20Minter,
type IFunToken,
type IOracle,
type IWasm,
type NibiruOracleChainLinkLike,
} from "./typechain"

export const ETHERS_ABI = {
WASM: ABI_WASM_PRECOMPILE as InterfaceAbi,
ORACLE: ABI_ORACLE_PRECOMPILE as InterfaceAbi,
FUNTOKEN: ABI_FUNTOKEN_PRECOMPILE as InterfaceAbi,
}

import {
type IWasm,
type IOracle,
type IFunToken,
type NibiruOracleChainLinkLike,
type ERC20Minter,
NibiruOracleChainLinkLike__factory,
ERC20Minter__factory,
} from "./typechain"

export const wasmPrecompile = (runner: ContractRunner): IWasm =>
new Contract(
ADDR_WASM_PRECOMPILE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@ import type {
BaseContract,
BigNumberish,
BytesLike,
ContractMethod,
ContractRunner,
FunctionFragment,
Result,
Interface,
ContractRunner,
ContractMethod,
Listener,
Result,
} from "ethers"

import type {
TypedContractEvent,
TypedContractMethod,
TypedDeferredTopicFilter,
TypedEventLog,
TypedListener,
TypedContractMethod,
} from "./common"

export interface ChainLinkAggregatorV3InterfaceInterface extends Interface {
Expand Down
15 changes: 8 additions & 7 deletions evm-core-ts/src/ethers/typechain/ERC20Minter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@
/* tslint:disable */
/* eslint-disable */
import type {
AddressLike,
BaseContract,
BigNumberish,
BytesLike,
ContractMethod,
ContractRunner,
EventFragment,
FunctionFragment,
Result,
Interface,
EventFragment,
AddressLike,
ContractRunner,
ContractMethod,
Listener,
Result,
} from "ethers"

import type {
TypedContractEvent,
TypedContractMethod,
TypedDeferredTopicFilter,
TypedEventLog,
TypedLogDescription,
TypedListener,
TypedContractMethod,
TypedLogDescription,
} from "./common"

export interface ERC20MinterInterface extends Interface {
Expand Down
15 changes: 8 additions & 7 deletions evm-core-ts/src/ethers/typechain/IFunToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@
/* tslint:disable */
/* eslint-disable */
import type {
AddressLike,
BaseContract,
BigNumberish,
BytesLike,
ContractMethod,
ContractRunner,
EventFragment,
FunctionFragment,
Result,
Interface,
EventFragment,
AddressLike,
ContractRunner,
ContractMethod,
Listener,
Result,
} from "ethers"

import type {
TypedContractEvent,
TypedContractMethod,
TypedDeferredTopicFilter,
TypedEventLog,
TypedLogDescription,
TypedListener,
TypedContractMethod,
TypedLogDescription,
} from "./common"

export declare namespace IFunToken {
Expand Down
9 changes: 5 additions & 4 deletions evm-core-ts/src/ethers/typechain/INibiruEvm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
/* eslint-disable */
import type {
BaseContract,
ContractMethod,
ContractRunner,
EventFragment,
FunctionFragment,
Interface,
EventFragment,
ContractRunner,
ContractMethod,
Listener,
} from "ethers"

import type {
TypedContractEvent,
TypedDeferredTopicFilter,
TypedEventLog,
TypedLogDescription,
TypedListener,
TypedLogDescription,
} from "./common"

export interface INibiruEvmInterface extends Interface {
Expand Down
9 changes: 5 additions & 4 deletions evm-core-ts/src/ethers/typechain/IOracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@
import type {
BaseContract,
BytesLike,
ContractMethod,
ContractRunner,
FunctionFragment,
Result,
Interface,
ContractRunner,
ContractMethod,
Listener,
Result,
} from "ethers"

import type {
TypedContractEvent,
TypedContractMethod,
TypedDeferredTopicFilter,
TypedEventLog,
TypedListener,
TypedContractMethod,
} from "./common"

export interface IOracleInterface extends Interface {
Expand Down
13 changes: 7 additions & 6 deletions evm-core-ts/src/ethers/typechain/IWasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@ import type {
BaseContract,
BigNumberish,
BytesLike,
ContractMethod,
ContractRunner,
EventFragment,
FunctionFragment,
Result,
Interface,
EventFragment,
ContractRunner,
ContractMethod,
Listener,
Result,
} from "ethers"

import type {
TypedContractEvent,
TypedContractMethod,
TypedDeferredTopicFilter,
TypedEventLog,
TypedLogDescription,
TypedListener,
TypedContractMethod,
TypedLogDescription,
} from "./common"

export declare namespace INibiruEvm {
Expand Down
9 changes: 5 additions & 4 deletions evm-core-ts/src/ethers/typechain/NibiruOracleChainLinkLike.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@ import type {
BaseContract,
BigNumberish,
BytesLike,
ContractMethod,
ContractRunner,
FunctionFragment,
Result,
Interface,
ContractRunner,
ContractMethod,
Listener,
Result,
} from "ethers"

import type {
TypedContractEvent,
TypedContractMethod,
TypedDeferredTopicFilter,
TypedEventLog,
TypedListener,
TypedContractMethod,
} from "./common"

export interface NibiruOracleChainLinkLikeInterface extends Interface {
Expand Down
8 changes: 4 additions & 4 deletions evm-core-ts/src/ethers/typechain/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
/* tslint:disable */
/* eslint-disable */
import type {
FunctionFragment,
Typed,
EventFragment,
ContractTransaction,
ContractTransactionResponse,
DeferredTopicFilter,
EventFragment,
EventLog,
TransactionRequest,
FunctionFragment,
LogDescription,
TransactionRequest,
Typed,
} from "ethers"

export interface TypedDeferredTopicFilter<_TCEvent extends TypedContractEvent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* eslint-disable */

import { Contract, Interface, type ContractRunner } from "ethers"

import type {
ChainLinkAggregatorV3Interface,
ChainLinkAggregatorV3InterfaceInterface,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* eslint-disable */

import { Contract, Interface, type ContractRunner } from "ethers"

import type { ERC20Minter, ERC20MinterInterface } from "../ERC20Minter"

const _abi = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* eslint-disable */

import { Contract, Interface, type ContractRunner } from "ethers"

import type { IFunToken, IFunTokenInterface } from "../IFunToken"

const _abi = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* eslint-disable */

import { Contract, Interface, type ContractRunner } from "ethers"

import type { INibiruEvm, INibiruEvmInterface } from "../INibiruEvm"

const _abi = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* eslint-disable */

import { Contract, Interface, type ContractRunner } from "ethers"

import type { IOracle, IOracleInterface } from "../IOracle"

const _abi = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* eslint-disable */

import { Contract, Interface, type ContractRunner } from "ethers"

import type { IWasm, IWasmInterface } from "../IWasm"

const _abi = [
Expand Down
Loading

0 comments on commit 8ddfa5e

Please sign in to comment.