@lit-protocol/vincent-ability-erc20-approval 0.0.7-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/CHANGELOG.md +14 -0
- package/CONTRIBUTING.md +89 -0
- package/README.md +76 -0
- package/dist/CHANGELOG.md +14 -0
- package/dist/CONTRIBUTING.md +89 -0
- package/dist/README.md +76 -0
- package/dist/package.json +29 -0
- package/dist/src/generated/lit-action.js +9 -0
- package/dist/src/generated/vincent-ability-metadata.json +3 -0
- package/dist/src/generated/vincent-bundled-ability.d.ts +65 -0
- package/dist/src/generated/vincent-bundled-ability.d.ts.map +1 -0
- package/dist/src/generated/vincent-bundled-ability.js +15 -0
- package/dist/src/generated/vincent-bundled-ability.js.map +1 -0
- package/dist/src/generated/vincent-bundled-ability.ts +13 -0
- package/dist/src/index.d.ts +3 -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/helpers/check-native-token-balance.d.ts +6 -0
- package/dist/src/lib/helpers/check-native-token-balance.d.ts.map +1 -0
- package/dist/src/lib/helpers/check-native-token-balance.js +9 -0
- package/dist/src/lib/helpers/check-native-token-balance.js.map +1 -0
- package/dist/src/lib/helpers/get-current-allowance.d.ts +8 -0
- package/dist/src/lib/helpers/get-current-allowance.d.ts.map +1 -0
- package/dist/src/lib/helpers/get-current-allowance.js +11 -0
- package/dist/src/lib/helpers/get-current-allowance.js.map +1 -0
- package/dist/src/lib/helpers/getErc20Contract.d.ts +4 -0
- package/dist/src/lib/helpers/getErc20Contract.d.ts.map +1 -0
- package/dist/src/lib/helpers/getErc20Contract.js +20 -0
- package/dist/src/lib/helpers/getErc20Contract.js.map +1 -0
- package/dist/src/lib/helpers/index.d.ts +4 -0
- package/dist/src/lib/helpers/index.d.ts.map +1 -0
- package/dist/src/lib/helpers/index.js +10 -0
- package/dist/src/lib/helpers/index.js.map +1 -0
- package/dist/src/lib/lit-action-helpers/index.d.ts +3 -0
- package/dist/src/lib/lit-action-helpers/index.d.ts.map +1 -0
- package/dist/src/lib/lit-action-helpers/index.js +8 -0
- package/dist/src/lib/lit-action-helpers/index.js.map +1 -0
- package/dist/src/lib/lit-action-helpers/send-erc20-approval-tx.d.ts +10 -0
- package/dist/src/lib/lit-action-helpers/send-erc20-approval-tx.d.ts.map +1 -0
- package/dist/src/lib/lit-action-helpers/send-erc20-approval-tx.js +94 -0
- package/dist/src/lib/lit-action-helpers/send-erc20-approval-tx.js.map +1 -0
- package/dist/src/lib/lit-action-helpers/sign-tx.d.ts +3 -0
- package/dist/src/lib/lit-action-helpers/sign-tx.d.ts.map +1 -0
- package/dist/src/lib/lit-action-helpers/sign-tx.js +28 -0
- package/dist/src/lib/lit-action-helpers/sign-tx.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 +16 -0
- package/dist/src/lib/lit-action.js.map +1 -0
- package/dist/src/lib/schemas.d.ts +67 -0
- package/dist/src/lib/schemas.d.ts.map +1 -0
- package/dist/src/lib/schemas.js +59 -0
- package/dist/src/lib/schemas.js.map +1 -0
- package/dist/src/lib/vincent-ability.d.ts +62 -0
- package/dist/src/lib/vincent-ability.d.ts.map +1 -0
- package/dist/src/lib/vincent-ability.js +99 -0
- package/dist/src/lib/vincent-ability.js.map +1 -0
- package/package.json +28 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
## 1.0.2 (2025-07-08)
|
|
2
|
+
|
|
3
|
+
### 🩹 Fixes
|
|
4
|
+
|
|
5
|
+
- - Fixed `fail` results being returned as `success` in some cases ([867a2f85](https://github.com/LIT-Protocol/Vincent/commit/867a2f85))
|
|
6
|
+
|
|
7
|
+
### 🧱 Updated Dependencies
|
|
8
|
+
|
|
9
|
+
- Updated ability-sdk to 1.0.2
|
|
10
|
+
- Updated app-sdk to 1.0.2
|
|
11
|
+
|
|
12
|
+
### ❤️ Thank You
|
|
13
|
+
|
|
14
|
+
- Daryl Collins
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Contributing to Vincent Ability ERC20 Approval
|
|
2
|
+
|
|
3
|
+
This document provides guidelines for contributing to the Vincent Ability ERC20 Approval project.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Vincent Ability ERC20 Approval is an ability to send ERC20 approve/allowance transactions from a Vincent app on behalf of the delegator. It's part of the Vincent Abilities ecosystem and is built using the Vincent Ability 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 ability-erc20-approval
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Building the Lit Action
|
|
28
|
+
|
|
29
|
+
Build the tool:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
nx action:build ability-erc20-approval
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Deploying the Lit Action to IPFS
|
|
36
|
+
|
|
37
|
+
Building will be done automatically. Deploy the tool:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
nx action:deploy ability-erc20-approval
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Project Structure
|
|
44
|
+
|
|
45
|
+
- `src/`: Source code
|
|
46
|
+
- `index.ts`: Main entry point
|
|
47
|
+
|
|
48
|
+
## Ability Development Guidelines
|
|
49
|
+
|
|
50
|
+
1. Use the Vincent Ability SDK to create abilities
|
|
51
|
+
2. Define clear schemas for ability parameters
|
|
52
|
+
3. Implement the ability lifecycle methods (precheck, execute)
|
|
53
|
+
4. Handle errors gracefully
|
|
54
|
+
5. Write comprehensive tests for all functionality
|
|
55
|
+
6. Document the ability's purpose and usage
|
|
56
|
+
|
|
57
|
+
## Integration with Policies
|
|
58
|
+
|
|
59
|
+
This ability can be integrated with various Vincent Policies to enforce constraints. When developing or modifying the ability, consider how it will be used with policies such as:
|
|
60
|
+
|
|
61
|
+
- Vincent Policy Spending Limit
|
|
62
|
+
|
|
63
|
+
## Testing
|
|
64
|
+
|
|
65
|
+
Write unit tests for all functionality:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pnpm test
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Documentation
|
|
72
|
+
|
|
73
|
+
- Document the ability's purpose and usage
|
|
74
|
+
- Update README.md when adding new features
|
|
75
|
+
- Document the ability's parameters and behavior
|
|
76
|
+
|
|
77
|
+
## Pull Request Process
|
|
78
|
+
|
|
79
|
+
1. Ensure your code follows the coding standards
|
|
80
|
+
2. Update documentation if necessary
|
|
81
|
+
3. Include tests for new functionality
|
|
82
|
+
4. Link any related issues in your pull request description
|
|
83
|
+
5. Request a review from a maintainer
|
|
84
|
+
|
|
85
|
+
## Additional Resources
|
|
86
|
+
|
|
87
|
+
- [Vincent Documentation](https://docs.heyvincent.ai/)
|
|
88
|
+
- [Vincent Ability SDK Documentation](../../libs/ability-sdk/README.md)
|
|
89
|
+
- [ERC20 Standard](https://eips.ethereum.org/EIPS/eip-20)
|
package/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Vincent Ability ERC20 Approval
|
|
2
|
+
|
|
3
|
+
An ability to send ERC20 approve/allowance transactions from a Vincent app on behalf of the delegator.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Vincent Ability ERC20 Approval is part of the Vincent Abilities ecosystem and is built using the Vincent Ability SDK. It allows Vincent apps to request and manage ERC20 token approvals on behalf of users, enabling seamless integration with DeFi protocols and other token-based applications.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- Request ERC20 token approvals for users
|
|
12
|
+
- Set specific allowance amounts
|
|
13
|
+
- Revoke existing approvals
|
|
14
|
+
- Support for multiple ERC20 tokens
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @lit-protocol/vincent-ability-erc20-approval
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
This ability can be used in Vincent apps to manage ERC20 approvals:
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { getVincentAbilityClient } from '@lit-protocol/vincent-app-sdk/abilityClient';
|
|
28
|
+
import { bundledVincentAbility } from '@lit-protocol/vincent-ability-erc20-approval';
|
|
29
|
+
|
|
30
|
+
// One of delegatee signers from your app's Vincent Dashboard
|
|
31
|
+
const delegateeSigner = new ethers.Wallet('YOUR_DELEGATEE_PRIVATE_KEY');
|
|
32
|
+
|
|
33
|
+
// Initialize the Vincent Ability Client
|
|
34
|
+
const abilityClient = getVincentAbilityClient({
|
|
35
|
+
ethersSigner: delegateeSigner,
|
|
36
|
+
bundledVincentAbility,
|
|
37
|
+
});
|
|
38
|
+
const delegatorPkpEthAddress = '0x09182301238'; // The delegator PKP Eth Address
|
|
39
|
+
|
|
40
|
+
const abilityParams = {
|
|
41
|
+
chainId: '8453', // The chain where the tx will be executed
|
|
42
|
+
tokenIn: '0x1234...', // The ERC20 token address
|
|
43
|
+
amountIn: '1000000000000000000', // The amount to approve (in wei)
|
|
44
|
+
rpcUrl: 'https://mainnet.base.org', // The RPC to send the transaction through
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Run precheck to see if ability should be executed
|
|
48
|
+
const precheckResult = await client.precheck(abilityParams, {
|
|
49
|
+
delegatorPkpEthAddress,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (precheckResult.success === true) {
|
|
53
|
+
// Execute the Vincent Ability
|
|
54
|
+
const executeResult = await client.execute(abilityParams, {
|
|
55
|
+
delegatorPkpEthAddress,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// ...ability has executed, you can check `executeResult` for details
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Building
|
|
63
|
+
|
|
64
|
+
Run `nx build ability-erc20-approval` to build the library.
|
|
65
|
+
|
|
66
|
+
## Running unit tests
|
|
67
|
+
|
|
68
|
+
Run `nx test ability-erc20-approval` to execute the unit tests via [Jest](https://jestjs.io).
|
|
69
|
+
|
|
70
|
+
## Contributing
|
|
71
|
+
|
|
72
|
+
Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines on how to contribute to this project.
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
## 1.0.2 (2025-07-08)
|
|
2
|
+
|
|
3
|
+
### 🩹 Fixes
|
|
4
|
+
|
|
5
|
+
- - Fixed `fail` results being returned as `success` in some cases ([867a2f85](https://github.com/LIT-Protocol/Vincent/commit/867a2f85))
|
|
6
|
+
|
|
7
|
+
### 🧱 Updated Dependencies
|
|
8
|
+
|
|
9
|
+
- Updated ability-sdk to 1.0.2
|
|
10
|
+
- Updated app-sdk to 1.0.2
|
|
11
|
+
|
|
12
|
+
### ❤️ Thank You
|
|
13
|
+
|
|
14
|
+
- Daryl Collins
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Contributing to Vincent Ability ERC20 Approval
|
|
2
|
+
|
|
3
|
+
This document provides guidelines for contributing to the Vincent Ability ERC20 Approval project.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Vincent Ability ERC20 Approval is an ability to send ERC20 approve/allowance transactions from a Vincent app on behalf of the delegator. It's part of the Vincent Abilities ecosystem and is built using the Vincent Ability 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 ability-erc20-approval
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Building the Lit Action
|
|
28
|
+
|
|
29
|
+
Build the tool:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
nx action:build ability-erc20-approval
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Deploying the Lit Action to IPFS
|
|
36
|
+
|
|
37
|
+
Building will be done automatically. Deploy the tool:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
nx action:deploy ability-erc20-approval
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Project Structure
|
|
44
|
+
|
|
45
|
+
- `src/`: Source code
|
|
46
|
+
- `index.ts`: Main entry point
|
|
47
|
+
|
|
48
|
+
## Ability Development Guidelines
|
|
49
|
+
|
|
50
|
+
1. Use the Vincent Ability SDK to create abilities
|
|
51
|
+
2. Define clear schemas for ability parameters
|
|
52
|
+
3. Implement the ability lifecycle methods (precheck, execute)
|
|
53
|
+
4. Handle errors gracefully
|
|
54
|
+
5. Write comprehensive tests for all functionality
|
|
55
|
+
6. Document the ability's purpose and usage
|
|
56
|
+
|
|
57
|
+
## Integration with Policies
|
|
58
|
+
|
|
59
|
+
This ability can be integrated with various Vincent Policies to enforce constraints. When developing or modifying the ability, consider how it will be used with policies such as:
|
|
60
|
+
|
|
61
|
+
- Vincent Policy Spending Limit
|
|
62
|
+
|
|
63
|
+
## Testing
|
|
64
|
+
|
|
65
|
+
Write unit tests for all functionality:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pnpm test
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Documentation
|
|
72
|
+
|
|
73
|
+
- Document the ability's purpose and usage
|
|
74
|
+
- Update README.md when adding new features
|
|
75
|
+
- Document the ability's parameters and behavior
|
|
76
|
+
|
|
77
|
+
## Pull Request Process
|
|
78
|
+
|
|
79
|
+
1. Ensure your code follows the coding standards
|
|
80
|
+
2. Update documentation if necessary
|
|
81
|
+
3. Include tests for new functionality
|
|
82
|
+
4. Link any related issues in your pull request description
|
|
83
|
+
5. Request a review from a maintainer
|
|
84
|
+
|
|
85
|
+
## Additional Resources
|
|
86
|
+
|
|
87
|
+
- [Vincent Documentation](https://docs.heyvincent.ai/)
|
|
88
|
+
- [Vincent Ability SDK Documentation](../../libs/ability-sdk/README.md)
|
|
89
|
+
- [ERC20 Standard](https://eips.ethereum.org/EIPS/eip-20)
|
package/dist/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Vincent Ability ERC20 Approval
|
|
2
|
+
|
|
3
|
+
An ability to send ERC20 approve/allowance transactions from a Vincent app on behalf of the delegator.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Vincent Ability ERC20 Approval is part of the Vincent Abilities ecosystem and is built using the Vincent Ability SDK. It allows Vincent apps to request and manage ERC20 token approvals on behalf of users, enabling seamless integration with DeFi protocols and other token-based applications.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- Request ERC20 token approvals for users
|
|
12
|
+
- Set specific allowance amounts
|
|
13
|
+
- Revoke existing approvals
|
|
14
|
+
- Support for multiple ERC20 tokens
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @lit-protocol/vincent-ability-erc20-approval
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
This ability can be used in Vincent apps to manage ERC20 approvals:
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { getVincentAbilityClient } from '@lit-protocol/vincent-app-sdk/abilityClient';
|
|
28
|
+
import { bundledVincentAbility } from '@lit-protocol/vincent-ability-erc20-approval';
|
|
29
|
+
|
|
30
|
+
// One of delegatee signers from your app's Vincent Dashboard
|
|
31
|
+
const delegateeSigner = new ethers.Wallet('YOUR_DELEGATEE_PRIVATE_KEY');
|
|
32
|
+
|
|
33
|
+
// Initialize the Vincent Ability Client
|
|
34
|
+
const abilityClient = getVincentAbilityClient({
|
|
35
|
+
ethersSigner: delegateeSigner,
|
|
36
|
+
bundledVincentAbility,
|
|
37
|
+
});
|
|
38
|
+
const delegatorPkpEthAddress = '0x09182301238'; // The delegator PKP Eth Address
|
|
39
|
+
|
|
40
|
+
const abilityParams = {
|
|
41
|
+
chainId: '8453', // The chain where the tx will be executed
|
|
42
|
+
tokenIn: '0x1234...', // The ERC20 token address
|
|
43
|
+
amountIn: '1000000000000000000', // The amount to approve (in wei)
|
|
44
|
+
rpcUrl: 'https://mainnet.base.org', // The RPC to send the transaction through
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Run precheck to see if ability should be executed
|
|
48
|
+
const precheckResult = await client.precheck(abilityParams, {
|
|
49
|
+
delegatorPkpEthAddress,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (precheckResult.success === true) {
|
|
53
|
+
// Execute the Vincent Ability
|
|
54
|
+
const executeResult = await client.execute(abilityParams, {
|
|
55
|
+
delegatorPkpEthAddress,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// ...ability has executed, you can check `executeResult` for details
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Building
|
|
63
|
+
|
|
64
|
+
Run `nx build ability-erc20-approval` to build the library.
|
|
65
|
+
|
|
66
|
+
## Running unit tests
|
|
67
|
+
|
|
68
|
+
Run `nx test ability-erc20-approval` to execute the unit tests via [Jest](https://jestjs.io).
|
|
69
|
+
|
|
70
|
+
## Contributing
|
|
71
|
+
|
|
72
|
+
Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines on how to contribute to this project.
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lit-protocol/vincent-ability-erc20-approval",
|
|
3
|
+
"version": "1.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
|
+
}
|