@openzeppelin/adapter-stellar 1.0.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 +272 -0
- package/dist/config.cjs +21 -0
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +8 -0
- package/dist/config.d.cts.map +1 -0
- package/dist/config.d.mts +8 -0
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +20 -0
- package/dist/config.mjs.map +1 -0
- package/dist/index.cjs +7564 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +261 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +263 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +7529 -0
- package/dist/index.mjs.map +1 -0
- package/dist/metadata.cjs +22 -0
- package/dist/metadata.cjs.map +1 -0
- package/dist/metadata.d.cts +7 -0
- package/dist/metadata.d.cts.map +1 -0
- package/dist/metadata.d.mts +7 -0
- package/dist/metadata.d.mts.map +1 -0
- package/dist/metadata.mjs +21 -0
- package/dist/metadata.mjs.map +1 -0
- package/dist/networks-BrV516-R.d.cts +15 -0
- package/dist/networks-BrV516-R.d.cts.map +1 -0
- package/dist/networks-C0MmhJcu.d.mts +15 -0
- package/dist/networks-C0MmhJcu.d.mts.map +1 -0
- package/dist/networks-DgUFSTiC.cjs +76 -0
- package/dist/networks-DgUFSTiC.cjs.map +1 -0
- package/dist/networks-QbEPbaGT.mjs +46 -0
- package/dist/networks-QbEPbaGT.mjs.map +1 -0
- package/dist/networks.cjs +8 -0
- package/dist/networks.d.cts +2 -0
- package/dist/networks.d.mts +2 -0
- package/dist/networks.mjs +3 -0
- package/dist/vite-config.cjs +43 -0
- package/dist/vite-config.cjs.map +1 -0
- package/dist/vite-config.d.cts +35 -0
- package/dist/vite-config.d.cts.map +1 -0
- package/dist/vite-config.d.mts +35 -0
- package/dist/vite-config.d.mts.map +1 -0
- package/dist/vite-config.mjs +42 -0
- package/dist/vite-config.mjs.map +1 -0
- package/package.json +114 -0
- package/src/__tests__/getDefaultServiceConfig.test.ts +105 -0
- package/src/access-control/actions.ts +214 -0
- package/src/access-control/feature-detection.ts +238 -0
- package/src/access-control/index.ts +54 -0
- package/src/access-control/indexer-client.ts +1474 -0
- package/src/access-control/onchain-reader.ts +446 -0
- package/src/access-control/service.ts +1431 -0
- package/src/access-control/validation.ts +256 -0
- package/src/adapter.ts +659 -0
- package/src/config.ts +43 -0
- package/src/configuration/__tests__/explorer.test.ts +80 -0
- package/src/configuration/__tests__/rpc.test.ts +355 -0
- package/src/configuration/execution.ts +83 -0
- package/src/configuration/explorer.ts +105 -0
- package/src/configuration/index.ts +5 -0
- package/src/configuration/network-services.ts +210 -0
- package/src/configuration/rpc.ts +270 -0
- package/src/configuration.ts +2 -0
- package/src/contract/__tests__/complete-type-coverage.test.ts +78 -0
- package/src/contract/index.ts +3 -0
- package/src/contract/loader.ts +498 -0
- package/src/contract/transformer.ts +1 -0
- package/src/contract/type.ts +65 -0
- package/src/index.ts +23 -0
- package/src/mapping/constants.ts +89 -0
- package/src/mapping/enum-metadata.ts +237 -0
- package/src/mapping/field-generator.ts +296 -0
- package/src/mapping/index.ts +5 -0
- package/src/mapping/struct-fields.ts +106 -0
- package/src/mapping/tuple-components.ts +43 -0
- package/src/mapping/type-coverage-validator.ts +151 -0
- package/src/mapping/type-mapper.ts +203 -0
- package/src/metadata.ts +16 -0
- package/src/networks/README.md +84 -0
- package/src/networks/index.ts +19 -0
- package/src/networks/mainnet.ts +20 -0
- package/src/networks/testnet.ts +20 -0
- package/src/networks.ts +2 -0
- package/src/query/handler.ts +411 -0
- package/src/query/index.ts +4 -0
- package/src/query/view-checker.ts +32 -0
- package/src/sac/spec-cache.ts +68 -0
- package/src/sac/spec-source.ts +35 -0
- package/src/sac/xdr.ts +101 -0
- package/src/transaction/components/AdvancedInfo.tsx +34 -0
- package/src/transaction/components/FeeConfiguration.tsx +41 -0
- package/src/transaction/components/StellarRelayerOptions.tsx +60 -0
- package/src/transaction/components/TransactionTiming.tsx +77 -0
- package/src/transaction/components/index.ts +5 -0
- package/src/transaction/components/useStellarRelayerOptions.ts +114 -0
- package/src/transaction/eoa.ts +229 -0
- package/src/transaction/execution-strategy.ts +33 -0
- package/src/transaction/formatter.ts +296 -0
- package/src/transaction/index.ts +4 -0
- package/src/transaction/relayer.ts +575 -0
- package/src/transaction/sender.ts +156 -0
- package/src/transform/index.ts +4 -0
- package/src/transform/input-parser.ts +9 -0
- package/src/transform/output-formatter.ts +133 -0
- package/src/transform/parsers/complex-parser.ts +157 -0
- package/src/transform/parsers/generic-parser.ts +171 -0
- package/src/transform/parsers/index.ts +86 -0
- package/src/transform/parsers/primitive-parser.ts +123 -0
- package/src/transform/parsers/scval-converter.ts +405 -0
- package/src/transform/parsers/struct-parser.ts +324 -0
- package/src/transform/parsers/types.ts +35 -0
- package/src/types/__tests__/artifacts.test.ts +89 -0
- package/src/types/artifacts.ts +19 -0
- package/src/utils/__tests__/artifacts.test.ts +77 -0
- package/src/utils/artifacts.ts +30 -0
- package/src/utils/formatting.ts +122 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/input-parsing.ts +336 -0
- package/src/utils/safe-type-parser.ts +303 -0
- package/src/utils/stellar-types.ts +35 -0
- package/src/utils/type-detection.ts +163 -0
- package/src/utils/xdr-ordering.ts +36 -0
- package/src/validation/__tests__/address.test.ts +267 -0
- package/src/validation/address.ts +136 -0
- package/src/validation/eoa.ts +33 -0
- package/src/validation/index.ts +3 -0
- package/src/validation/relayer.ts +13 -0
- package/src/vite-config.ts +67 -0
- package/src/wallet/README.md +93 -0
- package/src/wallet/__tests__/connection.test.ts +72 -0
- package/src/wallet/components/StellarWalletUiRoot.tsx +161 -0
- package/src/wallet/components/account/AccountDisplay.tsx +50 -0
- package/src/wallet/components/connect/ConnectButton.tsx +100 -0
- package/src/wallet/components/connect/ConnectorDialog.tsx +125 -0
- package/src/wallet/components/index.ts +3 -0
- package/src/wallet/connection.ts +151 -0
- package/src/wallet/context/StellarWalletContext.ts +32 -0
- package/src/wallet/context/index.ts +4 -0
- package/src/wallet/context/useStellarWalletContext.ts +17 -0
- package/src/wallet/hooks/facade-hooks.ts +31 -0
- package/src/wallet/hooks/index.ts +7 -0
- package/src/wallet/hooks/useStellarAccount.ts +27 -0
- package/src/wallet/hooks/useStellarConnect.ts +60 -0
- package/src/wallet/hooks/useStellarDisconnect.ts +47 -0
- package/src/wallet/hooks/useUiKitConfig.ts +40 -0
- package/src/wallet/implementation/wallets-kit-implementation.ts +379 -0
- package/src/wallet/index.ts +11 -0
- package/src/wallet/services/__tests__/configResolutionService.test.ts +163 -0
- package/src/wallet/services/configResolutionService.ts +65 -0
- package/src/wallet/stellar-wallets-kit/StellarWalletsKitConnectButton.tsx +82 -0
- package/src/wallet/stellar-wallets-kit/__mocks__/@creit.tech/stellar-wallets-kit.ts +48 -0
- package/src/wallet/stellar-wallets-kit/__tests__/export-service.test.ts +93 -0
- package/src/wallet/stellar-wallets-kit/__tests__/stellarUiKitManager.test.ts +0 -0
- package/src/wallet/stellar-wallets-kit/config-generator.ts +75 -0
- package/src/wallet/stellar-wallets-kit/export-service.ts +19 -0
- package/src/wallet/stellar-wallets-kit/index.ts +3 -0
- package/src/wallet/stellar-wallets-kit/stellarUiKitManager.ts +235 -0
- package/src/wallet/types.ts +19 -0
- package/src/wallet/utils/__tests__/filterWalletComponents.test.ts +150 -0
- package/src/wallet/utils/__tests__/uiKitService.test.ts +189 -0
- package/src/wallet/utils/filterWalletComponents.ts +89 -0
- package/src/wallet/utils/index.ts +3 -0
- package/src/wallet/utils/stellarWalletImplementationManager.ts +118 -0
- package/src/wallet/utils/uiKitService.ts +74 -0
package/README.md
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# Stellar Adapter (`@openzeppelin/adapter-stellar`)
|
|
2
|
+
|
|
3
|
+
This package provides the `ContractAdapter` implementation for the Stellar (Soroban) ecosystem for the UI Builder.
|
|
4
|
+
|
|
5
|
+
It is responsible for:
|
|
6
|
+
|
|
7
|
+
- Implementing the `ContractAdapter` interface from `@openzeppelin/ui-types`.
|
|
8
|
+
- Defining and exporting Stellar network configurations (Public Network and Testnet) as `StellarNetworkConfig` objects in `src/networks/` (Horizon URL, Soroban RPC URL, network passphrase, explorer URL, icon, etc.).
|
|
9
|
+
- Loading Stellar contract definitions and metadata and transforming them into the builder’s chain‑agnostic `ContractSchema`.
|
|
10
|
+
- Mapping Soroban value types to builder form fields and validating user input.
|
|
11
|
+
- Parsing user inputs into Soroban `ScVal` types for transaction execution and formatting view results.
|
|
12
|
+
- Transaction execution using an execution strategy pattern (EOA and Relayer strategies).
|
|
13
|
+
- Wallet integration and UI via the `src/wallet/` module.
|
|
14
|
+
- Adapter‑specific configuration and validation helpers (RPC resolution, explorer URLs, execution configuration validation).
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Transaction Execution
|
|
19
|
+
|
|
20
|
+
The Stellar adapter uses an execution strategy pattern similar to the EVM adapter to handle transaction submissions.
|
|
21
|
+
|
|
22
|
+
### Supported Strategies
|
|
23
|
+
|
|
24
|
+
1. EOA (Externally Owned Account): Uses the connected Stellar wallet (via Stellar Wallets Kit) to sign and submit Soroban transactions directly.
|
|
25
|
+
2. Relayer: Uses the OpenZeppelin Relayer service to submit transactions. The adapter exposes a `StellarRelayerOptions` React component to configure strategy‑specific options in the Builder UI.
|
|
26
|
+
|
|
27
|
+
The adapter selects the strategy at runtime based on the `ExecutionConfig` provided by the application.
|
|
28
|
+
|
|
29
|
+
### Configuration in the Builder
|
|
30
|
+
|
|
31
|
+
The Builder application’s “Customize” step passes an `ExecutionConfig` to the adapter’s `signAndBroadcast` method. The adapter uses a factory to instantiate the appropriate strategy and reports live status updates via the provided `onStatusChange` callback.
|
|
32
|
+
|
|
33
|
+
---
|
|
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
|
+
|
|
121
|
+
## Wallet Integration & UI
|
|
122
|
+
|
|
123
|
+
All wallet integration logic, UI components, facade hooks, and the UI context provider for Stellar are located in `src/wallet/`.
|
|
124
|
+
|
|
125
|
+
The `StellarAdapter` implements the optional UI methods from `ContractAdapter`:
|
|
126
|
+
|
|
127
|
+
- `getEcosystemReactUiContextProvider()` returns `StellarWalletUiRoot`, a stable provider root for Stellar wallet state.
|
|
128
|
+
- `getEcosystemReactHooks()` returns `stellarFacadeHooks` for account and connection status.
|
|
129
|
+
- `getEcosystemWalletComponents()` returns available wallet UI components (e.g., `ConnectButton`, `AccountDisplay`) for the active UI kit.
|
|
130
|
+
|
|
131
|
+
For full documentation on the wallet module, see `src/wallet/README.md`.
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
This adapter follows the standard module structure outlined in the main project Adapter Architecture Guide.
|
|
136
|
+
|
|
137
|
+
## Package Structure
|
|
138
|
+
|
|
139
|
+
```text
|
|
140
|
+
adapter-stellar/
|
|
141
|
+
├── src/
|
|
142
|
+
│ ├── access-control/ # Access Control & Ownable support (service, indexer)
|
|
143
|
+
│ ├── configuration/ # Adapter-specific configuration (RPC, explorer, execution)
|
|
144
|
+
│ ├── contract/ # Contract loading & metadata
|
|
145
|
+
│ ├── mapping/ # Soroban ↔ form field mapping & generators
|
|
146
|
+
│ ├── networks/ # Stellar network configurations
|
|
147
|
+
│ ├── query/ # View function execution
|
|
148
|
+
│ ├── transaction/ # Transaction execution system (EOA, Relayer)
|
|
149
|
+
│ │ ├── components/ # React components for configuration
|
|
150
|
+
│ │ ├── formatter.ts # Build Soroban tx data from form inputs
|
|
151
|
+
│ │ ├── execution-strategy.ts # Strategy interface
|
|
152
|
+
│ │ ├── eoa.ts / relayer.ts # Strategy implementations
|
|
153
|
+
│ ├── transform/ # Input parsing and output formatting
|
|
154
|
+
│ ├── types/ # Adapter-specific types
|
|
155
|
+
│ ├── utils/ # Utilities (artifact handling, formatting, etc.)
|
|
156
|
+
│ ├── validation/ # Validation utilities (addresses, configs)
|
|
157
|
+
│ ├── wallet/ # Wallet integration (see wallet/README.md)
|
|
158
|
+
│ │ ├── components/ # Wallet UI components
|
|
159
|
+
│ │ ├── context/ # Wallet context
|
|
160
|
+
│ │ ├── hooks/ # Facade & low-level hooks
|
|
161
|
+
│ │ ├── implementation/ # Stellar Wallets Kit implementation
|
|
162
|
+
│ │ ├── services/ # Config resolution for wallet UI
|
|
163
|
+
│ │ ├── stellar-wallets-kit/ # Kit-specific helpers
|
|
164
|
+
│ │ ├── README.md # Detailed wallet documentation
|
|
165
|
+
│ ├── adapter.ts # Main StellarAdapter class implementation
|
|
166
|
+
│ └── index.ts # Public package exports
|
|
167
|
+
├── package.json
|
|
168
|
+
├── tsconfig.json
|
|
169
|
+
├── tsup.config.ts
|
|
170
|
+
├── vitest.config.ts
|
|
171
|
+
└── README.md
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Usage (Adapter Instantiation)
|
|
177
|
+
|
|
178
|
+
Instantiate the adapter with a specific `StellarNetworkConfig`:
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
import { StellarAdapter, stellarTestnet } from '@openzeppelin/adapter-stellar';
|
|
182
|
+
|
|
183
|
+
const networkConfig = stellarTestnet; // or stellarPublic
|
|
184
|
+
const stellarAdapter = new StellarAdapter(networkConfig);
|
|
185
|
+
|
|
186
|
+
// Use stellarAdapter for operations on the configured Stellar network
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Network configurations for Stellar networks are exported from `src/networks/index.ts` (`stellarPublic`, `stellarTestnet`, arrays `stellarMainnetNetworks`, `stellarTestnetNetworks`, and `stellarNetworks`).
|
|
190
|
+
|
|
191
|
+
## Soroban RPC URL Configuration
|
|
192
|
+
|
|
193
|
+
Each `StellarNetworkConfig` specifies a default `sorobanRpcUrl`.
|
|
194
|
+
|
|
195
|
+
This URL can be overridden at runtime by the consuming application through the central `AppConfigService`. Configuration is loaded from environment variables (for the Builder app) or a `public/app.config.json` file (for exported apps).
|
|
196
|
+
|
|
197
|
+
To override a RPC URL, define an entry in `rpcEndpoints` keyed by the network’s string ID (e.g., `"stellar-testnet"`).
|
|
198
|
+
|
|
199
|
+
In `.env` for the Builder app:
|
|
200
|
+
`VITE_APP_CFG_RPC_ENDPOINT_STELLAR_TESTNET="https://your-custom-soroban-rpc.testnet.example"`
|
|
201
|
+
|
|
202
|
+
In `public/app.config.json` for an exported app:
|
|
203
|
+
|
|
204
|
+
```json
|
|
205
|
+
{
|
|
206
|
+
"rpcEndpoints": {
|
|
207
|
+
"stellar-testnet": "https://your-custom-soroban-rpc.testnet.example",
|
|
208
|
+
"stellar-public": "https://your-custom-soroban-rpc.public.example"
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
The adapter resolves Soroban RPC in this order:
|
|
214
|
+
|
|
215
|
+
1. User-provided RPC config from `UserRpcConfigService` (advanced user input)
|
|
216
|
+
2. RPC override via `AppConfigService.getRpcEndpointOverride(networkId)`
|
|
217
|
+
3. Default `sorobanRpcUrl` from the active `StellarNetworkConfig`
|
|
218
|
+
|
|
219
|
+
## Explorer URLs
|
|
220
|
+
|
|
221
|
+
Stellar explorers are used for display only. The adapter constructs URLs using `explorerUrl` from the network config:
|
|
222
|
+
|
|
223
|
+
- `getExplorerUrl(address)` → `.../account/{address}` or `.../contract/{id}` (Soroban contracts)
|
|
224
|
+
- `getExplorerTxUrl(txHash)` → `.../tx/{hash}`
|
|
225
|
+
|
|
226
|
+
No explorer API keys are required for adapter functionality.
|
|
227
|
+
|
|
228
|
+
## Network Configurations
|
|
229
|
+
|
|
230
|
+
Stellar networks are exported from `src/networks/`. Each `StellarNetworkConfig` includes:
|
|
231
|
+
|
|
232
|
+
- `id`: Unique network identifier (e.g., `"stellar-public"`, `"stellar-testnet"`)
|
|
233
|
+
- `name`: Display name
|
|
234
|
+
- `ecosystem`: Always `"stellar"`
|
|
235
|
+
- `network`: Always `"stellar"`
|
|
236
|
+
- `type`: `"mainnet"` or `"testnet"`
|
|
237
|
+
- `isTestnet`: boolean
|
|
238
|
+
- `horizonUrl`: Horizon endpoint for the network
|
|
239
|
+
- `sorobanRpcUrl`: Soroban JSON-RPC endpoint
|
|
240
|
+
- `networkPassphrase`: The network passphrase used by Wallets Kit / SDK
|
|
241
|
+
- `explorerUrl`: Base URL for the explorer (display only)
|
|
242
|
+
- `icon`: Icon identifier
|
|
243
|
+
|
|
244
|
+
See `src/networks/README.md` for details on adding networks and overriding RPC.
|
|
245
|
+
|
|
246
|
+
## Stellar Asset Contract (SAC) Support
|
|
247
|
+
|
|
248
|
+
The adapter fully supports Stellar Asset Contracts (SACs), which are special contracts that wrap native Stellar assets. SACs are automatically detected via RPC ledger entries and their specifications are loaded dynamically.
|
|
249
|
+
|
|
250
|
+
### How SAC Support Works
|
|
251
|
+
|
|
252
|
+
1. **Detection**: When loading a contract, the adapter checks its executable type via RPC
|
|
253
|
+
2. **Specification Loading**: For SAC contracts, the adapter fetches the official SAC specification from GitHub
|
|
254
|
+
3. **XDR Encoding**: The JSON spec is converted to XDR format using `@stellar/stellar-xdr-json`
|
|
255
|
+
4. **UI Generation**: The adapter generates the same UI fields as regular WASM contracts
|
|
256
|
+
|
|
257
|
+
### Technical Implementation Details
|
|
258
|
+
|
|
259
|
+
#### WASM Loading Strategy
|
|
260
|
+
|
|
261
|
+
The `@stellar/stellar-xdr-json` library requires a ~3MB WebAssembly module for XDR encoding. After extensive testing with various Vite bundling approaches (including `vite-plugin-wasm`, `vite-plugin-top-level-await`, and `?url` imports), we encountered persistent issues where Vite would serve HTML instead of the WASM binary, resulting in WebAssembly instantiation errors.
|
|
262
|
+
|
|
263
|
+
**Solution**: The WASM module is loaded from CDN (`unpkg.com`) rather than bundled. This approach:
|
|
264
|
+
|
|
265
|
+
- Avoids Vite bundling complexities and errors
|
|
266
|
+
- Reduces bundle size by 3MB for users who don't use SAC contracts
|
|
267
|
+
- Loads the WASM only when a SAC contract is actually detected (lazy loading)
|
|
268
|
+
- Simplifies the build configuration
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
This adapter generally follows the standard module structure and developer experience provided by the EVM adapter, while keeping the core app chain‑agnostic.
|
package/dist/config.cjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/config.ts
|
|
3
|
+
const stellarAdapterConfig = { dependencies: {
|
|
4
|
+
runtime: {
|
|
5
|
+
"@stellar/stellar-sdk": "^14.1.1",
|
|
6
|
+
"@stellar/stellar-xdr-json": "^23.0.0",
|
|
7
|
+
"lossless-json": "^4.0.2",
|
|
8
|
+
"@creit.tech/stellar-wallets-kit": "^1.9.5",
|
|
9
|
+
"@openzeppelin/relayer-sdk": "1.9.0",
|
|
10
|
+
react: "^19.0.0",
|
|
11
|
+
"react-dom": "^19.0.0"
|
|
12
|
+
},
|
|
13
|
+
dev: {
|
|
14
|
+
"@types/react": "^19.0.0",
|
|
15
|
+
"@types/react-dom": "^19.0.0"
|
|
16
|
+
}
|
|
17
|
+
} };
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.stellarAdapterConfig = stellarAdapterConfig;
|
|
21
|
+
//# sourceMappingURL=config.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.cjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["/**\n * Configuration for the Stellar adapter\n *\n * This file defines the dependencies required by the Stellar adapter\n * when generating exported projects. It follows the AdapterConfig\n * interface to provide a structured approach to dependency management.\n */\nimport type { AdapterConfig } from '@openzeppelin/ui-types';\n\nexport const stellarAdapterConfig: AdapterConfig = {\n /**\n * Dependencies required by the Stellar adapter\n * These will be included in exported projects that use this adapter\n */\n dependencies: {\n // Runtime dependencies\n runtime: {\n // Core Stellar libraries\n '@stellar/stellar-sdk': '^14.1.1',\n\n // SAC (Stellar Asset Contract) support - dynamically loaded from CDN\n // These are needed for XDR encoding when working with SAC contracts\n '@stellar/stellar-xdr-json': '^23.0.0',\n 'lossless-json': '^4.0.2',\n\n // Wallet connection and integration\n '@creit.tech/stellar-wallets-kit': '^1.9.5',\n\n // OpenZeppelin Relayer integration for gasless transactions\n '@openzeppelin/relayer-sdk': '1.9.0',\n\n // React integration for wallet components\n react: '^19.0.0',\n 'react-dom': '^19.0.0',\n },\n\n // Development dependencies\n dev: {\n '@types/react': '^19.0.0',\n '@types/react-dom': '^19.0.0',\n },\n },\n};\n"],"mappings":";;AASA,MAAa,uBAAsC,EAKjD,cAAc;CAEZ,SAAS;EAEP,wBAAwB;EAIxB,6BAA6B;EAC7B,iBAAiB;EAGjB,mCAAmC;EAGnC,6BAA6B;EAG7B,OAAO;EACP,aAAa;EACd;CAGD,KAAK;EACH,gBAAgB;EAChB,oBAAoB;EACrB;CACF,EACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.cts","names":[],"sources":["../src/config.ts"],"sourcesContent":[],"mappings":";;;;cASa,sBAAsB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.mts","names":[],"sources":["../src/config.ts"],"sourcesContent":[],"mappings":";;;;cASa,sBAAsB"}
|
package/dist/config.mjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/config.ts
|
|
2
|
+
const stellarAdapterConfig = { dependencies: {
|
|
3
|
+
runtime: {
|
|
4
|
+
"@stellar/stellar-sdk": "^14.1.1",
|
|
5
|
+
"@stellar/stellar-xdr-json": "^23.0.0",
|
|
6
|
+
"lossless-json": "^4.0.2",
|
|
7
|
+
"@creit.tech/stellar-wallets-kit": "^1.9.5",
|
|
8
|
+
"@openzeppelin/relayer-sdk": "1.9.0",
|
|
9
|
+
react: "^19.0.0",
|
|
10
|
+
"react-dom": "^19.0.0"
|
|
11
|
+
},
|
|
12
|
+
dev: {
|
|
13
|
+
"@types/react": "^19.0.0",
|
|
14
|
+
"@types/react-dom": "^19.0.0"
|
|
15
|
+
}
|
|
16
|
+
} };
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { stellarAdapterConfig };
|
|
20
|
+
//# sourceMappingURL=config.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["/**\n * Configuration for the Stellar adapter\n *\n * This file defines the dependencies required by the Stellar adapter\n * when generating exported projects. It follows the AdapterConfig\n * interface to provide a structured approach to dependency management.\n */\nimport type { AdapterConfig } from '@openzeppelin/ui-types';\n\nexport const stellarAdapterConfig: AdapterConfig = {\n /**\n * Dependencies required by the Stellar adapter\n * These will be included in exported projects that use this adapter\n */\n dependencies: {\n // Runtime dependencies\n runtime: {\n // Core Stellar libraries\n '@stellar/stellar-sdk': '^14.1.1',\n\n // SAC (Stellar Asset Contract) support - dynamically loaded from CDN\n // These are needed for XDR encoding when working with SAC contracts\n '@stellar/stellar-xdr-json': '^23.0.0',\n 'lossless-json': '^4.0.2',\n\n // Wallet connection and integration\n '@creit.tech/stellar-wallets-kit': '^1.9.5',\n\n // OpenZeppelin Relayer integration for gasless transactions\n '@openzeppelin/relayer-sdk': '1.9.0',\n\n // React integration for wallet components\n react: '^19.0.0',\n 'react-dom': '^19.0.0',\n },\n\n // Development dependencies\n dev: {\n '@types/react': '^19.0.0',\n '@types/react-dom': '^19.0.0',\n },\n },\n};\n"],"mappings":";AASA,MAAa,uBAAsC,EAKjD,cAAc;CAEZ,SAAS;EAEP,wBAAwB;EAIxB,6BAA6B;EAC7B,iBAAiB;EAGjB,mCAAmC;EAGnC,6BAA6B;EAG7B,OAAO;EACP,aAAa;EACd;CAGD,KAAK;EACH,gBAAgB;EAChB,oBAAoB;EACrB;CACF,EACF"}
|