Skip to content

Commit a1151f4

Browse files
committed
chore: remove pkp token id from wk methods. Dynamically get abi for isDelegateePermitted
1 parent 7a488d6 commit a1151f4

File tree

7 files changed

+37
-57
lines changed

7 files changed

+37
-57
lines changed

packages/apps/abilities-e2e/test-e2e/test-config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"appId": 92519500199,
2+
"appId": 25495808171,
33
"appVersion": 1,
44
"userPkp": {
55
"tokenId": "3642086617849255502636868489753780819830331370694537145307432406587444605687",

packages/apps/ability-sol-transaction-signer/src/generated/lit-action.js

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"ipfsCid": "QmZVuFvb658YHAmiPrA7Pn3aGsjtEKkeb6DJfwNvQcVAew"
2+
"ipfsCid": "Qmexso1eSsrbPwugcqRNqvejhqrPrRjvAz9qVCy9yJTHMD"
33
}

packages/apps/ability-sol-transaction-signer/src/lib/vincent-ability.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ export const vincentAbility = createVincentAbility({
7777
dataToEncryptHash,
7878
legacyTransactionOptions,
7979
} = abilityParams;
80-
const { tokenId } = delegatorPkpInfo;
80+
const { ethAddress } = delegatorPkpInfo;
8181

8282
try {
8383
const solanaKeypair = await getSolanaKeyPairFromWrappedKey({
84-
delegatorPkpTokenId: tokenId,
84+
delegatorAddress: ethAddress,
8585
ciphertext,
8686
dataToEncryptHash,
8787
});

packages/libs/contracts-sdk/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ export { createContract } from './utils';
4545

4646
export { getPkpTokenId } from './utils/pkpInfo';
4747

48-
export { VINCENT_DIAMOND_CONTRACT_ADDRESS_PROD } from './constants';
48+
export { VINCENT_DIAMOND_CONTRACT_ADDRESS_PROD, COMBINED_ABI } from './constants';

packages/libs/wrapped-keys/src/lib/api/utils.ts

Lines changed: 26 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { LIT_RPC } from '@lit-protocol/constants';
66
import {
77
VINCENT_DIAMOND_CONTRACT_ADDRESS_PROD,
88
getPkpTokenId,
9+
COMBINED_ABI,
910
} from '@lit-protocol/vincent-contracts-sdk';
1011

1112
import type { KeyType, Network } from '../types';
@@ -57,66 +58,45 @@ export function getFirstSessionSig(pkpSessionSigs: SessionSigsMap): AuthSig {
5758
*/
5859
export async function getVincentRegistryAccessControlCondition({
5960
delegatorAddress,
60-
delegatorPkpTokenId,
6161
}: {
62-
delegatorAddress?: string;
63-
delegatorPkpTokenId?: string;
62+
delegatorAddress: string;
6463
}): Promise<AccsEVMParams> {
65-
let _delegatorPkpTokenId = delegatorPkpTokenId;
66-
67-
if (delegatorAddress) {
68-
if (!ethers.utils.isAddress(delegatorAddress)) {
69-
throw new Error(`delegatorAddress is not a valid Ethereum Address: ${delegatorAddress}`);
70-
}
71-
72-
_delegatorPkpTokenId = (
73-
await getPkpTokenId({
74-
pkpEthAddress: delegatorAddress,
75-
signer: ethers.Wallet.createRandom().connect(
76-
new ethers.providers.StaticJsonRpcProvider(LIT_RPC.CHRONICLE_YELLOWSTONE),
77-
),
78-
})
79-
).toString();
64+
if (!ethers.utils.isAddress(delegatorAddress)) {
65+
throw new Error(`delegatorAddress is not a valid Ethereum Address: ${delegatorAddress}`);
8066
}
8167

82-
if (!_delegatorPkpTokenId) {
83-
throw new Error(
84-
'The delegator address or PKP token ID is required to create an access control conditions',
85-
);
86-
}
68+
const delegatorPkpTokenId = (
69+
await getPkpTokenId({
70+
pkpEthAddress: delegatorAddress,
71+
signer: ethers.Wallet.createRandom().connect(
72+
new ethers.providers.StaticJsonRpcProvider(LIT_RPC.CHRONICLE_YELLOWSTONE),
73+
),
74+
})
75+
).toString();
76+
77+
const contractInterface = new ethers.utils.Interface(COMBINED_ABI.fragments);
78+
const fragment = contractInterface.getFunction('isDelegateePermitted');
8779

8880
const functionAbi = {
8981
type: 'function',
90-
name: 'isDelegateePermitted',
91-
inputs: [
92-
{
93-
name: 'delegatee',
94-
type: 'address',
95-
},
96-
{
97-
name: 'pkpTokenId',
98-
type: 'uint256',
99-
},
100-
{
101-
name: 'abilityIpfsCid',
102-
type: 'string',
103-
},
104-
],
105-
outputs: [
106-
{
107-
name: 'isPermitted',
108-
type: 'bool',
109-
},
110-
],
111-
stateMutability: 'view',
82+
name: fragment.name,
83+
inputs: fragment.inputs.map((input) => ({
84+
name: input.name,
85+
type: input.type,
86+
})),
87+
outputs: fragment.outputs?.map((output) => ({
88+
name: output.name,
89+
type: output.type,
90+
})),
91+
stateMutability: fragment.stateMutability,
11292
};
11393

11494
return {
11595
contractAddress: VINCENT_DIAMOND_CONTRACT_ADDRESS_PROD,
11696
functionAbi,
11797
chain: CHAIN_YELLOWSTONE,
11898
functionName: 'isDelegateePermitted',
119-
functionParams: [':userAddress', _delegatorPkpTokenId, ':currentActionIpfsId'],
99+
functionParams: [':userAddress', delegatorPkpTokenId, ':currentActionIpfsId'],
120100
returnValueTest: {
121101
key: 'isPermitted',
122102
comparator: '=',

packages/libs/wrapped-keys/src/lib/lit-actions-client/get-solana-key-pair-from-wrapped-key.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@ declare const Lit: typeof LitNamespace;
1010
/**
1111
* Helper function to decrypt a Vincent Solana Wrapped Key and initialize a Solana Keypair.
1212
*
13-
* @param delegatorPkpTokenId - The PKP token ID of the vincent delegator
13+
* @param delegatorAddress - The PKP ethereum address of the vincent delegator
1414
* @param ciphertext - The encrypted wrapped key
1515
* @param dataToEncryptHash - Hash of the encrypted data
1616
* @returns A Solana Keypair instance
1717
* @throws Error if the decrypted private key is not prefixed with 'lit_' or if decryption fails
1818
*/
1919
export async function getSolanaKeyPairFromWrappedKey({
20-
delegatorPkpTokenId,
20+
delegatorAddress,
2121
ciphertext,
2222
dataToEncryptHash,
2323
}: {
24-
delegatorPkpTokenId: string;
24+
delegatorAddress: string;
2525
ciphertext: string;
2626
dataToEncryptHash: string;
2727
}): Promise<Keypair> {
2828
const accessControlConditions = [
2929
await getVincentRegistryAccessControlCondition({
30-
delegatorPkpTokenId,
30+
delegatorAddress,
3131
}),
3232
];
3333

0 commit comments

Comments
 (0)