@spicenet-io/spiceflow-ui 3.0.0 → 3.0.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/{auth-dynamic-C-_mXQTw.js → auth-dynamic-CG0Ou9V1.js} +1 -1
- package/dist/{auth-dynamic-te0UmMBN.js → auth-dynamic-CaSspPic.js} +1 -1
- package/dist/auth-dynamic.cjs.js +1 -1
- package/dist/auth-dynamic.js +1 -1
- package/dist/auth-privy.js +1 -1
- package/dist/auth-starknet.cjs.js +1 -1
- package/dist/auth-starknet.js +1 -1
- package/dist/components/AccountDisplay/AccountActions.d.ts +1 -1
- package/dist/components/SpiceDeposit/DepositRecoveryPrompt.d.ts +0 -1
- package/dist/components/SpiceWithdraw/SpiceWithdraw.d.ts +0 -7
- package/dist/components/ui/SpiceModalShell.d.ts +0 -1
- package/dist/errors.d.ts +1 -1
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/useGaslessExecution/index.d.ts +7 -1
- package/dist/hooks/useSupplyAssets.d.ts +3 -0
- package/dist/index-BOMLw4PF.js +2 -0
- package/dist/index-DFMaR3pe.js +2 -0
- package/dist/index.cjs.js +11 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.js +13 -13
- package/dist/providers/SpiceFlowProvider.d.ts +0 -2
- package/dist/types/account.d.ts +0 -3
- package/dist/types/assets.d.ts +0 -11
- package/dist/types/authorization.d.ts +0 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/supply.d.ts +1 -7
- package/dist/useSpiceBrand-Dk9KS_yU.js +2 -0
- package/dist/useSpiceBrand-QbPbGjw5.js +2 -0
- package/dist/utils/chains/index.d.ts +0 -2
- package/dist/utils/logos.d.ts +0 -2
- package/dist/utils/relayer/index.d.ts +14 -8
- package/package.json +2 -2
- package/dist/hooks/useSmartWallet.d.ts +0 -1
- package/dist/index-CmpsCAqC.js +0 -2
- package/dist/index-Uh1tWOql.js +0 -2
- package/dist/types/rollup.d.ts +0 -50
- package/dist/useSpiceBrand-CIwsc5dY.js +0 -2
- package/dist/useSpiceBrand-DAo6xoE2.js +0 -2
- package/dist/utils/abis/spicenet.d.ts +0 -49
- package/dist/utils/abis/spicenetWalletManager.d.ts +0 -566
- package/dist/utils/assetDisplay.d.ts +0 -4
- package/dist/utils/rollupBalances.d.ts +0 -14
- /package/dist/{Button-CaguAr48.js → Button-DjsYc4v4.js} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as i,jsxs as p}from"react/jsx-runtime";import z,{useState as E,useEffect as g}from"react";import{B as u,c as C,S as D}from"./Button-
|
|
2
|
+
import{jsx as i,jsxs as p}from"react/jsx-runtime";import z,{useState as E,useEffect as g}from"react";import{B as u,c as C,S as D}from"./Button-DjsYc4v4.js";import{useDynamicContext as T}from"@dynamic-labs/sdk-react-core";import{createWalletClient as j,custom as B}from"viem";import{b as q}from"./index-DFMaR3pe.js";const v=e=>{if(!e)return!1;const t=e.connector;if(!t)return!1;if(t.isEmbeddedWallet===!0)return!0;const n=(t.key||t.connectorKey||"").toLowerCase();if(n.includes("embedded")||n.includes("turnkey"))return!0;const r=(t.name||e.walletName||"").toLowerCase();return!!(r.includes("embedded")||r.includes("turnkey"))},N=e=>(e?.connectedWallets||[]).find(t=>v(t))||(v(e?.primaryWallet)?e.primaryWallet:null),K=e=>(e?.connectedWallets||[]).find(t=>t?.address&&t?.connector&&!v(t))||null,S=async(e,t)=>{if(!e?.address)throw new Error("Wallet not available");if(typeof e.getWalletClient=="function"){const n=t===void 0?[void 0]:[String(t),t,void 0];let r=null;for(const l of n)try{const a=await e.getWalletClient(l);if(a)return a}catch(a){r=a}if(r)throw r}if(typeof e.getEthereumProvider=="function"){const n=await e.getEthereumProvider(),r=t?q(t)?.viemChain:void 0;return j({account:e.address,chain:r,transport:B(n)})}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 n=await S(e,t);return{request:r=>n.request(r)}},O=(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 n=Number(e?.v??27);return Number.isFinite(n)?n>=27?n-27:n:0})()}),$=({onAuthSuccess:e,onAuthError:t,theme:n="light",className:r="",buttonText:l="Login with Dynamic",autoTrigger:a=!1})=>{const o=C(n),[m,P]=E(!1),[w,k]=E(!1),L=T(),{user:A,primaryWallet:b,connectedWallets:F,handleLogOut:I,setShowAuthFlow:h,sdkHasLoaded:f,showAuthFlow:x}=L,s=(N({connectedWallets:F,primaryWallet:b})||b)?.address,W=!!A,c=W&&!!s;return g(()=>{P(!0)},[]),g(()=>{c&&s&&e&&e(s)},[c,s,e]),g(()=>{a&&f&&m&&!c&&!x&&!w&&(k(!0),h(!0))},[a,f,m,c,x,w,h]),m?f?W&&!s?i("div",{className:r,children:p("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[i(D,{size:40,borderWidth:3,color:o.colors.primary}),i("p",{style:{color:o.colors.textMuted,fontSize:"14px"},children:"Finishing wallet setup..."})]})}):c&&s?i("div",{className:r,children:p(u,{variant:"primary",onClick:async()=>{try{await I()}catch(y){const d=`Dynamic logout failed: ${String(y)}`;t?t(d):console.error(d)}},theme:o,children:["Logout (",s.slice(0,6),"...",s.slice(-4),")"]})}):a?i("div",{className:r,children:p("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[i(D,{size:40,borderWidth:3,color:o.colors.primary}),i("p",{style:{color:o.colors.textMuted,fontSize:"14px"},children:"Opening login..."})]})}):i("div",{className:r,children:i(u,{variant:"primary",onClick:()=>{try{h(!0)}catch(y){const d=`Dynamic login failed: ${String(y)}`;t?t(d):console.error(d)}},theme:o,children:l})}):i("div",{className:r,children:i(u,{variant:"primary",disabled:!0,theme:o,children:"Loading..."})}):i("div",{className:r,children:i(u,{variant:"primary",disabled:!0,theme:o,children:l})})};class H extends z.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}}const G=e=>{const{theme:t="light",className:n="",buttonText:r="Login with Dynamic",onAuthError:l}=e,a=C(t);return i(H,{fallback:i("div",{className:n,children:i(u,{variant:"primary",onClick:()=>{l&&l('DynamicLogin must be used within SpiceFlowProvider provider="dynamic" and a mounted DynamicContextProvider.')},theme:a,children:r})}),children:i($,{...e})})};export{G as D,M as a,K as b,S as c,N as g,O as n};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";const r=require("react/jsx-runtime"),d=require("react"),s=require("./Button-B_UpyUH-.js"),q=require("@dynamic-labs/sdk-react-core"),W=require("viem"),z=require("./index-
|
|
2
|
+
"use strict";const r=require("react/jsx-runtime"),d=require("react"),s=require("./Button-B_UpyUH-.js"),q=require("@dynamic-labs/sdk-react-core"),W=require("viem"),z=require("./index-BOMLw4PF.js"),p=e=>{if(!e)return!1;const t=e.connector;if(!t)return!1;if(t.isEmbeddedWallet===!0)return!0;const i=(t.key||t.connectorKey||"").toLowerCase();if(i.includes("embedded")||i.includes("turnkey"))return!0;const n=(t.name||e.walletName||"").toLowerCase();return!!(n.includes("embedded")||n.includes("turnkey"))},j=e=>(e?.connectedWallets||[]).find(t=>p(t))||(p(e?.primaryWallet)?e.primaryWallet:null),B=e=>(e?.connectedWallets||[]).find(t=>t?.address&&t?.connector&&!p(t))||null,b=async(e,t)=>{if(!e?.address)throw new Error("Wallet not available");if(typeof e.getWalletClient=="function"){const i=t===void 0?[void 0]:[String(t),t,void 0];let n=null;for(const c of i)try{const a=await e.getWalletClient(c);if(a)return a}catch(a){n=a}if(n)throw n}if(typeof e.getEthereumProvider=="function"){const i=await e.getEthereumProvider(),n=t?z.getChainConfig(t)?.viemChain:void 0;return W.createWalletClient({account:e.address,chain:n,transport:W.custom(i)})}throw new Error("Wallet client not available")},F=async(e,t)=>{if(!e?.address)throw new Error("Wallet not available");if(typeof e.getEthereumProvider=="function")return e.getEthereumProvider();const i=await b(e,t);return{request:n=>i.request(n)}},I=(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 i=Number(e?.v??27);return Number.isFinite(i)?i>=27?i-27:i:0})()}),T=({onAuthSuccess:e,onAuthError:t,theme:i="light",className:n="",buttonText:c="Login with Dynamic",autoTrigger:a=!1})=>{const o=s.createTheme(i),[h,C]=d.useState(!1),[x,D]=d.useState(!1),P=q.useDynamicContext(),{user:N,primaryWallet:v,connectedWallets:S,handleLogOut:k,setShowAuthFlow:y,sdkHasLoaded:f,showAuthFlow:w}=P,l=(j({connectedWallets:S,primaryWallet:v})||v)?.address,E=!!N,u=E&&!!l;d.useEffect(()=>{C(!0)},[]),d.useEffect(()=>{u&&l&&e&&e(l)},[u,l,e]),d.useEffect(()=>{a&&f&&h&&!u&&!w&&!x&&(D(!0),y(!0))},[a,f,h,u,w,x,y]);const L=()=>{try{y(!0)}catch(g){const m=`Dynamic login failed: ${String(g)}`;t?t(m):console.error(m)}},A=async()=>{try{await k()}catch(g){const m=`Dynamic logout failed: ${String(g)}`;t?t(m):console.error(m)}};return h?f?E&&!l?r.jsx("div",{className:n,children:r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[r.jsx(s.Spinner,{size:40,borderWidth:3,color:o.colors.primary}),r.jsx("p",{style:{color:o.colors.textMuted,fontSize:"14px"},children:"Finishing wallet setup..."})]})}):u&&l?r.jsx("div",{className:n,children:r.jsxs(s.Button,{variant:"primary",onClick:A,theme:o,children:["Logout (",l.slice(0,6),"...",l.slice(-4),")"]})}):a?r.jsx("div",{className:n,children:r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[r.jsx(s.Spinner,{size:40,borderWidth:3,color:o.colors.primary}),r.jsx("p",{style:{color:o.colors.textMuted,fontSize:"14px"},children:"Opening login..."})]})}):r.jsx("div",{className:n,children:r.jsx(s.Button,{variant:"primary",onClick:L,theme:o,children:c})}):r.jsx("div",{className:n,children:r.jsx(s.Button,{variant:"primary",disabled:!0,theme:o,children:"Loading..."})}):r.jsx("div",{className:n,children:r.jsx(s.Button,{variant:"primary",disabled:!0,theme:o,children:c})})};class K extends d.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}}const M=e=>{const{theme:t="light",className:i="",buttonText:n="Login with Dynamic",onAuthError:c}=e,a=s.createTheme(t);return r.jsx(K,{fallback:r.jsx("div",{className:i,children:r.jsx(s.Button,{variant:"primary",onClick:()=>{c&&c('DynamicLogin must be used within SpiceFlowProvider provider="dynamic" and a mounted DynamicContextProvider.')},theme:a,children:n})}),children:r.jsx(T,{...e})})};exports.DynamicLogin=M,exports.getDynamicEmbeddedWallet=j,exports.getDynamicExternalWallet=B,exports.getProviderEthereumProvider=F,exports.getProviderWalletClient=b,exports.normalizeAuthorization=I;
|
package/dist/auth-dynamic.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";const e=require("./auth-dynamic-
|
|
2
|
+
"use strict";const e=require("./auth-dynamic-CaSspPic.js");require("react/jsx-runtime"),require("react"),require("./Button-B_UpyUH-.js"),require("@dynamic-labs/sdk-react-core"),require("viem"),require("./index-BOMLw4PF.js"),require("viem/actions"),require("@spicenet-io/spiceflow-core"),exports.DynamicLogin=e.DynamicLogin;
|
package/dist/auth-dynamic.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{D as e}from"./auth-dynamic-
|
|
2
|
+
import{D as e}from"./auth-dynamic-CG0Ou9V1.js";import"react/jsx-runtime";import"react";import"./Button-DjsYc4v4.js";import"@dynamic-labs/sdk-react-core";import"viem";import"./index-DFMaR3pe.js";import"viem/actions";import"@spicenet-io/spiceflow-core";export{e as DynamicLogin};
|
package/dist/auth-privy.js
CHANGED
|
@@ -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-
|
|
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};
|
|
@@ -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-
|
|
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-Dk9KS_yU.js"),v=require("./Button-B_UpyUH-.js");require("./index-BOMLw4PF.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.js
CHANGED
|
@@ -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-
|
|
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-QbPbGjw5.js";import{B as v}from"./Button-DjsYc4v4.js";import"./index-DFMaR3pe.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};
|
|
@@ -8,7 +8,6 @@ export interface DepositRecoveryPromptProps {
|
|
|
8
8
|
onComplete: (deposit: VerifiedPendingDeposit) => void;
|
|
9
9
|
onCancel: (deposit: VerifiedPendingDeposit) => void;
|
|
10
10
|
onSkip: () => void;
|
|
11
|
-
onChangeWallet?: () => void;
|
|
12
11
|
isProcessing: boolean;
|
|
13
12
|
error?: string | null;
|
|
14
13
|
styles?: CustomStyles;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Address } from "viem";
|
|
3
2
|
import { CustomStyles } from "../../types/theme";
|
|
4
|
-
import { ChainBatch } from "../../types/authorization";
|
|
5
3
|
import { DestinationToken } from "../../types/withdraw";
|
|
6
4
|
export interface SpiceWithdrawProps {
|
|
7
5
|
isOpen: boolean;
|
|
@@ -18,11 +16,6 @@ export interface SpiceWithdrawProps {
|
|
|
18
16
|
autoCloseDelay?: number;
|
|
19
17
|
supportedChains?: number[];
|
|
20
18
|
availableTokens?: Record<number, DestinationToken[]>;
|
|
21
|
-
buildSpicenetBatch?: (params: {
|
|
22
|
-
destinationChainId: number;
|
|
23
|
-
deliveryToken: Address;
|
|
24
|
-
deliveryAmount: bigint;
|
|
25
|
-
}) => ChainBatch | null;
|
|
26
19
|
}
|
|
27
20
|
export declare const SpiceWithdrawFlow: React.FC<SpiceWithdrawProps>;
|
|
28
21
|
export declare const SpiceWithdraw: React.FC<SpiceWithdrawProps>;
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type SpiceflowErrorCode = "WALLET_DISCONNECTED" | "WALLET_REJECTED" | "SIGNATURE_FAILED" | "CONCURRENT_EXECUTION" | "ABORT" | "NO_VENUE_FOR_CHAIN" | "NO_LIQUIDITY" | "VENUE_API_ERROR" | "NO_SWAP_ROUTE" | "ROUTE_TOKEN_NOT_FOUND" | "ROUTE_UNSUPPORTED_INPUT" | "ROUTE_STRATEGY_ERROR" | "INVALID_PARAMS" | "RELAYER_ERROR" | "RELAYER_EXECUTE_ERROR" | "RELAYER_STATUS_ERROR" | "ON_CHAIN_REVERT" | "POLLING_EXHAUSTED" | "POLLING_CONSECUTIVE_FAILURES" | "ALL_ATTEMPTS_FAILED";
|
|
1
|
+
export type SpiceflowErrorCode = "WALLET_DISCONNECTED" | "WALLET_REJECTED" | "SIGNATURE_FAILED" | "CONCURRENT_EXECUTION" | "ABORT" | "NO_VENUE_FOR_CHAIN" | "NO_LIQUIDITY" | "VENUE_API_ERROR" | "NO_SWAP_ROUTE" | "ROUTE_TOKEN_NOT_FOUND" | "ROUTE_UNSUPPORTED_INPUT" | "ROUTE_STRATEGY_ERROR" | "INVALID_PARAMS" | "INVALID_TOKEN_TRANSFER" | "RELAYER_ERROR" | "RELAYER_EXECUTE_ERROR" | "RELAYER_STATUS_ERROR" | "ON_CHAIN_REVERT" | "POLLING_EXHAUSTED" | "POLLING_CONSECUTIVE_FAILURES" | "ALL_ATTEMPTS_FAILED";
|
|
2
2
|
export declare class SpiceflowError extends Error {
|
|
3
3
|
readonly code: SpiceflowErrorCode;
|
|
4
4
|
readonly context: Record<string, unknown>;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -15,4 +15,3 @@ export type { VerifiedPendingDeposit } from "./usePendingDeposit";
|
|
|
15
15
|
export { useSpicePendingDeposits } from "./useSpicePendingDeposits";
|
|
16
16
|
export type { UseSpicePendingDepositsOptions, UseSpicePendingDepositsReturn, } from "./useSpicePendingDeposits";
|
|
17
17
|
export { useSpiceBrand } from "./useSpiceBrand";
|
|
18
|
-
export { useSmartWallet } from "./useSmartWallet";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Address } from "viem";
|
|
1
2
|
import { ChainBatch, Call } from "../../types/authorization";
|
|
2
3
|
export type { Call, ChainBatch };
|
|
3
|
-
export type GaslessStep = "idle" | "building" | "signing-delegation" | "signing-intent" | "submitting" | "executing" | "
|
|
4
|
+
export type GaslessStep = "idle" | "building" | "signing-delegation" | "signing-intent" | "submitting" | "executing" | "success" | "error";
|
|
4
5
|
export interface GaslessProgress {
|
|
5
6
|
step: GaslessStep;
|
|
6
7
|
message: string;
|
|
@@ -9,7 +10,12 @@ export interface GaslessProgress {
|
|
|
9
10
|
}
|
|
10
11
|
export type OnProgress = (progress: GaslessProgress) => void;
|
|
11
12
|
export interface GaslessExecutionOptions {
|
|
13
|
+
depositToEscrow?: {
|
|
14
|
+
token: Address;
|
|
15
|
+
amount: bigint;
|
|
16
|
+
};
|
|
12
17
|
useCustomTransfers?: boolean;
|
|
18
|
+
userOverride?: Address;
|
|
13
19
|
}
|
|
14
20
|
export declare function useSpiceExecution(): {
|
|
15
21
|
executeGasless: (chainBatches: ChainBatch[], tokenAddress: string, tokenTransferAmount: bigint, onProgress?: OnProgress, signal?: AbortSignal, options?: GaslessExecutionOptions) => Promise<string>;
|
|
@@ -17,7 +17,10 @@ export declare function useSupplyAssets(opts: {
|
|
|
17
17
|
_source: "wallet" | "spice";
|
|
18
18
|
})[];
|
|
19
19
|
filteredSpiceAssets: Asset[];
|
|
20
|
+
walletAssets: Asset[];
|
|
20
21
|
embeddedWalletAddress: `0x${string}` | undefined;
|
|
22
|
+
externalAddress: `0x${string}` | undefined;
|
|
23
|
+
isNon7702: boolean;
|
|
21
24
|
refreshSpiceAssets: () => Promise<void>;
|
|
22
25
|
refreshWalletAssets: () => void;
|
|
23
26
|
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";const l=require("viem"),f=require("viem/actions"),i=require("@spicenet-io/spiceflow-core"),d=[{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"}],b="0xcA11bde05977b3631167028862bE2a173976CA11";function C(e){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",contracts:{multicall3:{address:b}}})}const h=[1,8453,42161,4114,11155111,421614,84532,5115,123420001114,688688,688689],c=Object.fromEntries(h.map(e=>i.getChainMeta(e)).filter(e=>e!=null).map(e=>[e.id,{...e,viemChain:C(e),supportedTokens:i.getTokensForChain(e.id)}])),v=c,u=e=>c[e],g=e=>{const t=i.getChainMeta(e);return t?.displayName||t?.name||`Chain ${e}`},w=e=>{const t=i.getDelegateContract(e);if(!t)throw new Error(`Unsupported chain ID: ${e}`);return t},N=(e,t,a)=>{const n=u(e);return n?.blockExplorer?`${n.blockExplorer}/tx/${t}`:"#"},m=new Map,y=e=>{const t=m.get(e);if(t)return t;const a=u(e);if(!a)throw new Error(`Unsupported chain ID: ${e}`);const n=l.createPublicClient({chain:a.viemChain,transport:l.http(a.rpcUrl,{timeout:15e3,retryCount:2,retryDelay:300}),batch:{multicall:{wait:16}}});return m.set(e,n),n},I=()=>{const e={};return Object.values(c).forEach(t=>{e[t.id]={name:t.name,moralisName:t.moralisId||"",chain:t.viemChain,rpcUrl:t.rpcUrl}}),e},k=(e,t=[])=>{const a=u(e);if(!a)return[];const n=[];if(![11155111,421614,84532,688689].includes(e)){const s=t.find(r=>r.chainId===e&&r.isNative);s?n.push(s):n.push({address:i.ZERO_ADDRESS,name:a.nativeCurrency.name,symbol:a.nativeCurrency.symbol,decimals:a.nativeCurrency.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:void 0,isNative:!0,chainId:e})}if(!a.supportedTokens)return n;const o=n.some(s=>s.isNative);return a.supportedTokens.forEach(s=>{if(o&&i.isNativeToken(s.address))return;const r=t.find(p=>p.chainId===e&&p.address.toLowerCase()===s.address.toLowerCase());r?n.push(r):n.push({address:s.address,name:s.name,symbol:s.symbol,decimals:s.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:s.logo,isNative:!1,chainId:e})}),n},E=async(e,t)=>{const a=u(e);if(!a)throw new Error(`Unsupported chain ID: ${e}`);const n=t.toLowerCase();if(i.isNativeToken(n)){if(!a.nativeCurrency?.decimals)throw new Error(`Native currency decimals not configured for chain ${e}`);return a.nativeCurrency.decimals}if(a.supportedTokens){const o=a.supportedTokens.find(s=>s.address.toLowerCase()===n);if(o)return o.decimals}try{if(!l.isAddress(t,{strict:!1}))throw new Error(`Invalid token address: ${t}`);const o=l.getAddress(t),s=y(e),r=await f.readContract(s,{address:o,abi:d,functionName:"decimals"});return Number(r)}catch{throw new Error(`Could not determine decimals for token ${t} on chain ${e}`)}};exports.CHAIN_CONFIGS=v,exports.T=d,exports.getAllAssetsForChain=k,exports.getChainConfig=u,exports.getChainName=g,exports.getChainsForAssets=I,exports.getClientForChain=y,exports.getDelegateContractAddress=w,exports.getExplorerUrl=N,exports.getTokenDecimals=E;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{defineChain as f,createPublicClient as b,http as h,isAddress as C,getAddress as v}from"viem";import{readContract as w}from"viem/actions";import{getChainMeta as p,getTokensForChain as g,getDelegateContract as E,ZERO_ADDRESS as I,isNativeToken as c}from"@spicenet-io/spiceflow-core";const d=[{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"}],k="0xcA11bde05977b3631167028862bE2a173976CA11";function N(e){return f({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",contracts:{multicall3:{address:k}}})}const x=[1,8453,42161,4114,11155111,421614,84532,5115,123420001114,688688,688689],l=Object.fromEntries(x.map(e=>p(e)).filter(e=>e!=null).map(e=>[e.id,{...e,viemChain:N(e),supportedTokens:g(e.id)}])),U=l,i=e=>l[e],_=e=>{const t=p(e);return t?.displayName||t?.name||`Chain ${e}`},A=e=>{const t=E(e);if(!t)throw new Error(`Unsupported chain ID: ${e}`);return t},M=(e,t,a)=>{const n=i(e);return n?.blockExplorer?`${n.blockExplorer}/tx/${t}`:"#"},m=new Map,y=e=>{const t=m.get(e);if(t)return t;const a=i(e);if(!a)throw new Error(`Unsupported chain ID: ${e}`);const n=b({chain:a.viemChain,transport:h(a.rpcUrl,{timeout:15e3,retryCount:2,retryDelay:300}),batch:{multicall:{wait:16}}});return m.set(e,n),n},$=()=>{const e={};return Object.values(l).forEach(t=>{e[t.id]={name:t.name,moralisName:t.moralisId||"",chain:t.viemChain,rpcUrl:t.rpcUrl}}),e},T=(e,t=[])=>{const a=i(e);if(!a)return[];const n=[];if(![11155111,421614,84532,688689].includes(e)){const s=t.find(r=>r.chainId===e&&r.isNative);s?n.push(s):n.push({address:I,name:a.nativeCurrency.name,symbol:a.nativeCurrency.symbol,decimals:a.nativeCurrency.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:void 0,isNative:!0,chainId:e})}if(!a.supportedTokens)return n;const o=n.some(s=>s.isNative);return a.supportedTokens.forEach(s=>{if(o&&c(s.address))return;const r=t.find(u=>u.chainId===e&&u.address.toLowerCase()===s.address.toLowerCase());r?n.push(r):n.push({address:s.address,name:s.name,symbol:s.symbol,decimals:s.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:s.logo,isNative:!1,chainId:e})}),n},D=async(e,t)=>{const a=i(e);if(!a)throw new Error(`Unsupported chain ID: ${e}`);const n=t.toLowerCase();if(c(n)){if(!a.nativeCurrency?.decimals)throw new Error(`Native currency decimals not configured for chain ${e}`);return a.nativeCurrency.decimals}if(a.supportedTokens){const o=a.supportedTokens.find(s=>s.address.toLowerCase()===n);if(o)return o.decimals}try{if(!C(t,{strict:!1}))throw new Error(`Invalid token address: ${t}`);const o=v(t),s=y(e),r=await w(s,{address:o,abi:d,functionName:"decimals"});return Number(r)}catch{throw new Error(`Could not determine decimals for token ${t} on chain ${e}`)}};export{U as C,d as T,y as a,i as b,M as c,A as d,$ as e,T as f,_ as g,D as h};
|