@@ -41,7 +41,12 @@ import * as mockInterface from "../../src/forwarder/mock-interface";
4141import { StructuredData } from "../../src/utils/signature" ;
4242import nock from "nock" ;
4343import { AddressZero } from "@ethersproject/constants" ;
44- import { AuthTokenType , EvaluationMethod , GatingType , TokenType } from "@bosonprotocol/common" ;
44+ import {
45+ AuthTokenType ,
46+ EvaluationMethod ,
47+ GatingType ,
48+ TokenType
49+ } from "@bosonprotocol/common" ;
4550
4651jest . setTimeout ( 60_000 ) ;
4752
@@ -98,10 +103,7 @@ function assertSignedMetaTx(result: unknown) {
98103 expect ( typeof r . functionSignature ) . toBe ( "string" ) ;
99104}
100105
101- function assertStructuredData (
102- result : unknown ,
103- expectedPrimaryType : string
104- ) {
106+ function assertStructuredData ( result : unknown , expectedPrimaryType : string ) {
105107 const d = result as StructuredData ;
106108 expect ( d . primaryType ) . toBe ( expectedPrimaryType ) ;
107109 expect ( d . domain . name ) . toBe ( "Boson Protocol" ) ;
@@ -164,15 +166,22 @@ const createGroupArgs = {
164166describe ( "meta-tx handler" , ( ) => {
165167 // ── signMetaTx (base) ──────────────────────────────────────────────────────
166168 describe ( "#signMetaTx()" , ( ) => {
167- const extraArgs = { functionName : "testFn()" , functionSignature : "0xdeadbeef" } ;
169+ const extraArgs = {
170+ functionName : "testFn()" ,
171+ functionSignature : "0xdeadbeef"
172+ } ;
168173
169174 test ( "returns SignedMetaTx without returnTypedDataToSign" , async ( ) => {
170175 const result = await signMetaTx ( { ...base ( ) , ...extraArgs } ) ;
171176 assertSignedMetaTx ( result ) ;
172177 } ) ;
173178
174179 test ( "returns StructuredData with returnTypedDataToSign: true" , async ( ) => {
175- const result = await signMetaTx ( { ...base ( ) , ...extraArgs , returnTypedDataToSign : true } ) ;
180+ const result = await signMetaTx ( {
181+ ...base ( ) ,
182+ ...extraArgs ,
183+ returnTypedDataToSign : true
184+ } ) ;
176185 assertStructuredData ( result , "MetaTransaction" ) ;
177186 expect ( ( result as StructuredData ) . message ) . toMatchObject ( {
178187 functionName : extraArgs . functionName ,
@@ -184,7 +193,10 @@ describe("meta-tx handler", () => {
184193 // ── signMetaTxCreateSeller ─────────────────────────────────────────────────
185194 describe ( "#signMetaTxCreateSeller()" , ( ) => {
186195 test ( "returns SignedMetaTx without returnTypedDataToSign" , async ( ) => {
187- const result = await signMetaTxCreateSeller ( { ...base ( ) , createSellerArgs } ) ;
196+ const result = await signMetaTxCreateSeller ( {
197+ ...base ( ) ,
198+ createSellerArgs
199+ } ) ;
188200 assertSignedMetaTx ( result ) ;
189201 expect ( result . functionName ) . toContain ( "createSeller" ) ;
190202 } ) ;
@@ -202,7 +214,10 @@ describe("meta-tx handler", () => {
202214 // ── signMetaTxUpdateSeller ─────────────────────────────────────────────────
203215 describe ( "#signMetaTxUpdateSeller()" , ( ) => {
204216 test ( "returns SignedMetaTx without returnTypedDataToSign" , async ( ) => {
205- const result = await signMetaTxUpdateSeller ( { ...base ( ) , updateSellerArgs } ) ;
217+ const result = await signMetaTxUpdateSeller ( {
218+ ...base ( ) ,
219+ updateSellerArgs
220+ } ) ;
206221 assertSignedMetaTx ( result ) ;
207222 expect ( result . functionName ) . toContain ( "updateSeller" ) ;
208223 } ) ;
@@ -289,15 +304,22 @@ describe("meta-tx handler", () => {
289304 } ) ;
290305
291306 test ( "returns StructuredData with returnTypedDataToSign: true" , async ( ) => {
292- const result = await signMetaTxVoidOffer ( { ...base ( ) , offerId : "1" , returnTypedDataToSign : true } ) ;
307+ const result = await signMetaTxVoidOffer ( {
308+ ...base ( ) ,
309+ offerId : "1" ,
310+ returnTypedDataToSign : true
311+ } ) ;
293312 assertStructuredData ( result , "MetaTransaction" ) ;
294313 } ) ;
295314 } ) ;
296315
297316 // ── signMetaTxVoidOfferBatch ───────────────────────────────────────────────
298317 describe ( "#signMetaTxVoidOfferBatch()" , ( ) => {
299318 test ( "returns SignedMetaTx without returnTypedDataToSign" , async ( ) => {
300- const result = await signMetaTxVoidOfferBatch ( { ...base ( ) , offerIds : [ "1" , "2" ] } ) ;
319+ const result = await signMetaTxVoidOfferBatch ( {
320+ ...base ( ) ,
321+ offerIds : [ "1" , "2" ]
322+ } ) ;
301323 assertSignedMetaTx ( result ) ;
302324 expect ( result . functionName ) . toBe ( "voidOfferBatch(uint256[])" ) ;
303325 } ) ;
@@ -382,7 +404,10 @@ describe("meta-tx handler", () => {
382404 // ── signMetaTxExpireVoucher ────────────────────────────────────────────────
383405 describe ( "#signMetaTxExpireVoucher()" , ( ) => {
384406 test ( "returns SignedMetaTx without returnTypedDataToSign" , async ( ) => {
385- const result = await signMetaTxExpireVoucher ( { ...base ( ) , exchangeId : "1" } ) ;
407+ const result = await signMetaTxExpireVoucher ( {
408+ ...base ( ) ,
409+ exchangeId : "1"
410+ } ) ;
386411 assertSignedMetaTx ( result ) ;
387412 expect ( result . functionName ) . toBe ( "expireVoucher(uint256)" ) ;
388413 } ) ;
@@ -400,7 +425,10 @@ describe("meta-tx handler", () => {
400425 // ── signMetaTxRevokeVoucher ────────────────────────────────────────────────
401426 describe ( "#signMetaTxRevokeVoucher()" , ( ) => {
402427 test ( "returns SignedMetaTx without returnTypedDataToSign" , async ( ) => {
403- const result = await signMetaTxRevokeVoucher ( { ...base ( ) , exchangeId : "1" } ) ;
428+ const result = await signMetaTxRevokeVoucher ( {
429+ ...base ( ) ,
430+ exchangeId : "1"
431+ } ) ;
404432 assertSignedMetaTx ( result ) ;
405433 expect ( result . functionName ) . toBe ( "revokeVoucher(uint256)" ) ;
406434 } ) ;
@@ -418,7 +446,10 @@ describe("meta-tx handler", () => {
418446 // ── signMetaTxCreateGroup ──────────────────────────────────────────────────
419447 describe ( "#signMetaTxCreateGroup()" , ( ) => {
420448 test ( "returns SignedMetaTx without returnTypedDataToSign" , async ( ) => {
421- const result = await signMetaTxCreateGroup ( { ...base ( ) , createGroupArgs } ) ;
449+ const result = await signMetaTxCreateGroup ( {
450+ ...base ( ) ,
451+ createGroupArgs
452+ } ) ;
422453 assertSignedMetaTx ( result ) ;
423454 expect ( result . functionName ) . toContain ( "createGroup" ) ;
424455 } ) ;
@@ -598,30 +629,55 @@ describe("meta-tx handler", () => {
598629
599630 // ── Exchange meta-tx functions (via makeExchangeMetaTxSigner) ──────────────
600631 describe . each ( [
601- [ "#signMetaTxCancelVoucher()" , signMetaTxCancelVoucher , "cancelVoucher(uint256)" ] ,
602- [ "#signMetaTxRedeemVoucher()" , signMetaTxRedeemVoucher , "redeemVoucher(uint256)" ] ,
603- [ "#signMetaTxCompleteExchange()" , signMetaTxCompleteExchange , "completeExchange(uint256)" ] ,
604- [ "#signMetaTxRetractDispute()" , signMetaTxRetractDispute , "retractDispute(uint256)" ] ,
605- [ "#signMetaTxEscalateDispute()" , signMetaTxEscalateDispute , "escalateDispute(uint256)" ] ,
606- [ "#signMetaTxRaiseDispute()" , signMetaTxRaiseDispute , "raiseDispute(uint256)" ]
607- ] as const ) (
608- "%s" ,
609- ( _name , fn , expectedFunctionName ) => {
610- test ( "returns SignedMetaTx without returnTypedDataToSign" , async ( ) => {
611- const result = await fn ( { ...base ( ) , exchangeId : "1" } ) ;
612- assertSignedMetaTx ( result ) ;
613- expect ( result . functionName ) . toBe ( expectedFunctionName ) ;
614- } ) ;
615-
616- test ( "returns StructuredData with returnTypedDataToSign: true" , async ( ) => {
617- const result = await fn ( { ...base ( ) , exchangeId : "1" , returnTypedDataToSign : true } ) ;
618- assertStructuredData ( result , "MetaTxExchange" ) ;
619- expect ( ( result as StructuredData ) . message ) . toMatchObject ( {
620- functionName : expectedFunctionName
621- } ) ;
632+ [
633+ "#signMetaTxCancelVoucher()" ,
634+ signMetaTxCancelVoucher ,
635+ "cancelVoucher(uint256)"
636+ ] ,
637+ [
638+ "#signMetaTxRedeemVoucher()" ,
639+ signMetaTxRedeemVoucher ,
640+ "redeemVoucher(uint256)"
641+ ] ,
642+ [
643+ "#signMetaTxCompleteExchange()" ,
644+ signMetaTxCompleteExchange ,
645+ "completeExchange(uint256)"
646+ ] ,
647+ [
648+ "#signMetaTxRetractDispute()" ,
649+ signMetaTxRetractDispute ,
650+ "retractDispute(uint256)"
651+ ] ,
652+ [
653+ "#signMetaTxEscalateDispute()" ,
654+ signMetaTxEscalateDispute ,
655+ "escalateDispute(uint256)"
656+ ] ,
657+ [
658+ "#signMetaTxRaiseDispute()" ,
659+ signMetaTxRaiseDispute ,
660+ "raiseDispute(uint256)"
661+ ]
662+ ] as const ) ( "%s" , ( _name , fn , expectedFunctionName ) => {
663+ test ( "returns SignedMetaTx without returnTypedDataToSign" , async ( ) => {
664+ const result = await fn ( { ...base ( ) , exchangeId : "1" } ) ;
665+ assertSignedMetaTx ( result ) ;
666+ expect ( result . functionName ) . toBe ( expectedFunctionName ) ;
667+ } ) ;
668+
669+ test ( "returns StructuredData with returnTypedDataToSign: true" , async ( ) => {
670+ const result = await fn ( {
671+ ...base ( ) ,
672+ exchangeId : "1" ,
673+ returnTypedDataToSign : true
674+ } ) ;
675+ assertStructuredData ( result , "MetaTxExchange" ) ;
676+ expect ( ( result as StructuredData ) . message ) . toMatchObject ( {
677+ functionName : expectedFunctionName
622678 } ) ;
623- }
624- ) ;
679+ } ) ;
680+ } ) ;
625681
626682 // ── signMetaTxResolveDispute ───────────────────────────────────────────────
627683 describe ( "#signMetaTxResolveDispute()" , ( ) => {
@@ -650,7 +706,11 @@ describe("meta-tx handler", () => {
650706 ...base ( ) ,
651707 exchangeId : 1 ,
652708 buyerPercent : 10 ,
653- counterpartySig : { r : counterpartySig . r , s : counterpartySig . s , v : counterpartySig . v }
709+ counterpartySig : {
710+ r : counterpartySig . r ,
711+ s : counterpartySig . s ,
712+ v : counterpartySig . v
713+ }
654714 } ) ;
655715 expect ( signedMetaTx . r ) . toEqual ( EXPECTED_R ) ;
656716 expect ( signedMetaTx . s ) . toEqual ( EXPECTED_S ) ;
@@ -705,7 +765,9 @@ describe("meta-tx handler", () => {
705765 tokenAmounts : [ "1000000000000000000" ]
706766 } ) ;
707767 assertSignedMetaTx ( result ) ;
708- expect ( result . functionName ) . toBe ( "withdrawFunds(uint256,address[],uint256[])" ) ;
768+ expect ( result . functionName ) . toBe (
769+ "withdrawFunds(uint256,address[],uint256[])"
770+ ) ;
709771 } ) ;
710772
711773 test ( "returns StructuredData with returnTypedDataToSign: true" , async ( ) => {
0 commit comments