@lit-protocol/vincent-policy-send-counter 0.0.4-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.
Files changed (65) hide show
  1. package/CONTRIBUTING.md +89 -0
  2. package/README.md +71 -0
  3. package/dist/CONTRIBUTING.md +89 -0
  4. package/dist/README.md +71 -0
  5. package/dist/package.json +30 -0
  6. package/dist/src/generated/lit-action.js +9 -0
  7. package/dist/src/generated/vincent-bundled-policy.d.ts +212 -0
  8. package/dist/src/generated/vincent-bundled-policy.d.ts.map +1 -0
  9. package/dist/src/generated/vincent-bundled-policy.js +15 -0
  10. package/dist/src/generated/vincent-bundled-policy.js.map +1 -0
  11. package/dist/src/generated/vincent-bundled-policy.ts +13 -0
  12. package/dist/src/generated/vincent-policy-metadata.json +3 -0
  13. package/dist/src/index.d.ts +4 -0
  14. package/dist/src/index.d.ts.map +1 -0
  15. package/dist/src/index.js +9 -0
  16. package/dist/src/index.js.map +1 -0
  17. package/dist/src/lib/lit-action.d.ts +2 -0
  18. package/dist/src/lib/lit-action.d.ts.map +1 -0
  19. package/dist/src/lib/lit-action.js +12 -0
  20. package/dist/src/lib/lit-action.js.map +1 -0
  21. package/dist/src/lib/policy-helpers/calculate-usd-value.d.ts +7 -0
  22. package/dist/src/lib/policy-helpers/calculate-usd-value.d.ts.map +1 -0
  23. package/dist/src/lib/policy-helpers/calculate-usd-value.js +22 -0
  24. package/dist/src/lib/policy-helpers/calculate-usd-value.js.map +1 -0
  25. package/dist/src/lib/policy-helpers/check-spending-limit.d.ts +16 -0
  26. package/dist/src/lib/policy-helpers/check-spending-limit.d.ts.map +1 -0
  27. package/dist/src/lib/policy-helpers/check-spending-limit.js +29 -0
  28. package/dist/src/lib/policy-helpers/check-spending-limit.js.map +1 -0
  29. package/dist/src/lib/policy-helpers/get-eth-usd-price.d.ts +6 -0
  30. package/dist/src/lib/policy-helpers/get-eth-usd-price.d.ts.map +1 -0
  31. package/dist/src/lib/policy-helpers/get-eth-usd-price.js +22 -0
  32. package/dist/src/lib/policy-helpers/get-eth-usd-price.js.map +1 -0
  33. package/dist/src/lib/policy-helpers/get-token-amount-in-usd.d.ts +10 -0
  34. package/dist/src/lib/policy-helpers/get-token-amount-in-usd.d.ts.map +1 -0
  35. package/dist/src/lib/policy-helpers/get-token-amount-in-usd.js +68 -0
  36. package/dist/src/lib/policy-helpers/get-token-amount-in-usd.js.map +1 -0
  37. package/dist/src/lib/policy-helpers/get-uniswap-quote.d.ts +15 -0
  38. package/dist/src/lib/policy-helpers/get-uniswap-quote.d.ts.map +1 -0
  39. package/dist/src/lib/policy-helpers/get-uniswap-quote.js +114 -0
  40. package/dist/src/lib/policy-helpers/get-uniswap-quote.js.map +1 -0
  41. package/dist/src/lib/policy-helpers/index.d.ts +7 -0
  42. package/dist/src/lib/policy-helpers/index.d.ts.map +1 -0
  43. package/dist/src/lib/policy-helpers/index.js +10 -0
  44. package/dist/src/lib/policy-helpers/index.js.map +1 -0
  45. package/dist/src/lib/policy-helpers/send-spend-tx.d.ts +9 -0
  46. package/dist/src/lib/policy-helpers/send-spend-tx.d.ts.map +1 -0
  47. package/dist/src/lib/policy-helpers/send-spend-tx.js +144 -0
  48. package/dist/src/lib/policy-helpers/send-spend-tx.js.map +1 -0
  49. package/dist/src/lib/policy-helpers/sign-tx.d.ts +3 -0
  50. package/dist/src/lib/policy-helpers/sign-tx.d.ts.map +1 -0
  51. package/dist/src/lib/policy-helpers/sign-tx.js +28 -0
  52. package/dist/src/lib/policy-helpers/sign-tx.js.map +1 -0
  53. package/dist/src/lib/policy-helpers/spending-limit-contract.d.ts +4 -0
  54. package/dist/src/lib/policy-helpers/spending-limit-contract.d.ts.map +1 -0
  55. package/dist/src/lib/policy-helpers/spending-limit-contract.js +22 -0
  56. package/dist/src/lib/policy-helpers/spending-limit-contract.js.map +1 -0
  57. package/dist/src/lib/schemas.d.ts +101 -0
  58. package/dist/src/lib/schemas.d.ts.map +1 -0
  59. package/dist/src/lib/schemas.js +60 -0
  60. package/dist/src/lib/schemas.js.map +1 -0
  61. package/dist/src/lib/vincent-policy.d.ts +209 -0
  62. package/dist/src/lib/vincent-policy.d.ts.map +1 -0
  63. package/dist/src/lib/vincent-policy.js +117 -0
  64. package/dist/src/lib/vincent-policy.js.map +1 -0
  65. package/package.json +29 -0
