Skip to content
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

Feature/advance nft #358

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open

Feature/advance nft #358

wants to merge 17 commits into from

Conversation

tanuj-aelf
Copy link
Collaborator

No description provided.

Copy link

vizipi bot commented Dec 26, 2024

Pull request analysis by VIZIPI

Below you will find who is the most qualified team member to review your code.
This analysis includes his/her work on the code included in this Pull request, in addition to their experience in code affected by these changes ( partly found within the list of potential missing files below )   Feedback always welcome

Reviewers with knowledge related to these changes

Match % Person Commit Count Common Files
80.00% RutvikGhaskataEalf 22 4
20.00% yongenaelf 38 1
20.00% AelfHarsh 14 1
20.00% zhifenglee-portkey 10 1
20.00% vasmohi 4 1

Potential missing files from this Pull request

files commonly committed with a subset of this pr, but not committed this time. (click to collapse)
FilePercentilerate
docs/quick-start/advance-tutorials/nft-dapp/index.md60.00%3 out of 5 times

Committed file ranks

(click to expand)
  • 95.03%[docs/quick-start/advance-tutorials/nft-indexer/index.md]
  • 68.72%[docs/quick-start/advance-tutorials/_setup.md]
  • 55.57%[docs/quick-start/advance-tutorials/_category_.json]
  • 31.14%[...docs/quick-start/advance-tutorials/local-node-deployment/]
  • 99.87%[sidebars.ts]
  • Please remember to export PATH after installing aelf.deploy.

    :::info
    ℹ️ Note: If you have installed aelf.deploy and your terminal says that there is no such command available, please uninstall and install aelf.deploy.
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    Suggested change
    ℹ️ Note: If you have installed aelf.deploy and your terminal says that there is no such command available, please uninstall and install aelf.deploy.
    ℹ️ Note: If you have installed aelf.deploy and your terminal says that there is no such command available, please uninstall and reinstall aelf.deploy.

    2. Download the development template by entering your project name.
    ![download-template](/img/download-nft-indexer-template.png)
    3. Unzip the downloaded file to extract the project files.
    4. After unzipping, you are ready to start development
    Copy link
    Collaborator

    @yongenaelf yongenaelf Jan 2, 2025

    Choose a reason for hiding this comment

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

    Suggested change
    4. After unzipping, you are ready to start development
    4. After unzipping the files, you are ready to start development.

    Select `Codespaces`.
    5. Click on the `+` sign to create a new Codespace.
    6. After some time, your workspace will load with the contents of the repository.
    You can now continue your development using GitHub Codespaces.
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    Suggested change
    You can now continue your development using GitHub Codespaces.
    You may now continue your development using GitHub Codespaces.

    Comment on lines +63 to +72
    NFTAeIndexer/
    ├── Contracts/ # Contract interfaces
    │ ├── TokenContract.c.cs
    │ ├── TokenContract.g.cs
    ├── Entities/ # Data models
    │ ├── Account.cs # NFT account information
    │ └── TransferRecord.cs # NFT transfer records
    ├── Processors/ # Event processors
    │ └── NFTTransferredProcessor.cs # Handles NFT transfer events
    └── GraphQL/ # GraphQL query definitions
    Copy link
    Collaborator

    @yongenaelf yongenaelf Jan 2, 2025

    Choose a reason for hiding this comment

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

    ```

    :::tip
    ℹ️ Note: If other contract files are needed, they need to be generated by compiling the corresponding contract project!
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    any step-by-step instructions on how to do this?


    - Replace the existing **`fetchContract`** function with this updated code:

    ```javascript title="useNFTSmartContract.ts"
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    ts


    - Replace the existing **`useEffect`** hook with this updated code:

    ```javascript title="useNFTSmartContract.ts"
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    ts


    - Replace the existing connect function with this code snippet:

    ```javascript title="header/index.tsx"
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    tsx


    - Replace the existing **`fetchUserNftData`** function with this code snippet:

    ```javascript title="commonFunctions.ts"
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    ts


    ```javascript title="commonFunctions.ts"
    // fetch NFT Data from Indexer API
    export const fetchUserNftData = async (addres:string) => {
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    Suggested change
    export const fetchUserNftData = async (addres:string) => {
    export const fetchUserNftData = async (address:string) => {

    const body = JSON.stringify({
    query: `
    query {
    account(input: { chainId: "tDVW", address: "${addres}" }) {
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    Suggested change
    account(input: { chainId: "tDVW", address: "${addres}" }) {
    account(input: { chainId: "tDVW", address: "${address}" }) {


    - Replace the existing **`getNFTData`** function with this code snippet:

    ```javascript title="home/index.tsx"
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    tsx


    - Replace the existing **`getNFTData`** function with this code snippet:

    ```javascript title="profile/index.tsx"
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    tsx


    - Replace the existing **`createNftCollectionOnMainChain`** function with this code snippet:

    ```javascript title="create-nft/index.tsx"
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    tsx

    createLoadingId = toast.loading("Creating NFT Collection..");

    // Create an object with the necessary information for the new NFT collection.
    const createNtfInput: INftInput = {
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    Suggested change
    const createNtfInput: INftInput = {
    const createNftInput: INftInput = {

    const result = await mainChainSmartContract?.callSendMethod(
    "Create",
    currentWalletAddress,
    createNtfInput
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    Suggested change
    createNtfInput
    createNftInput

    removeNotification(createLoadingId);

    // Return the input data for further use.
    return createNtfInput;
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    Suggested change
    return createNtfInput;
    return createNftInput;


    - Replace the existing **`validateNftCollectionInfo`** function with this code snippet:

    ```javascript title="create-nft/index.tsx"
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    tsx

    Comment on lines +125 to +132
    while (!heightDone) {
    // Get the latest index height
    const sideIndexMainHeight = await GetParentChainHeight();
    if (Number(sideIndexMainHeight) >= VALIDATE_TXRESULT.Transaction.RefBlockNumber) {
    VALIDATE_TXRESULT = await aelf.chain.getTxResult(VALIDATE_TXID);
    heightDone = true;
    }
    }
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    you should have some logic to throttle this, like to wait a few seconds between calls.


    - Replace the existing **`GetParentChainHeight`** function with the following code snippet:

    ```javascript title="create-nft/index.tsx"
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    tsx


    - Replace the existing **`getMerklePathByTxId`** function with this code snippet:

    ```javascript title="create-nft/index.tsx"
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    tsx


    - Replace the existing **`createCollectionOnSideChain`** function with this code snippet:

    ```javascript title="create-nft/index.tsx"
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    tsx

    let crossChainLoadingId;
    try {
    crossChainLoadingId = toast.loading(
    "Creating Collection on SideChain..."
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    Suggested change
    "Creating Collection on SideChain..."
    "Creating Collection on dAppChain..."

    const CROSS_CHAIN_CREATE_TOKEN_PARAMS = {
    fromChainId: mainchain_from_chain_id,
    parentChainHeight: "" + BlockNumber,
    // @ts-ignore
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    why ignore?

    done = true;
    setIsNftCollectionCreated(true);
    toast.update(crossChainLoadingId, {
    render: "Collection was Created Successfully On SideChain",
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    Suggested change
    render: "Collection was Created Successfully On SideChain",
    render: "Collection was Created Successfully On dAppChain",

    Comment on lines +281 to +282
    if ((err as { Error: string }).Error.includes("Cross chain verification failed.")) {
    console.log("Exit.");
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    what should the user do to fix this?


    2. Replace the form variable with this code snippet:

    ```javascript title="create-nft/index.tsx"
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    tsx

    ```

    #### Here's what the function does:
    1. Initializes a new form variable with default values needed to create a nft.
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    Suggested change
    1. Initializes a new form variable with default values needed to create a nft.
    1. Initializes a new form variable with default values needed to create an NFT.

    @@ -0,0 +1,48 @@
    ### Configure Submit Form
    Now, let's Write a Function to Call Necessary Functions for NFT Creation.
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    Suggested change
    Now, let's Write a Function to Call Necessary Functions for NFT Creation.
    Now, let's write a function to call necessary functions for NFT creation.


    2. Replace the existing **`onSubmit`** function with this code snippet:

    ```javascript title="create-nft/index.tsx"
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    tsx

    @@ -0,0 +1,311 @@
    ### Create NFT Token
    **Step 1: Write a Function to create NFTs on the mainchain**
    Copy link
    Collaborator

    @yongenaelf yongenaelf Jan 2, 2025

    Choose a reason for hiding this comment

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

    Suggested change
    **Step 1: Write a Function to create NFTs on the mainchain**
    **Step 1: Write a function to create NFTs on the MainChain**

    @@ -0,0 +1,311 @@
    ### Create NFT Token
    **Step 1: Write a Function to create NFTs on the mainchain**
    Now, let's write the create NFTs on mainchain function.
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    Suggested change
    Now, let's write the create NFTs on mainchain function.
    Now, let's write the **create NFTs on MainChain** function.


    2. Replace the existing **`createNFTOnMainChain`** function with this code snippet:

    ```javascript title="create-nft/index.tsx"
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    tsx

    );

    // Preparing Parameter for Create Function
    const createNtfMainChainInput = {
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    Suggested change
    const createNtfMainChainInput = {
    const createNftMainChainInput = {

    const resultMainchain = await mainChainSmartContract?.callSendMethod(
    "Create",
    currentWalletAddress,
    createNtfMainChainInput
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    Suggested change
    createNtfMainChainInput
    createNftMainChainInput


    2. Replace the existing **`validateNftToken`** function with this code snippet:

    ```javascript title="create-nft/index.tsx"
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    tsx

    Comment on lines +115 to +125
    while (!heightDone) {
    // get latest index Hight
    const sideIndexMainHeight = await GetParentChainHeight();
    if (
    // check the latest index Hight is grater than or equal
    Number(sideIndexMainHeight) >= VALIDATE_TXRESULT.Transaction.RefBlockNumber
    ) {
    VALIDATE_TXRESULT = await aelf.chain.getTxResult(VALIDATE_TXID);
    heightDone = true;
    }
    }
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    throttle this loop by adding a delay between each call


    2. Replace the existing **`createNftTokenOnSideChain`** function with this code snippet:

    ```javascript title="create-nft/index.tsx"
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    tsx


    2. Replace the existing **`issueNftOnSideChain`** function with this code snippet:

    ```javascript title="create-nft/index.tsx"
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    tsx


    2. Replace the existing **`createNftToken`** function with this code snippet:

    ```javascript title="create-nft/index.tsx"
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    tsx

    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.

    3 participants