This repository hosts the code for a simplified client application for the Squads V4 Program. The app can be built, verified for integrity, and deployed as a static site using multiple hosting options, including self-hostable solutions like Docker with Nginx. Here’s how you can use it effectively.
- Verifiable Build: The
dist/directory contains the static files that can be verified via a hash. This ensures the integrity of the build delivered.- Verification can be done against:
- Remote URLs: Downloaded files can be verified for consistency with the expected hash.
- IPFS CID: Retrieve the build from IPFS and verify its authenticity.
- Verification can be done against:
- Self-hosting: Run the application as a Docker container using an Nginx server for fully self-managed hosting.
The following steps will guide you to build, verify, and host the application.
-
Clone the repository:
git clone https://github.com/x1-labs/squads-v4-ui cd squads-v4-ui -
Install dependencies:
yarn install --frozen-lockfile
-
Configure environment variables (optional):
cp .env.example .env
Edit
.envto customize the following variables:APP_RPC_URL: Solana RPC endpoint (default:https://rpc.testnet.x1.xyz)APP_PROGRAM_ID: Squads program ID (default:DDL3Xp6ie85DXgiPkXJ7abUyS2tGv4CGEod2DeQXQ941)APP_EXPLORER_URL: Solana explorer URL (default:https://explorer.x1.xyz)APP_SAVED_SQUAD_*: Pre-configured saved squads (see .env.example for format)
Note: These values can also be configured at runtime through the app's settings page.
-
Build the application:
yarn build
A
dist/directory will be created containing the static files. -
Generate a hash of the build:
./scripts/generate-hash.sh
To verify the files hosted at a remote URL:
- Use the
scripts/verify-remote.shscript:Replace./scripts/verify-remote.sh <REMOTE_URL> <EXPECTED_HASH>
<REMOTE_URL>with the base URL of the remote site and<EXPECTED_HASH>with the known SHA-256 hash of the build.
To verify an IPFS-hosted build:
- Ensure you have the IPFS CLI installed (
ipfs). - Use the
scripts/verify-ipfs.shscript:Replace./scripts/verify-ipfs.sh <IPFS_CID> <EXPECTED_HASH>
<IPFS_CID>with the CID of the IPFS build and<EXPECTED_HASH>with the known SHA-256 hash.
You can deploy the web app via a self-hosted Docker container using Nginx:
-
Build the Docker image:
docker build -t squads-public-v4-client . -
Run the container:
docker run -d -p 8080:80 squads-public-v4-client
The app will now be available at http://localhost:8080.
- Retrieve the hash from the running container:
docker exec <container_id> cat /var/build-metadata/hash.txt
A SHA-256 build hash is generated by combining all files in the dist/ directory in a deterministic order.
-
Run the
scripts/generate-hash.shscript:./scripts/generate-hash.sh
The output will show the computed hash of the local
dist/content. This hash should match the one provided in the deployment.
A manifest.json file is included in the build, containing references to all static assets. It ensures that asset file mappings remain consistent during deployment.
Recent hashes may be found here: Recent Hashes
The application includes a central registry system for X1 programs that manages IDLs, instruction summaries, and transaction tags. This allows for better transaction decoding and user-friendly display of on-chain data.
To add support for a new X1 program, edit the src/registry.ts file and add your program registration:
registry.register({
programId: 'YourProgramId123...', // Your program's public key
name: 'Your Program Name', // Human-readable name
idl: yourIdl, // Optional: Import your IDL JSON
instructions: {
// Define instruction-specific configurations
YourInstruction: {
summary: YourInstructionSummary, // Optional: React component for custom display summary
tags: {
label: 'Your Action',
color: 'blue', // Tag color: blue, green, purple, etc.
variant: 'subtle', // Tag style: default, outline, or subtle
},
},
},
});IDLs enable proper decoding of instruction data and accounts. Import your program's IDL JSON file and include it in the registration:
import yourProgramIdl from './lib/idls/your-program.json';
registry.register({
programId: 'YourProgramId...',
name: 'Your Program',
idl: yourProgramIdl,
// ...
});Create custom React components to display human-readable summaries of specific instructions:
// Create a summary component in src/components/instructions/summaries/
export const YourInstructionSummary: React.FC<InstructionSummaryProps> = ({ instruction, connection }) => {
return (
<div className="space-y-2 text-sm">
<div className="font-semibold">Your Action Summary</div>
{/* Display relevant instruction data */}
</div>
);
};
// Register it in src/registry.ts
instructions: {
YourInstruction: {
summary: YourInstructionSummary,
// ...
}
}Tags provide visual indicators for transaction types. They appear in the transaction table and details page:
instructions: {
Transfer: {
tags: { label: 'Token Transfer', color: 'purple', variant: 'subtle' }
},
Swap: {
tags: { label: 'Swap', color: 'green', variant: 'subtle' }
}
}You can also set default tags for all instructions in a program:
registry.register({
programId: 'YourDeFiProgram...',
name: 'Your DeFi Protocol',
defaultTags: { label: 'DeFi', color: 'blue', variant: 'subtle' },
// ...
});src/registry.ts- Main registry file with all program registrationssrc/lib/registry/- Core registry implementationsrc/lib/idls/- IDL JSON files for various programssrc/components/instructions/summaries/- Custom instruction summary componentssrc/lib/instructions/types.ts- TypeScript interfaces for the registry system
Contributions are welcome! Please fork the repository, make your changes, and open a pull request.
This project is licensed under the MIT License. Please see the included LICENSE file for details.