disableRole
The disableRole
function allows to disable a specified role. A role typically represents a set of permissions and access rights within the system. This function returns a JSON object with the roleId.
Parameters:
roleId (required)
: the unique identifier of the role to be disabled.address (optional)
: address of the entity disabling the role. This parameter is optional and depends on whether the address is required for the operation.seed (optional)
: transaction signing seed of the entity disabling the role. This parameter is optional and depends on whether the seed is required for the operation.
Code example
import { Sdk } from "@peaq-network/sdk";
/**
* Disables a role within a permission management system.
* @param {string} roleId - The unique identifier of the role to be disabled.
* @param {string} [address] - The address of the entity disabling the role. Optional if address is not required.
* @param {string} [seed] - The transaction signing seed of the entity disabling the role. Optional if seed is not required.
*/
async function disableRole(roleId, seed) {
// Create an instance of the peaq network SDK
const sdkInstance = await Sdk.createInstance({
baseUrl: "wss://wsspc1-qa.agung.peaq.network",
seed,
});
try {
await sdkInstance.connect();
// Perform the role disabling operation using the SDK's rbac.disableRole method
const result = await sdkInstance.rbac.disableRole({
roleId: roleId,
});
}
catch (error) {
console.error(`Error disabling role: ${error}`);
} finally {
// Disconnect the SDK instance
await sdkInstance.disconnect();
}
}
const seed = "your-seed-phrase";
const roleId = "78709009-cf06-4224-8632-b5ee8512"
disableRole(roleId, seed)
.then((result) => {
console.log(result);
})
.catch((error) => {
console.log("Error", error)
})
Response object
{
message: "Successfully disable role: 78709009-cf06-4224-8632-b5ee8512"
}