@spicenet-io/spiceflow-ui 3.2.0 → 3.2.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/Button-B--Fjq1m.js +2 -0
- package/dist/Button-dU4UsC56.js +2 -0
- package/dist/auth-dynamic.cjs.js +1 -1
- package/dist/auth-dynamic.js +1 -1
- package/dist/auth-privy.cjs.js +1 -1
- package/dist/auth-privy.js +1 -1
- package/dist/components/AssetSelector/AssetDropdown.d.ts +1 -11
- package/dist/components/AssetSelector/ChainIcon.d.ts +1 -7
- package/dist/components/AssetSelector/TokenIcon.d.ts +1 -7
- package/dist/components/AssetSelector/index.d.ts +1 -3
- package/dist/components/ExportWallet/ExportWalletButton.d.ts +2 -7
- package/dist/components/ProviderLogins/DynamicLogin.d.ts +2 -8
- package/dist/components/ProviderLogins/PrivyLogin.d.ts +2 -8
- package/dist/components/ProviderLogins/ProviderLogin.d.ts +2 -8
- package/dist/components/SpiceDeposit/DepositRecoveryPrompt.d.ts +1 -14
- package/dist/components/SpiceDeposit/DepositStatusModal.d.ts +4 -37
- package/dist/components/SpiceDeposit/SelectTokenModal.d.ts +1 -16
- package/dist/components/SpiceDeposit/SpiceDeposit.d.ts +2 -35
- package/dist/components/SpiceLockModal/LockSubComponents.d.ts +2 -45
- package/dist/components/SpicePay/SpicePay.d.ts +2 -29
- package/dist/components/SpiceSupply/SupplyEstimate.d.ts +2 -13
- package/dist/components/SpiceWithdraw/SelectPopover.d.ts +2 -7
- package/dist/components/SpiceWithdraw/SpiceWithdraw.d.ts +2 -26
- package/dist/components/StatusDisplay/StatusIcon.d.ts +1 -7
- package/dist/components/StatusDisplay/StatusPanel.d.ts +2 -31
- package/dist/components/StatusDisplay/StepItem.d.ts +1 -8
- package/dist/components/StatusDisplay/index.d.ts +1 -2
- package/dist/components/index.d.ts +0 -2
- package/dist/components/ui/AddFundsLink.d.ts +3 -0
- package/dist/components/ui/Button.d.ts +1 -11
- package/dist/components/ui/CloseIcon.d.ts +1 -6
- package/dist/components/ui/DetailRow.d.ts +3 -0
- package/dist/components/ui/FeeBreakdownCard.d.ts +2 -11
- package/dist/components/ui/Input.d.ts +1 -10
- package/dist/components/ui/Modal.d.ts +1 -10
- package/dist/components/ui/SearchInput.d.ts +15 -0
- package/dist/components/ui/SpiceModalShell.d.ts +1 -17
- package/dist/components/ui/Spinner.d.ts +1 -6
- package/dist/components/ui/StatusBanner.d.ts +1 -10
- package/dist/components/ui/icons.d.ts +13 -0
- package/dist/components/ui/index.d.ts +7 -8
- package/dist/index.cjs.js +31 -42
- package/dist/index.d.ts +10 -12
- package/dist/index.js +27 -38
- package/dist/providerWallet-DDywdl9_.js +2 -0
- package/dist/providerWallet-cDeDz-zR.js +2 -0
- package/dist/providers/custom.css +1 -1
- package/dist/types/assets.d.ts +23 -0
- package/dist/types/authorization.d.ts +5 -2
- package/dist/types/deposit.d.ts +95 -27
- package/dist/types/index.d.ts +2 -0
- package/dist/types/lock.d.ts +44 -0
- package/dist/types/pay.d.ts +30 -0
- package/dist/types/status.d.ts +41 -1
- package/dist/types/supply.d.ts +13 -0
- package/dist/types/ui.d.ts +95 -0
- package/dist/types/wallet.d.ts +31 -0
- package/dist/types/withdraw.d.ts +30 -0
- package/dist/utils/loadFonts.d.ts +1 -0
- package/dist/utils/relayer/index.d.ts +0 -20
- package/dist/utils/tokens.d.ts +43 -0
- package/package.json +1 -18
- package/dist/Button-D5zwqrrP.js +0 -2
- package/dist/Button-KtHGKIo6.js +0 -2
- package/dist/auth-starknet.cjs.js +0 -2
- package/dist/auth-starknet.d.ts +0 -6
- package/dist/auth-starknet.js +0 -2
- package/dist/components/Airdrop/Airdrop.d.ts +0 -28
- package/dist/components/Airdrop/index.d.ts +0 -2
- package/dist/components/DepositWidget/AssetInput.d.ts +0 -23
- package/dist/components/DepositWidget/CrossChainDepositModal.d.ts +0 -42
- package/dist/components/DepositWidget/DepositWidget.d.ts +0 -3
- package/dist/components/DepositWidget/DepositWidgetModal.d.ts +0 -11
- package/dist/components/DepositWidget/index.d.ts +0 -8
- package/dist/components/LpModal/AmountCard.d.ts +0 -11
- package/dist/components/LpModal/CompactAssetSelector.d.ts +0 -11
- package/dist/components/LpModal/LpModal.d.ts +0 -3
- package/dist/components/LpModal/PairInfoCard.d.ts +0 -14
- package/dist/components/LpModal/ProgressIndicators.d.ts +0 -4
- package/dist/components/LpModal/index.d.ts +0 -1
- package/dist/components/StarknetWallet/StarknetWalletButton.d.ts +0 -9
- package/dist/components/StarknetWallet/index.d.ts +0 -2
- package/dist/components/ui/Toast.d.ts +0 -10
- package/dist/hooks/useStarknetWallet.d.ts +0 -13
- package/dist/index-DJQ17ocQ.js +0 -2
- package/dist/index-WLbJouQ7.js +0 -2
- package/dist/providerWallet-DeNDXTJA.js +0 -2
- package/dist/providerWallet-DrwSLBof.js +0 -2
- package/dist/providers/StarknetWalletProvider.d.ts +0 -8
- package/dist/types/lp.d.ts +0 -43
- package/dist/useSpiceBrand-BBtUTOno.js +0 -2
- package/dist/useSpiceBrand-D-06ludX.js +0 -2
package/dist/Button-D5zwqrrP.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import{jsx as y,jsxs as F}from"react/jsx-runtime";import{useRef as j,useEffect as I,useState as h}from"react";const L={spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},borderRadius:{sm:"0.25rem",md:"0.5rem",lg:"0.75rem",full:"9999px"},typography:{fontFamily:'"Helvetica Neue", sans-serif',fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.75rem"},fontWeight:{normal:400,medium:500,semibold:600,bold:700}},shadows:{sm:"0 1px 2px 0 rgb(0 0 0 / 0.05)",md:"0 4px 6px -1px rgb(0 0 0 / 0.1)",lg:"0 10px 15px -3px rgb(0 0 0 / 0.1)"},animation:{fast:"150ms ease-in-out",normal:"200ms ease-in-out",slow:"300ms ease-in-out"}},N={primary:"#EA4B4B",primaryHover:"#E43838",secondary:"#f3f4f6",background:"#ffffff",surface:"#f9fafb",surfaceHover:"#f3f4f6",border:"#e5e7eb",borderHover:"#d1d5db",text:"#111827",textSecondary:"#374151",textMuted:"#6b7280",success:"#10b981",error:"#ef4444",warning:"#f59e0b",info:"#3b82f6"},T={primary:"#EA4B4B",primaryHover:"#E43838",secondary:"#171717",background:"#141414",surface:"#1e1e1e",surfaceHover:"#2a2a2a",border:"#2d2d2d",borderHover:"#3a3a3a",text:"#ffffff",textSecondary:"#888888",textMuted:"#666666",success:"#10b981",error:"#ef4444",warning:"#f59e0b",info:"#3b82f6"},$=(r="light")=>({mode:r,...L,colors:r==="light"?N:T}),S="spiceflow-spinner-keyframes";function A(){if(typeof document>"u"||document.getElementById(S))return;const r=document.createElement("style");r.id=S,r.textContent="@keyframes spiceflow-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}",document.head.appendChild(r)}const k=({size:r=16,borderWidth:d=2,color:s="currentColor",style:p})=>{const n=j(!1);return I(()=>{n.current||(A(),n.current=!0)},[]),y("div",{role:"status","aria-label":"Loading",style:{width:`${r}px`,height:`${r}px`,border:`${d}px solid ${s}`,borderTop:`${d}px solid transparent`,borderRadius:"50%",animation:"spiceflow-spin 1s linear infinite",flexShrink:0,...p}})},D=({variant:r="primary",size:d="md",loading:s=!1,fullWidth:p=!1,disabled:n,children:w,className:z="",style:C,theme:M,styles:e,dark:c=!1,...a})=>{const o=M||$("light"),[f,x]=h(!1),[u,m]=h(!1),b=c?"#111214":"white",v=()=>{switch(r){case"primary":return{backgroundColor:e?.button?.backgroundColor||o.colors.primary,color:e?.button?.color||"#ffffff",border:`1px solid ${e?.button?.backgroundColor||o.colors.primary}`};case"secondary":return{backgroundColor:o.colors.secondary,color:o.colors.text,border:`1px solid ${o.colors.border}`};case"success":return{backgroundColor:o.colors.success,color:o.colors.text,border:`1px solid ${o.colors.success}`};case"error":return{backgroundColor:o.colors.error,color:o.colors.text,border:`1px solid ${o.colors.error}`};case"ghost":return{backgroundColor:"transparent",color:o.colors.textSecondary,border:`1px solid ${o.colors.border}`};case"outline":{const t=e?.button?.backgroundColor||o.colors.primary,g=e?.button?.color||(c?"#ffffff":"#0e0d0b"),i=e?.button?.borderColor||(c?`${o.colors.primary}88`:"#0e0d0b"),l=n||s,R=c?"1px":"1.5px",H=e?.button?.disabledBackgroundColor||`${t}88`,W=e?.button?.disabledColor||g;return{height:"56px",backgroundColor:l?H:u?`${t}cc`:f?`${t}ee`:t,color:l?W:g,border:`${R} solid ${i}`,borderRadius:e?.button?.borderRadius||"12px",fontSize:"22px",fontWeight:500,letterSpacing:"1px",textTransform:"uppercase",fontFamily:'"IBM Plex Mono", monospace',opacity:l?.78:1,transform:l?"none":u?"scale(0.98)":f?"translateY(-2px)":"none",boxShadow:l?`3px 3px 0px ${b}, 4px 4px 0px ${i}`:u?`2px 2px 0px ${i}`:f?`5px 5px 0px ${b}, 6px 6px 0px ${i}`:`3px 3px 0px ${b}, 4px 4px 0px ${i}`,transition:"all 150ms ease"}}default:return{}}},B=()=>{if(r==="outline")return{};switch(d){case"sm":return{padding:`${o.spacing.sm} ${o.spacing.md}`,fontSize:o.typography.fontSize.sm};case"md":return{padding:`${o.spacing.md} ${o.spacing.lg}`,fontSize:o.typography.fontSize.base};case"lg":return{padding:`${o.spacing.lg} ${o.spacing.xl}`,fontSize:o.typography.fontSize.lg};default:return{}}},E={borderRadius:e?.button?.borderRadius||o.borderRadius.md,fontWeight:e?.button?.fontWeight||o.typography.fontWeight.medium,fontFamily:e?.button?.fontFamily||o.typography.fontFamily,fontSize:e?.button?.fontSize||void 0,transition:"all 150ms ease",cursor:n||s?"not-allowed":"pointer",opacity:(n||s)&&r!=="outline"?.6:1,width:p?"100%":"auto",display:"flex",alignItems:"center",justifyContent:"center",gap:o.spacing.sm,...v(),...B(),...e?.button?.fontSize&&{fontSize:e.button.fontSize}};return F("button",{style:{...E,...C},className:z,disabled:n||s,onMouseEnter:t=>{x(!0),a.onMouseEnter?.(t)},onMouseLeave:t=>{x(!1),m(!1),a.onMouseLeave?.(t)},onMouseDown:t=>{m(!0),a.onMouseDown?.(t)},onMouseUp:t=>{m(!1),a.onMouseUp?.(t)},...a,children:[s&&y(k,{size:16}),w]})};export{D as B,k as S,$ as c};
|
package/dist/Button-KtHGKIo6.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";const g=require("react/jsx-runtime"),u=require("react"),j={spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},borderRadius:{sm:"0.25rem",md:"0.5rem",lg:"0.75rem",full:"9999px"},typography:{fontFamily:'"Helvetica Neue", sans-serif',fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.75rem"},fontWeight:{normal:400,medium:500,semibold:600,bold:700}},shadows:{sm:"0 1px 2px 0 rgb(0 0 0 / 0.05)",md:"0 4px 6px -1px rgb(0 0 0 / 0.1)",lg:"0 10px 15px -3px rgb(0 0 0 / 0.1)"},animation:{fast:"150ms ease-in-out",normal:"200ms ease-in-out",slow:"300ms ease-in-out"}},F={primary:"#EA4B4B",primaryHover:"#E43838",secondary:"#f3f4f6",background:"#ffffff",surface:"#f9fafb",surfaceHover:"#f3f4f6",border:"#e5e7eb",borderHover:"#d1d5db",text:"#111827",textSecondary:"#374151",textMuted:"#6b7280",success:"#10b981",error:"#ef4444",warning:"#f59e0b",info:"#3b82f6"},T={primary:"#EA4B4B",primaryHover:"#E43838",secondary:"#171717",background:"#141414",surface:"#1e1e1e",surfaceHover:"#2a2a2a",border:"#2d2d2d",borderHover:"#3a3a3a",text:"#ffffff",textSecondary:"#888888",textMuted:"#666666",success:"#10b981",error:"#ef4444",warning:"#f59e0b",info:"#3b82f6"},$=(r="light")=>({mode:r,...j,colors:r==="light"?F:T}),S="spiceflow-spinner-keyframes";function I(){if(typeof document>"u"||document.getElementById(S))return;const r=document.createElement("style");r.id=S,r.textContent="@keyframes spiceflow-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}",document.head.appendChild(r)}const k=({size:r=16,borderWidth:d=2,color:s="currentColor",style:p})=>{const n=u.useRef(!1);return u.useEffect(()=>{n.current||(I(),n.current=!0)},[]),g.jsx("div",{role:"status","aria-label":"Loading",style:{width:`${r}px`,height:`${r}px`,border:`${d}px solid ${s}`,borderTop:`${d}px solid transparent`,borderRadius:"50%",animation:"spiceflow-spin 1s linear infinite",flexShrink:0,...p}})},L=({variant:r="primary",size:d="md",loading:s=!1,fullWidth:p=!1,disabled:n,children:w,className:z="",style:C,theme:M,styles:o,dark:c=!1,...a})=>{const e=M||$("light"),[f,y]=u.useState(!1),[m,b]=u.useState(!1),x=c?"#111214":"white",v=()=>{switch(r){case"primary":return{backgroundColor:o?.button?.backgroundColor||e.colors.primary,color:o?.button?.color||"#ffffff",border:`1px solid ${o?.button?.backgroundColor||e.colors.primary}`};case"secondary":return{backgroundColor:e.colors.secondary,color:e.colors.text,border:`1px solid ${e.colors.border}`};case"success":return{backgroundColor:e.colors.success,color:e.colors.text,border:`1px solid ${e.colors.success}`};case"error":return{backgroundColor:e.colors.error,color:e.colors.text,border:`1px solid ${e.colors.error}`};case"ghost":return{backgroundColor:"transparent",color:e.colors.textSecondary,border:`1px solid ${e.colors.border}`};case"outline":{const t=o?.button?.backgroundColor||e.colors.primary,h=o?.button?.color||(c?"#ffffff":"#0e0d0b"),i=o?.button?.borderColor||(c?`${e.colors.primary}88`:"#0e0d0b"),l=n||s,E=c?"1px":"1.5px",H=o?.button?.disabledBackgroundColor||`${t}88`,W=o?.button?.disabledColor||h;return{height:"56px",backgroundColor:l?H:m?`${t}cc`:f?`${t}ee`:t,color:l?W:h,border:`${E} solid ${i}`,borderRadius:o?.button?.borderRadius||"12px",fontSize:"22px",fontWeight:500,letterSpacing:"1px",textTransform:"uppercase",fontFamily:'"IBM Plex Mono", monospace',opacity:l?.78:1,transform:l?"none":m?"scale(0.98)":f?"translateY(-2px)":"none",boxShadow:l?`3px 3px 0px ${x}, 4px 4px 0px ${i}`:m?`2px 2px 0px ${i}`:f?`5px 5px 0px ${x}, 6px 6px 0px ${i}`:`3px 3px 0px ${x}, 4px 4px 0px ${i}`,transition:"all 150ms ease"}}default:return{}}},B=()=>{if(r==="outline")return{};switch(d){case"sm":return{padding:`${e.spacing.sm} ${e.spacing.md}`,fontSize:e.typography.fontSize.sm};case"md":return{padding:`${e.spacing.md} ${e.spacing.lg}`,fontSize:e.typography.fontSize.base};case"lg":return{padding:`${e.spacing.lg} ${e.spacing.xl}`,fontSize:e.typography.fontSize.lg};default:return{}}},R={borderRadius:o?.button?.borderRadius||e.borderRadius.md,fontWeight:o?.button?.fontWeight||e.typography.fontWeight.medium,fontFamily:o?.button?.fontFamily||e.typography.fontFamily,fontSize:o?.button?.fontSize||void 0,transition:"all 150ms ease",cursor:n||s?"not-allowed":"pointer",opacity:(n||s)&&r!=="outline"?.6:1,width:p?"100%":"auto",display:"flex",alignItems:"center",justifyContent:"center",gap:e.spacing.sm,...v(),...B(),...o?.button?.fontSize&&{fontSize:o.button.fontSize}};return g.jsxs("button",{style:{...R,...C},className:z,disabled:n||s,onMouseEnter:t=>{y(!0),a.onMouseEnter?.(t)},onMouseLeave:t=>{y(!1),b(!1),a.onMouseLeave?.(t)},onMouseDown:t=>{b(!0),a.onMouseDown?.(t)},onMouseUp:t=>{b(!1),a.onMouseUp?.(t)},...a,children:[s&&g.jsx(k,{size:16}),w]})};exports.Button=L,exports.Spinner=k,exports.createTheme=$;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";var A=Object.create;var C=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var _=(e,a,l,u)=>{if(a&&typeof a=="object"||typeof a=="function")for(let t of E(a))!z.call(e,t)&&t!==l&&C(e,t,{get:()=>a[t],enumerable:!(u=P(a,t))||u.enumerable});return e};var h=(e,a,l)=>(l=e!=null?A(R(e)):{},_(a||!e||!e.__esModule?C(l,"default",{value:e,enumerable:!0}):l,e));const r=require("react"),y=require("@spicenet-io/spiceflow-core"),c=require("react/jsx-runtime"),D=require("./useSpiceBrand-BBtUTOno.js"),v=require("./Button-KtHGKIo6.js");require("./index-WLbJouQ7.js"),require("viem"),require("viem/actions");const S="spiceflow:starknet-wallet-connected",T=y.getChainMeta(y.STARKNET_MAINNET_CHAIN_ID)?.rpcUrl??"https://starknet-mainnet.public.blastapi.io",W=(e=T)=>{const[a,l]=r.useState(null),[u,t]=r.useState(!1),[d,p]=r.useState(null),[f,w]=r.useState(null),[g,I]=r.useState(null),x=r.useRef(null);r.useEffect(()=>{import("starknet").then(({RpcProvider:n})=>{I(new n({nodeUrl:e}))}).catch(()=>{})},[e]);const q=r.useCallback(n=>n?`${n.slice(0,6)}...${n.slice(-4)}`:"",[]),k=r.useCallback(async(n,s)=>{const o=await n.enable(s),i=(await o.request({type:"wallet_requestAccounts"}))?.[0];return i?(x.current=o,l(i),w(s.name||s.id),localStorage.setItem(S,s.id),p(o),!0):!1},[g,e]),B=r.useCallback(async()=>{t(!0);try{const{getStarknet:n}=await import("get-starknet-core"),s=n(),o=await s.getAvailableWallets();if(o.length===0)return window.open("https://www.argent.xyz/argent-x/","_blank"),t(!1),!1;const i=o.find(m=>m.id==="argentX")||o.find(m=>m.id==="braavos")||o[0];return await k(s,i)}catch(n){const s=n instanceof Error?n.message:String(n);return console.error("[SpiceFlow:StarkNet] Connection failed:",s),!1}finally{t(!1)}},[k]),j=r.useCallback(()=>{l(null),p(null),w(null),x.current=null,localStorage.removeItem(S)},[]);return r.useEffect(()=>{const n=localStorage.getItem(S);n&&(async()=>{try{const{getStarknet:s}=await import("get-starknet-core"),o=s(),i=(await o.getAuthorizedWallets()).find(m=>m.id===n);if(!i){localStorage.removeItem(S);return}await k(o,i)}catch{localStorage.removeItem(S)}})()},[k]),{address:a,isConnected:!!a,isConnecting:u,account:d,provider:g,walletName:f,connect:B,disconnect:j,formatAddress:q}},b=r.createContext(null),U=({children:e,rpcUrl:a})=>{const l=W(a);return c.jsx(b.Provider,{value:l,children:e})},N=()=>{const e=r.useContext(b);if(!e)throw new Error("useStarknetWalletContext must be used within a <StarknetWalletProvider>. Wrap your StarkNet section with <StarknetWalletProvider> from '@spicenet-io/spiceflow-ui/auth/starknet'.");return e},$=({className:e,styles:a,onConnect:l,onDisconnect:u})=>{const t=N(),{dk:d,dark:p,theme:f}=D.useSpiceBrand(a),w=async()=>{await t.connect()&&l?.()},g=()=>{t.disconnect(),u?.()};return t.isConnected&&t.address?c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},className:e,children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",background:d.cardBg,border:`1px solid ${d.cardBorder}`,fontSize:"14px",minWidth:0},children:[c.jsx("span",{style:{fontWeight:500,color:d.textPrimary},children:t.formatAddress(t.address)}),t.walletName&&c.jsxs("span",{style:{color:d.textSecondary,fontSize:"12px",maxWidth:"120px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["(",t.walletName,")"]})]}),c.jsx(v.Button,{variant:"ghost",size:"sm",onClick:g,title:"Disconnect StarkNet wallet",dark:p,theme:f,children:"\u2715"})]}):c.jsx(v.Button,{variant:"primary",onClick:w,disabled:t.isConnecting,loading:t.isConnecting,className:e,dark:p,theme:f,children:t.isConnecting?"Connecting...":"Connect StarkNet Wallet"})};exports.StarknetWalletButton=$,exports.StarknetWalletProvider=U,exports.useStarknetWallet=W,exports.useStarknetWalletContext=N;
|
package/dist/auth-starknet.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { useStarknetWallet } from "./hooks/useStarknetWallet";
|
|
2
|
-
export type { StarknetWalletState } from "./hooks/useStarknetWallet";
|
|
3
|
-
export { StarknetWalletProvider, useStarknetWalletContext } from "./providers/StarknetWalletProvider";
|
|
4
|
-
export type { StarknetWalletProviderProps } from "./providers/StarknetWalletProvider";
|
|
5
|
-
export { StarknetWalletButton } from "./components/StarknetWallet/StarknetWalletButton";
|
|
6
|
-
export type { StarknetWalletButtonProps } from "./components/StarknetWallet/StarknetWalletButton";
|
package/dist/auth-starknet.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import{useState as u,useRef as z,useEffect as C,useCallback as h,createContext as E,useContext as R}from"react";import{getChainMeta as _,STARKNET_MAINNET_CHAIN_ID as D}from"@spicenet-io/spiceflow-core";import{jsx as S,jsxs as x}from"react/jsx-runtime";import{u as T}from"./useSpiceBrand-D-06ludX.js";import{B as v}from"./Button-D5zwqrrP.js";import"./index-DJQ17ocQ.js";import"viem";import"viem/actions";const p="spiceflow:starknet-wallet-connected",U=_(D)?.rpcUrl??"https://starknet-mainnet.public.blastapi.io",N=(n=U)=>{const[l,i]=u(null),[k,t]=u(!1),[s,c]=u(null),[m,f]=u(null),[g,I]=u(null),y=z(null);C(()=>{import("starknet").then(({RpcProvider:e})=>{I(new e({nodeUrl:n}))}).catch(()=>{})},[n]);const A=h(e=>e?`${e.slice(0,6)}...${e.slice(-4)}`:"",[]),w=h(async(e,r)=>{const a=await e.enable(r),o=(await a.request({type:"wallet_requestAccounts"}))?.[0];return o?(y.current=a,i(o),f(r.name||r.id),localStorage.setItem(p,r.id),c(a),!0):!1},[g,n]),B=h(async()=>{t(!0);try{const{getStarknet:e}=await import("get-starknet-core"),r=e(),a=await r.getAvailableWallets();if(a.length===0)return window.open("https://www.argent.xyz/argent-x/","_blank"),t(!1),!1;const o=a.find(d=>d.id==="argentX")||a.find(d=>d.id==="braavos")||a[0];return await w(r,o)}catch(e){const r=e instanceof Error?e.message:String(e);return console.error("[SpiceFlow:StarkNet] Connection failed:",r),!1}finally{t(!1)}},[w]),P=h(()=>{i(null),c(null),f(null),y.current=null,localStorage.removeItem(p)},[]);return C(()=>{const e=localStorage.getItem(p);e&&(async()=>{try{const{getStarknet:r}=await import("get-starknet-core"),a=r(),o=(await a.getAuthorizedWallets()).find(d=>d.id===e);if(!o){localStorage.removeItem(p);return}await w(a,o)}catch{localStorage.removeItem(p)}})()},[w]),{address:l,isConnected:!!l,isConnecting:k,account:s,provider:g,walletName:m,connect:B,disconnect:P,formatAddress:A}},W=E(null),$=({children:n,rpcUrl:l})=>{const i=N(l);return S(W.Provider,{value:i,children:n})},b=()=>{const n=R(W);if(!n)throw new Error("useStarknetWalletContext must be used within a <StarknetWalletProvider>. Wrap your StarkNet section with <StarknetWalletProvider> from '@spicenet-io/spiceflow-ui/auth/starknet'.");return n},j=({className:n,styles:l,onConnect:i,onDisconnect:k})=>{const t=b(),{dk:s,dark:c,theme:m}=T(l),f=async()=>{await t.connect()&&i?.()},g=()=>{t.disconnect(),k?.()};return t.isConnected&&t.address?x("div",{style:{display:"flex",alignItems:"center",gap:"8px"},className:n,children:[x("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",background:s.cardBg,border:`1px solid ${s.cardBorder}`,fontSize:"14px",minWidth:0},children:[S("span",{style:{fontWeight:500,color:s.textPrimary},children:t.formatAddress(t.address)}),t.walletName&&x("span",{style:{color:s.textSecondary,fontSize:"12px",maxWidth:"120px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["(",t.walletName,")"]})]}),S(v,{variant:"ghost",size:"sm",onClick:g,title:"Disconnect StarkNet wallet",dark:c,theme:m,children:"\u2715"})]}):S(v,{variant:"primary",onClick:f,disabled:t.isConnecting,loading:t.isConnecting,className:n,dark:c,theme:m,children:t.isConnecting?"Connecting...":"Connect StarkNet Wallet"})};export{j as StarknetWalletButton,$ as StarknetWalletProvider,N as useStarknetWallet,b as useStarknetWalletContext};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
export interface AirdropToken {
|
|
3
|
-
address: string;
|
|
4
|
-
symbol: string;
|
|
5
|
-
name: string;
|
|
6
|
-
decimals: number;
|
|
7
|
-
balance?: bigint;
|
|
8
|
-
balanceFormatted?: number;
|
|
9
|
-
}
|
|
10
|
-
export interface AirdropModalProps {
|
|
11
|
-
isOpen: boolean;
|
|
12
|
-
onClose: () => void;
|
|
13
|
-
onComplete?: () => void;
|
|
14
|
-
title?: string;
|
|
15
|
-
description?: string;
|
|
16
|
-
chainId: number;
|
|
17
|
-
airdropTag?: string;
|
|
18
|
-
walletAddress: string;
|
|
19
|
-
airdropTokens: string[];
|
|
20
|
-
getChainConfig: (chainId: number) => any;
|
|
21
|
-
getSupportedTokens: (chainId: number) => Array<{
|
|
22
|
-
address: string;
|
|
23
|
-
symbol: string;
|
|
24
|
-
name: string;
|
|
25
|
-
decimals: number;
|
|
26
|
-
}>;
|
|
27
|
-
}
|
|
28
|
-
export declare const AirdropModal: React.FC<AirdropModalProps>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { CustomStyles, Theme } from "../../types/theme";
|
|
3
|
-
export interface AssetInputAsset {
|
|
4
|
-
address: string;
|
|
5
|
-
symbol: string;
|
|
6
|
-
name: string;
|
|
7
|
-
decimals: number;
|
|
8
|
-
chainId: number;
|
|
9
|
-
logoURI?: string;
|
|
10
|
-
balance?: bigint;
|
|
11
|
-
balanceFormatted?: number;
|
|
12
|
-
}
|
|
13
|
-
export interface AssetInputProps {
|
|
14
|
-
asset: AssetInputAsset;
|
|
15
|
-
amount: string;
|
|
16
|
-
onAmountChange: (amount: string) => void;
|
|
17
|
-
onPercentageClick: (percentage: number) => void;
|
|
18
|
-
usdValue?: string;
|
|
19
|
-
disabled?: boolean;
|
|
20
|
-
styles?: CustomStyles;
|
|
21
|
-
theme: Theme;
|
|
22
|
-
}
|
|
23
|
-
export declare const AssetInput: React.FC<AssetInputProps>;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
export interface Asset {
|
|
3
|
-
address: string;
|
|
4
|
-
symbol: string;
|
|
5
|
-
name: string;
|
|
6
|
-
decimals: number;
|
|
7
|
-
isNative: boolean;
|
|
8
|
-
chainId: number;
|
|
9
|
-
balance?: bigint;
|
|
10
|
-
balanceFormatted?: number;
|
|
11
|
-
}
|
|
12
|
-
export interface SelectedAssetWithAmount {
|
|
13
|
-
asset: Asset;
|
|
14
|
-
amount: string;
|
|
15
|
-
}
|
|
16
|
-
export interface DepositResult {
|
|
17
|
-
asset: Asset;
|
|
18
|
-
txHash: string;
|
|
19
|
-
success: boolean;
|
|
20
|
-
error?: string;
|
|
21
|
-
}
|
|
22
|
-
export interface CrossChainDepositModalProps {
|
|
23
|
-
isOpen: boolean;
|
|
24
|
-
onClose: () => void;
|
|
25
|
-
onComplete: () => void;
|
|
26
|
-
title?: string;
|
|
27
|
-
description?: string;
|
|
28
|
-
chainId: 11155111 | 421614 | 84532 | undefined;
|
|
29
|
-
embeddedWalletAddress: string;
|
|
30
|
-
externalWalletAddress: string;
|
|
31
|
-
escrowAddress?: string;
|
|
32
|
-
supportedChains: number[];
|
|
33
|
-
airdropTokenSymbol?: string;
|
|
34
|
-
getChainConfig: (chainId: number) => any;
|
|
35
|
-
getSupportedTokens: (chainId: number) => Array<{
|
|
36
|
-
address: string;
|
|
37
|
-
symbol: string;
|
|
38
|
-
name: string;
|
|
39
|
-
decimals: number;
|
|
40
|
-
}>;
|
|
41
|
-
}
|
|
42
|
-
export declare const CrossChainDepositModal: React.FC<CrossChainDepositModalProps>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { DepositWidgetProps } from "../../types/deposit";
|
|
3
|
-
export interface DepositWidgetModalProps extends DepositWidgetProps {
|
|
4
|
-
isOpen: boolean;
|
|
5
|
-
onClose: () => void;
|
|
6
|
-
title?: string;
|
|
7
|
-
description?: React.ReactNode;
|
|
8
|
-
maxWidth?: string;
|
|
9
|
-
onComplete?: () => void;
|
|
10
|
-
}
|
|
11
|
-
export declare const DepositWidgetModal: React.FC<DepositWidgetModalProps>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { DepositWidget } from "./DepositWidget";
|
|
2
|
-
export { DepositWidgetModal } from "./DepositWidgetModal";
|
|
3
|
-
export type { DepositWidgetProps } from "../../types/deposit";
|
|
4
|
-
export type { DepositWidgetModalProps } from "./DepositWidgetModal";
|
|
5
|
-
export { CrossChainDepositModal } from "./CrossChainDepositModal";
|
|
6
|
-
export type { CrossChainDepositModalProps } from "./CrossChainDepositModal";
|
|
7
|
-
export { AssetInput } from "./AssetInput";
|
|
8
|
-
export type { AssetInputProps, AssetInputAsset } from "./AssetInput";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Asset } from "../../types/assets";
|
|
3
|
-
import { CustomStyles, Theme } from "../../types/theme";
|
|
4
|
-
export declare const AmountCard: React.FC<{
|
|
5
|
-
assetInput: any;
|
|
6
|
-
availableAssets: Asset[];
|
|
7
|
-
onAssetChange: (asset: Asset | null, amount: string) => void;
|
|
8
|
-
disabled?: boolean;
|
|
9
|
-
styles?: CustomStyles;
|
|
10
|
-
theme: Theme;
|
|
11
|
-
}>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Asset } from "../../types/assets";
|
|
3
|
-
import { CustomStyles, Theme } from "../../types/theme";
|
|
4
|
-
export declare const CompactAssetSelector: React.FC<{
|
|
5
|
-
selectedAsset?: any;
|
|
6
|
-
availableAssets: Asset[];
|
|
7
|
-
onAssetSelect: (asset: Asset) => void;
|
|
8
|
-
disabled?: boolean;
|
|
9
|
-
styles?: CustomStyles;
|
|
10
|
-
theme: Theme;
|
|
11
|
-
}>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Asset } from "../../types/assets";
|
|
3
|
-
import { CustomStyles, Theme } from "../../types/theme";
|
|
4
|
-
export declare const PairInfoCard: React.FC<{
|
|
5
|
-
pairLabel: string;
|
|
6
|
-
pairApr: string;
|
|
7
|
-
pairAddressLabel: string;
|
|
8
|
-
lpLabel: string;
|
|
9
|
-
onViewPool?: () => void;
|
|
10
|
-
styles?: CustomStyles;
|
|
11
|
-
theme: Theme;
|
|
12
|
-
token1?: Asset;
|
|
13
|
-
token2?: Asset;
|
|
14
|
-
}>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { LpModal } from "./LpModal";
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { CustomStyles } from "../../types/theme";
|
|
3
|
-
export interface StarknetWalletButtonProps {
|
|
4
|
-
className?: string;
|
|
5
|
-
styles?: CustomStyles;
|
|
6
|
-
onConnect?: () => void;
|
|
7
|
-
onDisconnect?: () => void;
|
|
8
|
-
}
|
|
9
|
-
export declare const StarknetWalletButton: React.FC<StarknetWalletButtonProps>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { AccountInterface, RpcProvider as RpcProviderType } from "starknet";
|
|
2
|
-
export interface StarknetWalletState {
|
|
3
|
-
address: string | null;
|
|
4
|
-
isConnected: boolean;
|
|
5
|
-
isConnecting: boolean;
|
|
6
|
-
account: AccountInterface | null;
|
|
7
|
-
provider: RpcProviderType | null;
|
|
8
|
-
walletName: string | null;
|
|
9
|
-
connect: () => Promise<boolean>;
|
|
10
|
-
disconnect: () => void;
|
|
11
|
-
formatAddress: (addr: string) => string;
|
|
12
|
-
}
|
|
13
|
-
export declare const useStarknetWallet: (rpcUrl?: string) => StarknetWalletState;
|
package/dist/index-DJQ17ocQ.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import{defineChain as h,createPublicClient as C,http as v,isAddress as w,getAddress as g}from"viem";import{readContract as E}from"viem/actions";import{getChainMeta as d,getTokensForChain as I,getDelegateContract as N,ZERO_ADDRESS as k,isNativeToken as m}from"@spicenet-io/spiceflow-core";const y=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{payable:!0,stateMutability:"payable",type:"fallback"},{anonymous:!1,inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Transfer",type:"event"}],x="0xcA11bde05977b3631167028862bE2a173976CA11",U={4114:"0x860aFc632a6D625B95d8B96f39ECC48E988c6962"},$=new Set([5115]);function _(e){const t=U[e.id]??($.has(e.id)?void 0:x);return h({id:e.id,name:e.name,nativeCurrency:e.nativeCurrency,rpcUrls:{default:{http:[e.rpcUrl]}},blockExplorers:{default:{name:e.displayName,url:e.blockExplorer}},testnet:e.network==="testnet",...t?{contracts:{multicall3:{address:t}}}:{}})}const A=[1,8453,42161,4114,11155111,421614,84532,5115,123420001114,688688,688689],l=Object.fromEntries(A.map(e=>d(e)).filter(e=>e!=null).map(e=>[e.id,{...e,viemChain:_(e),supportedTokens:I(e.id)}])),M=l;let f={};const u=new Map,D=e=>{f={...e||{}},u.clear()},c=e=>{const t=f[e];return t&&typeof t=="string"&&t.length>0?t:l[e]?.rpcUrl},i=e=>l[e],F=e=>{const t=d(e);return t?.displayName||t?.name||`Chain ${e}`},T=e=>{const t=N(e);if(!t)throw new Error(`Unsupported chain ID: ${e}`);return t},R=(e,t,n)=>{const s=i(e);return s?.blockExplorer?`${s.blockExplorer}/tx/${t}`:"#"},b=e=>{const t=i(e);if(!t)throw new Error(`Unsupported chain ID: ${e}`);const n=c(e);if(!n)throw new Error(`No RPC URL configured for chain ID: ${e}`);const s=`${e}:${n}`,r=u.get(s);if(r)return r;const a=C({chain:t.viemChain,transport:v(n,{timeout:15e3,retryCount:2,retryDelay:300}),batch:{multicall:{wait:16}}});return u.set(s,a),a},O=()=>{const e={};return Object.values(l).forEach(t=>{e[t.id]={name:t.name,moralisName:t.moralisId||"",chain:t.viemChain,rpcUrl:c(t.id)||t.rpcUrl}}),e},S=(e,t=[])=>{const n=i(e);if(!n)return[];const s=[];if(![11155111,421614,84532,688689].includes(e)){const a=t.find(o=>o.chainId===e&&o.isNative);a?s.push(a):s.push({address:k,name:n.nativeCurrency.name,symbol:n.nativeCurrency.symbol,decimals:n.nativeCurrency.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:void 0,isNative:!0,chainId:e})}if(!n.supportedTokens)return s;const r=s.some(a=>a.isNative);return n.supportedTokens.forEach(a=>{if(r&&m(a.address))return;const o=t.find(p=>p.chainId===e&&p.address.toLowerCase()===a.address.toLowerCase());o?s.push(o):s.push({address:a.address,name:a.name,symbol:a.symbol,decimals:a.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:a.logo,isNative:!1,chainId:e})}),s},L=async(e,t)=>{const n=i(e);if(!n)throw new Error(`Unsupported chain ID: ${e}`);const s=t.toLowerCase();if(m(s)){if(!n.nativeCurrency?.decimals)throw new Error(`Native currency decimals not configured for chain ${e}`);return n.nativeCurrency.decimals}if(n.supportedTokens){const r=n.supportedTokens.find(a=>a.address.toLowerCase()===s);if(r)return r.decimals}try{if(!w(t,{strict:!1}))throw new Error(`Invalid token address: ${t}`);const r=g(t),a=b(e),o=await E(a,{address:r,abi:y,functionName:"decimals"});return Number(o)}catch{throw new Error(`Could not determine decimals for token ${t} on chain ${e}`)}};export{M as C,y as K,F as a,b,O as c,R as d,T as e,S as f,i as g,c as h,L as i,D as s};
|
package/dist/index-WLbJouQ7.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";const l=require("viem"),C=require("viem/actions"),o=require("@spicenet-io/spiceflow-core"),y=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{payable:!0,stateMutability:"payable",type:"fallback"},{anonymous:!1,inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Transfer",type:"event"}],h="0xcA11bde05977b3631167028862bE2a173976CA11",g={4114:"0x860aFc632a6D625B95d8B96f39ECC48E988c6962"},v=new Set([5115]);function w(e){const t=g[e.id]??(v.has(e.id)?void 0:h);return l.defineChain({id:e.id,name:e.name,nativeCurrency:e.nativeCurrency,rpcUrls:{default:{http:[e.rpcUrl]}},blockExplorers:{default:{name:e.displayName,url:e.blockExplorer}},testnet:e.network==="testnet",...t?{contracts:{multicall3:{address:t}}}:{}})}const E=[1,8453,42161,4114,11155111,421614,84532,5115,123420001114,688688,688689],u=Object.fromEntries(E.map(e=>o.getChainMeta(e)).filter(e=>e!=null).map(e=>[e.id,{...e,viemChain:w(e),supportedTokens:o.getTokensForChain(e.id)}])),N=u;let f={};const p=new Map,I=e=>{f={...e||{}},p.clear()},d=e=>{const t=f[e];return t&&typeof t=="string"&&t.length>0?t:u[e]?.rpcUrl},c=e=>u[e],k=e=>{const t=o.getChainMeta(e);return t?.displayName||t?.name||`Chain ${e}`},A=e=>{const t=o.getDelegateContract(e);if(!t)throw new Error(`Unsupported chain ID: ${e}`);return t},U=(e,t,n)=>{const s=c(e);return s?.blockExplorer?`${s.blockExplorer}/tx/${t}`:"#"},b=e=>{const t=c(e);if(!t)throw new Error(`Unsupported chain ID: ${e}`);const n=d(e);if(!n)throw new Error(`No RPC URL configured for chain ID: ${e}`);const s=`${e}:${n}`,r=p.get(s);if(r)return r;const a=l.createPublicClient({chain:t.viemChain,transport:l.http(n,{timeout:15e3,retryCount:2,retryDelay:300}),batch:{multicall:{wait:16}}});return p.set(s,a),a},F=()=>{const e={};return Object.values(u).forEach(t=>{e[t.id]={name:t.name,moralisName:t.moralisId||"",chain:t.viemChain,rpcUrl:d(t.id)||t.rpcUrl}}),e},x=(e,t=[])=>{const n=c(e);if(!n)return[];const s=[];if(![11155111,421614,84532,688689].includes(e)){const a=t.find(i=>i.chainId===e&&i.isNative);a?s.push(a):s.push({address:o.ZERO_ADDRESS,name:n.nativeCurrency.name,symbol:n.nativeCurrency.symbol,decimals:n.nativeCurrency.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:void 0,isNative:!0,chainId:e})}if(!n.supportedTokens)return s;const r=s.some(a=>a.isNative);return n.supportedTokens.forEach(a=>{if(r&&o.isNativeToken(a.address))return;const i=t.find(m=>m.chainId===e&&m.address.toLowerCase()===a.address.toLowerCase());i?s.push(i):s.push({address:a.address,name:a.name,symbol:a.symbol,decimals:a.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:a.logo,isNative:!1,chainId:e})}),s},_=async(e,t)=>{const n=c(e);if(!n)throw new Error(`Unsupported chain ID: ${e}`);const s=t.toLowerCase();if(o.isNativeToken(s)){if(!n.nativeCurrency?.decimals)throw new Error(`Native currency decimals not configured for chain ${e}`);return n.nativeCurrency.decimals}if(n.supportedTokens){const r=n.supportedTokens.find(a=>a.address.toLowerCase()===s);if(r)return r.decimals}try{if(!l.isAddress(t,{strict:!1}))throw new Error(`Invalid token address: ${t}`);const r=l.getAddress(t),a=b(e),i=await C.readContract(a,{address:r,abi:y,functionName:"decimals"});return Number(i)}catch{throw new Error(`Could not determine decimals for token ${t} on chain ${e}`)}};exports.CHAIN_CONFIGS=N,exports.K=y,exports.getAllAssetsForChain=x,exports.getChainConfig=c,exports.getChainName=k,exports.getChainsForAssets=F,exports.getClientForChain=b,exports.getDelegateContractAddress=A,exports.getExplorerUrl=U,exports.getRpcUrlForChain=d,exports.getTokenDecimals=_,exports.setRpcOverrides=I;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import{createWalletClient as l,custom as d}from"viem";import{g as c}from"./index-DJQ17ocQ.js";const o=t=>{if(!t)return!1;const e=t.connector;if(!e)return!1;if(e.isEmbeddedWallet===!0)return!0;const r=(e.key||e.connectorKey||"").toLowerCase();if(r.includes("embedded")||r.includes("turnkey"))return!0;const n=(e.name||t.walletName||"").toLowerCase();return!!(n.includes("embedded")||n.includes("turnkey"))},u=t=>(t?.connectedWallets||[]).find(e=>o(e))||(o(t?.primaryWallet)?t.primaryWallet:null),f=t=>(t?.connectedWallets||[]).find(e=>e?.address&&e?.connector&&!o(e))||null,i=async(t,e)=>{if(!t?.address)throw new Error("Wallet not available");if(typeof t.getWalletClient=="function"){const r=e===void 0?[void 0]:[String(e),e,void 0];let n=null;for(const s of r)try{const a=await t.getWalletClient(s);if(a)return a}catch(a){n=a}if(n)throw n}if(typeof t.getEthereumProvider=="function"){const r=await t.getEthereumProvider(),n=e?c(e)?.viemChain:void 0;return l({account:t.address,chain:n,transport:d(r)})}throw new Error("Wallet client not available")},m=async(t,e)=>{if(!t?.address)throw new Error("Wallet not available");if(typeof t.getEthereumProvider=="function")return t.getEthereumProvider();const r=await i(t,e);return{request:n=>r.request(n)}},y=(t,e)=>({address:t?.address||e.address,chainId:Number(t?.chainId??e.chainId),contractAddress:t?.contractAddress||t?.delegate||e.contractAddress,nonce:BigInt(t?.nonce??e.nonce),r:t?.r,s:t?.s,yParity:(()=>{if(typeof t?.yParity=="number")return t.yParity;const r=Number(t?.v??27);return Number.isFinite(r)?r>=27?r-27:r:0})()});export{m as a,f as b,i as c,u as g,y as n};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";const o=require("viem"),c=require("./index-WLbJouQ7.js"),a=e=>{if(!e)return!1;const t=e.connector;if(!t)return!1;if(t.isEmbeddedWallet===!0)return!0;const r=(t.key||t.connectorKey||"").toLowerCase();if(r.includes("embedded")||r.includes("turnkey"))return!0;const n=(t.name||e.walletName||"").toLowerCase();return!!(n.includes("embedded")||n.includes("turnkey"))},s=e=>(e?.connectedWallets||[]).find(t=>a(t))||(a(e?.primaryWallet)?e.primaryWallet:null),u=e=>(e?.connectedWallets||[]).find(t=>t?.address&&t?.connector&&!a(t))||null,l=async(e,t)=>{if(!e?.address)throw new Error("Wallet not available");if(typeof e.getWalletClient=="function"){const r=t===void 0?[void 0]:[String(t),t,void 0];let n=null;for(const d of r)try{const i=await e.getWalletClient(d);if(i)return i}catch(i){n=i}if(n)throw n}if(typeof e.getEthereumProvider=="function"){const r=await e.getEthereumProvider(),n=t?c.getChainConfig(t)?.viemChain:void 0;return o.createWalletClient({account:e.address,chain:n,transport:o.custom(r)})}throw new Error("Wallet client not available")},m=async(e,t)=>{if(!e?.address)throw new Error("Wallet not available");if(typeof e.getEthereumProvider=="function")return e.getEthereumProvider();const r=await l(e,t);return{request:n=>r.request(n)}},f=(e,t)=>({address:e?.address||t.address,chainId:Number(e?.chainId??t.chainId),contractAddress:e?.contractAddress||e?.delegate||t.contractAddress,nonce:BigInt(e?.nonce??t.nonce),r:e?.r,s:e?.s,yParity:(()=>{if(typeof e?.yParity=="number")return e.yParity;const r=Number(e?.v??27);return Number.isFinite(r)?r>=27?r-27:r:0})()});exports.getDynamicEmbeddedWallet=s,exports.getDynamicExternalWallet=u,exports.getProviderEthereumProvider=m,exports.getProviderWalletClient=l,exports.normalizeAuthorization=f;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { type StarknetWalletState } from "../hooks/useStarknetWallet";
|
|
3
|
-
export interface StarknetWalletProviderProps {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
rpcUrl?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const StarknetWalletProvider: React.FC<StarknetWalletProviderProps>;
|
|
8
|
-
export declare const useStarknetWalletContext: () => StarknetWalletState;
|
package/dist/types/lp.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { SelectedAsset, Asset } from "./assets";
|
|
2
|
-
import { CustomStyles } from "./theme";
|
|
3
|
-
export interface LpAssetInput {
|
|
4
|
-
selectedAsset?: SelectedAsset;
|
|
5
|
-
usdValue: string;
|
|
6
|
-
balanceLabel: string;
|
|
7
|
-
progressIndex?: number;
|
|
8
|
-
}
|
|
9
|
-
export interface CrossNetworkCopy {
|
|
10
|
-
summary: string;
|
|
11
|
-
body: string;
|
|
12
|
-
}
|
|
13
|
-
export interface TransactionDetail {
|
|
14
|
-
label: string;
|
|
15
|
-
value: string;
|
|
16
|
-
isPositive?: boolean;
|
|
17
|
-
}
|
|
18
|
-
export interface LpModalProps {
|
|
19
|
-
isOpen: boolean;
|
|
20
|
-
onClose: () => void;
|
|
21
|
-
pairLabel: string;
|
|
22
|
-
pairApr: string;
|
|
23
|
-
pairAddressLabel: string;
|
|
24
|
-
lpLabel: string;
|
|
25
|
-
onViewPool?: () => void;
|
|
26
|
-
primaryAsset: LpAssetInput;
|
|
27
|
-
secondaryAsset?: LpAssetInput;
|
|
28
|
-
onPrimaryAssetChange: (asset: Asset | null, amount: string) => void;
|
|
29
|
-
onSecondaryAssetChange?: (asset: Asset | null, amount: string) => void;
|
|
30
|
-
availableAssets: Asset[];
|
|
31
|
-
showSecondaryAsset: boolean;
|
|
32
|
-
onAddSecondaryAsset?: () => void;
|
|
33
|
-
alertVariant?: "none" | "crossNetworkAssets" | "noCollateral";
|
|
34
|
-
crossNetworkCopy?: CrossNetworkCopy;
|
|
35
|
-
onClickDepositCollateral?: () => void;
|
|
36
|
-
transactionDetailsCollapsed?: boolean;
|
|
37
|
-
onToggleTransactionDetails?: () => void;
|
|
38
|
-
transactionDetails?: TransactionDetail[];
|
|
39
|
-
isSubmitting?: boolean;
|
|
40
|
-
canSubmit?: boolean;
|
|
41
|
-
onSubmit: () => void;
|
|
42
|
-
styles?: CustomStyles;
|
|
43
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";const p=require("react"),b=require("react/jsx-runtime"),S=require("@spicenet-io/spiceflow-core"),g=require("./index-WLbJouQ7.js"),T=require("viem"),A=require("./Button-KtHGKIo6.js");class d extends Error{constructor(t,r,e={}){super(r),this.code=t,this.context=e,this.name="SpiceflowError",Error.captureStackTrace&&Error.captureStackTrace(this,d)}}function _(o){return o instanceof d}const $=typeof process<"u"&&process.env?.NEXT_PUBLIC_RELAYER_API_URL||"https://tx-api-devserver.spicenet.io",v="__SPICEFLOW_RELAYER_API_URL__";function L(o,t){const r=t.match(/Output amount (\d+) is insufficient after fees (\d+) on chain (\d+)/);if(!r)return t;const[,e,a,s]=r,c=Number(s),n=BigInt(e),i=BigInt(a);let f;for(const l of o.intents){const R=l.chainBatches.find(O=>O.chainId===c);if(R){f=R;break}}const u=f?.tokenTransfers.find(l=>l.from==="escrow"&&l.to.toLowerCase()===o.user.toLowerCase()&&!S.isNativeToken(l.token));if(!u)return`Amount is too small to cover the estimated fee on ${g.getChainName(c)}.`;const h=S.getTokenByAddress(u.token,c),B=h?.decimals??18,w=h?.symbol??"tokens",E=T.formatUnits(n,B),x=T.formatUnits(i,B);return`Amount is too small to cover the estimated fee on ${g.getChainName(c)}. Amount: ${E} ${w}. Estimated fee: ${x} ${w}.`}function N(){if(typeof globalThis>"u")return;const o=globalThis[v];return typeof o=="string"&&o.length>0?o:void 0}class F{constructor(){this.baseUrl=$}setBaseUrl(t){this.baseUrl=t,typeof globalThis<"u"&&(globalThis[v]=t)}getBaseUrl(){return this.getEffectiveBaseUrl()}getEffectiveBaseUrl(){return N()||this.baseUrl}async createAction(t){const r=await fetch(`${this.getEffectiveBaseUrl()}/actions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t,(e,a)=>typeof a=="bigint"?a.toString():a)});if(!r.ok){const e=await r.text();throw new d("RELAYER_ERROR",`Relayer API error: ${r.status} - ${e}`,{httpStatus:r.status,responseBody:e,endpoint:"/actions"})}return await r.json()}async estimateActionFees(t){const r=await fetch(`${this.getEffectiveBaseUrl()}/actions/fees/estimate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t,(a,s)=>typeof s=="bigint"?s.toString():s)}),e=await r.json();if(!r.ok||!e.success||!e.data?.feeEstimate){const a=e.error?.message||`Relayer fee estimate error: ${r.status}`,s=L(t,a);throw new d("RELAYER_ERROR",s,{httpStatus:r.status,responseBody:JSON.stringify(e),endpoint:"/actions/fees/estimate"})}return e.data.feeEstimate}async estimateBatchGas(t){const r=await fetch(`${this.getEffectiveBaseUrl()}/actions/gas/estimate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t,(a,s)=>typeof s=="bigint"?s.toString():s)}),e=await r.json();if(!r.ok||!e.success||!e.data?.gasFee){const a=e.error?.message||`Relayer gas estimate error: ${r.status}`;throw new d("RELAYER_ERROR",a,{httpStatus:r.status,responseBody:JSON.stringify(e),endpoint:"/actions/gas/estimate"})}return{gasFee:BigInt(e.data.gasFee),gasQuoteSource:e.data.gasQuoteSource}}async executeStep(t,r,e,a){const s=`${this.getEffectiveBaseUrl()}/actions/${t}/intents/${r}/steps/${e}`,c=fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});let n;try{n=await Promise.race([c,new Promise((i,f)=>setTimeout(()=>f(new d("RELAYER_EXECUTE_ERROR",`Execute step request timed out after ${1e4/1e3}s`,{actionId:t,intentIndex:r,stepIndex:e,endpoint:`/actions/${t}/intents/${r}/steps/${e}`})),1e4))])}catch(i){throw i}if(!n.ok){const i=await n.text();throw new d("RELAYER_EXECUTE_ERROR",`Execute step error: ${n.status} - ${i}`,{httpStatus:n.status,responseBody:i,endpoint:`/actions/${t}/intents/${r}/steps/${e}`,actionId:t})}return{success:!0,transactionHash:(await n.json()).transactionHash}}async checkStepStatus(t,r){const e=t.split("/");let a="";if(e.length>=2){const n=e[0],i=e[1];a=`${this.getEffectiveBaseUrl()}/actions/${n}/intents/${i}/steps/${r}`}else a=`${this.getEffectiveBaseUrl()}/actions/${t}/intents/0/steps/${r}`;const s=await fetch(a);if(!s.ok)throw new d("RELAYER_STATUS_ERROR",`Intent step status check failed: ${s.status}`,{httpStatus:s.status,endpoint:a,intentId:t});const c=await s.json();return{success:!0,data:{status:c.status==="error"?"reverted":c.status,transactionHash:c.txid}}}async requestSpiceUsdAirdrop(t){try{const r=await fetch(`${this.getEffectiveBaseUrl()}/airdrop/${t.chainId}/spiceUsd`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({wallet:t.address})}),e=await r.json().catch(()=>({}));if(!r.ok){const a=e&&(e.error||e.message)||"Failed to request airdrop";return{success:!1,errorMessage:String(a)}}return e&&typeof e.error=="string"?{success:!1,errorMessage:e.error}:e&&(e.txHash||e.amount)?{success:!0,txHash:e.txHash,amount:e.amount}:{success:!0}}catch(r){return{success:!1,errorMessage:r?.message&&typeof r.message=="string"?r.message:"Failed to request airdrop"}}}async requestAirdrop(t){try{const r=await fetch(`${this.getEffectiveBaseUrl()}/airdrop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tag:t.tag||"default",airdrops:[{chainId:t.chainId,tokenId:t.tokenId,wallet:t.wallet,amount:t.amount||"0.0001"}]})}),e=await r.json().catch(()=>({}));if(!r.ok){const s=e?.message||e?.errors?.[0]?.error||"Failed to request airdrop";return{success:!1,errorMessage:String(s)}}const a=e?.airdrops?.[t.chainId]?.[t.tokenId]?.txHash;return e.errors&&e.errors.length>0?{success:!1,errorMessage:e.errors[0].error}:{success:!0,txHash:a}}catch(r){return{success:!1,errorMessage:r?.message&&typeof r.message=="string"?r.message:"Failed to request airdrop"}}}async createWallet(t,r){const e=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!e.ok){const a=await e.text();throw new d("RELAYER_ERROR",`Create wallet error: ${e.status} - ${a}`,{httpStatus:e.status,endpoint:`/wallets/${t}`})}return e.json()}async getWallet(t){const r=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${t}`);if(!r.ok){const e=await r.text();throw new d("RELAYER_ERROR",`Get wallet error: ${r.status} - ${e}`,{httpStatus:r.status,endpoint:`/wallets/${t}`})}return r.json()}async createWithdrawal(t){const r=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t,(e,a)=>typeof a=="bigint"?a.toString():a)});if(!r.ok){const e=await r.text();throw new d("RELAYER_ERROR",`Create withdrawal error: ${r.status} - ${e}`,{httpStatus:r.status,endpoint:"/withdrawals"})}return r.json()}async getWithdrawal(t){const r=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals/${t}`);if(!r.ok){const e=await r.text();throw new d("RELAYER_ERROR",`Get withdrawal error: ${r.status} - ${e}`,{httpStatus:r.status,endpoint:`/withdrawals/${t}`})}return r.json()}async getRollupTimestamp(){const t=await fetch(`${this.getEffectiveBaseUrl()}/time`);if(!t.ok)throw new d("RELAYER_ERROR",`Get rollup timestamp error: ${t.status}`,{httpStatus:t.status,endpoint:"/time"});return t.json()}}const m=new F,j=(o,t)=>{const r=a=>t?t(a):g.getChainName(a),e=[];return o.forEach((a,s)=>{const c=a.calls&&a.calls.length>0,n=a.tokenTransfers&&a.tokenTransfers.length>0;if(c||n){const i={stepId:s,status:s===0?"processing":"pending",chainId:a.chainId,chainName:r(a.chainId),description:"Processing transaction"};e.push(i)}}),e},I="spiceflow-mode",k=()=>{if(typeof window>"u")return null;try{const o=window.localStorage.getItem(I);return o==="embedded"?"7702":o==="external"?"ondemand":null}catch{return null}},M=o=>{if(!(typeof window>"u"))try{window.localStorage.setItem(I,o==="7702"?"embedded":"external")}catch{}},Y=()=>k()!==null,C=p.createContext(null),P=p.createContext(null),q=({children:o,provider:t,supportedChainIds:r,network:e="testnet",mode:a="7702",skipFlow:s=[],nativeChainId:c,appName:n="Spicenet",apiUrl:i,theme:f,rpcOverrides:u})=>{p.useEffect(()=>{if(!i)return;const l=m.getBaseUrl();return m.setBaseUrl(i),()=>m.setBaseUrl(l)},[i]),p.useEffect(()=>(g.setRpcOverrides(u),()=>g.setRpcOverrides(void 0)),[u]);const h=r??S.getChainIdsByNetwork(e),B=f??null,[w,E]=p.useState(()=>k()??a),x=p.useCallback(l=>{E(l),M(l)},[]);return b.jsx(C.Provider,{value:B,children:b.jsx(P.Provider,{value:{provider:t,supportedChainIds:h,skipFlow:s,mode:w,setMode:x,network:e,nativeChainId:c,appName:n,apiUrl:i,rpcOverrides:u},children:o})})};function y(o,t){const r=o.replace("#",""),e=Math.max(0,Math.round(parseInt(r.substring(0,2),16)*(1-t))),a=Math.max(0,Math.round(parseInt(r.substring(2,4),16)*(1-t))),s=Math.max(0,Math.round(parseInt(r.substring(4,6),16)*(1-t)));return`#${e.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`}function H(o,t){return{shell:t?.shell??"#141414",shellBorder:t?.shellBorder??y(t?.shell??"#141414",.35),shellInnerBorder:t?.shellInnerBorder??y(t?.shell??"#141414",.55),cardBg:t?.cardBg??"#1e1e1e",inputBg:t?.inputBg??"#171717",hoverBg:t?.hoverBg??"#2a2a2a",textPrimary:t?.textPrimary??"#ffffff",textSecondary:t?.textSecondary??"#888888",inputText:t?.inputText??"#e0e0e0",inputPlaceholder:t?.inputPlaceholder??"#555555",cardBorder:t?.cardBorder??"rgba(255,255,255,0.08)",inputBorder:t?.inputBorder??"rgba(255,255,255,0.10)",buttonBorder:t?.buttonBorder??"rgba(255,255,255,0.12)",successBg:t?.successBg??"#0a1f18",successBorder:t?.successBorder??"#1a4a3a",successText:t?.successText??"#6ee7b7",warningBg:t?.warningBg??"#1f1a0d",warningBorder:t?.warningBorder??"#4a3820",warningText:t?.warningText??"#fbbf24",errorBg:t?.errorBg??"#1f0d0d",errorBorder:t?.errorBorder??"#4a2020",errorText:t?.errorText??"#f87171",infoBg:t?.infoBg??"#0d1325",infoBorder:t?.infoBorder??"#2a3a5a",infoText:t?.infoText??"#60a5fa"}}function J(o){return{shell:"#ffffff",shellBorder:"#E9E9E9",shellInnerBorder:"#D5D5D5",cardBg:"#f9fafb",inputBg:"#ffffff",hoverBg:"#f3f4f6",textPrimary:"#111827",textSecondary:"#6b7280",inputText:"#111827",inputPlaceholder:"#9ca3af",cardBorder:"#E0E0E0",inputBorder:"#d1d5db",buttonBorder:"#0e0d0b",successBg:"#d1fae5",successBorder:"#6ee7b7",successText:"#065f46",warningBg:"#fef3c7",warningBorder:"#fcd34d",warningText:"#92400e",errorBg:"#fee2e2",errorBorder:"#fca5a5",errorText:"#dc2626",infoBg:"#dbeafe",infoBorder:"#93c5fd",infoText:"#1e40af"}}function U(o,t){const r=t?{...o,...t}:o,e=r.dark??!1,a=r.primaryColor,s=r.shell??(e?"#141414":"#ffffff");return{primaryColor:a,dark:e,fontFamily:r.fontFamily??'"Helvetica Neue", sans-serif',appName:r.appName??"Spicenet",logo:r.logo,borderRadius:r.borderRadius??"8px",shell:s,shellBorder:y(s,e?.35:.085),shellInnerBorder:y(s,e?.55:.165),card:r.card??(e?"#1e1e1e":"#f9fafb"),input:e?"#171717":"#ffffff",hover:e?"#2a2a2a":"#f3f4f6",text:r.text??(e?"#ffffff":"#111827"),textMuted:r.textMuted??(e?"#888888":"#6b7280"),inputText:e?"#e0e0e0":"#111827",inputPlaceholder:e?"#555555":"#9ca3af",border:r.border??(e?"rgba(255,255,255,0.08)":"#E0E0E0"),inputBorder:e?"rgba(255,255,255,0.10)":"#d1d5db",buttonBorder:e?"rgba(255,255,255,0.12)":"#0e0d0b",successBg:e?"#0a1f18":"#d1fae5",successBorder:e?"#1a4a3a":"#6ee7b7",successText:e?"#6ee7b7":"#065f46",warningBg:e?"#1f1a0d":"#fef3c7",warningBorder:e?"#4a3820":"#fcd34d",warningText:e?"#fbbf24":"#92400e",errorBg:e?"#1f0d0d":"#fee2e2",errorBorder:e?"#4a2020":"#fca5a5",errorText:e?"#f87171":"#dc2626",infoBg:e?"#0d1325":"#dbeafe",infoBorder:e?"#2a3a5a":"#93c5fd",infoText:e?"#60a5fa":"#1e40af"}}function D(o,t){const r=p.useContext(C)??void 0;return p.useMemo(()=>{const e=r??{primaryColor:"#EA4B4B"},a={...o?.primaryColor?{primaryColor:o.primaryColor}:{},...o?.fontFamily?{fontFamily:o.fontFamily}:{},...t!==void 0?{dark:t}:{}},s=U(e,a),{dark:c,primaryColor:n,appName:i}=s,f=A.createTheme(c?"dark":"light"),u={...f,colors:{...f.colors,primary:n,primaryHover:`${n}dd`},typography:{...f.typography,fontFamily:s.fontFamily}},h={shell:s.shell,shellBorder:s.shellBorder,shellInnerBorder:s.shellInnerBorder,cardBg:s.card,inputBg:s.input,hoverBg:s.hover,textPrimary:s.text,textSecondary:s.textMuted,inputText:s.inputText,inputPlaceholder:s.inputPlaceholder,cardBorder:s.border,inputBorder:s.inputBorder,buttonBorder:s.buttonBorder,successBg:s.successBg,successBorder:s.successBorder,successText:s.successText,warningBg:s.warningBg,warningBorder:s.warningBorder,warningText:s.warningText,errorBg:s.errorBg,errorBorder:s.errorBorder,errorText:s.errorText,infoBg:s.infoBg,infoBorder:s.infoBorder,infoText:s.infoText};return{brand:r,theme:u,dark:c,appName:i,primaryColor:n,dk:h,palette:h}},[r,o,t])}exports.RELAYER_API_URL=$,exports.SpiceFlowProvider=q,exports.SpiceFlowProviderContext=P,exports.SpiceflowError=d,exports.buildDarkPalette=H,exports.buildLightPalette=J,exports.createInitialSteps=j,exports.hasStoredSpiceFlowMode=Y,exports.isSpiceflowError=_,exports.relayerService=m,exports.resolveTheme=U,exports.useSpiceBrand=D;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import{createContext as R,useEffect as S,useState as _,useCallback as N,useContext as L,useMemo as j}from"react";import{jsx as b}from"react/jsx-runtime";import{isNativeToken as F,getTokenByAddress as M,getChainIdsByNetwork as Y}from"@spicenet-io/spiceflow-core";import{a as E,s as T}from"./index-DJQ17ocQ.js";import{formatUnits as $}from"viem";import{c as H}from"./Button-D5zwqrrP.js";class d extends Error{constructor(t,r,e={}){super(r),this.code=t,this.context=e,this.name="SpiceflowError",Error.captureStackTrace&&Error.captureStackTrace(this,d)}}function J(o){return o instanceof d}const v=typeof process<"u"&&process.env?.NEXT_PUBLIC_RELAYER_API_URL||"https://tx-api-devserver.spicenet.io",I="__SPICEFLOW_RELAYER_API_URL__";function q(o,t){const r=t.match(/Output amount (\d+) is insufficient after fees (\d+) on chain (\d+)/);if(!r)return t;const[,e,a,s]=r,c=Number(s),n=BigInt(e),i=BigInt(a);let f;for(const l of o.intents){const x=l.chainBatches.find(A=>A.chainId===c);if(x){f=x;break}}const u=f?.tokenTransfers.find(l=>l.from==="escrow"&&l.to.toLowerCase()===o.user.toLowerCase()&&!F(l.token));if(!u)return`Amount is too small to cover the estimated fee on ${E(c)}.`;const p=M(u.token,c),h=p?.decimals??18,g=p?.symbol??"tokens",w=$(n,h),y=$(i,h);return`Amount is too small to cover the estimated fee on ${E(c)}. Amount: ${w} ${g}. Estimated fee: ${y} ${g}.`}function W(){if(typeof globalThis>"u")return;const o=globalThis[I];return typeof o=="string"&&o.length>0?o:void 0}class D{constructor(){this.baseUrl=v}setBaseUrl(t){this.baseUrl=t,typeof globalThis<"u"&&(globalThis[I]=t)}getBaseUrl(){return this.getEffectiveBaseUrl()}getEffectiveBaseUrl(){return W()||this.baseUrl}async createAction(t){const r=await fetch(`${this.getEffectiveBaseUrl()}/actions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t,(e,a)=>typeof a=="bigint"?a.toString():a)});if(!r.ok){const e=await r.text();throw new d("RELAYER_ERROR",`Relayer API error: ${r.status} - ${e}`,{httpStatus:r.status,responseBody:e,endpoint:"/actions"})}return await r.json()}async estimateActionFees(t){const r=await fetch(`${this.getEffectiveBaseUrl()}/actions/fees/estimate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t,(a,s)=>typeof s=="bigint"?s.toString():s)}),e=await r.json();if(!r.ok||!e.success||!e.data?.feeEstimate){const a=e.error?.message||`Relayer fee estimate error: ${r.status}`,s=q(t,a);throw new d("RELAYER_ERROR",s,{httpStatus:r.status,responseBody:JSON.stringify(e),endpoint:"/actions/fees/estimate"})}return e.data.feeEstimate}async estimateBatchGas(t){const r=await fetch(`${this.getEffectiveBaseUrl()}/actions/gas/estimate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t,(a,s)=>typeof s=="bigint"?s.toString():s)}),e=await r.json();if(!r.ok||!e.success||!e.data?.gasFee){const a=e.error?.message||`Relayer gas estimate error: ${r.status}`;throw new d("RELAYER_ERROR",a,{httpStatus:r.status,responseBody:JSON.stringify(e),endpoint:"/actions/gas/estimate"})}return{gasFee:BigInt(e.data.gasFee),gasQuoteSource:e.data.gasQuoteSource}}async executeStep(t,r,e,a){const s=`${this.getEffectiveBaseUrl()}/actions/${t}/intents/${r}/steps/${e}`,c=fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});let n;try{n=await Promise.race([c,new Promise((i,f)=>setTimeout(()=>f(new d("RELAYER_EXECUTE_ERROR",`Execute step request timed out after ${1e4/1e3}s`,{actionId:t,intentIndex:r,stepIndex:e,endpoint:`/actions/${t}/intents/${r}/steps/${e}`})),1e4))])}catch(i){throw i}if(!n.ok){const i=await n.text();throw new d("RELAYER_EXECUTE_ERROR",`Execute step error: ${n.status} - ${i}`,{httpStatus:n.status,responseBody:i,endpoint:`/actions/${t}/intents/${r}/steps/${e}`,actionId:t})}return{success:!0,transactionHash:(await n.json()).transactionHash}}async checkStepStatus(t,r){const e=t.split("/");let a="";if(e.length>=2){const n=e[0],i=e[1];a=`${this.getEffectiveBaseUrl()}/actions/${n}/intents/${i}/steps/${r}`}else a=`${this.getEffectiveBaseUrl()}/actions/${t}/intents/0/steps/${r}`;const s=await fetch(a);if(!s.ok)throw new d("RELAYER_STATUS_ERROR",`Intent step status check failed: ${s.status}`,{httpStatus:s.status,endpoint:a,intentId:t});const c=await s.json();return{success:!0,data:{status:c.status==="error"?"reverted":c.status,transactionHash:c.txid}}}async requestSpiceUsdAirdrop(t){try{const r=await fetch(`${this.getEffectiveBaseUrl()}/airdrop/${t.chainId}/spiceUsd`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({wallet:t.address})}),e=await r.json().catch(()=>({}));if(!r.ok){const a=e&&(e.error||e.message)||"Failed to request airdrop";return{success:!1,errorMessage:String(a)}}return e&&typeof e.error=="string"?{success:!1,errorMessage:e.error}:e&&(e.txHash||e.amount)?{success:!0,txHash:e.txHash,amount:e.amount}:{success:!0}}catch(r){return{success:!1,errorMessage:r?.message&&typeof r.message=="string"?r.message:"Failed to request airdrop"}}}async requestAirdrop(t){try{const r=await fetch(`${this.getEffectiveBaseUrl()}/airdrop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tag:t.tag||"default",airdrops:[{chainId:t.chainId,tokenId:t.tokenId,wallet:t.wallet,amount:t.amount||"0.0001"}]})}),e=await r.json().catch(()=>({}));if(!r.ok){const s=e?.message||e?.errors?.[0]?.error||"Failed to request airdrop";return{success:!1,errorMessage:String(s)}}const a=e?.airdrops?.[t.chainId]?.[t.tokenId]?.txHash;return e.errors&&e.errors.length>0?{success:!1,errorMessage:e.errors[0].error}:{success:!0,txHash:a}}catch(r){return{success:!1,errorMessage:r?.message&&typeof r.message=="string"?r.message:"Failed to request airdrop"}}}async createWallet(t,r){const e=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!e.ok){const a=await e.text();throw new d("RELAYER_ERROR",`Create wallet error: ${e.status} - ${a}`,{httpStatus:e.status,endpoint:`/wallets/${t}`})}return e.json()}async getWallet(t){const r=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${t}`);if(!r.ok){const e=await r.text();throw new d("RELAYER_ERROR",`Get wallet error: ${r.status} - ${e}`,{httpStatus:r.status,endpoint:`/wallets/${t}`})}return r.json()}async createWithdrawal(t){const r=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t,(e,a)=>typeof a=="bigint"?a.toString():a)});if(!r.ok){const e=await r.text();throw new d("RELAYER_ERROR",`Create withdrawal error: ${r.status} - ${e}`,{httpStatus:r.status,endpoint:"/withdrawals"})}return r.json()}async getWithdrawal(t){const r=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals/${t}`);if(!r.ok){const e=await r.text();throw new d("RELAYER_ERROR",`Get withdrawal error: ${r.status} - ${e}`,{httpStatus:r.status,endpoint:`/withdrawals/${t}`})}return r.json()}async getRollupTimestamp(){const t=await fetch(`${this.getEffectiveBaseUrl()}/time`);if(!t.ok)throw new d("RELAYER_ERROR",`Get rollup timestamp error: ${t.status}`,{httpStatus:t.status,endpoint:"/time"});return t.json()}}const B=new D,G=(o,t)=>{const r=a=>t?t(a):E(a),e=[];return o.forEach((a,s)=>{const c=a.calls&&a.calls.length>0,n=a.tokenTransfers&&a.tokenTransfers.length>0;if(c||n){const i={stepId:s,status:s===0?"processing":"pending",chainId:a.chainId,chainName:r(a.chainId),description:"Processing transaction"};e.push(i)}}),e},k="spiceflow-mode",C=()=>{if(typeof window>"u")return null;try{const o=window.localStorage.getItem(k);return o==="embedded"?"7702":o==="external"?"ondemand":null}catch{return null}},X=o=>{if(!(typeof window>"u"))try{window.localStorage.setItem(k,o==="7702"?"embedded":"external")}catch{}},Q=()=>C()!==null,U=R(null),O=R(null),z=({children:o,provider:t,supportedChainIds:r,network:e="testnet",mode:a="7702",skipFlow:s=[],nativeChainId:c,appName:n="Spicenet",apiUrl:i,theme:f,rpcOverrides:u})=>{S(()=>{if(!i)return;const l=B.getBaseUrl();return B.setBaseUrl(i),()=>B.setBaseUrl(l)},[i]),S(()=>(T(u),()=>T(void 0)),[u]);const p=r??Y(e),h=f??null,[g,w]=_(()=>C()??a),y=N(l=>{w(l),X(l)},[]);return b(U.Provider,{value:h,children:b(O.Provider,{value:{provider:t,supportedChainIds:p,skipFlow:s,mode:g,setMode:y,network:e,nativeChainId:c,appName:n,apiUrl:i,rpcOverrides:u},children:o})})};function m(o,t){const r=o.replace("#",""),e=Math.max(0,Math.round(parseInt(r.substring(0,2),16)*(1-t))),a=Math.max(0,Math.round(parseInt(r.substring(2,4),16)*(1-t))),s=Math.max(0,Math.round(parseInt(r.substring(4,6),16)*(1-t)));return`#${e.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`}function K(o,t){return{shell:t?.shell??"#141414",shellBorder:t?.shellBorder??m(t?.shell??"#141414",.35),shellInnerBorder:t?.shellInnerBorder??m(t?.shell??"#141414",.55),cardBg:t?.cardBg??"#1e1e1e",inputBg:t?.inputBg??"#171717",hoverBg:t?.hoverBg??"#2a2a2a",textPrimary:t?.textPrimary??"#ffffff",textSecondary:t?.textSecondary??"#888888",inputText:t?.inputText??"#e0e0e0",inputPlaceholder:t?.inputPlaceholder??"#555555",cardBorder:t?.cardBorder??"rgba(255,255,255,0.08)",inputBorder:t?.inputBorder??"rgba(255,255,255,0.10)",buttonBorder:t?.buttonBorder??"rgba(255,255,255,0.12)",successBg:t?.successBg??"#0a1f18",successBorder:t?.successBorder??"#1a4a3a",successText:t?.successText??"#6ee7b7",warningBg:t?.warningBg??"#1f1a0d",warningBorder:t?.warningBorder??"#4a3820",warningText:t?.warningText??"#fbbf24",errorBg:t?.errorBg??"#1f0d0d",errorBorder:t?.errorBorder??"#4a2020",errorText:t?.errorText??"#f87171",infoBg:t?.infoBg??"#0d1325",infoBorder:t?.infoBorder??"#2a3a5a",infoText:t?.infoText??"#60a5fa"}}function V(o){return{shell:"#ffffff",shellBorder:"#E9E9E9",shellInnerBorder:"#D5D5D5",cardBg:"#f9fafb",inputBg:"#ffffff",hoverBg:"#f3f4f6",textPrimary:"#111827",textSecondary:"#6b7280",inputText:"#111827",inputPlaceholder:"#9ca3af",cardBorder:"#E0E0E0",inputBorder:"#d1d5db",buttonBorder:"#0e0d0b",successBg:"#d1fae5",successBorder:"#6ee7b7",successText:"#065f46",warningBg:"#fef3c7",warningBorder:"#fcd34d",warningText:"#92400e",errorBg:"#fee2e2",errorBorder:"#fca5a5",errorText:"#dc2626",infoBg:"#dbeafe",infoBorder:"#93c5fd",infoText:"#1e40af"}}function P(o,t){const r=t?{...o,...t}:o,e=r.dark??!1,a=r.primaryColor,s=r.shell??(e?"#141414":"#ffffff");return{primaryColor:a,dark:e,fontFamily:r.fontFamily??'"Helvetica Neue", sans-serif',appName:r.appName??"Spicenet",logo:r.logo,borderRadius:r.borderRadius??"8px",shell:s,shellBorder:m(s,e?.35:.085),shellInnerBorder:m(s,e?.55:.165),card:r.card??(e?"#1e1e1e":"#f9fafb"),input:e?"#171717":"#ffffff",hover:e?"#2a2a2a":"#f3f4f6",text:r.text??(e?"#ffffff":"#111827"),textMuted:r.textMuted??(e?"#888888":"#6b7280"),inputText:e?"#e0e0e0":"#111827",inputPlaceholder:e?"#555555":"#9ca3af",border:r.border??(e?"rgba(255,255,255,0.08)":"#E0E0E0"),inputBorder:e?"rgba(255,255,255,0.10)":"#d1d5db",buttonBorder:e?"rgba(255,255,255,0.12)":"#0e0d0b",successBg:e?"#0a1f18":"#d1fae5",successBorder:e?"#1a4a3a":"#6ee7b7",successText:e?"#6ee7b7":"#065f46",warningBg:e?"#1f1a0d":"#fef3c7",warningBorder:e?"#4a3820":"#fcd34d",warningText:e?"#fbbf24":"#92400e",errorBg:e?"#1f0d0d":"#fee2e2",errorBorder:e?"#4a2020":"#fca5a5",errorText:e?"#f87171":"#dc2626",infoBg:e?"#0d1325":"#dbeafe",infoBorder:e?"#2a3a5a":"#93c5fd",infoText:e?"#60a5fa":"#1e40af"}}function Z(o,t){const r=L(U)??void 0;return j(()=>{const e=r??{primaryColor:"#EA4B4B"},a={...o?.primaryColor?{primaryColor:o.primaryColor}:{},...o?.fontFamily?{fontFamily:o.fontFamily}:{},...t!==void 0?{dark:t}:{}},s=P(e,a),{dark:c,primaryColor:n,appName:i}=s,f=H(c?"dark":"light"),u={...f,colors:{...f.colors,primary:n,primaryHover:`${n}dd`},typography:{...f.typography,fontFamily:s.fontFamily}},p={shell:s.shell,shellBorder:s.shellBorder,shellInnerBorder:s.shellInnerBorder,cardBg:s.card,inputBg:s.input,hoverBg:s.hover,textPrimary:s.text,textSecondary:s.textMuted,inputText:s.inputText,inputPlaceholder:s.inputPlaceholder,cardBorder:s.border,inputBorder:s.inputBorder,buttonBorder:s.buttonBorder,successBg:s.successBg,successBorder:s.successBorder,successText:s.successText,warningBg:s.warningBg,warningBorder:s.warningBorder,warningText:s.warningText,errorBg:s.errorBg,errorBorder:s.errorBorder,errorText:s.errorText,infoBg:s.infoBg,infoBorder:s.infoBorder,infoText:s.infoText};return{brand:r,theme:u,dark:c,appName:i,primaryColor:n,dk:p,palette:p}},[r,o,t])}export{v as R,O as S,V as a,K as b,G as c,d,z as e,P as f,Q as h,J as i,B as r,Z as u};
|