-
Notifications
You must be signed in to change notification settings - Fork 7
Feat/sol contract whitelist policy #349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new Solana contract whitelist policy that restricts which programs can be called by transactions signed by the @lit-protocol/vincent-ability-sol-transaction-signer Ability. Users can whitelist specific Solana program IDs for each available Solana cluster (devnet, testnet, mainnet-beta).
- Adds a new
@lit-protocol/vincent-policy-sol-contract-whitelistpackage with validation logic - Integrates the policy with the existing Solana transaction signer ability
- Updates E2E tests to verify policy enforcement across different clusters
Reviewed Changes
Copilot reviewed 34 out of 65 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/apps/policy-sol-contract-whitelist/ | New policy package implementation with schemas, validation logic, and build configuration |
| packages/apps/ability-sol-transaction-signer/ | Integration of the new whitelist policy and schema updates |
| packages/apps/abilities-e2e/ | Enhanced E2E tests to validate policy enforcement scenarios |
| nx.json | Build configuration updates |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)
packages/apps/policy-sol-contract-whitelist/src/lib/lit-action-helpers/deserializeTransaction.ts:1
- The deserialization logic is duplicated between this file and the ability's deserializeTransaction helper. Consider extracting this logic to a shared utility module to avoid code duplication and ensure consistent behavior across both implementations.
import { Transaction, VersionedTransaction } from '@solana/web3.js';
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
packages/apps/policy-sol-contract-whitelist/scripts/deploy-lit-action.js
Outdated
Show resolved
Hide resolved
packages/apps/ability-sol-transaction-signer/src/lib/vincent-ability.ts
Outdated
Show resolved
Hide resolved
| const precheckResult = await client.precheck( | ||
| { | ||
| rpcUrl: SOL_RPC_URL, | ||
| rpcUrl: null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having to pass rpcUrl: null for both precheck and execute and make the parameter .optional().nullable() in both the Policy and Ability schemas in order to support having an optional parameter for a Policy
rpcUrl is something we want as a optional param for Policy/Ability precheck because otherwise we'd be using the publically available SOL RPC packaged in the web3.js SDK. However this RPC can be throttled and rate limited, so it needs to be possible for the caller to pass their own RPC URL for precheck to function. This isn't an issue with execute because the Lit nodes have their own private RPC available
However, when defining:
const ProgramWhitelistPolicy = createVincentAbilityPolicy({
abilityParamsSchema,
bundledVincentPolicy,
abilityParameterMappings: {
rpcUrl: 'rpcUrl',
cluster: 'cluster',
serializedTransaction: 'serializedTransaction',
},
});this throws an error if rpcUrl is undefined. The workaround is to pass null but this is bad Devx because you must pass rpcUrl: null whenever the Policy is enabled for the Ability
Description
Adds a new Policy for restricting what contracts can be called by transactions signed by the
@lit-protocol/vincent-ability-sol-transaction-signerAbilityUsers whitelist specific Solana program IDs for each available Solana cluster (network i.e.
devnet,testnet,mainnet-beta)Type of change
How Has This Been Tested?
Adds the policy to the existing E2E Solana tx signer Ability tests. Verifies a transaction is permitted to sign calling a whitelisted program on
devnet, but Ability execution is denied when making a signing request to execute the same program onmainnet-beta(which has no whitelisted programs)Checklist:
nx release plan) describing my changes and the version bump