@@ -30,6 +30,8 @@ import {
3030import { AcpX402 } from "../acpX402" ;
3131import { base , baseSepolia } from "viem/chains" ;
3232import MEMO_MANAGER_ABI from "../abis/memoManagerAbi" ;
33+ import { Attribution } from "ox/erc8021" ;
34+ import { appendBuilderCodeData } from "../utils" ;
3335
3436class AcpContractClientV2 extends BaseAcpContractClient {
3537 private RETRY_CONFIG = {
@@ -47,7 +49,8 @@ class AcpContractClientV2 extends BaseAcpContractClient {
4749 private memoManagerAddress : Address ,
4850 private accountManagerAddress : Address ,
4951 agentWalletAddress : Address ,
50- config : AcpContractConfig = baseAcpConfigV2
52+ config : AcpContractConfig = baseAcpConfigV2 ,
53+ private builderCode ?: string
5154 ) {
5255 super ( agentWalletAddress , config ) ;
5356 }
@@ -56,7 +59,8 @@ class AcpContractClientV2 extends BaseAcpContractClient {
5659 walletPrivateKey : Address ,
5760 sessionEntityKeyId : number ,
5861 agentWalletAddress : Address ,
59- config : AcpContractConfig = baseAcpConfigV2
62+ config : AcpContractConfig = baseAcpConfigV2 ,
63+ builderCode ?: string
6064 ) {
6165 const publicClients : Record <
6266 number ,
@@ -106,7 +110,8 @@ class AcpContractClientV2 extends BaseAcpContractClient {
106110 memoManagerAddress . result as Address ,
107111 accountManagerAddress . result as Address ,
108112 agentWalletAddress ,
109- config
113+ config ,
114+ builderCode
110115 ) ;
111116
112117 acpContractClient . publicClients = publicClients ;
@@ -221,10 +226,16 @@ class AcpContractClientV2 extends BaseAcpContractClient {
221226 throw new AcpError ( "Session key client not initialized" ) ;
222227 }
223228
229+ const dataSuffix = this . builderCode
230+ ? Attribution . toDataSuffix ( { codes : [ this . builderCode ] } )
231+ : undefined ;
232+
224233 const basePayload : any = {
225234 uo : operations . map ( ( operation ) => ( {
226235 target : operation . contractAddress ,
227- data : operation . data ,
236+ data : dataSuffix
237+ ? appendBuilderCodeData ( operation . data , dataSuffix as Hex )
238+ : operation . data ,
228239 value : operation . value ,
229240 } ) ) ,
230241 } ;
0 commit comments