@lit-protocol/e2e
Version:
Lit Protocol E2E testing package for running comprehensive integration tests
51 lines • 2.03 kB
JavaScript
import { getAddress } from 'viem';
export const createViemSignTypedDataTest = (ctx, getAuthContext) => {
return async () => {
const pkpViemAccount = await ctx.litClient.getPkpViemAccount({
pkpPublicKey: ctx.aliceViemAccountPkp.pubkey,
authContext: getAuthContext(),
chainConfig: ctx.litClient.getChainConfig().viemConfig,
});
const typedData = {
domain: {
name: 'E2E Test Service',
version: '1',
chainId: BigInt(1),
verifyingContract: getAddress('0x1e0Ae8205e9726E6F296ab8869930607a853204C'),
},
types: {
EIP712Domain: [
{ name: 'name', type: 'string' },
{ name: 'version', type: 'string' },
{ name: 'chainId', type: 'uint256' },
{ name: 'verifyingContract', type: 'address' },
],
Person: [
{ name: 'name', type: 'string' },
{ name: 'wallet', type: 'address' },
],
Mail: [
{ name: 'from', type: 'Person' },
{ name: 'to', type: 'Person' },
{ name: 'contents', type: 'string' },
],
},
primaryType: 'Mail',
message: {
from: {
name: 'Alice',
wallet: getAddress('0x2111111111111111111111111111111111111111'),
},
to: {
name: 'Bob',
wallet: getAddress('0x3111111111111111111111111111111111111111'),
},
contents: 'Hello from e2e typed data test!',
},
};
const signature = await pkpViemAccount.signTypedData(typedData);
expect(signature).toBeDefined();
expect(signature).toMatch(/^0x[a-fA-F0-9]{130}$/);
};
};
//# sourceMappingURL=viem-sign-typed-data.js.map