@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.
- package/CONTRIBUTING.md +89 -0
- package/README.md +71 -0
- package/dist/CONTRIBUTING.md +89 -0
- package/dist/README.md +71 -0
- package/dist/package.json +30 -0
- package/dist/src/generated/lit-action.js +9 -0
- package/dist/src/generated/vincent-bundled-policy.d.ts +212 -0
- package/dist/src/generated/vincent-bundled-policy.d.ts.map +1 -0
- package/dist/src/generated/vincent-bundled-policy.js +15 -0
- package/dist/src/generated/vincent-bundled-policy.js.map +1 -0
- package/dist/src/generated/vincent-bundled-policy.ts +13 -0
- package/dist/src/generated/vincent-policy-metadata.json +3 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +9 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib/lit-action.d.ts +2 -0
- package/dist/src/lib/lit-action.d.ts.map +1 -0
- package/dist/src/lib/lit-action.js +12 -0
- package/dist/src/lib/lit-action.js.map +1 -0
- package/dist/src/lib/policy-helpers/calculate-usd-value.d.ts +7 -0
- package/dist/src/lib/policy-helpers/calculate-usd-value.d.ts.map +1 -0
- package/dist/src/lib/policy-helpers/calculate-usd-value.js +22 -0
- package/dist/src/lib/policy-helpers/calculate-usd-value.js.map +1 -0
- package/dist/src/lib/policy-helpers/check-spending-limit.d.ts +16 -0
- package/dist/src/lib/policy-helpers/check-spending-limit.d.ts.map +1 -0
- package/dist/src/lib/policy-helpers/check-spending-limit.js +29 -0
- package/dist/src/lib/policy-helpers/check-spending-limit.js.map +1 -0
- package/dist/src/lib/policy-helpers/get-eth-usd-price.d.ts +6 -0
- package/dist/src/lib/policy-helpers/get-eth-usd-price.d.ts.map +1 -0
- package/dist/src/lib/policy-helpers/get-eth-usd-price.js +22 -0
- package/dist/src/lib/policy-helpers/get-eth-usd-price.js.map +1 -0
- package/dist/src/lib/policy-helpers/get-token-amount-in-usd.d.ts +10 -0
- package/dist/src/lib/policy-helpers/get-token-amount-in-usd.d.ts.map +1 -0
- package/dist/src/lib/policy-helpers/get-token-amount-in-usd.js +68 -0
- package/dist/src/lib/policy-helpers/get-token-amount-in-usd.js.map +1 -0
- package/dist/src/lib/policy-helpers/get-uniswap-quote.d.ts +15 -0
- package/dist/src/lib/policy-helpers/get-uniswap-quote.d.ts.map +1 -0
- package/dist/src/lib/policy-helpers/get-uniswap-quote.js +114 -0
- package/dist/src/lib/policy-helpers/get-uniswap-quote.js.map +1 -0
- package/dist/src/lib/policy-helpers/index.d.ts +7 -0
- package/dist/src/lib/policy-helpers/index.d.ts.map +1 -0
- package/dist/src/lib/policy-helpers/index.js +10 -0
- package/dist/src/lib/policy-helpers/index.js.map +1 -0
- package/dist/src/lib/policy-helpers/send-spend-tx.d.ts +9 -0
- package/dist/src/lib/policy-helpers/send-spend-tx.d.ts.map +1 -0
- package/dist/src/lib/policy-helpers/send-spend-tx.js +144 -0
- package/dist/src/lib/policy-helpers/send-spend-tx.js.map +1 -0
- package/dist/src/lib/policy-helpers/sign-tx.d.ts +3 -0
- package/dist/src/lib/policy-helpers/sign-tx.d.ts.map +1 -0
- package/dist/src/lib/policy-helpers/sign-tx.js +28 -0
- package/dist/src/lib/policy-helpers/sign-tx.js.map +1 -0
- package/dist/src/lib/policy-helpers/spending-limit-contract.d.ts +4 -0
- package/dist/src/lib/policy-helpers/spending-limit-contract.d.ts.map +1 -0
- package/dist/src/lib/policy-helpers/spending-limit-contract.js +22 -0
- package/dist/src/lib/policy-helpers/spending-limit-contract.js.map +1 -0
- package/dist/src/lib/schemas.d.ts +101 -0
- package/dist/src/lib/schemas.d.ts.map +1 -0
- package/dist/src/lib/schemas.js +60 -0
- package/dist/src/lib/schemas.js.map +1 -0
- package/dist/src/lib/vincent-policy.d.ts +209 -0
- package/dist/src/lib/vincent-policy.d.ts.map +1 -0
- package/dist/src/lib/vincent-policy.js +117 -0
- package/dist/src/lib/vincent-policy.js.map +1 -0
- package/package.json +29 -0
package/CONTRIBUTING.md
ADDED
|
@@ -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
|
+
}
|