@lit-protocol/vincent-policy-contract-whitelist 0.0.10-mma → 0.0.12-mma
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lit-protocol/vincent-policy-contract-whitelist",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12-mma",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
"ethers": "^5.8.0",
|
|
9
9
|
"tslib": "2.8.1",
|
|
10
10
|
"zod": "^3.25.64",
|
|
11
|
-
"@lit-protocol/vincent-ability-sdk": "0.0.
|
|
11
|
+
"@lit-protocol/vincent-ability-sdk": "0.0.12-mma"
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"@lit-protocol/vincent-app-sdk": "^0.0.
|
|
14
|
+
"@lit-protocol/vincent-app-sdk": "^0.0.12-mma"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"esbuild": "^0.19.12",
|
package/dist/CHANGELOG.md
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# 1.0.0 (2025-08-05)
|
|
2
|
-
|
|
3
|
-
### ⚠️ Breaking Changes
|
|
4
|
-
|
|
5
|
-
- #### Define uiSchema/jsonSchema for registry usage ([cebcee0c](https://github.com/LIT-Protocol/Vincent/commit/cebcee0c))
|
|
6
|
-
|
|
7
|
-
### 🧱 Updated Dependencies
|
|
8
|
-
|
|
9
|
-
- Updated ability-sdk to 2.0.0
|
|
10
|
-
- Updated app-sdk to 2.0.0
|
|
11
|
-
|
|
12
|
-
### ❤️ Thank You
|
|
13
|
-
|
|
14
|
-
- Daryl Collins
|
package/dist/CONTRIBUTING.md
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
# Contributing to Vincent Policy Contract Whitelist
|
|
2
|
-
|
|
3
|
-
This document provides guidelines for contributing to the Vincent Policy Contract Whitelist project.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
<!-- TODO -->
|
|
8
|
-
|
|
9
|
-
## Setup
|
|
10
|
-
|
|
11
|
-
1. Follow the global setup instructions in the repository root [CONTRIBUTING.md](../../../CONTRIBUTING.md).
|
|
12
|
-
2. Install dependencies:
|
|
13
|
-
```bash
|
|
14
|
-
pnpm install
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Development Workflow
|
|
18
|
-
|
|
19
|
-
### Testing
|
|
20
|
-
|
|
21
|
-
Run tests:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
nx test policy-contract-whitelist
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### Building the Lit Action
|
|
28
|
-
|
|
29
|
-
Build the policy:
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
nx action:build policy-contract-whitelist
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### Deploying the Lit Action to IPFS
|
|
36
|
-
|
|
37
|
-
Building will be done automatically. Deploy the policy:
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
nx action:deploy policy-contract-whitelist
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Project Structure
|
|
44
|
-
|
|
45
|
-
- `src/`: Source code
|
|
46
|
-
- `index.ts`: Main entry point
|
|
47
|
-
|
|
48
|
-
## Policy Development Guidelines
|
|
49
|
-
|
|
50
|
-
1. Use the Vincent Ability SDK to create policies
|
|
51
|
-
2. Define clear schemas for ability parameters and user parameters
|
|
52
|
-
3. Implement the policy lifecycle methods (evaluate, commit)
|
|
53
|
-
4. Handle errors gracefully
|
|
54
|
-
5. Write comprehensive tests for all functionality
|
|
55
|
-
6. Document the policy's purpose and usage
|
|
56
|
-
|
|
57
|
-
## Integration with Abilities
|
|
58
|
-
|
|
59
|
-
<!-- TODO -->
|
|
60
|
-
|
|
61
|
-
## Testing
|
|
62
|
-
|
|
63
|
-
Write unit tests for all functionality:
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
pnpm test
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## Documentation
|
|
70
|
-
|
|
71
|
-
- Document the policy's purpose and usage
|
|
72
|
-
- Update README.md when adding new features
|
|
73
|
-
- Document the policy's parameters and behavior
|
|
74
|
-
|
|
75
|
-
## Pull Request Process
|
|
76
|
-
|
|
77
|
-
1. Ensure your code follows the coding standards
|
|
78
|
-
2. Update documentation if necessary
|
|
79
|
-
3. Include tests for new functionality
|
|
80
|
-
4. Link any related issues in your pull request description
|
|
81
|
-
5. Request a review from a maintainer
|
|
82
|
-
|
|
83
|
-
## Additional Resources
|
|
84
|
-
|
|
85
|
-
- [Vincent Documentation](https://docs.heyvincent.ai/)
|
|
86
|
-
- [Vincent Ability SDK Documentation](../../libs/ability-sdk/README.md)
|
package/dist/README.md
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
# Vincent Policy: Contract Whitelist
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
The Contract Whitelist Policy enforces strict access control for blockchain transactions by ensuring that Vincent Apps can only interact with
|
|
6
|
-
pre-approved smart contracts and execute specific whitelisted functions on those contracts.
|
|
7
|
-
|
|
8
|
-
This Vincent Policy is designed to work with Vincent Abilities, particularly the [@lit-protocol/vincent-ability-evm-transaction-signer](../ability-evm-transaction-signer/) ability, to provide granular control over which transactions can be signed.
|
|
9
|
-
|
|
10
|
-
## Key Features
|
|
11
|
-
|
|
12
|
-
- **Multi-chain Support**: Configure whitelists for multiple blockchain networks
|
|
13
|
-
- **Granular Function Control**: Specify which functions are whitelisted using the Solidity function signature
|
|
14
|
-
- **Wildcard Support**: Allow all functions for trusted contracts using the `*` wildcard
|
|
15
|
-
|
|
16
|
-
## How It Works
|
|
17
|
-
|
|
18
|
-
The Contract Whitelist Policy is built using the Vincent Policy SDK and validates transactions against a hierarchical whitelist. Here's how it operates:
|
|
19
|
-
|
|
20
|
-
1. **Transaction Parsing**: Receives a serialized EVM transaction and parses it using ethers.js
|
|
21
|
-
2. **Data Extraction**: Extracts the chain ID (the `chainId` field in the transaction), target contract address (the `to` field in the transaction), and function selector (first 4 bytes of the transaction `data` field)
|
|
22
|
-
3. **Whitelist Validation**: Checks the transaction against the configured on-chain whitelist:
|
|
23
|
-
- Is the chain ID whitelisted?
|
|
24
|
-
- Is the contract address whitelisted for that chain?
|
|
25
|
-
- Is the function selector allowed (explicitly or via wildcard)?
|
|
26
|
-
4. **Result**: Returns an allow or deny decision with detailed information
|
|
27
|
-
|
|
28
|
-
## Example Configuration
|
|
29
|
-
|
|
30
|
-
```typescript
|
|
31
|
-
const policyConfig = {
|
|
32
|
-
whitelist: {
|
|
33
|
-
// Ethereum Mainnet
|
|
34
|
-
'1': {
|
|
35
|
-
// WETH Contract - Specific functions only
|
|
36
|
-
'0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2': {
|
|
37
|
-
functionSelectors: [
|
|
38
|
-
'0xa9059cbb', // transfer(address,uint256)
|
|
39
|
-
'0x23b872dd', // transferFrom(address,address,uint256)
|
|
40
|
-
],
|
|
41
|
-
},
|
|
42
|
-
// USDC Contract - Single function only
|
|
43
|
-
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48': {
|
|
44
|
-
functionSelectors: [
|
|
45
|
-
'0xa9059cbb', // transfer(address,uint256)
|
|
46
|
-
],
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
// Base Mainnet
|
|
50
|
-
'8453': {
|
|
51
|
-
// Base WETH - All functions allowed via wildcard
|
|
52
|
-
'0x4200000000000000000000000000000000000006': {
|
|
53
|
-
functionSelectors: ['*'], // Allow ALL functions for this contract
|
|
54
|
-
},
|
|
55
|
-
// Another contract with mixed approach
|
|
56
|
-
'0x1234567890123456789012345678901234567890': {
|
|
57
|
-
functionSelectors: [
|
|
58
|
-
'0xa9059cbb', // transfer(address,uint256) - explicitly allowed
|
|
59
|
-
'*', // Plus all other functions via wildcard
|
|
60
|
-
],
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### Wildcard Support
|
|
68
|
-
|
|
69
|
-
The policy supports using `'*'` as a wildcard to allow all functions for a specific contract:
|
|
70
|
-
|
|
71
|
-
- **Specific selectors only**: `['0xa9059cbb', '0x23b872dd']` - Only these exact functions are allowed
|
|
72
|
-
- **Wildcard only**: `['*']` - All functions are allowed for this contract
|
|
73
|
-
- **Mixed approach**: `['0xa9059cbb', '*']` - All functions are allowed (wildcard takes precedence)
|
|
74
|
-
|
|
75
|
-
**Security Note**: Use wildcards carefully! Only use `'*'` for contracts you fully trust, as it allows any function call to that contract.
|
|
76
|
-
|
|
77
|
-
## Integration with Abilities
|
|
78
|
-
|
|
79
|
-
The Contract Whitelist Policy is designed to work seamlessly with Vincent Abilities, particularly the [Transaction Signer Ability](../ability-evm-transaction-signer/README.md):
|
|
80
|
-
|
|
81
|
-
```typescript
|
|
82
|
-
import { createVincentAbilityPolicy } from '@lit-protocol/vincent-ability-sdk';
|
|
83
|
-
import { bundledVincentPolicy } from '@lit-protocol/vincent-policy-contract-whitelist';
|
|
84
|
-
|
|
85
|
-
const ContractWhitelistPolicy = createVincentAbilityPolicy({
|
|
86
|
-
abilityParamsSchema,
|
|
87
|
-
bundledVincentPolicy,
|
|
88
|
-
abilityParameterMappings: {
|
|
89
|
-
serializedTransaction: 'serializedTransaction',
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
See the comprehensive E2E test in [contract-whitelist.spec.ts](../abilities-e2e/test-e2e/contract-whitelist.spec.ts) for a complete example of:
|
|
95
|
-
|
|
96
|
-
- Setting up permissions and the Contract Whitelist Policy
|
|
97
|
-
- Executing the Transaction Signer Ability
|
|
98
|
-
- Validating the signed transaction
|
|
99
|
-
- Broadcasting the signed transaction to the network
|
|
100
|
-
|
|
101
|
-
## Output Schemas
|
|
102
|
-
|
|
103
|
-
### Precheck/Evaluation Allow Result
|
|
104
|
-
|
|
105
|
-
```typescript
|
|
106
|
-
{
|
|
107
|
-
chainId: number; // The validated chain ID
|
|
108
|
-
contractAddress: string; // The validated contract address
|
|
109
|
-
functionSelector: string; // The validated function selector
|
|
110
|
-
wildcardUsed: boolean; // Whether the wildcard "*" was used to allow this function
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
The `wildcardUsed` property indicates whether the transaction was allowed through the wildcard (`'*'`) or through an explicit function selector:
|
|
115
|
-
|
|
116
|
-
- `true`: The function was allowed via wildcard (function selector not explicitly listed)
|
|
117
|
-
- `false`: The function was explicitly whitelisted (even if wildcard is also present)
|
|
118
|
-
|
|
119
|
-
This information is valuable for auditing and security monitoring purposes.
|
|
120
|
-
|
|
121
|
-
### Precheck/Evaluation Deny Result
|
|
122
|
-
|
|
123
|
-
```typescript
|
|
124
|
-
{
|
|
125
|
-
reason: string; // Why the transaction was denied
|
|
126
|
-
chainId?: number; // The chain ID (if available)
|
|
127
|
-
contractAddress?: string; // The contract address (if available)
|
|
128
|
-
functionSelector?: string; // The function selector (if available)
|
|
129
|
-
}
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
## Building
|
|
133
|
-
|
|
134
|
-
Run `pnpx nx build policy-contract-whitelist` to build the library.
|
|
135
|
-
|
|
136
|
-
## Running E2E tests
|
|
137
|
-
|
|
138
|
-
Run `pnpx nx run abilities-e2e:test-e2e packages/apps/abilities-e2e/test-e2e/contract-whitelist.spec.ts` to execute the E2E tests via [Jest](https://jestjs.io).
|
|
139
|
-
|
|
140
|
-
## Contributing
|
|
141
|
-
|
|
142
|
-
Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines on how to contribute to this project.
|
|
143
|
-
|
|
144
|
-
## License
|
|
145
|
-
|
|
146
|
-
This project is licensed under the MIT License - see the LICENSE file for details.
|