@@ -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
0 commit comments