diff --git a/src/agent/ICheqd.ts b/src/agent/ICheqd.ts index 538ce23..4165a92 100644 --- a/src/agent/ICheqd.ts +++ b/src/agent/ICheqd.ts @@ -6635,7 +6635,8 @@ export class Cheqd implements IAgentPlugin { return await lit.decrypt( thresholdEncryptionCiphertext, publishedList.metadata.statusListHash!, - unifiedAccessControlConditions + unifiedAccessControlConditions, + options?.topArgs?.dkgOptions?.capacityDelegationAuthSig ); })() : await (async function () { @@ -6805,7 +6806,8 @@ export class Cheqd implements IAgentPlugin { return await lit.decrypt( thresholdEncryptionCiphertext, publishedList.metadata.statusListHash!, - unifiedAccessControlConditions + unifiedAccessControlConditions, + options?.topArgs?.dkgOptions?.capacityDelegationAuthSig ); })() : await (async function () { diff --git a/src/dkg-threshold/lit-protocol/v6.ts b/src/dkg-threshold/lit-protocol/v6.ts index 9b8efae..ca031bb 100644 --- a/src/dkg-threshold/lit-protocol/v6.ts +++ b/src/dkg-threshold/lit-protocol/v6.ts @@ -12,7 +12,6 @@ import { MintCapacityCreditsRes, UnifiedAccessControlConditions, AuthSig as GenericAuthSig, - CapacityCreditsRes, SignerLike, } from '@lit-protocol/types'; import { generateSymmetricKey, randomBytes } from '../../utils/helpers.js'; @@ -20,7 +19,7 @@ import { isBrowser, isNode } from '../../utils/env.js'; import { v4 } from 'uuid'; import { fromString } from 'uint8arrays'; import { LitProtocolDebugEnabled } from '../../utils/constants.js'; -import { LitAccessControlConditionResource, LitRLIResource } from '@lit-protocol/auth-helpers'; +import { LitAccessControlConditionResource } from '@lit-protocol/auth-helpers'; import ethers from 'ethers'; import { LIT_RPC } from '@lit-protocol/constants'; @@ -94,7 +93,6 @@ export type LitContractsCreateCapacityDelegationAuthSignatureOptions = { }; export type MintCapacityCreditsResult = MintCapacityCreditsRes; export type CreateCapacityDelegationAuthSignatureResult = { - litResource: LitRLIResource; capacityDelegationAuthSig: GenericAuthSig; }; @@ -179,20 +177,9 @@ export class LitProtocol { async decrypt( encryptedString: string, stringHash: string, - unifiedAccessControlConditions: NonNullable + unifiedAccessControlConditions: NonNullable, + capacityDelegationAuthSig: GenericAuthSig ): Promise { - // mint capacity credits - const { capacityTokenIdStr } = await this.contractClient.mintCapacityCreditsNFT({ - daysUntilUTCMidnightExpiration: 1, - }); - - const { capacityDelegationAuthSig } = await this.createCapacityDelegationAuthSignature({ - uses: '1', - dAppOwnerWallet: this.contractClient.signer, - capacityTokenId: capacityTokenIdStr, - delegateeAddresses: [], - }); - // generate session signatures const sessionSigs = await this.client.getSessionSigs({ chain: 'cheqd', @@ -222,6 +209,29 @@ export class LitProtocol { return toString(decryptedData, 'utf-8'); } + async createCapacityDelegationAuthSignature( + options: LitContractsCreateCapacityDelegationAuthSignatureOptions + ): Promise { + return await this.client.createCapacityDelegationAuthSig({ + dAppOwnerWallet: options.dAppOwnerWallet, + capacityTokenId: options.capacityTokenId, + delegateeAddresses: options.delegateeAddresses, + uses: options.uses, + domain: options.domain, + expiration: options.expiration, + statement: options.statement, + }); + } + + async mintCapacityCredits(options: LitContractsMintCapacityCreditsOptions): Promise { + return this.contractClient.mintCapacityCreditsNFT({ + daysUntilUTCMidnightExpiration: options.effectiveDays, + requestsPerDay: options.requestsPerDay, + requestsPerSecond: options.requestsPerSecond, + requestsPerKilosecond: options.requestsPerKilosecond, + }); + } + static async encryptDirect(data: Uint8Array): Promise { try { // generate symmetric key @@ -421,20 +431,6 @@ export class LitProtocol { returnValueTest, }; } - - async createCapacityDelegationAuthSignature( - options: LitContractsCreateCapacityDelegationAuthSignatureOptions - ): Promise { - return await this.client.createCapacityDelegationAuthSig({ - dAppOwnerWallet: options.dAppOwnerWallet, - capacityTokenId: options.capacityTokenId, - delegateeAddresses: options.delegateeAddresses, - uses: options.uses, - domain: options.domain, - expiration: options.expiration, - statement: options.statement, - }); - } } export class LitContracts {