@funkit/fun-relay 2.2.0-next.3 → 2.2.0-next.5

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.
package/dist/index.mjs CHANGED
@@ -195,7 +195,7 @@ function getTxHash({
195
195
  };
196
196
  logger.info(`${logPrefix}:started`, logProps);
197
197
  const getTxHashFromTxHashes = () => {
198
- const rawTxHashWithUnreliableTyping = txHashes[0].txHash;
198
+ const rawTxHashWithUnreliableTyping = txHashes[0]?.txHash;
199
199
  const txHash = typeof rawTxHashWithUnreliableTyping === "object" ? rawTxHashWithUnreliableTyping.id : rawTxHashWithUnreliableTyping;
200
200
  logger.info(`${logPrefix}:txHashesMode`, {
201
201
  ...logProps,
@@ -330,12 +330,14 @@ async function executeRelayQuote({
330
330
  ) {
331
331
  logger.info(`${logPrefix}:onTransactionConfirmed`, txHashes);
332
332
  isTransactionConfirmed = true;
333
- if (relayQuote.steps[0].requestId) {
333
+ const firstStep = relayQuote.steps[0];
334
+ const firstItem = firstStep?.items[0];
335
+ if (firstStep?.requestId && firstItem) {
334
336
  manuallyRegisterIndex(logger, {
335
- requestId: relayQuote.steps[0].requestId,
336
- chainId: relayQuote.steps[0].items[0].data.chainId,
337
+ requestId: firstStep.requestId,
338
+ chainId: firstItem.data.chainId,
337
339
  tx: jsonStringifyWithBigIntSanitization({
338
- ...relayQuote.steps[0].items[0].data,
340
+ ...firstItem.data,
339
341
  txHash
340
342
  })
341
343
  });
@@ -576,9 +578,9 @@ function getReferrer(clientId) {
576
578
  return clientId ? `${FUN_RELAY_REFERRER}|${clientId}` : FUN_RELAY_REFERRER;
577
579
  }
578
580
  var RelayQuoteClientError = class extends Error {
579
- constructor(statusCode, relayErrorCode, message) {
581
+ constructor(statusCode, relayErrorCode, message, requestId = "") {
580
582
  super(
581
- `An error occurred trying to generate a relay quote: ${relayErrorCode} - ${message}`
583
+ `An error occurred trying to generate a relay quote: ${relayErrorCode} - ReqId ${requestId || "NO_REQ_ID"} - ${message}`
582
584
  );
583
585
  this.statusCode = statusCode;
584
586
  this.relayErrorCode = relayErrorCode;
@@ -770,7 +772,8 @@ async function getRelayQuote({
770
772
  throw new RelayQuoteClientError(
771
773
  apiError.statusCode,
772
774
  rawError.errorCode,
773
- rawError.message ?? apiError.message
775
+ rawError.message ?? apiError.message,
776
+ rawError.requestId
774
777
  );
775
778
  }
776
779
  }