Skip to content

Update page.mdx #7342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Update page.mdx #7342

wants to merge 1 commit into from

Conversation

7bd0x
Copy link

@7bd0x 7bd0x commented Jun 15, 2025


PR-Codex overview

This PR introduces a new smart contract DarkMint for an ERC20 token, allowing users to buy tokens and enabling the contract owner to withdraw funds. It also integrates a TransakSDK script for cryptocurrency transactions.

Detailed summary

  • Removed imports and metadata related to Universal Bridge.
  • Added a new Solidity contract DarkMint inheriting from ERC20 and Ownable.
  • Implemented buyTokens function for purchasing tokens.
  • Included withdraw function for the contract owner to withdraw ETH.
  • Added a TransakSDK script for transaction integration.
  • Retained the DocImage component for displaying images.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features

    • Introduced a Solidity smart contract for purchasing ERC20 tokens using ETH, with owner withdrawal functionality.
    • Added a JavaScript snippet to integrate a fiat-to-crypto onramp widget and enable token purchases from the frontend.
  • Documentation

    • Replaced previous Universal Bridge product documentation with new smart contract and frontend integration examples.

Signed-off-by: 7bd0x <[email protected]>
@7bd0x 7bd0x requested review from a team as code owners June 15, 2025 10:36
Copy link

changeset-bot bot commented Jun 15, 2025

⚠️ No Changeset found

Latest commit: c1aac9c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

graphite-app bot commented Jun 15, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

Copy link

vercel bot commented Jun 15, 2025

@7bd0x is attempting to deploy a commit to the thirdweb Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Jun 15, 2025

Walkthrough

The content of the apps/portal/src/app/pay/page.mdx file was completely replaced. The original documentation and UI components were removed and substituted with a Solidity smart contract for an ERC20 token sale, along with frontend JavaScript for interacting with the contract and initializing a fiat-to-crypto onramp widget.

Changes

File(s) Change Summary
apps/portal/src/app/pay/page.mdx Replaced documentation and UI with a Solidity ERC20 token sale contract, frontend purchase logic, and Transak widget initialization.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Frontend (JS)
    participant SmartContract (DarkMint)
    participant Owner

    User->>Frontend (JS): Clicks "Buy Tokens"
    Frontend (JS)->>SmartContract (DarkMint): Calls buyTokens() with 0.01 ETH
    SmartContract (DarkMint)->>User: Transfers tokens if payment and balance checks pass
    Owner->>SmartContract (DarkMint): Calls withdraw()
    SmartContract (DarkMint)->>Owner: Transfers accumulated ETH
Loading

Suggested labels

Portal

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • TEAM-0000: Entity not found: Issue - Could not find referenced Issue.

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the Portal Involves changes to the Portal (docs) codebase. label Jun 15, 2025
Copy link
Contributor

@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: 4

🔭 Outside diff range comments (2)
apps/portal/src/app/pay/page.mdx (2)

57-82: ⚠️ Potential issue

Restore imports for FeatureCard and icons
The JSX grid uses FeatureCard, ArrowLeftRightIcon, PiggyBankIcon, ShieldCheckIcon, GlobeIcon, etc., but these are no longer imported. Add at the top:

import FeatureCard from 'components/FeatureCard';
import {
  ArrowLeftRightIcon,
  PiggyBankIcon,
  ShieldCheckIcon,
  GlobeIcon,
} from 'components/icons';

83-94: ⚠️ Potential issue

Add imports for remaining icons
You also need to import WebhookIcon and WalletIcon used in the later cards:

import { WebhookIcon, WalletIcon } from 'components/icons';
🧹 Nitpick comments (4)
apps/portal/src/app/pay/page.mdx (4)

13-18: Enforce a meaningful minimum purchase
Requiring msg.value > 0 allows ETH amounts below tokenPrice and results in zero tokens. Consider:

-    require(msg.value > 0, "أرسل بعض ETH لشراء التوكن");
+    require(msg.value >= tokenPrice, "أرسل ما لا يقل عن سعر التوكن");

