-
Notifications
You must be signed in to change notification settings - Fork 3
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
base: develop
Are you sure you want to change the base?
Feature/advance nft #358
Conversation
This reverts commit 1d67d68.
Pull request analysis by VIZIPI Below you will find who is the most qualified team member to review your code. Reviewers with knowledge related to these changes
Potential missing files from this Pull requestfiles commonly committed with a subset of this pr, but not committed this time. (click to collapse)
Committed file ranks |
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ️ 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can now continue your development using GitHub Codespaces. | |
You may now continue your development using GitHub Codespaces. |
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 |
There was a problem hiding this comment.
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! |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const fetchUserNftData = async (addres:string) => { | |
export const fetchUserNftData = async (address:string) => { |
const body = JSON.stringify({ | ||
query: ` | ||
query { | ||
account(input: { chainId: "tDVW", address: "${addres}" }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const createNtfInput: INftInput = { | |
const createNftInput: INftInput = { |
const result = await mainChainSmartContract?.callSendMethod( | ||
"Create", | ||
currentWalletAddress, | ||
createNtfInput |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createNtfInput | |
createNftInput |
removeNotification(createLoadingId); | ||
|
||
// Return the input data for further use. | ||
return createNtfInput; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return createNtfInput; | |
return createNftInput; |
|
||
- Replace the existing **`validateNftCollectionInfo`** function with this code snippet: | ||
|
||
```javascript title="create-nft/index.tsx" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tsx
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; | ||
} | ||
} |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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..." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Creating Collection on SideChain..." | |
"Creating Collection on dAppChain..." |
const CROSS_CHAIN_CREATE_TOKEN_PARAMS = { | ||
fromChainId: mainchain_from_chain_id, | ||
parentChainHeight: "" + BlockNumber, | ||
// @ts-ignore |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
render: "Collection was Created Successfully On SideChain", | |
render: "Collection was Created Successfully On dAppChain", |
if ((err as { Error: string }).Error.includes("Cross chain verification failed.")) { | ||
console.log("Exit."); |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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" |
There was a problem hiding this comment.
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** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
**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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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" |
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const createNtfMainChainInput = { | |
const createNftMainChainInput = { |
const resultMainchain = await mainChainSmartContract?.callSendMethod( | ||
"Create", | ||
currentWalletAddress, | ||
createNtfMainChainInput |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createNtfMainChainInput | |
createNftMainChainInput |
|
||
2. Replace the existing **`validateNftToken`** function with this code snippet: | ||
|
||
```javascript title="create-nft/index.tsx" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tsx
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; | ||
} | ||
} |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tsx
No description provided.