11import type { MultiProvider } from "@hyperlane-xyz/sdk" ;
22import type { Result } from "@hyperlane-xyz/utils" ;
3+ import {
4+ type GenericAllowBlockLists ,
5+ isAllowedIntent ,
6+ } from "../config/index.js" ;
37import type { Logger } from "../logger.js" ;
48
59type Metadata = {
@@ -8,6 +12,11 @@ type Metadata = {
812
913type ParsedArgs = {
1014 orderId : string ;
15+ senderAddress : string ;
16+ recipients : Array < {
17+ destinationChainName : string ;
18+ recipientAddress : string ;
19+ } > ;
1120} ;
1221
1322export abstract class BaseFiller <
@@ -17,6 +26,7 @@ export abstract class BaseFiller<
1726> {
1827 protected constructor (
1928 readonly multiProvider : MultiProvider ,
29+ readonly allowBlockLists : GenericAllowBlockLists ,
2030 readonly metadata : TMetadata ,
2131 readonly log : Logger ,
2232 ) { }
@@ -57,9 +67,26 @@ export abstract class BaseFiller<
5767 parsedArgs : TParsedArgs ,
5868 ) : Promise < Array < string > > ;
5969
60- protected abstract prepareIntent (
70+ protected async prepareIntent (
6171 parsedArgs : TParsedArgs ,
62- ) : Promise < Result < TIntentData > > ;
72+ ) : Promise < Result < TIntentData > > {
73+ this . log . info ( {
74+ msg : "Evaluating filling Intent" ,
75+ intent : `${ this . metadata . protocolName } -${ parsedArgs . orderId } ` ,
76+ } ) ;
77+
78+ const { senderAddress, recipients } = parsedArgs ;
79+
80+ if ( ! this . isAllowedIntent ( { senderAddress, recipients } ) ) {
81+ return {
82+ error : "Not allowed intent" ,
83+ success : false ,
84+ } ;
85+ }
86+
87+ return { error : "Not implemented" , success : false } ;
88+ }
89+
6390
6491 protected abstract fill (
6592 parsedArgs : TParsedArgs ,
@@ -70,4 +97,23 @@ export abstract class BaseFiller<
7097 protected async settleOrder ( parsedArgs : TParsedArgs , data : TIntentData ) {
7198 return ;
7299 }
100+
101+ protected isAllowedIntent ( {
102+ senderAddress,
103+ recipients,
104+ } : {
105+ senderAddress : string ;
106+ recipients : Array < {
107+ destinationChainName : string ;
108+ recipientAddress : string ;
109+ } > ;
110+ } ) {
111+ return recipients . every ( ( { destinationChainName, recipientAddress } ) =>
112+ isAllowedIntent ( this . allowBlockLists , {
113+ senderAddress,
114+ destinationDomain : destinationChainName ,
115+ recipientAddress,
116+ } ) ,
117+ ) ;
118+ }
73119}
0 commit comments