Skip to content

Commit 0b0c6ad

Browse files
committed
fix(docs): correct formatting and spacing in developer guides and example scripts
1 parent fe23c55 commit 0b0c6ad

File tree

3 files changed

+44
-41
lines changed

3 files changed

+44
-41
lines changed

docs/fassets/developer-guides.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,6 @@ Guides for reading and working with agent data.
113113
label: "Read FAssets Agent Details",
114114
href: "/fassets/developer-guides/fassets-agent-details",
115115
docId: "fassets/developer-guides/fassets-agent-details",
116-
}
116+
},
117117
]}
118118
/>

docs/fassets/developer-guides/fassets-list-agents.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ And return two values:
4040

4141
:::tip Index Parameters
4242
All of these functions use array-like slicing:
43+
4344
- `start`: Inclusive start index (0-based).
4445
- `end`: Exclusive end index.
4546

@@ -62,8 +63,8 @@ The script follows these steps:
6263
1. **Get Asset Manager Contract**: Retrieve the FAssets FXRP Asset Manager contract instance using the helper function `getAssetManagerFXRP()` from the Flare periphery contracts package.
6364

6465
2. **Define Chunk Size**: Set `chunkSize` to `3`, determining how many agents to fetch per request.
65-
Using smaller chunks helps avoid RPC timeout issues when dealing with many agents.
66-
You can adjust this value based on your network conditions and RPC provider limits.
66+
Using smaller chunks helps avoid RPC timeout issues when dealing with many agents.
67+
You can adjust this value based on your network conditions and RPC provider limits.
6768

6869
3. **Fetch First Chunk**: Call `getAvailableAgentsList(0, chunkSize)` which:
6970
- Returns the first three agents (indices 0, 1, 2).
@@ -104,4 +105,4 @@ To continue your FAssets development journey, you can:
104105
- Learn how to [mint FXRP](/fassets/developer-guides/fassets-mint)
105106
- Understand how to [redeem FXRP](/fassets/developer-guides/fassets-redeem)
106107
- Explore [FAssets system settings](/fassets/operational-parameters)
107-
:::
108+
:::

examples/developer-hub-javascript/fassets_list_agents.ts

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,51 @@ import { getAssetManagerFXRP } from "../utils/getters";
22

33
/**
44
* Script to list all available FAssets agents in chunks
5-
*
5+
*
66
* This script demonstrates how to iterate through all agents in the FAssets system
77
* by fetching them in chunks to avoid overwhelming the RPC endpoint with large requests.
8-
*
8+
*
99
* Run with: yarn hardhat run scripts/fassets/listAgents.ts --network coston2
1010
*/
1111

1212
async function main() {
13-
// 1. Get the FAssets FXRP asset manager contract instance
14-
const assetManager = await getAssetManagerFXRP();
15-
16-
// 2. Define how many agents to fetch per request
17-
// Using smaller chunks (e.g., 3) helps avoid RPC timeout issues
18-
const chunkSize = 3;
19-
20-
// 3. Fetch the first chunk and get the total count
21-
// The _totalLength property tells us how many agents exist in total
22-
console.log("Fetching first chunk with offset 0 and chunk size " + chunkSize);
23-
const firstChunk = await assetManager.getAvailableAgentsList(0, chunkSize);
24-
console.log(firstChunk._agents);
25-
26-
const totalLength = Number(BigInt(firstChunk._totalLength).toString());
27-
console.log(`Total number of agents: ${totalLength}`);
28-
29-
// 4. Iterate through remaining agents in chunks
30-
// The getAvailableAgentsDetailedList(start, end) function uses:
31-
// - start: inclusive start index (0-based)
32-
// - end: exclusive end index (like array slicing)
33-
// Example: (0, 3) returns agents at indices 0, 1, 2
34-
for (let offset = chunkSize; offset < totalLength; offset += chunkSize) {
35-
// Calculate end index, ensuring we don't exceed totalLength
36-
const endIndex = Math.min(offset + chunkSize, totalLength);
37-
console.log(`\n--- Fetching agents ${offset} to ${endIndex - 1} (end index ${endIndex} exclusive) ---`);
38-
39-
// Fetch the chunk of agents
40-
const agents = await assetManager.getAvailableAgentsList(offset, endIndex);
41-
console.log(agents._agents);
42-
}
43-
44-
console.log(`\nCompleted processing all ${totalLength} agents`);
13+
// 1. Get the FAssets FXRP asset manager contract instance
14+
const assetManager = await getAssetManagerFXRP();
15+
16+
// 2. Define how many agents to fetch per request
17+
// Using smaller chunks (e.g., 3) helps avoid RPC timeout issues
18+
const chunkSize = 3;
19+
20+
// 3. Fetch the first chunk and get the total count
21+
// The _totalLength property tells us how many agents exist in total
22+
console.log("Fetching first chunk with offset 0 and chunk size " + chunkSize);
23+
const firstChunk = await assetManager.getAvailableAgentsList(0, chunkSize);
24+
console.log(firstChunk._agents);
25+
26+
const totalLength = Number(BigInt(firstChunk._totalLength).toString());
27+
console.log(`Total number of agents: ${totalLength}`);
28+
29+
// 4. Iterate through remaining agents in chunks
30+
// The getAvailableAgentsDetailedList(start, end) function uses:
31+
// - start: inclusive start index (0-based)
32+
// - end: exclusive end index (like array slicing)
33+
// Example: (0, 3) returns agents at indices 0, 1, 2
34+
for (let offset = chunkSize; offset < totalLength; offset += chunkSize) {
35+
// Calculate end index, ensuring we don't exceed totalLength
36+
const endIndex = Math.min(offset + chunkSize, totalLength);
37+
console.log(
38+
`\n--- Fetching agents ${offset} to ${endIndex - 1} (end index ${endIndex} exclusive) ---`,
39+
);
40+
41+
// Fetch the chunk of agents
42+
const agents = await assetManager.getAvailableAgentsList(offset, endIndex);
43+
console.log(agents._agents);
44+
}
45+
46+
console.log(`\nCompleted processing all ${totalLength} agents`);
4547
}
4648

47-
main().catch(error => {
48-
console.error(error);
49-
process.exitCode = 1;
49+
main().catch((error) => {
50+
console.error(error);
51+
process.exitCode = 1;
5052
});

0 commit comments

Comments
 (0)