@lit-protocol/vincent-e2e-test-utils 1.2.1 → 2.0.0
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 +18 -6
- package/dist/CHANGELOG.md +35 -0
- package/dist/CONTRIBUTING.md +0 -0
- package/dist/README.md +59 -0
- package/dist/package.json +6 -2
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/lib/chain.d.ts +1 -2
- package/dist/src/lib/chain.d.ts.map +1 -1
- package/dist/src/lib/chain.js +2 -4
- package/dist/src/lib/chain.js.map +1 -1
- package/dist/src/lib/create-random-vincent-wallets.d.ts +1 -1
- package/dist/src/lib/create-random-vincent-wallets.js +1 -1
- package/dist/src/lib/create-random-vincent-wallets.js.map +1 -1
- package/dist/src/lib/delegator/add-permission-for-abilities.d.ts +2 -1
- package/dist/src/lib/delegator/add-permission-for-abilities.d.ts.map +1 -1
- package/dist/src/lib/delegator/add-permission-for-abilities.js +4 -3
- package/dist/src/lib/delegator/add-permission-for-abilities.js.map +1 -1
- package/dist/src/lib/delegator/agent-pkp.d.ts +18 -3
- package/dist/src/lib/delegator/agent-pkp.d.ts.map +1 -1
- package/dist/src/lib/delegator/agent-pkp.js +77 -26
- package/dist/src/lib/delegator/agent-pkp.js.map +1 -1
- package/dist/src/lib/delegator/get-platform-user-pkp-wallet.d.ts +8 -0
- package/dist/src/lib/delegator/get-platform-user-pkp-wallet.d.ts.map +1 -0
- package/dist/src/lib/delegator/get-platform-user-pkp-wallet.js +77 -0
- package/dist/src/lib/delegator/get-platform-user-pkp-wallet.js.map +1 -0
- package/dist/src/lib/delegator/index.d.ts +2 -0
- package/dist/src/lib/delegator/index.d.ts.map +1 -1
- package/dist/src/lib/delegator/index.js +7 -1
- package/dist/src/lib/delegator/index.js.map +1 -1
- package/dist/src/lib/delegator/permit-vincent-app-version.d.ts +4 -2
- package/dist/src/lib/delegator/permit-vincent-app-version.d.ts.map +1 -1
- package/dist/src/lib/delegator/permit-vincent-app-version.js +5 -7
- package/dist/src/lib/delegator/permit-vincent-app-version.js.map +1 -1
- package/dist/src/lib/delegator/platform-user-pkp.d.ts +10 -0
- package/dist/src/lib/delegator/platform-user-pkp.d.ts.map +1 -0
- package/dist/src/lib/delegator/platform-user-pkp.js +48 -0
- package/dist/src/lib/delegator/platform-user-pkp.js.map +1 -0
- package/dist/src/lib/ensure-capacity-credit.d.ts +2 -1
- package/dist/src/lib/ensure-capacity-credit.d.ts.map +1 -1
- package/dist/src/lib/ensure-capacity-credit.js +7 -4
- package/dist/src/lib/ensure-capacity-credit.js.map +1 -1
- package/dist/src/lib/env.d.ts +8 -2
- package/dist/src/lib/env.d.ts.map +1 -1
- package/dist/src/lib/env.js +7 -1
- package/dist/src/lib/env.js.map +1 -1
- package/dist/src/lib/funder/ensure-wallet-has-test-tokens.d.ts +2 -1
- package/dist/src/lib/funder/ensure-wallet-has-test-tokens.d.ts.map +1 -1
- package/dist/src/lib/funder/ensure-wallet-has-test-tokens.js +9 -7
- package/dist/src/lib/funder/ensure-wallet-has-test-tokens.js.map +1 -1
- package/dist/src/lib/index.d.ts +1 -1
- package/dist/src/lib/index.d.ts.map +1 -1
- package/dist/src/lib/index.js.map +1 -1
- package/dist/src/lib/litContractsClient/LitContractsInstance.d.ts +2 -1
- package/dist/src/lib/litContractsClient/LitContractsInstance.d.ts.map +1 -1
- package/dist/src/lib/litContractsClient/LitContractsInstance.js.map +1 -1
- package/dist/src/lib/litContractsClient/get-lit-contract-client.d.ts +2 -1
- package/dist/src/lib/litContractsClient/get-lit-contract-client.d.ts.map +1 -1
- package/dist/src/lib/litContractsClient/get-lit-contract-client.js.map +1 -1
- package/dist/src/lib/mint-new-pkp.d.ts +5 -3
- package/dist/src/lib/mint-new-pkp.d.ts.map +1 -1
- package/dist/src/lib/mint-new-pkp.js +10 -4
- package/dist/src/lib/mint-new-pkp.js.map +1 -1
- package/dist/src/lib/setup-vincent-development-environment.d.ts +10 -4
- package/dist/src/lib/setup-vincent-development-environment.d.ts.map +1 -1
- package/dist/src/lib/setup-vincent-development-environment.js +28 -7
- package/dist/src/lib/setup-vincent-development-environment.js.map +1 -1
- package/dist/src/lib/smartAccount/crossmint/setup-crossmint-account.d.ts.map +1 -1
- package/dist/src/lib/smartAccount/crossmint/setup-crossmint-account.js +1 -0
- package/dist/src/lib/smartAccount/crossmint/setup-crossmint-account.js.map +1 -1
- package/dist/src/lib/smartAccount/types.d.ts +1 -0
- package/dist/src/lib/smartAccount/types.d.ts.map +1 -1
- package/package.json +7 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
# 2.0.0 (2026-01-07)
|
|
2
2
|
|
|
3
|
-
###
|
|
3
|
+
### 🚀 Features
|
|
4
4
|
|
|
5
|
-
-
|
|
5
|
+
- feat: add Relay.link gated signer ability ([3eec29cb](https://github.com/LIT-Protocol/Vincent/commit/3eec29cb))
|
|
6
|
+
- **ability-relay-link**: New package - a Vincent Ability that acts as a secure gated signer for Relay.link swap operations. Supports ERC-4337 Smart Accounts (ZeroDev, Crossmint, Safe) and EOAs. Includes transaction decoding, simulation-based validation, and helpers for building/submitting UserOps.
|
|
7
|
+
- **ability-sdk**: Allow `validateSimulation` and `validateTransaction` lifecycle functions to be async to support dynamic address fetching.
|
|
8
|
+
- **e2e-test-utils**: Add Safe account setup helper, export Crossmint client from setup function, and rename `TEST_PLATFORM_USER_WALLET_OWNER_PRIVATE_KEY` env var to `TEST_AGENT_WALLET_PKP_OWNER_PRIVATE_KEY`. Update ENVs to be more chain-abstract.
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
- Adds a `enableSmartAccount` flag to the `setupVincentDevelopmentEnvironment`. Supports `safe`, `crossmint` and `zerodev` smart accounts. When the flag is set, the development environment will create a Smart Account owned by the `agentWalletOwner` (currently owns the Agent PKP for development). It will then add the Agent PKP as a signer on the Smart Account. ([77fe226d](https://github.com/LIT-Protocol/Vincent/commit/77fe226d))
|
|
8
11
|
|
|
9
|
-
###
|
|
12
|
+
### ⚠️ Breaking Changes
|
|
13
|
+
|
|
14
|
+
- Refactors dev environment to so that the dev EOA mints a Platforum User PKP which mints and owns an Agent PKP for each Vincent App ([d723a4ca](https://github.com/LIT-Protocol/Vincent/commit/d723a4ca))
|
|
15
|
+
|
|
16
|
+
### 🧱 Updated Dependencies
|
|
10
17
|
|
|
11
|
-
-
|
|
18
|
+
- Updated contracts-sdk to 6.0.0
|
|
19
|
+
|
|
20
|
+
### ❤️ Thank You
|
|
21
|
+
|
|
22
|
+
- awisniew207 @awisniew207
|
|
23
|
+
- Wyatt Barnes @spacesailor24
|
|
12
24
|
|
|
13
25
|
## 1.1.3 (2025-11-23)
|
|
14
26
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
## 1.1.3 (2025-11-23)
|
|
2
|
+
|
|
3
|
+
### 🧱 Updated Dependencies
|
|
4
|
+
|
|
5
|
+
- Updated contracts-sdk to 5.0.0
|
|
6
|
+
|
|
7
|
+
## 1.1.0 (2025-11-07)
|
|
8
|
+
|
|
9
|
+
### 🚀 Features
|
|
10
|
+
|
|
11
|
+
- Adds a `setupVincentDevelopmentEnvironment` function to streamline/abstract the developer experience. ([4ddce811](https://github.com/LIT-Protocol/Vincent/commit/4ddce811))
|
|
12
|
+
|
|
13
|
+
### ❤️ Thank You
|
|
14
|
+
|
|
15
|
+
- awisniew207 @awisniew207
|
|
16
|
+
|
|
17
|
+
# 1.0.0 (2025-11-06)
|
|
18
|
+
|
|
19
|
+
### 🚀 Features
|
|
20
|
+
|
|
21
|
+
- Add logic to registerNewAppVersion to avoid registering a new App version if the given Ability and Policy config matches the latest App version. Add logic to permitAppVersionForAgentWalletPkp to avoid permitting the App version if it's already been permitted. ([bbc0b752](https://github.com/LIT-Protocol/Vincent/commit/bbc0b752))
|
|
22
|
+
|
|
23
|
+
### ⚠️ Breaking Changes
|
|
24
|
+
|
|
25
|
+
- Initial release of Vincent E2E test util methods taken from the Vincent Ability Start Kit repo ([65b0a4a6](https://github.com/LIT-Protocol/Vincent/commit/65b0a4a6))
|
|
26
|
+
|
|
27
|
+
### ❤️ Thank You
|
|
28
|
+
|
|
29
|
+
- Wyatt Barnes @spacesailor24
|
|
30
|
+
|
|
31
|
+
# Changelog
|
|
32
|
+
|
|
33
|
+
## 0.1.0
|
|
34
|
+
|
|
35
|
+
Initial release of @lit-protocol/vincent-e2e-test-utils package.
|
|
File without changes
|
package/dist/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
E2E test utilities for the Vincent protocol, providing helper functions for setting up test environments, managing wallets, minting PKPs, and handling permissions.
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
<CodeGroup>
|
|
6
|
+
|
|
7
|
+
```bash npm
|
|
8
|
+
npm install @lit-protocol/vincent-e2e-test-utils
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```bash yarn
|
|
12
|
+
yarn add @lit-protocol/vincent-e2e-test-utils
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```bash pnpm
|
|
16
|
+
pnpm add @lit-protocol/vincent-e2e-test-utils
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
</CodeGroup>
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- **Quick Environment Setup**: `setupVincentDevelopmentEnvironment()` handles all the boilerplate for setting up a complete Vincent test environment
|
|
24
|
+
- **Wallet Management**: Create random wallets and manage test accounts with automatic funding
|
|
25
|
+
- **PKP Management**: Mint new PKPs and configure permissions
|
|
26
|
+
- **Capacity Token Handling**: Ensure unexpired capacity tokens for testing
|
|
27
|
+
- **Chain Helpers**: Access pre-configured providers and wallets for different networks
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
The easiest way to get started is with `setupVincentDevelopmentEnvironment()`:
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { setupVincentDevelopmentEnvironment } from '@lit-protocol/vincent-e2e-test-utils';
|
|
35
|
+
|
|
36
|
+
// Define your abilities and policies
|
|
37
|
+
const permissionData = {
|
|
38
|
+
[myAbility.ipfsCid]: {
|
|
39
|
+
[myPolicy.ipfsCid]: {
|
|
40
|
+
// policy configuration
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// Set up everything with one call
|
|
46
|
+
const { agentPkpInfo, wallets, appId, appVersion } = await setupVincentDevelopmentEnvironment({
|
|
47
|
+
permissionData,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Now you're ready to test!
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
This single function:
|
|
54
|
+
|
|
55
|
+
- Checks and funds all required accounts (funder, app delegatee, app manager)
|
|
56
|
+
- Registers or updates your app with abilities and policies
|
|
57
|
+
- Creates or uses an existing agent PKP
|
|
58
|
+
- Sets up permissions for the agent PKP
|
|
59
|
+
- Ensures a valid capacity token exists
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lit-protocol/vincent-e2e-test-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -11,9 +11,13 @@
|
|
|
11
11
|
"test:safe": "NODE_OPTIONS=--experimental-vm-modules dotenv -e .env jest test/smartAccount/safe.spec.ts"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
+
"@lit-protocol/auth-helpers": "^7",
|
|
15
|
+
"@lit-protocol/constants": "^7",
|
|
14
16
|
"@crossmint/wallets-sdk": "^0.18.7",
|
|
15
|
-
"@lit-protocol/constants": "^8.0.4",
|
|
16
17
|
"@lit-protocol/contracts-sdk": "^7.2.3",
|
|
18
|
+
"@lit-protocol/lit-node-client": "^7",
|
|
19
|
+
"@lit-protocol/pkp-ethers": "^7.3.1",
|
|
20
|
+
"@lit-protocol/types": "^7",
|
|
17
21
|
"@lit-protocol/vincent-contracts-sdk": "workspace:*",
|
|
18
22
|
"@t3-oss/env-core": "^0.13.8",
|
|
19
23
|
"@zerodev/ecdsa-validator": "^5.4.9",
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { delegator, delegatee, funder, chain, appManager, mintNewPkp, ensureUnexpiredCapacityToken, getEnv, getChainHelpers, createRandomVincentWallets, setupVincentDevelopmentEnvironment, setupZerodevAccount, setupCrossmintAccount, setupSafeAccount, } from './lib';
|
|
2
|
-
export type { PkpInfo, SmartAccountInfo, VincentDevEnvironment } from './lib';
|
|
2
|
+
export type { PkpInfo, SmartAccountInfo, ZerodevSmartAccountInfo, CrossmintSmartAccountInfo, SafeSmartAccountInfo, VincentDevEnvironment, } from './lib';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,SAAS,EACT,MAAM,EACN,KAAK,EACL,UAAU,EACV,UAAU,EACV,4BAA4B,EAC5B,MAAM,EACN,eAAe,EACf,0BAA0B,EAC1B,kCAAkC,EAClC,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,OAAO,CAAC;AAEf,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,SAAS,EACT,MAAM,EACN,KAAK,EACL,UAAU,EACV,UAAU,EACV,4BAA4B,EAC5B,MAAM,EACN,eAAe,EACf,0BAA0B,EAC1B,kCAAkC,EAClC,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,OAAO,CAAC;AAEf,YAAY,EACV,OAAO,EACP,gBAAgB,EAChB,uBAAuB,EACvB,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,OAAO,CAAC"}
|
package/dist/src/lib/chain.d.ts
CHANGED
|
@@ -2,13 +2,12 @@ import { ethers, Wallet } from 'ethers';
|
|
|
2
2
|
export declare const getChainHelpers: () => Promise<{
|
|
3
3
|
providers: {
|
|
4
4
|
yellowstone: ethers.providers.JsonRpcProvider;
|
|
5
|
-
base: ethers.providers.JsonRpcProvider;
|
|
6
5
|
};
|
|
7
6
|
wallets: {
|
|
8
7
|
appDelegatee: Wallet;
|
|
9
8
|
funder: Wallet;
|
|
10
9
|
appManager: Wallet;
|
|
11
|
-
|
|
10
|
+
platformUserWalletOwner: Wallet;
|
|
12
11
|
};
|
|
13
12
|
}>;
|
|
14
13
|
//# sourceMappingURL=chain.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../../src/lib/chain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../../src/lib/chain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAmBxC,eAAO,MAAM,eAAe;eAdf;QACT,WAAW,EAAE,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC;KAC/C;aACQ;QACP,YAAY,EAAE,MAAM,CAAC;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,uBAAuB,EAAE,MAAM,CAAC;KACjC;EAqCF,CAAC"}
|
package/dist/src/lib/chain.js
CHANGED
|
@@ -11,19 +11,17 @@ const getChainHelpers = async () => {
|
|
|
11
11
|
if (ethersHelpers) {
|
|
12
12
|
return ethersHelpers;
|
|
13
13
|
}
|
|
14
|
-
const { YELLOWSTONE_RPC_URL,
|
|
14
|
+
const { YELLOWSTONE_RPC_URL, TEST_FUNDER_PRIVATE_KEY, TEST_APP_MANAGER_PRIVATE_KEY, TEST_APP_DELEGATEE_PRIVATE_KEY, TEST_AGENT_WALLET_PKP_OWNER_PRIVATE_KEY, } = (0, env_1.getEnv)();
|
|
15
15
|
const yellowstoneProvider = new ethers_1.ethers.providers.JsonRpcProvider(YELLOWSTONE_RPC_URL);
|
|
16
|
-
const baseProvider = new ethers_1.ethers.providers.JsonRpcProvider(BASE_RPC_URL);
|
|
17
16
|
ethersHelpers = {
|
|
18
17
|
providers: {
|
|
19
18
|
yellowstone: yellowstoneProvider,
|
|
20
|
-
base: baseProvider,
|
|
21
19
|
},
|
|
22
20
|
wallets: {
|
|
23
21
|
appDelegatee: new ethers_1.Wallet(TEST_APP_DELEGATEE_PRIVATE_KEY, yellowstoneProvider),
|
|
24
22
|
funder: new ethers_1.Wallet(TEST_FUNDER_PRIVATE_KEY, yellowstoneProvider),
|
|
25
23
|
appManager: new ethers_1.Wallet(TEST_APP_MANAGER_PRIVATE_KEY, yellowstoneProvider),
|
|
26
|
-
|
|
24
|
+
platformUserWalletOwner: new ethers_1.Wallet(TEST_AGENT_WALLET_PKP_OWNER_PRIVATE_KEY, yellowstoneProvider),
|
|
27
25
|
},
|
|
28
26
|
};
|
|
29
27
|
return ethersHelpers;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.js","sourceRoot":"","sources":["../../../src/lib/chain.ts"],"names":[],"mappings":";;;AAAA,mCAAwC;AAExC,+BAA+B;AAE/B,IAAI,
|
|
1
|
+
{"version":3,"file":"chain.js","sourceRoot":"","sources":["../../../src/lib/chain.ts"],"names":[],"mappings":";;;AAAA,mCAAwC;AAExC,+BAA+B;AAE/B,IAAI,aAUH,CAAC;AAEF,kGAAkG;AAClG,wGAAwG;AACxG,iIAAiI;AAC1H,MAAM,eAAe,GAAG,KAAK,IAAI,EAAE;IACxC,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,MAAM,EACJ,mBAAmB,EACnB,uBAAuB,EACvB,4BAA4B,EAC5B,8BAA8B,EAC9B,uCAAuC,GACxC,GAAG,IAAA,YAAM,GAAE,CAAC;IAEb,MAAM,mBAAmB,GAAG,IAAI,eAAM,CAAC,SAAS,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC;IAEtF,aAAa,GAAG;QACd,SAAS,EAAE;YACT,WAAW,EAAE,mBAAmB;SACjC;QACD,OAAO,EAAE;YACP,YAAY,EAAE,IAAI,eAAM,CAAC,8BAA8B,EAAE,mBAAmB,CAAC;YAC7E,MAAM,EAAE,IAAI,eAAM,CAAC,uBAAuB,EAAE,mBAAmB,CAAC;YAChE,UAAU,EAAE,IAAI,eAAM,CAAC,4BAA4B,EAAE,mBAAmB,CAAC;YACzE,uBAAuB,EAAE,IAAI,eAAM,CACjC,uCAAuC,EACvC,mBAAmB,CACpB;SACF;KACF,CAAC;IAEF,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC;AA/BW,QAAA,eAAe,mBA+B1B"}
|
|
@@ -6,7 +6,7 @@ function createRandomVincentWallets() {
|
|
|
6
6
|
return {
|
|
7
7
|
appDelegatee: ethers_1.Wallet.createRandom(),
|
|
8
8
|
appManager: ethers_1.Wallet.createRandom(),
|
|
9
|
-
|
|
9
|
+
platformUserWalletOwner: ethers_1.Wallet.createRandom(),
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=create-random-vincent-wallets.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-random-vincent-wallets.js","sourceRoot":"","sources":["../../../src/lib/create-random-vincent-wallets.ts"],"names":[],"mappings":";;AAEA,gEAMC;AARD,mCAAgC;AAEhC,SAAgB,0BAA0B;IACxC,OAAO;QACL,YAAY,EAAE,eAAM,CAAC,YAAY,EAAE;QACnC,UAAU,EAAE,eAAM,CAAC,YAAY,EAAE;QACjC,
|
|
1
|
+
{"version":3,"file":"create-random-vincent-wallets.js","sourceRoot":"","sources":["../../../src/lib/create-random-vincent-wallets.ts"],"names":[],"mappings":";;AAEA,gEAMC;AARD,mCAAgC;AAEhC,SAAgB,0BAA0B;IACxC,OAAO;QACL,YAAY,EAAE,eAAM,CAAC,YAAY,EAAE;QACnC,UAAU,EAAE,eAAM,CAAC,YAAY,EAAE;QACjC,uBAAuB,EAAE,eAAM,CAAC,YAAY,EAAE;KAC/C,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { Wallet } from 'ethers';
|
|
2
|
-
|
|
2
|
+
import type { PKPEthersWallet } from '@lit-protocol/pkp-ethers';
|
|
3
|
+
export declare const addPermissionForAbilities: (wallet: Wallet | PKPEthersWallet, pkpTokenId: string, abilityIpfsCids: string[]) => Promise<void>;
|
|
3
4
|
//# sourceMappingURL=add-permission-for-abilities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-permission-for-abilities.d.ts","sourceRoot":"","sources":["../../../../src/lib/delegator/add-permission-for-abilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"add-permission-for-abilities.d.ts","sourceRoot":"","sources":["../../../../src/lib/delegator/add-permission-for-abilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAShE,eAAO,MAAM,yBAAyB,GACpC,QAAQ,MAAM,GAAG,eAAe,EAChC,YAAY,MAAM,EAClB,iBAAiB,MAAM,EAAE,kBAe1B,CAAC"}
|
|
@@ -3,12 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.addPermissionForAbilities = void 0;
|
|
4
4
|
const constants_1 = require("@lit-protocol/constants");
|
|
5
5
|
const get_lit_contract_client_1 = require("../litContractsClient/get-lit-contract-client");
|
|
6
|
-
// The LIT network requires that abilities be permitted for the
|
|
7
|
-
// This is part of the PKP ecosystem and is managed independently of the Vincent Delegation contract
|
|
6
|
+
// The LIT network requires that abilities be permitted for the Agent PKP to execute Lit Actions.
|
|
7
|
+
// This is part of the PKP ecosystem and is managed independently of the Vincent Delegation contract.
|
|
8
|
+
// The Platform User PKP wallet is used to add these permissions to the Agent PKP.
|
|
8
9
|
const addPermissionForAbilities = async (wallet, pkpTokenId, abilityIpfsCids) => {
|
|
9
10
|
const litContractClient = await (0, get_lit_contract_client_1.getLitContractsClient)({ wallet });
|
|
10
11
|
for (const ipfsCid of abilityIpfsCids) {
|
|
11
|
-
console.log(`Permitting ability: ${ipfsCid} with ability to sign on behalf of
|
|
12
|
+
console.log(`Permitting ability: ${ipfsCid} with ability to sign on behalf of Agent PKP ${pkpTokenId}`);
|
|
12
13
|
await litContractClient.addPermittedAction({
|
|
13
14
|
pkpTokenId,
|
|
14
15
|
ipfsId: ipfsCid,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-permission-for-abilities.js","sourceRoot":"","sources":["../../../../src/lib/delegator/add-permission-for-abilities.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"add-permission-for-abilities.js","sourceRoot":"","sources":["../../../../src/lib/delegator/add-permission-for-abilities.ts"],"names":[],"mappings":";;;AAIA,uDAA4D;AAE5D,2FAAsF;AAEtF,iGAAiG;AACjG,qGAAqG;AACrG,kFAAkF;AAC3E,MAAM,yBAAyB,GAAG,KAAK,EAC5C,MAAgC,EAChC,UAAkB,EAClB,eAAyB,EACzB,EAAE;IACF,MAAM,iBAAiB,GAAG,MAAM,IAAA,+CAAqB,EAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAElE,KAAK,MAAM,OAAO,IAAI,eAAe,EAAE,CAAC;QACtC,OAAO,CAAC,GAAG,CACT,uBAAuB,OAAO,gDAAgD,UAAU,EAAE,CAC3F,CAAC;QAEF,MAAM,iBAAiB,CAAC,kBAAkB,CAAC;YACzC,UAAU;YACV,MAAM,EAAE,OAAO;YACf,gBAAgB,EAAE,CAAC,6BAAiB,CAAC,YAAY,CAAC;SACnD,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC;AAlBW,QAAA,yBAAyB,6BAkBpC"}
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import type { PkpInfo } from '../mint-new-pkp';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Get an existing Agent PKP for a specific app ID, or mint a new one if none exists.
|
|
4
|
+
* The Agent PKP will be owned by the User Platform PKP.
|
|
5
|
+
* This function queries all Agent PKPs owned by the User Platform PKP and finds the one
|
|
6
|
+
* that has permissions for the specified app ID.
|
|
7
|
+
* @param appId the app ID to get or create an Agent PKP for
|
|
8
|
+
* @returns the Agent PKP info for the specified app
|
|
9
|
+
*/
|
|
10
|
+
export declare const ensureAgentPkpExists: (appId: number) => Promise<PkpInfo>;
|
|
11
|
+
export declare const ensureFundedAgentPkpExists: (appId: number) => Promise<PkpInfo>;
|
|
12
|
+
/**
|
|
13
|
+
* Returns Agent PKP info for a specific app for this run.
|
|
14
|
+
* This method will mint a new Agent PKP if none exists for the specified app.
|
|
15
|
+
* This method will also fund the Agent PKP if it is not already funded.
|
|
16
|
+
* @param appId the app ID to get a funded Agent PKP for
|
|
17
|
+
* @returns the funded Agent PKP info for the specified app
|
|
18
|
+
*/
|
|
19
|
+
export declare const getFundedAgentPkp: (appId: number) => Promise<PkpInfo>;
|
|
5
20
|
//# sourceMappingURL=agent-pkp.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-pkp.d.ts","sourceRoot":"","sources":["../../../../src/lib/delegator/agent-pkp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"agent-pkp.d.ts","sourceRoot":"","sources":["../../../../src/lib/delegator/agent-pkp.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAS/C;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,GAAU,OAAO,MAAM,KAAG,OAAO,CAAC,OAAO,CA6EzE,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAU,OAAO,MAAM,KAAG,OAAO,CAAC,OAAO,CAM/E,CAAC;AAKF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAU,OAAO,MAAM,KAAG,OAAO,CAAC,OAAO,CAWtE,CAAC"}
|
|
@@ -1,45 +1,96 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getFundedAgentPkp = exports.ensureFundedAgentPkpExists = exports.ensureAgentPkpExists = void 0;
|
|
4
|
+
const vincent_contracts_sdk_1 = require("@lit-protocol/vincent-contracts-sdk");
|
|
4
5
|
const chain_1 = require("../chain");
|
|
5
6
|
const ensure_wallet_has_test_tokens_1 = require("../funder/ensure-wallet-has-test-tokens");
|
|
6
7
|
const get_lit_contract_client_1 = require("../litContractsClient/get-lit-contract-client");
|
|
7
8
|
const mint_new_pkp_1 = require("../mint-new-pkp");
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
const get_platform_user_pkp_wallet_1 = require("./get-platform-user-pkp-wallet");
|
|
10
|
+
const platform_user_pkp_1 = require("./platform-user-pkp");
|
|
11
|
+
/**
|
|
12
|
+
* Get an existing Agent PKP for a specific app ID, or mint a new one if none exists.
|
|
13
|
+
* The Agent PKP will be owned by the User Platform PKP.
|
|
14
|
+
* This function queries all Agent PKPs owned by the User Platform PKP and finds the one
|
|
15
|
+
* that has permissions for the specified app ID.
|
|
16
|
+
* @param appId the app ID to get or create an Agent PKP for
|
|
17
|
+
* @returns the Agent PKP info for the specified app
|
|
18
|
+
*/
|
|
19
|
+
const ensureAgentPkpExists = async (appId) => {
|
|
20
|
+
const { wallets: { platformUserWalletOwner }, } = await (0, chain_1.getChainHelpers)();
|
|
21
|
+
// Get or create the Platform User PKP first
|
|
22
|
+
const platformUserPkp = await (0, platform_user_pkp_1.getFundedPlatformUserPkp)();
|
|
23
|
+
// Get all PKPs owned by the Platform User PKP using Lit Contracts Client
|
|
24
|
+
const litContractClient = await (0, get_lit_contract_client_1.getLitContractsClient)({ wallet: platformUserWalletOwner });
|
|
25
|
+
await litContractClient.connect();
|
|
26
|
+
const ownedPkps = await litContractClient.pkpNftContractUtils.read.getTokensInfoByAddress(platformUserPkp.ethAddress);
|
|
27
|
+
console.log(`Platform User PKP ${platformUserPkp.ethAddress} owns ${ownedPkps.length} Agent PKP(s)`);
|
|
28
|
+
// If there are owned PKPs, query their permitted apps to find the one for this app ID
|
|
16
29
|
if (ownedPkps.length > 0) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
30
|
+
const client = (0, vincent_contracts_sdk_1.getClient)({ signer: platformUserWalletOwner });
|
|
31
|
+
// Query all owned PKP addresses to find which one has permission for this app
|
|
32
|
+
const pkpAddresses = ownedPkps.map((pkp) => pkp.ethAddress);
|
|
33
|
+
// Get permitted apps for all owned PKPs
|
|
34
|
+
const permittedAppsData = await client.getPermittedAppsForPkps({
|
|
35
|
+
pkpEthAddresses: pkpAddresses,
|
|
36
|
+
offset: '0',
|
|
37
|
+
});
|
|
38
|
+
// Find the PKP that has permission for the specified app ID
|
|
39
|
+
for (const pkpData of permittedAppsData) {
|
|
40
|
+
const hasAppPermission = pkpData.permittedApps.some((app) => app.appId === appId);
|
|
41
|
+
if (hasAppPermission) {
|
|
42
|
+
const matchingPkp = ownedPkps.find((pkp) => pkp.tokenId === pkpData.pkpTokenId);
|
|
43
|
+
if (matchingPkp) {
|
|
44
|
+
console.log(`Found existing Agent PKP for app ${appId} with ethAddress: ${matchingPkp.ethAddress}, tokenId: ${matchingPkp.tokenId}`);
|
|
45
|
+
const publicKey = await litContractClient.pkpNftContract.read.getPubkey(matchingPkp.tokenId);
|
|
46
|
+
return {
|
|
47
|
+
tokenId: matchingPkp.tokenId,
|
|
48
|
+
ethAddress: matchingPkp.ethAddress,
|
|
49
|
+
publicKey,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
20
54
|
}
|
|
21
|
-
console.log(`No
|
|
22
|
-
// Be sure the
|
|
23
|
-
await (0, ensure_wallet_has_test_tokens_1.ensureWalletHasTestTokens)({ address:
|
|
24
|
-
|
|
25
|
-
|
|
55
|
+
console.log(`No Agent PKP found for app ${appId}; minting a new Agent PKP owned by Platform User PKP ${platformUserPkp.ethAddress}...`);
|
|
56
|
+
// Be sure the platformUserPkp has enough test tokens to mint a new PKP
|
|
57
|
+
await (0, ensure_wallet_has_test_tokens_1.ensureWalletHasTestTokens)({ address: platformUserPkp.ethAddress });
|
|
58
|
+
// Get PKP Ethers Wallet for the Platform User PKP
|
|
59
|
+
const platformUserPkpWallet = await (0, get_platform_user_pkp_wallet_1.getPlatformUserPkpWallet)(platformUserPkp);
|
|
60
|
+
// Mint a new PKP using the Platform User PKP's wallet
|
|
61
|
+
// This makes the Platform User PKP the owner and controller of the Agent PKP
|
|
62
|
+
const { tokenId, ethAddress, publicKey } = await (0, mint_new_pkp_1.mintNewPkp)({
|
|
63
|
+
wallet: platformUserPkpWallet,
|
|
64
|
+
});
|
|
65
|
+
console.log(`Minted new Agent PKP ${ethAddress} owned by Platform User PKP ${platformUserPkp.ethAddress}`);
|
|
66
|
+
return { tokenId, ethAddress, publicKey };
|
|
26
67
|
};
|
|
27
68
|
exports.ensureAgentPkpExists = ensureAgentPkpExists;
|
|
28
|
-
const ensureFundedAgentPkpExists = async () => {
|
|
29
|
-
const agentPkp = await (0, exports.ensureAgentPkpExists)();
|
|
69
|
+
const ensureFundedAgentPkpExists = async (appId) => {
|
|
70
|
+
const agentPkp = await (0, exports.ensureAgentPkpExists)(appId);
|
|
30
71
|
await (0, ensure_wallet_has_test_tokens_1.ensureWalletHasTestTokens)({ address: agentPkp.ethAddress });
|
|
31
72
|
return agentPkp;
|
|
32
73
|
};
|
|
33
74
|
exports.ensureFundedAgentPkpExists = ensureFundedAgentPkpExists;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
75
|
+
// Map to store Agent PKPs by app ID for the current run
|
|
76
|
+
const agentPkpsByAppId = new Map();
|
|
77
|
+
/**
|
|
78
|
+
* Returns Agent PKP info for a specific app for this run.
|
|
79
|
+
* This method will mint a new Agent PKP if none exists for the specified app.
|
|
80
|
+
* This method will also fund the Agent PKP if it is not already funded.
|
|
81
|
+
* @param appId the app ID to get a funded Agent PKP for
|
|
82
|
+
* @returns the funded Agent PKP info for the specified app
|
|
83
|
+
*/
|
|
84
|
+
const getFundedAgentPkp = async (appId) => {
|
|
85
|
+
const cached = agentPkpsByAppId.get(appId);
|
|
86
|
+
if (cached) {
|
|
87
|
+
// Verify that the cached PKP still has sufficient funds
|
|
88
|
+
await (0, ensure_wallet_has_test_tokens_1.ensureWalletHasTestTokens)({ address: cached.ethAddress });
|
|
89
|
+
return cached;
|
|
41
90
|
}
|
|
42
|
-
|
|
91
|
+
const agentPkp = await (0, exports.ensureFundedAgentPkpExists)(appId);
|
|
92
|
+
agentPkpsByAppId.set(appId, agentPkp);
|
|
93
|
+
return agentPkp;
|
|
43
94
|
};
|
|
44
95
|
exports.getFundedAgentPkp = getFundedAgentPkp;
|
|
45
96
|
//# sourceMappingURL=agent-pkp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-pkp.js","sourceRoot":"","sources":["../../../../src/lib/delegator/agent-pkp.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"agent-pkp.js","sourceRoot":"","sources":["../../../../src/lib/delegator/agent-pkp.ts"],"names":[],"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;IAEF,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;AAC5C,CAAC,CAAC;AA7EW,QAAA,oBAAoB,wBA6E/B;AAEK,MAAM,0BAA0B,GAAG,KAAK,EAAE,KAAa,EAAoB,EAAE;IAClF,MAAM,QAAQ,GAAG,MAAM,IAAA,4BAAoB,EAAC,KAAK,CAAC,CAAC;IAEnD,MAAM,IAAA,yDAAyB,EAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IAElE,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AANW,QAAA,0BAA0B,8BAMrC;AAEF,wDAAwD;AACxD,MAAM,gBAAgB,GAAyB,IAAI,GAAG,EAAE,CAAC;AAEzD;;;;;;GAMG;AACI,MAAM,iBAAiB,GAAG,KAAK,EAAE,KAAa,EAAoB,EAAE;IACzE,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC3C,IAAI,MAAM,EAAE,CAAC;QACX,wDAAwD;QACxD,MAAM,IAAA,yDAAyB,EAAC,EAAE,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;QAChE,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,IAAA,kCAA0B,EAAC,KAAK,CAAC,CAAC;IACzD,gBAAgB,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACtC,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAXW,QAAA,iBAAiB,qBAW5B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PKPEthersWallet } from '@lit-protocol/pkp-ethers';
|
|
2
|
+
import type { PkpInfo } from '../mint-new-pkp';
|
|
3
|
+
/**
|
|
4
|
+
* Get a PKPEthersWallet instance for the Platform User PKP
|
|
5
|
+
* This wallet can be used to sign transactions and mint new PKPs on behalf of the Platform User PKP
|
|
6
|
+
*/
|
|
7
|
+
export declare const getPlatformUserPkpWallet: (platformUserPkpInfo: PkpInfo) => Promise<PKPEthersWallet>;
|
|
8
|
+
//# sourceMappingURL=get-platform-user-pkp-wallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-platform-user-pkp-wallet.d.ts","sourceRoot":"","sources":["../../../../src/lib/delegator/get-platform-user-pkp-wallet.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAyB/C;;;GAGG;AACH,eAAO,MAAM,wBAAwB,GACnC,qBAAqB,OAAO,KAC3B,OAAO,CAAC,eAAe,CAkEzB,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPlatformUserPkpWallet = void 0;
|
|
4
|
+
const auth_helpers_1 = require("@lit-protocol/auth-helpers");
|
|
5
|
+
const constants_1 = require("@lit-protocol/constants");
|
|
6
|
+
const lit_node_client_1 = require("@lit-protocol/lit-node-client");
|
|
7
|
+
const pkp_ethers_1 = require("@lit-protocol/pkp-ethers");
|
|
8
|
+
const chain_1 = require("../chain");
|
|
9
|
+
const get_lit_contract_client_1 = require("../litContractsClient/get-lit-contract-client");
|
|
10
|
+
const SELECTED_LIT_NETWORK = constants_1.LIT_NETWORK.Datil;
|
|
11
|
+
let litNodeClient = null;
|
|
12
|
+
const getLitNodeClient = async () => {
|
|
13
|
+
if (litNodeClient) {
|
|
14
|
+
return litNodeClient;
|
|
15
|
+
}
|
|
16
|
+
litNodeClient = new lit_node_client_1.LitNodeClient({
|
|
17
|
+
alertWhenUnauthorized: false,
|
|
18
|
+
litNetwork: SELECTED_LIT_NETWORK,
|
|
19
|
+
debug: false,
|
|
20
|
+
});
|
|
21
|
+
await litNodeClient.connect();
|
|
22
|
+
return litNodeClient;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Get a PKPEthersWallet instance for the Platform User PKP
|
|
26
|
+
* This wallet can be used to sign transactions and mint new PKPs on behalf of the Platform User PKP
|
|
27
|
+
*/
|
|
28
|
+
const getPlatformUserPkpWallet = async (platformUserPkpInfo) => {
|
|
29
|
+
const { wallets: { platformUserWalletOwner }, } = await (0, chain_1.getChainHelpers)();
|
|
30
|
+
const litContractClient = await (0, get_lit_contract_client_1.getLitContractsClient)({ wallet: platformUserWalletOwner });
|
|
31
|
+
await litContractClient.connect();
|
|
32
|
+
const client = await getLitNodeClient();
|
|
33
|
+
// Get the PKP's public key
|
|
34
|
+
const publicKey = await litContractClient.pkpNftContract.read.getPubkey(platformUserPkpInfo.tokenId);
|
|
35
|
+
console.log(`Creating PKP Ethers Wallet for Platform User PKP ${platformUserPkpInfo.ethAddress}...`);
|
|
36
|
+
// Get session signatures for controlling the PKP
|
|
37
|
+
// The EOA wallet owner signs to prove it has authority to use the PKP
|
|
38
|
+
const sessionSigs = await client.getSessionSigs({
|
|
39
|
+
chain: 'ethereum',
|
|
40
|
+
resourceAbilityRequests: [
|
|
41
|
+
{
|
|
42
|
+
resource: new auth_helpers_1.LitPKPResource('*'),
|
|
43
|
+
ability: constants_1.LIT_ABILITY.PKPSigning,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
resource: new auth_helpers_1.LitActionResource('*'),
|
|
47
|
+
ability: constants_1.LIT_ABILITY.LitActionExecution,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
authNeededCallback: async ({ resourceAbilityRequests, uri }) => {
|
|
51
|
+
const [walletAddress, nonce] = await Promise.all([
|
|
52
|
+
platformUserWalletOwner.getAddress(),
|
|
53
|
+
client.getLatestBlockhash(),
|
|
54
|
+
]);
|
|
55
|
+
const toSign = await (0, auth_helpers_1.createSiweMessageWithRecaps)({
|
|
56
|
+
uri: uri || 'http://localhost:3000',
|
|
57
|
+
expiration: new Date(Date.now() + 1000 * 60 * 60 * 1).toISOString(), // 1 hour
|
|
58
|
+
resources: resourceAbilityRequests || [],
|
|
59
|
+
walletAddress,
|
|
60
|
+
nonce,
|
|
61
|
+
litNodeClient: client,
|
|
62
|
+
});
|
|
63
|
+
return await (0, auth_helpers_1.generateAuthSig)({ signer: platformUserWalletOwner, toSign });
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
// Create PKP Ethers Wallet with RPC provider for proper gas estimation
|
|
67
|
+
const pkpWallet = new pkp_ethers_1.PKPEthersWallet({
|
|
68
|
+
litNodeClient: client,
|
|
69
|
+
pkpPubKey: publicKey,
|
|
70
|
+
controllerSessionSigs: sessionSigs,
|
|
71
|
+
});
|
|
72
|
+
await pkpWallet.init();
|
|
73
|
+
console.log(`PKP Ethers Wallet initialized for Platform User PKP ${await pkpWallet.getAddress()}`);
|
|
74
|
+
return pkpWallet;
|
|
75
|
+
};
|
|
76
|
+
exports.getPlatformUserPkpWallet = getPlatformUserPkpWallet;
|
|
77
|
+
//# sourceMappingURL=get-platform-user-pkp-wallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-platform-user-pkp-wallet.js","sourceRoot":"","sources":["../../../../src/lib/delegator/get-platform-user-pkp-wallet.ts"],"names":[],"mappings":";;;AAEA,6DAKoC;AACpC,uDAAmE;AACnE,mEAA8D;AAC9D,yDAA2D;AAI3D,oCAA2C;AAC3C,2FAAsF;AAEtF,MAAM,oBAAoB,GAAG,uBAAW,CAAC,KAA0B,CAAC;AAEpE,IAAI,aAAa,GAAyB,IAAI,CAAC;AAE/C,MAAM,gBAAgB,GAAG,KAAK,IAA4B,EAAE;IAC1D,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,aAAa,GAAG,IAAI,+BAAa,CAAC;QAChC,qBAAqB,EAAE,KAAK;QAC5B,UAAU,EAAE,oBAAoB;QAChC,KAAK,EAAE,KAAK;KACb,CAAC,CAAC;I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;YAEH,MAAM,MAAM,GAAG,MAAM,IAAA,0CAA2B,EAAC;gBAC/C,GAAG,EAAE,GAAG,IAAI,uBAAuB;gBACnC,UAAU,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,SAAS;gBAC9E,SAAS,EAAE,uBAAuB,IAAI,EAAE;gBACxC,aAAa;gBACb,KAAK;gBACL,aAAa,EAAE,MAAM;aACtB,CAAC,CAAC;YAEH,OAAO,MAAM,IAAA,8BAAe,EAAC,EAAE,MAAM,EAAE,uBAAuB,EAAE,MAAM,EAAE,CAAC,CAAC;QAC5E,CAAC;KACF,CAAC,CAAC;IAEH,uEAAuE;IACvE,MAAM,SAAS,GAAG,IAAI,4BAAe,CAAC;QACpC,aAAa,EAAE,MAAM;QACrB,SAAS,EAAE,SAAS;QACpB,qBAAqB,EAAE,WAAW;KACnC,CAAC,CAAC;IAEH,MAAM,SAAS,CAAC,IAAI,EAAE,CAAC;IAEvB,OAAO,CAAC,GAAG,CACT,uDAAuD,MAAM,SAAS,CAAC,UAAU,EAAE,EAAE,CACtF,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AApEW,QAAA,wBAAwB,4BAoEnC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { addPermissionForAbilities } from './add-permission-for-abilities';
|
|
2
2
|
export { mintNewPkp } from '../mint-new-pkp';
|
|
3
3
|
export { getFundedAgentPkp, ensureAgentPkpExists, ensureFundedAgentPkpExists } from './agent-pkp';
|
|
4
|
+
export { getPlatformUserPkpWallet } from './get-platform-user-pkp-wallet';
|
|
5
|
+
export { getFundedPlatformUserPkp, ensurePlatformUserPkpExists, ensureFundedPlatformUserPkpExists, } from './platform-user-pkp';
|
|
4
6
|
export { permitAppVersionForAgentWalletPkp } from './permit-vincent-app-version';
|
|
5
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/delegator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAClG,OAAO,EAAE,iCAAiC,EAAE,MAAM,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/delegator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAClG,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,iCAAiC,GAClC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iCAAiC,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.permitAppVersionForAgentWalletPkp = exports.ensureFundedAgentPkpExists = exports.ensureAgentPkpExists = exports.getFundedAgentPkp = exports.mintNewPkp = exports.addPermissionForAbilities = void 0;
|
|
3
|
+
exports.permitAppVersionForAgentWalletPkp = exports.ensureFundedPlatformUserPkpExists = exports.ensurePlatformUserPkpExists = exports.getFundedPlatformUserPkp = exports.getPlatformUserPkpWallet = exports.ensureFundedAgentPkpExists = exports.ensureAgentPkpExists = exports.getFundedAgentPkp = exports.mintNewPkp = exports.addPermissionForAbilities = void 0;
|
|
4
4
|
var add_permission_for_abilities_1 = require("./add-permission-for-abilities");
|
|
5
5
|
Object.defineProperty(exports, "addPermissionForAbilities", { enumerable: true, get: function () { return add_permission_for_abilities_1.addPermissionForAbilities; } });
|
|
6
6
|
var mint_new_pkp_1 = require("../mint-new-pkp");
|
|
@@ -9,6 +9,12 @@ var agent_pkp_1 = require("./agent-pkp");
|
|
|
9
9
|
Object.defineProperty(exports, "getFundedAgentPkp", { enumerable: true, get: function () { return agent_pkp_1.getFundedAgentPkp; } });
|
|
10
10
|
Object.defineProperty(exports, "ensureAgentPkpExists", { enumerable: true, get: function () { return agent_pkp_1.ensureAgentPkpExists; } });
|
|
11
11
|
Object.defineProperty(exports, "ensureFundedAgentPkpExists", { enumerable: true, get: function () { return agent_pkp_1.ensureFundedAgentPkpExists; } });
|
|
12
|
+
var get_platform_user_pkp_wallet_1 = require("./get-platform-user-pkp-wallet");
|
|
13
|
+
Object.defineProperty(exports, "getPlatformUserPkpWallet", { enumerable: true, get: function () { return get_platform_user_pkp_wallet_1.getPlatformUserPkpWallet; } });
|
|
14
|
+
var platform_user_pkp_1 = require("./platform-user-pkp");
|
|
15
|
+
Object.defineProperty(exports, "getFundedPlatformUserPkp", { enumerable: true, get: function () { return platform_user_pkp_1.getFundedPlatformUserPkp; } });
|
|
16
|
+
Object.defineProperty(exports, "ensurePlatformUserPkpExists", { enumerable: true, get: function () { return platform_user_pkp_1.ensurePlatformUserPkpExists; } });
|
|
17
|
+
Object.defineProperty(exports, "ensureFundedPlatformUserPkpExists", { enumerable: true, get: function () { return platform_user_pkp_1.ensureFundedPlatformUserPkpExists; } });
|
|
12
18
|
var permit_vincent_app_version_1 = require("./permit-vincent-app-version");
|
|
13
19
|
Object.defineProperty(exports, "permitAppVersionForAgentWalletPkp", { enumerable: true, get: function () { return permit_vincent_app_version_1.permitAppVersionForAgentWalletPkp; } });
|
|
14
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/delegator/index.ts"],"names":[],"mappings":";;;AAAA,+EAA2E;AAAlE,yIAAA,yBAAyB,OAAA;AAClC,gDAA6C;AAApC,0GAAA,UAAU,OAAA;AACnB,yCAAkG;AAAzF,8GAAA,iBAAiB,OAAA;AAAE,iHAAA,oBAAoB,OAAA;AAAE,uHAAA,0BAA0B,OAAA;AAC5E,2EAAiF;AAAxE,+IAAA,iCAAiC,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/delegator/index.ts"],"names":[],"mappings":";;;AAAA,+EAA2E;AAAlE,yIAAA,yBAAyB,OAAA;AAClC,gDAA6C;AAApC,0GAAA,UAAU,OAAA;AACnB,yCAAkG;AAAzF,8GAAA,iBAAiB,OAAA;AAAE,iHAAA,oBAAoB,OAAA;AAAE,uHAAA,0BAA0B,OAAA;AAC5E,+EAA0E;AAAjE,wIAAA,wBAAwB,OAAA;AACjC,yDAI6B;AAH3B,6HAAA,wBAAwB,OAAA;AACxB,gIAAA,2BAA2B,OAAA;AAC3B,sIAAA,iCAAiC,OAAA;AAEnC,2EAAiF;AAAxE,+IAAA,iCAAiC,OAAA"}
|