@flashbacktech/flashbackclient 0.1.54 → 0.1.55
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.
|
@@ -279,9 +279,14 @@ const sendTransaction = async (context, signedTransactionXDR, bDebug = false) =>
|
|
|
279
279
|
console.log('sendTransaction: getResponse keys:', Object.keys(getResponse));
|
|
280
280
|
console.log('sendTransaction: getResponse.resultMetaXdr exists:', !!getResponse.resultMetaXdr);
|
|
281
281
|
console.log('sendTransaction: getResponse.resultMetaXdr type:', typeof getResponse.resultMetaXdr);
|
|
282
|
-
//
|
|
282
|
+
// In SDK v14, returnValue might be directly available
|
|
283
|
+
if ('returnValue' in getResponse && getResponse.returnValue) {
|
|
284
|
+
console.log('sendTransaction: Found returnValue directly in response:', getResponse.returnValue);
|
|
285
|
+
return getResponse.returnValue;
|
|
286
|
+
}
|
|
287
|
+
// Make sure the transaction's resultMetaXdr is not empty
|
|
283
288
|
if (!getResponse.resultMetaXdr) {
|
|
284
|
-
console.error('sendTransaction: Empty
|
|
289
|
+
console.error('sendTransaction: Empty resultMetaXdr in getTransaction response');
|
|
285
290
|
console.error('sendTransaction: This might indicate a network response format change');
|
|
286
291
|
console.error('sendTransaction: Available fields:', Object.keys(getResponse));
|
|
287
292
|
// Try alternative response formats that might have been introduced
|
|
@@ -289,29 +294,59 @@ const sendTransaction = async (context, signedTransactionXDR, bDebug = false) =>
|
|
|
289
294
|
console.log('sendTransaction: Found result field:', getResponse.result);
|
|
290
295
|
return getResponse.result;
|
|
291
296
|
}
|
|
292
|
-
if ('returnValue' in getResponse && getResponse.returnValue) {
|
|
293
|
-
console.log('sendTransaction: Found returnValue field:', getResponse.returnValue);
|
|
294
|
-
return getResponse.returnValue;
|
|
295
|
-
}
|
|
296
297
|
// If we still can't find the return value, return the full response instead of throwing
|
|
297
298
|
console.log('sendTransaction: No return value found, returning full response');
|
|
298
299
|
return getResponse;
|
|
299
300
|
}
|
|
300
|
-
//
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
301
|
+
// Try to parse the resultMetaXdr if it exists
|
|
302
|
+
try {
|
|
303
|
+
const transactionMeta = getResponse.resultMetaXdr;
|
|
304
|
+
console.log('sendTransaction: transactionMeta type:', typeof transactionMeta);
|
|
305
|
+
console.log('sendTransaction: transactionMeta keys:', Object.keys(transactionMeta));
|
|
306
|
+
// Try different approaches to extract the return value
|
|
307
|
+
let returnValue = null;
|
|
308
|
+
// Try the old v3 approach
|
|
309
|
+
if (transactionMeta.v3 && typeof transactionMeta.v3 === 'function') {
|
|
310
|
+
try {
|
|
311
|
+
const sorobanMeta = transactionMeta.v3().sorobanMeta();
|
|
312
|
+
if (sorobanMeta) {
|
|
313
|
+
returnValue = sorobanMeta.returnValue();
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
catch (v3Error) {
|
|
317
|
+
console.log('sendTransaction: v3 approach failed, trying alternatives...');
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
// Try direct property access
|
|
321
|
+
if (!returnValue && 'returnValue' in transactionMeta && transactionMeta.returnValue) {
|
|
322
|
+
returnValue = transactionMeta.returnValue;
|
|
323
|
+
}
|
|
324
|
+
// Try nested access
|
|
325
|
+
if (!returnValue && '_value' in transactionMeta && transactionMeta._value &&
|
|
326
|
+
typeof transactionMeta._value === 'object' && 'returnValue' in transactionMeta._value) {
|
|
327
|
+
returnValue = transactionMeta._value.returnValue;
|
|
328
|
+
}
|
|
329
|
+
if (returnValue) {
|
|
330
|
+
console.log('sendTransaction: returnValue extracted:', returnValue);
|
|
331
|
+
return (0, stellar_sdk_1.scValToNative)(returnValue);
|
|
332
|
+
}
|
|
333
|
+
console.log('sendTransaction: No return value found in metadata, returning full response');
|
|
334
|
+
return getResponse;
|
|
335
|
+
}
|
|
336
|
+
catch (metaError) {
|
|
337
|
+
console.error('sendTransaction: Error parsing resultMetaXdr:', metaError);
|
|
338
|
+
console.log('sendTransaction: Returning full response due to metadata parsing error');
|
|
339
|
+
return getResponse;
|
|
309
340
|
}
|
|
310
|
-
|
|
311
|
-
|
|
341
|
+
}
|
|
342
|
+
else if (String(getResponse.status).includes("NOT_FOUND")) {
|
|
343
|
+
console.log('sendTransaction: Transaction not found yet, continuing to poll...');
|
|
344
|
+
// Wait one second before the next poll
|
|
345
|
+
await (0, timing_1.sleep)(1000);
|
|
312
346
|
}
|
|
313
347
|
else {
|
|
314
|
-
console.error('sendTransaction: Transaction failed:', getResponse.
|
|
348
|
+
console.error('sendTransaction: Transaction failed with unexpected status:', getResponse.status);
|
|
349
|
+
console.error('sendTransaction: Error result:', getResponse.resultXdr);
|
|
315
350
|
throw new Error(`Transaction failed: ${getResponse.resultXdr}`);
|
|
316
351
|
}
|
|
317
352
|
}
|