Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions stablepay-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
"djed-sdk": "^1.0.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"viem": "^2.21.53",
"web3": "^1.7.3"
"viem": "^2.21.53"
},
"devDependencies": {
"@babel/preset-react": "^7.25.7",
Expand Down
3 changes: 1 addition & 2 deletions stablepay-sdk/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export default {
file: "dist/umd/index.js",
globals: {
"djed-sdk": "DjedSdk",
web3: "Web3",
react: "React",
"react-dom": "ReactDOM",
viem: "viem",
Expand All @@ -29,7 +28,7 @@ export default {
assetFileNames: "assets/[name][extname]",
},
],
external: ["djed-sdk", "web3", "react", "react-dom", "viem", "viem/chains"],
external: ["djed-sdk", "react", "react-dom", "viem", "viem/chains"],
plugins: [
resolve({
extensions: [".js", ".jsx"],
Expand Down
4 changes: 2 additions & 2 deletions stablepay-sdk/src/contexts/WalletContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const WalletProvider = ({ children }) => {

const connectWallet = useCallback(async () => {
if (!window.ethereum) {
setError('Please install MetaMask or another Web3 wallet');
setError('Please install MetaMask or another Ethereum wallet');
return false;
}

Expand Down Expand Up @@ -65,7 +65,7 @@ export const WalletProvider = ({ children }) => {
decimals: 18,
},
rpcUrls: ['https://rpc.mordor.etccooperative.org'],
blockExplorerUrls: ['https://etc-mordor.blockscout.com/'],
blockExplorerUrls: ['https://etc.blockscout.com/mordor'],
},
],
});
Expand Down
2 changes: 1 addition & 1 deletion stablepay-sdk/src/contexts/chains.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const mordor = defineChain({
},
},
blockExplorers: {
default: { name: 'BlockScout', url: 'https://blockscout.com/etc/mordor' },
default: { name: 'BlockScout', url: 'https://etc.blockscout.com/mordor' },
},
Comment on lines 18 to 20
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".

testnet: true,
});
22 changes: 14 additions & 8 deletions stablepay-sdk/src/core/Transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ export class Transaction {
}

try {
this.web3 = await getWeb3(this.networkUri);
this.djedContract = getDjedContract(this.web3, this.djedAddress);
const { stableCoin, reserveCoin } = await getCoinContracts(this.djedContract, this.web3);
// getWeb3 now returns {provider, signer}
const { provider, signer } = await getWeb3(this.networkUri);
this.provider = provider;
this.signer = signer;

// Use signer for contract interactions (allows write operations)
this.djedContract = getDjedContract(this.signer, this.djedAddress);
const { stableCoin, reserveCoin } = await getCoinContracts(this.djedContract, this.signer);
const { scDecimals, rcDecimals } = await getDecimals(stableCoin, reserveCoin);
this.stableCoin = stableCoin;
this.reserveCoin = reserveCoin;
Expand All @@ -23,10 +28,10 @@ export class Transaction {

// Get the oracle contract
this.oracleContract = await getOracleAddress(this.djedContract).then((addr) =>
getOracleContract(this.web3, addr, this.djedContract._address)
getOracleContract(this.signer, addr, this.djedContract.target)
);

this.oracleAddress = this.oracleContract._address;
this.oracleAddress = this.oracleContract.target;

console.log('Transaction initialized successfully');
} catch (error) {
Expand All @@ -37,10 +42,11 @@ export class Transaction {

getBlockchainDetails() {
return {
web3Available: !!this.web3,
providerAvailable: !!this.provider,
signerAvailable: !!this.signer,
djedContractAvailable: !!this.djedContract,
stableCoinAddress: this.stableCoin ? this.stableCoin._address : 'N/A',
reserveCoinAddress: this.reserveCoin ? this.reserveCoin._address : 'N/A',
stableCoinAddress: this.stableCoin ? this.stableCoin.target : 'N/A',
reserveCoinAddress: this.reserveCoin ? this.reserveCoin.target : 'N/A',
stableCoinDecimals: this.scDecimals,
reserveCoinDecimals: this.rcDecimals,
oracleAddress: this.oracleAddress || 'N/A',
Expand Down
2 changes: 1 addition & 1 deletion stablepay-sdk/src/core/Wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class Wallet {

async connect() {
if (!window.ethereum) {
throw new Error('No Web3 provider found');
throw new Error('No Ethereum provider found');
}

const accounts = await window.ethereum.request({
Expand Down
4 changes: 2 additions & 2 deletions stablepay-sdk/src/widget/TransactionReview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ const TransactionReview = ({ onTransactionComplete }) => {
if (!txHash || !selectedNetwork) return null;

const explorerBaseUrls = {
"ethereum-classic": "https://etc-mordor.blockscout.com/tx/",
"ethereum-classic": "https://etc.blockscout.com/mordor/tx/",
"sepolia": "https://sepolia.etherscan.io/tx/",
"milkomeda-mainnet": "https://explorer-mainnet-cardano-evm.c1.milkomeda.com/tx/",
};
Expand Down Expand Up @@ -260,7 +260,7 @@ const TransactionReview = ({ onTransactionComplete }) => {
<div className={styles.transactionLink}>
✅ Transaction Hash:{" "}
<a
href={`https://blockscout.com/etc/mordor/tx/${txHash}`}
href={getExplorerUrl() || `https://etc.blockscout.com/mordor/tx/${txHash}`}
target="_blank"
rel="noopener noreferrer"
className={styles.explorerLink}
Expand Down