Skip to content

Commit 08c4f0e

Browse files
committed
refac: Prettier
1 parent a401416 commit 08c4f0e

File tree

3 files changed

+71
-52
lines changed

3 files changed

+71
-52
lines changed

local-tests/tests/testKeccakEip1271AuthSigToEncryptDecryptString.ts

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ export const testKeccakEip1271AuthSigToEncryptDecryptString = async (
2222
const contractAddress = '0x88105De2349f59767278Fd15c0858f806c08d615';
2323
const deployerAddress = '0x0b1C5E9E82393AD5d1d1e9a498BF7bAAC13b31Ee'; // No purpose other than to be a random address
2424
const abi = [
25-
"function setTempOwner(address _tempOwner) external",
26-
"function getTempOwner() external view returns (address)",
27-
"function isValidSignature(bytes32 _hash, bytes calldata _signature) external view returns (bytes4)"
25+
'function setTempOwner(address _tempOwner) external',
26+
'function getTempOwner() external view returns (address)',
27+
'function isValidSignature(bytes32 _hash, bytes calldata _signature) external view returns (bytes4)',
2828
];
2929

3030
const alice = await devEnv.createRandomPerson();
@@ -75,7 +75,7 @@ export const testKeccakEip1271AuthSigToEncryptDecryptString = async (
7575
const eip1271AuthSig: AuthSig = {
7676
address: contractAddress,
7777
sig: siweSignature,
78-
derivedVia: "EIP1271",
78+
derivedVia: 'EIP1271',
7979
signedMessage: siweMessage,
8080
};
8181

@@ -86,14 +86,18 @@ export const testKeccakEip1271AuthSigToEncryptDecryptString = async (
8686
const setDeployerAsTempOwnerTx = await contract.setTempOwner(deployerAddress);
8787
await setDeployerAsTempOwnerTx.wait();
8888

89-
log("0. isValidSignature should FAIL since Alice (AuthSig.sig) is not the tempOwner yet");
89+
log(
90+
'0. isValidSignature should FAIL since Alice (AuthSig.sig) is not the tempOwner yet'
91+
);
9092
try {
9193
const isValid = await contract.isValidSignature(hash, siweSignature);
92-
if (isValid === "0x1626ba7e") {
93-
throw new Error(`Expected isValidSignature to be 0xffffffff but got ${isValid}`);
94+
if (isValid === '0x1626ba7e') {
95+
throw new Error(
96+
`Expected isValidSignature to be 0xffffffff but got ${isValid}`
97+
);
9498
}
9599
} catch (error) {
96-
log("Error calling isValidSignature:", error);
100+
log('Error calling isValidSignature:', error);
97101
throw error;
98102
}
99103

@@ -109,33 +113,42 @@ export const testKeccakEip1271AuthSigToEncryptDecryptString = async (
109113
devEnv.litNodeClient as unknown as ILitNodeClient
110114
);
111115
} catch (error) {
112-
if (!error.message.includes('NodeContractAuthsigUnauthorized') ||
116+
if (
117+
!error.message.includes('NodeContractAuthsigUnauthorized') ||
113118
!error.message.includes('Access control failed for Smart contract') ||
114-
!error.message.includes('validation error: Authsig failed for contract 0x88105De2349f59767278Fd15c0858f806c08d615. Return value was ffffffff.')
115-
) {
116-
throw new Error(`Expected error message to contain specific EIP1271 validation failure, but got: ${error}`);
119+
!error.message.includes(
120+
'validation error: Authsig failed for contract 0x88105De2349f59767278Fd15c0858f806c08d615. Return value was ffffffff.'
121+
)
122+
) {
123+
throw new Error(
124+
`Expected error message to contain specific EIP1271 validation failure, but got: ${error}`
125+
);
117126
}
118127
}
119128

120129
// Should PASS now
121-
log("1. Setting temp owner...");
130+
log('1. Setting temp owner...');
122131
const setTempOwnerTx = await contract.setTempOwner(alice.wallet.address);
123132
await setTempOwnerTx.wait();
124-
log("Set tempOwner transaction hash: ", setTempOwnerTx.hash);
133+
log('Set tempOwner transaction hash: ', setTempOwnerTx.hash);
125134

126135
const tempOwner = await contract.getTempOwner();
127136
if (tempOwner.toLowerCase() !== alice.wallet.address.toLowerCase()) {
128-
throw new Error(`Expected temp owner to be ${alice.wallet.address} but got ${tempOwner}`);
137+
throw new Error(
138+
`Expected temp owner to be ${alice.wallet.address} but got ${tempOwner}`
139+
);
129140
}
130141

131-
log("2. Checking isValidSignature...");
142+
log('2. Checking isValidSignature...');
132143
try {
133144
const isValid = await contract.isValidSignature(hash, siweSignature);
134-
if (isValid !== "0x1626ba7e") {
135-
throw new Error(`Expected isValidSignature to be 0x1626ba7e but got ${isValid}`);
145+
if (isValid !== '0x1626ba7e') {
146+
throw new Error(
147+
`Expected isValidSignature to be 0x1626ba7e but got ${isValid}`
148+
);
136149
}
137150
} catch (error) {
138-
log("Error calling isValidSignature:", error);
151+
log('Error calling isValidSignature:', error);
139152
throw error;
140153
}
141154

local-tests/tests/testShaEip1271AuthSigToEncryptDecryptString.ts

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ export const testShaEip1271AuthSigToEncryptDecryptString = async (
2222
const contractAddress = '0x88105De2349f59767278Fd15c0858f806c08d615';
2323
const deployerAddress = '0x0b1C5E9E82393AD5d1d1e9a498BF7bAAC13b31Ee'; // No purpose other than to be a random address
2424
const abi = [
25-
"function setTempOwner(address _tempOwner) external",
26-
"function getTempOwner() external view returns (address)",
27-
"function isValidSignature(bytes32 _hash, bytes calldata _signature) external view returns (bytes4)"
25+
'function setTempOwner(address _tempOwner) external',
26+
'function getTempOwner() external view returns (address)',
27+
'function isValidSignature(bytes32 _hash, bytes calldata _signature) external view returns (bytes4)',
2828
];
2929

3030
const alice = await devEnv.createRandomPerson();
@@ -70,13 +70,15 @@ export const testShaEip1271AuthSigToEncryptDecryptString = async (
7070
log('hash:', hashHex);
7171
log('hashUint8Array: ', hashUint8Array); // Match it against the hash done on the nodes before calling verifySignature()
7272

73-
const siweSignature = joinSignature(alice.wallet._signingKey().signDigest(hashHex));
73+
const siweSignature = joinSignature(
74+
alice.wallet._signingKey().signDigest(hashHex)
75+
);
7476
log('siweSignature: ', siweSignature);
7577

7678
const eip1271AuthSig: AuthSig = {
7779
address: contractAddress,
7880
sig: siweSignature,
79-
derivedVia: "EIP1271_SHA256",
81+
derivedVia: 'EIP1271_SHA256',
8082
signedMessage: siweMessage,
8183
};
8284

@@ -87,14 +89,18 @@ export const testShaEip1271AuthSigToEncryptDecryptString = async (
8789
const setDeployerAsTempOwnerTx = await contract.setTempOwner(deployerAddress);
8890
await setDeployerAsTempOwnerTx.wait();
8991

90-
log("0. isValidSignature should FAIL since Alice (AuthSig.sig) is not the tempOwner yet");
92+
log(
93+
'0. isValidSignature should FAIL since Alice (AuthSig.sig) is not the tempOwner yet'
94+
);
9195
try {
9296
const isValid = await contract.isValidSignature(hash, siweSignature);
93-
if (isValid === "0x1626ba7e") {
94-
throw new Error(`Expected isValidSignature to be 0xffffffff but got ${isValid}`);
97+
if (isValid === '0x1626ba7e') {
98+
throw new Error(
99+
`Expected isValidSignature to be 0xffffffff but got ${isValid}`
100+
);
95101
}
96102
} catch (error) {
97-
log("Error calling isValidSignature:", error);
103+
log('Error calling isValidSignature:', error);
98104
throw error;
99105
}
100106

@@ -110,33 +116,42 @@ export const testShaEip1271AuthSigToEncryptDecryptString = async (
110116
devEnv.litNodeClient as unknown as ILitNodeClient
111117
);
112118
} catch (error) {
113-
if (!error.message.includes('NodeContractAuthsigUnauthorized') ||
119+
if (
120+
!error.message.includes('NodeContractAuthsigUnauthorized') ||
114121
!error.message.includes('Access control failed for Smart contract') ||
115-
!error.message.includes('validation error: Authsig failed for contract 0x88105De2349f59767278Fd15c0858f806c08d615. Return value was ffffffff.')
116-
) {
117-
throw new Error(`Expected error message to contain specific EIP1271 validation failure, but got: ${error}`);
122+
!error.message.includes(
123+
'validation error: Authsig failed for contract 0x88105De2349f59767278Fd15c0858f806c08d615. Return value was ffffffff.'
124+
)
125+
) {
126+
throw new Error(
127+
`Expected error message to contain specific EIP1271 validation failure, but got: ${error}`
128+
);
118129
}
119130
}
120131

121132
// Should PASS now
122-
log("1. Setting temp owner...");
133+
log('1. Setting temp owner...');
123134
const setTempOwnerTx = await contract.setTempOwner(alice.wallet.address);
124135
await setTempOwnerTx.wait();
125-
log("Set tempOwner transaction hash: ", setTempOwnerTx.hash);
136+
log('Set tempOwner transaction hash: ', setTempOwnerTx.hash);
126137

127138
const tempOwner = await contract.getTempOwner();
128139
if (tempOwner.toLowerCase() !== alice.wallet.address.toLowerCase()) {
129-
throw new Error(`Expected temp owner to be ${alice.wallet.address} but got ${tempOwner}`);
140+
throw new Error(
141+
`Expected temp owner to be ${alice.wallet.address} but got ${tempOwner}`
142+
);
130143
}
131144

132-
log("2. Checking isValidSignature...");
145+
log('2. Checking isValidSignature...');
133146
try {
134147
const isValid = await contract.isValidSignature(hash, siweSignature);
135-
if (isValid !== "0x1626ba7e") {
136-
throw new Error(`Expected isValidSignature to be 0x1626ba7e but got ${isValid}`);
148+
if (isValid !== '0x1626ba7e') {
149+
throw new Error(
150+
`Expected isValidSignature to be 0x1626ba7e but got ${isValid}`
151+
);
137152
}
138153
} catch (error) {
139-
log("Error calling isValidSignature:", error);
154+
log('Error calling isValidSignature:', error);
140155
throw error;
141156
}
142157

tsconfig.json

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,15 @@
1010
"importHelpers": true,
1111
"target": "ES2020",
1212
"module": "ES2020",
13-
"lib": [
14-
"ES2020",
15-
"dom",
16-
"ES2021.String"
17-
],
13+
"lib": ["ES2020", "dom", "ES2021.String"],
1814
"skipLibCheck": true,
1915
"skipDefaultLibCheck": true,
2016
"baseUrl": ".",
2117
"allowSyntheticDefaultImports": true,
2218
"resolveJsonModule": true,
2319
"paths": {
24-
"@lit-protocol/*": [
25-
"packages/*/src"
26-
]
20+
"@lit-protocol/*": ["packages/*/src"]
2721
}
2822
},
29-
"exclude": [
30-
"node_modules",
31-
"tmp"
32-
]
33-
}
23+
"exclude": ["node_modules", "tmp"]
24+
}

0 commit comments

Comments
 (0)