fetchGroup
fetchGroup
function fetches group information from the RBAC system based on the provided group ID and owner's address.
Parameters:
groupId (string)
: ID of the group to be fetched (required).owner (Address)
: address of the owner of the group (required).
Code example
import { Sdk } from "@peaq-network/sdk";
/**
* Fetches group information from the RBAC system.
* @param {string} groupId - The ID of the group to be fetched (required).
* @param {Address} owner - The address of the owner of the group (required).
* @returns {Promise<Object>} - A promise that resolves to an object containing group details.
*/
const fetchGroup = async (groupId, owner, seed) => {
const sdkInstance = await Sdk.createInstance({
baseUrl: "wss://wsspc1-qa.agung.peaq.network",
seed,
});
try {
await sdkInstance.connect();
const group = await sdkInstance.rbac.fetchGroup({
groupId: groupId,
owner: owner
});
return group;
} finally {
await sdkInstance.disconnect();
}
};
// Example usage
const groupId = "02709409-kd01-4444-8222-b5zz8512"; // Replace with the actual group ID
const ownerAddress = "5GsA2xjSBY6DhpTGKKdJ4BjUYpbBaP5wxZnvBoHSytURn6N2"; // Replace with the actual owner address
const seed = "your-seed-phrase";
fetchGroup(groupId, ownerAddress, seed)
.then((group) => {
console.log("Fetched Group:", group);
})
.catch((error) => {
console.error("Error fetching group:", error);
});
Response object
{
id: "02709409-kd01-4444-8222-b5zz8512",
name: "myGroup",
enable: true
}