feat: add Nibiru mainet and testnet#748
feat: add Nibiru mainet and testnet#748kvhnuke merged 4 commits intoenkryptcom:feat/nibiru-networkfrom
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (3)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
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. Comment |
There was a problem hiding this comment.
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 avoidany.
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: Normalizeactivity.fromas well, not just the inputaddressDownstream 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 onceYou remove
0xbefore calling this function and then parse hex again. Prefer passing the original hex and parsing withparseInt(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 errorsGiven extension environments and 3rd-party API, consider a light retry (e.g., 2 attempts, jitter) inside
getAddressActivity.
14-46: Pagination/backfillThe API likely supports cursors/offsets. If users scroll activity, add pagination params and a way to request older pages.
58-85: Minor style: renamePromises→promisesFollow lowercase variable naming for values.
20-21: Encode address in URLAlthough hex is URL-safe, encoding is cheap and safe.
(Handled in the earlier diff.)
21-21: Prefer0xover0x0for empty data
0x0is not a valid empty input.(Handled in the earlier diff using
tx.methodId ?? '0x'.)
20-21: Consider includingsortororderif the API supports itEnsure newest-first for consistent UX.
20-21: Security/abuse: rate limiting and cacheIf users rapidly open Activity, cache the last response per address/network briefly (e.g., 15–30s) to avoid hammering the API.
20-21: TelemetryLog endpoint errors (count, rate, status) via existing telemetry (if any) to spot provider issues.
20-21: Test coverageAdd 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: DocsDocument the API assumptions (OR vs AND on address filters, value units) near the mapper.
20-21: Type hintIf
EthereumRawInfoallows, mark fields likecontractAddressandtoas possibly null to match reality.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 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.
- Chain ID 0x1AFF (6911) and RPC https://evm-rpc.testnet-2.nibiru.fi are the official testnet values; explorers match docs. (nibiru.fi)
packages/extension/src/providers/ethereum/networks/nibiru.ts (1)
7-22: Mainnet config verified — LGTM.
- Chain ID 0x1AF4 (6900), RPC https://evm-rpc.nibiru.fi, and explorers are per official docs. (nibiru.fi)
- coingeckoID 'nibiru' matches CoinGecko’s asset ID. (coingecko.com)
packages/extension/src/providers/ethereum/libs/activity-handlers/providers/routescan/index.ts (2)
14-47: Potential unit/format mismatches from Routescan fieldsConfirm that
value,gasLimit,gasUsed, andgasPriceare decimal strings in wei. If they’re hex or human units,numberToHexmay double-convert or mis-scale.Would you like me to adjust conversions after we confirm the API formats?
20-21: Confirm filter semantics onapi/evm/all/transactions
CombiningfromAddressesandtoAddresseslikely ANDs the filters—returning only self-transfers. If true, issue two calls (one withfromAddresses, one withtoAddresses), merge and de-duplicate bytxHash. If an OR-basedaddresses=parameter exists, prefer that.
packages/extension/src/providers/ethereum/libs/activity-handlers/providers/routescan/index.ts
Outdated
Show resolved
Hide resolved
| 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, |
There was a problem hiding this comment.
Fix nonce mapping (txIndex ≠ nonce) and nullability for to/contractAddress/data
txIndexis transaction index in block, not the sender nonce.- Prefer
nullover empty string for absent fields. - Provide best-effort
data(usemethodIdor0x), not0x0.
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.
Summary by CodeRabbit
New Features
Documentation