@lit-protocol/vincent-app-sdk 1.0.1-mcp1 → 1.0.1-mcp3
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/dist/src/utils/delegation.d.ts +7 -11
- package/dist/src/utils/delegation.d.ts.map +1 -1
- package/dist/src/utils/delegation.js +34 -10
- package/dist/src/utils/delegation.js.map +1 -1
- package/dist/src/utils/index.d.ts +2 -2
- package/dist/src/utils/index.d.ts.map +1 -1
- package/dist/src/utils/index.js +2 -2
- package/dist/src/utils/index.js.map +1 -1
- package/dist/src/utils/pkp.d.ts +4 -8
- package/dist/src/utils/pkp.d.ts.map +1 -1
- package/dist/src/utils/pkp.js +6 -14
- package/dist/src/utils/pkp.js.map +1 -1
- package/package.json +1 -1
|
@@ -18,27 +18,23 @@ import { ethers } from 'ethers';
|
|
|
18
18
|
*/
|
|
19
19
|
export declare function fetchDelegatedAgentPKPTokenIds(appId: number, version: number): Promise<ethers.BigNumber[]>;
|
|
20
20
|
/**
|
|
21
|
-
* Retrieves PKP
|
|
21
|
+
* Retrieves PKP Eth addresses for all delegators of a specific app version
|
|
22
22
|
*
|
|
23
23
|
* This function fetches the delegated agent PKP token IDs for a given app version
|
|
24
|
-
* and then retrieves
|
|
24
|
+
* and then retrieves the PKP Eth address for each token ID. This information
|
|
25
25
|
* can be used to identify and interact with the PKPs that are authorized as agents
|
|
26
26
|
* for the application.
|
|
27
27
|
*
|
|
28
28
|
* @param appId - The ID of the Vincent application
|
|
29
29
|
* @param appVersion - The version number of the application
|
|
30
|
-
* @returns An array of PKP
|
|
30
|
+
* @returns An array of PKP Eth addresses
|
|
31
31
|
*
|
|
32
32
|
* @example
|
|
33
33
|
* ```typescript
|
|
34
|
-
* const
|
|
35
|
-
* console.log(`Found ${
|
|
36
|
-
* console.log(`First PKP address: ${
|
|
34
|
+
* const pkpEthAddresses = await getDelegatorsAgentPkpAddresses(123, 1);
|
|
35
|
+
* console.log(`Found ${pkpEthAddresses.length} delegator PKPs`);
|
|
36
|
+
* console.log(`First PKP eth address: ${pkpEthAddresses[0]}`);
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
|
-
export declare function
|
|
40
|
-
tokenId: string;
|
|
41
|
-
ethAddress: string;
|
|
42
|
-
publicKey: string;
|
|
43
|
-
}[]>;
|
|
39
|
+
export declare function getDelegatorsAgentPkpAddresses(appId: number, appVersion: number): Promise<string[]>;
|
|
44
40
|
//# sourceMappingURL=delegation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delegation.d.ts","sourceRoot":"","sources":["../../../src/utils/delegation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAOhC;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,8BAA8B,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,+BASlF;
|
|
1
|
+
{"version":3,"file":"delegation.d.ts","sourceRoot":"","sources":["../../../src/utils/delegation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAOhC;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,8BAA8B,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,+BASlF;AAgCD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,8BAA8B,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,qBASrF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fetchDelegatedAgentPKPTokenIds = fetchDelegatedAgentPKPTokenIds;
|
|
4
|
-
exports.
|
|
4
|
+
exports.getDelegatorsAgentPkpAddresses = getDelegatorsAgentPkpAddresses;
|
|
5
5
|
const constants_1 = require("@lit-protocol/constants");
|
|
6
6
|
const contracts_1 = require("./contracts");
|
|
7
7
|
const pkp_1 = require("./pkp");
|
|
@@ -32,30 +32,54 @@ async function fetchDelegatedAgentPKPTokenIds(appId, version) {
|
|
|
32
32
|
throw new Error(`Error fetching delegated agent PKP token IDs: ${error}`);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
+
async function processWithConcurrency(items, processFn, concurrencyLimit) {
|
|
36
|
+
const results = [];
|
|
37
|
+
let index = 0;
|
|
38
|
+
// Start initial set of promises
|
|
39
|
+
const workers = Array(concurrencyLimit)
|
|
40
|
+
.fill(null)
|
|
41
|
+
.map(async () => {
|
|
42
|
+
while (index < items.length) {
|
|
43
|
+
const currentIndex = index++;
|
|
44
|
+
if (currentIndex >= items.length)
|
|
45
|
+
break;
|
|
46
|
+
try {
|
|
47
|
+
const result = await processFn(items[currentIndex]);
|
|
48
|
+
results[currentIndex] = result;
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
// Store the error but don't throw until all are done
|
|
52
|
+
results[currentIndex] = error;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
await Promise.all(workers);
|
|
57
|
+
return results;
|
|
58
|
+
}
|
|
35
59
|
/**
|
|
36
|
-
* Retrieves PKP
|
|
60
|
+
* Retrieves PKP Eth addresses for all delegators of a specific app version
|
|
37
61
|
*
|
|
38
62
|
* This function fetches the delegated agent PKP token IDs for a given app version
|
|
39
|
-
* and then retrieves
|
|
63
|
+
* and then retrieves the PKP Eth address for each token ID. This information
|
|
40
64
|
* can be used to identify and interact with the PKPs that are authorized as agents
|
|
41
65
|
* for the application.
|
|
42
66
|
*
|
|
43
67
|
* @param appId - The ID of the Vincent application
|
|
44
68
|
* @param appVersion - The version number of the application
|
|
45
|
-
* @returns An array of PKP
|
|
69
|
+
* @returns An array of PKP Eth addresses
|
|
46
70
|
*
|
|
47
71
|
* @example
|
|
48
72
|
* ```typescript
|
|
49
|
-
* const
|
|
50
|
-
* console.log(`Found ${
|
|
51
|
-
* console.log(`First PKP address: ${
|
|
73
|
+
* const pkpEthAddresses = await getDelegatorsAgentPkpAddresses(123, 1);
|
|
74
|
+
* console.log(`Found ${pkpEthAddresses.length} delegator PKPs`);
|
|
75
|
+
* console.log(`First PKP eth address: ${pkpEthAddresses[0]}`);
|
|
52
76
|
* ```
|
|
53
77
|
*/
|
|
54
|
-
async function
|
|
78
|
+
async function getDelegatorsAgentPkpAddresses(appId, appVersion) {
|
|
55
79
|
try {
|
|
56
80
|
const delegators = await fetchDelegatedAgentPKPTokenIds(appId, appVersion);
|
|
57
|
-
const
|
|
58
|
-
return
|
|
81
|
+
const delegatorsPkpEthAddresses = await processWithConcurrency(delegators, pkp_1.getPkpEthAddress, 5);
|
|
82
|
+
return delegatorsPkpEthAddresses;
|
|
59
83
|
}
|
|
60
84
|
catch (error) {
|
|
61
85
|
throw new Error(`Error fetching delegators agent PKP info: ${error}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delegation.js","sourceRoot":"","sources":["../../../src/utils/delegation.ts"],"names":[],"mappings":";;AAwBA,wEASC;
|
|
1
|
+
{"version":3,"file":"delegation.js","sourceRoot":"","sources":["../../../src/utils/delegation.ts"],"names":[],"mappings":";;AAwBA,wEASC;AAmDD,wEASC;AA3FD,uDAAsD;AAEtD,2CAA0C;AAC1C,+BAAyC;AAEzC;;;;;;;;;;;;;;;;GAgBG;AACI,KAAK,UAAU,8BAA8B,CAAC,KAAa,EAAE,OAAe;IACjF,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,IAAA,uBAAW,EAAC,uBAAW,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAC3D,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAE7D,OAAO,OAAO,CAAC,UAAU,CAAC,yBAA+C,CAAC;IAC5E,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,iDAAiD,KAAK,EAAE,CA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C,CAAC;IACxE,CAAC;AACH,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { fetchDelegatedAgentPKPTokenIds,
|
|
2
|
-
export { fetchDelegatedAgentPKPTokenIds,
|
|
1
|
+
import { fetchDelegatedAgentPKPTokenIds, getDelegatorsAgentPkpAddresses } from './delegation';
|
|
2
|
+
export { fetchDelegatedAgentPKPTokenIds, getDelegatorsAgentPkpAddresses };
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAE9F,OAAO,EAAE,8BAA8B,EAAE,8BAA8B,EAAE,CAAC"}
|
package/dist/src/utils/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getDelegatorsAgentPkpAddresses = exports.fetchDelegatedAgentPKPTokenIds = void 0;
|
|
4
4
|
const delegation_1 = require("./delegation");
|
|
5
5
|
Object.defineProperty(exports, "fetchDelegatedAgentPKPTokenIds", { enumerable: true, get: function () { return delegation_1.fetchDelegatedAgentPKPTokenIds; } });
|
|
6
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "getDelegatorsAgentPkpAddresses", { enumerable: true, get: function () { return delegation_1.getDelegatorsAgentPkpAddresses; } });
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,6CAA8F;AAErF,+GAFA,2CAA8B,OAEA;AAAE,+GAFA,2CAA8B,OAEA"}
|
package/dist/src/utils/pkp.d.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
/**
|
|
3
|
-
* Retrieves
|
|
3
|
+
* Retrieves PKP Eth Address
|
|
4
4
|
*
|
|
5
5
|
* This function queries the PKP Router contract to get the Ethereum address
|
|
6
|
-
*
|
|
6
|
+
* associated with a PKP token ID.
|
|
7
7
|
*
|
|
8
8
|
* @param pkpTokenId - The PKP token ID as ethers.BigNumber
|
|
9
|
-
* @returns
|
|
9
|
+
* @returns The PKP Eth address
|
|
10
10
|
*/
|
|
11
|
-
export declare function
|
|
12
|
-
tokenId: string;
|
|
13
|
-
ethAddress: string;
|
|
14
|
-
publicKey: string;
|
|
15
|
-
}>;
|
|
11
|
+
export declare function getPkpEthAddress(pkpTokenId: ethers.BigNumber): Promise<string>;
|
|
16
12
|
//# sourceMappingURL=pkp.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pkp.d.ts","sourceRoot":"","sources":["../../../src/utils/pkp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pkp.d.ts","sourceRoot":"","sources":["../../../src/utils/pkp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,MAAM,CAAC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAIpF"}
|
package/dist/src/utils/pkp.js
CHANGED
|
@@ -1,27 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getPkpEthAddress = getPkpEthAddress;
|
|
4
4
|
const constants_1 = require("@lit-protocol/constants");
|
|
5
5
|
const contracts_1 = require("./contracts");
|
|
6
6
|
/**
|
|
7
|
-
* Retrieves
|
|
7
|
+
* Retrieves PKP Eth Address
|
|
8
8
|
*
|
|
9
9
|
* This function queries the PKP Router contract to get the Ethereum address
|
|
10
|
-
*
|
|
10
|
+
* associated with a PKP token ID.
|
|
11
11
|
*
|
|
12
12
|
* @param pkpTokenId - The PKP token ID as ethers.BigNumber
|
|
13
|
-
* @returns
|
|
13
|
+
* @returns The PKP Eth address
|
|
14
14
|
*/
|
|
15
|
-
async function
|
|
15
|
+
async function getPkpEthAddress(pkpTokenId) {
|
|
16
16
|
const pubkeyRouter = (0, contracts_1.getContract)(constants_1.LIT_NETWORK.Datil, 'PubKeyRouter');
|
|
17
|
-
|
|
18
|
-
pubkeyRouter.getEthAddress(pkpTokenId),
|
|
19
|
-
pubkeyRouter.getPubkey(pkpTokenId),
|
|
20
|
-
]);
|
|
21
|
-
return {
|
|
22
|
-
tokenId: pkpTokenId.toHexString(),
|
|
23
|
-
ethAddress,
|
|
24
|
-
publicKey,
|
|
25
|
-
};
|
|
17
|
+
return await pubkeyRouter.getEthAddress(pkpTokenId);
|
|
26
18
|
}
|
|
27
19
|
//# sourceMappingURL=pkp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pkp.js","sourceRoot":"","sources":["../../../src/utils/pkp.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"pkp.js","sourceRoot":"","sources":["../../../src/utils/pkp.ts"],"names":[],"mappings":";;AAcA,4CAIC;AAlBD,uDAAsD;AAGtD,2CAA0C;AAE1C;;;;;;;;GAQG;AACI,KAAK,UAAU,gBAAgB,CAAC,UAA4B;IACjE,MAAM,YAAY,GAAG,IAAA,uBAAW,EAAC,uBAAW,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;IAEpE,OAAO,MAAM,YAAY,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;AACtD,CAAC"}
|