Skip to content

Update Blockscout URLs to new etc.blockscout.com interface#36

Open
nishantxscooby wants to merge 2 commits intoDjedAlliance:mainfrom
nishantxscooby:fix-blockscout-url
Open

Update Blockscout URLs to new etc.blockscout.com interface#36
nishantxscooby wants to merge 2 commits intoDjedAlliance:mainfrom
nishantxscooby:fix-blockscout-url

Conversation

@nishantxscooby
Copy link

@nishantxscooby nishantxscooby commented Jan 9, 2026

This PR updates all StablePay SDK Blockscout explorer links to use the new
etc.blockscout.com interface as recommended by the ETC community.

Changes:

  • Updated stablepay-sdk/src/widget/TransactionReview.jsx as the primary file
    responsible for transaction explorer redirection.
  • Updated stablepay-sdk/src/contexts/chains.js network configuration.
  • Updated WalletContext blockExplorerUrls.
  • URLs are now dynamically constructed using the selected network.
  • SDK rebuilt via rollup without modifying any dist files directly.

Fixes #19

Summary by CodeRabbit

  • Bug Fixes

    • Updated error messages for clearer wallet connection guidance
    • Corrected Mordor testnet block explorer URL to the latest domain
  • Chores

    • Removed unused dependency to optimize build size and streamline package requirements

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 9, 2026

📝 Walkthrough

Walkthrough

This 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

Cohort / File(s) Summary
Dependency and Build Configuration
stablepay-sdk/package.json, stablepay-sdk/rollup.config.mjs
Removed web3 transitive dependency and corresponding UMD global mapping; viem remains as primary provider library.
Blockscout URL Migration
stablepay-sdk/src/contexts/chains.js, stablepay-sdk/src/contexts/WalletContext.jsx, stablepay-sdk/src/widget/TransactionReview.jsx
Updated Ethereum Classic Mordor testnet explorer URLs from blockscout.com/etc/mordor to new domain structure etc.blockscout.com/mordor across chain configuration and UI components.
Web3 to Provider/Signer Migration
stablepay-sdk/src/core/Transaction.js
Refactored to use signer/provider model instead of web3: added public properties provider and signer; updated contract instantiation to use signer; modified getBlockchainDetails() to return providerAvailable, signerAvailable, and oracleContractAvailable; changed contract address property access from ._address to .target.
Error Message Refinements
stablepay-sdk/src/contexts/WalletContext.jsx, stablepay-sdk/src/core/Wallet.js
Updated error messages to use "Ethereum wallet" terminology instead of "Web3 wallet" for improved clarity.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • Zahnentferner

Poem

🐰✨ A nibble at the old web3 feast,
Viem's provider hops in with ease,
Blockscout paths find their new home,
Signers and wallets now clearly shown,
The SDK's burrow grows cleaner, not least! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes out-of-scope changes: removal of web3 dependency from package.json and rollup config, and migration from Web3.js to Ethers.js in Transaction.js, which are unrelated to the Blockscout URL updates in issue #19. Separate the web3-to-viem/Ethers.js migration (issue #10) into a distinct PR from the Blockscout URL updates (issue #19) to keep changes focused and reviewable.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the primary change: updating Blockscout URLs to the new etc.blockscout.com interface, which aligns with the main modifications across multiple configuration files.
Linked Issues check ✅ Passed The PR successfully addresses issue #19 by replacing older blockscout.com/etc URLs with the new etc.blockscout.com interface across chains.js, WalletContext.jsx, and TransactionReview.jsx.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

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: 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 for createWalletClient, custom, mainnet, sepolia.
Given the file starts at export 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 your viem version).

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.viem or window.viemChains globals. 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:

  1. Line 16: getWeb3() returns a Web3.js instance, not {provider, signer}. This destructuring will fail at runtime.
  2. Lines 21–22: getDjedContract() and getCoinContracts() expect a Web3.js instance, not a signer.
  3. Lines 31, 34, 48–49: Web3.js contracts use .address, not .target (ethers v6). Accessing .target returns undefined.

djed-sdk uses Web3.js, which provides:

  • getWeb3() → Web3 instance
  • Contract instances with .address property

Replace 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 moving react / react-dom to peerDependencies to 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 unconditional console.log / console.error in 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 when getExplorerUrl() 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 the explorerBaseUrls map.

Consider either:

  1. Removing the fallback and displaying the hash without a link when the network isn't supported, or
  2. Adding a comment explaining that Mordor is the default/primary network for this application.
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2a125cf and e04f188.

📒 Files selected for processing (7)
  • stablepay-sdk/package.json
  • stablepay-sdk/rollup.config.mjs
  • stablepay-sdk/src/contexts/WalletContext.jsx
  • stablepay-sdk/src/contexts/chains.js
  • stablepay-sdk/src/core/Transaction.js
  • stablepay-sdk/src/core/Wallet.js
  • stablepay-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/signerAvailable and 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 blockExplorerUrls parameter in wallet_addEthereumChain.

stablepay-sdk/src/widget/TransactionReview.jsx (1)

186-198: Consider renaming the network identifier for clarity and consistency.

The network key "ethereum-classic" in TransactionReview.jsx (line 190) maps to the Mordor testnet explorer. While config.js includes a clarifying comment (//Mordor Testnet details), this naming is inconsistent with chains.js, which defines the same network as 'mordor' with testnet: 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.

Comment on lines 18 to 20
blockExplorers: {
default: { name: 'BlockScout', url: 'https://blockscout.com/etc/mordor' },
default: { name: 'BlockScout', url: 'https://etc.blockscout.com/mordor' },
},
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 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 -20

Repository: 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 3

Repository: 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 2

Repository: 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 2

Repository: DjedAlliance/StablePay

Length of output: 93


🌐 Web query:

Blockscout Mordor testnet URL patterns for transactions and addresses

💡 Result:

Base explorer URLs

Common URL patterns

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 2

Repository: 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 1

Repository: 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 -50

Repository: 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 2

Repository: 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.js line 19
  • stablepay-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".

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.

using older Blockscout URLs (blockscout.com/etc/...) instead of the newer etc.blockscout.com interface

1 participant