[Extensions] Expose permission detection logic (#4375)

### TL;DR

Exposed permission detection logic for the Extensions module.

### What changed?

- Added `is*Supported` functions for various permission-related operations.
- Exported these new functions to make them accessible to users.
- Implemented `isGetAllRoleMembersSupported` function to check if both `getRoleMember` and `getRoleMemberCount` are supported.
- Renamed `grant.ts` to `grantRole.ts` for consistency.

### How to test?

1. Import the new `is*Supported` functions from the permissions module.
2. Pass an array of contract function selectors to these functions.
3. Verify that they correctly identify whether the corresponding permission operations are supported.

Example:
```typescript
import { isGetAllRoleMembersSupported } from "thirdweb/extensions/permissions";

const supported = isGetAllRoleMembersSupported(["0x..."]);
console.log("getAllRoleMembers supported:", supported);
```

### Why make this change?

This change allows developers to programmatically detect which permission-related operations are supported by a given contract. This is particularly useful when working with contracts that may implement only a subset of the permissions interface, enabling more robust and flexible integration with various smart contracts.

---

<!-- start pr-codex -->

---

## PR-Codex overview
This PR enhances the `thirdweb` package by exposing permission detection logic for various role-related operations.

### Detailed summary
- Exposes permission detection logic for `hasRole`, `revokeRole`, `getRoleAdmin`, `renounceRole`, and more
- Renamed `grant.js` to `grantRole.js`
- Added new exports for supported permission operations
- Added a new function `isGetAllRoleMembersSupported` to check support for `getAllRoleMembers` operation

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
This commit is contained in:
jnsdls
2024-09-04 06:56:14 +00:00
parent ccaaef481c
commit edb95d00ca
11 changed files with 59 additions and 4 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---
[Extensions] expose permission detection logic