This prevents zero-token transactions.


21-23: Use call instead of transfer in withdraw
.transfer can fail due to gas stipend limits. Prefer:

-    payable(owner()).transfer(address(this).balance);
+    (bool success, ) = owner().call{ value: address(this).balance }("");
+    require(success, "سحب العائدات فشل");

28-29: Avoid hardcoded API keys
Replace 'YOUR_API_KEY' with an environment variable, e.g.:

apiKey: process.env.NEXT_PUBLIC_TRANSAK_API_KEY,

43-53: Expose buyTokens via UI
Defining buyTokens() alone won’t trigger it. Add a button or event listener in the MDX to invoke it, for example:

<button onClick={buyTokens}>Buy Tokens</button>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e43afa1 and c1aac9c.

📒 Files selected for processing (1)
  • apps/portal/src/app/pay/page.mdx (1 hunks)
🧰 Additional context used
🪛 LanguageTool
apps/portal/src/app/pay/page.mdx

[uncategorized] ~40-~40: Loose punctuation mark.
Context: ...00px' }); transak.init(); </script> }); async function buyTokens() { const...

(UNLIKELY_OPENING_PUNCTUATION)

🔇 Additional comments (1)
apps/portal/src/app/pay/page.mdx (1)

55-96: Inconsistent AI summary
The AI-generated summary states that the original documentation (feature cards, SDK modules, quick starts, etc.) was completely removed, but lines 55–96 still contain the feature card grid, tables, and quick-start examples.

Likely an incorrect or invalid review comment.

Comment on lines +1 to +24
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract DarkMint is ERC20, Ownable {
uint256 public tokenPrice = 0.001 ether; // السعر لكل توكن
constructor() ERC20("DarkMint", "DMT") {
_mint(address(this), 1000000000 * 10 ** decimals()); // العقد يملك التوكن
}

function buyTokens() public payable {
require(msg.value > 0, "أرسل بعض ETH لشراء التوكن");
uint256 amount = (msg.value * (10 ** decimals())) / tokenPrice;
require(balanceOf(address(this)) >= amount, "كمية غير كافية");
_transfer(address(this), msg.sender, amount);
}

// سحب العائدات
function withdraw() public onlyOwner {
payable(owner()).transfer(address(this).balance);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Wrap Solidity code in a proper MDX code block
Raw Solidity lines must be enclosed in triple backticks with the solidity language tag (or a <CodeBlock> component) to render correctly in MDX. For example:

+```solidity
 // SPDX-License-Identifier: MIT
 pragma solidity ^0.8.0;
 import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
 import "@openzeppelin/contracts/access/Ownable.sol";
 
 contract DarkMint is ERC20, Ownable {
     uint256 public tokenPrice = 0.001 ether; // السعر لكل توكن
     constructor() ERC20("DarkMint", "DMT") {
         _mint(address(this), 1000000000 * 10 ** decimals());
     }
     ...
 }
+```  
🤖 Prompt for AI Agents
In apps/portal/src/app/pay/page.mdx lines 1 to 24, the Solidity code is not
wrapped in a proper MDX code block, which prevents correct rendering. Enclose
the entire Solidity code snippet within triple backticks followed by the word
"solidity" at the start and triple backticks at the end to create a fenced code
block for proper syntax highlighting and formatting in MDX.

Comment on lines +43 to +53
async function buyTokens() {
const tx = await contract.buyTokens({ value: ethers.utils.parseEther("0.01") });
console.log("معاملة قيد الإرسال...");

const receipt = await tx.wait();
if (receipt.status === 1) {
console.log("✅ تم الشراء بنجاح");
} else {
console.log("❌ فشل في الشراء");
}
}<DocImage src={PayOverviewImage} />
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Initialize and import the contract before calling buyTokens
The snippet references ethers and contract but neither are imported nor instantiated. You need to:

import { ethers } from 'ethers';
import DarkMintABI from './DarkMint.json';

const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
const contractAddress = '0x...'; // deployed address
const contract = new ethers.Contract(contractAddress, DarkMintABI, signer);
🤖 Prompt for AI Agents
In apps/portal/src/app/pay/page.mdx around lines 43 to 53, the buyTokens
function uses ethers and contract without importing or initializing them. To fix
this, import ethers from 'ethers' and the contract ABI from the appropriate JSON
file. Then, create a provider using ethers.providers.Web3Provider with
window.ethereum, get the signer from the provider, define the deployed contract
address, and instantiate the contract with new ethers.Contract using the
address, ABI, and signer before calling buyTokens.

} else {
console.log("❌ فشل في الشراء");
}
}<DocImage src={PayOverviewImage} />
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Import missing PayOverviewImage
<DocImage src={PayOverviewImage} /> will fail without an import. For example:

