Solana Adapter (@openzeppelin/contracts-ui-builder-adapter-solana)
This package provides the ContractAdapter implementation for the Solana blockchain for the UI Builder.
Note: While the basic structure is in place, including network configuration definitions, the core adapter logic for Solana-specific operations is currently a placeholder and will be implemented in future development phases.
It is intended to be responsible for:
- Implementing the
ContractAdapter interface from @openzeppelin/contracts-ui-builder-types.
- Defining and exporting specific Solana network configurations (e.g., Mainnet Beta, Devnet, Testnet) as
SolanaNetworkConfig objects. These are located in src/networks/ and include details like RPC endpoints, cluster information, explorer URLs, and commitment levels.
- Loading Solana program IDLs (Instruction Description Language).
- Mapping Solana-specific data types to the form field types.
- Parsing user input into Solana-compatible transaction instructions, according to the
SolanaNetworkConfig.
- Formatting results from on-chain program queries.
- Interacting with Solana wallets (e.g., via
@solana/wallet-adapter-base) for signing and sending transactions on the configured network.
- Providing other Solana-specific configurations and validation.
Usage
Once fully implemented, the SolanaAdapter class will be instantiated with a specific SolanaNetworkConfig object:
import { SolanaAdapter } from '@openzeppelin/contracts-ui-builder-adapter-solana';
import { SolanaNetworkConfig } from '@openzeppelin/contracts-ui-builder-types';
const placeholderNetworkConfig: SolanaNetworkConfig = {
id: 'solana-devnet',
name: 'Solana Devnet',
ecosystem: 'solana',
network: 'solana',
type: 'devnet',
isTestnet: true,
rpcEndpoint: 'https://api.devnet.solana.com',
explorerUrl: 'https://explorer.solana.com/?cluster=devnet',
commitment: 'confirmed',
};
const solanaAdapter = new SolanaAdapter(placeholderNetworkConfig);
Network configurations for Solana networks (e.g., solanaMainnetBeta, solanaDevnet) are defined and exported from src/networks/index.ts within this package. The full list is exported as solanaNetworks.
Package Structure
adapter-solana/
βββ src/
β βββ config/ # Adapter-specific configuration
β βββ idl/ # IDL (Interface Description Language) utilities
β βββ mapping/ # Type mapping utilities
β βββ networks/ # Solana network configurations
β βββ program/ # Program interaction utilities
β βββ transaction/ # Transaction execution system
β βββ validation/ # Validation utilities
β βββ wallet/ # Wallet integration (placeholder)
β βββ adapter.ts # Main SolanaAdapter class implementation
β βββ index.ts # Public package exports
βββ package.json
βββ tsconfig.json
βββ tsup.config.ts
βββ vitest.config.ts
βββ README.md
Internal Structure
This adapter follows the standard module structure outlined in the main project Adapter Architecture Guide, with the src/networks/ directory for managing its network configurations.