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
2 changes: 1 addition & 1 deletion 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
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;
Comment on lines 30 to +34
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

🌐 Web query:

ethers.js v6 .target property contract address

💡 Result:

In ethers v6 the Contract/BaseContract address field was renamed from .address to .target. .target can be an address/ENS name/Addressable; to get the resolved address use getAddress(). See the docs and migration notes. [1][2]

Example:

  • Reading the raw target (may be ENS or addressable):
    const addrOrName = myContract.target;
  • Getting the resolved address:
    const address = await myContract.getAddress();

Sources: [1] ethers v6 docs (BaseContract.target / getAddress). [2] v5→v6 migration notes (renamed address → target).


🏁 Script executed:

find . -name "package.json" -type f | head -20

Repository: DjedAlliance/StablePay

Length of output: 118


🏁 Script executed:

cat -n package.json

Repository: DjedAlliance/StablePay

Length of output: 110


🏁 Script executed:

cat -n ./djed-sdk/package.json

Repository: DjedAlliance/StablePay

Length of output: 762


🏁 Script executed:

cat -n ./stablepay-sdk/package.json

Repository: DjedAlliance/StablePay

Length of output: 1298


🏁 Script executed:

grep -A 10 -B 2 "this.oracleContract\|this.djedContract" stablepay-sdk/src/core/Transaction.js | head -40

Repository: DjedAlliance/StablePay

Length of output: 1578


🏁 Script executed:

find . -name "package-lock.json" -o -name "yarn.lock" | head -5

Repository: DjedAlliance/StablePay

Length of output: 128


🏁 Script executed:

grep -r "from.*['\"]ethers['\"]" djed-sdk/src --include="*.js" --include="*.ts" | head -20

Repository: DjedAlliance/StablePay

Length of output: 48


🏁 Script executed:

grep -r "require.*ethers" djed-sdk/src --include="*.js" --include="*.ts" | head -20

Repository: DjedAlliance/StablePay

Length of output: 48


🏁 Script executed:

grep -A 5 '"ethers"' djed-sdk/package-lock.json | head -20

Repository: DjedAlliance/StablePay

Length of output: 48


🏁 Script executed:

grep -A 5 '"ethers"' stablepay-sdk/package-lock.json | head -20

Repository: DjedAlliance/StablePay

Length of output: 48


🏁 Script executed:

head -50 stablepay-sdk/src/core/Transaction.js

Repository: DjedAlliance/StablePay

Length of output: 1964


🏁 Script executed:

find ./djed-sdk/src -type f -name "*.js" -o -name "*.ts" | head -10

Repository: DjedAlliance/StablePay

Length of output: 364


🏁 Script executed:

rg "getDjedContract|getOracleContract" djed-sdk/src --type js --type ts -A 10 | head -60

Repository: DjedAlliance/StablePay

Length of output: 1518


🌐 Web query:

web3.js contract address property how to access contract address web3.eth.Contract

💡 Result:

Use the contract instance's options.address property (stored lowercased). Example:

  • When creating:
    var myContract = new web3.eth.Contract(abi, '0xAbC...');

  • Read address:
    console.log(myContract.options.address); // '0xabc...'

  • Set or change address:
    myContract.options.address = '0x1234...';

(Note: older examples sometimes show contract._address, but the supported API is myContract.options.address.) [1][2]


🏁 Script executed:

head -20 djed-sdk/src/helpers.js

Repository: DjedAlliance/StablePay

Length of output: 622


🏁 Script executed:

cat -n stablepay-sdk/src/core/Transaction.js | sed -n '1,50p'

Repository: DjedAlliance/StablePay

Length of output: 2314


Replace .target with .options.address for web3.js contract instances.

The code uses .target to access contract addresses, but djed-sdk v1.0.2 bundles web3.js v1.7.3, not ethers.js v6. Web3.js contracts expose the address via the .options.address property, not .target. This affects:

  • Line 31: this.djedContract.target will be undefined, causing getOracleContract to receive invalid input
  • Line 34: this.oracleAddress = this.oracleContract.target will be undefined
  • Lines 48–49: this.stableCoin.target and this.reserveCoin.target will be undefined

Change all .target accesses to .options.address.

🤖 Prompt for AI Agents
In @stablepay-sdk/src/core/Transaction.js around lines 30 - 34, Replace all uses
of the ethers-style `.target` on web3.js contract instances with the web3.js
property `.options.address`; specifically update the call that passes
this.djedContract.target into getOracleContract to pass
this.djedContract.options.address, set this.oracleAddress =
this.oracleContract.options.address, and likewise change references
this.stableCoin.target and this.reserveCoin.target to
this.stableCoin.options.address and this.reserveCoin.options.address so valid
addresses are supplied.


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