@openzeppelin/ui-builder-adapter-stellar 0.16.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -0
- package/dist/index.cjs +6235 -3679
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +6206 -3643
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
- package/src/access-control/actions.ts +214 -0
- package/src/access-control/feature-detection.ts +226 -0
- package/src/access-control/index.ts +54 -0
- package/src/access-control/indexer-client.ts +1297 -0
- package/src/access-control/onchain-reader.ts +450 -0
- package/src/access-control/service.ts +1347 -0
- package/src/access-control/validation.ts +256 -0
- package/src/adapter.ts +21 -0
- package/src/configuration/network-services.ts +130 -9
- package/src/networks/mainnet.ts +1 -0
- package/src/networks/testnet.ts +1 -0
- package/src/query/handler.ts +6 -4
- package/src/sac/xdr.ts +1 -2
- package/src/transaction/eoa.ts +8 -1
- package/src/transaction/relayer.ts +8 -1
package/README.md
CHANGED
|
@@ -32,6 +32,92 @@ The Builder application’s “Customize” step passes an `ExecutionConfig` to
|
|
|
32
32
|
|
|
33
33
|
---
|
|
34
34
|
|
|
35
|
+
## Access Control Support
|
|
36
|
+
|
|
37
|
+
The Stellar adapter includes first-class support for OpenZeppelin Access Control and Ownable contracts through a dedicated service module.
|
|
38
|
+
|
|
39
|
+
### Features
|
|
40
|
+
|
|
41
|
+
- **Feature Detection**: Automatically detects contracts implementing AccessControl, Ownable, or both
|
|
42
|
+
- **Role Management**: Query current roles, grant/revoke roles, check permissions
|
|
43
|
+
- **Ownership Management**: Transfer ownership, query current owner
|
|
44
|
+
- **Dynamic Role Discovery**: Automatically discover role IDs via indexer when not explicitly provided
|
|
45
|
+
- **Historical Queries**: View complete history of role changes and ownership transfers via SubQuery indexer
|
|
46
|
+
- **Server-Side Filtering**: Filter events by contract, role, account, and limit (when indexer is available)
|
|
47
|
+
|
|
48
|
+
### Role Discovery
|
|
49
|
+
|
|
50
|
+
Since OpenZeppelin's Stellar contracts don't expose a `get_all_roles()` method, the adapter supports multiple ways to obtain role identifiers:
|
|
51
|
+
|
|
52
|
+
#### 1. Explicit Role IDs (Recommended for known contracts)
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
const service = adapter.getAccessControlService();
|
|
56
|
+
service.registerContract(contractAddress, schema, ['admin', 'minter', 'burner']);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
#### 2. Dynamic Discovery via Indexer
|
|
60
|
+
|
|
61
|
+
If no role IDs are provided, the service automatically queries the indexer for historical `ROLE_GRANTED` and `ROLE_REVOKED` events:
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
// Register without role IDs - discovery happens automatically
|
|
65
|
+
service.registerContract(contractAddress, schema);
|
|
66
|
+
|
|
67
|
+
// Or explicitly discover roles
|
|
68
|
+
const roles = await service.discoverKnownRoleIds(contractAddress);
|
|
69
|
+
// => ['admin', 'minter', 'burner']
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
#### 3. Adding Roles Manually
|
|
73
|
+
|
|
74
|
+
For newly created roles that haven't been granted yet (no historical events), you can add them manually:
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
// Add roles that may not exist in historical events
|
|
78
|
+
service.addKnownRoleIds(contractAddress, ['new_role', 'another_role']);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Role IDs are validated against Soroban Symbol constraints:
|
|
82
|
+
|
|
83
|
+
- Must start with a letter or underscore
|
|
84
|
+
- Can contain only alphanumeric characters and underscores
|
|
85
|
+
- Maximum 32 characters
|
|
86
|
+
|
|
87
|
+
### Indexer Integration
|
|
88
|
+
|
|
89
|
+
For historical queries (e.g., `getHistory()`), the adapter integrates with the [Stellar Access Control Indexer](https://github.com/OpenZeppelin/stellar-access-control-indexer), a SubQuery project that indexes Access Control and Ownable events.
|
|
90
|
+
|
|
91
|
+
#### Configuring the Indexer
|
|
92
|
+
|
|
93
|
+
Add `indexerUri` to your `StellarNetworkConfig`:
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
const stellarTestnet: StellarNetworkConfig = {
|
|
97
|
+
// ... other config
|
|
98
|
+
indexerUri: 'https://api.subquery.network/sq/openzeppelin/stellar-access-control-indexer',
|
|
99
|
+
};
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### Deployment
|
|
103
|
+
|
|
104
|
+
The indexer is production-ready and compatible with:
|
|
105
|
+
|
|
106
|
+
- **SubQuery Network** (decentralized, recommended for production)
|
|
107
|
+
- Self-hosted infrastructure (Docker)
|
|
108
|
+
|
|
109
|
+
For deployment instructions, see the [Indexer Deployment Guide](https://github.com/OpenZeppelin/stellar-access-control-indexer/blob/main/DEPLOYMENT.md).
|
|
110
|
+
|
|
111
|
+
#### Graceful Degradation
|
|
112
|
+
|
|
113
|
+
If no indexer is configured or the indexer is unavailable:
|
|
114
|
+
|
|
115
|
+
- On-chain queries (roles, ownership) work normally
|
|
116
|
+
- Historical queries return an empty array with a warning
|
|
117
|
+
- UI remains functional for all current-state operations
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
35
121
|
## Wallet Integration & UI
|
|
36
122
|
|
|
37
123
|
All wallet integration logic, UI components, facade hooks, and the UI context provider for Stellar are located in `src/wallet/`.
|
|
@@ -53,6 +139,7 @@ This adapter follows the standard module structure outlined in the main project
|
|
|
53
139
|
```text
|
|
54
140
|
adapter-stellar/
|
|
55
141
|
├── src/
|
|
142
|
+
│ ├── access-control/ # Access Control & Ownable support (service, indexer)
|
|
56
143
|
│ ├── configuration/ # Adapter-specific configuration (RPC, explorer, execution)
|
|
57
144
|
│ ├── contract/ # Contract loading & metadata
|
|
58
145
|
│ ├── mapping/ # Soroban ↔ form field mapping & generators
|