fetchGroupPermissions
fetchGroupPermissions
function retrieves an array of permission details associated with a specific group from the RBAC system. This function returns the array with information about permissions.
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 permissions associated with a specific group from the RBAC system.
* @param {string} groupId - The ID of the group for which to fetch permissions (required).
* @param {Address} owner - The address of the owner of the group (required).
* @returns {Promise<Array<Object>>} - A promise that resolves to an array of objects containing fetched permission details.
*/
const fetchGroupPermissions = async (groupId, owner, seed) => {
const sdkInstance = await Sdk.createInstance({
baseUrl: "wss://wsspc1-qa.agung.peaq.network",
seed,
});
try {
await sdkInstance.connect();
const permissions = await sdkInstance.rbac.fetchGroupPermissions({
groupId: groupId,
owner: owner
});
return permissions;
} finally {
await sdkInstance.disconnect();
}
};
// Example usage
const groupId = "02709409-kd01-4444-8222-b5zz8512";
const ownerAddress = "5GsA2xjSBY6DhpTGKKdJ4BjUYpbBaP5wxZnvBoHSytURn6N2";
const seed = "your-seed-phrase";
fetchGroupPermissions(groupId, ownerAddress, seed)
.then((permissions) => {
console.log("Fetched Group Permissions:", permissions);
})
.catch((error) => {
console.error("Error fetching group permissions:", error);
});
Response object
[
{
"id": "18709409-bc06-4444-2222-b4zz0000",
"name": "myPermission",
"enable": true
}
]