@spicenet-io/spiceflow-ui 3.3.10 → 3.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Button-CAv7hfnV.js +2 -0
- package/dist/Button-Cs81k5Pq.js +2 -0
- package/dist/auth-dynamic.cjs.js +1 -1
- package/dist/auth-dynamic.js +1 -1
- package/dist/auth-privy.cjs.js +1 -1
- package/dist/auth-privy.js +1 -1
- package/dist/components/SpiceSupply/lib/buildBatches.d.ts +1 -4
- package/dist/components/SpiceSupply/lib/executors.d.ts +1 -5
- package/dist/components/SpiceSupply/lib/feePreview.d.ts +1 -4
- package/dist/execution/pollIntentStep.d.ts +0 -1
- package/dist/index.cjs.js +8 -8
- package/dist/index.js +8 -8
- package/dist/{providerWallet-Cv_GlhF1.js → providerWallet-BC4uEdg8.js} +1 -1
- package/dist/{providerWallet-IDnLJm9s.js → providerWallet-QdrPrEd_.js} +1 -1
- package/dist/types/supply.d.ts +1 -0
- package/package.json +2 -2
- package/dist/Button-CIf9le-W.js +0 -2
- package/dist/Button-CWv90szi.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as R,jsxs as ye}from"react/jsx-runtime";import{createContext as H,useEffect as O,useState as A,useCallback as ge,useContext as be,useMemo as we,useRef as xe}from"react";import{getChainMeta as Y,getTokensForChain as Be,getDelegateContract as Ee,ZERO_ADDRESS as $e,isNativeToken as M,getTokenByAddress as Se,getChainIdsByNetwork as Ce}from"@spicenet-io/spiceflow-core";import{isAddress as _,getAddress as P,defineChain as Re,createPublicClient as ve,http as ke,formatUnits as q}from"viem";import{readContract as Te}from"viem/actions";function v(t,e){return!t||!e?!1:_(t)&&_(e)?P(t)===P(e):t.toLowerCase()===e.toLowerCase()}const G=[{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"}],Ie="0xcA11bde05977b3631167028862bE2a173976CA11",Ne={4114:"0x860aFc632a6D625B95d8B96f39ECC48E988c6962"},Ue=new Set([5115]);function Oe(t){const e=Ne[t.id]??(Ue.has(t.id)?void 0:Ie);return Re({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 Ae=[1,8453,42161,4114,11155111,421614,84532,5115,123420001114,688688,688689],k=Object.fromEntries(Ae.map(t=>Y(t)).filter(t=>t!=null).map(t=>[t.id,{...t,viemChain:Oe(t),supportedTokens:Be(t.id)}])),Me=k;let X={};const F=new Map,Q=t=>{X={...t||{}},F.clear()},L=t=>{const e=X[t];return e&&typeof e=="string"&&e.length>0?e:k[t]?.rpcUrl},B=t=>k[t],j=t=>{const e=Y(t);return e?.displayName||e?.name||`Chain ${t}`},_e=t=>{const e=Ee(t);if(!e)throw new Error(`Unsupported chain ID: ${t}`);return e},Pe=(t,e,a)=>{const r=B(t);return r?.blockExplorer?`${r.blockExplorer}/tx/${e}`:"#"};async function Fe(t,e){const a=`0x${e.toString(16)}`;try{await t.request({method:"wallet_switchEthereumChain",params:[{chainId:a}]});return}catch(s){if(!(s?.code===4902||typeof s?.message=="string"&&s.message.includes("Unrecognized chain ID")))throw s}const r=B(e);if(!r)throw new Error(`Cannot add unknown chain ${e} to wallet`);await t.request({method:"wallet_addEthereumChain",params:[{chainId:a,chainName:r.name||`Chain ${e}`,nativeCurrency:r.nativeCurrency||{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:[L(e)||r.rpcUrl],blockExplorerUrls:r.blockExplorer?[r.blockExplorer]:void 0}]})}const V=t=>{const e=B(t);if(!e)throw new Error(`Unsupported chain ID: ${t}`);const a=L(t);if(!a)throw new Error(`No RPC URL configured for chain ID: ${t}`);const r=`${t}:${a}`,s=F.get(r);if(s)return s;const n=ve({chain:e.viemChain,transport:ke(a,{timeout:15e3,retryCount:2,retryDelay:300}),batch:{multicall:{wait:16}}});return F.set(r,n),n},Le=()=>{const t={};return Object.values(k).forEach(e=>{t[e.id]={name:e.name,moralisName:e.moralisId||"",chain:e.viemChain,rpcUrl:L(e.id)||e.rpcUrl}}),t},je=(t,e=[])=>{const a=B(t);if(!a)return[];const r=[];if(![11155111,421614,84532,688689].includes(t)){const n=e.find(c=>c.chainId===t&&c.isNative);n?r.push(n):r.push({address:$e,name:a.nativeCurrency.name,symbol:a.nativeCurrency.symbol,decimals:a.nativeCurrency.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:void 0,isNative:!0,chainId:t})}if(!a.supportedTokens)return r;const s=r.some(n=>n.isNative);return a.supportedTokens.forEach(n=>{if(s&&M(n.address))return;const c=e.find(d=>d.chainId===t&&v(d.address,n.address));c?r.push(c):r.push({address:n.address,name:n.name,symbol:n.symbol,decimals:n.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:n.logo,isNative:!1,chainId:t})}),r},De=async(t,e)=>{const a=B(t);if(!a)throw new Error(`Unsupported chain ID: ${t}`);const r=e.toLowerCase();if(M(r)){if(!a.nativeCurrency?.decimals)throw new Error(`Native currency decimals not configured for chain ${t}`);return a.nativeCurrency.decimals}if(a.supportedTokens){const s=a.supportedTokens.find(n=>v(n.address,r));if(s)return s.decimals}try{if(!_(e,{strict:!1}))throw new Error(`Invalid token address: ${e}`);const s=P(e),n=V(t),c=await Te(n,{address:s,abi:G,functionName:"decimals"});return Number(c)}catch{throw new Error(`Could not determine decimals for token ${e} on chain ${t}`)}};class f extends Error{constructor(e,a,r={}){super(a),this.code=e,this.context=r,this.name="SpiceflowError",Error.captureStackTrace&&Error.captureStackTrace(this,f)}}function D(t){return t instanceof f}const ze=["user rejected","user denied","user cancelled","rejected the request","action_rejected","4001"];function Z(t){if(!t)return"";if(typeof t=="string")return t;const e=t,a=e.message||e.reason||"",r=e.details||"";return`${a} ${r}`.trim()}const K=t=>{if(D(t))return t.code==="WALLET_REJECTED";const e=Z(t).toLowerCase();return ze.some(a=>e.includes(a))},Je=(t,e="Something went wrong. Please try again.")=>K(t)?"Transaction was rejected.":D(t)?t.message||e:Z(t)||e;function We(t,e){const a=e.match(/Output amount (\d+) is insufficient after fees (\d+) on chain (\d+)/);if(!a)return e;const[,r,s,n]=a,c=Number(n),d=BigInt(r),p=BigInt(s);let o;for(const m of t.intents){const E=m.chainBatches.find($=>$.chainId===c);if(E){o=E;break}}const u=o?.tokenTransfers.find(m=>m.from==="escrow"&&v(m.to,t.user)&&!M(m.token)),l=j(c);if(!u)return`Amount is too small to cover the estimated fee on ${l}.`;const h=Se(u.token,c),w=h?.decimals??18,x=h?.symbol??"tokens",i=q(d,w),g=q(p,w);return`Amount is too small to cover the estimated fee on ${l}. Amount: ${i} ${x}. Estimated fee: ${g} ${x}.`}const ee=typeof process<"u"&&process.env?.NEXT_PUBLIC_RELAYER_API_URL||"https://tx-api-devserver.spicenet.io";function T(t,e){return typeof e=="bigint"?e.toString():e}class He{constructor(){this.baseUrl=ee}setBaseUrl(e){this.baseUrl=e}getBaseUrl(){return this.baseUrl}async createAction(e){const a=`${this.baseUrl}/actions`,r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,T)}),s=await r.json();if(!r.ok||s.success===!1)throw new f("RELAYER_ERROR",s.error?.message||`Relayer API error: ${r.status}`,{httpStatus:r.status,responseBody:JSON.stringify(s),endpoint:"/actions"});return s}async estimateActionFees(e){const a=`${this.baseUrl}/actions/fees/estimate`,r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,T)}),s=await r.json();if(!r.ok||!s.success||!s.data?.feeEstimate){const n=s.error?.message||`Relayer fee estimate error: ${r.status}`;throw new f("RELAYER_ERROR",We(e,n),{httpStatus:r.status,responseBody:JSON.stringify(s),endpoint:"/actions/fees/estimate"})}return s.data.feeEstimate}async estimateBatchGas(e){const a=`${this.baseUrl}/actions/gas/estimate`,r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,T)}),s=await r.json();if(!r.ok||!s.success||!s.data?.gasFee)throw new f("RELAYER_ERROR",s.error?.message||`Relayer gas estimate error: ${r.status}`,{httpStatus:r.status,responseBody:JSON.stringify(s),endpoint:"/actions/gas/estimate"});return{gasFee:BigInt(s.data.gasFee),gasQuoteSource:s.data.gasQuoteSource}}async executeStep(e,a,r,s){const n=`${this.baseUrl}/actions/${e}/intents/${a}/steps/${r}`,c=`/actions/${e}/intents/${a}/steps/${r}`,d=1e4,p=new Promise((l,h)=>setTimeout(()=>h(new f("RELAYER_EXECUTE_ERROR",`Execute step request timed out after ${d/1e3}s`,{actionId:e,intentIndex:a,stepIndex:r,endpoint:c})),d)),o=await Promise.race([fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),p]),u=await o.json();if(!o.ok||u.success===!1)throw new f("RELAYER_EXECUTE_ERROR",u.error?.message||`Execute step error: ${o.status}`,{httpStatus:o.status,responseBody:JSON.stringify(u),endpoint:c,actionId:e});if(u?.status==="error"||u?.status==="reverted"){const l=u?.error?`: ${u.error}`:"";throw new f("RELAYER_EXECUTE_ERROR",`Step ${r} previously ${u.status}${l}`,{httpStatus:o.status,responseBody:JSON.stringify(u),endpoint:c,actionId:e,intentIndex:a,stepIndex:r,stepStatus:u.status})}return{success:!0,transactionHash:u.transactionHash}}async checkStepStatus(e,a){const r=e.split("/"),s=r[0],n=r.length>=2?r[1]:"0",c=`${this.baseUrl}/actions/${s}/intents/${n}/steps/${a}`,d=await fetch(c),p=await d.json();if(!d.ok||p.success===!1)throw new f("RELAYER_STATUS_ERROR",p.error?.message||`Intent step status check failed: ${d.status}`,{httpStatus:d.status,responseBody:JSON.stringify(p),endpoint:c,intentId:e});return{success:!0,data:{status:p.status==="error"?"reverted":p.status,transactionHash:p.txid}}}async createWallet(e,a){const r=`${this.baseUrl}/wallets/${e}`,s=await fetch(r,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),n=await s.json();if(!s.ok||n.success===!1)throw new f("RELAYER_ERROR",n.error?.message||`Create wallet error: ${s.status}`,{httpStatus:s.status,responseBody:JSON.stringify(n),endpoint:`/wallets/${e}`});return n}async getWallet(e){const a=`${this.baseUrl}/wallets/${e}`,r=await fetch(a),s=await r.json();if(!r.ok||s.success===!1)throw new f("RELAYER_ERROR",s.error?.message||`Get wallet error: ${r.status}`,{httpStatus:r.status,responseBody:JSON.stringify(s),endpoint:`/wallets/${e}`});return s}async createWithdrawal(e){const a=`${this.baseUrl}/withdrawals`,r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,T)}),s=await r.json();if(!r.ok||s.success===!1)throw new f("RELAYER_ERROR",s.error?.message||`Create withdrawal error: ${r.status}`,{httpStatus:r.status,responseBody:JSON.stringify(s),endpoint:"/withdrawals"});return s}async getWithdrawal(e){const a=`${this.baseUrl}/withdrawals/${e}`,r=await fetch(a),s=await r.json();if(!r.ok||s.success===!1)throw new f("RELAYER_ERROR",s.error?.message||`Get withdrawal error: ${r.status}`,{httpStatus:r.status,responseBody:JSON.stringify(s),endpoint:`/withdrawals/${e}`});return s}async getRollupTimestamp(){const e=`${this.baseUrl}/time`,a=await fetch(e),r=await a.json();if(!a.ok||r.success===!1)throw new f("RELAYER_ERROR",r.error?.message||`Get rollup timestamp error: ${a.status}`,{httpStatus:a.status,responseBody:JSON.stringify(r),endpoint:"/time"});return r}}const b=new He,z=new Map;async function Ye(t,e){const a=t.toLowerCase(),r=z.get(a);if(r)return r;const s=(async()=>{try{await b.getWallet(t);return}catch{}const{unix_timestamp:n}=await b.getRollupTimestamp(),c=`I am creating a new smart wallet and adding an admin wallet ethereum:0x${t.slice(2).toLowerCase()}. Nonce: ${n}`,d=await e(c),p=typeof d=="string"?d:d.signature;if(!p)throw new Error("Wallet returned no smart wallet signature");await b.createWallet(t,{timestamp:n,signature:p})})();z.set(a,s);try{await s}finally{z.delete(a)}}const qe=(t,e)=>{const a=s=>e?e(s):j(s),r=[];return t.forEach((s,n)=>{const c=s.calls&&s.calls.length>0,d=s.tokenTransfers&&s.tokenTransfers.length>0;!c&&!d||r.push({stepId:n,status:n===0?"processing":"pending",chainId:s.chainId,chainName:a(s.chainId),description:"Processing transaction"})}),r},te="spiceflow-mode",re=()=>{if(typeof window>"u")return null;try{const t=window.localStorage.getItem(te);return t==="embedded"?"7702":t==="external"?"ondemand":null}catch{return null}},Ge=t=>{if(!(typeof window>"u"))try{window.localStorage.setItem(te,t==="7702"?"embedded":"external")}catch{}},Xe=()=>re()!==null,ae=H(null),se=H(null),Qe=({children:t,provider:e,supportedChainIds:a,allowedTokens:r,network:s="testnet",mode:n="7702",skipFlow:c=[],nativeChainId:d,appName:p="Spicenet",apiUrl:o,theme:u,rpcOverrides:l})=>{O(()=>{if(!o)return;const m=b.getBaseUrl();return b.setBaseUrl(o),()=>b.setBaseUrl(m)},[o]),O(()=>(Q(l),()=>Q(void 0)),[l]);const h=a??Ce(s),w=u??null,[x,i]=A(()=>re()??n),g=ge(m=>{i(m),Ge(m)},[]);return R(ae.Provider,{value:w,children:R(se.Provider,{value:{provider:e,supportedChainIds:h,allowedTokens:r,skipFlow:c,mode:x,setMode:g,network:s,nativeChainId:d,appName:p,apiUrl:o,rpcOverrides:l},children:t})})},Ve={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"}},Ze={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"},Ke={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"},ne=(t="light")=>({mode:t,...Ve,colors:t==="light"?Ze:Ke});function I(t,e){const a=t.replace("#",""),r=Math.max(0,Math.round(parseInt(a.substring(0,2),16)*(1-e))),s=Math.max(0,Math.round(parseInt(a.substring(2,4),16)*(1-e))),n=Math.max(0,Math.round(parseInt(a.substring(4,6),16)*(1-e)));return`#${r.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function et(t,e){return{shell:e?.shell??"#141414",shellBorder:e?.shellBorder??I(e?.shell??"#141414",.35),shellInnerBorder:e?.shellInnerBorder??I(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 tt(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 oe(t,e){const a=e?{...t,...e}:t,r=a.dark??!1,s=a.primaryColor,n=a.shell??(r?"#141414":"#ffffff");return{primaryColor:s,dark:r,fontFamily:a.fontFamily??'"Helvetica Neue", sans-serif',appName:a.appName??"Spicenet",logo:a.logo,borderRadius:a.borderRadius??"8px",shell:n,shellBorder:I(n,r?.35:.085),shellInnerBorder:I(n,r?.55:.165),card:a.card??(r?"#1e1e1e":"#f9fafb"),input:r?"#171717":"#ffffff",hover:r?"#2a2a2a":"#f3f4f6",text:a.text??(r?"#ffffff":"#111827"),textMuted:a.textMuted??(r?"#888888":"#6b7280"),inputText:r?"#e0e0e0":"#111827",inputPlaceholder:r?"#555555":"#9ca3af",border:a.border??(r?"rgba(255,255,255,0.08)":"#e5e7eb"),inputBorder:r?"rgba(255,255,255,0.10)":"#d1d5db",buttonBorder:r?"rgba(255,255,255,0.12)":"#0e0d0b",successBg:r?"#0a1f18":"#d1fae5",successBorder:r?"#1a4a3a":"#6ee7b7",successText:r?"#6ee7b7":"#065f46",warningBg:r?"#1f1a0d":"#fef3c7",warningBorder:r?"#4a3820":"#fde68a",warningText:r?"#fbbf24":"#92400e",errorBg:r?"#1f0d0d":"#fef2f2",errorBorder:r?"#4a2020":"#fecaca",errorText:r?"#f87171":"#dc2626",infoBg:r?"#0d1325":"#dbeafe",infoBorder:r?"#2a3a5a":"#93c5fd",infoText:r?"#60a5fa":"#1e40af"}}const rt='"IBM Plex Mono", monospace';function ie(t,e){const a=be(ae)??void 0;return we(()=>{const r=a??{primaryColor:"#EA4B4B"},s={...t?.primaryColor?{primaryColor:t.primaryColor}:{},...t?.fontFamily?{fontFamily:t.fontFamily}:{},...e!==void 0?{dark:e}:{}},n=oe(r,s),{dark:c,primaryColor:d,appName:p}=n,o=ne(c?"dark":"light"),u={...o,colors:{...o.colors,primary:d,primaryHover:`${d}dd`},typography:{...o.typography,fontFamily:n.fontFamily}},l={shell:n.shell,shellBorder:n.shellBorder,shellInnerBorder:n.shellInnerBorder,cardBg:n.card,inputBg:n.input,hoverBg:n.hover,textPrimary:n.text,textSecondary:n.textMuted,inputText:n.inputText,inputPlaceholder:n.inputPlaceholder,cardBorder:n.border,inputBorder:n.inputBorder,buttonBorder:n.buttonBorder,successBg:n.successBg,successBorder:n.successBorder,successText:n.successText,warningBg:n.warningBg,warningBorder:n.warningBorder,warningText:n.warningText,errorBg:n.errorBg,errorBorder:n.errorBorder,errorText:n.errorText,infoBg:n.infoBg,infoBorder:n.infoBorder,infoText:n.infoText},h=t?.inputVariant?t.inputVariant==="dark":c;return{brand:a,theme:u,dark:c,appName:p,primaryColor:d,dk:l,palette:l,fontFamily:n.fontFamily,monoFont:rt,inputDark:h,cardBg:h?l.cardBg:"#E9E9E9",cardBorder:h?l.cardBorder:"#C6C6C6",textPrimary:l.textPrimary,textSecondary:l.textSecondary,subtitleText:h?l.textSecondary:"#979AA0"}},[a,t,e])}const ce="spiceflow-spinner-keyframes";function at(){if(typeof document>"u"||document.getElementById(ce))return;const t=document.createElement("style");t.id=ce,t.textContent="@keyframes spiceflow-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}",document.head.appendChild(t)}const de=({size:t=16,borderWidth:e=2,color:a="currentColor",style:r})=>{const s=xe(!1);return O(()=>{s.current||(at(),s.current=!0)},[]),R("div",{role:"status","aria-label":"Loading",style:{width:`${t}px`,height:`${t}px`,border:`${e}px solid ${a}`,borderTop:`${e}px solid transparent`,borderRadius:"50%",animation:"spiceflow-spin 1s linear infinite",flexShrink:0,...r}})},st=({variant:t="primary",size:e="md",loading:a=!1,fullWidth:r=!1,disabled:s,children:n,className:c="",style:d,theme:p,styles:o,dark:u,...l})=>{const{theme:h,dark:w,palette:x}=ie(o,u),i=p||h,g=u??w,[m,E]=A(!1),[$,N]=A(!1),U=g?x.shell:"white",le=()=>{switch(t){case"primary":return{backgroundColor:o?.button?.backgroundColor||i.colors.primary,color:o?.button?.color||"#ffffff",border:`1px solid ${o?.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 y=o?.button?.backgroundColor||i.colors.primary,W=o?.button?.color||(g?"#ffffff":"#0e0d0b"),S=o?.button?.borderColor||(g?`${i.colors.primary}88`:"#0e0d0b"),C=s||a,fe=g?"1px":"1.5px",me=o?.button?.disabledBackgroundColor||`${y}88`,he=o?.button?.disabledColor||W;return{height:"56px",backgroundColor:C?me:$?`${y}cc`:m?`${y}ee`:y,color:C?he:W,border:`${fe} solid ${S}`,borderRadius:o?.button?.borderRadius||"12px",fontSize:"22px",fontWeight:500,fontFamily:'"IBM Plex Mono", monospace',opacity:C?.78:1,transform:C?"none":$?"scale(0.98)":m?"translateY(-2px)":"none",boxShadow:C?`3px 3px 0px ${U}, 4px 4px 0px ${S}`:$?`2px 2px 0px ${S}`:m?`5px 5px 0px ${U}, 6px 6px 0px ${S}`:`3px 3px 0px ${U}, 4px 4px 0px ${S}`,transition:"transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease, border-color 150ms ease, color 150ms ease"}}default:return{}}},ue=()=>{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{}}},pe={borderRadius:o?.button?.borderRadius||i.borderRadius.md,fontWeight:o?.button?.fontWeight||i.typography.fontWeight.medium,fontFamily:o?.button?.fontFamily||i.typography.fontFamily,fontSize:o?.button?.fontSize||void 0,transition:"background-color 150ms ease, border-color 150ms ease, color 150ms ease, opacity 150ms ease",cursor:s||a?"not-allowed":"pointer",opacity:(s||a)&&t!=="outline"?.6:1,width:r?"100%":"auto",display:"flex",alignItems:"center",justifyContent:"center",gap:i.spacing.sm,...le(),...ue(),...o?.button?.fontSize&&{fontSize:o.button.fontSize}},J=s||a;return ye("button",{type:l.type??"button","data-spiceflow-focus":!0,"aria-busy":a||void 0,"aria-disabled":J||void 0,style:{...pe,...d},className:c,disabled:J,onMouseEnter:y=>{E(!0),l.onMouseEnter?.(y)},onMouseLeave:y=>{E(!1),N(!1),l.onMouseLeave?.(y)},onMouseDown:y=>{N(!0),l.onMouseDown?.(y)},onMouseUp:y=>{N(!1),l.onMouseUp?.(y)},...l,children:[a&&R(de,{size:16}),n]})};export{st as B,Me as C,ee as R,de as S,G as _,Le as a,V as b,ne as c,j as d,se as e,Ye as f,B as g,Pe as h,K as i,v as j,Fe as k,_e as l,De as m,qe as n,je as o,f as p,Xe as q,b as r,Je as s,D as t,ie as u,Qe as v,oe as w,et as x,tt as y};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";const T=require("react/jsx-runtime"),y=require("react"),w=require("@spicenet-io/spiceflow-core"),b=require("viem"),ue=require("viem/actions");function I(t,e){return!t||!e?!1:b.isAddress(t)&&b.isAddress(e)?b.getAddress(t)===b.getAddress(e):t.toLowerCase()===e.toLowerCase()}const z=[{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"}],pe="0xcA11bde05977b3631167028862bE2a173976CA11",fe={4114:"0x860aFc632a6D625B95d8B96f39ECC48E988c6962"},me=new Set([5115]);function he(t){const e=fe[t.id]??(me.has(t.id)?void 0:pe);return b.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 ge=[1,8453,42161,4114,11155111,421614,84532,5115,123420001114,688688,688689],N=Object.fromEntries(ge.map(t=>w.getChainMeta(t)).filter(t=>t!=null).map(t=>[t.id,{...t,viemChain:he(t),supportedTokens:w.getTokensForChain(t.id)}])),ye=N;let J={};const F=new Map,H=t=>{J={...t||{}},F.clear()},M=t=>{const e=J[t];return e&&typeof e=="string"&&e.length>0?e:N[t]?.rpcUrl},S=t=>N[t],P=t=>{const e=w.getChainMeta(t);return e?.displayName||e?.name||`Chain ${t}`},be=t=>{const e=w.getDelegateContract(t);if(!e)throw new Error(`Unsupported chain ID: ${t}`);return e},we=(t,e,a)=>{const r=S(t);return r?.blockExplorer?`${r.blockExplorer}/tx/${e}`:"#"};async function xe(t,e){const a=`0x${e.toString(16)}`;try{await t.request({method:"wallet_switchEthereumChain",params:[{chainId:a}]});return}catch(s){if(!(s?.code===4902||typeof s?.message=="string"&&s.message.includes("Unrecognized chain ID")))throw s}const r=S(e);if(!r)throw new Error(`Cannot add unknown chain ${e} to wallet`);await t.request({method:"wallet_addEthereumChain",params:[{chainId:a,chainName:r.name||`Chain ${e}`,nativeCurrency:r.nativeCurrency||{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:[M(e)||r.rpcUrl],blockExplorerUrls:r.blockExplorer?[r.blockExplorer]:void 0}]})}const Y=t=>{const e=S(t);if(!e)throw new Error(`Unsupported chain ID: ${t}`);const a=M(t);if(!a)throw new Error(`No RPC URL configured for chain ID: ${t}`);const r=`${t}:${a}`,s=F.get(r);if(s)return s;const n=b.createPublicClient({chain:e.viemChain,transport:b.http(a,{timeout:15e3,retryCount:2,retryDelay:300}),batch:{multicall:{wait:16}}});return F.set(r,n),n},Be=()=>{const t={};return Object.values(N).forEach(e=>{t[e.id]={name:e.name,moralisName:e.moralisId||"",chain:e.viemChain,rpcUrl:M(e.id)||e.rpcUrl}}),t},Ee=(t,e=[])=>{const a=S(t);if(!a)return[];const r=[];if(![11155111,421614,84532,688689].includes(t)){const n=e.find(c=>c.chainId===t&&c.isNative);n?r.push(n):r.push({address:w.ZERO_ADDRESS,name:a.nativeCurrency.name,symbol:a.nativeCurrency.symbol,decimals:a.nativeCurrency.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:void 0,isNative:!0,chainId:t})}if(!a.supportedTokens)return r;const s=r.some(n=>n.isNative);return a.supportedTokens.forEach(n=>{if(s&&w.isNativeToken(n.address))return;const c=e.find(d=>d.chainId===t&&I(d.address,n.address));c?r.push(c):r.push({address:n.address,name:n.name,symbol:n.symbol,decimals:n.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:n.logo,isNative:!1,chainId:t})}),r},Ce=async(t,e)=>{const a=S(t);if(!a)throw new Error(`Unsupported chain ID: ${t}`);const r=e.toLowerCase();if(w.isNativeToken(r)){if(!a.nativeCurrency?.decimals)throw new Error(`Native currency decimals not configured for chain ${t}`);return a.nativeCurrency.decimals}if(a.supportedTokens){const s=a.supportedTokens.find(n=>I(n.address,r));if(s)return s.decimals}try{if(!b.isAddress(e,{strict:!1}))throw new Error(`Invalid token address: ${e}`);const s=b.getAddress(e),n=Y(t),c=await ue.readContract(n,{address:s,abi:z,functionName:"decimals"});return Number(c)}catch{throw new Error(`Could not determine decimals for token ${e} on chain ${t}`)}};class f extends Error{constructor(e,a,r={}){super(a),this.code=e,this.context=r,this.name="SpiceflowError",Error.captureStackTrace&&Error.captureStackTrace(this,f)}}function L(t){return t instanceof f}const Se=["user rejected","user denied","user cancelled","rejected the request","action_rejected","4001"];function q(t){if(!t)return"";if(typeof t=="string")return t;const e=t,a=e.message||e.reason||"",r=e.details||"";return`${a} ${r}`.trim()}const G=t=>{if(L(t))return t.code==="WALLET_REJECTED";const e=q(t).toLowerCase();return Se.some(a=>e.includes(a))},$e=(t,e="Something went wrong. Please try again.")=>G(t)?"Transaction was rejected.":L(t)?t.message||e:q(t)||e;function Re(t,e){const a=e.match(/Output amount (\d+) is insufficient after fees (\d+) on chain (\d+)/);if(!a)return e;const[,r,s,n]=a,c=Number(n),d=BigInt(r),p=BigInt(s);let o;for(const m of t.intents){const $=m.chainBatches.find(R=>R.chainId===c);if($){o=$;break}}const u=o?.tokenTransfers.find(m=>m.from==="escrow"&&I(m.to,t.user)&&!w.isNativeToken(m.token)),l=P(c);if(!u)return`Amount is too small to cover the estimated fee on ${l}.`;const h=w.getTokenByAddress(u.token,c),E=h?.decimals??18,C=h?.symbol??"tokens",i=b.formatUnits(d,E),x=b.formatUnits(p,E);return`Amount is too small to cover the estimated fee on ${l}. Amount: ${i} ${C}. Estimated fee: ${x} ${C}.`}const X=typeof process<"u"&&process.env?.NEXT_PUBLIC_RELAYER_API_URL||"https://tx-api-devserver.spicenet.io";function U(t,e){return typeof e=="bigint"?e.toString():e}class ve{constructor(){this.baseUrl=X}setBaseUrl(e){this.baseUrl=e}getBaseUrl(){return this.baseUrl}async createAction(e){const a=`${this.baseUrl}/actions`,r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,U)}),s=await r.json();if(!r.ok||s.success===!1)throw new f("RELAYER_ERROR",s.error?.message||`Relayer API error: ${r.status}`,{httpStatus:r.status,responseBody:JSON.stringify(s),endpoint:"/actions"});return s}async estimateActionFees(e){const a=`${this.baseUrl}/actions/fees/estimate`,r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,U)}),s=await r.json();if(!r.ok||!s.success||!s.data?.feeEstimate){const n=s.error?.message||`Relayer fee estimate error: ${r.status}`;throw new f("RELAYER_ERROR",Re(e,n),{httpStatus:r.status,responseBody:JSON.stringify(s),endpoint:"/actions/fees/estimate"})}return s.data.feeEstimate}async estimateBatchGas(e){const a=`${this.baseUrl}/actions/gas/estimate`,r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,U)}),s=await r.json();if(!r.ok||!s.success||!s.data?.gasFee)throw new f("RELAYER_ERROR",s.error?.message||`Relayer gas estimate error: ${r.status}`,{httpStatus:r.status,responseBody:JSON.stringify(s),endpoint:"/actions/gas/estimate"});return{gasFee:BigInt(s.data.gasFee),gasQuoteSource:s.data.gasQuoteSource}}async executeStep(e,a,r,s){const n=`${this.baseUrl}/actions/${e}/intents/${a}/steps/${r}`,c=`/actions/${e}/intents/${a}/steps/${r}`,d=1e4,p=new Promise((l,h)=>setTimeout(()=>h(new f("RELAYER_EXECUTE_ERROR",`Execute step request timed out after ${d/1e3}s`,{actionId:e,intentIndex:a,stepIndex:r,endpoint:c})),d)),o=await Promise.race([fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),p]),u=await o.json();if(!o.ok||u.success===!1)throw new f("RELAYER_EXECUTE_ERROR",u.error?.message||`Execute step error: ${o.status}`,{httpStatus:o.status,responseBody:JSON.stringify(u),endpoint:c,actionId:e});if(u?.status==="error"||u?.status==="reverted"){const l=u?.error?`: ${u.error}`:"";throw new f("RELAYER_EXECUTE_ERROR",`Step ${r} previously ${u.status}${l}`,{httpStatus:o.status,responseBody:JSON.stringify(u),endpoint:c,actionId:e,intentIndex:a,stepIndex:r,stepStatus:u.status})}return{success:!0,transactionHash:u.transactionHash}}async checkStepStatus(e,a){const r=e.split("/"),s=r[0],n=r.length>=2?r[1]:"0",c=`${this.baseUrl}/actions/${s}/intents/${n}/steps/${a}`,d=await fetch(c),p=await d.json();if(!d.ok||p.success===!1)throw new f("RELAYER_STATUS_ERROR",p.error?.message||`Intent step status check failed: ${d.status}`,{httpStatus:d.status,responseBody:JSON.stringify(p),endpoint:c,intentId:e});return{success:!0,data:{status:p.status==="error"?"reverted":p.status,transactionHash:p.txid}}}async createWallet(e,a){const r=`${this.baseUrl}/wallets/${e}`,s=await fetch(r,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),n=await s.json();if(!s.ok||n.success===!1)throw new f("RELAYER_ERROR",n.error?.message||`Create wallet error: ${s.status}`,{httpStatus:s.status,responseBody:JSON.stringify(n),endpoint:`/wallets/${e}`});return n}async getWallet(e){const a=`${this.baseUrl}/wallets/${e}`,r=await fetch(a),s=await r.json();if(!r.ok||s.success===!1)throw new f("RELAYER_ERROR",s.error?.message||`Get wallet error: ${r.status}`,{httpStatus:r.status,responseBody:JSON.stringify(s),endpoint:`/wallets/${e}`});return s}async createWithdrawal(e){const a=`${this.baseUrl}/withdrawals`,r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,U)}),s=await r.json();if(!r.ok||s.success===!1)throw new f("RELAYER_ERROR",s.error?.message||`Create withdrawal error: ${r.status}`,{httpStatus:r.status,responseBody:JSON.stringify(s),endpoint:"/withdrawals"});return s}async getWithdrawal(e){const a=`${this.baseUrl}/withdrawals/${e}`,r=await fetch(a),s=await r.json();if(!r.ok||s.success===!1)throw new f("RELAYER_ERROR",s.error?.message||`Get withdrawal error: ${r.status}`,{httpStatus:r.status,responseBody:JSON.stringify(s),endpoint:`/withdrawals/${e}`});return s}async getRollupTimestamp(){const e=`${this.baseUrl}/time`,a=await fetch(e),r=await a.json();if(!a.ok||r.success===!1)throw new f("RELAYER_ERROR",r.error?.message||`Get rollup timestamp error: ${a.status}`,{httpStatus:a.status,responseBody:JSON.stringify(r),endpoint:"/time"});return r}}const B=new ve,j=new Map;async function ke(t,e){const a=t.toLowerCase(),r=j.get(a);if(r)return r;const s=(async()=>{try{await B.getWallet(t);return}catch{}const{unix_timestamp:n}=await B.getRollupTimestamp(),c=`I am creating a new smart wallet and adding an admin wallet ethereum:0x${t.slice(2).toLowerCase()}. Nonce: ${n}`,d=await e(c),p=typeof d=="string"?d:d.signature;if(!p)throw new Error("Wallet returned no smart wallet signature");await B.createWallet(t,{timestamp:n,signature:p})})();j.set(a,s);try{await s}finally{j.delete(a)}}const Te=(t,e)=>{const a=s=>e?e(s):P(s),r=[];return t.forEach((s,n)=>{const c=s.calls&&s.calls.length>0,d=s.tokenTransfers&&s.tokenTransfers.length>0;!c&&!d||r.push({stepId:n,status:n===0?"processing":"pending",chainId:s.chainId,chainName:a(s.chainId),description:"Processing transaction"})}),r},Q="spiceflow-mode",V=()=>{if(typeof window>"u")return null;try{const t=window.localStorage.getItem(Q);return t==="embedded"?"7702":t==="external"?"ondemand":null}catch{return null}},Ie=t=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Q,t==="7702"?"embedded":"external")}catch{}},Ne=()=>V()!==null,Z=y.createContext(null),K=y.createContext(null),Ue=({children:t,provider:e,supportedChainIds:a,allowedTokens:r,network:s="testnet",mode:n="7702",skipFlow:c=[],nativeChainId:d,appName:p="Spicenet",apiUrl:o,theme:u,rpcOverrides:l})=>{y.useEffect(()=>{if(!o)return;const m=B.getBaseUrl();return B.setBaseUrl(o),()=>B.setBaseUrl(m)},[o]),y.useEffect(()=>(H(l),()=>H(void 0)),[l]);const h=a??w.getChainIdsByNetwork(s),E=u??null,[C,i]=y.useState(()=>V()??n),x=y.useCallback(m=>{i(m),Ie(m)},[]);return T.jsx(Z.Provider,{value:E,children:T.jsx(K.Provider,{value:{provider:e,supportedChainIds:h,allowedTokens:r,skipFlow:c,mode:C,setMode:x,network:s,nativeChainId:d,appName:p,apiUrl:o,rpcOverrides:l},children:t})})},Ae={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"}},Oe={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"},_e={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"},ee=(t="light")=>({mode:t,...Ae,colors:t==="light"?Oe:_e});function A(t,e){const a=t.replace("#",""),r=Math.max(0,Math.round(parseInt(a.substring(0,2),16)*(1-e))),s=Math.max(0,Math.round(parseInt(a.substring(2,4),16)*(1-e))),n=Math.max(0,Math.round(parseInt(a.substring(4,6),16)*(1-e)));return`#${r.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function Fe(t,e){return{shell:e?.shell??"#141414",shellBorder:e?.shellBorder??A(e?.shell??"#141414",.35),shellInnerBorder:e?.shellInnerBorder??A(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 Me(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 te(t,e){const a=e?{...t,...e}:t,r=a.dark??!1,s=a.primaryColor,n=a.shell??(r?"#141414":"#ffffff");return{primaryColor:s,dark:r,fontFamily:a.fontFamily??'"Helvetica Neue", sans-serif',appName:a.appName??"Spicenet",logo:a.logo,borderRadius:a.borderRadius??"8px",shell:n,shellBorder:A(n,r?.35:.085),shellInnerBorder:A(n,r?.55:.165),card:a.card??(r?"#1e1e1e":"#f9fafb"),input:r?"#171717":"#ffffff",hover:r?"#2a2a2a":"#f3f4f6",text:a.text??(r?"#ffffff":"#111827"),textMuted:a.textMuted??(r?"#888888":"#6b7280"),inputText:r?"#e0e0e0":"#111827",inputPlaceholder:r?"#555555":"#9ca3af",border:a.border??(r?"rgba(255,255,255,0.08)":"#e5e7eb"),inputBorder:r?"rgba(255,255,255,0.10)":"#d1d5db",buttonBorder:r?"rgba(255,255,255,0.12)":"#0e0d0b",successBg:r?"#0a1f18":"#d1fae5",successBorder:r?"#1a4a3a":"#6ee7b7",successText:r?"#6ee7b7":"#065f46",warningBg:r?"#1f1a0d":"#fef3c7",warningBorder:r?"#4a3820":"#fde68a",warningText:r?"#fbbf24":"#92400e",errorBg:r?"#1f0d0d":"#fef2f2",errorBorder:r?"#4a2020":"#fecaca",errorText:r?"#f87171":"#dc2626",infoBg:r?"#0d1325":"#dbeafe",infoBorder:r?"#2a3a5a":"#93c5fd",infoText:r?"#60a5fa":"#1e40af"}}const Pe='"IBM Plex Mono", monospace';function re(t,e){const a=y.useContext(Z)??void 0;return y.useMemo(()=>{const r=a??{primaryColor:"#EA4B4B"},s={...t?.primaryColor?{primaryColor:t.primaryColor}:{},...t?.fontFamily?{fontFamily:t.fontFamily}:{},...e!==void 0?{dark:e}:{}},n=te(r,s),{dark:c,primaryColor:d,appName:p}=n,o=ee(c?"dark":"light"),u={...o,colors:{...o.colors,primary:d,primaryHover:`${d}dd`},typography:{...o.typography,fontFamily:n.fontFamily}},l={shell:n.shell,shellBorder:n.shellBorder,shellInnerBorder:n.shellInnerBorder,cardBg:n.card,inputBg:n.input,hoverBg:n.hover,textPrimary:n.text,textSecondary:n.textMuted,inputText:n.inputText,inputPlaceholder:n.inputPlaceholder,cardBorder:n.border,inputBorder:n.inputBorder,buttonBorder:n.buttonBorder,successBg:n.successBg,successBorder:n.successBorder,successText:n.successText,warningBg:n.warningBg,warningBorder:n.warningBorder,warningText:n.warningText,errorBg:n.errorBg,errorBorder:n.errorBorder,errorText:n.errorText,infoBg:n.infoBg,infoBorder:n.infoBorder,infoText:n.infoText},h=t?.inputVariant?t.inputVariant==="dark":c;return{brand:a,theme:u,dark:c,appName:p,primaryColor:d,dk:l,palette:l,fontFamily:n.fontFamily,monoFont:Pe,inputDark:h,cardBg:h?l.cardBg:"#E9E9E9",cardBorder:h?l.cardBorder:"#C6C6C6",textPrimary:l.textPrimary,textSecondary:l.textSecondary,subtitleText:h?l.textSecondary:"#979AA0"}},[a,t,e])}const ae="spiceflow-spinner-keyframes";function Le(){if(typeof document>"u"||document.getElementById(ae))return;const t=document.createElement("style");t.id=ae,t.textContent="@keyframes spiceflow-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}",document.head.appendChild(t)}const se=({size:t=16,borderWidth:e=2,color:a="currentColor",style:r})=>{const s=y.useRef(!1);return y.useEffect(()=>{s.current||(Le(),s.current=!0)},[]),T.jsx("div",{role:"status","aria-label":"Loading",style:{width:`${t}px`,height:`${t}px`,border:`${e}px solid ${a}`,borderTop:`${e}px solid transparent`,borderRadius:"50%",animation:"spiceflow-spin 1s linear infinite",flexShrink:0,...r}})},je=({variant:t="primary",size:e="md",loading:a=!1,fullWidth:r=!1,disabled:s,children:n,className:c="",style:d,theme:p,styles:o,dark:u,...l})=>{const{theme:h,dark:E,palette:C}=re(o,u),i=p||h,x=u??E,[m,$]=y.useState(!1),[R,O]=y.useState(!1),_=x?C.shell:"white",ne=()=>{switch(t){case"primary":return{backgroundColor:o?.button?.backgroundColor||i.colors.primary,color:o?.button?.color||"#ffffff",border:`1px solid ${o?.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 g=o?.button?.backgroundColor||i.colors.primary,W=o?.button?.color||(x?"#ffffff":"#0e0d0b"),v=o?.button?.borderColor||(x?`${i.colors.primary}88`:"#0e0d0b"),k=s||a,ce=x?"1px":"1.5px",de=o?.button?.disabledBackgroundColor||`${g}88`,le=o?.button?.disabledColor||W;return{height:"56px",backgroundColor:k?de:R?`${g}cc`:m?`${g}ee`:g,color:k?le:W,border:`${ce} solid ${v}`,borderRadius:o?.button?.borderRadius||"12px",fontSize:"22px",fontWeight:500,fontFamily:'"IBM Plex Mono", monospace',opacity:k?.78:1,transform:k?"none":R?"scale(0.98)":m?"translateY(-2px)":"none",boxShadow:k?`3px 3px 0px ${_}, 4px 4px 0px ${v}`:R?`2px 2px 0px ${v}`:m?`5px 5px 0px ${_}, 6px 6px 0px ${v}`:`3px 3px 0px ${_}, 4px 4px 0px ${v}`,transition:"transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease, border-color 150ms ease, color 150ms ease"}}default:return{}}},oe=()=>{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{}}},ie={borderRadius:o?.button?.borderRadius||i.borderRadius.md,fontWeight:o?.button?.fontWeight||i.typography.fontWeight.medium,fontFamily:o?.button?.fontFamily||i.typography.fontFamily,fontSize:o?.button?.fontSize||void 0,transition:"background-color 150ms ease, border-color 150ms ease, color 150ms ease, opacity 150ms ease",cursor:s||a?"not-allowed":"pointer",opacity:(s||a)&&t!=="outline"?.6:1,width:r?"100%":"auto",display:"flex",alignItems:"center",justifyContent:"center",gap:i.spacing.sm,...ne(),...oe(),...o?.button?.fontSize&&{fontSize:o.button.fontSize}},D=s||a;return T.jsxs("button",{type:l.type??"button","data-spiceflow-focus":!0,"aria-busy":a||void 0,"aria-disabled":D||void 0,style:{...ie,...d},className:c,disabled:D,onMouseEnter:g=>{$(!0),l.onMouseEnter?.(g)},onMouseLeave:g=>{$(!1),O(!1),l.onMouseLeave?.(g)},onMouseDown:g=>{O(!0),l.onMouseDown?.(g)},onMouseUp:g=>{O(!1),l.onMouseUp?.(g)},...l,children:[a&&T.jsx(se,{size:16}),n]})};exports.Button=je,exports.CHAIN_CONFIGS=ye,exports.RELAYER_API_URL=X,exports.SpiceFlowProvider=Ue,exports.SpiceFlowProviderContext=K,exports.SpiceflowError=f,exports.Spinner=se,exports._=z,exports.addressesEqual=I,exports.buildDarkPalette=Fe,exports.buildLightPalette=Me,exports.createInitialSteps=Te,exports.createTheme=ee,exports.ensureSmartWallet=ke,exports.ensureWalletOnChain=xe,exports.getAllAssetsForChain=Ee,exports.getChainConfig=S,exports.getChainName=P,exports.getChainsForAssets=Be,exports.getClientForChain=Y,exports.getDelegateContractAddress=be,exports.getExplorerUrl=we,exports.getTokenDecimals=Ce,exports.hasStoredSpiceFlowMode=Ne,exports.isSpiceflowError=L,exports.isUserRejection=G,exports.relayerService=B,exports.resolveTheme=te,exports.sanitizeError=$e,exports.useSpiceBrand=re;
|
package/dist/auth-dynamic.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";const e=require("react/jsx-runtime"),c=require("react"),t=require("./Button-
|
|
2
|
+
"use strict";const e=require("react/jsx-runtime"),c=require("react"),t=require("./Button-Cs81k5Pq.js"),W=require("@dynamic-labs/sdk-react-core"),k=require("./providerWallet-QdrPrEd_.js");require("@spicenet-io/spiceflow-core"),require("viem"),require("viem/actions");const q=({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=W.useDynamicContext(),{user:E,primaryWallet:f,connectedWallets:b,handleLogOut:C,setShowAuthFlow:x,sdkHasLoaded:p,showAuthFlow:j}=w,n=(k.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 N=()=>{try{x(!0)}catch(y){const u=`Dynamic login failed: ${String(y)}`;r?r(u):console.error(u)}},L=async()=>{try{await C()}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:L,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:N,theme:s,children:o})}):e.jsx("div",{className:i,children:e.jsx(t.Button,{variant:"primary",disabled:!0,theme:s,children:"Loading..."})}):e.jsx("div",{className:i,children:e.jsx(t.Button,{variant:"primary",disabled:!0,theme:s,children:o})})};class B extends c.Component{constructor(r){super(r),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}}const F=a=>{const{theme:r="light",className:h="",buttonText:i="Login with Dynamic",onAuthError:o}=a,l=t.createTheme(r);return e.jsx(B,{fallback:e.jsx("div",{className:h,children:e.jsx(t.Button,{variant:"primary",onClick:()=>{o&&o('DynamicLogin must be used within SpiceFlowProvider provider="dynamic" and a mounted DynamicContextProvider.')},theme:l,children:i})}),children:e.jsx(q,{...a})})};exports.DynamicLogin=F;
|
package/dist/auth-dynamic.js
CHANGED
|
@@ -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,S as b}from"./Button-
|
|
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,S as b}from"./Button-CAv7hfnV.js";import{useDynamicContext as j}from"@dynamic-labs/sdk-react-core";import{g as z}from"./providerWallet-BC4uEdg8.js";import"@spicenet-io/spiceflow-core";import"viem";import"viem/actions";const M=({onAuthSuccess:a,onAuthError:r,theme:m="light",className:t="",buttonText:o="Login with Dynamic",autoTrigger:s=!1})=>{const i=S(m),[h,C]=N(!1),[x,E]=N(!1),L=j(),{user:W,primaryWallet:v,connectedWallets:k,handleLogOut:F,setShowAuthFlow:p,sdkHasLoaded:u,showAuthFlow:D}=L,n=(z({connectedWallets:k,primaryWallet:v})||v)?.address,w=!!W,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:t,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:t,children:g(d,{variant:"primary",onClick:async()=>{try{await F()}catch(y){const c=`Dynamic logout failed: ${String(y)}`;r?r(c):console.error(c)}},theme:i,children:["Logout (",n.slice(0,6),"...",n.slice(-4),")"]})}):s?e("div",{className:t,children:g("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e(b,{size:40,borderWidth:3,color:i.colors.primary}),e("p",{style:{color:i.colors.textMuted,fontSize:"14px"},children:"Opening login..."})]})}):e("div",{className:t,children:e(d,{variant:"primary",onClick:()=>{try{p(!0)}catch(y){const c=`Dynamic login failed: ${String(y)}`;r?r(c):console.error(c)}},theme:i,children:o})}):e("div",{className:t,children:e(d,{variant:"primary",disabled:!0,theme:i,children:"Loading..."})}):e("div",{className:t,children:e(d,{variant:"primary",disabled:!0,theme:i,children:o})})};class T extends A.Component{constructor(r){super(r),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}}const B=a=>{const{theme:r="light",className:m="",buttonText:t="Login with Dynamic",onAuthError:o}=a,s=S(r);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:t})}),children:e(M,{...a})})};export{B as DynamicLogin};
|
package/dist/auth-privy.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";const e=require("react/jsx-runtime"),o=require("react"),c=require("./Button-
|
|
2
|
+
"use strict";const e=require("react/jsx-runtime"),o=require("react"),c=require("./Button-Cs81k5Pq.js"),f=require("@privy-io/react-auth");require("@spicenet-io/spiceflow-core"),require("viem"),require("viem/actions");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:i,authenticated:n,user:r}=f.usePrivy(),{login:L}=f.useLogin(),{logout:b}=f.useLogout();o.useEffect(()=>{j(!0)},[]),o.useEffect(()=>{h&&i&&!n&&m&&!x&&(p(!0),y())},[h,i,n,m,x]),o.useEffect(()=>{if(i&&n&&r&&d){const t=r.wallet?.address||r.email?.address;t&&d(t)}},[i,n,r,d]),o.useEffect(()=>{},[i,n,a]);const y=()=>{try{L()}catch(t){const s=`Login failed: ${String(t)}`;a?a(s):console.error(s)}},q=()=>{try{b()}catch(t){const s=`Logout failed: ${String(t)}`;a?a(s):console.error(s)}};if(!m)return e.jsx("div",{className:l,children:e.jsx(c.Button,{variant:"primary",disabled:!0,theme:u,children:g})});if(!i)return e.jsx("div",{className:l,children:e.jsx(c.Button,{variant:"primary",disabled:!0,theme:u,children:"Loading..."})});if(n&&r){const t=r.wallet?.address||r.email?.address,s=t?`${t.slice(0,6)}...${t.slice(-4)}`:"Connected";return e.jsx("div",{className:l,children:e.jsxs(c.Button,{variant:"primary",onClick:q,theme:u,children:["Logout (",s,")"]})})}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;
|
package/dist/auth-privy.js
CHANGED
|
@@ -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-
|
|
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-CAv7hfnV.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";const T=({onAuthSuccess:m,onAuthError:n,theme:x="light",className:a="",buttonText:g="Login with Privy",autoTrigger:u=!1})=>{const l=P(x),[h,L]=v(!1),[p,b]=v(!1),{ready:o,authenticated:s,user:t}=j(),{login:S}=w(),{logout:N}=B();c(()=>{L(!0)},[]),c(()=>{u&&o&&!s&&h&&!p&&(b(!0),f())},[u,o,s,h,p]),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:g})});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:g})})};export{T as PrivyLogin};
|
|
@@ -29,8 +29,5 @@ export interface BatchBuilderContext {
|
|
|
29
29
|
}
|
|
30
30
|
export declare function buildPayChainBatches(ctx: BatchBuilderContext, options?: SupplyBatchBuildOptions): Promise<ChainBatch[]>;
|
|
31
31
|
export declare function buildSupplyChainBatches(ctx: BatchBuilderContext, options?: SupplyBatchBuildOptions): Promise<ChainBatch[]>;
|
|
32
|
-
export declare function estimateRequiredGrossFunding(requiredNetFunding: bigint, buildBatches: (grossFundingAmount: bigint) => ChainBatch[] | Promise<ChainBatch[]>, fundingToken: Address, estimateGasless: EstimateGaslessFn, gaslessOptions?: Pick<GaslessExecutionOptions, "useCustomTransfers" | "userOverride">): Promise<
|
|
33
|
-
grossFunding: bigint;
|
|
34
|
-
feeEstimate: FeeEstimateSummary;
|
|
35
|
-
}>;
|
|
32
|
+
export declare function estimateRequiredGrossFunding(requiredNetFunding: bigint, buildBatches: (grossFundingAmount: bigint) => ChainBatch[] | Promise<ChainBatch[]>, fundingToken: Address, estimateGasless: EstimateGaslessFn, gaslessOptions?: Pick<GaslessExecutionOptions, "useCustomTransfers" | "userOverride">): Promise<bigint>;
|
|
36
33
|
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Dispatch, MutableRefObject, SetStateAction } from "react";
|
|
2
2
|
import { type Address } from "viem";
|
|
3
|
-
import { type FeeEstimateSummary } from "@spicenet-io/spiceflow-core";
|
|
4
3
|
import type { ChainBatch } from "../../../types/authorization";
|
|
5
4
|
import type { SelectedAsset } from "../../../types/assets";
|
|
6
5
|
import type { SpiceSupplyProps, SupplyBatchBuildOptions } from "../../../types/supply";
|
|
@@ -15,10 +14,7 @@ export type PaymentResult = {
|
|
|
15
14
|
};
|
|
16
15
|
type BuildPayBatchesFn = (options?: SupplyBatchBuildOptions) => Promise<ChainBatch[]>;
|
|
17
16
|
type BuildSupplyBatchesFn = (options?: SupplyBatchBuildOptions) => Promise<ChainBatch[]>;
|
|
18
|
-
type EstimateRequiredGrossFundingFn = (requiredNetFunding: bigint, buildBatches: (grossFundingAmount: bigint) => ChainBatch[] | Promise<ChainBatch[]>, fundingToken: Address, gaslessOptions?: Pick<GaslessExecutionOptions, "useCustomTransfers" | "userOverride">) => Promise<
|
|
19
|
-
grossFunding: bigint;
|
|
20
|
-
feeEstimate: FeeEstimateSummary;
|
|
21
|
-
}>;
|
|
17
|
+
type EstimateRequiredGrossFundingFn = (requiredNetFunding: bigint, buildBatches: (grossFundingAmount: bigint) => ChainBatch[] | Promise<ChainBatch[]>, fundingToken: Address, gaslessOptions?: Pick<GaslessExecutionOptions, "useCustomTransfers" | "userOverride">) => Promise<bigint>;
|
|
22
18
|
export type ExecutorContext = {
|
|
23
19
|
selectedAsset: SelectedAsset | null;
|
|
24
20
|
parsedAmount: number;
|
|
@@ -10,10 +10,7 @@ import type { GaslessExecutionOptions } from "../../../hooks/useSpiceExecution";
|
|
|
10
10
|
type EstimateGaslessFn = (chainBatches: ChainBatch[], tokenAddress: string, tokenTransferAmount: bigint, options?: GaslessExecutionOptions) => Promise<FeeEstimateSummary>;
|
|
11
11
|
type BuildPayBatchesFn = (options?: SupplyBatchBuildOptions) => Promise<ChainBatch[]>;
|
|
12
12
|
type BuildSupplyBatchesFn = (options?: SupplyBatchBuildOptions) => Promise<ChainBatch[]>;
|
|
13
|
-
type EstimateRequiredGrossFundingFn = (requiredNetFunding: bigint, buildBatches: (grossFundingAmount: bigint) => ChainBatch[] | Promise<ChainBatch[]>, fundingToken: Address, gaslessOptions?: Pick<GaslessExecutionOptions, "useCustomTransfers" | "userOverride">) => Promise<
|
|
14
|
-
grossFunding: bigint;
|
|
15
|
-
feeEstimate: FeeEstimateSummary;
|
|
16
|
-
}>;
|
|
13
|
+
type EstimateRequiredGrossFundingFn = (requiredNetFunding: bigint, buildBatches: (grossFundingAmount: bigint) => ChainBatch[] | Promise<ChainBatch[]>, fundingToken: Address, gaslessOptions?: Pick<GaslessExecutionOptions, "useCustomTransfers" | "userOverride">) => Promise<bigint>;
|
|
17
14
|
export interface FeePreviewContext {
|
|
18
15
|
selectedAsset: SelectedAsset | null;
|
|
19
16
|
isPayMode: boolean;
|
|
@@ -19,7 +19,6 @@ export declare function runAllIntentSteps(options: {
|
|
|
19
19
|
intentIndex: number;
|
|
20
20
|
intentId: string;
|
|
21
21
|
totalSteps: number;
|
|
22
|
-
startStepIndex?: number;
|
|
23
22
|
delayBeforeSpicenetStepMs?: number;
|
|
24
23
|
isSpicenetStep?: (stepIndex: number) => boolean;
|
|
25
24
|
maxExecuteAttemptsForStep?: (stepIndex: number) => number;
|