Update Blockscout URLs to new etc.blockscout.com interface#36
Update Blockscout URLs to new etc.blockscout.com interface#36nishantxscooby wants to merge 2 commits intoDjedAlliance:mainfrom
Conversation
📝 WalkthroughWalkthroughThis PR removes the web3 dependency from stablepay-sdk and migrates to a viem-based provider/signer model. Additionally, it updates Ethereum Classic Mordor testnet explorer URLs to the new Blockscout domain structure and refines wallet-related error messages for clarity. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
stablepay-sdk/src/core/Wallet.js (1)
1-38: Potential build/runtime failure: missing imports forcreateWalletClient,custom,mainnet,sepolia.
Given the file starts atexport class Wallet(Line 1) but uses those identifiers (Line 17-19, 33-34), this will throw unless imports exist elsewhere. Please add/restore the needed imports (and ensure they match yourviemversion).Proposed fix (if imports are truly missing)
+import { createWalletClient, custom } from 'viem'; +import { mainnet, sepolia } from 'viem/chains'; + export class Wallet { constructor(chainId) { this.chainId = chainId; this.client = null; this.account = null; }stablepay-sdk/rollup.config.mjs (1)
17-31: UMD build will fail at runtime: viem and viem/chains do not provide UMD globals.Viem only publishes ESM and CommonJS builds—no UMD distribution with
window.viemorwindow.viemChainsglobals. The current config externalizes them (Line 31) and maps them to globals (Lines 24–25), but those globals won't exist at runtime for UMD consumers.Either bundle viem into the UMD output (keep external only for ESM/CJS builds) or remove UMD support if only ESM/CJS are needed.
stablepay-sdk/src/core/Transaction.js (1)
14-35: Fix critical API mismatch: djed-sdk returns Web3.js contracts (.address), not ethers v6 (.target).The code has broken assumptions about djed-sdk's return types:
- Line 16:
getWeb3()returns a Web3.js instance, not{provider, signer}. This destructuring will fail at runtime.- Lines 21–22:
getDjedContract()andgetCoinContracts()expect a Web3.js instance, not a signer.- Lines 31, 34, 48–49: Web3.js contracts use
.address, not.target(ethers v6). Accessing.targetreturnsundefined.djed-sdk uses Web3.js, which provides:
getWeb3()→ Web3 instance- Contract instances with
.addresspropertyReplace the destructuring and use the Web3 instance directly:
Corrected init() flow
- const { provider, signer } = await getWeb3(this.networkUri); - this.provider = provider; - this.signer = signer; - this.djedContract = getDjedContract(this.signer, this.djedAddress); - const { stableCoin, reserveCoin } = await getCoinContracts(this.djedContract, this.signer); + const web3 = await getWeb3(this.networkUri); + this.web3 = web3; + this.djedContract = getDjedContract(this.web3, this.djedAddress); + const { stableCoin, reserveCoin } = await getCoinContracts(this.djedContract, this.web3); - this.oracleAddress = this.oracleContract.target; + this.oracleAddress = this.oracleContract.address; - stableCoinAddress: this.stableCoin ? this.stableCoin.target : 'N/A', - reserveCoinAddress: this.reserveCoin ? this.reserveCoin.target : 'N/A', + stableCoinAddress: this.stableCoin ? this.stableCoin.address : 'N/A', + reserveCoinAddress: this.reserveCoin ? this.reserveCoin.address : 'N/A', - getOracleContract(this.signer, addr, this.djedContract.target) + getOracleContract(this.web3, addr, this.djedContract.address)
🤖 Fix all issues with AI agents
In @stablepay-sdk/src/contexts/chains.js:
- Around line 18-20: Replace the incorrect BlockScout Mordor base URL
"https://etc.blockscout.com/mordor" with the correct hyphenated domain
"https://etc-mordor.blockscout.com" wherever it’s used: update the
blockExplorers.default entry in the blockExplorers object inside chains.js,
update the hardcoded explorer URL in TransactionReview.jsx (ethereum-classic
transaction/address links) to use the patterns
https://etc-mordor.blockscout.com/tx/<hash> and
https://etc-mordor.blockscout.com/address/<address>, and update the
blockExplorerUrls array passed in the wallet_addEthereumChain params in
WalletContext.jsx to include "https://etc-mordor.blockscout.com".
🧹 Nitpick comments (3)
stablepay-sdk/package.json (1)
14-19: Consider movingreact/react-domtopeerDependenciesto avoid duplicate React copies in consuming apps.
Right now they’re hard dependencies (Line 16-17), which commonly causes “Invalid hook call” / duplicate React issues in SDK-style packages.stablepay-sdk/src/core/Transaction.js (1)
36-92: Avoid unconditionalconsole.log/console.errorin a library.
These will spam consuming apps (Line 36, 38, 79, 87, 90). Prefer a passed-in logger, debug flag, or no logs by default.stablepay-sdk/src/widget/TransactionReview.jsx (1)
259-278: Consider the implications of the hardcoded Mordor fallback.The fallback URL
https://etc.blockscout.com/mordor/tx/${txHash}on line 263 will direct users to the Mordor explorer even if they're on a different network whengetExplorerUrl()returns null. While this may be intentional if Mordor is the default network, it could confuse users who submit transactions on other networks that aren't in theexplorerBaseUrlsmap.Consider either:
- Removing the fallback and displaying the hash without a link when the network isn't supported, or
- Adding a comment explaining that Mordor is the default/primary network for this application.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
stablepay-sdk/package.jsonstablepay-sdk/rollup.config.mjsstablepay-sdk/src/contexts/WalletContext.jsxstablepay-sdk/src/contexts/chains.jsstablepay-sdk/src/core/Transaction.jsstablepay-sdk/src/core/Wallet.jsstablepay-sdk/src/widget/TransactionReview.jsx
🔇 Additional comments (4)
stablepay-sdk/src/core/Transaction.js (1)
43-55: Public API change:getBlockchainDetails()keys/semantics changed—ensure versioning + consumers updated.
providerAvailable/signerAvailableand the address fields (Line 45-54) will break callers expecting the old shape. Consider a minor/major bump (or keep backward-compatible keys temporarily).stablepay-sdk/src/contexts/WalletContext.jsx (2)
28-28: LGTM: Improved error message clarity.The updated error message is more user-friendly and provides clear guidance to users who don't have a wallet installed.
56-71: LGTM: Blockscout URL correctly updated.The block explorer URL has been properly updated to the new Blockscout interface format. The base URL without a trailing slash is appropriate for the
blockExplorerUrlsparameter inwallet_addEthereumChain.stablepay-sdk/src/widget/TransactionReview.jsx (1)
186-198: Consider renaming the network identifier for clarity and consistency.The network key
"ethereum-classic"inTransactionReview.jsx(line 190) maps to the Mordor testnet explorer. Whileconfig.jsincludes a clarifying comment (//Mordor Testnet details), this naming is inconsistent withchains.js, which defines the same network as'mordor'withtestnet: true. To improve clarity and avoid confusion if ETC mainnet is added in the future, align the identifier across the codebase—either rename to"mordor"or"ethereum-classic-mordor"to explicitly indicate the testnet.
| blockExplorers: { | ||
| default: { name: 'BlockScout', url: 'https://blockscout.com/etc/mordor' }, | ||
| default: { name: 'BlockScout', url: 'https://etc.blockscout.com/mordor' }, | ||
| }, |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# Find all files that reference blockExplorers or the explorer URL
find stablepay-sdk -type f -name "*.js" -o -name "*.jsx" | head -20Repository: DjedAlliance/StablePay
Length of output: 807
🏁 Script executed:
# Search for usage of blockExplorers configuration
rg "blockExplorers" stablepay-sdk --type js --type jsx -A 3 -B 3Repository: DjedAlliance/StablePay
Length of output: 93
🏁 Script executed:
# Search for URL construction patterns with /tx/ or /address/
rg "(\/tx\/|\/address\/)" stablepay-sdk --type js --type jsx -B 2 -A 2Repository: DjedAlliance/StablePay
Length of output: 153
🏁 Script executed:
# Search for BlockScout, Blockscout, or explorer URL patterns
rg "(BlockScout|blockscout|explorer.*url)" stablepay-sdk --type js --type jsx -i -B 2 -A 2Repository: DjedAlliance/StablePay
Length of output: 93
🌐 Web query:
Blockscout Mordor testnet URL patterns for transactions and addresses
💡 Result:
Base explorer URLs
Common URL patterns
- Transaction: /tx/<transaction_hash>
Example: https://etc-mordor.blockscout.com/tx/0x0123...abcd. [3] - Address: /address/
Example: https://etc-mordor.blockscout.com/address/0x0123...abcd. [3]
Sources: [etc-mordor.blockscout.com, Blockscout docs].
References: [1] https://etc-mordor.blockscout.com, [2] https://blockscout.com/etc/mordor, [3] Blockscout linking docs (routes like /tx/ and /address/).
🏁 Script executed:
# Search for blockExplorers usage without jsx type specification
rg "blockExplorers" stablepay-sdk --type js -A 5 -B 2Repository: DjedAlliance/StablePay
Length of output: 35560
🏁 Script executed:
# Search for explorer URL construction patterns
rg "explorerUrl|explorer.*url|blockExplorer" stablepay-sdk --type js -i -A 3 -B 1Repository: DjedAlliance/StablePay
Length of output: 37440
🏁 Script executed:
# Check the chains.js file to see the full context
cat -n stablepay-sdk/src/contexts/chains.js | head -50Repository: DjedAlliance/StablePay
Length of output: 719
🏁 Script executed:
# Search for how URLs are constructed with tx or address patterns
rg "tx|address" stablepay-sdk/src/contexts/WalletContext.jsx -i -A 2 -B 2Repository: DjedAlliance/StablePay
Length of output: 649
Fix incorrect Blockscout Mordor base URL format across multiple files.
The base URL is using the wrong domain format. Change from https://etc.blockscout.com/mordor to https://etc-mordor.blockscout.com in:
stablepay-sdk/src/contexts/chains.jsline 19stablepay-sdk/src/widget/TransactionReview.jsx(hardcoded explorer URL for ethereum-classic)stablepay-sdk/src/contexts/WalletContext.jsx(blockExplorerUrls in wallet_addEthereumChain params)
The correct URL patterns for Blockscout Mordor are:
- Transaction:
https://etc-mordor.blockscout.com/tx/<hash> - Address:
https://etc-mordor.blockscout.com/address/<address>
All current explorer links will fail with the hyphenated domain missing.
🤖 Prompt for AI Agents
In @stablepay-sdk/src/contexts/chains.js around lines 18 - 20, Replace the
incorrect BlockScout Mordor base URL "https://etc.blockscout.com/mordor" with
the correct hyphenated domain "https://etc-mordor.blockscout.com" wherever it’s
used: update the blockExplorers.default entry in the blockExplorers object
inside chains.js, update the hardcoded explorer URL in TransactionReview.jsx
(ethereum-classic transaction/address links) to use the patterns
https://etc-mordor.blockscout.com/tx/<hash> and
https://etc-mordor.blockscout.com/address/<address>, and update the
blockExplorerUrls array passed in the wallet_addEthereumChain params in
WalletContext.jsx to include "https://etc-mordor.blockscout.com".
This PR updates all StablePay SDK Blockscout explorer links to use the new
etc.blockscout.com interface as recommended by the ETC community.
Changes:
responsible for transaction explorer redirection.
Fixes #19
Summary by CodeRabbit
Bug Fixes
Chores
✏️ Tip: You can customize this high-level summary in your review settings.