@spicenet-io/spiceflow-ui 1.7.1 → 1.7.3

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.
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import React, { useEffect, useState, useCallback } from 'react';
4
- import { c as createTheme, B as Button } from './Button-aWXByNBC.js';
4
+ import { c as createTheme, B as Button } from './Button-RifBkofT.js';
5
5
  import { useDynamicContext, useConnectWithOtp } from '@dynamic-labs/sdk-react-core';
6
6
 
7
7
  const Input = ({
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from 'react/jsx-runtime';
3
3
  import { useState, useEffect } from 'react';
4
- import { B as Button, c as createTheme } from './Button-aWXByNBC.js';
4
+ import { B as Button, c as createTheme } from './Button-RifBkofT.js';
5
5
  import { usePrivy, useLogin, useLogout } from '@privy-io/react-auth';
6
6
 
7
7
  const PrivyLogin = ({
package/dist/index.cjs.js CHANGED
@@ -86,10 +86,10 @@ const CHAIN_CONFIGS = {
86
86
  moralisName: "",
87
87
  supportedTokens: [
88
88
  {
89
- address: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
89
+ address: "0xBeB51deb2018b67b35d5695Fd15bb30D452c7868",
90
90
  name: "USD Coin",
91
91
  symbol: "USDC",
92
- decimals: 6
92
+ decimals: 18
93
93
  }
94
94
  ]
95
95
  },
@@ -120,10 +120,10 @@ const CHAIN_CONFIGS = {
120
120
  moralisName: "0x14a34",
121
121
  supportedTokens: [
122
122
  {
123
- address: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
123
+ address: "0xf370dC3765f81aC9dD2FEBd59Fb4e710330B0BC8",
124
124
  name: "USD Coin",
125
125
  symbol: "USDC",
126
- decimals: 6
126
+ decimals: 18
127
127
  },
128
128
  {
129
129
  address: "0x4Fc381B6CC6Df8cF1c1bD46D184475bE5b7A3c62",
@@ -3166,6 +3166,39 @@ class RelayerService {
3166
3166
  throw error;
3167
3167
  }
3168
3168
  }
3169
+ async requestSpiceUsdAirdrop(params) {
3170
+ try {
3171
+ const response = await fetch(
3172
+ `${this.baseUrl}/airdrop/${params.chainId}/spiceUsd`,
3173
+ {
3174
+ method: "POST",
3175
+ headers: {
3176
+ "Content-Type": "application/json"
3177
+ },
3178
+ body: JSON.stringify({ wallet: params.address })
3179
+ }
3180
+ );
3181
+ const data = await response.json().catch(() => ({}));
3182
+ if (!response.ok) {
3183
+ const msg = data && (data.error || data.message) || "Failed to request airdrop";
3184
+ return { success: false, errorMessage: String(msg) };
3185
+ }
3186
+ if (data && typeof data.error === "string") {
3187
+ return { success: false, errorMessage: data.error };
3188
+ }
3189
+ if (data && (data.txHash || data.amount)) {
3190
+ return {
3191
+ success: true,
3192
+ txHash: data.txHash,
3193
+ amount: data.amount
3194
+ };
3195
+ }
3196
+ return { success: true };
3197
+ } catch (error) {
3198
+ const msg = error?.message && typeof error.message === "string" ? error.message : "Failed to request airdrop";
3199
+ return { success: false, errorMessage: msg };
3200
+ }
3201
+ }
3169
3202
  }
3170
3203
  const relayerService = new RelayerService();
3171
3204
  const createInitialSteps = (chainBatches, customGetChainName) => {
@@ -6980,6 +7013,9 @@ const DepositModal = React.memo(
6980
7013
  null
6981
7014
  );
6982
7015
  const [showAirdropTooltip, setShowAirdropTooltip] = React.useState(false);
7016
+ const [airdropLoading, setAirdropLoading] = React.useState(false);
7017
+ const [airdropMessage, setAirdropMessage] = React.useState(null);
7018
+ const [airdropError, setAirdropError] = React.useState(null);
6983
7019
  const {
6984
7020
  intentStatus,
6985
7021
  startStatusPolling,
@@ -7016,13 +7052,6 @@ const DepositModal = React.memo(
7016
7052
  "Submitting deposit data to backend after bridging completes:",
7017
7053
  depositData
7018
7054
  );
7019
- for (const data of depositData) {
7020
- console.log("Calling submitSpiceDeposit with:", data);
7021
- await relayerService.submitSpiceDeposit(data);
7022
- console.log(
7023
- `Successfully submitted deposit for txHash: ${data.txHash} on chainId: ${data.chainId}`
7024
- );
7025
- }
7026
7055
  }
7027
7056
  setPostDepositStatus("success");
7028
7057
  setPostDepositAmount(bridgedAmount);
@@ -7055,6 +7084,44 @@ const DepositModal = React.memo(
7055
7084
  }, [isOpen]);
7056
7085
  React.useMemo(() => {
7057
7086
  }, [depositAmount]);
7087
+ const handleAirdropClick = React.useCallback(async () => {
7088
+ const targetAddress = sourceAddress || address;
7089
+ setAirdropMessage(null);
7090
+ setAirdropError(null);
7091
+ if (!targetAddress) {
7092
+ setAirdropError("Connect your wallet before requesting an airdrop");
7093
+ return;
7094
+ }
7095
+ const selectedChainId = selectedDepositAssets[0]?.asset?.chainId ?? supportedChains[0];
7096
+ if (!selectedChainId) {
7097
+ setAirdropError("No chain selected for airdrop");
7098
+ return;
7099
+ }
7100
+ setAirdropLoading(true);
7101
+ try {
7102
+ const result = await relayerService.requestSpiceUsdAirdrop({
7103
+ chainId: selectedChainId,
7104
+ address: targetAddress
7105
+ });
7106
+ if (!result.success) {
7107
+ setAirdropError(result.errorMessage || "Failed to request airdrop");
7108
+ return;
7109
+ }
7110
+ if (result.txHash || result.amount) {
7111
+ const amountText = result.amount ? ` ${result.amount}` : "";
7112
+ setAirdropMessage(
7113
+ `Airdrop${amountText} requested successfully. Transaction will appear shortly.`
7114
+ );
7115
+ return;
7116
+ }
7117
+ setAirdropMessage("Airdrop requested successfully.");
7118
+ } catch (e) {
7119
+ const msg = e?.message && typeof e.message === "string" ? e.message : "Failed to request airdrop";
7120
+ setAirdropError(msg);
7121
+ } finally {
7122
+ setAirdropLoading(false);
7123
+ }
7124
+ }, [address, sourceAddress, selectedDepositAssets, supportedChains]);
7058
7125
  const handleDepositAssetSelect = (asset, index) => {
7059
7126
  setSelectedDepositAssets((prev) => {
7060
7127
  const updated = [...prev];
@@ -7330,7 +7397,7 @@ const DepositModal = React.memo(
7330
7397
  );
7331
7398
  }
7332
7399
  if (sponsorGas && nativeChainId) {
7333
- const gasAmount = viem.parseUnits("0.0003", 18);
7400
+ const gasAmount = viem.parseUnits("0.05", 18);
7334
7401
  tokenTransfers.push({
7335
7402
  tokenAddress: "0x0",
7336
7403
  tokenAmount: gasAmount.toString(),
@@ -7470,7 +7537,7 @@ const DepositModal = React.memo(
7470
7537
  });
7471
7538
  }
7472
7539
  if (sponsorGas && nativeChainId) {
7473
- const gasAmount = viem.parseUnits("0.0003", 18);
7540
+ const gasAmount = viem.parseUnits("0.05", 18);
7474
7541
  tokenTransfers.push({
7475
7542
  tokenAddress: "0x0",
7476
7543
  tokenAmount: gasAmount.toString(),
@@ -7669,94 +7736,107 @@ const DepositModal = React.memo(
7669
7736
  style: {
7670
7737
  display: "flex",
7671
7738
  justifyContent: "flex-end",
7672
- alignItems: "center",
7739
+ alignItems: "flex-start",
7740
+ flexDirection: "column",
7673
7741
  gap: "4px",
7674
7742
  marginBottom: "8px"
7675
7743
  },
7676
7744
  children: [
7677
- /* @__PURE__ */ jsxRuntime.jsx(
7678
- "button",
7679
- {
7680
- onClick: () => {
7681
- },
7682
- style: {
7683
- padding: "4px 8px",
7684
- borderRadius: "4px",
7685
- border: "1px solid #D1D5DB",
7686
- background: "#E5E7EB",
7687
- color: "#4B5563",
7688
- fontSize: "11px",
7689
- fontWeight: 500,
7690
- cursor: "pointer",
7691
- display: "flex",
7692
- alignItems: "center",
7693
- gap: "4px",
7694
- transition: "all 0.2s",
7695
- whiteSpace: "nowrap"
7696
- },
7697
- onMouseEnter: (e) => {
7698
- e.currentTarget.style.color = "#1F2937";
7699
- e.currentTarget.style.background = "#D1D5DB";
7700
- },
7701
- onMouseLeave: (e) => {
7702
- e.currentTarget.style.color = "#4B5563";
7703
- e.currentTarget.style.background = "#E5E7EB";
7704
- },
7705
- children: "Airdrop"
7706
- }
7707
- ),
7708
7745
  /* @__PURE__ */ jsxRuntime.jsxs(
7709
7746
  "div",
7710
7747
  {
7711
- onMouseEnter: () => setShowAirdropTooltip(true),
7712
- onMouseLeave: () => setShowAirdropTooltip(false),
7713
7748
  style: {
7714
- position: "relative",
7715
- width: "14px",
7716
- height: "14px",
7717
- borderRadius: "50%",
7718
- backgroundColor: "#9CA3AF",
7719
- color: "white",
7720
7749
  display: "flex",
7750
+ justifyContent: "flex-end",
7721
7751
  alignItems: "center",
7722
- justifyContent: "center",
7723
- fontSize: "9px",
7724
- fontWeight: "bold",
7725
- cursor: "help"
7752
+ gap: "4px"
7726
7753
  },
7727
7754
  children: [
7728
- "i",
7729
- showAirdropTooltip && /* @__PURE__ */ jsxRuntime.jsxs(
7755
+ /* @__PURE__ */ jsxRuntime.jsx(
7756
+ "button",
7757
+ {
7758
+ onClick: handleAirdropClick,
7759
+ style: {
7760
+ padding: "4px 8px",
7761
+ borderRadius: "4px",
7762
+ border: "1px solid #D1D5DB",
7763
+ background: "#E5E7EB",
7764
+ color: "#4B5563",
7765
+ fontSize: "11px",
7766
+ fontWeight: 500,
7767
+ cursor: airdropLoading ? "default" : "pointer",
7768
+ display: "flex",
7769
+ alignItems: "center",
7770
+ gap: "4px",
7771
+ transition: "all 0.2s",
7772
+ whiteSpace: "nowrap"
7773
+ },
7774
+ onMouseEnter: (e) => {
7775
+ e.currentTarget.style.color = "#1F2937";
7776
+ e.currentTarget.style.background = "#D1D5DB";
7777
+ },
7778
+ onMouseLeave: (e) => {
7779
+ e.currentTarget.style.color = "#4B5563";
7780
+ e.currentTarget.style.background = "#E5E7EB";
7781
+ },
7782
+ children: airdropLoading ? "Requesting..." : "Airdrop"
7783
+ }
7784
+ ),
7785
+ /* @__PURE__ */ jsxRuntime.jsxs(
7730
7786
  "div",
7731
7787
  {
7788
+ onMouseEnter: () => setShowAirdropTooltip(true),
7789
+ onMouseLeave: () => setShowAirdropTooltip(false),
7732
7790
  style: {
7733
- position: "absolute",
7734
- bottom: "calc(100% + 8px)",
7735
- right: 0,
7736
- backgroundColor: "#1F2937",
7791
+ position: "relative",
7792
+ width: "14px",
7793
+ height: "14px",
7794
+ borderRadius: "50%",
7795
+ backgroundColor: "#9CA3AF",
7737
7796
  color: "white",
7738
- padding: "8px 12px",
7739
- borderRadius: "6px",
7740
- fontSize: "12px",
7741
- whiteSpace: "nowrap",
7742
- boxShadow: "0 4px 6px rgba(0, 0, 0, 0.1)",
7743
- zIndex: 100
7797
+ display: "flex",
7798
+ alignItems: "center",
7799
+ justifyContent: "center",
7800
+ fontSize: "9px",
7801
+ fontWeight: "bold",
7802
+ cursor: "help"
7744
7803
  },
7745
7804
  children: [
7746
- "This is testnet USDC, and it won't be available on mainnet",
7747
- /* @__PURE__ */ jsxRuntime.jsx(
7805
+ "i",
7806
+ showAirdropTooltip && /* @__PURE__ */ jsxRuntime.jsxs(
7748
7807
  "div",
7749
7808
  {
7750
7809
  style: {
7751
7810
  position: "absolute",
7752
- top: "100%",
7753
- right: "10px",
7754
- width: 0,
7755
- height: 0,
7756
- borderLeft: "6px solid transparent",
7757
- borderRight: "6px solid transparent",
7758
- borderTop: "6px solid #1F2937"
7759
- }
7811
+ bottom: "calc(100% + 8px)",
7812
+ right: 0,
7813
+ backgroundColor: "#1F2937",
7814
+ color: "white",
7815
+ padding: "8px 12px",
7816
+ borderRadius: "6px",
7817
+ fontSize: "12px",
7818
+ whiteSpace: "nowrap",
7819
+ boxShadow: "0 4px 6px rgba(0, 0, 0, 0.1)",
7820
+ zIndex: 100
7821
+ },
7822
+ children: [
7823
+ "This is testnet USDC, and it won't be available on mainnet",
7824
+ /* @__PURE__ */ jsxRuntime.jsx(
7825
+ "div",
7826
+ {
7827
+ style: {
7828
+ position: "absolute",
7829
+ top: "100%",
7830
+ right: "10px",
7831
+ width: 0,
7832
+ height: 0,
7833
+ borderLeft: "6px solid transparent",
7834
+ borderRight: "6px solid transparent",
7835
+ borderTop: "6px solid #1F2937"
7836
+ }
7837
+ }
7838
+ )
7839
+ ]
7760
7840
  }
7761
7841
  )
7762
7842
  ]
@@ -7764,6 +7844,18 @@ const DepositModal = React.memo(
7764
7844
  )
7765
7845
  ]
7766
7846
  }
7847
+ ),
7848
+ (airdropMessage || airdropError) && /* @__PURE__ */ jsxRuntime.jsx(
7849
+ "div",
7850
+ {
7851
+ style: {
7852
+ marginTop: "6px",
7853
+ fontSize: "11px",
7854
+ color: airdropError ? "#b91c1c" : "#047857",
7855
+ fontFamily: styles?.fontFamily || theme.typography.fontFamily
7856
+ },
7857
+ children: airdropError || airdropMessage
7858
+ }
7767
7859
  )
7768
7860
  ]
7769
7861
  }
@@ -7842,8 +7934,7 @@ const DepositModal = React.memo(
7842
7934
  /* @__PURE__ */ jsxRuntime.jsx(
7843
7935
  "button",
7844
7936
  {
7845
- onClick: () => {
7846
- },
7937
+ onClick: handleAirdropClick,
7847
7938
  style: {
7848
7939
  padding: "4px 8px",
7849
7940
  borderRadius: "4px",
@@ -7852,7 +7943,7 @@ const DepositModal = React.memo(
7852
7943
  color: "#4B5563",
7853
7944
  fontSize: "11px",
7854
7945
  fontWeight: 500,
7855
- cursor: "pointer",
7946
+ cursor: airdropLoading ? "default" : "pointer",
7856
7947
  display: "flex",
7857
7948
  alignItems: "center",
7858
7949
  gap: "4px",
@@ -7867,7 +7958,7 @@ const DepositModal = React.memo(
7867
7958
  e.currentTarget.style.color = "#4B5563";
7868
7959
  e.currentTarget.style.background = "#E5E7EB";
7869
7960
  },
7870
- children: "Airdrop"
7961
+ children: airdropLoading ? "Requesting..." : "Airdrop"
7871
7962
  }
7872
7963
  ),
7873
7964
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -7929,6 +8020,18 @@ const DepositModal = React.memo(
7929
8020
  )
7930
8021
  ]
7931
8022
  }
8023
+ ),
8024
+ (airdropMessage || airdropError) && /* @__PURE__ */ jsxRuntime.jsx(
8025
+ "div",
8026
+ {
8027
+ style: {
8028
+ marginTop: "6px",
8029
+ fontSize: "11px",
8030
+ color: airdropError ? "#b91c1c" : "#047857",
8031
+ fontFamily: styles?.fontFamily || theme.typography.fontFamily
8032
+ },
8033
+ children: airdropError || airdropMessage
8034
+ }
7932
8035
  )
7933
8036
  ]
7934
8037
  }
@@ -10018,105 +10121,8 @@ const formatCurrencyWithDecimals = (amount) => {
10018
10121
  maximumFractionDigits: 5
10019
10122
  }).format(rounded);
10020
10123
  };
10021
- const defaultBalanceData = {
10022
- totalBalance: 10333,
10023
- percentageChange: 2.15,
10024
- tradingAccounts: [
10025
- { id: "hyperliquid", name: "HYPERLIQUID", balance: 800 },
10026
- { id: "lighter", name: "LIGHTER", balance: 1200 }
10027
- ],
10028
- freeCollateral: 8e3,
10029
- freeCollateralItems: [
10030
- {
10031
- id: "usdc-eth",
10032
- name: "USDC",
10033
- balance: 3e3,
10034
- subtitle: "USD COIN",
10035
- iconColor: "#2775CA",
10036
- networks: [11155111]
10037
- },
10038
- // Ethereum Sepolia
10039
- {
10040
- id: "usdc-arb",
10041
- name: "USDC",
10042
- balance: 2e3,
10043
- subtitle: "USD COIN",
10044
- iconColor: "#2775CA",
10045
- networks: [42161]
10046
- },
10047
- // Arbitrum
10048
- {
10049
- id: "usdc-base",
10050
- name: "USDC",
10051
- balance: 1500,
10052
- subtitle: "USD COIN",
10053
- iconColor: "#2775CA",
10054
- networks: [84532]
10055
- },
10056
- // Base Sepolia
10057
- {
10058
- id: "weth",
10059
- name: "WETH",
10060
- balance: 500,
10061
- subtitle: "WRAPPED ETH",
10062
- iconColor: "#627EEA",
10063
- networks: [11155111]
10064
- },
10065
- {
10066
- id: "uniswap-pt",
10067
- name: "UNISWAP PT",
10068
- balance: 500,
10069
- iconColor: "#FF007A",
10070
- networks: [11155111]
10071
- },
10072
- {
10073
- id: "pendle-pt",
10074
- name: "PENDLE PT",
10075
- balance: 500,
10076
- iconColor: "#6366F1",
10077
- networks: [11155111]
10078
- }
10079
- ],
10080
- defiPositions: 2333,
10081
- defiPositionsItems: [
10082
- {
10083
- id: "uniswap-v4",
10084
- name: "UNISWAP V4",
10085
- balance: 1166.5,
10086
- iconColor: "#FF007A"
10087
- },
10088
- {
10089
- id: "pendle-pt-defi",
10090
- name: "PENDLE PT",
10091
- balance: 1166.5,
10092
- iconColor: "#6366F1"
10093
- }
10094
- ],
10095
- credit: 2333,
10096
- creditItems: [
10097
- {
10098
- id: "usdc-credit",
10099
- name: "USDC",
10100
- balance: 1e3,
10101
- subtitle: "USD COIN",
10102
- iconColor: "#2775CA"
10103
- },
10104
- {
10105
- id: "uniswap-lp",
10106
- name: "UNISWAP LP",
10107
- balance: 666.5,
10108
- iconColor: "#FF007A"
10109
- },
10110
- {
10111
- id: "pendle-pt-credit",
10112
- name: "PENDLE PT",
10113
- balance: 666.5,
10114
- iconColor: "#6366F1"
10115
- }
10116
- ]
10117
- };
10118
10124
  const SpiceBalance = ({
10119
- balanceData = defaultBalanceData,
10125
+ balanceData,
10120
10126
  isLoading = false,
10121
10127
  styles,
10122
10128
  className = "",
@@ -10212,24 +10218,6 @@ const SpiceBalance = ({
10212
10218
  balanceData.freeCollateralItems,
10213
10219
  balanceData.freeCollateral
10214
10220
  ]);
10215
- React.useMemo(() => {
10216
- if (balanceData.defiPositionsItems) {
10217
- return balanceData.defiPositionsItems.reduce(
10218
- (sum, item) => sum + item.balance,
10219
- 0
10220
- );
10221
- }
10222
- return balanceData.defiPositions;
10223
- }, [balanceData.defiPositionsItems, balanceData.defiPositions]);
10224
- React.useMemo(() => {
10225
- if (balanceData.creditItems) {
10226
- return balanceData.creditItems.reduce(
10227
- (sum, item) => sum + item.balance,
10228
- 0
10229
- );
10230
- }
10231
- return balanceData.credit;
10232
- }, [balanceData.creditItems, balanceData.credit]);
10233
10221
  const maskBalance = (value) => {
10234
10222
  return isBalanceVisible ? value : "******";
10235
10223
  };
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import React, { useState, useRef, useEffect, useCallback, createContext, useContext, useTransition, forwardRef, createElement, useMemo } from 'react';
4
4
  import { defineChain, createPublicClient, http, isAddress, getAddress, parseEther, encodeFunctionData, parseUnits, erc20Abi } from 'viem';
5
- import { c as createTheme, B as Button, d as defaultTheme } from './Button-aWXByNBC.js';
5
+ import { c as createTheme, B as Button, d as defaultTheme } from './Button-RifBkofT.js';
6
6
  import { getBalance, readContract } from 'viem/actions';
7
7
  import { basecampTestnet, citreaTestnet, baseSepolia, arbitrumSepolia, sepolia } from 'viem/chains';
8
8
  import { createPortal } from 'react-dom';
@@ -84,10 +84,10 @@ const CHAIN_CONFIGS = {
84
84
  moralisName: "",
85
85
  supportedTokens: [
86
86
  {
87
- address: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
87
+ address: "0xBeB51deb2018b67b35d5695Fd15bb30D452c7868",
88
88
  name: "USD Coin",
89
89
  symbol: "USDC",
90
- decimals: 6
90
+ decimals: 18
91
91
  }
92
92
  ]
93
93
  },
@@ -118,10 +118,10 @@ const CHAIN_CONFIGS = {
118
118
  moralisName: "0x14a34",
119
119
  supportedTokens: [
120
120
  {
121
- address: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
121
+ address: "0xf370dC3765f81aC9dD2FEBd59Fb4e710330B0BC8",
122
122
  name: "USD Coin",
123
123
  symbol: "USDC",
124
- decimals: 6
124
+ decimals: 18
125
125
  },
126
126
  {
127
127
  address: "0x4Fc381B6CC6Df8cF1c1bD46D184475bE5b7A3c62",
@@ -3164,6 +3164,39 @@ class RelayerService {
3164
3164
  throw error;
3165
3165
  }
3166
3166
  }
3167
+ async requestSpiceUsdAirdrop(params) {
3168
+ try {
3169
+ const response = await fetch(
3170
+ `${this.baseUrl}/airdrop/${params.chainId}/spiceUsd`,
3171
+ {
3172
+ method: "POST",
3173
+ headers: {
3174
+ "Content-Type": "application/json"
3175
+ },
3176
+ body: JSON.stringify({ wallet: params.address })
3177
+ }
3178
+ );
3179
+ const data = await response.json().catch(() => ({}));
3180
+ if (!response.ok) {
3181
+ const msg = data && (data.error || data.message) || "Failed to request airdrop";
3182
+ return { success: false, errorMessage: String(msg) };
3183
+ }
3184
+ if (data && typeof data.error === "string") {
3185
+ return { success: false, errorMessage: data.error };
3186
+ }
3187
+ if (data && (data.txHash || data.amount)) {
3188
+ return {
3189
+ success: true,
3190
+ txHash: data.txHash,
3191
+ amount: data.amount
3192
+ };
3193
+ }
3194
+ return { success: true };
3195
+ } catch (error) {
3196
+ const msg = error?.message && typeof error.message === "string" ? error.message : "Failed to request airdrop";
3197
+ return { success: false, errorMessage: msg };
3198
+ }
3199
+ }
3167
3200
  }
3168
3201
  const relayerService = new RelayerService();
3169
3202
  const createInitialSteps = (chainBatches, customGetChainName) => {
@@ -6978,6 +7011,9 @@ const DepositModal = React.memo(
6978
7011
  null
6979
7012
  );
6980
7013
  const [showAirdropTooltip, setShowAirdropTooltip] = useState(false);
7014
+ const [airdropLoading, setAirdropLoading] = useState(false);
7015
+ const [airdropMessage, setAirdropMessage] = useState(null);
7016
+ const [airdropError, setAirdropError] = useState(null);
6981
7017
  const {
6982
7018
  intentStatus,
6983
7019
  startStatusPolling,
@@ -7014,13 +7050,6 @@ const DepositModal = React.memo(
7014
7050
  "Submitting deposit data to backend after bridging completes:",
7015
7051
  depositData
7016
7052
  );
7017
- for (const data of depositData) {
7018
- console.log("Calling submitSpiceDeposit with:", data);
7019
- await relayerService.submitSpiceDeposit(data);
7020
- console.log(
7021
- `Successfully submitted deposit for txHash: ${data.txHash} on chainId: ${data.chainId}`
7022
- );
7023
- }
7024
7053
  }
7025
7054
  setPostDepositStatus("success");
7026
7055
  setPostDepositAmount(bridgedAmount);
@@ -7053,6 +7082,44 @@ const DepositModal = React.memo(
7053
7082
  }, [isOpen]);
7054
7083
  useMemo(() => {
7055
7084
  }, [depositAmount]);
7085
+ const handleAirdropClick = useCallback(async () => {
7086
+ const targetAddress = sourceAddress || address;
7087
+ setAirdropMessage(null);
7088
+ setAirdropError(null);
7089
+ if (!targetAddress) {
7090
+ setAirdropError("Connect your wallet before requesting an airdrop");
7091
+ return;
7092
+ }
7093
+ const selectedChainId = selectedDepositAssets[0]?.asset?.chainId ?? supportedChains[0];
7094
+ if (!selectedChainId) {
7095
+ setAirdropError("No chain selected for airdrop");
7096
+ return;
7097
+ }
7098
+ setAirdropLoading(true);
7099
+ try {
7100
+ const result = await relayerService.requestSpiceUsdAirdrop({
7101
+ chainId: selectedChainId,
7102
+ address: targetAddress
7103
+ });
7104
+ if (!result.success) {
7105
+ setAirdropError(result.errorMessage || "Failed to request airdrop");
7106
+ return;
7107
+ }
7108
+ if (result.txHash || result.amount) {
7109
+ const amountText = result.amount ? ` ${result.amount}` : "";
7110
+ setAirdropMessage(
7111
+ `Airdrop${amountText} requested successfully. Transaction will appear shortly.`
7112
+ );
7113
+ return;
7114
+ }
7115
+ setAirdropMessage("Airdrop requested successfully.");
7116
+ } catch (e) {
7117
+ const msg = e?.message && typeof e.message === "string" ? e.message : "Failed to request airdrop";
7118
+ setAirdropError(msg);
7119
+ } finally {
7120
+ setAirdropLoading(false);
7121
+ }
7122
+ }, [address, sourceAddress, selectedDepositAssets, supportedChains]);
7056
7123
  const handleDepositAssetSelect = (asset, index) => {
7057
7124
  setSelectedDepositAssets((prev) => {
7058
7125
  const updated = [...prev];
@@ -7328,7 +7395,7 @@ const DepositModal = React.memo(
7328
7395
  );
7329
7396
  }
7330
7397
  if (sponsorGas && nativeChainId) {
7331
- const gasAmount = parseUnits("0.0003", 18);
7398
+ const gasAmount = parseUnits("0.05", 18);
7332
7399
  tokenTransfers.push({
7333
7400
  tokenAddress: "0x0",
7334
7401
  tokenAmount: gasAmount.toString(),
@@ -7468,7 +7535,7 @@ const DepositModal = React.memo(
7468
7535
  });
7469
7536
  }
7470
7537
  if (sponsorGas && nativeChainId) {
7471
- const gasAmount = parseUnits("0.0003", 18);
7538
+ const gasAmount = parseUnits("0.05", 18);
7472
7539
  tokenTransfers.push({
7473
7540
  tokenAddress: "0x0",
7474
7541
  tokenAmount: gasAmount.toString(),
@@ -7667,94 +7734,107 @@ const DepositModal = React.memo(
7667
7734
  style: {
7668
7735
  display: "flex",
7669
7736
  justifyContent: "flex-end",
7670
- alignItems: "center",
7737
+ alignItems: "flex-start",
7738
+ flexDirection: "column",
7671
7739
  gap: "4px",
7672
7740
  marginBottom: "8px"
7673
7741
  },
7674
7742
  children: [
7675
- /* @__PURE__ */ jsx(
7676
- "button",
7677
- {
7678
- onClick: () => {
7679
- },
7680
- style: {
7681
- padding: "4px 8px",
7682
- borderRadius: "4px",
7683
- border: "1px solid #D1D5DB",
7684
- background: "#E5E7EB",
7685
- color: "#4B5563",
7686
- fontSize: "11px",
7687
- fontWeight: 500,
7688
- cursor: "pointer",
7689
- display: "flex",
7690
- alignItems: "center",
7691
- gap: "4px",
7692
- transition: "all 0.2s",
7693
- whiteSpace: "nowrap"
7694
- },
7695
- onMouseEnter: (e) => {
7696
- e.currentTarget.style.color = "#1F2937";
7697
- e.currentTarget.style.background = "#D1D5DB";
7698
- },
7699
- onMouseLeave: (e) => {
7700
- e.currentTarget.style.color = "#4B5563";
7701
- e.currentTarget.style.background = "#E5E7EB";
7702
- },
7703
- children: "Airdrop"
7704
- }
7705
- ),
7706
7743
  /* @__PURE__ */ jsxs(
7707
7744
  "div",
7708
7745
  {
7709
- onMouseEnter: () => setShowAirdropTooltip(true),
7710
- onMouseLeave: () => setShowAirdropTooltip(false),
7711
7746
  style: {
7712
- position: "relative",
7713
- width: "14px",
7714
- height: "14px",
7715
- borderRadius: "50%",
7716
- backgroundColor: "#9CA3AF",
7717
- color: "white",
7718
7747
  display: "flex",
7748
+ justifyContent: "flex-end",
7719
7749
  alignItems: "center",
7720
- justifyContent: "center",
7721
- fontSize: "9px",
7722
- fontWeight: "bold",
7723
- cursor: "help"
7750
+ gap: "4px"
7724
7751
  },
7725
7752
  children: [
7726
- "i",
7727
- showAirdropTooltip && /* @__PURE__ */ jsxs(
7753
+ /* @__PURE__ */ jsx(
7754
+ "button",
7755
+ {
7756
+ onClick: handleAirdropClick,
7757
+ style: {
7758
+ padding: "4px 8px",
7759
+ borderRadius: "4px",
7760
+ border: "1px solid #D1D5DB",
7761
+ background: "#E5E7EB",
7762
+ color: "#4B5563",
7763
+ fontSize: "11px",
7764
+ fontWeight: 500,
7765
+ cursor: airdropLoading ? "default" : "pointer",
7766
+ display: "flex",
7767
+ alignItems: "center",
7768
+ gap: "4px",
7769
+ transition: "all 0.2s",
7770
+ whiteSpace: "nowrap"
7771
+ },
7772
+ onMouseEnter: (e) => {
7773
+ e.currentTarget.style.color = "#1F2937";
7774
+ e.currentTarget.style.background = "#D1D5DB";
7775
+ },
7776
+ onMouseLeave: (e) => {
7777
+ e.currentTarget.style.color = "#4B5563";
7778
+ e.currentTarget.style.background = "#E5E7EB";
7779
+ },
7780
+ children: airdropLoading ? "Requesting..." : "Airdrop"
7781
+ }
7782
+ ),
7783
+ /* @__PURE__ */ jsxs(
7728
7784
  "div",
7729
7785
  {
7786
+ onMouseEnter: () => setShowAirdropTooltip(true),
7787
+ onMouseLeave: () => setShowAirdropTooltip(false),
7730
7788
  style: {
7731
- position: "absolute",
7732
- bottom: "calc(100% + 8px)",
7733
- right: 0,
7734
- backgroundColor: "#1F2937",
7789
+ position: "relative",
7790
+ width: "14px",
7791
+ height: "14px",
7792
+ borderRadius: "50%",
7793
+ backgroundColor: "#9CA3AF",
7735
7794
  color: "white",
7736
- padding: "8px 12px",
7737
- borderRadius: "6px",
7738
- fontSize: "12px",
7739
- whiteSpace: "nowrap",
7740
- boxShadow: "0 4px 6px rgba(0, 0, 0, 0.1)",
7741
- zIndex: 100
7795
+ display: "flex",
7796
+ alignItems: "center",
7797
+ justifyContent: "center",
7798
+ fontSize: "9px",
7799
+ fontWeight: "bold",
7800
+ cursor: "help"
7742
7801
  },
7743
7802
  children: [
7744
- "This is testnet USDC, and it won't be available on mainnet",
7745
- /* @__PURE__ */ jsx(
7803
+ "i",
7804
+ showAirdropTooltip && /* @__PURE__ */ jsxs(
7746
7805
  "div",
7747
7806
  {
7748
7807
  style: {
7749
7808
  position: "absolute",
7750
- top: "100%",
7751
- right: "10px",
7752
- width: 0,
7753
- height: 0,
7754
- borderLeft: "6px solid transparent",
7755
- borderRight: "6px solid transparent",
7756
- borderTop: "6px solid #1F2937"
7757
- }
7809
+ bottom: "calc(100% + 8px)",
7810
+ right: 0,
7811
+ backgroundColor: "#1F2937",
7812
+ color: "white",
7813
+ padding: "8px 12px",
7814
+ borderRadius: "6px",
7815
+ fontSize: "12px",
7816
+ whiteSpace: "nowrap",
7817
+ boxShadow: "0 4px 6px rgba(0, 0, 0, 0.1)",
7818
+ zIndex: 100
7819
+ },
7820
+ children: [
7821
+ "This is testnet USDC, and it won't be available on mainnet",
7822
+ /* @__PURE__ */ jsx(
7823
+ "div",
7824
+ {
7825
+ style: {
7826
+ position: "absolute",
7827
+ top: "100%",
7828
+ right: "10px",
7829
+ width: 0,
7830
+ height: 0,
7831
+ borderLeft: "6px solid transparent",
7832
+ borderRight: "6px solid transparent",
7833
+ borderTop: "6px solid #1F2937"
7834
+ }
7835
+ }
7836
+ )
7837
+ ]
7758
7838
  }
7759
7839
  )
7760
7840
  ]
@@ -7762,6 +7842,18 @@ const DepositModal = React.memo(
7762
7842
  )
7763
7843
  ]
7764
7844
  }
7845
+ ),
7846
+ (airdropMessage || airdropError) && /* @__PURE__ */ jsx(
7847
+ "div",
7848
+ {
7849
+ style: {
7850
+ marginTop: "6px",
7851
+ fontSize: "11px",
7852
+ color: airdropError ? "#b91c1c" : "#047857",
7853
+ fontFamily: styles?.fontFamily || theme.typography.fontFamily
7854
+ },
7855
+ children: airdropError || airdropMessage
7856
+ }
7765
7857
  )
7766
7858
  ]
7767
7859
  }
@@ -7840,8 +7932,7 @@ const DepositModal = React.memo(
7840
7932
  /* @__PURE__ */ jsx(
7841
7933
  "button",
7842
7934
  {
7843
- onClick: () => {
7844
- },
7935
+ onClick: handleAirdropClick,
7845
7936
  style: {
7846
7937
  padding: "4px 8px",
7847
7938
  borderRadius: "4px",
@@ -7850,7 +7941,7 @@ const DepositModal = React.memo(
7850
7941
  color: "#4B5563",
7851
7942
  fontSize: "11px",
7852
7943
  fontWeight: 500,
7853
- cursor: "pointer",
7944
+ cursor: airdropLoading ? "default" : "pointer",
7854
7945
  display: "flex",
7855
7946
  alignItems: "center",
7856
7947
  gap: "4px",
@@ -7865,7 +7956,7 @@ const DepositModal = React.memo(
7865
7956
  e.currentTarget.style.color = "#4B5563";
7866
7957
  e.currentTarget.style.background = "#E5E7EB";
7867
7958
  },
7868
- children: "Airdrop"
7959
+ children: airdropLoading ? "Requesting..." : "Airdrop"
7869
7960
  }
7870
7961
  ),
7871
7962
  /* @__PURE__ */ jsxs(
@@ -7927,6 +8018,18 @@ const DepositModal = React.memo(
7927
8018
  )
7928
8019
  ]
7929
8020
  }
8021
+ ),
8022
+ (airdropMessage || airdropError) && /* @__PURE__ */ jsx(
8023
+ "div",
8024
+ {
8025
+ style: {
8026
+ marginTop: "6px",
8027
+ fontSize: "11px",
8028
+ color: airdropError ? "#b91c1c" : "#047857",
8029
+ fontFamily: styles?.fontFamily || theme.typography.fontFamily
8030
+ },
8031
+ children: airdropError || airdropMessage
8032
+ }
7930
8033
  )
7931
8034
  ]
7932
8035
  }
@@ -10016,105 +10119,8 @@ const formatCurrencyWithDecimals = (amount) => {
10016
10119
  maximumFractionDigits: 5
10017
10120
  }).format(rounded);
10018
10121
  };
10019
- const defaultBalanceData = {
10020
- totalBalance: 10333,
10021
- percentageChange: 2.15,
10022
- tradingAccounts: [
10023
- { id: "hyperliquid", name: "HYPERLIQUID", balance: 800 },
10024
- { id: "lighter", name: "LIGHTER", balance: 1200 }
10025
- ],
10026
- freeCollateral: 8e3,
10027
- freeCollateralItems: [
10028
- {
10029
- id: "usdc-eth",
10030
- name: "USDC",
10031
- balance: 3e3,
10032
- subtitle: "USD COIN",
10033
- iconColor: "#2775CA",
10034
- networks: [11155111]
10035
- },
10036
- // Ethereum Sepolia
10037
- {
10038
- id: "usdc-arb",
10039
- name: "USDC",
10040
- balance: 2e3,
10041
- subtitle: "USD COIN",
10042
- iconColor: "#2775CA",
10043
- networks: [42161]
10044
- },
10045
- // Arbitrum
10046
- {
10047
- id: "usdc-base",
10048
- name: "USDC",
10049
- balance: 1500,
10050
- subtitle: "USD COIN",
10051
- iconColor: "#2775CA",
10052
- networks: [84532]
10053
- },
10054
- // Base Sepolia
10055
- {
10056
- id: "weth",
10057
- name: "WETH",
10058
- balance: 500,
10059
- subtitle: "WRAPPED ETH",
10060
- iconColor: "#627EEA",
10061
- networks: [11155111]
10062
- },
10063
- {
10064
- id: "uniswap-pt",
10065
- name: "UNISWAP PT",
10066
- balance: 500,
10067
- iconColor: "#FF007A",
10068
- networks: [11155111]
10069
- },
10070
- {
10071
- id: "pendle-pt",
10072
- name: "PENDLE PT",
10073
- balance: 500,
10074
- iconColor: "#6366F1",
10075
- networks: [11155111]
10076
- }
10077
- ],
10078
- defiPositions: 2333,
10079
- defiPositionsItems: [
10080
- {
10081
- id: "uniswap-v4",
10082
- name: "UNISWAP V4",
10083
- balance: 1166.5,
10084
- iconColor: "#FF007A"
10085
- },
10086
- {
10087
- id: "pendle-pt-defi",
10088
- name: "PENDLE PT",
10089
- balance: 1166.5,
10090
- iconColor: "#6366F1"
10091
- }
10092
- ],
10093
- credit: 2333,
10094
- creditItems: [
10095
- {
10096
- id: "usdc-credit",
10097
- name: "USDC",
10098
- balance: 1e3,
10099
- subtitle: "USD COIN",
10100
- iconColor: "#2775CA"
10101
- },
10102
- {
10103
- id: "uniswap-lp",
10104
- name: "UNISWAP LP",
10105
- balance: 666.5,
10106
- iconColor: "#FF007A"
10107
- },
10108
- {
10109
- id: "pendle-pt-credit",
10110
- name: "PENDLE PT",
10111
- balance: 666.5,
10112
- iconColor: "#6366F1"
10113
- }
10114
- ]
10115
- };
10116
10122
  const SpiceBalance = ({
10117
- balanceData = defaultBalanceData,
10123
+ balanceData,
10118
10124
  isLoading = false,
10119
10125
  styles,
10120
10126
  className = "",
@@ -10210,24 +10216,6 @@ const SpiceBalance = ({
10210
10216
  balanceData.freeCollateralItems,
10211
10217
  balanceData.freeCollateral
10212
10218
  ]);
10213
- useMemo(() => {
10214
- if (balanceData.defiPositionsItems) {
10215
- return balanceData.defiPositionsItems.reduce(
10216
- (sum, item) => sum + item.balance,
10217
- 0
10218
- );
10219
- }
10220
- return balanceData.defiPositions;
10221
- }, [balanceData.defiPositionsItems, balanceData.defiPositions]);
10222
- useMemo(() => {
10223
- if (balanceData.creditItems) {
10224
- return balanceData.creditItems.reduce(
10225
- (sum, item) => sum + item.balance,
10226
- 0
10227
- );
10228
- }
10229
- return balanceData.credit;
10230
- }, [balanceData.creditItems, balanceData.credit]);
10231
10219
  const maskBalance = (value) => {
10232
10220
  return isBalanceVisible ? value : "******";
10233
10221
  };
@@ -34,7 +34,7 @@ export interface BalanceData {
34
34
  creditItems?: AccountItem[];
35
35
  }
36
36
  export interface SpiceBalanceProps {
37
- balanceData?: BalanceData;
37
+ balanceData: BalanceData;
38
38
  isLoading?: boolean;
39
39
  onRefresh?: () => void;
40
40
  styles?: any;
@@ -54,6 +54,15 @@ export declare class RelayerService {
54
54
  status: "pending" | "processing" | "success" | "failed";
55
55
  };
56
56
  }>;
57
+ requestSpiceUsdAirdrop(params: {
58
+ chainId: number;
59
+ address: string;
60
+ }): Promise<{
61
+ success: boolean;
62
+ txHash?: string;
63
+ amount?: string;
64
+ errorMessage?: string;
65
+ }>;
57
66
  }
58
67
  export declare const relayerService: RelayerService;
59
68
  export declare const createInitialSteps: (chainBatches: ChainBatch[], customGetChainName?: (chainId: number) => string) => SwapStep[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spicenet-io/spiceflow-ui",
3
- "version": "1.7.1",
3
+ "version": "1.7.3",
4
4
  "description": "Spiceflow UI SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",
File without changes