Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions local-tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ import { testSignTransactionWithSolanaEncryptedKey } from './tests/wrapped-keys/
import { testBatchGeneratePrivateKeys } from './tests/wrapped-keys/testBatchGeneratePrivateKeys';

import { setLitActionsCodeToLocal } from './tests/wrapped-keys/util';
import { testUseEoaSessionSigsToRequestSingleResponse } from './tests/testUseEoaSessionSigsToRequestSingleResponse';

// Use the current LIT action code to test against
setLitActionsCodeToLocal();
Expand Down Expand Up @@ -170,6 +171,7 @@ setLitActionsCodeToLocal();
testUseEoaSessionSigsToEncryptDecryptString,
testUseEoaSessionSigsToEncryptDecryptFile,
testUseEoaSessionSigsToEncryptDecryptZip,
testUseEoaSessionSigsToRequestSingleResponse,
};

const pkpSessionSigsTests = {
Expand Down
56 changes: 56 additions & 0 deletions local-tests/tests/testUseEoaSessionSigsToRequestSingleResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { getEoaSessionSigs } from 'local-tests/setup/session-sigs/get-eoa-session-sigs';
import { TinnyEnvironment } from 'local-tests/setup/tinny-environment';

/**
* Test Commands:
* ✅ NETWORK=datil-dev yarn test:local --filter=testUseEoaSessionSigsToRequestSingleResponse
* ✅ NETWORK=datil-test yarn test:local --filter=testUseEoaSessionSigsToRequestSingleResponse
* ✅ NETWORK=datil yarn test:local --filter=testUseEoaSessionSigsToRequestSingleResponse
*/
export const testUseEoaSessionSigsToRequestSingleResponse = async (
devEnv: TinnyEnvironment
) => {
const alice = await devEnv.createRandomPerson();

try {
const eoaSessionSigs = await getEoaSessionSigs(devEnv, alice);

const res = await devEnv.litNodeClient.executeJs({
sessionSigs: eoaSessionSigs,
code: `(async () => {
console.log('hello world')
})();`,
numResponsesRequired: 1,
});
} finally {
devEnv.releasePrivateKeyFromUser(alice);
}
console.log('res:', res);

// Expected output:
// {
// success: true,
// signedData: {},
// decryptedData: {},
// claimData: {},
// response: "",
// logs: "hello world\n",
// }

// -- assertions
if (res.response) {
throw new Error(`Expected "response" to be falsy`);
}

if (!res.logs) {
throw new Error(`Expected "logs" in res`);
}

if (!res.logs.includes('hello world')) {
throw new Error(`Expected "logs" to include 'hello world'`);
}

if (!res.success) {
throw new Error(`Expected "success" in res`);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ export const testBatchGeneratePrivateKeys = async (

const solanaMessageToSign = 'This is a test solana message';
const evmMessageToSign = 'This is a test evm message';
const results = await batchGeneratePrivateKeys({
const { results } = await batchGeneratePrivateKeys({
pkpSessionSigs: pkpSessionSigsSigning,
actions: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export const getSignatures = <T>(params: {

if (allKeys.length !== initialKeys.length) {
throwError({
message: 'total number of valid signatures does not match requested',
message: `Total number of valid signatures does not match requested. Valid signatures: ${allKeys.length}, Requested signatures: ${initialKeys.length}`,
errorKind: LIT_ERROR.NO_VALID_SHARES.kind,
errorCode: LIT_ERROR.NO_VALID_SHARES.code,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ export class LitNodeClientNodeJs
const res = await this.handleNodePromises(
nodePromises,
requestId,
this.connectedNodes.size
params.numResponsesRequired || this.connectedNodes.size
);

// -- case: promises rejected
Expand Down Expand Up @@ -1162,7 +1162,7 @@ export class LitNodeClientNodeJs
const signatures = getSignatures({
requestId,
networkPubKeySet: this.networkPubKeySet,
minNodeCount: this.config.minNodeCount,
minNodeCount: params.numResponsesRequired || this.config.minNodeCount,
signedData: signedDataList,
});

Expand Down
22 changes: 20 additions & 2 deletions packages/types/src/lib/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,8 @@ export interface JsonExecutionSdkParamsTargetNode
}

export interface JsonExecutionSdkParams
extends Pick<LitActionSdkParams, 'jsParams'> {
extends Pick<LitActionSdkParams, 'jsParams'>,
ExecuteJsAdvancedOptions {
/**
* JS code to run on the nodes
*/
Expand All @@ -522,14 +523,29 @@ export interface JsonExecutionSdkParams
* auth methods to resolve
*/
authMethods?: AuthMethod[];
}

export interface ExecuteJsAdvancedOptions {
/**
* a strategy for proccessing `reponse` objects returned from the
* Lit Action execution context
*/
responseStrategy?: LitActionResponseStrategy;

/**
* Allow overriding the default `code` property in the `JsonExecutionSdkParams`
*/
ipfsOptions?: IpfsOptions;

/**
* number of responses required to consider the execution successful
*/
numResponsesRequired?: number;

/**
* idea: the number of nodes to pay for running executions
*/
// numNodesToRunOn?: number;
}

export interface JsonExecutionRequestTargetNode extends JsonExecutionRequest {
Expand Down Expand Up @@ -687,7 +703,7 @@ export interface SigShare {
bigr?: string; // backward compatibility
bigR?: string;
publicKey: string;
dataSigned?: string;
dataSigned?: string | 'fail';
siweMessage?: string;
sigName?: string;
}
Expand All @@ -704,6 +720,8 @@ export interface PkpSignedData {
export interface NodeShare {
claimData: any;
shareIndex: any;

// I think this is deprecated
unsignedJwt: any;
signedData: SigShare;
decryptedData: any;
Expand Down
Loading