Skip to content

Commit c3c38ff

Browse files
committed
refactor(types): enhance TypedData message structure and simplify test parameters
- Updated the TypedData message structure to use more specific types for domain, types, and value fields. - Simplified the test parameters in the Ethereum signing test to directly use wallet addresses. - Updated related interfaces and types for consistency across the codebase.
1 parent a739bfa commit c3c38ff

File tree

5 files changed

+53
-27
lines changed

5 files changed

+53
-27
lines changed

local-tests/tests/wrapped-keys/testFailEthereumSignTypedDataWrappedKeyInvalidDecryption.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,8 @@ export const testFailEthereumSignTypedDataWrappedKeyInvalidDecryption = async (
7373
],
7474
},
7575
value: {
76-
from: {
77-
name: 'Alice',
78-
wallet: alice.wallet.address,
79-
},
80-
to: {
81-
name: 'Bob',
82-
wallet: '0x1234567890123456789012345678901234567890',
83-
},
76+
from: alice.wallet.address,
77+
to: '0x1234567890123456789012345678901234567890',
8478
contents: 'Hello, Bob!',
8579
},
8680
};

packages/wrapped-keys-lit-actions/src/lib/internal/ethereum/signTypedData.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
1+
interface TypedDataField {
2+
name: string;
3+
type: string;
4+
}
5+
interface TypedDataMessage {
6+
domain: {
7+
name?: string;
8+
version?: string;
9+
chainId?: number | string | bigint;
10+
verifyingContract?: string;
11+
salt?: string;
12+
};
13+
types: Record<string, TypedDataField[]>;
14+
value: Record<string, string | number>;
15+
}
116
interface SignTypedDataParams {
217
privateKey: string;
3-
messageToSign: {
4-
domain: any;
5-
types: Record<string, any[]>;
6-
value: Record<string, any>;
7-
};
18+
messageToSign: TypedDataMessage;
819
}
920

1021
interface VerifyMessageSignatureParams {
11-
messageToSign: {
12-
domain: any;
13-
types: Record<string, any[]>;
14-
value: Record<string, any>;
15-
};
22+
messageToSign: TypedDataMessage;
1623
signature: string;
1724
}
1825

packages/wrapped-keys-lit-actions/src/lib/raw-action-functions/ethereum/signTypedDataWithEncryptedEthereumKey.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
import { getDecryptedKeyToSingleNode } from '../../internal/common/getDecryptedKeyToSingleNode';
22
import { signTypedDataEthereumKey } from '../../internal/ethereum/signTypedData';
33

4+
interface TypedDataField {
5+
name: string;
6+
type: string;
7+
}
8+
interface TypedDataMessage {
9+
domain: {
10+
name?: string;
11+
version?: string;
12+
chainId?: number | string | bigint;
13+
verifyingContract?: string;
14+
salt?: string;
15+
};
16+
types: Record<string, TypedDataField[]>;
17+
value: Record<string, string | number>;
18+
}
419
export interface SignTypedDataWithEncryptedEthereumKeyParams {
520
accessControlConditions: string;
621
ciphertext: string;
722
dataToEncryptHash: string;
8-
messageToSign: {
9-
domain: any;
10-
types: Record<string, any[]>;
11-
value: Record<string, any>;
12-
};
23+
messageToSign: TypedDataMessage;
1324
}
1425

1526
/**

packages/wrapped-keys/src/lib/lit-actions-client/lit-action-cid-repository.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"solana": "QmS4Y6f2zHriNzioxBbysbuXQbjX7ga468CCyYcuY2AeeH"
99
},
1010
"signTypedData": {
11-
"evm": "QmRnMnUbdZznL9vHnS1eFAdH5tQY1Dj59rtYVznLuexatb",
11+
"evm": "Qme9u1juozWAZFv9c2dxnZS5t3ErUNcDfZNKqSuXkreH5t",
1212
"solana": ""
1313
},
1414
"generateEncryptedKey": {

packages/wrapped-keys/src/lib/types.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,24 @@ export interface ImportPrivateKeyResult {
231231
pkpAddress: string;
232232
id: string;
233233
}
234+
235+
interface TypedDataField {
236+
name: string;
237+
type: string;
238+
}
239+
240+
interface TypedDataDomain {
241+
name?: string;
242+
version?: string;
243+
chainId?: number | string | bigint;
244+
verifyingContract?: string;
245+
salt?: string;
246+
}
247+
234248
interface signTypedDataMessageParams {
235-
domain: any;
236-
types: Record<string, any[]>;
237-
value: Record<string, any>;
249+
domain: TypedDataDomain;
250+
types: Record<string, TypedDataField[]>;
251+
value: Record<string, string | number>;
238252
}
239253

240254
interface SignMessageParams {

0 commit comments

Comments
 (0)