File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ {
2+ "env" : {
3+ "node" : true ,
4+ "es2021" : true ,
5+ "jest" : true
6+ },
7+ "extends" : " eslint:recommended" ,
8+ "parserOptions" : {
9+ "ecmaVersion" : " latest" ,
10+ "sourceType" : " module"
11+ },
12+ "rules" : {
13+ "no-unused-vars" : [" warn" , { "argsIgnorePattern" : " ^_" }],
14+ "no-console" : " warn"
15+ }
16+ }
Original file line number Diff line number Diff line change 66 */
77
88const { Agent } = require ( '../models/agent' ) ;
9+ const logger = require ( '../utils/logger' ) ;
910
1011class A2AService {
1112 constructor ( walletService , db ) {
@@ -94,7 +95,7 @@ class A2AService {
9495 * @private
9596 */
9697 _handleError ( method , error ) {
97- console . error ( `A2AService.${ method } error:` , error ) ;
98+ logger . error ( `A2AService.${ method } error:` , error ) ;
9899 return error instanceof Error ? error : new Error ( error ) ;
99100 }
100101}
Original file line number Diff line number Diff line change 77
88const crypto = require ( 'crypto' ) ;
99const MandateService = require ( './mandate' ) ;
10+ const logger = require ( '../utils/logger' ) ;
1011
1112class AgentService {
1213 constructor ( database , config = { } ) {
@@ -184,7 +185,7 @@ class AgentService {
184185 * @private
185186 */
186187 _handleError ( method , error ) {
187- console . error ( `AgentService.${ method } error:` , error ) ;
188+ logger . error ( `AgentService.${ method } error:` , error ) ;
188189 return error instanceof Error ? error : new Error ( error ) ;
189190 }
190191}
Original file line number Diff line number Diff line change 88
99const jwt = require ( 'jsonwebtoken' ) ;
1010const crypto = require ( 'crypto' ) ;
11+ const logger = require ( '../utils/logger' ) ;
1112
1213class MandateService {
1314 constructor ( config = { } ) {
@@ -107,7 +108,10 @@ class MandateService {
107108 sub : agentDid ,
108109 nbf : Math . floor ( Date . now ( ) / 1000 ) ,
109110 vc : {
110- '@context' : [ 'https://www.w3.org/2018/credentials/v1' ] ,
111+ '@context' : [
112+ 'https://www.w3.org/2018/credentials/v1' ,
113+ 'https://open-commerce-protocol.io/contexts/agent/v1'
114+ ] ,
111115 type : [ 'VerifiableCredential' , 'AgentAuthorityCredential' ] ,
112116 credentialSubject : {
113117 id : agentDid ,
@@ -119,6 +123,15 @@ class MandateService {
119123
120124 return jwt . sign ( payload , this . signingKey , { algorithm : 'HS256' } ) ;
121125 }
126+
127+ /**
128+ * Handle and format errors
129+ * @private
130+ */
131+ _handleError ( method , error ) {
132+ logger . error ( `MandateService.${ method } error:` , error ) ;
133+ return error instanceof Error ? error : new Error ( error ) ;
134+ }
122135}
123136
124137module . exports = MandateService ;
Original file line number Diff line number Diff line change 77
88const TokenizationService = require ( './tokenization' ) ;
99const crypto = require ( 'crypto' ) ;
10+ const logger = require ( '../utils/logger' ) ;
1011
1112class MobilePaymentService {
1213 constructor ( tokenizationService , walletService , config = { } ) {
@@ -403,7 +404,7 @@ class MobilePaymentService {
403404 * @private
404405 */
405406 _handleError ( method , error ) {
406- console . error ( `MobilePaymentService.${ method } error:` , error ) ;
407+ logger . error ( `MobilePaymentService.${ method } error:` , error ) ;
407408 return error instanceof Error ? error : new Error ( error ) ;
408409 }
409410}
Original file line number Diff line number Diff line change 88const axios = require ( 'axios' ) ;
99const crypto = require ( 'crypto' ) ;
1010const MandateService = require ( './mandate' ) ;
11+ const logger = require ( '../utils/logger' ) ;
1112
1213class TokenizationService {
1314 constructor ( config = { } ) {
@@ -387,6 +388,8 @@ class TokenizationService {
387388 * @private
388389 */
389390 _handleError ( error ) {
391+ logger . error ( 'TokenizationService error:' , error ) ;
392+
390393 if ( error . response ) {
391394 const { status, data } = error . response ;
392395 return new Error (
Original file line number Diff line number Diff line change 77 */
88
99const Joi = require ( 'joi' ) ;
10+ const logger = require ( '../utils/logger' ) ;
1011
1112class UCPService {
1213 constructor ( a2aService , config = { } ) {
@@ -123,7 +124,7 @@ class UCPService {
123124 * @private
124125 */
125126 _handleError ( method , error ) {
126- console . error ( `UCPService.${ method } error:` , error ) ;
127+ logger . error ( `UCPService.${ method } error:` , error ) ;
127128 return error instanceof Error ? error : new Error ( error ) ;
128129 }
129130}
Original file line number Diff line number Diff line change 66 */
77
88const crypto = require ( 'crypto' ) ;
9+ const logger = require ( '../utils/logger' ) ;
910
1011class WalletService {
1112 constructor ( database , config = { } ) {
@@ -402,12 +403,12 @@ class WalletService {
402403 try {
403404 // This would integrate with a stored payment method
404405 // For now, just log the event
405- console . log ( `Auto top-up triggered for wallet ${ walletId } . Current balance: ${ currentBalance } ` ) ;
406+ logger . info ( `Auto top-up triggered for wallet ${ walletId } . Current balance: ${ currentBalance } ` ) ;
406407
407408 // You would implement actual top-up logic here
408409 // Example: await this.addFunds({ walletId, amount: this.config.autoTopUp.amount, ... });
409410 } catch ( error ) {
410- console . error ( 'Auto top-up failed:' , error ) ;
411+ logger . error ( 'Auto top-up failed:' , error ) ;
411412 }
412413 }
413414
@@ -424,7 +425,7 @@ class WalletService {
424425 * @private
425426 */
426427 _handleError ( method , error ) {
427- console . error ( `WalletService.${ method } error:` , error ) ;
428+ logger . error ( `WalletService.${ method } error:` , error ) ;
428429 return error instanceof Error ? error : new Error ( error ) ;
429430 }
430431}
Original file line number Diff line number Diff line change 66 */
77
88const crypto = require ( 'crypto' ) ;
9+ const logger = require ( '../utils/logger' ) ;
910
1011class Web3Service {
1112 constructor ( tokenizationService ) {
@@ -113,9 +114,9 @@ class Web3Service {
113114 } ;
114115
115116 const tokenAddress = tokenAddresses [ stablecoin ] ;
116- if ( ! tokenAddress ) throw new Error ( `Unsupported stablecoin: ${ stablecoin } ` ) ;
117+ if ( ! tokenAddress ) throw new Error ( `Zero Trust Validation Failed: Unsupported stablecoin: ${ stablecoin } ` ) ;
117118
118- console . log ( `x402: Executing ${ stablecoin } settlement for ${ amount } to ${ to } ...` ) ;
119+ logger . info ( `x402: Executing ${ stablecoin } settlement for ${ amount } to ${ to } ...` ) ;
119120
120121 // 1. Construct ERC20 transfer data (Simplified)
121122 const txData = {
@@ -152,7 +153,7 @@ class Web3Service {
152153 * @private
153154 */
154155 _handleError ( method , error ) {
155- console . error ( `Web3Service.${ method } error:` , error ) ;
156+ logger . error ( `Web3Service.${ method } error:` , error ) ;
156157 return error instanceof Error ? error : new Error ( error ) ;
157158 }
158159}
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ const logFormat = winston.format.combine(
1919const logger = winston . createLogger ( {
2020 level : config . logging . level ,
2121 format : logFormat ,
22- defaultMeta : { service : 'open-wallet ' } ,
22+ defaultMeta : { service : 'ocp-sdk ' } ,
2323 transports : [ ]
2424} ) ;
2525
You can’t perform that action at this time.
0 commit comments