@spicenet-io/spiceflow-ui 3.3.61 → 3.3.63

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.
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ "use strict";var Re=Object.create;var re=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var We=Object.getOwnPropertyNames;var Pe=Object.getPrototypeOf,Ne=Object.prototype.hasOwnProperty;var Ue=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of We(e))!Ne.call(t,n)&&n!==r&&re(t,n,{get:()=>e[n],enumerable:!(a=Te(e,n))||a.enumerable});return t};var N=(t,e,r)=>(r=t!=null?Re(Pe(t)):{},Ue(e||!t||!t.__esModule?re(r,"default",{value:t,enumerable:!0}):r,t));const U=require("react/jsx-runtime"),E=require("react"),T=require("@spicenet-io/spiceflow-core"),x=require("viem"),Me=require("viem/actions"),ae=require("@tanstack/react-query"),I=require("@privy-io/react-auth"),H=require("@dynamic-labs/sdk-react-core"),ne=require("wagmi");function D(t,e){return!t||!e?!1:x.isAddress(t)&&x.isAddress(e)?x.getAddress(t)===x.getAddress(e):t.toLowerCase()===e.toLowerCase()}const se=[{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"}],Oe="0xcA11bde05977b3631167028862bE2a173976CA11",Fe={4114:"0x860aFc632a6D625B95d8B96f39ECC48E988c6962"},Le=new Set([5115]);function je(t){const e=Fe[t.id]??(Le.has(t.id)?void 0:Oe);return x.defineChain({id:t.id,name:t.name,nativeCurrency:t.nativeCurrency,rpcUrls:{default:{http:[t.rpcUrl]}},blockExplorers:{default:{name:t.displayName,url:t.blockExplorer}},testnet:t.network==="testnet",...e?{contracts:{multicall3:{address:e}}}:{}})}const _e=[1,8453,42161,4114,11155111,421614,84532,5115,123420001114,688688,688689],z=Object.fromEntries(_e.map(t=>T.getChainMeta(t)).filter(t=>t!=null).map(t=>[t.id,{...t,viemChain:je(t),supportedTokens:T.getTokensForChain(t.id)}])),De=z;let oe={};const Y=new Map,ie=t=>{oe={...t||{}},Y.clear()},Q=t=>{const e=oe[t];return e&&typeof e=="string"&&e.length>0?e:z[t]?.rpcUrl},M=t=>z[t],X=t=>{const e=T.getChainMeta(t);return e?.displayName||e?.name||`Chain ${t}`},ze=t=>{const e=T.getDelegateContract(t);if(!e)throw new Error(`Unsupported chain ID: ${t}`);return e},qe=(t,e,r)=>{const a=M(t);return a?.blockExplorer?`${a.blockExplorer}/tx/${e}`:"#"};async function Ge(t,e){const r=`0x${e.toString(16)}`;try{await t.request({method:"wallet_switchEthereumChain",params:[{chainId:r}]});return}catch(n){if(!(n?.code===4902||typeof n?.message=="string"&&n.message.includes("Unrecognized chain ID")))throw n}const a=M(e);if(!a)throw new Error(`Cannot add unknown chain ${e} to wallet`);await t.request({method:"wallet_addEthereumChain",params:[{chainId:r,chainName:a.name||`Chain ${e}`,nativeCurrency:a.nativeCurrency||{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:[Q(e)||a.rpcUrl],blockExplorerUrls:a.blockExplorer?[a.blockExplorer]:void 0}]})}const de=t=>{const e=M(t);if(!e)throw new Error(`Unsupported chain ID: ${t}`);const r=Q(t);if(!r)throw new Error(`No RPC URL configured for chain ID: ${t}`);const a=`${t}:${r}`,n=Y.get(a);if(n)return n;const s=x.createPublicClient({chain:e.viemChain,transport:x.http(r,{timeout:15e3,retryCount:2,retryDelay:300}),batch:{multicall:{wait:16}}});return Y.set(a,s),s},Je=()=>{const t={};return Object.values(z).forEach(e=>{t[e.id]={name:e.name,moralisName:e.moralisId||"",chain:e.viemChain,rpcUrl:Q(e.id)||e.rpcUrl}}),t},He=(t,e=[])=>{const r=M(t);if(!r)return[];const a=[];if(![11155111,421614,84532,688689].includes(t)){const s=e.find(d=>d.chainId===t&&d.isNative);s?a.push(s):a.push({address:T.ZERO_ADDRESS,name:r.nativeCurrency.name,symbol:r.nativeCurrency.symbol,decimals:r.nativeCurrency.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:void 0,isNative:!0,chainId:t})}if(!r.supportedTokens)return a;const n=a.some(s=>s.isNative);return r.supportedTokens.forEach(s=>{if(n&&T.isNativeToken(s.address))return;const d=e.find(o=>o.chainId===t&&D(o.address,s.address));d?a.push(d):a.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:t})}),a},Ye=async(t,e)=>{const r=M(t);if(!r)throw new Error(`Unsupported chain ID: ${t}`);const a=e.toLowerCase();if(T.isNativeToken(a)){if(!r.nativeCurrency?.decimals)throw new Error(`Native currency decimals not configured for chain ${t}`);return r.nativeCurrency.decimals}if(r.supportedTokens){const n=r.supportedTokens.find(s=>D(s.address,a));if(n)return n.decimals}try{if(!x.isAddress(e,{strict:!1}))throw new Error(`Invalid token address: ${e}`);const n=x.getAddress(e),s=de(t),d=await Me.readContract(s,{address:n,abi:se,functionName:"decimals"});return Number(d)}catch{throw new Error(`Could not determine decimals for token ${e} on chain ${t}`)}};class C extends Error{constructor(e,r,a={}){super(r),this.code=e,this.context=a,this.name="SpiceflowError",Error.captureStackTrace&&Error.captureStackTrace(this,C)}}function K(t){return t instanceof C}const Qe=["user rejected","user denied","user cancelled","rejected the request","action_rejected","4001"];function le(t){if(!t)return"";if(typeof t=="string")return t;const e=t,r=e.message||e.reason||"",a=e.details||"";return`${r} ${a}`.trim()}const ce=t=>{if(K(t))return t.code==="WALLET_REJECTED";const e=le(t).toLowerCase();return Qe.some(r=>e.includes(r))},Xe=(t,e="Something went wrong. Please try again.")=>ce(t)?"Transaction was rejected.":K(t)?t.message||e:le(t)||e;function Ke(t,e){const r=e.match(/Output amount (\d+) is insufficient after fees (\d+) on chain (\d+)/);if(!r)return e;const[,a,n,s]=r,d=Number(s),o=BigInt(a),m=BigInt(n);let u;for(const p of t.intents){const h=p.chainBatches.find(b=>b.chainId===d);if(h){u=h;break}}const f=u?.tokenTransfers.find(p=>p.from==="escrow"&&D(p.to,t.user)&&!T.isNativeToken(p.token)),l=X(d);if(!f)return`Amount is too small to cover the estimated fee on ${l}.`;const y=T.getTokenByAddress(f.token,d),c=y?.decimals??18,w=y?.symbol??"tokens",i=x.formatUnits(o,c),g=x.formatUnits(m,c);return`Amount is too small to cover the estimated fee on ${l}. Amount: ${i} ${w}. Estimated fee: ${g} ${w}.`}const Ve="https://tx-submission-api.spicenet.io",ue=Ve;function q(t,e){return typeof e=="bigint"?e.toString():e}function $(t,e){if(!t)return e;const r=t.error;return(typeof t.message=="string"?t.message:"")||(r&&typeof r=="object"&&"message"in r&&typeof r.message=="string"?r.message:"")||(typeof r=="string"?r:"")||e}async function Ze(t){try{return await t.json()}catch{return null}}function et(t){return(Array.isArray(t?.balances)?t.balances:[]).flatMap(e=>{if(!e||typeof e!="object")return[];const r=e;return[{receiptToken:typeof r.receiptToken=="string"?r.receiptToken:void 0,tokenName:String(r.tokenName??""),balanceAvailable:String(r.balanceAvailable??"0"),chainTokens:Array.isArray(r.chainTokens)?r.chainTokens.filter(a=>typeof a=="string"):r.chainTokens&&typeof r.chainTokens=="object"?r.chainTokens:r.chainTokenConfig&&typeof r.chainTokenConfig=="object"?r.chainTokenConfig:void 0,decimals:typeof r.decimals=="number"?r.decimals:void 0,balanceUsd:typeof r.balanceUsd=="number"||typeof r.balanceUsd=="string"?r.balanceUsd:null}]})}class tt{constructor(){this.baseUrl=ue}setBaseUrl(e){this.baseUrl=e}getBaseUrl(){return this.baseUrl}async createAction(e){const r=`${this.baseUrl}/actions`,a=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,q)}),n=await a.json();if(!a.ok||n.success===!1)throw new C("RELAYER_ERROR",$(n,`Relayer API error: ${a.status}`),{httpStatus:a.status,responseBody:JSON.stringify(n),endpoint:"/actions"});return n}async estimateActionFees(e){const r=`${this.baseUrl}/actions/fees/estimate`,a=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,q)}),n=await a.json();if(!a.ok||!n.success||!n.data?.feeEstimate){const s=$(n,`Relayer fee estimate error: ${a.status}`);throw new C("RELAYER_ERROR",Ke(e,s),{httpStatus:a.status,responseBody:JSON.stringify(n),endpoint:"/actions/fees/estimate"})}return n.data.feeEstimate}async estimateBatchGas(e){const r=`${this.baseUrl}/actions/gas/estimate`,a=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,q)}),n=await a.json();if(!a.ok||!n.success||!n.data?.gasFee)throw new C("RELAYER_ERROR",$(n,`Relayer gas estimate error: ${a.status}`),{httpStatus:a.status,responseBody:JSON.stringify(n),endpoint:"/actions/gas/estimate"});return{gasFee:BigInt(n.data.gasFee),gasQuoteSource:n.data.gasQuoteSource}}async executeStep(e,r,a,n){const s=`${this.baseUrl}/actions/${e}/intents/${r}/steps/${a}`,d=`/actions/${e}/intents/${r}/steps/${a}`,o=3e4,m=new Promise((l,y)=>setTimeout(()=>y(new C("RELAYER_EXECUTE_ERROR",`Execute step request timed out after ${o/1e3}s`,{actionId:e,intentIndex:r,stepIndex:a,endpoint:d})),o)),u=await Promise.race([fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),m]),f=await u.json();if(!u.ok||f.success===!1)throw new C("RELAYER_EXECUTE_ERROR",$(f,`Execute step error: ${u.status}`),{httpStatus:u.status,responseBody:JSON.stringify(f),endpoint:d,actionId:e});if(f?.status==="error"||f?.status==="reverted"){const l=$(f,""),y=l?`: ${l}`:"";throw new C("RELAYER_EXECUTE_ERROR",`Step ${a} previously ${f.status}${y}`,{httpStatus:u.status,responseBody:JSON.stringify(f),endpoint:d,actionId:e,intentIndex:r,stepIndex:a,stepStatus:f.status})}return{success:!0,transactionHash:f.transactionHash}}async checkStepStatus(e,r){const a=e.split("/"),n=a[0],s=a.length>=2?a[1]:"0",d=`${this.baseUrl}/actions/${n}/intents/${s}/steps/${r}`,o=await fetch(d),m=await o.json();if(!o.ok||m.success===!1)throw new C("RELAYER_STATUS_ERROR",$(m,`Intent step status check failed: ${o.status}`),{httpStatus:o.status,responseBody:JSON.stringify(m),endpoint:d,intentId:e});return{success:!0,data:{status:m.status==="error"?"reverted":m.status,transactionHash:m.txid,error:$(m,"")}}}async createWallet(e,r){const a=`${this.baseUrl}/wallets/${e}`,n=await fetch(a,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),s=await n.json();if(!n.ok||s.success===!1)throw new C("RELAYER_ERROR",$(s,`Create wallet error: ${n.status}`),{httpStatus:n.status,responseBody:JSON.stringify(s),endpoint:`/wallets/${e}`});return s}async getWallet(e){const r=`${this.baseUrl}/wallets/${e}`,a=await fetch(r),n=await a.json();if(!a.ok||n.success===!1)throw new C("RELAYER_ERROR",$(n,`Get wallet error: ${a.status}`),{httpStatus:a.status,responseBody:JSON.stringify(n),endpoint:`/wallets/${e}`});return n}async createWithdrawal(e){const r=`${this.baseUrl}/withdrawals`,a=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,q)}),n=await a.json();if(!a.ok||n.success===!1)throw new C("RELAYER_ERROR",$(n,`Create withdrawal error: ${a.status}`),{httpStatus:a.status,responseBody:JSON.stringify(n),endpoint:"/withdrawals"});return n}async getWithdrawal(e){const r=`${this.baseUrl}/withdrawals/${e}`,a=await fetch(r),n=await a.json();if(!a.ok||n.success===!1)throw new C("RELAYER_ERROR",$(n,`Get withdrawal error: ${a.status}`),{httpStatus:a.status,responseBody:JSON.stringify(n),endpoint:`/withdrawals/${e}`});return n}async getRollupTimestamp(){const e=`${this.baseUrl}/time`,r=await fetch(e),a=await r.json();if(!r.ok||a.success===!1)throw new C("RELAYER_ERROR",$(a,`Get rollup timestamp error: ${r.status}`),{httpStatus:r.status,responseBody:JSON.stringify(a),endpoint:"/time"});return a}}const W=new tt;async function rt(t){const e=`${W.getBaseUrl()}/wallets/${t}/balance`,r=await fetch(e,{cache:"no-store"}),a=await Ze(r);if(!r.ok||a?.success===!1)throw new C("RELAYER_ERROR",$(a,`Unable to verify Spice balance: ${r.status}`),{httpStatus:r.status,responseBody:JSON.stringify(a),endpoint:`/wallets/${t}/balance`});return et(a)}const V=new Map;async function Z(t,e){const r=t.toLowerCase(),a=V.get(r);if(a)return a;const n=(async()=>{try{await W.getWallet(t);return}catch{}const{unix_timestamp:s}=await W.getRollupTimestamp(),d=`I am creating a new smart wallet and adding an admin wallet ethereum:0x${t.slice(2).toLowerCase()}. Nonce: ${s}`,o=await e(d),m=typeof o=="string"?o:o.signature;if(!m)throw new Error("Wallet returned no smart wallet signature");await W.createWallet(t,{timestamp:s,signature:m})})();V.set(r,n);try{await n}finally{V.delete(r)}}const at=(t,e)=>{const r=n=>e?e(n):X(n),a=[];return t.forEach((n,s)=>{const d=n.calls&&n.calls.length>0,o=n.tokenTransfers&&n.tokenTransfers.length>0;!d&&!o||a.push({stepId:s,status:s===0?"processing":"pending",chainId:n.chainId,chainName:r(n.chainId),description:"Processing transaction"})}),a},ee=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 a=(e.name||t.walletName||"").toLowerCase();return!!(a.includes("embedded")||a.includes("turnkey"))},G=t=>(t?.connectedWallets||[]).find(e=>ee(e))||(ee(t?.primaryWallet)?t.primaryWallet:null),nt=t=>(t?.connectedWallets||[]).find(e=>e?.address&&e?.connector&&!ee(e))||null,pe=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 a=null;for(const n of r)try{const s=await t.getWalletClient(n);if(s)return s}catch(s){a=s}if(a)throw a}if(typeof t.getEthereumProvider=="function"){const r=await t.getEthereumProvider(),a=e?M(e)?.viemChain:void 0;return x.createWalletClient({account:t.address,chain:a,transport:x.custom(r)})}throw new Error("Wallet client not available")},fe=async(t,e)=>{if(!t?.address)throw new Error("Wallet not available");if(typeof t.getEthereumProvider=="function")return t.getEthereumProvider();const r=await pe(t,e);return{request:a=>r.request(a)}},st=(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})()}),me=t=>{const e=t?.wallet;if(e?.address&&e.walletClientType==="privy"&&e.connectorType==="embedded"&&!e.imported)return e.address},A=t=>t?.address?{address:t.address,wallet:t,getWalletClient:e=>pe(t,e),getEthereumProvider:e=>fe(t,e)}:null,he=()=>{const t=E.useContext(O),{address:e,connector:r}=ne.useAccount();let a=null,n=null;try{a=I.useWallets(),{user:n}=I.usePrivy()}catch{a=null,n=null}let s=null;try{s=H.useDynamicContext()}catch{s=null}const d=a?.wallets||[],o=I.getEmbeddedConnectedWallet(d),m=o?.address?.toLowerCase(),u=d.find(S=>S.connectorType!=="embedded"&&S.address?.toLowerCase()!==m),f=G(s),l=nt(s),y=f?.address?.toLowerCase(),c=e?.toLowerCase(),w=e&&r&&!(c&&(m&&c===m||y&&c===y))?{address:e,connector:r,getEthereumProvider:()=>r.getProvider()}:null,i=e&&r?{address:e,connector:r,getEthereumProvider:()=>r.getProvider()}:null,g=t?.provider,p=A(o)||A(f),h=A(w)||A(u)||A(l)||null,b=g==="dynamic"?A(f):g==="privy"?A(o):p,v=g==="dynamic"?A(w)||A(l):g==="privy"?A(w)||A(u):h,k=g==="dynamic"?b?.address:g==="privy"?b?.address||me(n):p?.address||me(n),R=A(i)||v;return{embeddedWallet:b,externalWallet:v,embeddedAddress:k,externalAddress:v?.address,activeWallet:R,activeAddress:R?.address}},ot=()=>{const[t,e]=E.useState(!1);let r=null,a=null;try{r=H.useDynamicContext()}catch(c){a=c instanceof Error?c.message:String(c)}if(E.useEffect(()=>{e(!0)},[]),a)return{isReady:!1,isAuthenticated:!1,isConnected:!1,provider:"dynamic",actions:{signAuthorization:async()=>{throw new Error("Dynamic context not available")},signMessage:async()=>{throw new Error("Dynamic context not available")},getEthereumProvider:async()=>{throw new Error("Dynamic context not available")}}};const{user:n,primaryWallet:s,connectedWallets:d}=r||{},o=G({connectedWallets:d,primaryWallet:s})||s,m=!!n,u=o?.address,f={isReady:t&&!!r,isAuthenticated:m,isConnected:m&&!!u,address:u,provider:"dynamic"},l=async c=>{if(!o)throw new Error("Dynamic embedded wallet not available");const{isEthereumWallet:w}=await import("@dynamic-labs/ethereum");if(!w(o))throw new Error("Embedded wallet is not an Ethereum wallet");const i=await o.getWalletClient();if(!i)throw new Error("Dynamic wallet client not available");return{signature:await i.signMessage({message:c,account:o.address})}},y=async()=>{if(!u)throw new Error("Dynamic embedded wallet not available");await Z(u,l)};return{...f,actions:{signAuthorization:async c=>{if(!o)throw new Error("Dynamic embedded wallet not available");await y();const{isEthereumWallet:w}=await import("@dynamic-labs/ethereum");if(!w(o))throw new Error("Embedded wallet is not an Ethereum wallet");const i=o.connector,g={address:o.address,chainId:c.chainId,contractAddress:c.contractAddress,nonce:c.nonce},p={address:c.contractAddress,chainId:c.chainId,nonce:c.nonce},h=typeof i?.getWaasWalletClient=="function"?await i.getWaasWalletClient():null;if(h&&typeof h.signRawMessage=="function"){const{hashAuthorization:b}=await import("viem/experimental"),{parseSignature:v}=await import("viem"),k={address:c.contractAddress,chainId:c.chainId,nonce:c.nonce},R=i.getSignedSessionId,S=typeof R=="function"?await R.call(i):void 0,F=i.getAuthToken,P=typeof F=="function"?F.call(i):void 0,B=await h.signRawMessage({accountAddress:o.address,authToken:P,context:{eip7702Auth:k},message:b(k).slice(2),signedSessionId:S}),L=v(B);return{address:g.contractAddress,chainId:g.chainId,contractAddress:g.contractAddress,nonce:BigInt(g.nonce),r:L.r,s:L.s,yParity:Number(L.yParity)}}if(typeof i?.signAuthorization=="function"){typeof i.switchNetwork=="function"&&await i.switchNetwork({networkChainId:c.chainId});const b=await i.signAuthorization(p);return st(b,g)}throw new Error("Dynamic embedded wallet does not support EIP-7702 authorization. Ensure @dynamic-labs packages are v4.15+.")},signMessage:async c=>{if(!(typeof c=="object"&&"raw"in c))return l(c);if(await y(),!o)throw new Error("Dynamic embedded wallet not available");const w=await o.getWalletClient();if(!w)throw new Error("Dynamic wallet client not available");return{signature:await w.signMessage({message:{raw:c.raw},account:o.address})}},getEthereumProvider:async()=>{if(!o)throw new Error("Dynamic embedded wallet not available");const{isEthereumWallet:c}=await import("@dynamic-labs/ethereum");if(!c(o))throw new Error("Embedded wallet is not an Ethereum wallet");return fe(o)}}}},it=t=>{const e=t?.wallet;if(e?.address&&e.walletClientType==="privy"&&e.connectorType==="embedded"&&!e.imported)return e.address},ye=()=>{const t=E.useContext(O),e=t?.mode||"7702";let r=null,a=null;try{r=I.useWallets(),{user:a}=I.usePrivy()}catch{r=null}const n=I.getEmbeddedConnectedWallet(r?.wallets||[])?.address,s=it(a);let d=null;try{d=H.useDynamicContext()}catch{d=null}const o=(G(d)||d?.primaryWallet)?.address;if(!(!t||e!=="7702"))return t.provider==="privy"?n??s:t.provider==="dynamic"?o:n??s??o},dt=()=>{const t=E.useContext(O)?.mode,{isConnected:e,address:r}=ne.useAccount();let a=null,n=null,s=null,d=null,o=null;try{a=I.usePrivy(),n=I.useSign7702Authorization(),s=I.useSignMessage(),d=I.useWallets()}catch(p){o=p instanceof Error?p.message:String(p)}if(o)return t==="ondemand"&&e&&r?{isReady:!0,isAuthenticated:!0,isConnected:!0,address:r,provider:"privy",actions:{signAuthorization:async()=>{throw new Error("Not available in ondemand mode")},signMessage:async()=>{throw new Error("Not available in ondemand mode")},getEthereumProvider:async()=>{throw new Error("Not available in ondemand mode")}}}:{isReady:!1,isAuthenticated:!1,isConnected:!1,provider:null,actions:{signAuthorization:async()=>{throw new Error("Privy not available")},signMessage:async()=>{throw new Error("Privy not available")},getEthereumProvider:async()=>{throw new Error("Privy not available")}}};const{ready:m=!1,authenticated:u=!1}=a||{},f=ye(),l=I.getEmbeddedConnectedWallet(d?.wallets||[]),y=f||l?.address,c=!!y&&!!l,w={isReady:t==="ondemand"?!0:m,isAuthenticated:t==="ondemand"?!0:u||c,isConnected:t==="ondemand"?e&&!!r||m&&(u||c)&&c:m&&c,address:t==="ondemand"&&!f&&e?r:y,provider:"privy"},i=async p=>{if(s)try{return{signature:(await s.signMessage({message:p})).signature}}catch(k){if(!l)throw k}if(!l)throw new Error("Privy sign message not available");const h=await l.getEthereumProvider(),{createWalletClient:b,custom:v}=await import("viem");return{signature:await b({account:l.address,transport:v(h)}).signMessage({account:l.address,message:p})}},g=async()=>{if(!y)throw new Error("Embedded wallet not available for smart wallet setup");await Z(y,i)};return{...w,actions:{signAuthorization:async p=>{if(!n)throw new Error("Privy sign authorization not available");try{await g();const h=await n.signAuthorization({contractAddress:p.contractAddress,chainId:p.chainId,nonce:p.nonce},{address:y});return delete h.v,h}catch(h){const b=typeof h?.message=="string"?h.message:String(h?.message??h??"");throw b.includes("not configured")||b.includes("chain")?new Error(`Chain ${p.chainId} is not configured in PrivyProvider. Add this chain to your Privy dashboard or supportedChainIds.`):h}},signMessage:async p=>{if(typeof p=="object"&&"raw"in p){if(await g(),!l)throw new Error("Embedded wallet not available for raw signing");const h=await l.getEthereumProvider(),{createWalletClient:b,custom:v}=await import("viem");return{signature:await b({account:l.address,transport:v(h)}).signMessage({account:l.address,message:p})}}return i(p)},getEthereumProvider:async()=>{if(!l)throw new Error("Embedded wallet not available");return l.getEthereumProvider()}}}},ge=()=>{const t=E.useContext(O)?.provider,e=dt(),r=ot();return t==="privy"?e:t==="dynamic"?r:{isReady:!1,isAuthenticated:!1,isConnected:!1,provider:null,actions:{signAuthorization:async()=>{throw new Error("No wallet provider available")},signMessage:async()=>{throw new Error("No wallet provider available")},getEthereumProvider:async()=>{throw new Error("No wallet provider available")}}}},lt="https://portal-api.spicenet.io/api/v1",te=t=>t.replace(/\/+$/,""),ct=(t,e)=>`${t}:${e}`;async function ut(t,e){const r=new URLSearchParams({walletAddress:e,campaignId:"spicenet-portal",campaignGroup:"1"}),a=await fetch(`${t}/portal/mainnet/linked-portal-wallet?${r.toString()}`,{cache:"no-store"});return a.ok?(await a.json()).portalWalletAddress?.toLowerCase()??null:null}async function pt(t,e,r){const a=new URLSearchParams({walletAddress:e,campaignId:r.campaignId,campaignGroup:r.campaignGroup,partnerId:r.partnerId}),n=await fetch(`${t}/portal/mainnet/whitelist/check?${a.toString()}`,{cache:"no-store"});if(!n.ok)throw new Error(`Failed to check whitelist: ${n.status}`);return await n.json()}async function ft(t,e,r,a){const n=await fetch(`${t}/portal/mainnet/link-wallet`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({campaignId:e.campaignId,campaignGroup:e.campaignGroup,partnerId:e.partnerId,externalWalletAddress:r,embeddedWalletAddress:a})});if(!n.ok)throw new Error(`Failed to link wallet: ${n.status}`)}function we({walletAddress:t,campaignId:e,campaignGroup:r,partnerId:a,apiBaseUrl:n=lt,enabled:s=!0,staleTime:d=5*60*1e3,refetchInterval:o=!1}={}){const{isAuthenticated:m,isConnected:u}=ge(),{externalAddress:f,embeddedAddress:l}=he(),y=t??f,c=typeof y=="string"?y.toLowerCase():void 0,w=typeof l=="string"?l.toLowerCase():void 0,i=typeof f=="string"?f.toLowerCase():void 0,g=s&&m&&u&&!!f&&!!c&&x.isAddress(c)&&!!e&&!!r&&!!a,p=E.useMemo(()=>["partner-whitelist","check",c,e,r,a,te(n)],[c,e,r,a,n]),h=ae.useQuery({queryKey:p,enabled:g,staleTime:d,refetchInterval:o,queryFn:async()=>{if(!c||!x.isAddress(c))throw new Error("A valid wallet address is required");if(!e||!r||!a)throw new Error("campaignId, campaignGroup, and partnerId are required");const S=te(n),F={campaignId:e,campaignGroup:r,partnerId:a},P=await ut(S,c);return P?pt(S,P,F):{walletAddress:c,campaignId:e,campaignGroup:r,partnerId:a,isWhitelisted:!1,isLinkedWallet:!1,whitelistedWalletAddress:null,externalWalletAddress:c}}}),b=s&&m&&u&&!!i&&x.isAddress(i)&&!!w&&x.isAddress(w)&&!!e&&!!r&&!!a,v=ae.useMutation({mutationFn:S=>ft(te(n),{campaignId:e,campaignGroup:r,partnerId:a},S.external,S.embedded)}),k=E.useRef(new Set),R=v.mutate;return E.useEffect(()=>{if(!b||!i||!w||!e||!r||!a)return;const S=ct(i,w);k.current.has(S)||(k.current.add(S),R({external:i,embedded:w}))},[b,i,w,e,r,a,R]),{isWhitelisted:h.data?.isWhitelisted??!1,whitelistCheck:h.data,checkedWalletAddress:c,externalWalletAddress:f,embeddedWalletAddress:l,isExternalWalletConnected:!!f,isWhitelistCheckEnabled:g,linkWallet:v,isWalletLinked:v.isSuccess,...h}}const be="spiceflow-mode",Ee=()=>{if(typeof window>"u")return null;try{const t=window.localStorage.getItem(be);return t==="7702"?"7702":t==="non7702"?"ondemand":t==="embedded"?"7702":t==="external"?"ondemand":null}catch{return null}},mt=t=>{if(!(typeof window>"u"))try{window.localStorage.setItem(be,t==="7702"?"7702":"non7702")}catch{}},ht=()=>Ee()!==null,ve=E.createContext(null),yt=["__spicenet_whitelist_blocked__"],O=E.createContext(null),gt=({children:t,value:e,whitelist:r})=>{const a=r!==!1&&!!r&&r.enabled!==!1,n=we(a?r:{enabled:!1}),s=a&&n.isWhitelistCheckEnabled&&n.isSuccess,d=a&&(!s||!n.isWhitelisted),o=E.useMemo(()=>({...e,allowedTokens:d?yt:e.allowedTokens,mode:d?"ondemand":e.mode,isUserWhitelisted:s?n.isWhitelisted:null,isWhitelistChecking:a&&n.isWhitelistCheckEnabled&&(n.isLoading||n.isFetching),isWhitelistConfigured:a,isWhitelistGateActive:d,whitelistCheck:n.whitelistCheck}),[e,a,d,s,n.isWhitelisted,n.isWhitelistCheckEnabled,n.isLoading,n.isFetching,n.whitelistCheck]);return U.jsx(O.Provider,{value:o,children:t})},wt=({children:t,provider:e,supportedChainIds:r,allowedTokens:a,network:n="testnet",mode:s,skipFlow:d=[],nativeChainId:o,appName:m="Spicenet",apiUrl:u,theme:f,rpcOverrides:l,whitelist:y})=>{E.useEffect(()=>{if(!u)return;const v=W.getBaseUrl();return W.setBaseUrl(u),()=>W.setBaseUrl(v)},[u]),E.useEffect(()=>(ie(l),()=>ie(void 0)),[l]);const c=E.useMemo(()=>T.getChainIdsByNetwork(n),[n]),w=r??c,i=f??null,[g,p]=E.useState(()=>s??Ee()??"7702");E.useEffect(()=>{s&&p(s)},[s]);const h=E.useCallback(v=>{if(s){p(s);return}p(v),mt(v)},[s]),b=E.useMemo(()=>({provider:e,supportedChainIds:w,allowedTokens:a,skipFlow:d,mode:g,setMode:h,network:n,nativeChainId:o,appName:m,apiUrl:u,rpcOverrides:l,isUserWhitelisted:null,isWhitelistChecking:!1,isWhitelistConfigured:!1,isWhitelistGateActive:!1}),[e,w,a,d,g,h,n,o,m,u,l]);return U.jsx(ve.Provider,{value:i,children:U.jsx(O.Provider,{value:b,children:U.jsx(gt,{value:b,whitelist:y,children:t})})})},bt={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"}},Et={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"},vt={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"},xe=(t="light")=>({mode:t,...bt,colors:t==="light"?Et:vt});function J(t,e){const r=t.replace("#",""),a=Math.max(0,Math.round(parseInt(r.substring(0,2),16)*(1-e))),n=Math.max(0,Math.round(parseInt(r.substring(2,4),16)*(1-e))),s=Math.max(0,Math.round(parseInt(r.substring(4,6),16)*(1-e)));return`#${a.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`}function xt(t,e){return{shell:e?.shell??"#141414",shellBorder:e?.shellBorder??J(e?.shell??"#141414",.35),shellInnerBorder:e?.shellInnerBorder??J(e?.shell??"#141414",.55),cardBg:e?.cardBg??"#1e1e1e",inputBg:e?.inputBg??"#171717",hoverBg:e?.hoverBg??"#2a2a2a",textPrimary:e?.textPrimary??"#ffffff",textSecondary:e?.textSecondary??"#888888",inputText:e?.inputText??"#e0e0e0",inputPlaceholder:e?.inputPlaceholder??"#555555",cardBorder:e?.cardBorder??"rgba(255,255,255,0.08)",inputBorder:e?.inputBorder??"rgba(255,255,255,0.10)",buttonBorder:e?.buttonBorder??"rgba(255,255,255,0.12)",successBg:e?.successBg??"#0a1f18",successBorder:e?.successBorder??"#1a4a3a",successText:e?.successText??"#6ee7b7",warningBg:e?.warningBg??"#1f1a0d",warningBorder:e?.warningBorder??"#4a3820",warningText:e?.warningText??"#fbbf24",errorBg:e?.errorBg??"#1f0d0d",errorBorder:e?.errorBorder??"#4a2020",errorText:e?.errorText??"#f87171",infoBg:e?.infoBg??"#0d1325",infoBorder:e?.infoBorder??"#2a3a5a",infoText:e?.infoText??"#60a5fa"}}function Ct(t){return{shell:"#ffffff",shellBorder:"#E9E9E9",shellInnerBorder:"#D5D5D5",cardBg:"#f9fafb",inputBg:"#ffffff",hoverBg:"#f3f4f6",textPrimary:"#111827",textSecondary:"#6b7280",inputText:"#111827",inputPlaceholder:"#9ca3af",cardBorder:"#e5e7eb",inputBorder:"#d1d5db",buttonBorder:"#0e0d0b",successBg:"#d1fae5",successBorder:"#6ee7b7",successText:"#065f46",warningBg:"#fef3c7",warningBorder:"#fde68a",warningText:"#92400e",errorBg:"#fef2f2",errorBorder:"#fecaca",errorText:"#dc2626",infoBg:"#dbeafe",infoBorder:"#93c5fd",infoText:"#1e40af"}}function Ce(t,e){const r=e?{...t,...e}:t,a=r.dark??!1,n=r.primaryColor,s=r.shell??(a?"#141414":"#ffffff");return{primaryColor:n,dark:a,fontFamily:r.fontFamily??'"Helvetica Neue", sans-serif',appName:r.appName??"Spicenet",logo:r.logo,borderRadius:r.borderRadius??"8px",shell:s,shellBorder:J(s,a?.35:.085),shellInnerBorder:J(s,a?.55:.165),card:r.card??(a?"#1e1e1e":"#f9fafb"),input:a?"#171717":"#ffffff",hover:a?"#2a2a2a":"#f3f4f6",text:r.text??(a?"#ffffff":"#111827"),textMuted:r.textMuted??(a?"#888888":"#6b7280"),inputText:a?"#e0e0e0":"#111827",inputPlaceholder:a?"#555555":"#9ca3af",border:r.border??(a?"rgba(255,255,255,0.08)":"#e5e7eb"),inputBorder:a?"rgba(255,255,255,0.10)":"#d1d5db",buttonBorder:a?"rgba(255,255,255,0.12)":"#0e0d0b",successBg:a?"#0a1f18":"#d1fae5",successBorder:a?"#1a4a3a":"#6ee7b7",successText:a?"#6ee7b7":"#065f46",warningBg:a?"#1f1a0d":"#fef3c7",warningBorder:a?"#4a3820":"#fde68a",warningText:a?"#fbbf24":"#92400e",errorBg:a?"#1f0d0d":"#fef2f2",errorBorder:a?"#4a2020":"#fecaca",errorText:a?"#f87171":"#dc2626",infoBg:a?"#0d1325":"#dbeafe",infoBorder:a?"#2a3a5a":"#93c5fd",infoText:a?"#60a5fa":"#1e40af"}}const St='"IBM Plex Mono", monospace';function Se(t,e){const r=E.useContext(ve)??void 0;return E.useMemo(()=>{const a=r??{primaryColor:"#EA4B4B"},n={...t?.primaryColor?{primaryColor:t.primaryColor}:{},...t?.fontFamily?{fontFamily:t.fontFamily}:{},...e!==void 0?{dark:e}:{}},s=Ce(a,n),{dark:d,primaryColor:o,appName:m}=s,u=xe(d?"dark":"light"),f={...u,colors:{...u.colors,primary:o,primaryHover:`${o}dd`},typography:{...u.typography,fontFamily:s.fontFamily}},l={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},y=t?.inputVariant?t.inputVariant==="dark":d;return{brand:r,theme:f,dark:d,appName:m,primaryColor:o,dk:l,palette:l,fontFamily:s.fontFamily,monoFont:St,inputDark:y,cardBg:y?l.cardBg:"#E9E9E9",cardBorder:y?l.cardBorder:"#C6C6C6",textPrimary:l.textPrimary,textSecondary:l.textSecondary,subtitleText:y?l.textSecondary:"#979AA0"}},[r,t,e])}const Be="spiceflow-spinner-keyframes";function Bt(){if(typeof document>"u"||document.getElementById(Be))return;const t=document.createElement("style");t.id=Be,t.textContent="@keyframes spiceflow-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}",document.head.appendChild(t)}const ke=({size:t=16,borderWidth:e=2,color:r="currentColor",style:a})=>{const n=E.useRef(!1);return E.useEffect(()=>{n.current||(Bt(),n.current=!0)},[]),U.jsx("div",{role:"status","aria-label":"Loading",style:{width:`${t}px`,height:`${t}px`,border:`${e}px solid ${r}`,borderTop:`${e}px solid transparent`,borderRadius:"50%",animation:"spiceflow-spin 1s linear infinite",flexShrink:0,...a}})},kt=({variant:t="primary",size:e="md",loading:r=!1,fullWidth:a=!1,disabled:n,children:s,className:d="",style:o,theme:m,styles:u,dark:f,...l})=>{const{theme:y,dark:c,palette:w}=Se(u,f),i=m||y,g=f??c,[p,h]=E.useState(!1),[b,v]=E.useState(!1),k=g?w.shell:"white",R=()=>{switch(t){case"primary":return{backgroundColor:u?.button?.backgroundColor||i.colors.primary,color:u?.button?.color||"#ffffff",border:`1px solid ${u?.button?.backgroundColor||i.colors.primary}`};case"secondary":return{backgroundColor:i.colors.secondary,color:i.colors.text,border:`1px solid ${i.colors.border}`};case"success":return{backgroundColor:i.colors.success,color:i.colors.text,border:`1px solid ${i.colors.success}`};case"error":return{backgroundColor:i.colors.error,color:i.colors.text,border:`1px solid ${i.colors.error}`};case"ghost":return{backgroundColor:"transparent",color:i.colors.textSecondary,border:`1px solid ${i.colors.border}`};case"outline":{const B=u?.button?.backgroundColor||i.colors.primary,L=u?.button?.color||(g?"#ffffff":"#0e0d0b"),j=u?.button?.borderColor||(g?`${i.colors.primary}88`:"#0e0d0b"),_=n||r,$e=g?"1px":"1.5px",Ae=u?.button?.disabledBackgroundColor||`${B}88`,Ie=u?.button?.disabledColor||L;return{height:"56px",backgroundColor:_?Ae:b?`${B}cc`:p?`${B}ee`:B,color:_?Ie:L,border:`${$e} solid ${j}`,borderRadius:u?.button?.borderRadius||"12px",fontSize:"22px",fontWeight:500,fontFamily:'"IBM Plex Mono", monospace',opacity:_?.78:1,transform:_?"none":b?"scale(0.98)":p?"translateY(-2px)":"none",boxShadow:_?`3px 3px 0px ${k}, 4px 4px 0px ${j}`:b?`2px 2px 0px ${j}`:p?`5px 5px 0px ${k}, 6px 6px 0px ${j}`:`3px 3px 0px ${k}, 4px 4px 0px ${j}`,transition:"transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease, border-color 150ms ease, color 150ms ease"}}default:return{}}},S=()=>{if(t==="outline")return{};switch(e){case"sm":return{padding:`${i.spacing.sm} ${i.spacing.md}`,fontSize:i.typography.fontSize.sm};case"md":return{padding:`${i.spacing.md} ${i.spacing.lg}`,fontSize:i.typography.fontSize.base};case"lg":return{padding:`${i.spacing.lg} ${i.spacing.xl}`,fontSize:i.typography.fontSize.lg};default:return{}}},F={borderRadius:u?.button?.borderRadius||i.borderRadius.md,fontWeight:u?.button?.fontWeight||i.typography.fontWeight.medium,fontFamily:u?.button?.fontFamily||i.typography.fontFamily,fontSize:u?.button?.fontSize||void 0,transition:"background-color 150ms ease, border-color 150ms ease, color 150ms ease, opacity 150ms ease",cursor:n||r?"not-allowed":"pointer",opacity:(n||r)&&t!=="outline"?.6:1,width:a?"100%":"auto",display:"flex",alignItems:"center",justifyContent:"center",gap:i.spacing.sm,...R(),...S(),...u?.button?.fontSize&&{fontSize:u.button.fontSize}},P=n||r;return U.jsxs("button",{type:l.type??"button","data-spiceflow-focus":!0,"aria-busy":r||void 0,"aria-disabled":P||void 0,style:{...F,...o},className:d,disabled:P,onMouseEnter:B=>{h(!0),l.onMouseEnter?.(B)},onMouseLeave:B=>{h(!1),v(!1),l.onMouseLeave?.(B)},onMouseDown:B=>{v(!0),l.onMouseDown?.(B)},onMouseUp:B=>{v(!1),l.onMouseUp?.(B)},...l,children:[r&&U.jsx(ke,{size:16}),s]})};exports.Button=kt,exports.CHAIN_CONFIGS=De,exports.RELAYER_API_URL=ue,exports.SpiceFlowProvider=wt,exports.SpiceFlowProviderContext=O,exports.SpiceflowError=C,exports.Spinner=ke,exports.addressesEqual=D,exports.buildDarkPalette=xt,exports.buildLightPalette=Ct,exports.createInitialSteps=at,exports.createTheme=xe,exports.ensureSmartWallet=Z,exports.ensureWalletOnChain=Ge,exports.getAllAssetsForChain=He,exports.getChainConfig=M,exports.getChainName=X,exports.getChainsForAssets=Je,exports.getClientForChain=de,exports.getDelegateContractAddress=ze,exports.getDynamicEmbeddedWallet=G,exports.getExplorerUrl=qe,exports.getTokenDecimals=Ye,exports.getWalletBalanceEntries=rt,exports.hasStoredSpiceFlowMode=ht,exports.isSpiceflowError=K,exports.isUserRejection=ce,exports.j=se,exports.relayerService=W,exports.resolveTheme=Ce,exports.sanitizeError=Xe,exports.useEmbeddedWalletAddress=ye,exports.useIsUserWhitelisted=we,exports.useProviderWallets=he,exports.useSpiceBrand=Se,exports.useWallet=ge;
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{jsx as U,jsxs as Oe}from"react/jsx-runtime";import{useContext as L,useState as j,useEffect as M,useMemo as _,useRef as ie,createContext as de,useCallback as Fe}from"react";import{getChainMeta as le,getTokensForChain as Le,getDelegateContract as _e,ZERO_ADDRESS as je,isNativeToken as Y,getTokenByAddress as De,getChainIdsByNetwork as ze}from"@spicenet-io/spiceflow-core";import{isAddress as R,getAddress as q,defineChain as Ge,createPublicClient as Je,http as He,formatUnits as ce,createWalletClient as Ye,custom as qe}from"viem";import{readContract as Qe}from"viem/actions";import{useQuery as Xe,useMutation as Ke}from"@tanstack/react-query";import{useWallets as Q,usePrivy as X,getEmbeddedConnectedWallet as K,useSign7702Authorization as Ve,useSignMessage as Ze}from"@privy-io/react-auth";import{useDynamicContext as V}from"@dynamic-labs/sdk-react-core";import{useAccount as ue}from"wagmi";function D(t,e){return!t||!e?!1:R(t)&&R(e)?q(t)===q(e):t.toLowerCase()===e.toLowerCase()}const pe=[{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"}],et="0xcA11bde05977b3631167028862bE2a173976CA11",tt={4114:"0x860aFc632a6D625B95d8B96f39ECC48E988c6962"},rt=new Set([5115]);function at(t){const e=tt[t.id]??(rt.has(t.id)?void 0:et);return Ge({id:t.id,name:t.name,nativeCurrency:t.nativeCurrency,rpcUrls:{default:{http:[t.rpcUrl]}},blockExplorers:{default:{name:t.displayName,url:t.blockExplorer}},testnet:t.network==="testnet",...e?{contracts:{multicall3:{address:e}}}:{}})}const nt=[1,8453,42161,4114,11155111,421614,84532,5115,123420001114,688688,688689],z=Object.fromEntries(nt.map(t=>le(t)).filter(t=>t!=null).map(t=>[t.id,{...t,viemChain:at(t),supportedTokens:Le(t.id)}])),st=z;let fe={};const Z=new Map,me=t=>{fe={...t||{}},Z.clear()},ee=t=>{const e=fe[t];return e&&typeof e=="string"&&e.length>0?e:z[t]?.rpcUrl},T=t=>z[t],te=t=>{const e=le(t);return e?.displayName||e?.name||`Chain ${t}`},ot=t=>{const e=_e(t);if(!e)throw new Error(`Unsupported chain ID: ${t}`);return e},it=(t,e,r)=>{const a=T(t);return a?.blockExplorer?`${a.blockExplorer}/tx/${e}`:"#"};async function dt(t,e){const r=`0x${e.toString(16)}`;try{await t.request({method:"wallet_switchEthereumChain",params:[{chainId:r}]});return}catch(n){if(!(n?.code===4902||typeof n?.message=="string"&&n.message.includes("Unrecognized chain ID")))throw n}const a=T(e);if(!a)throw new Error(`Cannot add unknown chain ${e} to wallet`);await t.request({method:"wallet_addEthereumChain",params:[{chainId:r,chainName:a.name||`Chain ${e}`,nativeCurrency:a.nativeCurrency||{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:[ee(e)||a.rpcUrl],blockExplorerUrls:a.blockExplorer?[a.blockExplorer]:void 0}]})}const he=t=>{const e=T(t);if(!e)throw new Error(`Unsupported chain ID: ${t}`);const r=ee(t);if(!r)throw new Error(`No RPC URL configured for chain ID: ${t}`);const a=`${t}:${r}`,n=Z.get(a);if(n)return n;const s=Je({chain:e.viemChain,transport:He(r,{timeout:15e3,retryCount:2,retryDelay:300}),batch:{multicall:{wait:16}}});return Z.set(a,s),s},lt=()=>{const t={};return Object.values(z).forEach(e=>{t[e.id]={name:e.name,moralisName:e.moralisId||"",chain:e.viemChain,rpcUrl:ee(e.id)||e.rpcUrl}}),t},ct=(t,e=[])=>{const r=T(t);if(!r)return[];const a=[];if(![11155111,421614,84532,688689].includes(t)){const s=e.find(d=>d.chainId===t&&d.isNative);s?a.push(s):a.push({address:je,name:r.nativeCurrency.name,symbol:r.nativeCurrency.symbol,decimals:r.nativeCurrency.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:void 0,isNative:!0,chainId:t})}if(!r.supportedTokens)return a;const n=a.some(s=>s.isNative);return r.supportedTokens.forEach(s=>{if(n&&Y(s.address))return;const d=e.find(o=>o.chainId===t&&D(o.address,s.address));d?a.push(d):a.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:t})}),a},ut=async(t,e)=>{const r=T(t);if(!r)throw new Error(`Unsupported chain ID: ${t}`);const a=e.toLowerCase();if(Y(a)){if(!r.nativeCurrency?.decimals)throw new Error(`Native currency decimals not configured for chain ${t}`);return r.nativeCurrency.decimals}if(r.supportedTokens){const n=r.supportedTokens.find(s=>D(s.address,a));if(n)return n.decimals}try{if(!R(e,{strict:!1}))throw new Error(`Invalid token address: ${e}`);const n=q(e),s=he(t),d=await Qe(s,{address:n,abi:pe,functionName:"decimals"});return Number(d)}catch{throw new Error(`Could not determine decimals for token ${e} on chain ${t}`)}};class E extends Error{constructor(e,r,a={}){super(r),this.code=e,this.context=a,this.name="SpiceflowError",Error.captureStackTrace&&Error.captureStackTrace(this,E)}}function re(t){return t instanceof E}const pt=["user rejected","user denied","user cancelled","rejected the request","action_rejected","4001"];function ye(t){if(!t)return"";if(typeof t=="string")return t;const e=t,r=e.message||e.reason||"",a=e.details||"";return`${r} ${a}`.trim()}const ge=t=>{if(re(t))return t.code==="WALLET_REJECTED";const e=ye(t).toLowerCase();return pt.some(r=>e.includes(r))},ft=(t,e="Something went wrong. Please try again.")=>ge(t)?"Transaction was rejected.":re(t)?t.message||e:ye(t)||e;function mt(t,e){const r=e.match(/Output amount (\d+) is insufficient after fees (\d+) on chain (\d+)/);if(!r)return e;const[,a,n,s]=r,d=Number(s),o=BigInt(a),m=BigInt(n);let u;for(const p of t.intents){const h=p.chainBatches.find(b=>b.chainId===d);if(h){u=h;break}}const f=u?.tokenTransfers.find(p=>p.from==="escrow"&&D(p.to,t.user)&&!Y(p.token)),l=te(d);if(!f)return`Amount is too small to cover the estimated fee on ${l}.`;const y=De(f.token,d),c=y?.decimals??18,w=y?.symbol??"tokens",i=ce(o,c),g=ce(m,c);return`Amount is too small to cover the estimated fee on ${l}. Amount: ${i} ${w}. Estimated fee: ${g} ${w}.`}const ht="https://tx-submission-api.spicenet.io",we=ht;function G(t,e){return typeof e=="bigint"?e.toString():e}function k(t,e){if(!t)return e;const r=t.error;return(typeof t.message=="string"?t.message:"")||(r&&typeof r=="object"&&"message"in r&&typeof r.message=="string"?r.message:"")||(typeof r=="string"?r:"")||e}async function yt(t){try{return await t.json()}catch{return null}}function gt(t){return(Array.isArray(t?.balances)?t.balances:[]).flatMap(e=>{if(!e||typeof e!="object")return[];const r=e;return[{receiptToken:typeof r.receiptToken=="string"?r.receiptToken:void 0,tokenName:String(r.tokenName??""),balanceAvailable:String(r.balanceAvailable??"0"),chainTokens:Array.isArray(r.chainTokens)?r.chainTokens.filter(a=>typeof a=="string"):r.chainTokens&&typeof r.chainTokens=="object"?r.chainTokens:r.chainTokenConfig&&typeof r.chainTokenConfig=="object"?r.chainTokenConfig:void 0,decimals:typeof r.decimals=="number"?r.decimals:void 0,balanceUsd:typeof r.balanceUsd=="number"||typeof r.balanceUsd=="string"?r.balanceUsd:null}]})}class wt{constructor(){this.baseUrl=we}setBaseUrl(e){this.baseUrl=e}getBaseUrl(){return this.baseUrl}async createAction(e){const r=`${this.baseUrl}/actions`,a=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,G)}),n=await a.json();if(!a.ok||n.success===!1)throw new E("RELAYER_ERROR",k(n,`Relayer API error: ${a.status}`),{httpStatus:a.status,responseBody:JSON.stringify(n),endpoint:"/actions"});return n}async estimateActionFees(e){const r=`${this.baseUrl}/actions/fees/estimate`,a=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,G)}),n=await a.json();if(!a.ok||!n.success||!n.data?.feeEstimate){const s=k(n,`Relayer fee estimate error: ${a.status}`);throw new E("RELAYER_ERROR",mt(e,s),{httpStatus:a.status,responseBody:JSON.stringify(n),endpoint:"/actions/fees/estimate"})}return n.data.feeEstimate}async estimateBatchGas(e){const r=`${this.baseUrl}/actions/gas/estimate`,a=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,G)}),n=await a.json();if(!a.ok||!n.success||!n.data?.gasFee)throw new E("RELAYER_ERROR",k(n,`Relayer gas estimate error: ${a.status}`),{httpStatus:a.status,responseBody:JSON.stringify(n),endpoint:"/actions/gas/estimate"});return{gasFee:BigInt(n.data.gasFee),gasQuoteSource:n.data.gasQuoteSource}}async executeStep(e,r,a,n){const s=`${this.baseUrl}/actions/${e}/intents/${r}/steps/${a}`,d=`/actions/${e}/intents/${r}/steps/${a}`,o=3e4,m=new Promise((l,y)=>setTimeout(()=>y(new E("RELAYER_EXECUTE_ERROR",`Execute step request timed out after ${o/1e3}s`,{actionId:e,intentIndex:r,stepIndex:a,endpoint:d})),o)),u=await Promise.race([fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),m]),f=await u.json();if(!u.ok||f.success===!1)throw new E("RELAYER_EXECUTE_ERROR",k(f,`Execute step error: ${u.status}`),{httpStatus:u.status,responseBody:JSON.stringify(f),endpoint:d,actionId:e});if(f?.status==="error"||f?.status==="reverted"){const l=k(f,""),y=l?`: ${l}`:"";throw new E("RELAYER_EXECUTE_ERROR",`Step ${a} previously ${f.status}${y}`,{httpStatus:u.status,responseBody:JSON.stringify(f),endpoint:d,actionId:e,intentIndex:r,stepIndex:a,stepStatus:f.status})}return{success:!0,transactionHash:f.transactionHash}}async checkStepStatus(e,r){const a=e.split("/"),n=a[0],s=a.length>=2?a[1]:"0",d=`${this.baseUrl}/actions/${n}/intents/${s}/steps/${r}`,o=await fetch(d),m=await o.json();if(!o.ok||m.success===!1)throw new E("RELAYER_STATUS_ERROR",k(m,`Intent step status check failed: ${o.status}`),{httpStatus:o.status,responseBody:JSON.stringify(m),endpoint:d,intentId:e});return{success:!0,data:{status:m.status==="error"?"reverted":m.status,transactionHash:m.txid,error:k(m,"")}}}async createWallet(e,r){const a=`${this.baseUrl}/wallets/${e}`,n=await fetch(a,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),s=await n.json();if(!n.ok||s.success===!1)throw new E("RELAYER_ERROR",k(s,`Create wallet error: ${n.status}`),{httpStatus:n.status,responseBody:JSON.stringify(s),endpoint:`/wallets/${e}`});return s}async getWallet(e){const r=`${this.baseUrl}/wallets/${e}`,a=await fetch(r),n=await a.json();if(!a.ok||n.success===!1)throw new E("RELAYER_ERROR",k(n,`Get wallet error: ${a.status}`),{httpStatus:a.status,responseBody:JSON.stringify(n),endpoint:`/wallets/${e}`});return n}async createWithdrawal(e){const r=`${this.baseUrl}/withdrawals`,a=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,G)}),n=await a.json();if(!a.ok||n.success===!1)throw new E("RELAYER_ERROR",k(n,`Create withdrawal error: ${a.status}`),{httpStatus:a.status,responseBody:JSON.stringify(n),endpoint:"/withdrawals"});return n}async getWithdrawal(e){const r=`${this.baseUrl}/withdrawals/${e}`,a=await fetch(r),n=await a.json();if(!a.ok||n.success===!1)throw new E("RELAYER_ERROR",k(n,`Get withdrawal error: ${a.status}`),{httpStatus:a.status,responseBody:JSON.stringify(n),endpoint:`/withdrawals/${e}`});return n}async getRollupTimestamp(){const e=`${this.baseUrl}/time`,r=await fetch(e),a=await r.json();if(!r.ok||a.success===!1)throw new E("RELAYER_ERROR",k(a,`Get rollup timestamp error: ${r.status}`),{httpStatus:r.status,responseBody:JSON.stringify(a),endpoint:"/time"});return a}}const I=new wt;async function bt(t){const e=`${I.getBaseUrl()}/wallets/${t}/balance`,r=await fetch(e,{cache:"no-store"}),a=await yt(r);if(!r.ok||a?.success===!1)throw new E("RELAYER_ERROR",k(a,`Unable to verify Spice balance: ${r.status}`),{httpStatus:r.status,responseBody:JSON.stringify(a),endpoint:`/wallets/${t}/balance`});return gt(a)}const ae=new Map;async function ne(t,e){const r=t.toLowerCase(),a=ae.get(r);if(a)return a;const n=(async()=>{try{await I.getWallet(t);return}catch{}const{unix_timestamp:s}=await I.getRollupTimestamp(),d=`I am creating a new smart wallet and adding an admin wallet ethereum:0x${t.slice(2).toLowerCase()}. Nonce: ${s}`,o=await e(d),m=typeof o=="string"?o:o.signature;if(!m)throw new Error("Wallet returned no smart wallet signature");await I.createWallet(t,{timestamp:s,signature:m})})();ae.set(r,n);try{await n}finally{ae.delete(r)}}const vt=(t,e)=>{const r=n=>e?e(n):te(n),a=[];return t.forEach((n,s)=>{const d=n.calls&&n.calls.length>0,o=n.tokenTransfers&&n.tokenTransfers.length>0;!d&&!o||a.push({stepId:s,status:s===0?"processing":"pending",chainId:n.chainId,chainName:r(n.chainId),description:"Processing transaction"})}),a},se=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 a=(e.name||t.walletName||"").toLowerCase();return!!(a.includes("embedded")||a.includes("turnkey"))},J=t=>(t?.connectedWallets||[]).find(e=>se(e))||(se(t?.primaryWallet)?t.primaryWallet:null),Et=t=>(t?.connectedWallets||[]).find(e=>e?.address&&e?.connector&&!se(e))||null,be=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 a=null;for(const n of r)try{const s=await t.getWalletClient(n);if(s)return s}catch(s){a=s}if(a)throw a}if(typeof t.getEthereumProvider=="function"){const r=await t.getEthereumProvider(),a=e?T(e)?.viemChain:void 0;return Ye({account:t.address,chain:a,transport:qe(r)})}throw new Error("Wallet client not available")},ve=async(t,e)=>{if(!t?.address)throw new Error("Wallet not available");if(typeof t.getEthereumProvider=="function")return t.getEthereumProvider();const r=await be(t,e);return{request:a=>r.request(a)}},xt=(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})()}),Ee=t=>{const e=t?.wallet;if(e?.address&&e.walletClientType==="privy"&&e.connectorType==="embedded"&&!e.imported)return e.address},S=t=>t?.address?{address:t.address,wallet:t,getWalletClient:e=>be(t,e),getEthereumProvider:e=>ve(t,e)}:null,xe=()=>{const t=L(W),{address:e,connector:r}=ue();let a=null,n=null;try{a=Q(),{user:n}=X()}catch{a=null,n=null}let s=null;try{s=V()}catch{s=null}const d=a?.wallets||[],o=K(d),m=o?.address?.toLowerCase(),u=d.find(x=>x.connectorType!=="embedded"&&x.address?.toLowerCase()!==m),f=J(s),l=Et(s),y=f?.address?.toLowerCase(),c=e?.toLowerCase(),w=e&&r&&!(c&&(m&&c===m||y&&c===y))?{address:e,connector:r,getEthereumProvider:()=>r.getProvider()}:null,i=e&&r?{address:e,connector:r,getEthereumProvider:()=>r.getProvider()}:null,g=t?.provider,p=S(o)||S(f),h=S(w)||S(u)||S(l)||null,b=g==="dynamic"?S(f):g==="privy"?S(o):p,v=g==="dynamic"?S(w)||S(l):g==="privy"?S(w)||S(u):h,B=g==="dynamic"?b?.address:g==="privy"?b?.address||Ee(n):p?.address||Ee(n),$=S(i)||v;return{embeddedWallet:b,externalWallet:v,embeddedAddress:B,externalAddress:v?.address,activeWallet:$,activeAddress:$?.address}},Ct=()=>{const[t,e]=j(!1);let r=null,a=null;try{r=V()}catch(c){a=c instanceof Error?c.message:String(c)}if(M(()=>{e(!0)},[]),a)return{isReady:!1,isAuthenticated:!1,isConnected:!1,provider:"dynamic",actions:{signAuthorization:async()=>{throw new Error("Dynamic context not available")},signMessage:async()=>{throw new Error("Dynamic context not available")},getEthereumProvider:async()=>{throw new Error("Dynamic context not available")}}};const{user:n,primaryWallet:s,connectedWallets:d}=r||{},o=J({connectedWallets:d,primaryWallet:s})||s,m=!!n,u=o?.address,f={isReady:t&&!!r,isAuthenticated:m,isConnected:m&&!!u,address:u,provider:"dynamic"},l=async c=>{if(!o)throw new Error("Dynamic embedded wallet not available");const{isEthereumWallet:w}=await import("@dynamic-labs/ethereum");if(!w(o))throw new Error("Embedded wallet is not an Ethereum wallet");const i=await o.getWalletClient();if(!i)throw new Error("Dynamic wallet client not available");return{signature:await i.signMessage({message:c,account:o.address})}},y=async()=>{if(!u)throw new Error("Dynamic embedded wallet not available");await ne(u,l)};return{...f,actions:{signAuthorization:async c=>{if(!o)throw new Error("Dynamic embedded wallet not available");await y();const{isEthereumWallet:w}=await import("@dynamic-labs/ethereum");if(!w(o))throw new Error("Embedded wallet is not an Ethereum wallet");const i=o.connector,g={address:o.address,chainId:c.chainId,contractAddress:c.contractAddress,nonce:c.nonce},p={address:c.contractAddress,chainId:c.chainId,nonce:c.nonce},h=typeof i?.getWaasWalletClient=="function"?await i.getWaasWalletClient():null;if(h&&typeof h.signRawMessage=="function"){const{hashAuthorization:b}=await import("viem/experimental"),{parseSignature:v}=await import("viem"),B={address:c.contractAddress,chainId:c.chainId,nonce:c.nonce},$=i.getSignedSessionId,x=typeof $=="function"?await $.call(i):void 0,P=i.getAuthToken,A=typeof P=="function"?P.call(i):void 0,C=await h.signRawMessage({accountAddress:o.address,authToken:A,context:{eip7702Auth:B},message:b(B).slice(2),signedSessionId:x}),N=v(C);return{address:g.contractAddress,chainId:g.chainId,contractAddress:g.contractAddress,nonce:BigInt(g.nonce),r:N.r,s:N.s,yParity:Number(N.yParity)}}if(typeof i?.signAuthorization=="function"){typeof i.switchNetwork=="function"&&await i.switchNetwork({networkChainId:c.chainId});const b=await i.signAuthorization(p);return xt(b,g)}throw new Error("Dynamic embedded wallet does not support EIP-7702 authorization. Ensure @dynamic-labs packages are v4.15+.")},signMessage:async c=>{if(!(typeof c=="object"&&"raw"in c))return l(c);if(await y(),!o)throw new Error("Dynamic embedded wallet not available");const w=await o.getWalletClient();if(!w)throw new Error("Dynamic wallet client not available");return{signature:await w.signMessage({message:{raw:c.raw},account:o.address})}},getEthereumProvider:async()=>{if(!o)throw new Error("Dynamic embedded wallet not available");const{isEthereumWallet:c}=await import("@dynamic-labs/ethereum");if(!c(o))throw new Error("Embedded wallet is not an Ethereum wallet");return ve(o)}}}},Bt=t=>{const e=t?.wallet;if(e?.address&&e.walletClientType==="privy"&&e.connectorType==="embedded"&&!e.imported)return e.address},Ce=()=>{const t=L(W),e=t?.mode||"7702";let r=null,a=null;try{r=Q(),{user:a}=X()}catch{r=null}const n=K(r?.wallets||[])?.address,s=Bt(a);let d=null;try{d=V()}catch{d=null}const o=(J(d)||d?.primaryWallet)?.address;if(!(!t||e!=="7702"))return t.provider==="privy"?n??s:t.provider==="dynamic"?o:n??s??o},kt=()=>{const t=L(W)?.mode,{isConnected:e,address:r}=ue();let a=null,n=null,s=null,d=null,o=null;try{a=X(),n=Ve(),s=Ze(),d=Q()}catch(p){o=p instanceof Error?p.message:String(p)}if(o)return t==="ondemand"&&e&&r?{isReady:!0,isAuthenticated:!0,isConnected:!0,address:r,provider:"privy",actions:{signAuthorization:async()=>{throw new Error("Not available in ondemand mode")},signMessage:async()=>{throw new Error("Not available in ondemand mode")},getEthereumProvider:async()=>{throw new Error("Not available in ondemand mode")}}}:{isReady:!1,isAuthenticated:!1,isConnected:!1,provider:null,actions:{signAuthorization:async()=>{throw new Error("Privy not available")},signMessage:async()=>{throw new Error("Privy not available")},getEthereumProvider:async()=>{throw new Error("Privy not available")}}};const{ready:m=!1,authenticated:u=!1}=a||{},f=Ce(),l=K(d?.wallets||[]),y=f||l?.address,c=!!y&&!!l,w={isReady:t==="ondemand"?!0:m,isAuthenticated:t==="ondemand"?!0:u||c,isConnected:t==="ondemand"?e&&!!r||m&&(u||c)&&c:m&&c,address:t==="ondemand"&&!f&&e?r:y,provider:"privy"},i=async p=>{if(s)try{return{signature:(await s.signMessage({message:p})).signature}}catch(B){if(!l)throw B}if(!l)throw new Error("Privy sign message not available");const h=await l.getEthereumProvider(),{createWalletClient:b,custom:v}=await import("viem");return{signature:await b({account:l.address,transport:v(h)}).signMessage({account:l.address,message:p})}},g=async()=>{if(!y)throw new Error("Embedded wallet not available for smart wallet setup");await ne(y,i)};return{...w,actions:{signAuthorization:async p=>{if(!n)throw new Error("Privy sign authorization not available");try{await g();const h=await n.signAuthorization({contractAddress:p.contractAddress,chainId:p.chainId,nonce:p.nonce},{address:y});return delete h.v,h}catch(h){const b=typeof h?.message=="string"?h.message:String(h?.message??h??"");throw b.includes("not configured")||b.includes("chain")?new Error(`Chain ${p.chainId} is not configured in PrivyProvider. Add this chain to your Privy dashboard or supportedChainIds.`):h}},signMessage:async p=>{if(typeof p=="object"&&"raw"in p){if(await g(),!l)throw new Error("Embedded wallet not available for raw signing");const h=await l.getEthereumProvider(),{createWalletClient:b,custom:v}=await import("viem");return{signature:await b({account:l.address,transport:v(h)}).signMessage({account:l.address,message:p})}}return i(p)},getEthereumProvider:async()=>{if(!l)throw new Error("Embedded wallet not available");return l.getEthereumProvider()}}}},Be=()=>{const t=L(W)?.provider,e=kt(),r=Ct();return t==="privy"?e:t==="dynamic"?r:{isReady:!1,isAuthenticated:!1,isConnected:!1,provider:null,actions:{signAuthorization:async()=>{throw new Error("No wallet provider available")},signMessage:async()=>{throw new Error("No wallet provider available")},getEthereumProvider:async()=>{throw new Error("No wallet provider available")}}}},St="https://portal-api.spicenet.io/api/v1",oe=t=>t.replace(/\/+$/,""),$t=(t,e)=>`${t}:${e}`;async function It(t,e){const r=new URLSearchParams({walletAddress:e,campaignId:"spicenet-portal",campaignGroup:"1"}),a=await fetch(`${t}/portal/mainnet/linked-portal-wallet?${r.toString()}`,{cache:"no-store"});return a.ok?(await a.json()).portalWalletAddress?.toLowerCase()??null:null}async function At(t,e,r){const a=new URLSearchParams({walletAddress:e,campaignId:r.campaignId,campaignGroup:r.campaignGroup,partnerId:r.partnerId}),n=await fetch(`${t}/portal/mainnet/whitelist/check?${a.toString()}`,{cache:"no-store"});if(!n.ok)throw new Error(`Failed to check whitelist: ${n.status}`);return await n.json()}async function Rt(t,e,r,a){const n=await fetch(`${t}/portal/mainnet/link-wallet`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({campaignId:e.campaignId,campaignGroup:e.campaignGroup,partnerId:e.partnerId,externalWalletAddress:r,embeddedWalletAddress:a})});if(!n.ok)throw new Error(`Failed to link wallet: ${n.status}`)}function ke({walletAddress:t,campaignId:e,campaignGroup:r,partnerId:a,apiBaseUrl:n=St,enabled:s=!0,staleTime:d=5*60*1e3,refetchInterval:o=!1}={}){const{isAuthenticated:m,isConnected:u}=Be(),{externalAddress:f,embeddedAddress:l}=xe(),y=t??f,c=typeof y=="string"?y.toLowerCase():void 0,w=typeof l=="string"?l.toLowerCase():void 0,i=typeof f=="string"?f.toLowerCase():void 0,g=s&&m&&u&&!!f&&!!c&&R(c)&&!!e&&!!r&&!!a,p=_(()=>["partner-whitelist","check",c,e,r,a,oe(n)],[c,e,r,a,n]),h=Xe({queryKey:p,enabled:g,staleTime:d,refetchInterval:o,queryFn:async()=>{if(!c||!R(c))throw new Error("A valid wallet address is required");if(!e||!r||!a)throw new Error("campaignId, campaignGroup, and partnerId are required");const x=oe(n),P={campaignId:e,campaignGroup:r,partnerId:a},A=await It(x,c);return A?At(x,A,P):{walletAddress:c,campaignId:e,campaignGroup:r,partnerId:a,isWhitelisted:!1,isLinkedWallet:!1,whitelistedWalletAddress:null,externalWalletAddress:c}}}),b=s&&m&&u&&!!i&&R(i)&&!!w&&R(w)&&!!e&&!!r&&!!a,v=Ke({mutationFn:x=>Rt(oe(n),{campaignId:e,campaignGroup:r,partnerId:a},x.external,x.embedded)}),B=ie(new Set),$=v.mutate;return M(()=>{if(!b||!i||!w||!e||!r||!a)return;const x=$t(i,w);B.current.has(x)||(B.current.add(x),$({external:i,embedded:w}))},[b,i,w,e,r,a,$]),{isWhitelisted:h.data?.isWhitelisted??!1,whitelistCheck:h.data,checkedWalletAddress:c,externalWalletAddress:f,embeddedWalletAddress:l,isExternalWalletConnected:!!f,isWhitelistCheckEnabled:g,linkWallet:v,isWalletLinked:v.isSuccess,...h}}const Se="spiceflow-mode",$e=()=>{if(typeof window>"u")return null;try{const t=window.localStorage.getItem(Se);return t==="7702"?"7702":t==="non7702"?"ondemand":t==="embedded"?"7702":t==="external"?"ondemand":null}catch{return null}},Tt=t=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Se,t==="7702"?"7702":"non7702")}catch{}},Wt=()=>$e()!==null,Ie=de(null),Pt=["__spicenet_whitelist_blocked__"],W=de(null),Nt=({children:t,value:e,whitelist:r})=>{const a=r!==!1&&!!r&&r.enabled!==!1,n=ke(a?r:{enabled:!1}),s=a&&n.isWhitelistCheckEnabled&&n.isSuccess,d=a&&(!s||!n.isWhitelisted),o=_(()=>({...e,allowedTokens:d?Pt:e.allowedTokens,mode:d?"ondemand":e.mode,isUserWhitelisted:s?n.isWhitelisted:null,isWhitelistChecking:a&&n.isWhitelistCheckEnabled&&(n.isLoading||n.isFetching),isWhitelistConfigured:a,isWhitelistGateActive:d,whitelistCheck:n.whitelistCheck}),[e,a,d,s,n.isWhitelisted,n.isWhitelistCheckEnabled,n.isLoading,n.isFetching,n.whitelistCheck]);return U(W.Provider,{value:o,children:t})},Ut=({children:t,provider:e,supportedChainIds:r,allowedTokens:a,network:n="testnet",mode:s,skipFlow:d=[],nativeChainId:o,appName:m="Spicenet",apiUrl:u,theme:f,rpcOverrides:l,whitelist:y})=>{M(()=>{if(!u)return;const v=I.getBaseUrl();return I.setBaseUrl(u),()=>I.setBaseUrl(v)},[u]),M(()=>(me(l),()=>me(void 0)),[l]);const c=_(()=>ze(n),[n]),w=r??c,i=f??null,[g,p]=j(()=>s??$e()??"7702");M(()=>{s&&p(s)},[s]);const h=Fe(v=>{if(s){p(s);return}p(v),Tt(v)},[s]),b=_(()=>({provider:e,supportedChainIds:w,allowedTokens:a,skipFlow:d,mode:g,setMode:h,network:n,nativeChainId:o,appName:m,apiUrl:u,rpcOverrides:l,isUserWhitelisted:null,isWhitelistChecking:!1,isWhitelistConfigured:!1,isWhitelistGateActive:!1}),[e,w,a,d,g,h,n,o,m,u,l]);return U(Ie.Provider,{value:i,children:U(W.Provider,{value:b,children:U(Nt,{value:b,whitelist:y,children:t})})})},Mt={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"}},Ot={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"},Ft={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"},Ae=(t="light")=>({mode:t,...Mt,colors:t==="light"?Ot:Ft});function H(t,e){const r=t.replace("#",""),a=Math.max(0,Math.round(parseInt(r.substring(0,2),16)*(1-e))),n=Math.max(0,Math.round(parseInt(r.substring(2,4),16)*(1-e))),s=Math.max(0,Math.round(parseInt(r.substring(4,6),16)*(1-e)));return`#${a.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`}function Lt(t,e){return{shell:e?.shell??"#141414",shellBorder:e?.shellBorder??H(e?.shell??"#141414",.35),shellInnerBorder:e?.shellInnerBorder??H(e?.shell??"#141414",.55),cardBg:e?.cardBg??"#1e1e1e",inputBg:e?.inputBg??"#171717",hoverBg:e?.hoverBg??"#2a2a2a",textPrimary:e?.textPrimary??"#ffffff",textSecondary:e?.textSecondary??"#888888",inputText:e?.inputText??"#e0e0e0",inputPlaceholder:e?.inputPlaceholder??"#555555",cardBorder:e?.cardBorder??"rgba(255,255,255,0.08)",inputBorder:e?.inputBorder??"rgba(255,255,255,0.10)",buttonBorder:e?.buttonBorder??"rgba(255,255,255,0.12)",successBg:e?.successBg??"#0a1f18",successBorder:e?.successBorder??"#1a4a3a",successText:e?.successText??"#6ee7b7",warningBg:e?.warningBg??"#1f1a0d",warningBorder:e?.warningBorder??"#4a3820",warningText:e?.warningText??"#fbbf24",errorBg:e?.errorBg??"#1f0d0d",errorBorder:e?.errorBorder??"#4a2020",errorText:e?.errorText??"#f87171",infoBg:e?.infoBg??"#0d1325",infoBorder:e?.infoBorder??"#2a3a5a",infoText:e?.infoText??"#60a5fa"}}function _t(t){return{shell:"#ffffff",shellBorder:"#E9E9E9",shellInnerBorder:"#D5D5D5",cardBg:"#f9fafb",inputBg:"#ffffff",hoverBg:"#f3f4f6",textPrimary:"#111827",textSecondary:"#6b7280",inputText:"#111827",inputPlaceholder:"#9ca3af",cardBorder:"#e5e7eb",inputBorder:"#d1d5db",buttonBorder:"#0e0d0b",successBg:"#d1fae5",successBorder:"#6ee7b7",successText:"#065f46",warningBg:"#fef3c7",warningBorder:"#fde68a",warningText:"#92400e",errorBg:"#fef2f2",errorBorder:"#fecaca",errorText:"#dc2626",infoBg:"#dbeafe",infoBorder:"#93c5fd",infoText:"#1e40af"}}function Re(t,e){const r=e?{...t,...e}:t,a=r.dark??!1,n=r.primaryColor,s=r.shell??(a?"#141414":"#ffffff");return{primaryColor:n,dark:a,fontFamily:r.fontFamily??'"Helvetica Neue", sans-serif',appName:r.appName??"Spicenet",logo:r.logo,borderRadius:r.borderRadius??"8px",shell:s,shellBorder:H(s,a?.35:.085),shellInnerBorder:H(s,a?.55:.165),card:r.card??(a?"#1e1e1e":"#f9fafb"),input:a?"#171717":"#ffffff",hover:a?"#2a2a2a":"#f3f4f6",text:r.text??(a?"#ffffff":"#111827"),textMuted:r.textMuted??(a?"#888888":"#6b7280"),inputText:a?"#e0e0e0":"#111827",inputPlaceholder:a?"#555555":"#9ca3af",border:r.border??(a?"rgba(255,255,255,0.08)":"#e5e7eb"),inputBorder:a?"rgba(255,255,255,0.10)":"#d1d5db",buttonBorder:a?"rgba(255,255,255,0.12)":"#0e0d0b",successBg:a?"#0a1f18":"#d1fae5",successBorder:a?"#1a4a3a":"#6ee7b7",successText:a?"#6ee7b7":"#065f46",warningBg:a?"#1f1a0d":"#fef3c7",warningBorder:a?"#4a3820":"#fde68a",warningText:a?"#fbbf24":"#92400e",errorBg:a?"#1f0d0d":"#fef2f2",errorBorder:a?"#4a2020":"#fecaca",errorText:a?"#f87171":"#dc2626",infoBg:a?"#0d1325":"#dbeafe",infoBorder:a?"#2a3a5a":"#93c5fd",infoText:a?"#60a5fa":"#1e40af"}}const jt='"IBM Plex Mono", monospace';function Te(t,e){const r=L(Ie)??void 0;return _(()=>{const a=r??{primaryColor:"#EA4B4B"},n={...t?.primaryColor?{primaryColor:t.primaryColor}:{},...t?.fontFamily?{fontFamily:t.fontFamily}:{},...e!==void 0?{dark:e}:{}},s=Re(a,n),{dark:d,primaryColor:o,appName:m}=s,u=Ae(d?"dark":"light"),f={...u,colors:{...u.colors,primary:o,primaryHover:`${o}dd`},typography:{...u.typography,fontFamily:s.fontFamily}},l={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},y=t?.inputVariant?t.inputVariant==="dark":d;return{brand:r,theme:f,dark:d,appName:m,primaryColor:o,dk:l,palette:l,fontFamily:s.fontFamily,monoFont:jt,inputDark:y,cardBg:y?l.cardBg:"#E9E9E9",cardBorder:y?l.cardBorder:"#C6C6C6",textPrimary:l.textPrimary,textSecondary:l.textSecondary,subtitleText:y?l.textSecondary:"#979AA0"}},[r,t,e])}const We="spiceflow-spinner-keyframes";function Dt(){if(typeof document>"u"||document.getElementById(We))return;const t=document.createElement("style");t.id=We,t.textContent="@keyframes spiceflow-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}",document.head.appendChild(t)}const Pe=({size:t=16,borderWidth:e=2,color:r="currentColor",style:a})=>{const n=ie(!1);return M(()=>{n.current||(Dt(),n.current=!0)},[]),U("div",{role:"status","aria-label":"Loading",style:{width:`${t}px`,height:`${t}px`,border:`${e}px solid ${r}`,borderTop:`${e}px solid transparent`,borderRadius:"50%",animation:"spiceflow-spin 1s linear infinite",flexShrink:0,...a}})},zt=({variant:t="primary",size:e="md",loading:r=!1,fullWidth:a=!1,disabled:n,children:s,className:d="",style:o,theme:m,styles:u,dark:f,...l})=>{const{theme:y,dark:c,palette:w}=Te(u,f),i=m||y,g=f??c,[p,h]=j(!1),[b,v]=j(!1),B=g?w.shell:"white",$=()=>{switch(t){case"primary":return{backgroundColor:u?.button?.backgroundColor||i.colors.primary,color:u?.button?.color||"#ffffff",border:`1px solid ${u?.button?.backgroundColor||i.colors.primary}`};case"secondary":return{backgroundColor:i.colors.secondary,color:i.colors.text,border:`1px solid ${i.colors.border}`};case"success":return{backgroundColor:i.colors.success,color:i.colors.text,border:`1px solid ${i.colors.success}`};case"error":return{backgroundColor:i.colors.error,color:i.colors.text,border:`1px solid ${i.colors.error}`};case"ghost":return{backgroundColor:"transparent",color:i.colors.textSecondary,border:`1px solid ${i.colors.border}`};case"outline":{const C=u?.button?.backgroundColor||i.colors.primary,N=u?.button?.color||(g?"#ffffff":"#0e0d0b"),O=u?.button?.borderColor||(g?`${i.colors.primary}88`:"#0e0d0b"),F=n||r,Ne=g?"1px":"1.5px",Ue=u?.button?.disabledBackgroundColor||`${C}88`,Me=u?.button?.disabledColor||N;return{height:"56px",backgroundColor:F?Ue:b?`${C}cc`:p?`${C}ee`:C,color:F?Me:N,border:`${Ne} solid ${O}`,borderRadius:u?.button?.borderRadius||"12px",fontSize:"22px",fontWeight:500,fontFamily:'"IBM Plex Mono", monospace',opacity:F?.78:1,transform:F?"none":b?"scale(0.98)":p?"translateY(-2px)":"none",boxShadow:F?`3px 3px 0px ${B}, 4px 4px 0px ${O}`:b?`2px 2px 0px ${O}`:p?`5px 5px 0px ${B}, 6px 6px 0px ${O}`:`3px 3px 0px ${B}, 4px 4px 0px ${O}`,transition:"transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease, border-color 150ms ease, color 150ms ease"}}default:return{}}},x=()=>{if(t==="outline")return{};switch(e){case"sm":return{padding:`${i.spacing.sm} ${i.spacing.md}`,fontSize:i.typography.fontSize.sm};case"md":return{padding:`${i.spacing.md} ${i.spacing.lg}`,fontSize:i.typography.fontSize.base};case"lg":return{padding:`${i.spacing.lg} ${i.spacing.xl}`,fontSize:i.typography.fontSize.lg};default:return{}}},P={borderRadius:u?.button?.borderRadius||i.borderRadius.md,fontWeight:u?.button?.fontWeight||i.typography.fontWeight.medium,fontFamily:u?.button?.fontFamily||i.typography.fontFamily,fontSize:u?.button?.fontSize||void 0,transition:"background-color 150ms ease, border-color 150ms ease, color 150ms ease, opacity 150ms ease",cursor:n||r?"not-allowed":"pointer",opacity:(n||r)&&t!=="outline"?.6:1,width:a?"100%":"auto",display:"flex",alignItems:"center",justifyContent:"center",gap:i.spacing.sm,...$(),...x(),...u?.button?.fontSize&&{fontSize:u.button.fontSize}},A=n||r;return Oe("button",{type:l.type??"button","data-spiceflow-focus":!0,"aria-busy":r||void 0,"aria-disabled":A||void 0,style:{...P,...o},className:d,disabled:A,onMouseEnter:C=>{h(!0),l.onMouseEnter?.(C)},onMouseLeave:C=>{h(!1),v(!1),l.onMouseLeave?.(C)},onMouseDown:C=>{v(!0),l.onMouseDown?.(C)},onMouseUp:C=>{v(!1),l.onMouseUp?.(C)},...l,children:[r&&U(Pe,{size:16}),s]})};export{re as A,zt as B,st as C,Ut as D,ke as E,Re as F,Lt as G,_t as H,we as R,Pe as S,lt as a,T as b,Ae as c,he as d,te as e,W as f,J as g,it as h,ge as i,pe as j,D as k,dt as l,ot as m,ut as n,vt as o,Be as p,xe as q,I as r,ft as s,Ce as t,Te as u,ct as v,E as w,bt as x,Wt as y,ne as z};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";const e=require("react/jsx-runtime"),c=require("react"),t=require("./Button-B2_1dqjj.js"),k=require("@dynamic-labs/sdk-react-core");require("@spicenet-io/spiceflow-core"),require("viem"),require("viem/actions"),require("@tanstack/react-query"),require("@privy-io/react-auth"),require("wagmi");const L=({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),w=k.useDynamicContext(),{user:E,primaryWallet:f,connectedWallets:b,handleLogOut:q,setShowAuthFlow:x,sdkHasLoaded:p,showAuthFlow:j}=w,n=(t.getDynamicEmbeddedWallet({connectedWallets:b,primaryWallet:f})||f)?.address,v=!!E,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 C=()=>{try{x(!0)}catch(y){const u=`Dynamic login failed: ${String(y)}`;r?r(u):console.error(u)}},N=async()=>{try{await q()}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:N,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:C,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 W 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 B=a=>{const{theme:r="light",className:h="",buttonText:i="Login with Dynamic",onAuthError:o}=a,l=t.createTheme(r);return e.jsx(W,{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(L,{...a})})};exports.DynamicLogin=B;
2
+ "use strict";const e=require("react/jsx-runtime"),c=require("react"),t=require("./Button-BBBrNeWB.js"),k=require("@dynamic-labs/sdk-react-core");require("@spicenet-io/spiceflow-core"),require("viem"),require("viem/actions"),require("@tanstack/react-query"),require("@privy-io/react-auth"),require("wagmi");const L=({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),w=k.useDynamicContext(),{user:E,primaryWallet:f,connectedWallets:b,handleLogOut:q,setShowAuthFlow:x,sdkHasLoaded:p,showAuthFlow:j}=w,n=(t.getDynamicEmbeddedWallet({connectedWallets:b,primaryWallet:f})||f)?.address,v=!!E,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 C=()=>{try{x(!0)}catch(y){const u=`Dynamic login failed: ${String(y)}`;r?r(u):console.error(u)}},N=async()=>{try{await q()}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:N,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:C,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 W 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 B=a=>{const{theme:r="light",className:h="",buttonText:i="Login with Dynamic",onAuthError:o}=a,l=t.createTheme(r);return e.jsx(W,{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(L,{...a})})};exports.DynamicLogin=B;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as e,jsxs as g}from"react/jsx-runtime";import A,{useState as N,useEffect as f}from"react";import{B as d,c as S,g as j,S as b}from"./Button-CUn4Vuav.js";import{useDynamicContext as z}from"@dynamic-labs/sdk-react-core";import"@spicenet-io/spiceflow-core";import"viem";import"viem/actions";import"@tanstack/react-query";import"@privy-io/react-auth";import"wagmi";const M=({onAuthSuccess:a,onAuthError:t,theme:m="light",className:r="",buttonText:o="Login with Dynamic",autoTrigger:s=!1})=>{const i=S(m),[h,C]=N(!1),[x,E]=N(!1),k=z(),{user:L,primaryWallet:v,connectedWallets:W,handleLogOut:F,setShowAuthFlow:p,sdkHasLoaded:u,showAuthFlow:D}=k,n=(j({connectedWallets:W,primaryWallet:v})||v)?.address,w=!!L,l=w&&!!n;return f(()=>{C(!0)},[]),f(()=>{l&&n&&a&&a(n)},[l,n,a]),f(()=>{s&&u&&h&&!l&&!D&&!x&&(E(!0),p(!0))},[s,u,h,l,D,x,p]),h?u?w&&!n?e("div",{className:r,children:g("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e(b,{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:r,children:g(d,{variant:"primary",onClick:async()=>{try{await F()}catch(y){const c=`Dynamic logout failed: ${String(y)}`;t?t(c):console.error(c)}},theme:i,children:["Logout (",n.slice(0,6),"...",n.slice(-4),")"]})}):s?e("div",{className:r,children:g("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e(b,{size:40,borderWidth:3,color:i.colors.primary}),e("p",{style:{color:i.colors.textMuted,fontSize:"14px"},children:"Opening login..."})]})}):e("div",{className:r,children:e(d,{variant:"primary",onClick:()=>{try{p(!0)}catch(y){const c=`Dynamic login failed: ${String(y)}`;t?t(c):console.error(c)}},theme:i,children:o})}):e("div",{className:r,children:e(d,{variant:"primary",disabled:!0,theme:i,children:"Loading..."})}):e("div",{className:r,children:e(d,{variant:"primary",disabled:!0,theme:i,children:o})})};class T extends A.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 B=a=>{const{theme:t="light",className:m="",buttonText:r="Login with Dynamic",onAuthError:o}=a,s=S(t);return e(T,{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:r})}),children:e(M,{...a})})};export{B as DynamicLogin};
2
+ import{jsx as e,jsxs as g}from"react/jsx-runtime";import A,{useState as N,useEffect as f}from"react";import{B as d,c as S,g as j,S as b}from"./Button-C6HynhzI.js";import{useDynamicContext as z}from"@dynamic-labs/sdk-react-core";import"@spicenet-io/spiceflow-core";import"viem";import"viem/actions";import"@tanstack/react-query";import"@privy-io/react-auth";import"wagmi";const M=({onAuthSuccess:a,onAuthError:t,theme:m="light",className:r="",buttonText:o="Login with Dynamic",autoTrigger:s=!1})=>{const i=S(m),[h,C]=N(!1),[x,E]=N(!1),k=z(),{user:L,primaryWallet:v,connectedWallets:W,handleLogOut:F,setShowAuthFlow:p,sdkHasLoaded:u,showAuthFlow:D}=k,n=(j({connectedWallets:W,primaryWallet:v})||v)?.address,w=!!L,l=w&&!!n;return f(()=>{C(!0)},[]),f(()=>{l&&n&&a&&a(n)},[l,n,a]),f(()=>{s&&u&&h&&!l&&!D&&!x&&(E(!0),p(!0))},[s,u,h,l,D,x,p]),h?u?w&&!n?e("div",{className:r,children:g("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e(b,{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:r,children:g(d,{variant:"primary",onClick:async()=>{try{await F()}catch(y){const c=`Dynamic logout failed: ${String(y)}`;t?t(c):console.error(c)}},theme:i,children:["Logout (",n.slice(0,6),"...",n.slice(-4),")"]})}):s?e("div",{className:r,children:g("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e(b,{size:40,borderWidth:3,color:i.colors.primary}),e("p",{style:{color:i.colors.textMuted,fontSize:"14px"},children:"Opening login..."})]})}):e("div",{className:r,children:e(d,{variant:"primary",onClick:()=>{try{p(!0)}catch(y){const c=`Dynamic login failed: ${String(y)}`;t?t(c):console.error(c)}},theme:i,children:o})}):e("div",{className:r,children:e(d,{variant:"primary",disabled:!0,theme:i,children:"Loading..."})}):e("div",{className:r,children:e(d,{variant:"primary",disabled:!0,theme:i,children:o})})};class T extends A.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 B=a=>{const{theme:t="light",className:m="",buttonText:r="Login with Dynamic",onAuthError:o}=a,s=S(t);return e(T,{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:r})}),children:e(M,{...a})})};export{B as DynamicLogin};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";const e=require("react/jsx-runtime"),o=require("react"),c=require("./Button-B2_1dqjj.js"),f=require("@privy-io/react-auth");require("@spicenet-io/spiceflow-core"),require("viem"),require("viem/actions"),require("@tanstack/react-query"),require("@dynamic-labs/sdk-react-core"),require("wagmi");const S=({onAuthSuccess:d,onAuthError:a,theme:v="light",className:l="",buttonText:g="Login with Privy",autoTrigger:h=!1})=>{const u=c.createTheme(v),[m,j]=o.useState(!1),[x,p]=o.useState(!1),{ready:s,authenticated:n,user:t}=f.usePrivy(),{login:q}=f.useLogin(),{logout:L}=f.useLogout();o.useEffect(()=>{j(!0)},[]),o.useEffect(()=>{h&&s&&!n&&m&&!x&&(p(!0),y())},[h,s,n,m,x]),o.useEffect(()=>{if(s&&n&&t&&d){const r=t.wallet?.address||t.email?.address;r&&d(r)}},[s,n,t,d]),o.useEffect(()=>{},[s,n,a]);const y=()=>{try{q()}catch(r){const i=`Login failed: ${String(r)}`;a?a(i):console.error(i)}},b=()=>{try{L()}catch(r){const i=`Logout failed: ${String(r)}`;a?a(i):console.error(i)}};if(!m)return e.jsx("div",{className:l,children:e.jsx(c.Button,{variant:"primary",disabled:!0,theme:u,children:g})});if(!s)return e.jsx("div",{className:l,children:e.jsx(c.Button,{variant:"primary",disabled:!0,theme:u,children:"Loading..."})});if(n&&t){const r=t.wallet?.address||t.email?.address,i=r?`${r.slice(0,6)}...${r.slice(-4)}`:"Connected";return e.jsx("div",{className:l,children:e.jsxs(c.Button,{variant:"primary",onClick:b,theme:u,children:["Logout (",i,")"]})})}return h?e.jsx("div",{className:l,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e.jsx(c.Spinner,{size:40,borderWidth:3,color:"#3b82f6"}),e.jsx("p",{style:{color:"#6b7280",fontSize:"14px"},children:"Opening login..."})]})}):e.jsx("div",{className:l,children:e.jsx(c.Button,{variant:"primary",onClick:y,theme:u,children:g})})};exports.PrivyLogin=S;
2
+ "use strict";const e=require("react/jsx-runtime"),o=require("react"),c=require("./Button-BBBrNeWB.js"),f=require("@privy-io/react-auth");require("@spicenet-io/spiceflow-core"),require("viem"),require("viem/actions"),require("@tanstack/react-query"),require("@dynamic-labs/sdk-react-core"),require("wagmi");const S=({onAuthSuccess:d,onAuthError:a,theme:v="light",className:l="",buttonText:g="Login with Privy",autoTrigger:h=!1})=>{const u=c.createTheme(v),[m,j]=o.useState(!1),[x,p]=o.useState(!1),{ready:s,authenticated:n,user:t}=f.usePrivy(),{login:q}=f.useLogin(),{logout:L}=f.useLogout();o.useEffect(()=>{j(!0)},[]),o.useEffect(()=>{h&&s&&!n&&m&&!x&&(p(!0),y())},[h,s,n,m,x]),o.useEffect(()=>{if(s&&n&&t&&d){const r=t.wallet?.address||t.email?.address;r&&d(r)}},[s,n,t,d]),o.useEffect(()=>{},[s,n,a]);const y=()=>{try{q()}catch(r){const i=`Login failed: ${String(r)}`;a?a(i):console.error(i)}},b=()=>{try{L()}catch(r){const i=`Logout failed: ${String(r)}`;a?a(i):console.error(i)}};if(!m)return e.jsx("div",{className:l,children:e.jsx(c.Button,{variant:"primary",disabled:!0,theme:u,children:g})});if(!s)return e.jsx("div",{className:l,children:e.jsx(c.Button,{variant:"primary",disabled:!0,theme:u,children:"Loading..."})});if(n&&t){const r=t.wallet?.address||t.email?.address,i=r?`${r.slice(0,6)}...${r.slice(-4)}`:"Connected";return e.jsx("div",{className:l,children:e.jsxs(c.Button,{variant:"primary",onClick:b,theme:u,children:["Logout (",i,")"]})})}return h?e.jsx("div",{className:l,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e.jsx(c.Spinner,{size:40,borderWidth:3,color:"#3b82f6"}),e.jsx("p",{style:{color:"#6b7280",fontSize:"14px"},children:"Opening login..."})]})}):e.jsx("div",{className:l,children:e.jsx(c.Button,{variant:"primary",onClick:y,theme:u,children:g})})};exports.PrivyLogin=S;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as r,jsxs as y}from"react/jsx-runtime";import{useState as v,useEffect as c}from"react";import{B as d,c as P,S as $}from"./Button-CUn4Vuav.js";import{usePrivy as j,useLogin as w,useLogout as B}from"@privy-io/react-auth";import"@spicenet-io/spiceflow-core";import"viem";import"viem/actions";import"@tanstack/react-query";import"@dynamic-labs/sdk-react-core";import"wagmi";const T=({onAuthSuccess:m,onAuthError:n,theme:x="light",className:a="",buttonText:p="Login with Privy",autoTrigger:u=!1})=>{const l=P(x),[h,L]=v(!1),[g,b]=v(!1),{ready:o,authenticated:s,user:t}=j(),{login:S}=w(),{logout:N}=B();c(()=>{L(!0)},[]),c(()=>{u&&o&&!s&&h&&!g&&(b(!0),f())},[u,o,s,h,g]),c(()=>{if(o&&s&&t&&m){const e=t.wallet?.address||t.email?.address;e&&m(e)}},[o,s,t,m]),c(()=>{},[o,s,n]);const f=()=>{try{S()}catch(e){const i=`Login failed: ${String(e)}`;n?n(i):console.error(i)}},C=()=>{try{N()}catch(e){const i=`Logout failed: ${String(e)}`;n?n(i):console.error(i)}};if(!h)return r("div",{className:a,children:r(d,{variant:"primary",disabled:!0,theme:l,children:p})});if(!o)return r("div",{className:a,children:r(d,{variant:"primary",disabled:!0,theme:l,children:"Loading..."})});if(s&&t){const e=t.wallet?.address||t.email?.address,i=e?`${e.slice(0,6)}...${e.slice(-4)}`:"Connected";return r("div",{className:a,children:y(d,{variant:"primary",onClick:C,theme:l,children:["Logout (",i,")"]})})}return u?r("div",{className:a,children:y("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:f,theme:l,children:p})})};export{T as PrivyLogin};
2
+ import{jsx as r,jsxs as y}from"react/jsx-runtime";import{useState as v,useEffect as c}from"react";import{B as d,c as P,S as $}from"./Button-C6HynhzI.js";import{usePrivy as j,useLogin as w,useLogout as B}from"@privy-io/react-auth";import"@spicenet-io/spiceflow-core";import"viem";import"viem/actions";import"@tanstack/react-query";import"@dynamic-labs/sdk-react-core";import"wagmi";const T=({onAuthSuccess:m,onAuthError:n,theme:x="light",className:a="",buttonText:p="Login with Privy",autoTrigger:u=!1})=>{const l=P(x),[h,L]=v(!1),[g,b]=v(!1),{ready:o,authenticated:s,user:t}=j(),{login:S}=w(),{logout:N}=B();c(()=>{L(!0)},[]),c(()=>{u&&o&&!s&&h&&!g&&(b(!0),f())},[u,o,s,h,g]),c(()=>{if(o&&s&&t&&m){const e=t.wallet?.address||t.email?.address;e&&m(e)}},[o,s,t,m]),c(()=>{},[o,s,n]);const f=()=>{try{S()}catch(e){const i=`Login failed: ${String(e)}`;n?n(i):console.error(i)}},C=()=>{try{N()}catch(e){const i=`Logout failed: ${String(e)}`;n?n(i):console.error(i)}};if(!h)return r("div",{className:a,children:r(d,{variant:"primary",disabled:!0,theme:l,children:p})});if(!o)return r("div",{className:a,children:r(d,{variant:"primary",disabled:!0,theme:l,children:"Loading..."})});if(s&&t){const e=t.wallet?.address||t.email?.address,i=e?`${e.slice(0,6)}...${e.slice(-4)}`:"Connected";return r("div",{className:a,children:y(d,{variant:"primary",onClick:C,theme:l,children:["Logout (",i,")"]})})}return u?r("div",{className:a,children:y("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:f,theme:l,children:p})})};export{T as PrivyLogin};
@@ -50,8 +50,14 @@ export declare function useIsUserWhitelisted({ walletAddress, campaignId, campai
50
50
  whitelistCheck: PartnerWhitelistCheckResponse | undefined;
51
51
  checkedWalletAddress: string | undefined;
52
52
  externalWalletAddress: `0x${string}` | undefined;
53
+ embeddedWalletAddress: `0x${string}` | undefined;
53
54
  isExternalWalletConnected: boolean;
54
55
  isWhitelistCheckEnabled: boolean;
56
+ linkWallet: import("@tanstack/react-query").UseMutationResult<void, Error, {
57
+ external: string;
58
+ embedded: string;
59
+ }, unknown>;
60
+ isWalletLinked: boolean;
55
61
  } | {
56
62
  data: PartnerWhitelistCheckResponse;
57
63
  error: null;
@@ -83,8 +89,14 @@ export declare function useIsUserWhitelisted({ walletAddress, campaignId, campai
83
89
  whitelistCheck: PartnerWhitelistCheckResponse | undefined;
84
90
  checkedWalletAddress: string | undefined;
85
91
  externalWalletAddress: `0x${string}` | undefined;
92
+ embeddedWalletAddress: `0x${string}` | undefined;
86
93
  isExternalWalletConnected: boolean;
87
94
  isWhitelistCheckEnabled: boolean;
95
+ linkWallet: import("@tanstack/react-query").UseMutationResult<void, Error, {
96
+ external: string;
97
+ embedded: string;
98
+ }, unknown>;
99
+ isWalletLinked: boolean;
88
100
  } | {
89
101
  data: undefined;
90
102
  error: Error;
@@ -116,8 +128,14 @@ export declare function useIsUserWhitelisted({ walletAddress, campaignId, campai
116
128
  whitelistCheck: PartnerWhitelistCheckResponse | undefined;
117
129
  checkedWalletAddress: string | undefined;
118
130
  externalWalletAddress: `0x${string}` | undefined;
131
+ embeddedWalletAddress: `0x${string}` | undefined;
119
132
  isExternalWalletConnected: boolean;
120
133
  isWhitelistCheckEnabled: boolean;
134
+ linkWallet: import("@tanstack/react-query").UseMutationResult<void, Error, {
135
+ external: string;
136
+ embedded: string;
137
+ }, unknown>;
138
+ isWalletLinked: boolean;
121
139
  } | {
122
140
  data: undefined;
123
141
  error: null;
@@ -149,8 +167,14 @@ export declare function useIsUserWhitelisted({ walletAddress, campaignId, campai
149
167
  whitelistCheck: PartnerWhitelistCheckResponse | undefined;
150
168
  checkedWalletAddress: string | undefined;
151
169
  externalWalletAddress: `0x${string}` | undefined;
170
+ embeddedWalletAddress: `0x${string}` | undefined;
152
171
  isExternalWalletConnected: boolean;
153
172
  isWhitelistCheckEnabled: boolean;
173
+ linkWallet: import("@tanstack/react-query").UseMutationResult<void, Error, {
174
+ external: string;
175
+ embedded: string;
176
+ }, unknown>;
177
+ isWalletLinked: boolean;
154
178
  } | {
155
179
  data: undefined;
156
180
  error: null;
@@ -182,8 +206,14 @@ export declare function useIsUserWhitelisted({ walletAddress, campaignId, campai
182
206
  whitelistCheck: PartnerWhitelistCheckResponse | undefined;
183
207
  checkedWalletAddress: string | undefined;
184
208
  externalWalletAddress: `0x${string}` | undefined;
209
+ embeddedWalletAddress: `0x${string}` | undefined;
185
210
  isExternalWalletConnected: boolean;
186
211
  isWhitelistCheckEnabled: boolean;
212
+ linkWallet: import("@tanstack/react-query").UseMutationResult<void, Error, {
213
+ external: string;
214
+ embedded: string;
215
+ }, unknown>;
216
+ isWalletLinked: boolean;
187
217
  } | {
188
218
  data: PartnerWhitelistCheckResponse;
189
219
  isError: false;
@@ -215,6 +245,12 @@ export declare function useIsUserWhitelisted({ walletAddress, campaignId, campai
215
245
  whitelistCheck: PartnerWhitelistCheckResponse | undefined;
216
246
  checkedWalletAddress: string | undefined;
217
247
  externalWalletAddress: `0x${string}` | undefined;
248
+ embeddedWalletAddress: `0x${string}` | undefined;
218
249
  isExternalWalletConnected: boolean;
219
250
  isWhitelistCheckEnabled: boolean;
251
+ linkWallet: import("@tanstack/react-query").UseMutationResult<void, Error, {
252
+ external: string;
253
+ embedded: string;
254
+ }, unknown>;
255
+ isWalletLinked: boolean;
220
256
  };