@openzeppelin/ui-builder-adapter-stellar 0.10.0 → 0.11.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 +24 -0
- package/dist/index.cjs +425 -196
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +409 -180
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
- package/src/config.ts +5 -0
- package/src/contract/loader.ts +35 -0
- package/src/contract/type.ts +65 -0
- package/src/mapping/field-generator.ts +45 -8
- package/src/mapping/type-mapper.ts +7 -3
- package/src/sac/spec-cache.ts +68 -0
- package/src/sac/spec-source.ts +35 -0
- package/src/sac/xdr.ts +102 -0
- package/src/transform/parsers/scval-converter.ts +22 -0
- package/src/utils/formatting.ts +3 -0
- package/src/utils/type-detection.ts +4 -0
package/README.md
CHANGED
|
@@ -156,6 +156,30 @@ Stellar networks are exported from `src/networks/`. Each `StellarNetworkConfig`
|
|
|
156
156
|
|
|
157
157
|
See `src/networks/README.md` for details on adding networks and overriding RPC.
|
|
158
158
|
|
|
159
|
+
## Stellar Asset Contract (SAC) Support
|
|
160
|
+
|
|
161
|
+
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.
|
|
162
|
+
|
|
163
|
+
### How SAC Support Works
|
|
164
|
+
|
|
165
|
+
1. **Detection**: When loading a contract, the adapter checks its executable type via RPC
|
|
166
|
+
2. **Specification Loading**: For SAC contracts, the adapter fetches the official SAC specification from GitHub
|
|
167
|
+
3. **XDR Encoding**: The JSON spec is converted to XDR format using `@stellar/stellar-xdr-json`
|
|
168
|
+
4. **UI Generation**: The adapter generates the same UI fields as regular WASM contracts
|
|
169
|
+
|
|
170
|
+
### Technical Implementation Details
|
|
171
|
+
|
|
172
|
+
#### WASM Loading Strategy
|
|
173
|
+
|
|
174
|
+
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.
|
|
175
|
+
|
|
176
|
+
**Solution**: The WASM module is loaded from CDN (`unpkg.com`) rather than bundled. This approach:
|
|
177
|
+
|
|
178
|
+
- Avoids Vite bundling complexities and errors
|
|
179
|
+
- Reduces bundle size by 3MB for users who don't use SAC contracts
|
|
180
|
+
- Loads the WASM only when a SAC contract is actually detected (lazy loading)
|
|
181
|
+
- Simplifies the build configuration
|
|
182
|
+
|
|
159
183
|
---
|
|
160
184
|
|
|
161
185
|
This adapter generally follows the standard module structure and developer experience provided by the EVM adapter, while keeping the core app chain‑agnostic.
|