@lit-protocol/vincent-e2e-test-utils 1.2.1 → 2.0.1

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 (73) hide show
  1. package/CHANGELOG.md +23 -5
  2. package/dist/CHANGELOG.md +59 -0
  3. package/dist/CONTRIBUTING.md +0 -0
  4. package/dist/README.md +59 -0
  5. package/dist/package.json +6 -2
  6. package/dist/src/index.d.ts +1 -1
  7. package/dist/src/index.d.ts.map +1 -1
  8. package/dist/src/lib/chain.d.ts +1 -2
  9. package/dist/src/lib/chain.d.ts.map +1 -1
  10. package/dist/src/lib/chain.js +2 -4
  11. package/dist/src/lib/chain.js.map +1 -1
  12. package/dist/src/lib/create-random-vincent-wallets.d.ts +1 -1
  13. package/dist/src/lib/create-random-vincent-wallets.js +1 -1
  14. package/dist/src/lib/create-random-vincent-wallets.js.map +1 -1
  15. package/dist/src/lib/delegator/add-permission-for-abilities.d.ts +2 -1
  16. package/dist/src/lib/delegator/add-permission-for-abilities.d.ts.map +1 -1
  17. package/dist/src/lib/delegator/add-permission-for-abilities.js +4 -3
  18. package/dist/src/lib/delegator/add-permission-for-abilities.js.map +1 -1
  19. package/dist/src/lib/delegator/agent-pkp.d.ts +18 -3
  20. package/dist/src/lib/delegator/agent-pkp.d.ts.map +1 -1
  21. package/dist/src/lib/delegator/agent-pkp.js +77 -26
  22. package/dist/src/lib/delegator/agent-pkp.js.map +1 -1
  23. package/dist/src/lib/delegator/get-platform-user-pkp-wallet.d.ts +8 -0
  24. package/dist/src/lib/delegator/get-platform-user-pkp-wallet.d.ts.map +1 -0
  25. package/dist/src/lib/delegator/get-platform-user-pkp-wallet.js +77 -0
  26. package/dist/src/lib/delegator/get-platform-user-pkp-wallet.js.map +1 -0
  27. package/dist/src/lib/delegator/index.d.ts +2 -0
  28. package/dist/src/lib/delegator/index.d.ts.map +1 -1
  29. package/dist/src/lib/delegator/index.js +7 -1
  30. package/dist/src/lib/delegator/index.js.map +1 -1
  31. package/dist/src/lib/delegator/permit-vincent-app-version.d.ts +4 -2
  32. package/dist/src/lib/delegator/permit-vincent-app-version.d.ts.map +1 -1
  33. package/dist/src/lib/delegator/permit-vincent-app-version.js +5 -7
  34. package/dist/src/lib/delegator/permit-vincent-app-version.js.map +1 -1
  35. package/dist/src/lib/delegator/platform-user-pkp.d.ts +10 -0
  36. package/dist/src/lib/delegator/platform-user-pkp.d.ts.map +1 -0
  37. package/dist/src/lib/delegator/platform-user-pkp.js +48 -0
  38. package/dist/src/lib/delegator/platform-user-pkp.js.map +1 -0
  39. package/dist/src/lib/ensure-capacity-credit.d.ts +2 -1
  40. package/dist/src/lib/ensure-capacity-credit.d.ts.map +1 -1
  41. package/dist/src/lib/ensure-capacity-credit.js +7 -4
  42. package/dist/src/lib/ensure-capacity-credit.js.map +1 -1
  43. package/dist/src/lib/env.d.ts +8 -2
  44. package/dist/src/lib/env.d.ts.map +1 -1
  45. package/dist/src/lib/env.js +7 -1
  46. package/dist/src/lib/env.js.map +1 -1
  47. package/dist/src/lib/funder/ensure-wallet-has-test-tokens.d.ts +2 -1
  48. package/dist/src/lib/funder/ensure-wallet-has-test-tokens.d.ts.map +1 -1
  49. package/dist/src/lib/funder/ensure-wallet-has-test-tokens.js +9 -7
  50. package/dist/src/lib/funder/ensure-wallet-has-test-tokens.js.map +1 -1
  51. package/dist/src/lib/index.d.ts +1 -1
  52. package/dist/src/lib/index.d.ts.map +1 -1
  53. package/dist/src/lib/index.js.map +1 -1
  54. package/dist/src/lib/litContractsClient/LitContractsInstance.d.ts +2 -1
  55. package/dist/src/lib/litContractsClient/LitContractsInstance.d.ts.map +1 -1
  56. package/dist/src/lib/litContractsClient/LitContractsInstance.js.map +1 -1
  57. package/dist/src/lib/litContractsClient/get-lit-contract-client.d.ts +2 -1
  58. package/dist/src/lib/litContractsClient/get-lit-contract-client.d.ts.map +1 -1
  59. package/dist/src/lib/litContractsClient/get-lit-contract-client.js.map +1 -1
  60. package/dist/src/lib/mint-new-pkp.d.ts +5 -3
  61. package/dist/src/lib/mint-new-pkp.d.ts.map +1 -1
  62. package/dist/src/lib/mint-new-pkp.js +10 -4
  63. package/dist/src/lib/mint-new-pkp.js.map +1 -1
  64. package/dist/src/lib/setup-vincent-development-environment.d.ts +10 -4
  65. package/dist/src/lib/setup-vincent-development-environment.d.ts.map +1 -1
  66. package/dist/src/lib/setup-vincent-development-environment.js +28 -7
  67. package/dist/src/lib/setup-vincent-development-environment.js.map +1 -1
  68. package/dist/src/lib/smartAccount/crossmint/setup-crossmint-account.d.ts.map +1 -1
  69. package/dist/src/lib/smartAccount/crossmint/setup-crossmint-account.js +1 -0
  70. package/dist/src/lib/smartAccount/crossmint/setup-crossmint-account.js.map +1 -1
  71. package/dist/src/lib/smartAccount/types.d.ts +1 -0
  72. package/dist/src/lib/smartAccount/types.d.ts.map +1 -1
  73. package/package.json +7 -3
