File tree Expand file tree Collapse file tree 4 files changed +28
-18
lines changed
typescript/solver/solvers/compactX Expand file tree Collapse file tree 4 files changed +28
-18
lines changed Original file line number Diff line number Diff line change @@ -150,6 +150,9 @@ const metadata: CompactXMetadata = {
150150 {
151151 name : "validateArbiterAndTribunal" ,
152152 } ,
153+ {
154+ name : "verifyNonce" ,
155+ } ,
153156 ] ,
154157 } ,
155158} ;
Original file line number Diff line number Diff line change @@ -70,24 +70,6 @@ export class CompactXFiller extends BaseFiller<
7070 intent : `${ this . metadata . protocolName } -${ request . compact . id } ` ,
7171 } ) ;
7272
73- const chainId = + request . chainId ;
74-
75- // Check if nonce has already been consumed
76- const theCompactService = new TheCompactService (
77- this . multiProvider ,
78- this . log ,
79- ) ;
80-
81- const nonceConsumed = await theCompactService . hasConsumedAllocatorNonce (
82- chainId ,
83- BigInt ( request . compact . nonce ) ,
84- request . compact . arbiter ,
85- ) ;
86-
87- if ( nonceConsumed ) {
88- throw new Error ( "Nonce has already been consumed" ) ;
89- }
90-
9173 // Process the broadcast transaction
9274 const mandateChainId = request . compact . mandate . chainId ;
9375
Original file line number Diff line number Diff line change 11export { checkExpirations } from "./checkExpirations.js" ;
22export { validateArbiterAndTribunal } from "./validateArbiterAndTribunal.js" ;
33export { validateChainsAndTokens } from "./validateChainsAndTokens.js" ;
4+ export { verifyNonce } from "./verifyNonce.js" ;
45export { verifySignatures } from "./verifySignatures.js" ;
Original file line number Diff line number Diff line change 1+ import type { CompactXRule } from "../filler.js" ;
2+ import { TheCompactService } from "../services/TheCompactService.js" ;
3+ import { log } from "../utils.js" ;
4+
5+ export function verifyNonce ( ) : CompactXRule {
6+ return async ( parsedArgs , context ) => {
7+ const theCompactService = new TheCompactService ( context . multiProvider , log ) ;
8+
9+ const nonceConsumed = await theCompactService . hasConsumedAllocatorNonce (
10+ + parsedArgs . context . chainId ,
11+ BigInt ( parsedArgs . context . compact . nonce ) ,
12+ parsedArgs . context . compact . arbiter ,
13+ ) ;
14+
15+ if ( nonceConsumed ) {
16+ return {
17+ error : "Nonce has already been consumed" ,
18+ success : false ,
19+ } ;
20+ }
21+
22+ return { data : "Signatures are Ok" , success : true } ;
23+ } ;
24+ }
You can’t perform that action at this time.
0 commit comments