@lit-protocol/vincent-e2e-test-utils 1.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 +19 -0
- package/CONTRIBUTING.md +0 -0
- package/README.md +17 -0
- package/dist/CHANGELOG.md +5 -0
- package/dist/CONTRIBUTING.md +0 -0
- package/dist/README.md +17 -0
- package/dist/package.json +39 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +15 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib/appManager/ensure-funded.d.ts +2 -0
- package/dist/src/lib/appManager/ensure-funded.d.ts.map +1 -0
- package/dist/src/lib/appManager/ensure-funded.js +11 -0
- package/dist/src/lib/appManager/ensure-funded.js.map +1 -0
- package/dist/src/lib/appManager/index.d.ts +5 -0
- package/dist/src/lib/appManager/index.d.ts.map +1 -0
- package/dist/src/lib/appManager/index.js +12 -0
- package/dist/src/lib/appManager/index.js.map +1 -0
- package/dist/src/lib/appManager/register-new-app-version.d.ts +28 -0
- package/dist/src/lib/appManager/register-new-app-version.d.ts.map +1 -0
- package/dist/src/lib/appManager/register-new-app-version.js +82 -0
- package/dist/src/lib/appManager/register-new-app-version.js.map +1 -0
- package/dist/src/lib/appManager/register-new-app.d.ts +13 -0
- package/dist/src/lib/appManager/register-new-app.d.ts.map +1 -0
- package/dist/src/lib/appManager/register-new-app.js +30 -0
- package/dist/src/lib/appManager/register-new-app.js.map +1 -0
- package/dist/src/lib/appManager/remove-delegatee-from-app.d.ts +7 -0
- package/dist/src/lib/appManager/remove-delegatee-from-app.d.ts.map +1 -0
- package/dist/src/lib/appManager/remove-delegatee-from-app.js +26 -0
- package/dist/src/lib/appManager/remove-delegatee-from-app.js.map +1 -0
- package/dist/src/lib/chain.d.ts +14 -0
- package/dist/src/lib/chain.d.ts.map +1 -0
- package/dist/src/lib/chain.js +32 -0
- package/dist/src/lib/chain.js.map +1 -0
- package/dist/src/lib/create-random-vincent-wallets.d.ts +7 -0
- package/dist/src/lib/create-random-vincent-wallets.d.ts.map +1 -0
- package/dist/src/lib/create-random-vincent-wallets.js +12 -0
- package/dist/src/lib/create-random-vincent-wallets.js.map +1 -0
- package/dist/src/lib/delegatee/ensure-funded.d.ts +2 -0
- package/dist/src/lib/delegatee/ensure-funded.d.ts.map +1 -0
- package/dist/src/lib/delegatee/ensure-funded.js +11 -0
- package/dist/src/lib/delegatee/ensure-funded.js.map +1 -0
- package/dist/src/lib/delegatee/get-app-info.d.ts +5 -0
- package/dist/src/lib/delegatee/get-app-info.d.ts.map +1 -0
- package/dist/src/lib/delegatee/get-app-info.js +19 -0
- package/dist/src/lib/delegatee/get-app-info.js.map +1 -0
- package/dist/src/lib/delegatee/index.d.ts +3 -0
- package/dist/src/lib/delegatee/index.d.ts.map +1 -0
- package/dist/src/lib/delegatee/index.js +8 -0
- package/dist/src/lib/delegatee/index.js.map +1 -0
- package/dist/src/lib/delegator/add-permission-for-abilities.d.ts +3 -0
- package/dist/src/lib/delegator/add-permission-for-abilities.d.ts.map +1 -0
- package/dist/src/lib/delegator/add-permission-for-abilities.js +20 -0
- package/dist/src/lib/delegator/add-permission-for-abilities.js.map +1 -0
- package/dist/src/lib/delegator/agent-pkp.d.ts +5 -0
- package/dist/src/lib/delegator/agent-pkp.d.ts.map +1 -0
- package/dist/src/lib/delegator/agent-pkp.js +45 -0
- package/dist/src/lib/delegator/agent-pkp.js.map +1 -0
- package/dist/src/lib/delegator/index.d.ts +5 -0
- package/dist/src/lib/delegator/index.d.ts.map +1 -0
- package/dist/src/lib/delegator/index.js +14 -0
- package/dist/src/lib/delegator/index.js.map +1 -0
- package/dist/src/lib/delegator/permit-vincent-app-version.d.ts +16 -0
- package/dist/src/lib/delegator/permit-vincent-app-version.d.ts.map +1 -0
- package/dist/src/lib/delegator/permit-vincent-app-version.js +45 -0
- package/dist/src/lib/delegator/permit-vincent-app-version.js.map +1 -0
- package/dist/src/lib/ensure-capacity-credit.d.ts +3 -0
- package/dist/src/lib/ensure-capacity-credit.d.ts.map +1 -0
- package/dist/src/lib/ensure-capacity-credit.js +54 -0
- package/dist/src/lib/ensure-capacity-credit.js.map +1 -0
- package/dist/src/lib/env.d.ts +20 -0
- package/dist/src/lib/env.d.ts.map +1 -0
- package/dist/src/lib/env.js +49 -0
- package/dist/src/lib/env.js.map +1 -0
- package/dist/src/lib/funder/check-funder-balance.d.ts +3 -0
- package/dist/src/lib/funder/check-funder-balance.d.ts.map +1 -0
- package/dist/src/lib/funder/check-funder-balance.js +19 -0
- package/dist/src/lib/funder/check-funder-balance.js.map +1 -0
- package/dist/src/lib/funder/ensure-wallet-has-test-tokens.d.ts +4 -0
- package/dist/src/lib/funder/ensure-wallet-has-test-tokens.d.ts.map +1 -0
- package/dist/src/lib/funder/ensure-wallet-has-test-tokens.js +33 -0
- package/dist/src/lib/funder/ensure-wallet-has-test-tokens.js.map +1 -0
- package/dist/src/lib/funder/index.d.ts +5 -0
- package/dist/src/lib/funder/index.d.ts.map +1 -0
- package/dist/src/lib/funder/index.js +10 -0
- package/dist/src/lib/funder/index.js.map +1 -0
- package/dist/src/lib/index.d.ts +16 -0
- package/dist/src/lib/index.d.ts.map +1 -0
- package/dist/src/lib/index.js +25 -0
- package/dist/src/lib/index.js.map +1 -0
- package/dist/src/lib/litContractsClient/LitContractsInstance.d.ts +13 -0
- package/dist/src/lib/litContractsClient/LitContractsInstance.d.ts.map +1 -0
- package/dist/src/lib/litContractsClient/LitContractsInstance.js +48 -0
- package/dist/src/lib/litContractsClient/LitContractsInstance.js.map +1 -0
- package/dist/src/lib/litContractsClient/get-lit-contract-client.d.ts +6 -0
- package/dist/src/lib/litContractsClient/get-lit-contract-client.d.ts.map +1 -0
- package/dist/src/lib/litContractsClient/get-lit-contract-client.js +19 -0
- package/dist/src/lib/litContractsClient/get-lit-contract-client.js.map +1 -0
- package/dist/src/lib/litContractsClient/index.d.ts +3 -0
- package/dist/src/lib/litContractsClient/index.d.ts.map +1 -0
- package/dist/src/lib/litContractsClient/index.js +8 -0
- package/dist/src/lib/litContractsClient/index.js.map +1 -0
- package/dist/src/lib/mint-new-pkp.d.ts +14 -0
- package/dist/src/lib/mint-new-pkp.d.ts.map +1 -0
- package/dist/src/lib/mint-new-pkp.js +34 -0
- package/dist/src/lib/mint-new-pkp.js.map +1 -0
- package/dist/src/lib/types.d.ts +17 -0
- package/dist/src/lib/types.d.ts.map +1 -0
- package/dist/src/lib/types.js +3 -0
- package/dist/src/lib/types.js.map +1 -0
- package/package.json +38 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# 1.0.0 (2025-11-06)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- 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))
|
|
6
|
+
|
|
7
|
+
### ⚠️ Breaking Changes
|
|
8
|
+
|
|
9
|
+
- 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))
|
|
10
|
+
|
|
11
|
+
### ❤️ Thank You
|
|
12
|
+
|
|
13
|
+
- Wyatt Barnes @spacesailor24
|
|
14
|
+
|
|
15
|
+
# Changelog
|
|
16
|
+
|
|
17
|
+
## 0.1.0
|
|
18
|
+
|
|
19
|
+
Initial release of @lit-protocol/vincent-e2e-test-utils package.
|
package/CONTRIBUTING.md
ADDED
|
File without changes
|
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @lit-protocol/vincent-e2e-test-utils
|
|
2
|
+
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
|
+
|
|
5
|
+
## Building
|
|
6
|
+
|
|
7
|
+
Run `nx build e2e-test-utils` to build the library.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
This package provides E2E test utilities for the Vincent protocol.
|
|
12
|
+
|
|
13
|
+
## Development
|
|
14
|
+
|
|
15
|
+
### Documentation
|
|
16
|
+
|
|
17
|
+
Documentation is generated using TypeDoc. Build the docs with the appropriate Nx command.
|
|
File without changes
|
package/dist/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @lit-protocol/vincent-e2e-test-utils
|
|
2
|
+
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
|
+
|
|
5
|
+
## Building
|
|
6
|
+
|
|
7
|
+
Run `nx build e2e-test-utils` to build the library.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
This package provides E2E test utilities for the Vincent protocol.
|
|
12
|
+
|
|
13
|
+
## Development
|
|
14
|
+
|
|
15
|
+
### Documentation
|
|
16
|
+
|
|
17
|
+
Documentation is generated using TypeDoc. Build the docs with the appropriate Nx command.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lit-protocol/vincent-e2e-test-utils",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@lit-protocol/constants": "^8.0.4",
|
|
9
|
+
"@lit-protocol/contracts-sdk": "^7.2.3",
|
|
10
|
+
"@lit-protocol/vincent-contracts-sdk": "^2.0.0",
|
|
11
|
+
"@t3-oss/env-core": "^0.13.8",
|
|
12
|
+
"ethers": "^5.7.2",
|
|
13
|
+
"tslib": "^2.8.1",
|
|
14
|
+
"zod": "^3.25.64"
|
|
15
|
+
},
|
|
16
|
+
"main": "./dist/src/index.js",
|
|
17
|
+
"types": "./dist/src/index.d.ts",
|
|
18
|
+
"files": [
|
|
19
|
+
"dist/**",
|
|
20
|
+
"*.md"
|
|
21
|
+
],
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"require": "./dist/src/index.js",
|
|
25
|
+
"import": "./dist/src/index.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/semver": "^7.7.0",
|
|
30
|
+
"chokidar-cli": "^3.0.0",
|
|
31
|
+
"ipfs-only-hash": "^4.0.0",
|
|
32
|
+
"jsonc-eslint-parser": "^2.4.0",
|
|
33
|
+
"typedoc": "0.27.9",
|
|
34
|
+
"typedoc-material-theme": "1.3.0",
|
|
35
|
+
"typedoc-plugin-extras": "^4.0.0",
|
|
36
|
+
"typedoc-plugin-zod": "^1.4.1"
|
|
37
|
+
},
|
|
38
|
+
"type": "commonjs"
|
|
39
|
+
}
|
|
@@ -0,0 +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,GAC3B,MAAM,OAAO,CAAC;AAEf,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRandomVincentWallets = exports.getChainHelpers = exports.getEnv = exports.ensureUnexpiredCapacityToken = exports.mintNewPkp = exports.appManager = exports.chain = exports.funder = exports.delegatee = exports.delegator = void 0;
|
|
4
|
+
var lib_1 = require("./lib");
|
|
5
|
+
Object.defineProperty(exports, "delegator", { enumerable: true, get: function () { return lib_1.delegator; } });
|
|
6
|
+
Object.defineProperty(exports, "delegatee", { enumerable: true, get: function () { return lib_1.delegatee; } });
|
|
7
|
+
Object.defineProperty(exports, "funder", { enumerable: true, get: function () { return lib_1.funder; } });
|
|
8
|
+
Object.defineProperty(exports, "chain", { enumerable: true, get: function () { return lib_1.chain; } });
|
|
9
|
+
Object.defineProperty(exports, "appManager", { enumerable: true, get: function () { return lib_1.appManager; } });
|
|
10
|
+
Object.defineProperty(exports, "mintNewPkp", { enumerable: true, get: function () { return lib_1.mintNewPkp; } });
|
|
11
|
+
Object.defineProperty(exports, "ensureUnexpiredCapacityToken", { enumerable: true, get: function () { return lib_1.ensureUnexpiredCapacityToken; } });
|
|
12
|
+
Object.defineProperty(exports, "getEnv", { enumerable: true, get: function () { return lib_1.getEnv; } });
|
|
13
|
+
Object.defineProperty(exports, "getChainHelpers", { enumerable: true, get: function () { return lib_1.getChainHelpers; } });
|
|
14
|
+
Object.defineProperty(exports, "createRandomVincentWallets", { enumerable: true, get: function () { return lib_1.createRandomVincentWallets; } });
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,6BAWe;AAVb,gGAAA,SAAS,OAAA;AACT,gGAAA,SAAS,OAAA;AACT,6FAAA,MAAM,OAAA;AACN,4FAAA,KAAK,OAAA;AACL,iGAAA,UAAU,OAAA;AACV,iGAAA,UAAU,OAAA;AACV,mHAAA,4BAA4B,OAAA;AAC5B,6FAAA,MAAM,OAAA;AACN,sGAAA,eAAe,OAAA;AACf,iHAAA,0BAA0B,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensure-funded.d.ts","sourceRoot":"","sources":["../../../../src/lib/appManager/ensure-funded.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,sBAAsB,qBAMlC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ensureAppManagerFunded = void 0;
|
|
4
|
+
const chain_1 = require("../chain");
|
|
5
|
+
const funder_1 = require("../funder");
|
|
6
|
+
const ensureAppManagerFunded = async () => {
|
|
7
|
+
const { wallets: { appManager }, } = await (0, chain_1.getChainHelpers)();
|
|
8
|
+
return (0, funder_1.ensureWalletHasTestTokens)({ address: await appManager.getAddress() });
|
|
9
|
+
};
|
|
10
|
+
exports.ensureAppManagerFunded = ensureAppManagerFunded;
|
|
11
|
+
//# sourceMappingURL=ensure-funded.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensure-funded.js","sourceRoot":"","sources":["../../../../src/lib/appManager/ensure-funded.ts"],"names":[],"mappings":";;;AAAA,oCAA2C;AAC3C,sCAAsD;AAE/C,MAAM,sBAAsB,GAAG,KAAK,IAAI,EAAE;IAC/C,MAAM,EACJ,OAAO,EAAE,EAAE,UAAU,EAAE,GACxB,GAAG,MAAM,IAAA,uBAAe,GAAE,CAAC;IAE5B,OAAO,IAAA,kCAAyB,EAAC,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AAC/E,CAAC,CAAC;AANW,QAAA,sBAAsB,0BAMjC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { registerNewApp } from './register-new-app';
|
|
2
|
+
export { registerNewAppVersion } from './register-new-app-version';
|
|
3
|
+
export { removeDelegateeFromApp } from './remove-delegatee-from-app';
|
|
4
|
+
export { ensureAppManagerFunded } from './ensure-funded';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/appManager/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ensureAppManagerFunded = exports.removeDelegateeFromApp = exports.registerNewAppVersion = exports.registerNewApp = void 0;
|
|
4
|
+
var register_new_app_1 = require("./register-new-app");
|
|
5
|
+
Object.defineProperty(exports, "registerNewApp", { enumerable: true, get: function () { return register_new_app_1.registerNewApp; } });
|
|
6
|
+
var register_new_app_version_1 = require("./register-new-app-version");
|
|
7
|
+
Object.defineProperty(exports, "registerNewAppVersion", { enumerable: true, get: function () { return register_new_app_version_1.registerNewAppVersion; } });
|
|
8
|
+
var remove_delegatee_from_app_1 = require("./remove-delegatee-from-app");
|
|
9
|
+
Object.defineProperty(exports, "removeDelegateeFromApp", { enumerable: true, get: function () { return remove_delegatee_from_app_1.removeDelegateeFromApp; } });
|
|
10
|
+
var ensure_funded_1 = require("./ensure-funded");
|
|
11
|
+
Object.defineProperty(exports, "ensureAppManagerFunded", { enumerable: true, get: function () { return ensure_funded_1.ensureAppManagerFunded; } });
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/appManager/index.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AAA3C,kHAAA,cAAc,OAAA;AACvB,uEAAmE;AAA1D,iIAAA,qBAAqB,OAAA;AAC9B,yEAAqE;AAA5D,mIAAA,sBAAsB,OAAA;AAC/B,iDAAyD;AAAhD,uHAAA,sBAAsB,OAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers a new app version. On-chain app versions are immutable, so any time you modify
|
|
3
|
+
* abilities or policies, you must register a new version of your app using the new ipfs CIDs
|
|
4
|
+
*
|
|
5
|
+
* This function will check if the latest app version already has the same abilities and policies.
|
|
6
|
+
* If they match, it will return the existing appVersion without registering a new one.
|
|
7
|
+
*
|
|
8
|
+
* @param abilityIpfsCids - Array of ability IPFS CIDs to register
|
|
9
|
+
* @param abilityPolicies - Array of policy IPFS CIDs for each ability (must be parallel to abilityIpfsCids)
|
|
10
|
+
* @param registerNewVersionOverride - Whether to register a new version even if the latest version already has the same abilities and policies
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* Assumptions:
|
|
14
|
+
* - `abilityIpfsCids` and `abilityPolicies` are parallel arrays where `abilityPolicies[i]` contains
|
|
15
|
+
* the policy CIDs for the ability at `abilityIpfsCids[i]`
|
|
16
|
+
* - The comparison is order-independent for both abilities and policies within each ability
|
|
17
|
+
* - Two app versions are considered equivalent if they have the same set of abilities (regardless of order)
|
|
18
|
+
* and each ability has the same set of policies (regardless of order)
|
|
19
|
+
*/
|
|
20
|
+
export declare function registerNewAppVersion({ abilityIpfsCids, abilityPolicies, registerNewVersionOverride, }: {
|
|
21
|
+
abilityIpfsCids: string[];
|
|
22
|
+
abilityPolicies: string[][];
|
|
23
|
+
registerNewVersionOverride?: boolean;
|
|
24
|
+
}): Promise<{
|
|
25
|
+
appId: number;
|
|
26
|
+
appVersion: number;
|
|
27
|
+
}>;
|
|
28
|
+
//# sourceMappingURL=register-new-app-version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-new-app-version.d.ts","sourceRoot":"","sources":["../../../../src/lib/appManager/register-new-app-version.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,qBAAqB,CAAC,EAC1C,eAAe,EACf,eAAe,EACf,0BAAkC,GACnC,EAAE;IACD,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,eAAe,EAAE,MAAM,EAAE,EAAE,CAAC;IAC5B,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACtC;;;GA4EA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerNewAppVersion = registerNewAppVersion;
|
|
4
|
+
const vincent_contracts_sdk_1 = require("@lit-protocol/vincent-contracts-sdk");
|
|
5
|
+
const chain_1 = require("../chain");
|
|
6
|
+
const get_app_info_1 = require("../delegatee/get-app-info");
|
|
7
|
+
/**
|
|
8
|
+
* Registers a new app version. On-chain app versions are immutable, so any time you modify
|
|
9
|
+
* abilities or policies, you must register a new version of your app using the new ipfs CIDs
|
|
10
|
+
*
|
|
11
|
+
* This function will check if the latest app version already has the same abilities and policies.
|
|
12
|
+
* If they match, it will return the existing appVersion without registering a new one.
|
|
13
|
+
*
|
|
14
|
+
* @param abilityIpfsCids - Array of ability IPFS CIDs to register
|
|
15
|
+
* @param abilityPolicies - Array of policy IPFS CIDs for each ability (must be parallel to abilityIpfsCids)
|
|
16
|
+
* @param registerNewVersionOverride - Whether to register a new version even if the latest version already has the same abilities and policies
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* Assumptions:
|
|
20
|
+
* - `abilityIpfsCids` and `abilityPolicies` are parallel arrays where `abilityPolicies[i]` contains
|
|
21
|
+
* the policy CIDs for the ability at `abilityIpfsCids[i]`
|
|
22
|
+
* - The comparison is order-independent for both abilities and policies within each ability
|
|
23
|
+
* - Two app versions are considered equivalent if they have the same set of abilities (regardless of order)
|
|
24
|
+
* and each ability has the same set of policies (regardless of order)
|
|
25
|
+
*/
|
|
26
|
+
async function registerNewAppVersion({ abilityIpfsCids, abilityPolicies, registerNewVersionOverride = false, }) {
|
|
27
|
+
const app = await (0, get_app_info_1.getAppInfo)();
|
|
28
|
+
if (!app) {
|
|
29
|
+
throw new Error('App was expected, but not found. Please register a new app first.');
|
|
30
|
+
}
|
|
31
|
+
const { appId, appVersion: latestVersion } = app;
|
|
32
|
+
const { wallets: { appManager }, } = await (0, chain_1.getChainHelpers)();
|
|
33
|
+
const client = (0, vincent_contracts_sdk_1.getClient)({ signer: appManager });
|
|
34
|
+
if (!registerNewVersionOverride) {
|
|
35
|
+
// Get the existing app version to compare
|
|
36
|
+
const existingAppVersion = await client.getAppVersion({
|
|
37
|
+
appId,
|
|
38
|
+
version: latestVersion,
|
|
39
|
+
});
|
|
40
|
+
if (existingAppVersion) {
|
|
41
|
+
// Create a map from ability CID to its policies for easy lookup
|
|
42
|
+
const existingAbilityMap = new Map();
|
|
43
|
+
existingAppVersion.appVersion.abilities.forEach((ability) => {
|
|
44
|
+
existingAbilityMap.set(ability.abilityIpfsCid, ability.policyIpfsCids);
|
|
45
|
+
});
|
|
46
|
+
// Check if we have the same number of abilities and compare them
|
|
47
|
+
if (existingAbilityMap.size === abilityIpfsCids.length) {
|
|
48
|
+
// For each ability in the new version, check if it exists with the same policies
|
|
49
|
+
const allMatch = abilityIpfsCids.every((abilityId, index) => {
|
|
50
|
+
const existingPolicies = existingAbilityMap.get(abilityId);
|
|
51
|
+
if (existingPolicies === undefined)
|
|
52
|
+
return false; // Ability doesn't exist in current version
|
|
53
|
+
const newPolicies = abilityPolicies[index];
|
|
54
|
+
if (newPolicies === undefined) {
|
|
55
|
+
throw new Error(`Parallel arrays are not in sync: abilityPolicies[${index}] is undefined for ability '${abilityId}'.`);
|
|
56
|
+
}
|
|
57
|
+
// Compare policy arrays (order-independent)
|
|
58
|
+
if (existingPolicies.length !== newPolicies.length)
|
|
59
|
+
return false;
|
|
60
|
+
const sortedExisting = [...existingPolicies].sort();
|
|
61
|
+
const sortedNew = [...newPolicies].sort();
|
|
62
|
+
return sortedExisting.every((policy, i) => policy === sortedNew[i]);
|
|
63
|
+
});
|
|
64
|
+
if (allMatch) {
|
|
65
|
+
console.log(`App version ${latestVersion} already has the same abilities and policies. Skipping registration.`);
|
|
66
|
+
return { appId, appVersion: latestVersion };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Register new version if abilities or policies have changed
|
|
72
|
+
const { txHash, newAppVersion } = await client.registerNextVersion({
|
|
73
|
+
appId,
|
|
74
|
+
versionAbilities: {
|
|
75
|
+
abilityIpfsCids: abilityIpfsCids,
|
|
76
|
+
abilityPolicies: abilityPolicies,
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
console.log(`Registered new App version ${newAppVersion} for existing app: ${appId}\nTx hash: ${txHash}`);
|
|
80
|
+
return { appId, appVersion: newAppVersion };
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=register-new-app-version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-new-app-version.js","sourceRoot":"","sources":["../../../../src/lib/appManager/register-new-app-version.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers a new app
|
|
3
|
+
* @param abilityIpfsCids - Array of ability IPFS CIDs to register
|
|
4
|
+
* @param abilityPolicies - Array of policy IPFS CIDs for each ability
|
|
5
|
+
*/
|
|
6
|
+
export declare function registerNewApp({ abilityIpfsCids, abilityPolicies, }: {
|
|
7
|
+
abilityIpfsCids: string[];
|
|
8
|
+
abilityPolicies: string[][];
|
|
9
|
+
}): Promise<{
|
|
10
|
+
appId: number;
|
|
11
|
+
appVersion: number;
|
|
12
|
+
}>;
|
|
13
|
+
//# sourceMappingURL=register-new-app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-new-app.d.ts","sourceRoot":"","sources":["../../../../src/lib/appManager/register-new-app.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,EACnC,eAAe,EACf,eAAe,GAChB,EAAE;IACD,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,eAAe,EAAE,MAAM,EAAE,EAAE,CAAC;CAC7B;;;GAqBA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerNewApp = registerNewApp;
|
|
4
|
+
const vincent_contracts_sdk_1 = require("@lit-protocol/vincent-contracts-sdk");
|
|
5
|
+
const chain_1 = require("../chain");
|
|
6
|
+
function generateRandomAppId() {
|
|
7
|
+
return Math.floor(Math.random() * (100_000_000_000 - 10_000_000_000)) + 10_000_000_000;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Registers a new app
|
|
11
|
+
* @param abilityIpfsCids - Array of ability IPFS CIDs to register
|
|
12
|
+
* @param abilityPolicies - Array of policy IPFS CIDs for each ability
|
|
13
|
+
*/
|
|
14
|
+
async function registerNewApp({ abilityIpfsCids, abilityPolicies, }) {
|
|
15
|
+
const { wallets: { appManager, appDelegatee }, } = await (0, chain_1.getChainHelpers)();
|
|
16
|
+
const appId = generateRandomAppId();
|
|
17
|
+
const { txHash } = await (0, vincent_contracts_sdk_1.getClient)({
|
|
18
|
+
signer: appManager,
|
|
19
|
+
}).registerApp({
|
|
20
|
+
appId,
|
|
21
|
+
delegateeAddresses: [await appDelegatee.getAddress()],
|
|
22
|
+
versionAbilities: {
|
|
23
|
+
abilityIpfsCids: abilityIpfsCids,
|
|
24
|
+
abilityPolicies: abilityPolicies,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
console.log(`Registered new App with ID: ${appId}\nTx hash: ${txHash}`);
|
|
28
|
+
return { appId, appVersion: 1 };
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=register-new-app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-new-app.js","sourceRoot":"","sources":["../../../../src/lib/appManager/register-new-app.ts"],"names":[],"mappings":";;AAaA,wCA2BC;AAxCD,+EAAgE;AAEhE,oCAA2C;AAE3C,SAAS,mBAAmB;IAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,eAAe,GAAG,cAAc,CAAC,CAAC,GAAG,cAAc,CAAC;AACzF,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,cAAc,CAAC,EACnC,eAAe,EACf,eAAe,GAIhB;IACC,MAAM,EACJ,OAAO,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,GACtC,GAAG,MAAM,IAAA,uBAAe,GAAE,CAAC;IAE5B,MAAM,KAAK,GAAG,mBAAmB,EAAE,CAAC;IAEpC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,iCAAS,EAAC;QACjC,MAAM,EAAE,UAAU;KACnB,CAAC,CAAC,WAAW,CAAC;QACb,KAAK;QACL,kBAAkB,EAAE,CAAC,MAAM,YAAY,CAAC,UAAU,EAAE,CAAC;QACrD,gBAAgB,EAAE;YAChB,eAAe,EAAE,eAAe;YAChC,eAAe,EAAE,eAAe;SACjC;KACF,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,+BAA+B,KAAK,cAAc,MAAM,EAAE,CAAC,CAAC;IAExE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-delegatee-from-app.d.ts","sourceRoot":"","sources":["../../../../src/lib/appManager/remove-delegatee-from-app.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,wBAAsB,sBAAsB;;GAyB3C"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeDelegateeFromApp = removeDelegateeFromApp;
|
|
4
|
+
const vincent_contracts_sdk_1 = require("@lit-protocol/vincent-contracts-sdk");
|
|
5
|
+
const chain_1 = require("../chain");
|
|
6
|
+
const get_app_info_1 = require("../delegatee/get-app-info");
|
|
7
|
+
/**
|
|
8
|
+
* Removes a delegatee from an app
|
|
9
|
+
*/
|
|
10
|
+
async function removeDelegateeFromApp() {
|
|
11
|
+
const app = await (0, get_app_info_1.getAppInfo)();
|
|
12
|
+
if (!app) {
|
|
13
|
+
throw new Error('App was expected, but not found. Please register a new app first.');
|
|
14
|
+
}
|
|
15
|
+
const { appId } = app;
|
|
16
|
+
const { wallets: { appManager, appDelegatee }, } = await (0, chain_1.getChainHelpers)();
|
|
17
|
+
const { txHash } = await (0, vincent_contracts_sdk_1.getClient)({
|
|
18
|
+
signer: appManager,
|
|
19
|
+
}).removeDelegatee({
|
|
20
|
+
appId,
|
|
21
|
+
delegateeAddress: appDelegatee.address,
|
|
22
|
+
});
|
|
23
|
+
console.log(`Removed delegatee ${appDelegatee.address} from App with ID: ${appId}\nTx hash: ${txHash}`);
|
|
24
|
+
return { txHash };
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=remove-delegatee-from-app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-delegatee-from-app.js","sourceRoot":"","sources":["../../../../src/lib/appManager/remove-delegatee-from-app.ts"],"names":[],"mappings":";;AAQA,wDAyBC;AAjCD,+EAAgE;AAEhE,oCAA2C;AAC3C,4DAAuD;AAEvD;;GAEG;AACI,KAAK,UAAU,sBAAsB;IAC1C,MAAM,GAAG,GAAG,MAAM,IAAA,yBAAU,GAAE,CAAC;IAE/B,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;IACvF,CAAC;IAED,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC;IAEtB,MAAM,EACJ,OAAO,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,GACtC,GAAG,MAAM,IAAA,uBAAe,GAAE,CAAC;IAE5B,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,iCAAS,EAAC;QACjC,MAAM,EAAE,UAAU;KACnB,CAAC,CAAC,eAAe,CAAC;QACjB,KAAK;QACL,gBAAgB,EAAE,YAAY,CAAC,OAAO;KACvC,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CACT,qBAAqB,YAAY,CAAC,OAAO,sBAAsB,KAAK,cAAc,MAAM,EAAE,CAC3F,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ethers, Wallet } from 'ethers';
|
|
2
|
+
export declare const getChainHelpers: () => Promise<{
|
|
3
|
+
providers: {
|
|
4
|
+
yellowstone: ethers.providers.JsonRpcProvider;
|
|
5
|
+
base: ethers.providers.JsonRpcProvider;
|
|
6
|
+
};
|
|
7
|
+
wallets: {
|
|
8
|
+
appDelegatee: Wallet;
|
|
9
|
+
funder: Wallet;
|
|
10
|
+
appManager: Wallet;
|
|
11
|
+
agentWalletOwner: Wallet;
|
|
12
|
+
};
|
|
13
|
+
}>;
|
|
14
|
+
//# sourceMappingURL=chain.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getChainHelpers = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const env_1 = require("./env");
|
|
6
|
+
let ethersHelpers;
|
|
7
|
+
// Vincent delegation uses a set of wallets that interact with LIT's test network: Yellowstone RPC
|
|
8
|
+
// This function constructs Ethers Wallet objects configured using the appropriate environment variables
|
|
9
|
+
// It also provides the low-level providers for `yellowstone` and `base` networks for doing things like checking account balances
|
|
10
|
+
const getChainHelpers = async () => {
|
|
11
|
+
if (ethersHelpers) {
|
|
12
|
+
return ethersHelpers;
|
|
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)();
|
|
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
|
+
ethersHelpers = {
|
|
18
|
+
providers: {
|
|
19
|
+
yellowstone: yellowstoneProvider,
|
|
20
|
+
base: baseProvider,
|
|
21
|
+
},
|
|
22
|
+
wallets: {
|
|
23
|
+
appDelegatee: new ethers_1.Wallet(TEST_APP_DELEGATEE_PRIVATE_KEY, yellowstoneProvider),
|
|
24
|
+
funder: new ethers_1.Wallet(TEST_FUNDER_PRIVATE_KEY, yellowstoneProvider),
|
|
25
|
+
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),
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
return ethersHelpers;
|
|
30
|
+
};
|
|
31
|
+
exports.getChainHelpers = getChainHelpers;
|
|
32
|
+
//# sourceMappingURL=chain.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-random-vincent-wallets.d.ts","sourceRoot":"","sources":["../../../src/lib/create-random-vincent-wallets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,wBAAgB,0BAA0B;;;;EAMzC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRandomVincentWallets = createRandomVincentWallets;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
function createRandomVincentWallets() {
|
|
6
|
+
return {
|
|
7
|
+
appDelegatee: ethers_1.Wallet.createRandom(),
|
|
8
|
+
appManager: ethers_1.Wallet.createRandom(),
|
|
9
|
+
agentWalletOwner: ethers_1.Wallet.createRandom(),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=create-random-vincent-wallets.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensure-funded.d.ts","sourceRoot":"","sources":["../../../../src/lib/delegatee/ensure-funded.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,wBAAwB,qBAMpC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ensureAppDelegateeFunded = void 0;
|
|
4
|
+
const chain_1 = require("../chain");
|
|
5
|
+
const funder_1 = require("../funder");
|
|
6
|
+
const ensureAppDelegateeFunded = async () => {
|
|
7
|
+
const { wallets: { appDelegatee }, } = await (0, chain_1.getChainHelpers)();
|
|
8
|
+
return (0, funder_1.ensureWalletHasTestTokens)({ address: await appDelegatee.getAddress() });
|
|
9
|
+
};
|
|
10
|
+
exports.ensureAppDelegateeFunded = ensureAppDelegateeFunded;
|
|
11
|
+
//# sourceMappingURL=ensure-funded.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensure-funded.js","sourceRoot":"","sources":["../../../../src/lib/delegatee/ensure-funded.ts"],"names":[],"mappings":";;;AAAA,oCAA2C;AAC3C,sCAAsD;AAE/C,MAAM,wBAAwB,GAAG,KAAK,IAAI,EAAE;IACjD,MAAM,EACJ,OAAO,EAAE,EAAE,YAAY,EAAE,GAC1B,GAAG,MAAM,IAAA,uBAAe,GAAE,CAAC;IAE5B,OAAO,IAAA,kCAAyB,EAAC,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AACjF,CAAC,CAAC;AANW,QAAA,wBAAwB,4BAMnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-app-info.d.ts","sourceRoot":"","sources":["../../../../src/lib/delegatee/get-app-info.ts"],"names":[],"mappings":"AAIA,wBAAsB,UAAU;;;UAiB/B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAppInfo = getAppInfo;
|
|
4
|
+
const vincent_contracts_sdk_1 = require("@lit-protocol/vincent-contracts-sdk");
|
|
5
|
+
const chain_1 = require("../chain");
|
|
6
|
+
async function getAppInfo() {
|
|
7
|
+
const { wallets: { appDelegatee }, } = await (0, chain_1.getChainHelpers)();
|
|
8
|
+
const app = await (0, vincent_contracts_sdk_1.getClient)({
|
|
9
|
+
signer: appDelegatee,
|
|
10
|
+
}).getAppByDelegateeAddress({
|
|
11
|
+
delegateeAddress: appDelegatee.address,
|
|
12
|
+
});
|
|
13
|
+
if (!app) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const { id: appId, latestVersion: appVersion } = app;
|
|
17
|
+
return { appId, appVersion };
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=get-app-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-app-info.js","sourceRoot":"","sources":["../../../../src/lib/delegatee/get-app-info.ts"],"names":[],"mappings":";;AAIA,gCAiBC;AArBD,+EAAgE;AAEhE,oCAA2C;AAEpC,KAAK,UAAU,UAAU;IAC9B,MAAM,EACJ,OAAO,EAAE,EAAE,YAAY,EAAE,GAC1B,GAAG,MAAM,IAAA,uBAAe,GAAE,CAAC;IAE5B,MAAM,GAAG,GAAG,MAAM,IAAA,iCAAS,EAAC;QAC1B,MAAM,EAAE,YAAY;KACrB,CAAC,CAAC,wBAAwB,CAAC;QAC1B,gBAAgB,EAAE,YAAY,CAAC,OAAO;KACvC,CAAC,CAAC;IAEH,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC;IACrD,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/delegatee/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAppInfo = exports.ensureAppDelegateeFunded = void 0;
|
|
4
|
+
var ensure_funded_1 = require("./ensure-funded");
|
|
5
|
+
Object.defineProperty(exports, "ensureAppDelegateeFunded", { enumerable: true, get: function () { return ensure_funded_1.ensureAppDelegateeFunded; } });
|
|
6
|
+
var get_app_info_1 = require("./get-app-info");
|
|
7
|
+
Object.defineProperty(exports, "getAppInfo", { enumerable: true, get: function () { return get_app_info_1.getAppInfo; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/delegatee/index.ts"],"names":[],"mappings":";;;AAAA,iDAA2D;AAAlD,yHAAA,wBAAwB,OAAA;AACjC,+CAA4C;AAAnC,0GAAA,UAAU,OAAA"}
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addPermissionForAbilities = void 0;
|
|
4
|
+
const constants_1 = require("@lit-protocol/constants");
|
|
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
|
|
8
|
+
const addPermissionForAbilities = async (wallet, pkpTokenId, abilityIpfsCids) => {
|
|
9
|
+
const litContractClient = await (0, get_lit_contract_client_1.getLitContractsClient)({ wallet });
|
|
10
|
+
for (const ipfsCid of abilityIpfsCids) {
|
|
11
|
+
console.log(`Permitting ability: ${ipfsCid} with ability to sign on behalf of user's agent PKP ${pkpTokenId}`);
|
|
12
|
+
await litContractClient.addPermittedAction({
|
|
13
|
+
pkpTokenId,
|
|
14
|
+
ipfsId: ipfsCid,
|
|
15
|
+
authMethodScopes: [constants_1.AUTH_METHOD_SCOPE.SignAnything],
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
exports.addPermissionForAbilities = addPermissionForAbilities;
|
|
20
|
+
//# sourceMappingURL=add-permission-for-abilities.js.map
|