@@ -0,0 +1,89 @@
1
+ # Contributing to Vincent Policy Send Counter
2
+
3
+ This document provides guidelines for contributing to the Vincent Policy Send Counter project.
4
+
5
+ ## Overview
6
+
7
+ The Vincent Policy Send Counter is a policy that can be attached to tools to avoid them spending more than a user-defined limit in a specific period of time. It's part of the Vincent Tools ecosystem and is built using the Vincent Tool SDK.
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-spending-limit
25
+ ```
26
+
27
+ ### Building the Lit Action
28
+
29
+ Build the policy:
30
+
31
+ ```bash
32
+ nx action:build policy-spending-limit
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-spending-limit
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 Tool SDK to create policies
51
+ 2. Define clear schemas for tool 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 Tools
58
+
59
+ This policy can be integrated with various Vincent Tools to enforce sending limits. When developing or modifying the policy, consider how it will be used by tools such as:
60
+
61
+ - Vincent Tool ERC20 Approval
62
+ - Vincent Tool Uniswap Swap
63
+
64
+ ## Testing
65
+
66
+ Write unit tests for all functionality:
67
+
68
+ ```bash
69
+ pnpm test
70
+ ```
71
+
72
+ ## Documentation
73
+
74
+ - Document the policy's purpose and usage
75
+ - Update README.md when adding new features
76
+ - Document the policy's parameters and behavior
77
+
78
+ ## Pull Request Process
79
+
80
+ 1. Ensure your code follows the coding standards
81
+ 2. Update documentation if necessary
82
+ 3. Include tests for new functionality
83
+ 4. Link any related issues in your pull request description
84
+ 5. Request a review from a maintainer
85
+
86
+ ## Additional Resources
87
+
88
+ - [Vincent Documentation](https://docs.heyvincent.ai/)
89
+ - [Vincent Tool SDK Documentation](../../libs/tool-sdk/README.md)
package/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # Vincent Policy Send Counter
2
+
3
+ A policy that can be attached to Vincent tools to limit the number of transactions that can be sent within a specific time period.
4
+
5
+ ## Overview
6
+
7
+ The Vincent Policy Send Counter is part of the Vincent Tools ecosystem and is built using the Vincent Tool SDK. It allows users to set transaction count limits for tools, providing an additional layer of security and control.
8
+
9
+ ## Features
10
+
11
+ - Set maximum transaction limits per time period
12
+ - Track transaction counts across multiple tools
13
+ - Configurable by users through the Vincent Dashboard
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @lit-protocol/vincent-policy-send-counter
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ This policy can be integrated with Vincent Tools to enforce transaction count limits:
24
+
25
+ ```typescript
26
+ import {
27
+ createVincentToolPolicy,
28
+ createVincentTool,
29
+ supportedPoliciesForTool,
30
+ } from '@lit-protocol/vincent-tool-sdk';
31
+ import { bundledVincentPolicy } from '@lit-protocol/vincent-policy-send-counter';
32
+
33
+ const toolParamsSchema = z.object({
34
+ // Your tool's parameter schema
35
+ });
36
+
37
+ const sendCounterPolicy = createVincentToolPolicy({
38
+ toolParamsSchema,
39
+ bundledVincentPolicy,
40
+ // Map your tool's parameters to the policy's expected parameters if needed
41
+ toolParameterMappings: {
42
+ /* your parameter mappings */
43
+ },
44
+ });
45
+
46
+ export const myTool = createVincentTool({
47
+ toolParamsSchema,
48
+ supportedPolicies: supportedPoliciesForTool([sendCounterPolicy]),
49
+ // ... rest of tool implementation
50
+ });
51
+ ```
52
+
53
+ ## Building
54
+
55
+ ```bash
56
+ nx build policy-send-counter
57
+ ```
58
+
59
+ ## Running Tests
60
+
61
+ ```bash
62
+ nx test policy-send-counter
63
+ ```
64
+
65
+ ## Contributing
66
+
67
+ Please see [CONTRIBUTING.md](../../CONTRIBUTING.md) for guidelines on how to contribute to this project.
68
+
69
+ ## License
70
+
71
+ This project is licensed under the MIT License - see the [LICENSE](../../LICENSE) file for details.
@@ -0,0 +1,89 @@
1
+ # Contributing to Vincent Policy Send Counter
2
+
3
+ This document provides guidelines for contributing to the Vincent Policy Send Counter project.
4
+
5
+ ## Overview
6
+
7
+ The Vincent Policy Send Counter is a policy that can be attached to tools to avoid them spending more than a user-defined limit in a specific period of time. It's part of the Vincent Tools ecosystem and is built using the Vincent Tool SDK.
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-spending-limit
25
+ ```
26
+
27
+ ### Building the Lit Action
28
+
29
+ Build the policy:
30
+
31
+ ```bash
32
+ nx action:build policy-spending-limit
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-spending-limit
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 Tool SDK to create policies
51
+ 2. Define clear schemas for tool 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 Tools
58
+
59
+ This policy can be integrated with various Vincent Tools to enforce sending limits. When developing or modifying the policy, consider how it will be used by tools such as:
60
+
61
+ - Vincent Tool ERC20 Approval
62
+ - Vincent Tool Uniswap Swap
63
+
64
+ ## Testing
65
+
66
+ Write unit tests for all functionality:
67
+
68
+ ```bash
69
+ pnpm test
70
+ ```
71
+
72
+ ## Documentation
73
+
74
+ - Document the policy's purpose and usage
75
+ - Update README.md when adding new features
76
+ - Document the policy's parameters and behavior
77
+
78
+ ## Pull Request Process
79
+
80
+ 1. Ensure your code follows the coding standards
81
+ 2. Update documentation if necessary
82
+ 3. Include tests for new functionality
83
+ 4. Link any related issues in your pull request description
84
+ 5. Request a review from a maintainer
85
+
86
+ ## Additional Resources
87
+
88
+ - [Vincent Documentation](https://docs.heyvincent.ai/)
89
+ - [Vincent Tool SDK Documentation](../../libs/tool-sdk/README.md)
package/dist/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # Vincent Policy Send Counter
2
+
3
+ A policy that can be attached to Vincent tools to limit the number of transactions that can be sent within a specific time period.
4
+
5
+ ## Overview
6
+
7
+ The Vincent Policy Send Counter is part of the Vincent Tools ecosystem and is built using the Vincent Tool SDK. It allows users to set transaction count limits for tools, providing an additional layer of security and control.
8
+
9
+ ## Features
10
+
11
+ - Set maximum transaction limits per time period
12
+ - Track transaction counts across multiple tools
13
+ - Configurable by users through the Vincent Dashboard
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @lit-protocol/vincent-policy-send-counter
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ This policy can be integrated with Vincent Tools to enforce transaction count limits:
24
+
25
+ ```typescript
26
+ import {
27
+ createVincentToolPolicy,
28
+ createVincentTool,
29
+ supportedPoliciesForTool,
30
+ } from '@lit-protocol/vincent-tool-sdk';
31
+ import { bundledVincentPolicy } from '@lit-protocol/vincent-policy-send-counter';
32
+
33
+ const toolParamsSchema = z.object({
34
+ // Your tool's parameter schema
35
+ });
36
+
37
+ const sendCounterPolicy = createVincentToolPolicy({
38
+ toolParamsSchema,
39
+ bundledVincentPolicy,
40
+ // Map your tool's parameters to the policy's expected parameters if needed
41
+ toolParameterMappings: {
42
+ /* your parameter mappings */
43
+ },
44
+ });
45
+
46
+ export const myTool = createVincentTool({
47
+ toolParamsSchema,
48
+ supportedPolicies: supportedPoliciesForTool([sendCounterPolicy]),
49
+ // ... rest of tool implementation
50
+ });
51
+ ```
52
+
53
+ ## Building
54
+
55
+ ```bash
56
+ nx build policy-send-counter
57
+ ```
58
+
59
+ ## Running Tests
60
+
61
+ ```bash
62
+ nx test policy-send-counter
63
+ ```
64
+
65
+ ## Contributing
66
+
67
+ Please see [CONTRIBUTING.md](../../CONTRIBUTING.md) for guidelines on how to contribute to this project.
68
+
69
+ ## License
70
+
71
+ This project is licensed under the MIT License - see the [LICENSE](../../LICENSE) file for details.
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@lit-protocol/vincent-policy-send-counter",
3
+ "version": "0.0.1",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "dependencies": {
8
+ "@lit-protocol/vincent-tool-sdk": "workspace:*",
9
+ "@uniswap/sdk-core": "^7.7.2",
10
+ "ethers": "^5.8.0",
11
+ "tslib": "2.8.1",
12
+ "zod": "^3.25.64"
13
+ },
14
+ "peerDependencies": {
15
+ "@lit-protocol/vincent-app-sdk": "workspace:^"
16
+ },
17
+ "devDependencies": {
18
+ "esbuild": "^0.19.12",
19
+ "esbuild-plugin-polyfill-node": "^0.3.0",
20
+ "ipfs-only-hash": "^4.0.0"
21
+ },
22
+ "main": "./dist/src/index.js",
23
+ "module": "./dist/src/index.js",
24
+ "types": "./dist/src/index.d.ts",
25
+ "files": [
26
+ "dist/**",
27
+ "*.md"
28
+ ],
29
+ "type": "commonjs"
30
+ }