@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/wallet.cjs CHANGED
@@ -264,7 +264,7 @@ var init_constants = __esm({
264
264
  "src/constants.ts"() {
265
265
  "use strict";
266
266
  SDK_NAME = "@trustware/sdk";
267
- SDK_VERSION = "1.1.12-staging.1";
267
+ SDK_VERSION = "1.1.12-staging.2";
268
268
  API_ROOT = "https://bv-staging-api.trustware.io";
269
269
  API_PREFIX = "/api";
270
270
  WALLETCONNECT_PROJECT_ID = "72ea74c400f5111d43aea638d7d83a24";
package/dist/wallet.mjs CHANGED
@@ -238,7 +238,7 @@ var init_constants = __esm({
238
238
  "src/constants.ts"() {
239
239
  "use strict";
240
240
  SDK_NAME = "@trustware/sdk";
241
- SDK_VERSION = "1.1.12-staging.1";
241
+ SDK_VERSION = "1.1.12-staging.2";
242
242
  API_ROOT = "https://bv-staging-api.trustware.io";
243
243
  API_PREFIX = "/api";
244
244
  WALLETCONNECT_PROJECT_ID = "72ea74c400f5111d43aea638d7d83a24";
package/dist/widget.cjs CHANGED
@@ -593,7 +593,7 @@ var init_constants = __esm({
593
593
  "src/constants.ts"() {
594
594
  "use strict";
595
595
  SDK_NAME = "@trustware/sdk";
596
- SDK_VERSION = "1.1.12-staging.1";
596
+ SDK_VERSION = "1.1.12-staging.2";
597
597
  API_ROOT = "https://bv-staging-api.trustware.io";
598
598
  GTM_ID = "GTM-TZDGNCXB";
599
599
  API_PREFIX = "/api";
@@ -31719,7 +31719,18 @@ async function sendRouteAsUserOperation(params) {
31719
31719
  );
31720
31720
  }
31721
31721
  console.debug("[send] UserOp included", { userOpHash, txHash });
31722
- await submitReceipt(intentId, txHash, getSponsorshipRequestId(), eoaAddress);
31722
+ try {
31723
+ void submitReceipt(
31724
+ intentId,
31725
+ txHash,
31726
+ getSponsorshipRequestId(),
31727
+ eoaAddress
31728
+ ).catch((err) => {
31729
+ console.debug("[send] receipt submission failed (non-fatal)", err);
31730
+ });
31731
+ } catch (err) {
31732
+ console.debug("[send] receipt submission failed (non-fatal)", err);
31733
+ }
31723
31734
  return { userOpHash, txHash, intentId };
31724
31735
  }
31725
31736
  var NATIVE_ADDRS;
@@ -33943,10 +33954,6 @@ function useSwapExecution(fromChain) {
33943
33954
  numericChainId,
33944
33955
  { approvalsEnsured: ownsApprovals }
33945
33956
  );
33946
- try {
33947
- await submitReceipt(routeResult.intentId, hash);
33948
- } catch {
33949
- }
33950
33957
  setState((p) => ({
33951
33958
  ...p,
33952
33959
  isSubmitting: false,
@@ -33955,6 +33962,8 @@ function useSwapExecution(fromChain) {
33955
33962
  txStatus: "processing"
33956
33963
  }));
33957
33964
  startPolling(routeResult.intentId, onSuccess, onError);
33965
+ void submitReceipt(routeResult.intentId, hash).catch(() => {
33966
+ });
33958
33967
  } catch (err) {
33959
33968
  const msg = mapTxError(err);
33960
33969
  setState((p) => ({
@@ -36390,6 +36399,7 @@ function SwapMode({
36390
36399
  }, [route.loading]);
36391
36400
  (0, import_react50.useEffect)(() => {
36392
36401
  if (!route.data) return;
36402
+ if (stage !== "home" && stage !== "review") return;
36393
36403
  const id = setInterval(() => {
36394
36404
  const ts = quoteTimestampRef.current;
36395
36405
  if (ts === null) return;
@@ -36401,7 +36411,11 @@ function SwapMode({
36401
36411
  }
36402
36412
  }, 1e3);
36403
36413
  return () => clearInterval(id);
36404
- }, [route.data]);
36414
+ }, [route.data, stage]);
36415
+ const handleRetryQuote = (0, import_react50.useCallback)(() => {
36416
+ if (!latestFetchParamsRef.current) return;
36417
+ void fetchRef.current(latestFetchParamsRef.current);
36418
+ }, []);
36405
36419
  (0, import_react50.useEffect)(() => {
36406
36420
  if (stage !== "review") return;
36407
36421
  if (!route.data || !walletAddress) return;
@@ -37930,6 +37944,10 @@ function SwapMode({
37930
37944
  txStatus: execution.txStatus,
37931
37945
  isSubmitting: execution.isSubmitting,
37932
37946
  isGasSponsored,
37947
+ hasQuote: !!route.data,
37948
+ isQuoteRefreshing: route.loading,
37949
+ quoteError: route.error,
37950
+ onRetryQuote: handleRetryQuote,
37933
37951
  onExecute: () => void handleExecute()
37934
37952
  }
37935
37953
  )
@@ -39266,10 +39284,15 @@ function SwapActionArea({
39266
39284
  txStatus,
39267
39285
  isSubmitting,
39268
39286
  isGasSponsored,
39287
+ hasQuote,
39288
+ isQuoteRefreshing,
39289
+ quoteError,
39290
+ onRetryQuote,
39269
39291
  onExecute
39270
39292
  }) {
39271
39293
  const needsApproval = allowanceStatus === "needed" && !isGasSponsored;
39272
39294
  const isChecking = allowanceStatus === "checking";
39295
+ const quoteUnavailable = !hasQuote && !isQuoteRefreshing && !isSubmitting && txStatus === "idle";
39273
39296
  let label;
39274
39297
  if (isChecking) {
39275
39298
  label = "Checking approval...";
@@ -39277,12 +39300,14 @@ function SwapActionArea({
39277
39300
  label = `Approving ${fromTokenSymbol}...`;
39278
39301
  } else if (isSubmitting) {
39279
39302
  label = "Confirm in wallet...";
39303
+ } else if (isQuoteRefreshing) {
39304
+ label = "Refreshing quote...";
39280
39305
  } else if (needsApproval) {
39281
39306
  label = `Approve ${fromTokenSymbol}`;
39282
39307
  } else {
39283
39308
  label = "Swap";
39284
39309
  }
39285
- const isDisabled = isSubmitting || isChecking;
39310
+ const isDisabled = isSubmitting || isChecking || isQuoteRefreshing || !hasQuote;
39286
39311
  return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { style: { marginTop: spacing[6] }, children: [
39287
39312
  isGasSponsored && !isSubmitting && /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
39288
39313
  "div",
@@ -39322,7 +39347,38 @@ function SwapActionArea({
39322
39347
  ]
39323
39348
  }
39324
39349
  ),
39325
- /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
39350
+ quoteUnavailable ? /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, { children: [
39351
+ /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
39352
+ "p",
39353
+ {
39354
+ style: {
39355
+ fontSize: fontSize.xs,
39356
+ color: colors.destructive,
39357
+ textAlign: "center",
39358
+ marginBottom: spacing[3]
39359
+ },
39360
+ children: quoteError ?? "This quote expired."
39361
+ }
39362
+ ),
39363
+ /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
39364
+ "button",
39365
+ {
39366
+ onClick: onRetryQuote,
39367
+ style: {
39368
+ width: "100%",
39369
+ height: "3.5rem",
39370
+ borderRadius: "1.5rem",
39371
+ backgroundColor: colors.primary,
39372
+ color: colors.primaryForeground,
39373
+ fontSize: fontSize.base,
39374
+ fontWeight: fontWeight.semibold,
39375
+ border: 0,
39376
+ cursor: "pointer"
39377
+ },
39378
+ children: "Get a new quote"
39379
+ }
39380
+ )
39381
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
39326
39382
  "button",
39327
39383
  {
39328
39384
  onClick: onExecute,