Skip to content

feat: add Nibiru mainet and testnet#748

Merged
kvhnuke merged 4 commits intoenkryptcom:feat/nibiru-networkfrom
ruslan-sh-r:feat/add-nibiru-network
Sep 10, 2025
Merged

feat: add Nibiru mainet and testnet#748
kvhnuke merged 4 commits intoenkryptcom:feat/nibiru-networkfrom
ruslan-sh-r:feat/add-nibiru-network

Conversation

@ruslan-sh-r
Copy link
Contributor

@ruslan-sh-r ruslan-sh-r commented Sep 8, 2025

Summary by CodeRabbit

  • New Features

    • Added support for Nibiru and Nibiru Testnet networks.
    • Enabled transaction activity history for these networks via a new activity provider.
    • Integrated network details: RPC connectivity, block explorer links, icons, and token metadata.
    • Added price platform mapping for Nibiru where available.
  • Documentation

    • Updated the Supported Chains list to include Nibiru and Nibiru Testnet.

@coderabbitai
Copy link

coderabbitai bot commented Sep 8, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (3)
  • main
  • develop
  • devop/vite-migrate

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ruslan-sh-r ruslan-sh-r changed the base branch from main to develop September 8, 2025 13:48
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (18)
packages/extension/src/providers/ethereum/networks/nibiru-testnet.ts (1)

19-20: Confirm Routescan integration picks the testnet endpoint.
The Routescan API uses environment + chainId in its base URL (e.g., api.routescan.io/v2/network/testnet/evm/6911/…). Ensure the provider composes URLs accordingly from NetworkEndpoints. (routescan.io)

If helpful, I can add an assertion test for getAllActivity(address) on testnet to guard URL composition.

packages/extension/src/providers/ethereum/libs/activity-handlers/providers/routescan/configs.ts (1)

3-6: Type the map as Partial<Record<NetworkNames, string>> to catch key typos.
Avoids using plain string keys and improves DX.

Apply:

-import { NetworkNames } from '@enkryptcom/types';
+import { NetworkNames } from '@enkryptcom/types';

