@trustware/sdk-staging 1.1.12-staging.1 → 1.1.12-staging.2

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/widget.mjs CHANGED
@@ -571,7 +571,7 @@ var init_constants = __esm({
571
571
  "src/constants.ts"() {
572
572
  "use strict";
573
573
  SDK_NAME = "@trustware/sdk";
574
- SDK_VERSION = "1.1.12-staging.1";
574
+ SDK_VERSION = "1.1.12-staging.2";
575
575
  API_ROOT = "https://bv-staging-api.trustware.io";
576
576
  GTM_ID = "GTM-TZDGNCXB";
577
577
  API_PREFIX = "/api";
@@ -31664,7 +31664,18 @@ async function sendRouteAsUserOperation(params) {
31664
31664
  );
31665
31665
  }
31666
31666
  console.debug("[send] UserOp included", { userOpHash, txHash });
31667
- await submitReceipt(intentId, txHash, getSponsorshipRequestId(), eoaAddress);
31667
+ try {
31668
+ void submitReceipt(
31669
+ intentId,
31670
+ txHash,
31671
+ getSponsorshipRequestId(),
31672
+ eoaAddress
31673
+ ).catch((err) => {
31674
+ console.debug("[send] receipt submission failed (non-fatal)", err);
31675
+ });
31676
+ } catch (err) {
31677
+ console.debug("[send] receipt submission failed (non-fatal)", err);
31678
+ }
31668
31679
  return { userOpHash, txHash, intentId };
31669
31680
  }
31670
31681
  var NATIVE_ADDRS;
@@ -33886,10 +33897,6 @@ function useSwapExecution(fromChain) {
33886
33897
  numericChainId,
33887
33898
  { approvalsEnsured: ownsApprovals }
33888
33899
  );
33889
- try {
33890
- await submitReceipt(routeResult.intentId, hash);
33891
- } catch {
33892
- }
33893
33900
  setState((p) => ({
33894
33901
  ...p,
33895
33902
  isSubmitting: false,
@@ -33898,6 +33905,8 @@ function useSwapExecution(fromChain) {
33898
33905
  txStatus: "processing"
33899
33906
  }));
33900
33907
  startPolling(routeResult.intentId, onSuccess, onError);
33908
+ void submitReceipt(routeResult.intentId, hash).catch(() => {
33909
+ });
33901
33910
  } catch (err) {
33902
33911
  const msg = mapTxError(err);
33903
33912
  setState((p) => ({
@@ -36340,6 +36349,7 @@ function SwapMode({
36340
36349
  }, [route.loading]);
36341
36350
  useEffect34(() => {
36342
36351
  if (!route.data) return;
36352
+ if (stage !== "home" && stage !== "review") return;
36343
36353
  const id = setInterval(() => {
36344
36354
  const ts = quoteTimestampRef.current;
36345
36355
  if (ts === null) return;
@@ -36351,7 +36361,11 @@ function SwapMode({
36351
36361
  }
36352
36362
  }, 1e3);
36353
36363
  return () => clearInterval(id);
36354
- }, [route.data]);
36364
+ }, [route.data, stage]);
36365
+ const handleRetryQuote = useCallback22(() => {
36366
+ if (!latestFetchParamsRef.current) return;
36367
+ void fetchRef.current(latestFetchParamsRef.current);
36368
+ }, []);
36355
36369
  useEffect34(() => {
36356
36370
  if (stage !== "review") return;
36357
36371
  if (!route.data || !walletAddress) return;
@@ -37880,6 +37894,10 @@ function SwapMode({
37880
37894
  txStatus: execution.txStatus,
37881
37895
  isSubmitting: execution.isSubmitting,
37882
37896
  isGasSponsored,
37897
+ hasQuote: !!route.data,
37898
+ isQuoteRefreshing: route.loading,
37899
+ quoteError: route.error,
37900
+ onRetryQuote: handleRetryQuote,
37883
37901
  onExecute: () => void handleExecute()
37884
37902
  }
37885
37903
  )
@@ -39216,10 +39234,15 @@ function SwapActionArea({
39216
39234
  txStatus,
39217
39235
  isSubmitting,
39218
39236
  isGasSponsored,
39237
+ hasQuote,
39238
+ isQuoteRefreshing,
39239
+ quoteError,
39240
+ onRetryQuote,
39219
39241
  onExecute
39220
39242
  }) {
39221
39243
  const needsApproval = allowanceStatus === "needed" && !isGasSponsored;
39222
39244
  const isChecking = allowanceStatus === "checking";
39245
+ const quoteUnavailable = !hasQuote && !isQuoteRefreshing && !isSubmitting && txStatus === "idle";
39223
39246
  let label;
39224
39247
  if (isChecking) {
39225
39248
  label = "Checking approval...";
@@ -39227,12 +39250,14 @@ function SwapActionArea({
39227
39250
  label = `Approving ${fromTokenSymbol}...`;
39228
39251
  } else if (isSubmitting) {
39229
39252
  label = "Confirm in wallet...";
39253
+ } else if (isQuoteRefreshing) {
39254
+ label = "Refreshing quote...";
39230
39255
  } else if (needsApproval) {
39231
39256
  label = `Approve ${fromTokenSymbol}`;
39232
39257
  } else {
39233
39258
  label = "Swap";
39234
39259
  }
39235
- const isDisabled = isSubmitting || isChecking;
39260
+ const isDisabled = isSubmitting || isChecking || isQuoteRefreshing || !hasQuote;
39236
39261
  return /* @__PURE__ */ jsxs47("div", { style: { marginTop: spacing[6] }, children: [
39237
39262
  isGasSponsored && !isSubmitting && /* @__PURE__ */ jsxs47(
39238
39263
  "div",
@@ -39272,7 +39297,38 @@ function SwapActionArea({
39272
39297
  ]
39273
39298
  }
39274
39299
  ),
39275
- /* @__PURE__ */ jsx59(
39300
+ quoteUnavailable ? /* @__PURE__ */ jsxs47(Fragment13, { children: [
39301
+ /* @__PURE__ */ jsx59(
39302
+ "p",
39303
+ {
39304
+ style: {
39305
+ fontSize: fontSize.xs,
39306
+ color: colors.destructive,
39307
+ textAlign: "center",
39308
+ marginBottom: spacing[3]
39309
+ },
39310
+ children: quoteError ?? "This quote expired."
39311
+ }
39312
+ ),
39313
+ /* @__PURE__ */ jsx59(
39314
+ "button",
39315
+ {
39316
+ onClick: onRetryQuote,
39317
+ style: {
39318
+ width: "100%",
39319
+ height: "3.5rem",
39320
+ borderRadius: "1.5rem",
39321
+ backgroundColor: colors.primary,
39322
+ color: colors.primaryForeground,
39323
+ fontSize: fontSize.base,
39324
+ fontWeight: fontWeight.semibold,
39325
+ border: 0,
39326
+ cursor: "pointer"
39327
+ },
39328
+ children: "Get a new quote"
39329
+ }
39330
+ )
39331
+ ] }) : /* @__PURE__ */ jsx59(
39276
39332
  "button",
39277
39333
  {
39278
39334
  onClick: onExecute,