11import AcpClient , { AcpContractClientV2 } from "@virtuals-protocol/acp-node" ;
22import * as dotenv from "dotenv" ;
3- import { Address } from "viem " ;
3+ import { BUYER_AGENT_WALLET_ADDRESS , BUYER_ENTITY_ID , WHITELISTED_WALLET_PRIVATE_KEY } from "./env " ;
44
55// Load environment variables
66dotenv . config ( { override : true } ) ;
77
8+ function subsection ( title : string ) {
9+ console . log ( `\n--- ${ title } ---` ) ;
10+ }
11+
812async function testHelperFunctions ( ) {
9- console . log ( "Testing ACP helper functions..." ) ;
13+ console . log ( `\n${ "=" . repeat ( 60 ) } ` ) ;
14+ console . log ( "🔹 ACP Helper Functions Test" ) ;
15+ console . log ( `${ "=" . repeat ( 60 ) } \n` ) ;
1016
11- // Initialize AcpClient
17+ console . log ( "Initializing ACP client...\n" ) ;
1218 const acpClient = new AcpClient ( {
1319 acpContractClient : await AcpContractClientV2 . build (
14- process . env . WHITELISTED_WALLET_PRIVATE_KEY as `0x${ string } ` ,
15- Number ( process . env . WHITELISTED_WALLET_ENTITY_ID ) ,
16- process . env . BUYER_AGENT_WALLET_ADDRESS as Address
20+ WHITELISTED_WALLET_PRIVATE_KEY ,
21+ BUYER_ENTITY_ID ,
22+ BUYER_AGENT_WALLET_ADDRESS ,
1723 )
1824 } ) ;
1925
20- // Get active jobs
21- const activeJobs = await acpClient . getActiveJobs ( 1 , 10 ) ;
26+ /* ---------------- ACTIVE JOBS ---------------- */
27+ subsection ( "Active Jobs" ) ;
28+ const activeJobs = await acpClient . getActiveJobs ( 1 , 3 ) ;
2229 console . log ( "\n🔵 Active Jobs:" ) ;
2330 console . log ( activeJobs . length > 0 ? activeJobs : "No active jobs found." ) ;
2431
25- // Get completed jobs
26- const completedJobs = await acpClient . getCompletedJobs ( 1 , 10 ) ;
32+ /* ---------------- COMPLETED JOBS ---------------- */
33+ const completedJobs = await acpClient . getCompletedJobs ( 1 , 3 ) ;
2734 console . log ( "\n✅ Completed Jobs:" ) ;
28- console . log ( completedJobs . length > 0 ? completedJobs : "No completed jobs found." ) ;
29-
30- // Get cancelled jobs
31- const cancelledJobs = await acpClient . getCancelledJobs ( 1 , 10 ) ;
32- console . log ( "\n❌ Cancelled Jobs:" ) ;
33- console . log ( cancelledJobs . length > 0 ? cancelledJobs : "No cancelled jobs found." ) ;
34-
3535 if ( completedJobs . length > 0 ) {
36+ console . log ( completedJobs ) ;
37+
3638 const onChainJobId = completedJobs [ 0 ] . id ;
3739 if ( onChainJobId ) {
3840 const job = await acpClient . getJobById ( onChainJobId ) ;
@@ -50,26 +52,31 @@ async function testHelperFunctions() {
5052 }
5153 }
5254 } else {
53- console . log ( "\n⚠️ No completed jobs available for detailed inspection ." ) ;
55+ console . log ( "No completed jobs found ." ) ;
5456 }
5557
56- // Get jobs with pending memos
57- const jobsWithPendingMemos = await acpClient . getPendingMemoJobs ( ) ;
58+ /* ---------------- CANCELLED JOBS ---------------- */
59+ const cancelledJobs = await acpClient . getCancelledJobs ( 1 , 3 ) ;
60+ console . log ( "\n❌ Cancelled Jobs:" ) ;
61+ console . log ( cancelledJobs . length > 0 ? cancelledJobs : "No cancelled jobs found." ) ;
62+
63+ /* ---------------- PENDING MEMO JOBS ---------------- */
64+ const jobsWithPendingMemos = await acpClient . getPendingMemoJobs ( 1 , 3 ) ;
5865 console . log ( jobsWithPendingMemos . length > 0 ? jobsWithPendingMemos : "No jobs with pending memos jobs found." ) ;
5966
60- // Get agent
67+ /* ---------------- AGENT INFO ---------------- */
6168 const agentWalletAddress = acpClient . walletAddress ;
6269 const agent = await acpClient . getAgent ( agentWalletAddress ) ;
6370 console . log ( agent ? agent : `No agent with wallet address ${ jobsWithPendingMemos } found.` ) ;
6471}
6572
66- // Run the test
6773testHelperFunctions ( )
6874 . then ( ( ) => {
6975 console . log ( "\n✨ Test completed successfully" ) ;
7076 process . exit ( 0 ) ;
7177 } )
72- . catch ( error => {
73- console . error ( "Error in helper functions test:" , error ) ;
78+ . catch ( ( error ) => {
79+ console . error ( "\n❌ Error in helper functions test:" ) ;
80+ console . error ( error ) ;
7481 process . exit ( 1 ) ;
7582 } ) ;
0 commit comments