@@ -289,6 +289,35 @@ export const invalidEventsSignatures: { input: any; output: string }[] = [
289289 { input : undefined , output : 'Invalid parameter value in encodeEventSignature' } ,
290290] ;
291291
292+ export const validErrorsSignatures : { input : any ; output : string } [ ] = [
293+ {
294+ input : 'Unauthorized()' ,
295+ output : '0x82b4290015f7ec7256ca2a6247d3c2a89c4865c0e791456df195f40ad0a81367' ,
296+ } ,
297+ {
298+ input : {
299+ inputs : [ { internalType : 'string' , name : '' , type : 'string' } ] ,
300+ name : 'CustomError' ,
301+ type : 'error' ,
302+ } ,
303+ output : '0x8d6ea8bed4afafaebcad40e72174583b8bf4969c5d3bc84536051f3939bf9d81' ,
304+ } ,
305+ {
306+ input : 'Error(string)' ,
307+ output : '0x08c379a0afcc32b1a39302f7cb8073359698411ab5fd6e3edb2c02c0b5fba8aa' ,
308+ } ,
309+ ] ;
310+
311+ export const invalidErrorSignatures : { input : any ; output : string } [ ] = [
312+ { input : 345 , output : 'Invalid parameter value in encodeErrorSignature' } ,
313+ { input : { } , output : 'Invalid parameter value in encodeErrorSignature' } ,
314+ { input : [ 'mystring' ] , output : 'Invalid parameter value in encodeErrorSignature' } ,
315+ // Using "null" value intentionally for validation
316+ // eslint-disable-next-line no-null/no-null
317+ { input : null , output : 'Invalid parameter value in encodeErrorSignature' } ,
318+ { input : undefined , output : 'Invalid parameter value in encodeErrorSignature' } ,
319+ ] ;
320+
292321export const validDecodeLogsData : {
293322 input : { abi : any ; data : any ; topics : any } ;
294323 output : Record < string , unknown > ;
@@ -677,6 +706,13 @@ export const validEncodeParametersData: {
677706 ] ,
678707 output : '0x00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002d000000000000000000000000000000000000000000000000000000000000004e0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000002200000000000000000000000000000000000000000000000000000000000000ff' ,
679708 } ,
709+ {
710+ input : [
711+ [ 'uint' , 'tuple(uint256, string)' ] ,
712+ [ 1234 , [ 5678 , 'Hello World' ] ] ,
713+ ] ,
714+ output : '0x00000000000000000000000000000000000000000000000000000000000004d20000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000162e0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000b48656c6c6f20576f726c64000000000000000000000000000000000000000000' ,
715+ } ,
680716] ;
681717
682718export const inValidEncodeParametersData : {
@@ -900,3 +936,77 @@ export const inValidDecodeParametersData: {
900936 output : 'Parameter decoding error' ,
901937 } ,
902938] ;
939+
940+ export const validDecodeContractErrorData : {
941+ input : any [ ] ;
942+ output : any ;
943+ } [ ] = [
944+ {
945+ input : [
946+ [
947+ { inputs : [ ] , name : 'ErrorWithNoParams' , type : 'error' } ,
948+ {
949+ inputs : [
950+ { name : 'code' , type : 'uint256' } ,
951+ { name : 'message' , type : 'string' } ,
952+ ] ,
953+ name : 'ErrorWithParams' ,
954+ type : 'error' ,
955+ } ,
956+ ] ,
957+ {
958+ code : 12 ,
959+ message : 'message' ,
960+ data : '0xc85bda60000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001c5468697320697320616e206572726f72207769746820706172616d7300000000' ,
961+ } ,
962+ ] ,
963+ output : {
964+ errorName : 'ErrorWithParams' ,
965+ errorSignature : 'ErrorWithParams(uint256,string)' ,
966+ errorArgs : {
967+ code : 42 ,
968+ message : 'This is an error with params' ,
969+ } ,
970+ } ,
971+ } ,
972+ ] ;
973+
974+ export const invalidDecodeContractErrorData : {
975+ input : any [ ] ;
976+ } [ ] = [
977+ {
978+ input : [
979+ [
980+ { inputs : [ ] , name : 'ErrorWithNoParams' , type : 'error' } ,
981+ {
982+ inputs : [
983+ { name : 'code' , type : 'uint256' } ,
984+ { name : 'message' , type : 'string' } ,
985+ ] ,
986+ name : 'ErrorWithParams' ,
987+ type : 'error' ,
988+ } ,
989+ ] ,
990+ {
991+ code : 12 ,
992+ message : 'message' ,
993+ data : '0xc85bda60000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000123450000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c5468697320697320616e206572726f72207769746820706172616d7300000000' ,
994+ } ,
995+ ] ,
996+ } ,
997+ ] ;
998+
999+ export const validIsAbiConstructorFragment : {
1000+ input : any ;
1001+ } [ ] = [
1002+ {
1003+ input : { inputs : [ ] , stateMutability : 'nonpayable' , type : 'constructor' } ,
1004+ } ,
1005+ ] ;
1006+ export const invalidIsAbiConstructorFragment : {
1007+ input : any ;
1008+ } [ ] = [
1009+ {
1010+ input : { inputs : [ ] , stateMutability : 'nonpayable' , type : 'function' } ,
1011+ } ,
1012+ ] ;
0 commit comments