noah-clarity 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/contract.js +49 -1
  2. package/package.json +1 -1
package/dist/contract.js CHANGED
@@ -29,6 +29,9 @@ class KYCContract {
29
29
  */
30
30
  async registerKYC(params, privateKey) {
31
31
  const senderAddress = (0, transactions_1.getAddressFromPrivateKey)(privateKey, this.network.version);
32
+ // #region agent log
33
+ fetch('http://127.0.0.1:7249/ingest/b239a7fb-669e-478f-b888-bd46beaadedf', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ location: 'contract.ts:50', 'message': 'registerKYC entry', 'data': { senderAddress, network: this.network.coreApiUrl, attesterId: params.attesterId, commitmentLength: params.commitment.length, signatureLength: params.signature.length }, timestamp: Date.now(), sessionId: 'debug-session', runId: 'run1', hypothesisId: 'A' }) }).catch(() => { });
34
+ // #endregion agent log
32
35
  const { address, name } = this.parseContractAddress(this.config.kycRegistryAddress);
33
36
  // Ensure commitment is exactly 32 bytes (64 hex chars)
34
37
  const commitmentHex = params.commitment.replace('0x', '');
@@ -58,12 +61,41 @@ class KYCContract {
58
61
  anchorMode: transactions_1.AnchorMode.Any,
59
62
  postConditionMode: transactions_1.PostConditionMode.Allow,
60
63
  };
64
+ // #region agent log
65
+ fetch('http://127.0.0.1:7249/ingest/b239a7fb-669e-478f-b888-bd46beaadedf', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ location: 'contract.ts:74', 'message': 'Transaction options before makeContractCall', 'data': { contractAddress: address, contractName: name, functionName: 'register-kyc', fee: txOptions.fee, anchorMode: txOptions.anchorMode, postConditionMode: txOptions.postConditionMode, networkUrl: this.network.coreApiUrl }, timestamp: Date.now(), sessionId: 'debug-session', runId: 'run1', hypothesisId: 'B' }) }).catch(() => { });
66
+ // #endregion agent log
61
67
  try {
62
68
  const transaction = await (0, transactions_1.makeContractCall)(txOptions);
69
+ // #region agent log
70
+ const serializedTx = transaction.serialize();
71
+ const txData = {
72
+ txId: transaction.txid(),
73
+ nonce: transaction.auth?.spendingCondition?.nonce,
74
+ serializedTxLength: serializedTx.byteLength,
75
+ };
76
+ fetch('http://127.0.0.1:7249/ingest/b239a7fb-669e-478f-b888-bd46beaadedf', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ location: 'contract.ts:87', 'message': 'Transaction created, before broadcast', 'data': txData, timestamp: Date.now(), sessionId: 'debug-session', runId: 'run1', hypothesisId: 'A' }) }).catch(() => { });
77
+ // #endregion agent log
63
78
  const broadcastResponse = await (0, transactions_1.broadcastTransaction)(transaction, this.network);
64
79
  return broadcastResponse.txid;
65
80
  }
66
81
  catch (error) {
82
+ // #region agent log
83
+ const errorKeys = error ? Object.keys(error) : [];
84
+ const errorStructure = {
85
+ hasError: !!error,
86
+ hasResponse: !!error?.response,
87
+ hasData: !!error?.data,
88
+ hasStatus: !!error?.status,
89
+ hasStatusText: !!error?.statusText,
90
+ hasReason: !!error?.reason,
91
+ hasMessage: !!error?.message,
92
+ errorKeys: errorKeys,
93
+ errorType: error?.constructor?.name,
94
+ status: error?.status,
95
+ statusText: error?.statusText,
96
+ };
97
+ fetch('http://127.0.0.1:7249/ingest/b239a7fb-669e-478f-b888-bd46beaadedf', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ location: 'contract.ts:91', 'message': 'Error object structure', 'data': errorStructure, timestamp: Date.now(), sessionId: 'debug-session', runId: 'run1', hypothesisId: 'C' }) }).catch(() => { });
98
+ // #endregion agent log
67
99
  // Capture detailed error information
68
100
  let errorMessage = 'Transaction failed';
69
101
  let errorDetails = {};
@@ -100,10 +132,26 @@ class KYCContract {
100
132
  errorDetails.status = error.status;
101
133
  if (error?.statusText)
102
134
  errorDetails.statusText = error.statusText;
135
+ // #region agent log
136
+ fetch('http://127.0.0.1:7249/ingest/b239a7fb-669e-478f-b888-bd46beaadedf', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ location: 'contract.ts:120', 'message': 'Error details captured', 'data': errorDetails, timestamp: Date.now(), sessionId: 'debug-session', runId: 'run1', hypothesisId: 'C' }) }).catch(() => { });
137
+ // #endregion agent log
138
+ // Try to extract response body if it exists
139
+ let responseBody = null;
140
+ if (error?.response?.data) {
141
+ responseBody = error.response.data;
142
+ }
143
+ else if (error?.data) {
144
+ responseBody = error.data;
145
+ }
146
+ // #region agent log
147
+ if (responseBody) {
148
+ fetch('http://127.0.0.1:7249/ingest/b239a7fb-669e-478f-b888-bd46beaadedf', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ location: 'contract.ts:135', 'message': 'API response body', 'data': { responseBody: typeof responseBody === 'string' ? responseBody : JSON.stringify(responseBody) }, timestamp: Date.now(), sessionId: 'debug-session', runId: 'run1', hypothesisId: 'C' }) }).catch(() => { });
149
+ }
150
+ // #endregion agent log
103
151
  // Log the full error for debugging
104
152
  console.error('Transaction broadcast error:', errorDetails);
105
153
  // Provide detailed error message
106
- const detailedMessage = errorDetails.response || errorDetails.reason || errorDetails.apiError || errorDetails.data || errorMessage;
154
+ const detailedMessage = responseBody || errorDetails.response || errorDetails.reason || errorDetails.apiError || errorDetails.data || errorMessage;
107
155
  throw new Error(`Transaction failed: ${detailedMessage}`);
108
156
  }
109
157
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "noah-clarity",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "TypeScript SDK for Noah-v2 KYC system on Stacks",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",