-const NetworkEndpoints: Record<string, string> = {
+const NetworkEndpoints: Partial<Record<NetworkNames, string>> = {
   [NetworkNames.Nibiru]: 'https://routescan.io/',
   [NetworkNames.NibiruTestnet]: 'https://testnet.routescan.io/',
 };

Additionally, if RoutescanActivity needs API hosts (api.routescan.io) and the network segment (“mainnet”/“testnet”), consider storing structured config (e.g., { env: 'mainnet'|'testnet' }) instead of full URLs to prevent brittle string parsing. (routescan.io)

packages/extension/src/providers/ethereum/networks/nibiru.ts (1)

19-21: Double-check CoinGecko platform mapping.
If CoinGecko hasn’t exposed a “nibiru” asset platform for contract mapping yet, token market lookups by contract may return empty.

Use the script in networks.ts comment to confirm “nibiru” exists in /asset_platforms; if not, temporarily omit coingeckoPlatform to avoid failed lookups.

packages/extension/src/providers/ethereum/libs/activity-handlers/providers/routescan/types.ts (1)

6-19: Deduplicate account refs and avoid any.
Model shared shape once and tighten types.

-export interface RoutescanTxType {
+type RSAccountRef = {
+  id: string;
+  isContract: boolean;
+  alias?: string;
+  dapp?: unknown;
+  owner?: string;
+  icon?: string;
+  iconUrls?: Record<string, string>;
+  tags?: string[];
+};
+
+export interface RoutescanTxType {
   chainId: string;
   blockNumber: number;
   txIndex: number;
   timestamp: string;
-  from: {
-    id: string;
-    isContract: boolean;
-  };
-  to: {
-    id: string;
-    isContract: boolean;
-    alias?: string;
-    dapp?: any;
-    owner?: string;
-    icon?: string;
-    iconUrls?: Record<string, string>;
-    tags?: string[];
-  };
+  from: RSAccountRef;
+  to: RSAccountRef;
packages/extension/src/providers/ethereum/libs/activity-handlers/providers/routescan/index.ts (14)

20-20: Limit mismatch: limit=30 but slice(0, 50)

Either request 50 or drop the slice. Your other patch sets limit=50; keep it consistent.

Also applies to: 45-45


53-53: Normalize activity.from as well, not just the input address

Downstream comparisons rely on consistent casing.

-  address = address.toLowerCase();
+  address = address.toLowerCase();

(Handled indirectly in the previous comment by lowercasing on comparison.)


14-18: Hex chainId handling is split; simplify by passing full hex and parsing once

You remove 0x before calling this function and then parse hex again. Prefer passing the original hex and parsing with parseInt(chainId, 16) directly, or pass decimal and skip parsing. Avoid double handling.

-  chainId: string,
+  chainIdHex: string,
 ...
-  const decimalChainId = parseInt(chainId, 16);
+  const decimalChainId = parseInt(chainIdHex.replace(/^0x/, ''), 16);

And call with (network as EvmNetwork).chainID.


1-12: External call basics: add retries with backoff for transient errors

Given extension environments and 3rd-party API, consider a light retry (e.g., 2 attempts, jitter) inside getAddressActivity.


14-46: Pagination/backfill

The API likely supports cursors/offsets. If users scroll activity, add pagination params and a way to request older pages.


58-85: Minor style: rename Promisespromises

Follow lowercase variable naming for values.


20-21: Encode address in URL

Although hex is URL-safe, encoding is cheap and safe.

(Handled in the earlier diff.)


21-21: Prefer 0x over 0x0 for empty data

0x0 is not a valid empty input.

(Handled in the earlier diff using tx.methodId ?? '0x'.)


20-21: Consider including sort or order if the API supports it

Ensure newest-first for consistent UX.


20-21: Security/abuse: rate limiting and cache

If users rapidly open Activity, cache the last response per address/network briefly (e.g., 15–30s) to avoid hammering the API.


20-21: Telemetry

Log endpoint errors (count, rate, status) via existing telemetry (if any) to spot provider issues.


20-21: Test coverage

Add a unit test for mapper: RoutescanTxType → EthereumRawInfo, esp. edge cases (no to, status=false, contract vs EOA).

I can scaffold a small test harness with fixtures from Routescan.


20-21: Docs

Document the API assumptions (OR vs AND on address filters, value units) near the mapper.


20-21: Type hint

If EthereumRawInfo allows, mark fields like contractAddress and to as possibly null to match reality.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1b2c545 and e38a7c4.

📒 Files selected for processing (9)
  • README.md (2 hunks)
  • packages/extension/src/providers/ethereum/libs/activity-handlers/index.ts (2 hunks)
  • packages/extension/src/providers/ethereum/libs/activity-handlers/providers/routescan/configs.ts (1 hunks)
  • packages/extension/src/providers/ethereum/libs/activity-handlers/providers/routescan/index.ts (1 hunks)
  • packages/extension/src/providers/ethereum/libs/activity-handlers/providers/routescan/types.ts (1 hunks)
  • packages/extension/src/providers/ethereum/networks/index.ts (2 hunks)
  • packages/extension/src/providers/ethereum/networks/nibiru-testnet.ts (1 hunks)
  • packages/extension/src/providers/ethereum/networks/nibiru.ts (1 hunks)
  • packages/types/src/networks.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
packages/extension/src/providers/ethereum/networks/nibiru.ts (2)
packages/extension/src/providers/ethereum/types/evm-network.ts (2)
  • EvmNetworkOptions (22-53)
  • EvmNetwork (55-286)
packages/extension/src/providers/ethereum/libs/activity-handlers/index.ts (1)
  • RoutescanActivity (17-17)
packages/extension/src/providers/ethereum/networks/nibiru-testnet.ts (2)
packages/extension/src/providers/ethereum/types/evm-network.ts (2)
  • EvmNetworkOptions (22-53)
  • EvmNetwork (55-286)
packages/extension/src/providers/ethereum/libs/activity-handlers/index.ts (1)
  • RoutescanActivity (17-17)
packages/extension/src/providers/ethereum/libs/activity-handlers/providers/routescan/index.ts (4)
packages/extension/src/providers/ethereum/libs/activity-handlers/providers/routescan/types.ts (1)
  • RoutescanTxType (1-32)
packages/extension/src/providers/ethereum/libs/activity-handlers/providers/routescan/configs.ts (1)
  • NetworkEndpoints (8-8)
packages/extension/src/providers/ethereum/types/evm-network.ts (1)
  • EvmNetwork (55-286)
packages/extension/src/providers/ethereum/libs/transaction/decoder.ts (1)
  • decodeTx (98-98)
🔇 Additional comments (10)
README.md (2)

122-123: Docs: Added Nibiru and Nibiru Testnet — LGTM.
Matches the new network modules in this PR.


231-231: Section footer duplication check — OK.
“back to top” footer is consistent with other sections.

packages/types/src/networks.ts (1)

115-116: NetworkNames: Nibiru enums — LGTM.
Names align with usage in networks/nibiru*.ts.

packages/extension/src/providers/ethereum/libs/activity-handlers/index.ts (1)

8-18: Expose RoutescanActivity — LGTM.
Naming and re-export pattern match downstream imports.

packages/extension/src/providers/ethereum/networks/index.ts (2)

81-83: Imports for nibiru and nibiruTestnet — LGTM.
No circular deps; paths align with existing structure.


172-174: Wiring networks into the map — LGTM.
Keys match filename conventions used elsewhere.

packages/extension/src/providers/ethereum/networks/nibiru-testnet.ts (1)

7-20: Config looks correct; chain ID and RPC verified.

packages/extension/src/providers/ethereum/networks/nibiru.ts (1)

7-22: Mainnet config verified — LGTM.

packages/extension/src/providers/ethereum/libs/activity-handlers/providers/routescan/index.ts (2)

14-47: Potential unit/format mismatches from Routescan fields

Confirm that value, gasLimit, gasUsed, and gasPrice are decimal strings in wei. If they’re hex or human units, numberToHex may double-convert or mis-scale.

Would you like me to adjust conversions after we confirm the API formats?


20-21: Confirm filter semantics on api/evm/all/transactions
Combining fromAddresses and toAddresses likely ANDs the filters—returning only self-transfers. If true, issue two calls (one with fromAddresses, one with toAddresses), merge and de-duplicate by txHash. If an OR-based addresses= parameter exists, prefer that.

Comment on lines 27 to 38
const rawTx: EthereumRawInfo = {
blockHash: tx.blockHash,
blockNumber: numberToHex(tx.blockNumber),
contractAddress: tx.to?.isContract ? tx.to.id : '',
data: '0x0',
effectiveGasPrice: numberToHex(tx.gasPrice),
from: tx.from.id,
to: tx.to?.id === '' ? null : tx.to?.id,
gas: numberToHex(tx.gasLimit),
gasUsed: numberToHex(tx.gasUsed),
nonce: numberToHex(tx.txIndex),
status: tx.status,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix nonce mapping (txIndex ≠ nonce) and nullability for to/contractAddress/data

  • txIndex is transaction index in block, not the sender nonce.
  • Prefer null over empty string for absent fields.
  • Provide best-effort data (use methodId or 0x), not 0x0.

See patch in the previous comment (lines 21–46).

🤖 Prompt for AI Agents
In
packages/extension/src/providers/ethereum/libs/activity-handlers/providers/routescan/index.ts
around lines 27 to 38, the rawTx construction incorrectly maps nonce to
tx.txIndex and uses empty-string/placeholder values; change nonce to use the
actual sender nonce (tx.nonce), make contractAddress and to nullable (use null
when absent instead of ''), and set data to a best-effort value (prefer
tx.methodId if present, otherwise '0x') rather than '0x0'; ensure fields keep
correct types (nullable strings or hex strings) when you update these mappings.

@ruslan-sh-r ruslan-sh-r marked this pull request as draft September 8, 2025 14:03
@ruslan-sh-r ruslan-sh-r marked this pull request as ready for review September 8, 2025 14:24
@kvhnuke kvhnuke changed the base branch from develop to feat/nibiru-network September 10, 2025 20:27
@kvhnuke kvhnuke merged commit fb5c184 into enkryptcom:feat/nibiru-network Sep 10, 2025
2 checks passed
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.

2 participants