package/CHANGELOG.md CHANGED
@@ -1,14 +1,32 @@
1
- ## 1.2.1 (2025-12-10)
1
+ ## 2.0.1 (2026-01-08)
2
2
 
3
- ### 🩹 Fixes
3
+ ### 🧱 Updated Dependencies
4
4
 
5
- - Fix published package to include smart account functionality that was missing from the 1.2.0 release build. ([f327df67](https://github.com/LIT-Protocol/Vincent/commit/f327df67))
5
+ - Updated contracts-sdk to 7.0.0
6
6
 
7
- ## 1.2.0 (2025-12-09)
7
+ # 2.0.0 (2026-01-07)
8
8
 
9
9
  ### 🚀 Features
10
10
 
11
- - Adds a `smartAccountType` parameter to the `setupVincentDevelopmentEnvironment`. Supports `safe`, `crossmint` and `zerodev` smart accounts. When the parameter 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. ([fe037134](https://github.com/LIT-Protocol/Vincent/commit/fe037134))
11
+ - feat: add Relay.link gated signer ability ([3eec29cb](https://github.com/LIT-Protocol/Vincent/commit/3eec29cb))
12
+ - **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.
13
+ - **ability-sdk**: Allow `validateSimulation` and `validateTransaction` lifecycle functions to be async to support dynamic address fetching.
14
+ - **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.
15
+
16
+ - 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))
17
+
18
+ ### ⚠️ Breaking Changes
19
+
20
+ - 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))
21
+
22
+ ### 🧱 Updated Dependencies
23
+
24
+ - Updated contracts-sdk to 6.0.0
25
+
26
+ ### ❤️ Thank You
27
+
28
+ - awisniew207 @awisniew207
29
+ - Wyatt Barnes @spacesailor24
12
30
 
13
31
  ## 1.1.3 (2025-11-23)
14
32
 
@@ -0,0 +1,59 @@
1
+ # 2.0.0 (2026-01-07)
2
+
3
+ ### 🚀 Features
4
+
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.
9
+
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))
11
+
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
17
+
18
+ - Updated contracts-sdk to 6.0.0
19
+
20
+ ### ❤️ Thank You
21
+
22
+ - awisniew207 @awisniew207
23
+ - Wyatt Barnes @spacesailor24
24
+
25
+ ## 1.1.3 (2025-11-23)
26
+
27
+ ### 🧱 Updated Dependencies
28
+
29
+ - Updated contracts-sdk to 5.0.0
30
+
31
+ ## 1.1.0 (2025-11-07)
32
+
33
+ ### 🚀 Features
34
+
35
+ - Adds a `setupVincentDevelopmentEnvironment` function to streamline/abstract the developer experience. ([4ddce811](https://github.com/LIT-Protocol/Vincent/commit/4ddce811))
36
+
37
+ ### ❤️ Thank You
38
+
39
+ - awisniew207 @awisniew207
40
+
41
+ # 1.0.0 (2025-11-06)
42
+
43
+ ### 🚀 Features
44
+
45
+ - 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))
46
+
47
+ ### ⚠️ Breaking Changes
48
+
49
+ - 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))
50
+
51
+ ### ❤️ Thank You
52
+
53
+ - Wyatt Barnes @spacesailor24
54
+
55
+ # Changelog
56
+
57
+ ## 0.1.0
58
+
59
+ 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.2.1",
3
+ "version": "2.0.0",
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",
@@ -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
@@ -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,EAAE,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAC"}
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"}
@@ -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
- agentWalletOwner: Wallet;
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;AAoBxC,eAAO,MAAM,eAAe;eAff;QACT,WAAW,EAAE,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC;QAC9C,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC;KACxC;aACQ;QACP,YAAY,EAAE,MAAM,CAAC;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,gBAAgB,EAAE,MAAM,CAAC;KAC1B;EAqCF,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"}
@@ -11,19 +11,17 @@ const getChainHelpers = async () => {
11
11
  if (ethersHelpers) {
12
12
  return ethersHelpers;
13
13
  }
14
- const { YELLOWSTONE_RPC_URL, BASE_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)();
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
- agentWalletOwner: new ethers_1.Wallet(TEST_AGENT_WALLET_PKP_OWNER_PRIVATE_KEY, yellowstoneProvider),
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,aAWH,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,YAAY,EACZ,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;IACtF,MAAM,YAAY,GAAG,IAAI,eAAM,CAAC,SAAS,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;IAExE,aAAa,GAAG;QACd,SAAS,EAAE;YACT,WAAW,EAAE,mBAAmB;YAChC,IAAI,EAAE,YAAY;SACnB;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,gBAAgB,EAAE,IAAI,eAAM,CAAC,uCAAuC,EAAE,mBAAmB,CAAC;SAC3F;KACF,CAAC;IAEF,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC;AA/BW,QAAA,eAAe,mBA+B1B"}
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"}
@@ -2,6 +2,6 @@ import { Wallet } from 'ethers';
2
2
  export declare function createRandomVincentWallets(): {
3
3
  appDelegatee: Wallet;
4
4
  appManager: Wallet;
5
- agentWalletOwner: Wallet;
5
+ platformUserWalletOwner: Wallet;
6
6
  };
7
7
  //# sourceMappingURL=create-random-vincent-wallets.d.ts.map
@@ -6,7 +6,7 @@ function createRandomVincentWallets() {
6
6
  return {
7
7
  appDelegatee: ethers_1.Wallet.createRandom(),
8
8
  appManager: ethers_1.Wallet.createRandom(),
9
- agentWalletOwner: ethers_1.Wallet.createRandom(),
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,gBAAgB,EAAE,eAAM,CAAC,YAAY,EAAE;KACxC,CAAC;AACJ,CAAC"}
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
- export declare const addPermissionForAbilities: (wallet: Wallet, pkpTokenId: string, abilityIpfsCids: string[]) => Promise<void>;
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;AAQrC,eAAO,MAAM,yBAAyB,GACpC,QAAQ,MAAM,EACd,YAAY,MAAM,EAClB,iBAAiB,MAAM,EAAE,kBAe1B,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 agent PKP to sign on behalf of the user's agent PKP.
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 user's agent PKP ${pkpTokenId}`);
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":";;;AAEA,uDAA4D;AAE5D,2FAAsF;AAEtF,oHAAoH;AACpH,oGAAoG;AAC7F,MAAM,yBAAyB,GAAG,KAAK,EAC5C,MAAc,EACd,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,uDAAuD,UAAU,EAAE,CAClG,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
+ {"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
- export declare const ensureAgentPkpExists: () => Promise<PkpInfo>;
3
- export declare const ensureFundedAgentPkpExists: () => Promise<PkpInfo>;
4
- export declare const getFundedAgentPkp: () => Promise<PkpInfo>;
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":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAQ/C,eAAO,MAAM,oBAAoB,QAAa,OAAO,CAAC,OAAO,CAkC5D,CAAC;AAEF,eAAO,MAAM,0BAA0B,QAAa,OAAO,CAAC,OAAO,CAMlE,CAAC;AAOF,eAAO,MAAM,iBAAiB,QAAa,OAAO,CAAC,OAAO,CAMzD,CAAC"}
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
- // Get an existing, or mint a new one if there is no existing, agent PKP using the agent wallet owner's address
9
- const ensureAgentPkpExists = async () => {
10
- const { wallets: { agentWalletOwner }, } = await (0, chain_1.getChainHelpers)();
11
- const litContractClient = await (0, get_lit_contract_client_1.getLitContractsClient)({ wallet: agentWalletOwner });
12
- const ownedPkps = await litContractClient.pkpNftContractUtils.read.getTokensInfoByAddress(agentWalletOwner.address);
13
- if (ownedPkps.length > 1) {
14
- console.warn('> 1 PKP found for agent wallet owner. When e2e testing, we recommend that you use a _dedicated agent wallet owner account_ which always only has a single agent PKP. Using the first PKP found.', ownedPkps);
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
- console.log(`${agentWalletOwner.address} has a PKP -- using existing PKP with ethAddress: ${ownedPkps[0].ethAddress}, tokenId: ${ownedPkps[0].tokenId}`);
18
- const { tokenId, ethAddress } = ownedPkps[0];
19
- return { tokenId, ethAddress };
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 agent PKPs found; minting a new agent PKP for ${agentWalletOwner.address}...`);
22
- // Be sure the agentWalletOwner has enough test tokens to mint a new PKP
23
- await (0, ensure_wallet_has_test_tokens_1.ensureWalletHasTestTokens)({ address: await agentWalletOwner.getAddress() });
24
- const { tokenId, ethAddress } = await (0, mint_new_pkp_1.mintNewPkp)({ wallet: agentWalletOwner });
25
- return { tokenId, ethAddress };
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
- const agentPkpInfo = null;
35
- // Returns agent Pkp info for this run.
36
- // This method will mint a new agent Pkp if none exists for the current agent wallet owner.
37
- // This method will also fund the agent Pkp if it is not already funded.
38
- const getFundedAgentPkp = async () => {
39
- if (agentPkpInfo) {
40
- return agentPkpInfo;
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
- return await (0, exports.ensureFundedAgentPkpExists)();
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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AAG,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;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CAAC,UAAU,EAAE;gBACpC,MAAM,CAAC,kBAAkB,EAAE;aAC5B,CAAC,CAAC;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"}