@lit-protocol/vincent-policy-contract-whitelist 0.0.1-ea

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/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ ## 0.0.2 (2025-08-01)
2
+
3
+ ### 🧱 Updated Dependencies
4
+
5
+ - Updated ability-sdk to 2.0.0
6
+ - Updated app-sdk to 2.0.0
@@ -0,0 +1,86 @@
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/README.md ADDED
@@ -0,0 +1,140 @@
1
+ # Vincent Policy: Contract Whitelist
2
+
3
+ ## Overview
4
+
5
+ The Contract Whitelist Policy is a Vincent Policy that restricts the signing of EVM transactions to a predefined whitelist of contract addresses and function selectors across multiple chains. This policy provides critical security controls for Vincent Agent Wallets by ensuring they can only interact with trusted contracts and approved functions.
6
+
7
+ 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.
8
+
9
+ ## How It Works
10
+
11
+ The Contract Whitelist Policy is built using the Vincent Policy SDK and validates transactions against a hierarchical whitelist. Here's how it operates:
12
+
13
+ - **Input**: Receives a serialized EVM transaction from the ability
14
+ - **Parsing**: Uses `ethers.utils.parseTransaction` to extract transaction details
15
+ - **Extraction**: Gets the chain ID, target contract address, and function selector (first 4 bytes of `data` field)
16
+ - **Validation**: Checks against the whitelist hierarchy
17
+ - **Whitelist Matching**: The policy checks in order:
18
+ - Is the chain ID whitelisted?
19
+ - Is the contract address whitelisted for that chain?
20
+ - Is the function selector allowed (either explicitly or via wildcard `*`)?
21
+
22
+ ## Example Configuration
23
+
24
+ ```typescript
25
+ const policyConfig = {
26
+ whitelist: {
27
+ // Ethereum Mainnet
28
+ '1': {
29
+ // WETH Contract - Specific functions only
30
+ '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2': {
31
+ functionSelectors: [
32
+ '0xa9059cbb', // transfer(address,uint256)
33
+ '0x23b872dd', // transferFrom(address,address,uint256)
34
+ ],
35
+ },
36
+ // USDC Contract - Single function only
37
+ '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48': {
38
+ functionSelectors: [
39
+ '0xa9059cbb', // transfer(address,uint256)
40
+ ],
41
+ },
42
+ },
43
+ // Base Mainnet
44
+ '8453': {
45
+ // Base WETH - All functions allowed via wildcard
46
+ '0x4200000000000000000000000000000000000006': {
47
+ functionSelectors: ['*'], // Allow ALL functions for this contract
48
+ },
49
+ // Another contract with mixed approach
50
+ '0x1234567890123456789012345678901234567890': {
51
+ functionSelectors: [
52
+ '0xa9059cbb', // transfer(address,uint256) - explicitly allowed
53
+ '*', // Plus all other functions via wildcard
54
+ ],
55
+ },
56
+ },
57
+ },
58
+ };
59
+ ```
60
+
61
+ ### Wildcard Support
62
+
63
+ The policy supports using `'*'` as a wildcard to allow all functions for a specific contract:
64
+
65
+ - **Specific selectors only**: `['0xa9059cbb', '0x23b872dd']` - Only these exact functions are allowed
66
+ - **Wildcard only**: `['*']` - All functions are allowed for this contract
67
+ - **Mixed approach**: `['0xa9059cbb', '*']` - All functions are allowed (wildcard takes precedence)
68
+
69
+ **Security Note**: Use wildcards carefully! Only use `'*'` for contracts you fully trust, as it allows any function call to that contract.
70
+
71
+ ## Integration with Abilities
72
+
73
+ The Contract Whitelist Policy is designed to work seamlessly with Vincent Abilities, particularly the [Transaction Signer Ability](../ability-evm-transaction-signer/README.md):
74
+
75
+ ```typescript
76
+ import { createVincentAbilityPolicy } from '@lit-protocol/vincent-ability-sdk';
77
+ import { bundledVincentPolicy } from '@lit-protocol/vincent-policy-contract-whitelist';
78
+
79
+ const ContractWhitelistPolicy = createVincentAbilityPolicy({
80
+ abilityParamsSchema,
81
+ bundledVincentPolicy,
82
+ abilityParameterMappings: {
83
+ serializedTransaction: 'serializedTransaction',
84
+ },
85
+ });
86
+ ```
87
+
88
+ See the comprehensive E2E test in [contract-whitelist.spec.ts](../abilities-e2e/test-e2e/contract-whitelist.spec.ts) for a complete example of:
89
+
90
+ - Setting up permissions and the Contract Whitelist Policy
91
+ - Executing the Transaction Signer Ability
92
+ - Validating the signed transaction
93
+ - Broadcasting the signed transaction to the network
94
+
95
+ ## Output Schemas
96
+
97
+ ### Precheck/Evaluation Allow Result
98
+
99
+ ```typescript
100
+ {
101
+ chainId: number; // The validated chain ID
102
+ contractAddress: string; // The validated contract address
103
+ functionSelector: string; // The validated function selector
104
+ wildcardUsed: boolean; // Whether the wildcard "*" was used to allow this function
105
+ }
106
+ ```
107
+
108
+ The `wildcardUsed` property indicates whether the transaction was allowed through the wildcard (`'*'`) or through an explicit function selector:
109
+
110
+ - `true`: The function was allowed via wildcard (function selector not explicitly listed)
111
+ - `false`: The function was explicitly whitelisted (even if wildcard is also present)
112
+
113
+ This information is valuable for auditing and security monitoring purposes.
114
+
115
+ ### Precheck/Evaluation Deny Result
116
+
117
+ ```typescript
118
+ {
119
+ reason: string; // Why the transaction was denied
120
+ chainId?: number; // The chain ID (if available)
121
+ contractAddress?: string; // The contract address (if available)
122
+ functionSelector?: string; // The function selector (if available)
123
+ }
124
+ ```
125
+
126
+ ## Building
127
+
128
+ Run `pnpx nx build policy-contract-whitelist` to build the library.
129
+
130
+ ## Running E2E tests
131
+
132
+ 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).
133
+
134
+ ## Contributing
135
+
136
+ Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines on how to contribute to this project.
137
+
138
+ ## License
139
+
140
+ This project is licensed under the MIT License - see the LICENSE file for details.
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@lit-protocol/vincent-policy-contract-whitelist",
3
+ "version": "0.0.2",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "dependencies": {
8
+ "@lit-protocol/vincent-ability-sdk": "workspace:*",
9
+ "ethers": "^5.8.0",
10
+ "tslib": "2.8.1",
11
+ "zod": "^3.25.64"
12
+ },
13
+ "peerDependencies": {
14
+ "@lit-protocol/vincent-app-sdk": "workspace:^"
15
+ },
16
+ "devDependencies": {
17
+ "esbuild": "^0.19.12",
18
+ "esbuild-plugin-polyfill-node": "^0.3.0",
19
+ "ipfs-only-hash": "^4.0.0"
20
+ },
21
+ "main": "./dist/src/index.js",
22
+ "module": "./dist/src/index.js",
23
+ "types": "./dist/src/index.d.ts",
24
+ "files": [
25
+ "dist/**",
26
+ "*.md"
27
+ ],
28
+ "type": "commonjs"
29
+ }
@@ -0,0 +1,191 @@
1
+ /**
2
+ * DO NOT EDIT THIS FILE. IT IS GENERATED ON BUILD.
3
+ */
4
+ export declare const bundledVincentPolicy: import("@lit-protocol/vincent-ability-sdk").BundledVincentPolicy<import("node_modules/@lit-protocol/vincent-ability-sdk/dist/src/lib/types").VincentPolicy<"@lit-protocol/vincent-policy-contract-whitelist", import("zod").ZodObject<{
5
+ serializedTransaction: import("zod").ZodString;
6
+ }, "strip", import("zod").ZodTypeAny, {
7
+ serializedTransaction: string;
8
+ }, {
9
+ serializedTransaction: string;
10
+ }>, import("zod").ZodObject<{
11
+ whitelist: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
12
+ functionSelectors: import("zod").ZodArray<import("zod").ZodString, "many">;
13
+ }, "strip", import("zod").ZodTypeAny, {
14
+ functionSelectors: string[];
15
+ }, {
16
+ functionSelectors: string[];
17
+ }>>>;
18
+ }, "strip", import("zod").ZodTypeAny, {
19
+ whitelist: Record<string, Record<string, {
20
+ functionSelectors: string[];
21
+ }>>;
22
+ }, {
23
+ whitelist: Record<string, Record<string, {
24
+ functionSelectors: string[];
25
+ }>>;
26
+ }>, import("zod").ZodObject<{
27
+ chainId: import("zod").ZodNumber;
28
+ contractAddress: import("zod").ZodString;
29
+ functionSelector: import("zod").ZodString;
30
+ wildcardUsed: import("zod").ZodBoolean;
31
+ }, "strip", import("zod").ZodTypeAny, {
32
+ chainId: number;
33
+ contractAddress: string;
34
+ functionSelector: string;
35
+ wildcardUsed: boolean;
36
+ }, {
37
+ chainId: number;
38
+ contractAddress: string;
39
+ functionSelector: string;
40
+ wildcardUsed: boolean;
41
+ }>, import("zod").ZodObject<{
42
+ reason: import("zod").ZodString;
43
+ chainId: import("zod").ZodOptional<import("zod").ZodNumber>;
44
+ contractAddress: import("zod").ZodOptional<import("zod").ZodString>;
45
+ functionSelector: import("zod").ZodOptional<import("zod").ZodString>;
46
+ }, "strip", import("zod").ZodTypeAny, {
47
+ reason: string;
48
+ chainId?: number | undefined;
49
+ contractAddress?: string | undefined;
50
+ functionSelector?: string | undefined;
51
+ }, {
52
+ reason: string;
53
+ chainId?: number | undefined;
54
+ contractAddress?: string | undefined;
55
+ functionSelector?: string | undefined;
56
+ }>, import("zod").ZodObject<{
57
+ chainId: import("zod").ZodNumber;
58
+ contractAddress: import("zod").ZodString;
59
+ functionSelector: import("zod").ZodString;
60
+ wildcardUsed: import("zod").ZodBoolean;
61
+ }, "strip", import("zod").ZodTypeAny, {
62
+ chainId: number;
63
+ contractAddress: string;
64
+ functionSelector: string;
65
+ wildcardUsed: boolean;
66
+ }, {
67
+ chainId: number;
68
+ contractAddress: string;
69
+ functionSelector: string;
70
+ wildcardUsed: boolean;
71
+ }>, import("zod").ZodObject<{
72
+ reason: import("zod").ZodString;
73
+ chainId: import("zod").ZodOptional<import("zod").ZodNumber>;
74
+ contractAddress: import("zod").ZodOptional<import("zod").ZodString>;
75
+ functionSelector: import("zod").ZodOptional<import("zod").ZodString>;
76
+ }, "strip", import("zod").ZodTypeAny, {
77
+ reason: string;
78
+ chainId?: number | undefined;
79
+ contractAddress?: string | undefined;
80
+ functionSelector?: string | undefined;
81
+ }, {
82
+ reason: string;
83
+ chainId?: number | undefined;
84
+ contractAddress?: string | undefined;
85
+ functionSelector?: string | undefined;
86
+ }>, import("zod").ZodUndefined, import("zod").ZodUndefined, import("zod").ZodUndefined, import("node_modules/@lit-protocol/vincent-ability-sdk/dist/src/lib/types").PolicyLifecycleFunction<import("zod").ZodObject<{
87
+ serializedTransaction: import("zod").ZodString;
88
+ }, "strip", import("zod").ZodTypeAny, {
89
+ serializedTransaction: string;
90
+ }, {
91
+ serializedTransaction: string;
92
+ }>, import("zod").ZodObject<{
93
+ whitelist: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
94
+ functionSelectors: import("zod").ZodArray<import("zod").ZodString, "many">;
95
+ }, "strip", import("zod").ZodTypeAny, {
96
+ functionSelectors: string[];
97
+ }, {
98
+ functionSelectors: string[];
99
+ }>>>;
100
+ }, "strip", import("zod").ZodTypeAny, {
101
+ whitelist: Record<string, Record<string, {
102
+ functionSelectors: string[];
103
+ }>>;
104
+ }, {
105
+ whitelist: Record<string, Record<string, {
106
+ functionSelectors: string[];
107
+ }>>;
108
+ }>, import("zod").ZodObject<{
109
+ chainId: import("zod").ZodNumber;
110
+ contractAddress: import("zod").ZodString;
111
+ functionSelector: import("zod").ZodString;
112
+ wildcardUsed: import("zod").ZodBoolean;
113
+ }, "strip", import("zod").ZodTypeAny, {
114
+ chainId: number;
115
+ contractAddress: string;
116
+ functionSelector: string;
117
+ wildcardUsed: boolean;
118
+ }, {
119
+ chainId: number;
120
+ contractAddress: string;
121
+ functionSelector: string;
122
+ wildcardUsed: boolean;
123
+ }>, import("zod").ZodObject<{
124
+ reason: import("zod").ZodString;
125
+ chainId: import("zod").ZodOptional<import("zod").ZodNumber>;
126
+ contractAddress: import("zod").ZodOptional<import("zod").ZodString>;
127
+ functionSelector: import("zod").ZodOptional<import("zod").ZodString>;
128
+ }, "strip", import("zod").ZodTypeAny, {
129
+ reason: string;
130
+ chainId?: number | undefined;
131
+ contractAddress?: string | undefined;
132
+ functionSelector?: string | undefined;
133
+ }, {
134
+ reason: string;
135
+ chainId?: number | undefined;
136
+ contractAddress?: string | undefined;
137
+ functionSelector?: string | undefined;
138
+ }>>, import("node_modules/@lit-protocol/vincent-ability-sdk/dist/src/lib/types").PolicyLifecycleFunction<import("zod").ZodObject<{
139
+ serializedTransaction: import("zod").ZodString;
140
+ }, "strip", import("zod").ZodTypeAny, {
141
+ serializedTransaction: string;
142
+ }, {
143
+ serializedTransaction: string;
144
+ }>, import("zod").ZodObject<{
145
+ whitelist: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
146
+ functionSelectors: import("zod").ZodArray<import("zod").ZodString, "many">;
147
+ }, "strip", import("zod").ZodTypeAny, {
148
+ functionSelectors: string[];
149
+ }, {
150
+ functionSelectors: string[];
151
+ }>>>;
152
+ }, "strip", import("zod").ZodTypeAny, {
153
+ whitelist: Record<string, Record<string, {
154
+ functionSelectors: string[];
155
+ }>>;
156
+ }, {
157
+ whitelist: Record<string, Record<string, {
158
+ functionSelectors: string[];
159
+ }>>;
160
+ }>, import("zod").ZodObject<{
161
+ chainId: import("zod").ZodNumber;
162
+ contractAddress: import("zod").ZodString;
163
+ functionSelector: import("zod").ZodString;
164
+ wildcardUsed: import("zod").ZodBoolean;
165
+ }, "strip", import("zod").ZodTypeAny, {
166
+ chainId: number;
167
+ contractAddress: string;
168
+ functionSelector: string;
169
+ wildcardUsed: boolean;
170
+ }, {
171
+ chainId: number;
172
+ contractAddress: string;
173
+ functionSelector: string;
174
+ wildcardUsed: boolean;
175
+ }>, import("zod").ZodObject<{
176
+ reason: import("zod").ZodString;
177
+ chainId: import("zod").ZodOptional<import("zod").ZodNumber>;
178
+ contractAddress: import("zod").ZodOptional<import("zod").ZodString>;
179
+ functionSelector: import("zod").ZodOptional<import("zod").ZodString>;
180
+ }, "strip", import("zod").ZodTypeAny, {
181
+ reason: string;
182
+ chainId?: number | undefined;
183
+ contractAddress?: string | undefined;
184
+ functionSelector?: string | undefined;
185
+ }, {
186
+ reason: string;
187
+ chainId?: number | undefined;
188
+ contractAddress?: string | undefined;
189
+ functionSelector?: string | undefined;
190
+ }>>, import("node_modules/@lit-protocol/vincent-ability-sdk/dist/src/lib/types").CommitLifecycleFunction<import("zod").ZodUndefined, import("zod").ZodUndefined, import("zod").ZodUndefined>>, string>;
191
+ //# sourceMappingURL=vincent-bundled-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vincent-bundled-policy.d.ts","sourceRoot":"","sources":["../../../src/generated/vincent-bundled-policy.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sMAA0D,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ /**
3
+ * DO NOT EDIT THIS FILE. IT IS GENERATED ON BUILD.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.bundledVincentPolicy = void 0;
7
+ const tslib_1 = require("tslib");
8
+ const vincent_ability_sdk_1 = require("@lit-protocol/vincent-ability-sdk");
9
+ const vincent_policy_1 = require("../lib/vincent-policy");
10
+ const vincent_policy_metadata_json_1 = tslib_1.__importDefault(require("./vincent-policy-metadata.json"));
11
+ if (!vincent_policy_metadata_json_1.default.ipfsCid) {
12
+ throw new Error('ipfsCid is not defined in metadata JSON file');
13
+ }
14
+ exports.bundledVincentPolicy = (0, vincent_ability_sdk_1.asBundledVincentPolicy)(vincent_policy_1.vincentPolicy, vincent_policy_metadata_json_1.default.ipfsCid);
15
+ //# sourceMappingURL=vincent-bundled-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vincent-bundled-policy.js","sourceRoot":"","sources":["../../../src/generated/vincent-bundled-policy.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,2EAA2E;AAC3E,0DAAsD;AACtD,0GAAsD;AAEtD,IAAG,CAAC,sCAAQ,CAAC,OAAO,EAAE,CAAC;IACrB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;AAClE,CAAC;AAEY,QAAA,oBAAoB,GAAG,IAAA,4CAAsB,EAAC,8BAAa,EAAE,sCAAQ,CAAC,OAAO,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "ipfsCid": "QmW45uW3wcTR6kAj6Fu1EScZpaV29jcDRVeQ4QKpKzR84G"
3
+ }
@@ -0,0 +1,4 @@
1
+ export { bundledVincentPolicy } from './generated/vincent-bundled-policy';
2
+ import * as vincentPolicyMetadata from './generated/vincent-policy-metadata.json';
3
+ export { vincentPolicyMetadata };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,KAAK,qBAAqB,MAAM,0CAA0C,CAAC;AAElF,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.vincentPolicyMetadata = exports.bundledVincentPolicy = void 0;
4
+ const tslib_1 = require("tslib");
5
+ var vincent_bundled_policy_1 = require("./generated/vincent-bundled-policy");
6
+ Object.defineProperty(exports, "bundledVincentPolicy", { enumerable: true, get: function () { return vincent_bundled_policy_1.bundledVincentPolicy; } });
7
+ const vincentPolicyMetadata = tslib_1.__importStar(require("./generated/vincent-policy-metadata.json"));
8
+ exports.vincentPolicyMetadata = vincentPolicyMetadata;
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,6EAA0E;AAAjE,8HAAA,oBAAoB,OAAA;AAC7B,wGAAkF;AAEzE,sDAAqB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=lit-action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lit-action.d.ts","sourceRoot":"","sources":["../../../src/lib/lit-action.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vincent_ability_sdk_1 = require("@lit-protocol/vincent-ability-sdk");
4
+ const vincent_policy_1 = require("./vincent-policy");
5
+ (async () => {
6
+ return await (0, vincent_ability_sdk_1.vincentPolicyHandler)({
7
+ vincentPolicy: vincent_policy_1.vincentPolicy,
8
+ context,
9
+ abilityParams,
10
+ });
11
+ })();
12
+ //# sourceMappingURL=lit-action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lit-action.js","sourceRoot":"","sources":["../../../src/lib/lit-action.ts"],"names":[],"mappings":";;AAAA,2EAAyE;AAEzE,qDAAiD;AAUjD,CAAC,KAAK,IAAI,EAAE;IACV,OAAO,MAAM,IAAA,0CAAoB,EAAC;QAChC,aAAa,EAAE,8BAAa;QAC5B,OAAO;QACP,aAAa;KACd,CAAC,CAAC;AACL,CAAC,CAAC,EAAE,CAAC"}
@@ -0,0 +1,90 @@
1
+ import { z } from 'zod';
2
+ export declare const abilityParamsSchema: z.ZodObject<{
3
+ serializedTransaction: z.ZodString;
4
+ }, "strip", z.ZodTypeAny, {
5
+ serializedTransaction: string;
6
+ }, {
7
+ serializedTransaction: string;
8
+ }>;
9
+ export declare const userParamsSchema: z.ZodObject<{
10
+ whitelist: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodObject<{
11
+ functionSelectors: z.ZodArray<z.ZodString, "many">;
12
+ }, "strip", z.ZodTypeAny, {
13
+ functionSelectors: string[];
14
+ }, {
15
+ functionSelectors: string[];
16
+ }>>>;
17
+ }, "strip", z.ZodTypeAny, {
18
+ whitelist: Record<string, Record<string, {
19
+ functionSelectors: string[];
20
+ }>>;
21
+ }, {
22
+ whitelist: Record<string, Record<string, {
23
+ functionSelectors: string[];
24
+ }>>;
25
+ }>;
26
+ export declare const precheckAllowResultSchema: z.ZodObject<{
27
+ chainId: z.ZodNumber;
28
+ contractAddress: z.ZodString;
29
+ functionSelector: z.ZodString;
30
+ wildcardUsed: z.ZodBoolean;
31
+ }, "strip", z.ZodTypeAny, {
32
+ chainId: number;
33
+ contractAddress: string;
34
+ functionSelector: string;
35
+ wildcardUsed: boolean;
36
+ }, {
37
+ chainId: number;
38
+ contractAddress: string;
39
+ functionSelector: string;
40
+ wildcardUsed: boolean;
41
+ }>;
42
+ export declare const precheckDenyResultSchema: z.ZodObject<{
43
+ reason: z.ZodString;
44
+ chainId: z.ZodOptional<z.ZodNumber>;
45
+ contractAddress: z.ZodOptional<z.ZodString>;
46
+ functionSelector: z.ZodOptional<z.ZodString>;
47
+ }, "strip", z.ZodTypeAny, {
48
+ reason: string;
49
+ chainId?: number | undefined;
50
+ contractAddress?: string | undefined;
51
+ functionSelector?: string | undefined;
52
+ }, {
53
+ reason: string;
54
+ chainId?: number | undefined;
55
+ contractAddress?: string | undefined;
56
+ functionSelector?: string | undefined;
57
+ }>;
58
+ export declare const evalAllowResultSchema: z.ZodObject<{
59
+ chainId: z.ZodNumber;
60
+ contractAddress: z.ZodString;
61
+ functionSelector: z.ZodString;
62
+ wildcardUsed: z.ZodBoolean;
63
+ }, "strip", z.ZodTypeAny, {
64
+ chainId: number;
65
+ contractAddress: string;
66
+ functionSelector: string;
67
+ wildcardUsed: boolean;
68
+ }, {
69
+ chainId: number;
70
+ contractAddress: string;
71
+ functionSelector: string;
72
+ wildcardUsed: boolean;
73
+ }>;
74
+ export declare const evalDenyResultSchema: z.ZodObject<{
75
+ reason: z.ZodString;
76
+ chainId: z.ZodOptional<z.ZodNumber>;
77
+ contractAddress: z.ZodOptional<z.ZodString>;
78
+ functionSelector: z.ZodOptional<z.ZodString>;
79
+ }, "strip", z.ZodTypeAny, {
80
+ reason: string;
81
+ chainId?: number | undefined;
82
+ contractAddress?: string | undefined;
83
+ functionSelector?: string | undefined;
84
+ }, {
85
+ reason: string;
86
+ chainId?: number | undefined;
87
+ contractAddress?: string | undefined;
88
+ functionSelector?: string | undefined;
89
+ }>;
90
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/lib/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,mBAAmB;;;;;;EAI9B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;EAU3B,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;EASpC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;EAcnC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;EAShC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;EAc/B,CAAC"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.evalDenyResultSchema = exports.evalAllowResultSchema = exports.precheckDenyResultSchema = exports.precheckAllowResultSchema = exports.userParamsSchema = exports.abilityParamsSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.abilityParamsSchema = zod_1.z.object({
6
+ serializedTransaction: zod_1.z
7
+ .string()
8
+ .describe('The serialized transaction to be evaluated and signed'),
9
+ });
10
+ exports.userParamsSchema = zod_1.z.object({
11
+ whitelist: zod_1.z.record(zod_1.z.string(), // chainId
12
+ zod_1.z.record(zod_1.z.string(), // contract address
13
+ zod_1.z.object({
14
+ functionSelectors: zod_1.z.array(zod_1.z.string()),
15
+ }))),
16
+ });
17
+ exports.precheckAllowResultSchema = zod_1.z.object({
18
+ chainId: zod_1.z.number().describe('The chain ID the serialized transaction is being sent to'),
19
+ contractAddress: zod_1.z
20
+ .string()
21
+ .describe('The contract address the serialized transaction is being sent to'),
22
+ functionSelector: zod_1.z.string().describe('The function selector of the serialized transaction'),
23
+ wildcardUsed: zod_1.z
24
+ .boolean()
25
+ .describe('Whether the wildcard "*" was used to allow this function selector'),
26
+ });
27
+ exports.precheckDenyResultSchema = zod_1.z.object({
28
+ reason: zod_1.z.string().describe('The reason for denying the precheck.'),
29
+ chainId: zod_1.z
30
+ .number()
31
+ .describe('The chain ID the serialized transaction is being sent to')
32
+ .optional(),
33
+ contractAddress: zod_1.z
34
+ .string()
35
+ .describe('The contract address the serialized transaction is being sent to')
36
+ .optional(),
37
+ functionSelector: zod_1.z
38
+ .string()
39
+ .describe('The function selector of the serialized transaction')
40
+ .optional(),
41
+ });
42
+ exports.evalAllowResultSchema = zod_1.z.object({
43
+ chainId: zod_1.z.number().describe('The chain ID the serialized transaction is being sent to'),
44
+ contractAddress: zod_1.z
45
+ .string()
46
+ .describe('The contract address the serialized transaction is being sent to'),
47
+ functionSelector: zod_1.z.string().describe('The function selector of the serialized transaction'),
48
+ wildcardUsed: zod_1.z
49
+ .boolean()
50
+ .describe('Whether the wildcard "*" was used to allow this function selector'),
51
+ });
52
+ exports.evalDenyResultSchema = zod_1.z.object({
53
+ reason: zod_1.z.string().describe('The reason for denying the evaluation.'),
54
+ chainId: zod_1.z
55
+ .number()
56
+ .describe('The chain ID the serialized transaction is being sent to')
57
+ .optional(),
58
+ contractAddress: zod_1.z
59
+ .string()
60
+ .describe('The contract address the serialized transaction is being sent to')
61
+ .optional(),
62
+ functionSelector: zod_1.z
63
+ .string()
64
+ .describe('The function selector of the serialized transaction')
65
+ .optional(),
66
+ });
67
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/lib/schemas.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAEX,QAAA,mBAAmB,GAAG,OAAC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AAE;CACd,CAAC,CAAC;AAEU,QAAA,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0DAA0D,CAAC;IACxF,eAAe,EAAE,OAAC;SACf,MAAM,EAAE;SACR,QAAQ,CAAC,kEAAkE,CAAC;IAC/E,gBAAgB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qDAAqD,CAAC;IAC5F,YAAY,EAAE,OAAC;SACZ,OAAO,EAAE;SACT,QAAQ,CAAC,mEAAmE,CAAC;CACjF,CAAC,CAAC;AAEU,QAAA,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3C,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,wCAAwC,CAAC;IACrE,OAAO,EAAE,OAAC;SACP,MAAM,EAAE;SACR,QAAQ,CAAC,0DAA0D,CAAC;SACpE,QAAQ,EAAE;IACb,eAAe,EAAE,OAAC;SACf,MAAM,EAAE;SACR,QAAQ,CAAC,kEAAkE,CAAC;SAC5E,QAAQ,EAAE;IACb,gBAAgB,EAAE,OAAC;SAChB,MAAM,EAAE;SACR,QAAQ,CAAC,qDAAqD,CAAC;SAC/D,QAAQ,EAAE;CACd,CAAC,CAAC"}
@@ -0,0 +1,188 @@
1
+ export declare const vincentPolicy: import("node_modules/@lit-protocol/vincent-ability-sdk/dist/src/lib/types").VincentPolicy<"@lit-protocol/vincent-policy-contract-whitelist", import("zod").ZodObject<{
2
+ serializedTransaction: import("zod").ZodString;
3
+ }, "strip", import("zod").ZodTypeAny, {
4
+ serializedTransaction: string;
5
+ }, {
6
+ serializedTransaction: string;
7
+ }>, import("zod").ZodObject<{
8
+ whitelist: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
9
+ functionSelectors: import("zod").ZodArray<import("zod").ZodString, "many">;
10
+ }, "strip", import("zod").ZodTypeAny, {
11
+ functionSelectors: string[];
12
+ }, {
13
+ functionSelectors: string[];
14
+ }>>>;
15
+ }, "strip", import("zod").ZodTypeAny, {
16
+ whitelist: Record<string, Record<string, {
17
+ functionSelectors: string[];
18
+ }>>;
19
+ }, {
20
+ whitelist: Record<string, Record<string, {
21
+ functionSelectors: string[];
22
+ }>>;
23
+ }>, import("zod").ZodObject<{
24
+ chainId: import("zod").ZodNumber;
25
+ contractAddress: import("zod").ZodString;
26
+ functionSelector: import("zod").ZodString;
27
+ wildcardUsed: import("zod").ZodBoolean;
28
+ }, "strip", import("zod").ZodTypeAny, {
29
+ chainId: number;
30
+ contractAddress: string;
31
+ functionSelector: string;
32
+ wildcardUsed: boolean;
33
+ }, {
34
+ chainId: number;
35
+ contractAddress: string;
36
+ functionSelector: string;
37
+ wildcardUsed: boolean;
38
+ }>, import("zod").ZodObject<{
39
+ reason: import("zod").ZodString;
40
+ chainId: import("zod").ZodOptional<import("zod").ZodNumber>;
41
+ contractAddress: import("zod").ZodOptional<import("zod").ZodString>;
42
+ functionSelector: import("zod").ZodOptional<import("zod").ZodString>;
43
+ }, "strip", import("zod").ZodTypeAny, {
44
+ reason: string;
45
+ chainId?: number | undefined;
46
+ contractAddress?: string | undefined;
47
+ functionSelector?: string | undefined;
48
+ }, {
49
+ reason: string;
50
+ chainId?: number | undefined;
51
+ contractAddress?: string | undefined;
52
+ functionSelector?: string | undefined;
53
+ }>, import("zod").ZodObject<{
54
+ chainId: import("zod").ZodNumber;
55
+ contractAddress: import("zod").ZodString;
56
+ functionSelector: import("zod").ZodString;
57
+ wildcardUsed: import("zod").ZodBoolean;
58
+ }, "strip", import("zod").ZodTypeAny, {
59
+ chainId: number;
60
+ contractAddress: string;
61
+ functionSelector: string;
62
+ wildcardUsed: boolean;
63
+ }, {
64
+ chainId: number;
65
+ contractAddress: string;
66
+ functionSelector: string;
67
+ wildcardUsed: boolean;
68
+ }>, import("zod").ZodObject<{
69
+ reason: import("zod").ZodString;
70
+ chainId: import("zod").ZodOptional<import("zod").ZodNumber>;
71
+ contractAddress: import("zod").ZodOptional<import("zod").ZodString>;
72
+ functionSelector: import("zod").ZodOptional<import("zod").ZodString>;
73
+ }, "strip", import("zod").ZodTypeAny, {
74
+ reason: string;
75
+ chainId?: number | undefined;
76
+ contractAddress?: string | undefined;
77
+ functionSelector?: string | undefined;
78
+ }, {
79
+ reason: string;
80
+ chainId?: number | undefined;
81
+ contractAddress?: string | undefined;
82
+ functionSelector?: string | undefined;
83
+ }>, import("zod").ZodUndefined, import("zod").ZodUndefined, import("zod").ZodUndefined, import("node_modules/@lit-protocol/vincent-ability-sdk/dist/src/lib/types").PolicyLifecycleFunction<import("zod").ZodObject<{
84
+ serializedTransaction: import("zod").ZodString;
85
+ }, "strip", import("zod").ZodTypeAny, {
86
+ serializedTransaction: string;
87
+ }, {
88
+ serializedTransaction: string;
89
+ }>, import("zod").ZodObject<{
90
+ whitelist: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
91
+ functionSelectors: import("zod").ZodArray<import("zod").ZodString, "many">;
92
+ }, "strip", import("zod").ZodTypeAny, {
93
+ functionSelectors: string[];
94
+ }, {
95
+ functionSelectors: string[];
96
+ }>>>;
97
+ }, "strip", import("zod").ZodTypeAny, {
98
+ whitelist: Record<string, Record<string, {
99
+ functionSelectors: string[];
100
+ }>>;
101
+ }, {
102
+ whitelist: Record<string, Record<string, {
103
+ functionSelectors: string[];
104
+ }>>;
105
+ }>, import("zod").ZodObject<{
106
+ chainId: import("zod").ZodNumber;
107
+ contractAddress: import("zod").ZodString;
108
+ functionSelector: import("zod").ZodString;
109
+ wildcardUsed: import("zod").ZodBoolean;
110
+ }, "strip", import("zod").ZodTypeAny, {
111
+ chainId: number;
112
+ contractAddress: string;
113
+ functionSelector: string;
114
+ wildcardUsed: boolean;
115
+ }, {
116
+ chainId: number;
117
+ contractAddress: string;
118
+ functionSelector: string;
119
+ wildcardUsed: boolean;
120
+ }>, import("zod").ZodObject<{
121
+ reason: import("zod").ZodString;
122
+ chainId: import("zod").ZodOptional<import("zod").ZodNumber>;
123
+ contractAddress: import("zod").ZodOptional<import("zod").ZodString>;
124
+ functionSelector: import("zod").ZodOptional<import("zod").ZodString>;
125
+ }, "strip", import("zod").ZodTypeAny, {
126
+ reason: string;
127
+ chainId?: number | undefined;
128
+ contractAddress?: string | undefined;
129
+ functionSelector?: string | undefined;
130
+ }, {
131
+ reason: string;
132
+ chainId?: number | undefined;
133
+ contractAddress?: string | undefined;
134
+ functionSelector?: string | undefined;
135
+ }>>, import("node_modules/@lit-protocol/vincent-ability-sdk/dist/src/lib/types").PolicyLifecycleFunction<import("zod").ZodObject<{
136
+ serializedTransaction: import("zod").ZodString;
137
+ }, "strip", import("zod").ZodTypeAny, {
138
+ serializedTransaction: string;
139
+ }, {
140
+ serializedTransaction: string;
141
+ }>, import("zod").ZodObject<{
142
+ whitelist: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
143
+ functionSelectors: import("zod").ZodArray<import("zod").ZodString, "many">;
144
+ }, "strip", import("zod").ZodTypeAny, {
145
+ functionSelectors: string[];
146
+ }, {
147
+ functionSelectors: string[];
148
+ }>>>;
149
+ }, "strip", import("zod").ZodTypeAny, {
150
+ whitelist: Record<string, Record<string, {
151
+ functionSelectors: string[];
152
+ }>>;
153
+ }, {
154
+ whitelist: Record<string, Record<string, {
155
+ functionSelectors: string[];
156
+ }>>;
157
+ }>, import("zod").ZodObject<{
158
+ chainId: import("zod").ZodNumber;
159
+ contractAddress: import("zod").ZodString;
160
+ functionSelector: import("zod").ZodString;
161
+ wildcardUsed: import("zod").ZodBoolean;
162
+ }, "strip", import("zod").ZodTypeAny, {
163
+ chainId: number;
164
+ contractAddress: string;
165
+ functionSelector: string;
166
+ wildcardUsed: boolean;
167
+ }, {
168
+ chainId: number;
169
+ contractAddress: string;
170
+ functionSelector: string;
171
+ wildcardUsed: boolean;
172
+ }>, import("zod").ZodObject<{
173
+ reason: import("zod").ZodString;
174
+ chainId: import("zod").ZodOptional<import("zod").ZodNumber>;
175
+ contractAddress: import("zod").ZodOptional<import("zod").ZodString>;
176
+ functionSelector: import("zod").ZodOptional<import("zod").ZodString>;
177
+ }, "strip", import("zod").ZodTypeAny, {
178
+ reason: string;
179
+ chainId?: number | undefined;
180
+ contractAddress?: string | undefined;
181
+ functionSelector?: string | undefined;
182
+ }, {
183
+ reason: string;
184
+ chainId?: number | undefined;
185
+ contractAddress?: string | undefined;
186
+ functionSelector?: string | undefined;
187
+ }>>, import("node_modules/@lit-protocol/vincent-ability-sdk/dist/src/lib/types").CommitLifecycleFunction<import("zod").ZodUndefined, import("zod").ZodUndefined, import("zod").ZodUndefined>>;
188
+ //# sourceMappingURL=vincent-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vincent-policy.d.ts","sourceRoot":"","sources":["../../../src/lib/vincent-policy.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6LAoIxB,CAAC"}
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.vincentPolicy = void 0;
4
+ const vincent_ability_sdk_1 = require("@lit-protocol/vincent-ability-sdk");
5
+ const ethers_1 = require("ethers");
6
+ const schemas_1 = require("./schemas");
7
+ exports.vincentPolicy = (0, vincent_ability_sdk_1.createVincentPolicy)({
8
+ packageName: '@lit-protocol/vincent-policy-contract-whitelist',
9
+ abilityParamsSchema: schemas_1.abilityParamsSchema,
10
+ userParamsSchema: schemas_1.userParamsSchema,
11
+ precheckAllowResultSchema: schemas_1.precheckAllowResultSchema,
12
+ precheckDenyResultSchema: schemas_1.precheckDenyResultSchema,
13
+ evalAllowResultSchema: schemas_1.evalAllowResultSchema,
14
+ evalDenyResultSchema: schemas_1.evalDenyResultSchema,
15
+ precheck: async ({ abilityParams, userParams }, { allow, deny }) => {
16
+ try {
17
+ const { serializedTransaction } = abilityParams;
18
+ const { whitelist } = userParams;
19
+ const transaction = ethers_1.ethers.utils.parseTransaction(serializedTransaction);
20
+ const { chainId, to: contractAddress, data } = transaction;
21
+ const functionSelector = data.slice(0, 10);
22
+ if (!contractAddress) {
23
+ return deny({
24
+ reason: 'to property of serialized transaction not provided',
25
+ });
26
+ }
27
+ const chainWhitelist = whitelist[chainId];
28
+ if (!chainWhitelist) {
29
+ return deny({
30
+ reason: 'Chain ID not whitelisted',
31
+ chainId,
32
+ contractAddress,
33
+ functionSelector,
34
+ });
35
+ }
36
+ const functionWhitelist = chainWhitelist[contractAddress];
37
+ if (!functionWhitelist) {
38
+ return deny({
39
+ reason: 'Function selector not whitelisted',
40
+ chainId,
41
+ contractAddress,
42
+ functionSelector,
43
+ });
44
+ }
45
+ const hasSpecificSelector = functionWhitelist.functionSelectors.includes(functionSelector);
46
+ const hasWildcard = functionWhitelist.functionSelectors.includes('*');
47
+ if (!hasSpecificSelector && !hasWildcard) {
48
+ return deny({
49
+ reason: 'Function selector not whitelisted',
50
+ chainId,
51
+ contractAddress,
52
+ functionSelector,
53
+ });
54
+ }
55
+ return allow({
56
+ chainId,
57
+ contractAddress,
58
+ functionSelector,
59
+ wildcardUsed: hasWildcard && !hasSpecificSelector,
60
+ });
61
+ }
62
+ catch (error) {
63
+ console.error('Precheck error:', error);
64
+ return deny({
65
+ reason: error instanceof Error ? error.message : 'Unknown error',
66
+ });
67
+ }
68
+ },
69
+ evaluate: async ({ abilityParams, userParams }, { allow, deny }) => {
70
+ try {
71
+ const { serializedTransaction } = abilityParams;
72
+ const { whitelist } = userParams;
73
+ const transaction = ethers_1.ethers.utils.parseTransaction(serializedTransaction);
74
+ const { chainId, to: contractAddress, data } = transaction;
75
+ const functionSelector = data.slice(0, 10);
76
+ if (!contractAddress) {
77
+ return deny({
78
+ reason: 'to property of serialized transaction not provided',
79
+ });
80
+ }
81
+ const chainWhitelist = whitelist[chainId];
82
+ if (!chainWhitelist) {
83
+ return deny({
84
+ reason: 'Chain ID not whitelisted',
85
+ chainId,
86
+ contractAddress,
87
+ functionSelector,
88
+ });
89
+ }
90
+ const functionWhitelist = chainWhitelist[contractAddress];
91
+ if (!functionWhitelist) {
92
+ return deny({
93
+ reason: 'Function selector not whitelisted',
94
+ chainId,
95
+ contractAddress,
96
+ functionSelector,
97
+ });
98
+ }
99
+ const hasSpecificSelector = functionWhitelist.functionSelectors.includes(functionSelector);
100
+ const hasWildcard = functionWhitelist.functionSelectors.includes('*');
101
+ if (!hasSpecificSelector && !hasWildcard) {
102
+ return deny({
103
+ reason: 'Function selector not whitelisted',
104
+ chainId,
105
+ contractAddress,
106
+ functionSelector,
107
+ });
108
+ }
109
+ return allow({
110
+ chainId,
111
+ contractAddress,
112
+ functionSelector,
113
+ wildcardUsed: hasWildcard && !hasSpecificSelector,
114
+ });
115
+ }
116
+ catch (error) {
117
+ console.error('Precheck error:', error);
118
+ return deny({
119
+ reason: error instanceof Error ? error.message : 'Unknown error',
120
+ });
121
+ }
122
+ },
123
+ });
124
+ //# sourceMappingURL=vincent-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vincent-policy.js","sourceRoot":"","sources":["../../../src/lib/vincent-policy.ts"],"names":[],"mappings":";;;AAAA,2EAAwE;AACxE,mCAAgC;AAEhC,uCAOmB;AAEN,QAAA,aAAa,GAAG,IAAA,yCAAmB,EAAC;IAC/C,WAAW,EAAE,iDAA0D;IAEvE,mBAAmB,EAAnB,6BAAmB;IACnB,gBAAgB,EAAhB,0BAAgB;IAEhB,yBAAyB,EAAzB,mCAAyB;IACzB,wBAAwB,EAAxB,kCAAwB;IAExB,qBAA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
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "dependencies": {
8
+ "ethers": "^5.8.0",
9
+ "tslib": "2.8.1",
10
+ "zod": "^3.25.64",
11
+ "@lit-protocol/vincent-ability-sdk": "2.0.0"
12
+ },
13
+ "peerDependencies": {
14
+ "@lit-protocol/vincent-app-sdk": "^2.0.0"
15
+ },
16
+ "devDependencies": {
17
+ "esbuild": "^0.19.12",
18
+ "esbuild-plugin-polyfill-node": "^0.3.0",
19
+ "ipfs-only-hash": "^4.0.0"
20
+ },
21
+ "main": "./dist/src/index.js",
22
+ "module": "./dist/src/index.js",
23
+ "types": "./dist/src/index.d.ts",
24
+ "files": [
25
+ "dist/**",
26
+ "*.md"
27
+ ]
28
+ }