import PayOverviewImage from 'public/assets/pay-overview.png';
🤖 Prompt for AI Agents
In apps/portal/src/app/pay/page.mdx at line 53, the component uses
PayOverviewImage without importing it, which will cause a runtime error. Add an
import statement at the top of the file to import PayOverviewImage from the
correct path, for example: import PayOverviewImage from
'public/assets/pay-overview.png'; this will ensure the image is properly
referenced and the component renders correctly.

Comment on lines +26 to +41
<script>
const transak = new TransakSDK({
apiKey: 'YOUR_API_KEY',
environment: 'STAGING',
defaultCryptoCurrency: 'ETH',
walletAddress: '0xYourWallet',
fiatCurrency: 'USD',
email: '',
redirectURL: '',
hostURL: window.location.origin,
widgetHeight: '625px',
widgetWidth: '500px'
});
transak.init();
</script>
});
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix script block syntax and dependencies

  1. Remove the stray }); on line 41.
  2. Use Next.js’s <Script> component (imported from next/script) or ensure your MDX supports raw <script>.
  3. Import TransakSDK from @transak/transak-sdk.

Example diff:

+ import Script from 'next/script';
+ import TransakSDK from '@transak/transak-sdk';
  
- <script>
+ <Script strategy="lazyOnload">
    const transak = new TransakSDK({
      apiKey: 'YOUR_API_KEY',
      ...
    });
    transak.init();
- </script>
- });
+ </Script>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<script>
const transak = new TransakSDK({
apiKey: 'YOUR_API_KEY',
environment: 'STAGING',
defaultCryptoCurrency: 'ETH',
walletAddress: '0xYourWallet',
fiatCurrency: 'USD',
email: '',
redirectURL: '',
hostURL: window.location.origin,
widgetHeight: '625px',
widgetWidth: '500px'
});
transak.init();
</script>
});
import Script from 'next/script';
import TransakSDK from '@transak/transak-sdk';
<Script strategy="lazyOnload">
const transak = new TransakSDK({
apiKey: 'YOUR_API_KEY',
environment: 'STAGING',
defaultCryptoCurrency: 'ETH',
walletAddress: '0xYourWallet',
fiatCurrency: 'USD',
email: '',
redirectURL: '',
hostURL: window.location.origin,
widgetHeight: '625px',
widgetWidth: '500px'
});
transak.init();
</Script>
🧰 Tools
🪛 LanguageTool

[uncategorized] ~40-~40: Loose punctuation mark.
Context: ...00px' }); transak.init(); </script> }); async function buyTokens() { const...

(UNLIKELY_OPENING_PUNCTUATION)

🤖 Prompt for AI Agents
In apps/portal/src/app/pay/page.mdx lines 26 to 41, remove the stray closing
characters `});` at the end of the script block to fix syntax errors. Replace
the raw `<script>` tag with Next.js's `<Script>` component imported from
`next/script` to ensure proper script loading in MDX. Also, add an import
statement for `TransakSDK` from `@transak/transak-sdk` at the top of the file to
correctly reference the SDK.

@jnsdls jnsdls closed this Jun 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Portal Involves changes to the Portal (docs) codebase.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants