Skip to content

Commit 6d2b804

Browse files
committed
additional edits and screenshots added
1 parent 363d01b commit 6d2b804

File tree

8 files changed

+76
-50
lines changed

8 files changed

+76
-50
lines changed

docs/quick-start/advance-tutorials/nft-indexer/index.md

Lines changed: 76 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ sidebar_position: 1
33
title: NFT AeIndexer
44
description: Advance featured AeIndexer application
55
---
6-
# NFT dApp with AeIndexer
6+
# NFT AeIndexer
77

88
**Description**: This application demonstrates how to maintain account balances and transfer records by indexing aelf's NFT issued data.
99

@@ -25,16 +25,21 @@ description: Advance featured AeIndexer application
2525

2626
- Enter the AeIndexer Name and other information to create a NFT AeIndexer.
2727
<!-- Commenting out missing image references -->
28-
<!-- ![dashboard](./-nftindexer/img/dashboard.png) -->
29-
<!-- ![create-app](./nft-aeindexer/img/create-app.png) -->
28+
![run-app-success](/img/create-nft-indexer.png)
29+
![create-app](/img/name-nft-indexer.png)
3030

3131
## Step 3 - Develop NFT AeIndexer
3232

33+
### Download development template
34+
- In the created AeIndexer details page, download the development template by entering the project name.
35+
![download-template](/img/download-nft-indexer-template.png)
36+
- After unzipping, you can start developing.
37+
3338
### Project Structure
3439
The NFT AeIndexer project consists of the following key components:
3540

3641
```
37-
nftIndexer/
42+
NFTAeIndexer/
3843
├── Contracts/ # Contract interfaces
3944
├── Entities/ # Data models
4045
│ ├── Account.cs # NFT account information
@@ -46,6 +51,17 @@ nftIndexer/
4651

4752
### Core Components
4853

54+
- Obtain the Token contract files through the [AeFinder GitHub NFT AeIndexer sample](https://github.com/AeFinderProject/aefinder/tree/master/samples/TokenAeIndexer), and copy these two files to the directory src/NFTAeIndexer/Contracts.
55+
56+
:::tip
57+
ℹ️ Note: If other contract files are needed, they need to be generated by compiling the corresponding contract project!
58+
:::
59+
60+
```
61+
TokenContract.c.cs
62+
TokenContract.g.cs
63+
```
64+
4965
#### 1. Entity Models
5066

5167
**Account.cs**
@@ -92,10 +108,10 @@ using AElf.Contracts.MultiToken;
92108
using AeFinder.Sdk.Logging;
93109
using AeFinder.Sdk.Processor;
94110
using AeFinder.Sdk;
95-
using nftIndexer.Entities;
111+
using NFTAeIndexer.Entities;
96112
using Volo.Abp.DependencyInjection;
97113

98-
namespace nftIndexer.Processors;
114+
namespace NFTAeIndexer.Processors;
99115

100116
public class NFTTransferredProcessor : LogEventProcessorBase<Issued>, ITransientDependency
101117
{
@@ -185,12 +201,12 @@ public class NFTTransferredProcessor : LogEventProcessorBase<Issued>, ITransient
185201
}
186202
```
187203

188-
- Add files `AccountDto.cs`, `TransferRecordDto.cs`, `GetAccountInput.cs`, `GetTransferRecordInput.cs` to the directory `src/nftIndexer/GraphQL`.
204+
- Add files `AccountDto.cs`, `TransferRecordDto.cs`, `GetAccountInput.cs`, `GetTransferRecordInput.cs` to the directory `src/NFTAeIndexer/GraphQL`.
189205

190206
```csharp title="AccountDto.cs"
191207
using AeFinder.Sdk.Dtos;
192208

193-
namespace nftIndexer.GraphQL;
209+
namespace NFTAeIndexer.GraphQL;
194210

195211
public class AccountDto : AeFinderEntityDto
196212
{
@@ -206,7 +222,7 @@ public class AccountDto : AeFinderEntityDto
206222
```csharp title="TransferRecordDto.cs"
207223
using AeFinder.Sdk.Dtos;
208224

209-
namespace nftIndexer.GraphQL;
225+
namespace NFTAeIndexer.GraphQL;
210226

