@spicenet-io/spiceflow-ui 3.1.3 → 3.1.4

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,2 +1,2 @@
1
1
  "use client";
2
- "use strict";const e=require("react/jsx-runtime"),c=require("react"),t=require("./Button-B_UpyUH-.js"),L=require("@dynamic-labs/sdk-react-core"),W=require("./providerWallet-CjMkNbyR.js");require("viem"),require("./index-BEUnI98r.js"),require("viem/actions"),require("@spicenet-io/spiceflow-core");const k=({onAuthSuccess:a,onAuthError:r,theme:h="light",className:i="",buttonText:o="Login with Dynamic",autoTrigger:l=!1})=>{const s=t.createTheme(h),[m,D]=c.useState(!1),[g,S]=c.useState(!1),b=L.useDynamicContext(),{user:w,primaryWallet:f,connectedWallets:E,handleLogOut:N,setShowAuthFlow:x,sdkHasLoaded:p,showAuthFlow:j}=b,n=(W.getDynamicEmbeddedWallet({connectedWallets:E,primaryWallet:f})||f)?.address,v=!!w,d=v&&!!n;c.useEffect(()=>{D(!0)},[]),c.useEffect(()=>{d&&n&&a&&a(n)},[d,n,a]),c.useEffect(()=>{l&&p&&m&&!d&&!j&&!g&&(S(!0),x(!0))},[l,p,m,d,j,g,x]);const q=()=>{try{x(!0)}catch(y){const u=`Dynamic login failed: ${String(y)}`;r?r(u):console.error(u)}},C=async()=>{try{await N()}catch(y){const u=`Dynamic logout failed: ${String(y)}`;r?r(u):console.error(u)}};return m?p?v&&!n?e.jsx("div",{className:i,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e.jsx(t.Spinner,{size:40,borderWidth:3,color:s.colors.primary}),e.jsx("p",{style:{color:s.colors.textMuted,fontSize:"14px"},children:"Finishing wallet setup..."})]})}):d&&n?e.jsx("div",{className:i,children:e.jsxs(t.Button,{variant:"primary",onClick:C,theme:s,children:["Logout (",n.slice(0,6),"...",n.slice(-4),")"]})}):l?e.jsx("div",{className:i,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e.jsx(t.Spinner,{size:40,borderWidth:3,color:s.colors.primary}),e.jsx("p",{style:{color:s.colors.textMuted,fontSize:"14px"},children:"Opening login..."})]})}):e.jsx("div",{className:i,children:e.jsx(t.Button,{variant:"primary",onClick:q,theme:s,children:o})}):e.jsx("div",{className:i,children:e.jsx(t.Button,{variant:"primary",disabled:!0,theme:s,children:"Loading..."})}):e.jsx("div",{className:i,children:e.jsx(t.Button,{variant:"primary",disabled:!0,theme:s,children:o})})};class B extends c.Component{constructor(r){super(r),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}}const F=a=>{const{theme:r="light",className:h="",buttonText:i="Login with Dynamic",onAuthError:o}=a,l=t.createTheme(r);return e.jsx(B,{fallback:e.jsx("div",{className:h,children:e.jsx(t.Button,{variant:"primary",onClick:()=>{o&&o('DynamicLogin must be used within SpiceFlowProvider provider="dynamic" and a mounted DynamicContextProvider.')},theme:l,children:i})}),children:e.jsx(k,{...a})})};exports.DynamicLogin=F;
2
+ "use strict";const e=require("react/jsx-runtime"),c=require("react"),t=require("./Button-B_UpyUH-.js"),L=require("@dynamic-labs/sdk-react-core"),W=require("./providerWallet-CXXHCasD.js");require("viem"),require("./index-eS_pa_hv.js"),require("viem/actions"),require("@spicenet-io/spiceflow-core");const k=({onAuthSuccess:a,onAuthError:r,theme:h="light",className:i="",buttonText:o="Login with Dynamic",autoTrigger:l=!1})=>{const s=t.createTheme(h),[m,D]=c.useState(!1),[g,S]=c.useState(!1),b=L.useDynamicContext(),{user:w,primaryWallet:f,connectedWallets:E,handleLogOut:N,setShowAuthFlow:x,sdkHasLoaded:p,showAuthFlow:j}=b,n=(W.getDynamicEmbeddedWallet({connectedWallets:E,primaryWallet:f})||f)?.address,v=!!w,d=v&&!!n;c.useEffect(()=>{D(!0)},[]),c.useEffect(()=>{d&&n&&a&&a(n)},[d,n,a]),c.useEffect(()=>{l&&p&&m&&!d&&!j&&!g&&(S(!0),x(!0))},[l,p,m,d,j,g,x]);const q=()=>{try{x(!0)}catch(y){const u=`Dynamic login failed: ${String(y)}`;r?r(u):console.error(u)}},C=async()=>{try{await N()}catch(y){const u=`Dynamic logout failed: ${String(y)}`;r?r(u):console.error(u)}};return m?p?v&&!n?e.jsx("div",{className:i,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e.jsx(t.Spinner,{size:40,borderWidth:3,color:s.colors.primary}),e.jsx("p",{style:{color:s.colors.textMuted,fontSize:"14px"},children:"Finishing wallet setup..."})]})}):d&&n?e.jsx("div",{className:i,children:e.jsxs(t.Button,{variant:"primary",onClick:C,theme:s,children:["Logout (",n.slice(0,6),"...",n.slice(-4),")"]})}):l?e.jsx("div",{className:i,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e.jsx(t.Spinner,{size:40,borderWidth:3,color:s.colors.primary}),e.jsx("p",{style:{color:s.colors.textMuted,fontSize:"14px"},children:"Opening login..."})]})}):e.jsx("div",{className:i,children:e.jsx(t.Button,{variant:"primary",onClick:q,theme:s,children:o})}):e.jsx("div",{className:i,children:e.jsx(t.Button,{variant:"primary",disabled:!0,theme:s,children:"Loading..."})}):e.jsx("div",{className:i,children:e.jsx(t.Button,{variant:"primary",disabled:!0,theme:s,children:o})})};class B extends c.Component{constructor(r){super(r),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}}const F=a=>{const{theme:r="light",className:h="",buttonText:i="Login with Dynamic",onAuthError:o}=a,l=t.createTheme(r);return e.jsx(B,{fallback:e.jsx("div",{className:h,children:e.jsx(t.Button,{variant:"primary",onClick:()=>{o&&o('DynamicLogin must be used within SpiceFlowProvider provider="dynamic" and a mounted DynamicContextProvider.')},theme:l,children:i})}),children:e.jsx(k,{...a})})};exports.DynamicLogin=F;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as e,jsxs as g}from"react/jsx-runtime";import A,{useState as b,useEffect as f}from"react";import{B as d,c as w,S as N}from"./Button-DjsYc4v4.js";import{useDynamicContext as T}from"@dynamic-labs/sdk-react-core";import{g as j}from"./providerWallet-BlhIbvVk.js";import"viem";import"./index-D2i8C5Pt.js";import"viem/actions";import"@spicenet-io/spiceflow-core";const z=({onAuthSuccess:a,onAuthError:r,theme:m="light",className:t="",buttonText:o="Login with Dynamic",autoTrigger:s=!1})=>{const i=w(m),[h,E]=b(!1),[x,W]=b(!1),C=T(),{user:L,primaryWallet:v,connectedWallets:k,handleLogOut:F,setShowAuthFlow:p,sdkHasLoaded:u,showAuthFlow:D}=C,n=(j({connectedWallets:k,primaryWallet:v})||v)?.address,S=!!L,l=S&&!!n;return f(()=>{E(!0)},[]),f(()=>{l&&n&&a&&a(n)},[l,n,a]),f(()=>{s&&u&&h&&!l&&!D&&!x&&(W(!0),p(!0))},[s,u,h,l,D,x,p]),h?u?S&&!n?e("div",{className:t,children:g("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e(N,{size:40,borderWidth:3,color:i.colors.primary}),e("p",{style:{color:i.colors.textMuted,fontSize:"14px"},children:"Finishing wallet setup..."})]})}):l&&n?e("div",{className:t,children:g(d,{variant:"primary",onClick:async()=>{try{await F()}catch(y){const c=`Dynamic logout failed: ${String(y)}`;r?r(c):console.error(c)}},theme:i,children:["Logout (",n.slice(0,6),"...",n.slice(-4),")"]})}):s?e("div",{className:t,children:g("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e(N,{size:40,borderWidth:3,color:i.colors.primary}),e("p",{style:{color:i.colors.textMuted,fontSize:"14px"},children:"Opening login..."})]})}):e("div",{className:t,children:e(d,{variant:"primary",onClick:()=>{try{p(!0)}catch(y){const c=`Dynamic login failed: ${String(y)}`;r?r(c):console.error(c)}},theme:i,children:o})}):e("div",{className:t,children:e(d,{variant:"primary",disabled:!0,theme:i,children:"Loading..."})}):e("div",{className:t,children:e(d,{variant:"primary",disabled:!0,theme:i,children:o})})};class B extends A.Component{constructor(r){super(r),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}}const I=a=>{const{theme:r="light",className:m="",buttonText:t="Login with Dynamic",onAuthError:o}=a,s=w(r);return e(B,{fallback:e("div",{className:m,children:e(d,{variant:"primary",onClick:()=>{o&&o('DynamicLogin must be used within SpiceFlowProvider provider="dynamic" and a mounted DynamicContextProvider.')},theme:s,children:t})}),children:e(z,{...a})})};export{I as DynamicLogin};
2
+ import{jsx as e,jsxs as g}from"react/jsx-runtime";import A,{useState as b,useEffect as f}from"react";import{B as d,c as w,S as N}from"./Button-CaguAr48.js";import{useDynamicContext as T}from"@dynamic-labs/sdk-react-core";import{g as j}from"./providerWallet-BaSuHs-I.js";import"viem";import"./index-CJJLFvEf.js";import"viem/actions";import"@spicenet-io/spiceflow-core";const z=({onAuthSuccess:a,onAuthError:r,theme:m="light",className:t="",buttonText:o="Login with Dynamic",autoTrigger:s=!1})=>{const i=w(m),[h,E]=b(!1),[x,W]=b(!1),C=T(),{user:L,primaryWallet:v,connectedWallets:k,handleLogOut:F,setShowAuthFlow:p,sdkHasLoaded:u,showAuthFlow:D}=C,n=(j({connectedWallets:k,primaryWallet:v})||v)?.address,S=!!L,l=S&&!!n;return f(()=>{E(!0)},[]),f(()=>{l&&n&&a&&a(n)},[l,n,a]),f(()=>{s&&u&&h&&!l&&!D&&!x&&(W(!0),p(!0))},[s,u,h,l,D,x,p]),h?u?S&&!n?e("div",{className:t,children:g("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e(N,{size:40,borderWidth:3,color:i.colors.primary}),e("p",{style:{color:i.colors.textMuted,fontSize:"14px"},children:"Finishing wallet setup..."})]})}):l&&n?e("div",{className:t,children:g(d,{variant:"primary",onClick:async()=>{try{await F()}catch(y){const c=`Dynamic logout failed: ${String(y)}`;r?r(c):console.error(c)}},theme:i,children:["Logout (",n.slice(0,6),"...",n.slice(-4),")"]})}):s?e("div",{className:t,children:g("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e(N,{size:40,borderWidth:3,color:i.colors.primary}),e("p",{style:{color:i.colors.textMuted,fontSize:"14px"},children:"Opening login..."})]})}):e("div",{className:t,children:e(d,{variant:"primary",onClick:()=>{try{p(!0)}catch(y){const c=`Dynamic login failed: ${String(y)}`;r?r(c):console.error(c)}},theme:i,children:o})}):e("div",{className:t,children:e(d,{variant:"primary",disabled:!0,theme:i,children:"Loading..."})}):e("div",{className:t,children:e(d,{variant:"primary",disabled:!0,theme:i,children:o})})};class B extends A.Component{constructor(r){super(r),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}}const I=a=>{const{theme:r="light",className:m="",buttonText:t="Login with Dynamic",onAuthError:o}=a,s=w(r);return e(B,{fallback:e("div",{className:m,children:e(d,{variant:"primary",onClick:()=>{o&&o('DynamicLogin must be used within SpiceFlowProvider provider="dynamic" and a mounted DynamicContextProvider.')},theme:s,children:t})}),children:e(z,{...a})})};export{I as DynamicLogin};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as r,jsxs as v}from"react/jsx-runtime";import{useState as y,useEffect as c}from"react";import{B as d,c as P,S as $}from"./Button-DjsYc4v4.js";import{usePrivy as j,useLogin as w,useLogout as B}from"@privy-io/react-auth";const T=({onAuthSuccess:m,onAuthError:n,theme:x="light",className:a="",buttonText:f="Login with Privy",autoTrigger:u=!1})=>{const l=P(x),[h,L]=y(!1),[g,b]=y(!1),{ready:s,authenticated:o,user:i}=j(),{login:S}=w(),{logout:N}=B();c(()=>{L(!0)},[]),c(()=>{u&&s&&!o&&h&&!g&&(b(!0),p())},[u,s,o,h,g]),c(()=>{if(s&&o&&i&&m){const e=i.wallet?.address||i.email?.address;e&&m(e)}},[s,o,i,m]),c(()=>{},[s,o,n]);const p=()=>{try{S()}catch(e){const t=`Login failed: ${String(e)}`;n?n(t):console.error(t)}},C=()=>{try{N()}catch(e){const t=`Logout failed: ${String(e)}`;n?n(t):console.error(t)}};if(!h)return r("div",{className:a,children:r(d,{variant:"primary",disabled:!0,theme:l,children:f})});if(!s)return r("div",{className:a,children:r(d,{variant:"primary",disabled:!0,theme:l,children:"Loading..."})});if(o&&i){const e=i.wallet?.address||i.email?.address,t=e?`${e.slice(0,6)}...${e.slice(-4)}`:"Connected";return r("div",{className:a,children:v(d,{variant:"primary",onClick:C,theme:l,children:["Logout (",t,")"]})})}return u?r("div",{className:a,children:v("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[r($,{size:40,borderWidth:3,color:"#3b82f6"}),r("p",{style:{color:"#6b7280",fontSize:"14px"},children:"Opening login..."})]})}):r("div",{className:a,children:r(d,{variant:"primary",onClick:p,theme:l,children:f})})};export{T as PrivyLogin};
2
+ import{jsx as r,jsxs as v}from"react/jsx-runtime";import{useState as y,useEffect as c}from"react";import{B as d,c as P,S as $}from"./Button-CaguAr48.js";import{usePrivy as j,useLogin as w,useLogout as B}from"@privy-io/react-auth";const T=({onAuthSuccess:m,onAuthError:n,theme:x="light",className:a="",buttonText:f="Login with Privy",autoTrigger:u=!1})=>{const l=P(x),[h,L]=y(!1),[g,b]=y(!1),{ready:s,authenticated:o,user:i}=j(),{login:S}=w(),{logout:N}=B();c(()=>{L(!0)},[]),c(()=>{u&&s&&!o&&h&&!g&&(b(!0),p())},[u,s,o,h,g]),c(()=>{if(s&&o&&i&&m){const e=i.wallet?.address||i.email?.address;e&&m(e)}},[s,o,i,m]),c(()=>{},[s,o,n]);const p=()=>{try{S()}catch(e){const t=`Login failed: ${String(e)}`;n?n(t):console.error(t)}},C=()=>{try{N()}catch(e){const t=`Logout failed: ${String(e)}`;n?n(t):console.error(t)}};if(!h)return r("div",{className:a,children:r(d,{variant:"primary",disabled:!0,theme:l,children:f})});if(!s)return r("div",{className:a,children:r(d,{variant:"primary",disabled:!0,theme:l,children:"Loading..."})});if(o&&i){const e=i.wallet?.address||i.email?.address,t=e?`${e.slice(0,6)}...${e.slice(-4)}`:"Connected";return r("div",{className:a,children:v(d,{variant:"primary",onClick:C,theme:l,children:["Logout (",t,")"]})})}return u?r("div",{className:a,children:v("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[r($,{size:40,borderWidth:3,color:"#3b82f6"}),r("p",{style:{color:"#6b7280",fontSize:"14px"},children:"Opening login..."})]})}):r("div",{className:a,children:r(d,{variant:"primary",onClick:p,theme:l,children:f})})};export{T as PrivyLogin};
@@ -1,2 +1,2 @@
1
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-fWPbO0Pf.js"),v=require("./Button-B_UpyUH-.js");require("./index-BEUnI98r.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;
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-ZtrZ3GKZ.js"),v=require("./Button-B_UpyUH-.js");require("./index-eS_pa_hv.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;
@@ -1,2 +1,2 @@
1
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-CsEv5pNz.js";import{B as v}from"./Button-DjsYc4v4.js";import"./index-D2i8C5Pt.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};
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-f6H0Xw5W.js";import{B as v}from"./Button-CaguAr48.js";import"./index-CJJLFvEf.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,5 +1,6 @@
1
1
  import React from "react";
2
2
  import { CustomStyles } from "../../types/theme";
3
+ import type { PostDepositContext } from "../../types/deposit";
3
4
  import { ChainBatch } from "../../types/authorization";
4
5
  export interface EscrowRecovery {
5
6
  chainId: number;
@@ -12,7 +13,7 @@ export interface SpiceDepositProps {
12
13
  isOpen: boolean;
13
14
  onClose: () => void;
14
15
  styles?: CustomStyles;
15
- depositBatches?: ChainBatch[] | ((depositAmount: string, depositTokenAddress: string) => Promise<ChainBatch[]>);
16
+ depositBatches?: ChainBatch[] | ((context: PostDepositContext) => Promise<ChainBatch[]>) | ((depositAmount: string, depositTokenAddress: string) => Promise<ChainBatch[]>);
16
17
  allowedTokens?: string[];
17
18
  onDepositAmountChange?: (amount: string) => void;
18
19
  destinationChainId?: number;
@@ -0,0 +1,12 @@
1
+ import type { ChainBatch } from "../../types/authorization";
2
+ import type { SelectedAsset } from "../../types/assets";
3
+ import type { DepositModalProps, PostDepositContext } from "../../types/deposit";
4
+ export declare function buildPostDepositContext({ sourceChainId, selectedAsset, destinationChainId, destinationTokenAddress, isCrossDenomination, convertedUsdAmount, }: {
5
+ sourceChainId: number;
6
+ selectedAsset: SelectedAsset;
7
+ destinationChainId?: number;
8
+ destinationTokenAddress?: string;
9
+ isCrossDenomination: boolean;
10
+ convertedUsdAmount: bigint | null;
11
+ }): PostDepositContext;
12
+ export declare function resolveDepositBatches(depositBatches: DepositModalProps["depositBatches"], context: PostDepositContext): Promise<ChainBatch[]>;
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import type { Address } from "viem";
3
3
  import type { Call } from "../../types/authorization";
4
4
  import type { CustomStyles } from "../../types/theme";
5
- import type { BuildActionCallsContext } from "../../types/supply";
5
+ import type { BuildActionCallsContext, SpiceSupplyProps } from "../../types/supply";
6
6
  export interface SpicePayProps {
7
7
  isOpen: boolean;
8
8
  onClose: () => void;
@@ -17,6 +17,7 @@ export interface SpicePayProps {
17
17
  maxPaymentAmount?: string;
18
18
  onAmountChange?: (amount: string) => void;
19
19
  buildActionCalls: (amount: bigint, ctx: BuildActionCallsContext) => Call[];
20
+ buildSpicenetBatch?: SpiceSupplyProps["buildSpicenetBatch"];
20
21
  sourceChains?: number[];
21
22
  onPaymentSuccess?: (txHash?: string) => void;
22
23
  onPaymentError?: (error: Error) => void;
@@ -28,4 +28,11 @@ export interface SupplyQuoteResult {
28
28
  needsSwap: boolean;
29
29
  selectedIsEquivalent: boolean;
30
30
  }
31
+ export declare function resolveInputSupplySwapQuote(params: {
32
+ chainId: number;
33
+ recipient: Address;
34
+ tokenIn: Address;
35
+ tokenOut: Address;
36
+ amountIn: bigint;
37
+ }): Promise<ResolvedSwap>;
31
38
  export declare function useSupplyQuote(opts: UseSupplyQuoteOpts): SupplyQuoteResult;
@@ -1,2 +1,2 @@
1
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"}],U="0xcA11bde05977b3631167028862bE2a173976CA11",x={4114:"0x860aFc632a6D625B95d8B96f39ECC48E988c6962"},$=new Set([5115]);function _(e){const t=x[e.id]??($.has(e.id)?void 0:U);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 U,F as a,b,R as c,T as d,O as e,S as f,i as g,c as h,L as i,D as s};
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,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,y as q,D as s};
@@ -1,2 +1,2 @@
1
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],U=e=>{const t=o.getChainMeta(e);return t?.displayName||t?.name||`Chain ${e}`},k=e=>{const t=o.getDelegateContract(e);if(!t)throw new Error(`Unsupported chain ID: ${e}`);return t},A=(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.U=y,exports.getAllAssetsForChain=x,exports.getChainConfig=c,exports.getChainName=U,exports.getChainsForAssets=F,exports.getClientForChain=b,exports.getDelegateContractAddress=k,exports.getExplorerUrl=A,exports.getRpcUrlForChain=d,exports.getTokenDecimals=_,exports.setRpcOverrides=I;
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.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.q=y,exports.setRpcOverrides=I;