211227
public class TransferRecordDto : AeFinderEntityDto
212228
{
@@ -218,7 +234,7 @@ public class TransferRecordDto : AeFinderEntityDto
218234
```
219235

220236
```csharp title="GetAccountInput.cs"
221-
namespace nftIndexer.GraphQL;
237+
namespace NFTAeIndexer.GraphQL;
222238

223239
public class GetAccountInput
224240
{
@@ -229,7 +245,7 @@ public class GetAccountInput
229245
```
230246

231247
```csharp title="GetTransferRecordInput.cs"
232-
namespace nftIndexer.GraphQL;
248+
namespace NFTAeIndexer.GraphQL;
233249

234250
public class GetTransferRecordInput
235251
{
@@ -239,15 +255,15 @@ public class GetTransferRecordInput
239255
}
240256
```
241257

242-
- Modify `src/nftIndexer/GraphQL/Query.cs` to add query logic.
258+
- Modify `src/NFTAeIndexer/GraphQL/Query.cs` to add query logic.
243259

244260
```csharp title="Query.cs"
245261
using AeFinder.Sdk;
246262
using GraphQL;
247-
using nftIndexer.Entities;
263+
using NFTAeIndexer.Entities;
248264
using Volo.Abp.ObjectMapping;
249265

250-
namespace nftIndexer.GraphQL;
266+
namespace NFTAeIndexer.GraphQL;
251267

252268
public class Query
253269
{
@@ -257,70 +273,74 @@ public class Query
257273
GetAccountInput input)
258274
{
259275
var queryable = await repository.GetQueryableAsync();
260-
276+
261277
queryable = queryable.Where(a => a.Metadata.ChainId == input.ChainId);
262-
278+
263279
if (!input.Address.IsNullOrWhiteSpace())
264280
{
265281
queryable = queryable.Where(a => a.Address == input.Address);
266-
}
267-
268-
if(!input.Symbol.IsNullOrWhiteSpace())
282+
}
283+
284+
if (!input.Symbol.IsNullOrWhiteSpace())
269285
{
270-
queryable = queryable.Where(a => a.Symbol == input.Symbol);
286+
queryable = queryable.Where(a => a.Symbol == input.Symbol && a.Symbol.Contains("-"));
271287
}
272-
273-
var accounts= queryable.OrderBy(o=>o.Metadata.Block.BlockHeight).ToList();
288+
289+
var accounts = queryable.OrderBy(o => o.Metadata.Block.BlockHeight).ToList();
274290

275291
return objectMapper.Map<List<Account>, List<AccountDto>>(accounts);
276292
}
277-
293+
278294
public static async Task<List<TransferRecordDto>> TransferRecord(
279295
[FromServices] IReadOnlyRepository<TransferRecord> repository,
280296
[FromServices] IObjectMapper objectMapper,
281297
GetTransferRecordInput input)
282298
{
283299
var queryable = await repository.GetQueryableAsync();
284-
300+
285301
queryable = queryable.Where(a => a.Metadata.ChainId == input.ChainId);
286-
302+
287303
if (!input.Address.IsNullOrWhiteSpace())
288304
{
289305
queryable = queryable.Where(a => a.ToAddress == input.Address);
290306
}
291-
292-
if(!input.Symbol.IsNullOrWhiteSpace())
307+
308+
// Filter by Symbol, ensuring it matches the NFT pattern
309+
if (!input.Symbol.IsNullOrWhiteSpace())
293310
{
294-
queryable = queryable.Where(a => a.Symbol == input.Symbol);
311+
queryable = queryable.Where(a => a.Symbol == input.Symbol && a.Symbol.Contains("-"));
295312
}
296-
297-
var accounts= queryable.OrderBy(o=>o.Metadata.Block.BlockHeight).ToList();
298313

299-
return objectMapper.Map<List<TransferRecord>, List<TransferRecordDto>>(accounts);
314+
// Ensure NFT-specific conditions
315+
queryable = queryable.Where(a => a.Symbol.Contains("-") && a.Amount > 0);
316+
317+
var transferRecords = queryable.OrderBy(o => o.Metadata.Block.BlockHeight).ToList();
318+
319+
return objectMapper.Map<List<TransferRecord>, List<TransferRecordDto>>(transferRecords);
300320
}
301321
}
302322
```
303323

304324
- Register log event processor
305325

306-
Modify `src/nftIndexer/nftIndexerModule.cs` to register NFTTransferredProcessor.
326+
Modify `src/NFTAeIndexer/NFTAeIndexerModule.cs` to register NFTTransferredProcessor.
307327

308-
```csharp title="nftIndexerModule.cs"
328+
```csharp title="NFTAeIndexerModule.cs"
309329
using AeFinder.Sdk.Processor;
310-
using nftIndexer.GraphQL;
311-
using nftIndexer.Processors;
330+
using NFTAeIndexer.GraphQL;
331+
using NFTAeIndexer.Processors;
312332
using GraphQL.Types;
313333
using Microsoft.Extensions.DependencyInjection;
314334
using Volo.Abp.AutoMapper;
315335
using Volo.Abp.Modularity;
316336

317-
namespace nftIndexer;
337+
namespace NFTAeIndexer;
318338

319-
public class nftIndexerModule: AbpModule
339+
public class NFTAeIndexerModule: AbpModule
320340
{
321341
public override void ConfigureServices(ServiceConfigurationContext context)
322342
{
323-
Configure<AbpAutoMapperOptions>(options => { options.AddMaps<nftIndexerModule>(); });
343+
Configure<AbpAutoMapperOptions>(options => { options.AddMaps<NFTAeIndexerModule>(); });
324344
context.Services.AddSingleton<ISchema, AeIndexerSchema>();
325345

326346
// Add your LogEventProcessor implementation.
@@ -331,18 +351,18 @@ public class nftIndexerModule: AbpModule
331351

332352
- Add entity mapping
333353

334-
Modify src/nftIndexer/nftIndexerAutoMapperProfile.cs and add entity mapping code.
354+
Modify src/NFTAeIndexer/NFTAeIndexerAutoMapperProfile.cs and add entity mapping code.
335355

336-
```csharp title="nftIndexerAutoMapperProfile.cs"
337-
using nftIndexer.Entities;
338-
using nftIndexer.GraphQL;
356+
```csharp title="NFTAeIndexerAutoMapperProfile.cs"
357+
using NFTAeIndexer.Entities;
358+
using NFTAeIndexer.GraphQL;
339359
using AutoMapper;
340360

341-
namespace nftIndexer;
361+
namespace NFTAeIndexer;
342362

343-
public class nftIndexerAutoMapperProfile : Profile
363+
public class NFTAeIndexerAutoMapperProfile : Profile
344364
{
345-
public nftIndexerAutoMapperProfile()
365+
public NFTAeIndexerAutoMapperProfile()
346366
{
347367
CreateMap<Account, AccountDto>();
348368
CreateMap<TransferRecord, TransferRecordDto>();
@@ -358,7 +378,7 @@ dotnet build -c Release
358378

359379
## Step 4 - Deploy AeIndexer
360380
- Open the AeIndexer details page and click Deploy.
361-
<!-- ![deploy](./token-aeindexer/img/deploy.png) -->
381+
![deploy](/img/deploy-nft-indexer-template.png)
362382
- Fill out the subscription manifest and upload the DLL file.
363383
1. Subscription manifest:
364384
```json
@@ -382,15 +402,15 @@ dotnet build -c Release
382402
]
383403
}
384404
```
385-
2. DLL file location: src/nftIndexer/bin/Release/net8.0/nftIndexer.dll
386-
<!-- ![deploy-2](./token-aeindexer/img/deploy-2.png) -->
405+
2. DLL file location: src/NFTAeIndexer/bin/Release/net8.0/NFTAeIndexer.dll
406+
![deploy-2](/img/subscription-nft-indexer.png)
387407
- Click the deploy button to submit deployment information. When the normal processing block information appears on the Logs page at the bottom of the details page, it means that the deployment has been successful and data indexing has started.
388-
<!-- ![log](./token-aeindexer/img/log.png) -->
408+
![log](/img/logs-nft-indexer.png)
389409

390410
## Step 5 - Query indexed data
391411
Through the Playground page below the details page, you can use GraphQL syntax to query the indexed data information. Enter the query statement on the left, and the query results will be displayed on the right.
392412

393-
```GraphQL
413+
```
394414
query{
395415
account(input: { chainId: "tDVW", address: "2AaBGTi2cJLWtEXR7w96hzun4qVz2KnsGZ1XfqErhKTgDj9Q8x"}) {
396416
symbol,
@@ -407,3 +427,9 @@ query{
407427
}
408428
}
409429
}
430+
```
431+
![query-graphQL](/img/query-nft-indexer.png)
432+
433+
:::tip
434+
ℹ️ Note: For the complete demo code, please visit AeFinder github to download. https://github.com/AeFinderProject/aefinder/tree/master/samples/TokenAeIndexer
435+
:::

static/img/create-nft-indexer.png

174 KB
Loading
295 KB
Loading
292 KB
Loading

static/img/logs-nft-indexer.png

566 KB
Loading

static/img/name-nft-indexer.png

314 KB
Loading

static/img/query-nft-indexer.png

420 KB
Loading
437 KB
Loading

0 commit comments

Comments
 (0)