@spicenet-io/spiceflow-ui 2.5.8 → 2.5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{createContext as h,useState as I,useCallback as k,useContext as $,useMemo as v}from"react";import{jsx as g}from"react/jsx-runtime";import{getChainIdsByNetwork as P}from"@spicenet-io/spiceflow-core";import{g as R}from"./index-D67FO4eR.js";import{c as C}from"./Button-DjsYc4v4.js";class d extends Error{constructor(e,s,r={}){super(s),this.code=e,this.context=r,this.name="SpiceflowError",Error.captureStackTrace&&Error.captureStackTrace(this,d)}}function U(o){return o instanceof d}const B=typeof process<"u"&&process.env?.NEXT_PUBLIC_RELAYER_API_URL||"https://tx-submission-api-dev.spicenet.io";class N{constructor(){this.baseUrl=B}setBaseUrl(e){this.baseUrl=e}async createAction(e){const s=await fetch(`${this.baseUrl}/actions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(r,a)=>typeof a=="bigint"?a.toString():a)});if(!s.ok){const r=await s.text();throw new d("RELAYER_ERROR",`Relayer API error: ${s.status} - ${r}`,{httpStatus:s.status,responseBody:r,endpoint:"/actions"})}return s.json()}async executeStep(e,s,r,a){const t=await fetch(`${this.baseUrl}/actions/${e}/intents/${s}/steps/${r}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!t.ok){const n=await t.text();throw new d("RELAYER_EXECUTE_ERROR",`Execute step error: ${t.status} - ${n}`,{httpStatus:t.status,responseBody:n,endpoint:`/actions/${e}/intents/${s}/steps/${r}`,actionId:e})}return{success:!0,transactionHash:(await t.json()).transactionHash}}async checkStepStatus(e,s){const r=e.split("/");let a="";if(r.length>=2){const i=r[0],c=r[1];a=`${this.baseUrl}/actions/${i}/intents/${c}/steps/${s}`}else a=`${this.baseUrl}/actions/${e}/intents/0/steps/${s}`;const t=await fetch(a);if(!t.ok)throw new d("RELAYER_STATUS_ERROR",`Intent step status check failed: ${t.status}`,{httpStatus:t.status,endpoint:a,intentId:e});const n=await t.json();return{success:!0,data:{status:n.status==="error"?"reverted":n.status,transactionHash:n.txid}}}async submitSpiceDeposit(e){const s=e.isDeposit?"deposit":"withdrawal";try{const r=await fetch(`${this.baseUrl}/spicedeposit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await r.json();return!r.ok||!a.success?(console.error(`Failed to submit ${s} request to API:`,a.error?.message),{success:!1,error:a.error}):a}catch(r){return console.error(`Error submitting ${s} request to API:`,r),{success:!1,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async requestAirdrop(e){try{const s=await fetch(`${this.baseUrl}/airdrop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tag:e.tag||"default",airdrops:[{chainId:e.chainId,tokenId:e.tokenId,wallet:e.wallet,amount:e.amount||"0.0001"}]})}),r=await s.json().catch(()=>({}));if(!s.ok){const t=r?.message||r?.errors?.[0]?.error||"Failed to request airdrop";return{success:!1,errorMessage:String(t)}}const a=r?.airdrops?.[e.chainId]?.[e.tokenId]?.txHash;return r.errors&&r.errors.length>0?{success:!1,errorMessage:r.errors[0].error}:{success:!0,txHash:a}}catch(s){return{success:!1,errorMessage:s?.message&&typeof s.message=="string"?s.message:"Failed to request airdrop"}}}}const m=new N,A=(o,e)=>{const s=a=>e?e(a):R(a),r=[];return o.forEach((a,t)=>{const n=a.calls&&a.calls.length>0,i=a.tokenTransfers&&a.tokenTransfers.length>0;if(n||i){const c={stepId:t,status:t===0?"processing":"pending",chainId:a.chainId,chainName:s(a.chainId),description:"Processing transaction"};r.push(c)}}),r},x=h(null),b=h(null),F=({children:o,provider:e,supportedChainIds:s,network:r="testnet",mode:a="7702",skipFlow:t=[],nativeChainId:n,appName:i="Spicenet",apiUrl:c,theme:f})=>{c&&m.setBaseUrl(c);const p=s??P(r),l=f??null,[w,T]=I(a),S=k(E=>T(E),[]);return g(x.Provider,{value:l,children:g(b.Provider,{value:{provider:e,supportedChainIds:p,skipFlow:t,mode:w,setMode:S,network:r,nativeChainId:n,appName:i,apiUrl:c},children:o})})};function u(o,e){const s=o.replace("#",""),r=Math.max(0,Math.round(parseInt(s.substring(0,2),16)*(1-e))),a=Math.max(0,Math.round(parseInt(s.substring(2,4),16)*(1-e))),t=Math.max(0,Math.round(parseInt(s.substring(4,6),16)*(1-e)));return`#${r.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}${t.toString(16).padStart(2,"0")}`}function M(o,e){return{shell:e?.shell??"#141414",shellBorder:e?.shellBorder??u(e?.shell??"#141414",.35),shellInnerBorder:e?.shellInnerBorder??u(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 O(o){return{shell:"#ffffff",shellBorder:"#E9E9E9",shellInnerBorder:"#D5D5D5",cardBg:"#f9fafb",inputBg:"#ffffff",hoverBg:"#f3f4f6",textPrimary:"#111827",textSecondary:"#6b7280",inputText:"#111827",inputPlaceholder:"#9ca3af",cardBorder:"#E0E0E0",inputBorder:"#d1d5db",buttonBorder:"#0e0d0b",successBg:"#d1fae5",successBorder:"#6ee7b7",successText:"#065f46",warningBg:"#fef3c7",warningBorder:"#fcd34d",warningText:"#92400e",errorBg:"#fee2e2",errorBorder:"#fca5a5",errorText:"#dc2626",infoBg:"#dbeafe",infoBorder:"#93c5fd",infoText:"#1e40af"}}function y(o,e){const s=e?{...o,...e}:o,r=s.dark??!1,a=s.primaryColor,t=s.shell??(r?"#141414":"#ffffff");return{primaryColor:a,dark:r,fontFamily:s.fontFamily??'"Helvetica Neue", sans-serif',appName:s.appName??"Spicenet",logo:s.logo,borderRadius:s.borderRadius??"8px",shell:t,shellBorder:u(t,r?.35:.085),shellInnerBorder:u(t,r?.55:.165),card:s.card??(r?"#1e1e1e":"#f9fafb"),input:r?"#171717":"#ffffff",hover:r?"#2a2a2a":"#f3f4f6",text:s.text??(r?"#ffffff":"#111827"),textMuted:s.textMuted??(r?"#888888":"#6b7280"),inputText:r?"#e0e0e0":"#111827",inputPlaceholder:r?"#555555":"#9ca3af",border:s.border??(r?"rgba(255,255,255,0.08)":"#E0E0E0"),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":"#fcd34d",warningText:r?"#fbbf24":"#92400e",errorBg:r?"#1f0d0d":"#fee2e2",errorBorder:r?"#4a2020":"#fca5a5",errorText:r?"#f87171":"#dc2626",infoBg:r?"#0d1325":"#dbeafe",infoBorder:r?"#2a3a5a":"#93c5fd",infoText:r?"#60a5fa":"#1e40af"}}function j(o,e){const s=$(x)??void 0;return v(()=>{const r=s??{primaryColor:"#EA4B4B"},a={...o?.primaryColor?{primaryColor:o.primaryColor}:{},...o?.fontFamily?{fontFamily:o.fontFamily}:{},...e!==void 0?{dark:e}:{}},t=y(r,a),{dark:n,primaryColor:i,appName:c}=t,f=C(n?"dark":"light"),p={...f,colors:{...f.colors,primary:i,primaryHover:`${i}dd`},typography:{...f.typography,fontFamily:t.fontFamily}},l={shell:t.shell,shellBorder:t.shellBorder,shellInnerBorder:t.shellInnerBorder,cardBg:t.card,inputBg:t.input,hoverBg:t.hover,textPrimary:t.text,textSecondary:t.textMuted,inputText:t.inputText,inputPlaceholder:t.inputPlaceholder,cardBorder:t.border,inputBorder:t.inputBorder,buttonBorder:t.buttonBorder,successBg:t.successBg,successBorder:t.successBorder,successText:t.successText,warningBg:t.warningBg,warningBorder:t.warningBorder,warningText:t.warningText,errorBg:t.errorBg,errorBorder:t.errorBorder,errorText:t.errorText,infoBg:t.infoBg,infoBorder:t.infoBorder,infoText:t.infoText};return{brand:s,theme:p,dark:n,appName:c,primaryColor:i,dk:l,palette:l}},[s,o,e])}export{B as R,b as S,O as a,M as b,A as c,d,F as e,y as f,U as i,m as r,j as u};
2
+ import{createContext as h,useState as I,useCallback as k,useContext as $,useMemo as v}from"react";import{jsx as g}from"react/jsx-runtime";import{getChainIdsByNetwork as P}from"@spicenet-io/spiceflow-core";import{g as R}from"./index-BJoP4QDB.js";import{c as C}from"./Button-DjsYc4v4.js";class d extends Error{constructor(e,s,r={}){super(s),this.code=e,this.context=r,this.name="SpiceflowError",Error.captureStackTrace&&Error.captureStackTrace(this,d)}}function U(o){return o instanceof d}const B=typeof process<"u"&&process.env?.NEXT_PUBLIC_RELAYER_API_URL||"https://tx-submission-api-dev.spicenet.io";class N{constructor(){this.baseUrl=B}setBaseUrl(e){this.baseUrl=e}async createAction(e){const s=await fetch(`${this.baseUrl}/actions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(r,a)=>typeof a=="bigint"?a.toString():a)});if(!s.ok){const r=await s.text();throw new d("RELAYER_ERROR",`Relayer API error: ${s.status} - ${r}`,{httpStatus:s.status,responseBody:r,endpoint:"/actions"})}return s.json()}async executeStep(e,s,r,a){const t=await fetch(`${this.baseUrl}/actions/${e}/intents/${s}/steps/${r}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!t.ok){const n=await t.text();throw new d("RELAYER_EXECUTE_ERROR",`Execute step error: ${t.status} - ${n}`,{httpStatus:t.status,responseBody:n,endpoint:`/actions/${e}/intents/${s}/steps/${r}`,actionId:e})}return{success:!0,transactionHash:(await t.json()).transactionHash}}async checkStepStatus(e,s){const r=e.split("/");let a="";if(r.length>=2){const i=r[0],c=r[1];a=`${this.baseUrl}/actions/${i}/intents/${c}/steps/${s}`}else a=`${this.baseUrl}/actions/${e}/intents/0/steps/${s}`;const t=await fetch(a);if(!t.ok)throw new d("RELAYER_STATUS_ERROR",`Intent step status check failed: ${t.status}`,{httpStatus:t.status,endpoint:a,intentId:e});const n=await t.json();return{success:!0,data:{status:n.status==="error"?"reverted":n.status,transactionHash:n.txid}}}async submitSpiceDeposit(e){const s=e.isDeposit?"deposit":"withdrawal";try{const r=await fetch(`${this.baseUrl}/spicedeposit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await r.json();return!r.ok||!a.success?(console.error(`Failed to submit ${s} request to API:`,a.error?.message),{success:!1,error:a.error}):a}catch(r){return console.error(`Error submitting ${s} request to API:`,r),{success:!1,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async requestAirdrop(e){try{const s=await fetch(`${this.baseUrl}/airdrop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tag:e.tag||"default",airdrops:[{chainId:e.chainId,tokenId:e.tokenId,wallet:e.wallet,amount:e.amount||"0.0001"}]})}),r=await s.json().catch(()=>({}));if(!s.ok){const t=r?.message||r?.errors?.[0]?.error||"Failed to request airdrop";return{success:!1,errorMessage:String(t)}}const a=r?.airdrops?.[e.chainId]?.[e.tokenId]?.txHash;return r.errors&&r.errors.length>0?{success:!1,errorMessage:r.errors[0].error}:{success:!0,txHash:a}}catch(s){return{success:!1,errorMessage:s?.message&&typeof s.message=="string"?s.message:"Failed to request airdrop"}}}}const m=new N,A=(o,e)=>{const s=a=>e?e(a):R(a),r=[];return o.forEach((a,t)=>{const n=a.calls&&a.calls.length>0,i=a.tokenTransfers&&a.tokenTransfers.length>0;if(n||i){const c={stepId:t,status:t===0?"processing":"pending",chainId:a.chainId,chainName:s(a.chainId),description:"Processing transaction"};r.push(c)}}),r},x=h(null),b=h(null),F=({children:o,provider:e,supportedChainIds:s,network:r="testnet",mode:a="7702",skipFlow:t=[],nativeChainId:n,appName:i="Spicenet",apiUrl:c,theme:f})=>{c&&m.setBaseUrl(c);const p=s??P(r),l=f??null,[w,T]=I(a),S=k(E=>T(E),[]);return g(x.Provider,{value:l,children:g(b.Provider,{value:{provider:e,supportedChainIds:p,skipFlow:t,mode:w,setMode:S,network:r,nativeChainId:n,appName:i,apiUrl:c},children:o})})};function u(o,e){const s=o.replace("#",""),r=Math.max(0,Math.round(parseInt(s.substring(0,2),16)*(1-e))),a=Math.max(0,Math.round(parseInt(s.substring(2,4),16)*(1-e))),t=Math.max(0,Math.round(parseInt(s.substring(4,6),16)*(1-e)));return`#${r.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}${t.toString(16).padStart(2,"0")}`}function M(o,e){return{shell:e?.shell??"#141414",shellBorder:e?.shellBorder??u(e?.shell??"#141414",.35),shellInnerBorder:e?.shellInnerBorder??u(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 O(o){return{shell:"#ffffff",shellBorder:"#E9E9E9",shellInnerBorder:"#D5D5D5",cardBg:"#f9fafb",inputBg:"#ffffff",hoverBg:"#f3f4f6",textPrimary:"#111827",textSecondary:"#6b7280",inputText:"#111827",inputPlaceholder:"#9ca3af",cardBorder:"#E0E0E0",inputBorder:"#d1d5db",buttonBorder:"#0e0d0b",successBg:"#d1fae5",successBorder:"#6ee7b7",successText:"#065f46",warningBg:"#fef3c7",warningBorder:"#fcd34d",warningText:"#92400e",errorBg:"#fee2e2",errorBorder:"#fca5a5",errorText:"#dc2626",infoBg:"#dbeafe",infoBorder:"#93c5fd",infoText:"#1e40af"}}function y(o,e){const s=e?{...o,...e}:o,r=s.dark??!1,a=s.primaryColor,t=s.shell??(r?"#141414":"#ffffff");return{primaryColor:a,dark:r,fontFamily:s.fontFamily??'"Helvetica Neue", sans-serif',appName:s.appName??"Spicenet",logo:s.logo,borderRadius:s.borderRadius??"8px",shell:t,shellBorder:u(t,r?.35:.085),shellInnerBorder:u(t,r?.55:.165),card:s.card??(r?"#1e1e1e":"#f9fafb"),input:r?"#171717":"#ffffff",hover:r?"#2a2a2a":"#f3f4f6",text:s.text??(r?"#ffffff":"#111827"),textMuted:s.textMuted??(r?"#888888":"#6b7280"),inputText:r?"#e0e0e0":"#111827",inputPlaceholder:r?"#555555":"#9ca3af",border:s.border??(r?"rgba(255,255,255,0.08)":"#E0E0E0"),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":"#fcd34d",warningText:r?"#fbbf24":"#92400e",errorBg:r?"#1f0d0d":"#fee2e2",errorBorder:r?"#4a2020":"#fca5a5",errorText:r?"#f87171":"#dc2626",infoBg:r?"#0d1325":"#dbeafe",infoBorder:r?"#2a3a5a":"#93c5fd",infoText:r?"#60a5fa":"#1e40af"}}function j(o,e){const s=$(x)??void 0;return v(()=>{const r=s??{primaryColor:"#EA4B4B"},a={...o?.primaryColor?{primaryColor:o.primaryColor}:{},...o?.fontFamily?{fontFamily:o.fontFamily}:{},...e!==void 0?{dark:e}:{}},t=y(r,a),{dark:n,primaryColor:i,appName:c}=t,f=C(n?"dark":"light"),p={...f,colors:{...f.colors,primary:i,primaryHover:`${i}dd`},typography:{...f.typography,fontFamily:t.fontFamily}},l={shell:t.shell,shellBorder:t.shellBorder,shellInnerBorder:t.shellInnerBorder,cardBg:t.card,inputBg:t.input,hoverBg:t.hover,textPrimary:t.text,textSecondary:t.textMuted,inputText:t.inputText,inputPlaceholder:t.inputPlaceholder,cardBorder:t.border,inputBorder:t.inputBorder,buttonBorder:t.buttonBorder,successBg:t.successBg,successBorder:t.successBorder,successText:t.successText,warningBg:t.warningBg,warningBorder:t.warningBorder,warningText:t.warningText,errorBg:t.errorBg,errorBorder:t.errorBorder,errorText:t.errorText,infoBg:t.infoBg,infoBorder:t.infoBorder,infoText:t.infoText};return{brand:s,theme:p,dark:n,appName:c,primaryColor:i,dk:l,palette:l}},[s,o,e])}export{B as R,b as S,O as a,M as b,A as c,d,F as e,y as f,U as i,m as r,j as u};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";const l=require("react"),g=require("react/jsx-runtime"),I=require("@spicenet-io/spiceflow-core"),P=require("./index-CkWAs8UV.js"),v=require("./Button-B_UpyUH-.js");class d extends Error{constructor(e,s,r={}){super(s),this.code=e,this.context=r,this.name="SpiceflowError",Error.captureStackTrace&&Error.captureStackTrace(this,d)}}function k(a){return a instanceof d}const B=typeof process<"u"&&process.env?.NEXT_PUBLIC_RELAYER_API_URL||"https://tx-submission-api-dev.spicenet.io";class R{constructor(){this.baseUrl=B}setBaseUrl(e){this.baseUrl=e}async createAction(e){const s=await fetch(`${this.baseUrl}/actions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(r,o)=>typeof o=="bigint"?o.toString():o)});if(!s.ok){const r=await s.text();throw new d("RELAYER_ERROR",`Relayer API error: ${s.status} - ${r}`,{httpStatus:s.status,responseBody:r,endpoint:"/actions"})}return s.json()}async executeStep(e,s,r,o){const t=await fetch(`${this.baseUrl}/actions/${e}/intents/${s}/steps/${r}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!t.ok){const n=await t.text();throw new d("RELAYER_EXECUTE_ERROR",`Execute step error: ${t.status} - ${n}`,{httpStatus:t.status,responseBody:n,endpoint:`/actions/${e}/intents/${s}/steps/${r}`,actionId:e})}return{success:!0,transactionHash:(await t.json()).transactionHash}}async checkStepStatus(e,s){const r=e.split("/");let o="";if(r.length>=2){const i=r[0],c=r[1];o=`${this.baseUrl}/actions/${i}/intents/${c}/steps/${s}`}else o=`${this.baseUrl}/actions/${e}/intents/0/steps/${s}`;const t=await fetch(o);if(!t.ok)throw new d("RELAYER_STATUS_ERROR",`Intent step status check failed: ${t.status}`,{httpStatus:t.status,endpoint:o,intentId:e});const n=await t.json();return{success:!0,data:{status:n.status==="error"?"reverted":n.status,transactionHash:n.txid}}}async submitSpiceDeposit(e){const s=e.isDeposit?"deposit":"withdrawal";try{const r=await fetch(`${this.baseUrl}/spicedeposit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),o=await r.json();return!r.ok||!o.success?(console.error(`Failed to submit ${s} request to API:`,o.error?.message),{success:!1,error:o.error}):o}catch(r){return console.error(`Error submitting ${s} request to API:`,r),{success:!1,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async requestAirdrop(e){try{const s=await fetch(`${this.baseUrl}/airdrop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tag:e.tag||"default",airdrops:[{chainId:e.chainId,tokenId:e.tokenId,wallet:e.wallet,amount:e.amount||"0.0001"}]})}),r=await s.json().catch(()=>({}));if(!s.ok){const t=r?.message||r?.errors?.[0]?.error||"Failed to request airdrop";return{success:!1,errorMessage:String(t)}}const o=r?.airdrops?.[e.chainId]?.[e.tokenId]?.txHash;return r.errors&&r.errors.length>0?{success:!1,errorMessage:r.errors[0].error}:{success:!0,txHash:o}}catch(s){return{success:!1,errorMessage:s?.message&&typeof s.message=="string"?s.message:"Failed to request airdrop"}}}}const x=new R,C=(a,e)=>{const s=o=>e?e(o):P.getChainName(o),r=[];return a.forEach((o,t)=>{const n=o.calls&&o.calls.length>0,i=o.tokenTransfers&&o.tokenTransfers.length>0;if(n||i){const c={stepId:t,status:t===0?"processing":"pending",chainId:o.chainId,chainName:s(o.chainId),description:"Processing transaction"};r.push(c)}}),r},b=l.createContext(null),m=l.createContext(null),$=({children:a,provider:e,supportedChainIds:s,network:r="testnet",mode:o="7702",skipFlow:t=[],nativeChainId:n,appName:i="Spicenet",apiUrl:c,theme:u})=>{c&&x.setBaseUrl(c);const h=s??I.getChainIdsByNetwork(r),f=u??null,[w,S]=l.useState(o),T=l.useCallback(E=>S(E),[]);return g.jsx(b.Provider,{value:f,children:g.jsx(m.Provider,{value:{provider:e,supportedChainIds:h,skipFlow:t,mode:w,setMode:T,network:r,nativeChainId:n,appName:i,apiUrl:c},children:a})})};function p(a,e){const s=a.replace("#",""),r=Math.max(0,Math.round(parseInt(s.substring(0,2),16)*(1-e))),o=Math.max(0,Math.round(parseInt(s.substring(2,4),16)*(1-e))),t=Math.max(0,Math.round(parseInt(s.substring(4,6),16)*(1-e)));return`#${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${t.toString(16).padStart(2,"0")}`}function U(a,e){return{shell:e?.shell??"#141414",shellBorder:e?.shellBorder??p(e?.shell??"#141414",.35),shellInnerBorder:e?.shellInnerBorder??p(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 A(a){return{shell:"#ffffff",shellBorder:"#E9E9E9",shellInnerBorder:"#D5D5D5",cardBg:"#f9fafb",inputBg:"#ffffff",hoverBg:"#f3f4f6",textPrimary:"#111827",textSecondary:"#6b7280",inputText:"#111827",inputPlaceholder:"#9ca3af",cardBorder:"#E0E0E0",inputBorder:"#d1d5db",buttonBorder:"#0e0d0b",successBg:"#d1fae5",successBorder:"#6ee7b7",successText:"#065f46",warningBg:"#fef3c7",warningBorder:"#fcd34d",warningText:"#92400e",errorBg:"#fee2e2",errorBorder:"#fca5a5",errorText:"#dc2626",infoBg:"#dbeafe",infoBorder:"#93c5fd",infoText:"#1e40af"}}function y(a,e){const s=e?{...a,...e}:a,r=s.dark??!1,o=s.primaryColor,t=s.shell??(r?"#141414":"#ffffff");return{primaryColor:o,dark:r,fontFamily:s.fontFamily??'"Helvetica Neue", sans-serif',appName:s.appName??"Spicenet",logo:s.logo,borderRadius:s.borderRadius??"8px",shell:t,shellBorder:p(t,r?.35:.085),shellInnerBorder:p(t,r?.55:.165),card:s.card??(r?"#1e1e1e":"#f9fafb"),input:r?"#171717":"#ffffff",hover:r?"#2a2a2a":"#f3f4f6",text:s.text??(r?"#ffffff":"#111827"),textMuted:s.textMuted??(r?"#888888":"#6b7280"),inputText:r?"#e0e0e0":"#111827",inputPlaceholder:r?"#555555":"#9ca3af",border:s.border??(r?"rgba(255,255,255,0.08)":"#E0E0E0"),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":"#fcd34d",warningText:r?"#fbbf24":"#92400e",errorBg:r?"#1f0d0d":"#fee2e2",errorBorder:r?"#4a2020":"#fca5a5",errorText:r?"#f87171":"#dc2626",infoBg:r?"#0d1325":"#dbeafe",infoBorder:r?"#2a3a5a":"#93c5fd",infoText:r?"#60a5fa":"#1e40af"}}function F(a,e){const s=l.useContext(b)??void 0;return l.useMemo(()=>{const r=s??{primaryColor:"#EA4B4B"},o={...a?.primaryColor?{primaryColor:a.primaryColor}:{},...a?.fontFamily?{fontFamily:a.fontFamily}:{},...e!==void 0?{dark:e}:{}},t=y(r,o),{dark:n,primaryColor:i,appName:c}=t,u=v.createTheme(n?"dark":"light"),h={...u,colors:{...u.colors,primary:i,primaryHover:`${i}dd`},typography:{...u.typography,fontFamily:t.fontFamily}},f={shell:t.shell,shellBorder:t.shellBorder,shellInnerBorder:t.shellInnerBorder,cardBg:t.card,inputBg:t.input,hoverBg:t.hover,textPrimary:t.text,textSecondary:t.textMuted,inputText:t.inputText,inputPlaceholder:t.inputPlaceholder,cardBorder:t.border,inputBorder:t.inputBorder,buttonBorder:t.buttonBorder,successBg:t.successBg,successBorder:t.successBorder,successText:t.successText,warningBg:t.warningBg,warningBorder:t.warningBorder,warningText:t.warningText,errorBg:t.errorBg,errorBorder:t.errorBorder,errorText:t.errorText,infoBg:t.infoBg,infoBorder:t.infoBorder,infoText:t.infoText};return{brand:s,theme:h,dark:n,appName:c,primaryColor:i,dk:f,palette:f}},[s,a,e])}exports.RELAYER_API_URL=B,exports.SpiceFlowProvider=$,exports.SpiceFlowProviderContext=m,exports.SpiceflowError=d,exports.buildDarkPalette=U,exports.buildLightPalette=A,exports.createInitialSteps=C,exports.isSpiceflowError=k,exports.relayerService=x,exports.resolveTheme=y,exports.useSpiceBrand=F;
2
+ "use strict";const l=require("react"),g=require("react/jsx-runtime"),I=require("@spicenet-io/spiceflow-core"),P=require("./index-B1Vl1ITK.js"),v=require("./Button-B_UpyUH-.js");class d extends Error{constructor(e,s,r={}){super(s),this.code=e,this.context=r,this.name="SpiceflowError",Error.captureStackTrace&&Error.captureStackTrace(this,d)}}function k(a){return a instanceof d}const B=typeof process<"u"&&process.env?.NEXT_PUBLIC_RELAYER_API_URL||"https://tx-submission-api-dev.spicenet.io";class R{constructor(){this.baseUrl=B}setBaseUrl(e){this.baseUrl=e}async createAction(e){const s=await fetch(`${this.baseUrl}/actions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(r,o)=>typeof o=="bigint"?o.toString():o)});if(!s.ok){const r=await s.text();throw new d("RELAYER_ERROR",`Relayer API error: ${s.status} - ${r}`,{httpStatus:s.status,responseBody:r,endpoint:"/actions"})}return s.json()}async executeStep(e,s,r,o){const t=await fetch(`${this.baseUrl}/actions/${e}/intents/${s}/steps/${r}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!t.ok){const n=await t.text();throw new d("RELAYER_EXECUTE_ERROR",`Execute step error: ${t.status} - ${n}`,{httpStatus:t.status,responseBody:n,endpoint:`/actions/${e}/intents/${s}/steps/${r}`,actionId:e})}return{success:!0,transactionHash:(await t.json()).transactionHash}}async checkStepStatus(e,s){const r=e.split("/");let o="";if(r.length>=2){const i=r[0],c=r[1];o=`${this.baseUrl}/actions/${i}/intents/${c}/steps/${s}`}else o=`${this.baseUrl}/actions/${e}/intents/0/steps/${s}`;const t=await fetch(o);if(!t.ok)throw new d("RELAYER_STATUS_ERROR",`Intent step status check failed: ${t.status}`,{httpStatus:t.status,endpoint:o,intentId:e});const n=await t.json();return{success:!0,data:{status:n.status==="error"?"reverted":n.status,transactionHash:n.txid}}}async submitSpiceDeposit(e){const s=e.isDeposit?"deposit":"withdrawal";try{const r=await fetch(`${this.baseUrl}/spicedeposit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),o=await r.json();return!r.ok||!o.success?(console.error(`Failed to submit ${s} request to API:`,o.error?.message),{success:!1,error:o.error}):o}catch(r){return console.error(`Error submitting ${s} request to API:`,r),{success:!1,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async requestAirdrop(e){try{const s=await fetch(`${this.baseUrl}/airdrop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tag:e.tag||"default",airdrops:[{chainId:e.chainId,tokenId:e.tokenId,wallet:e.wallet,amount:e.amount||"0.0001"}]})}),r=await s.json().catch(()=>({}));if(!s.ok){const t=r?.message||r?.errors?.[0]?.error||"Failed to request airdrop";return{success:!1,errorMessage:String(t)}}const o=r?.airdrops?.[e.chainId]?.[e.tokenId]?.txHash;return r.errors&&r.errors.length>0?{success:!1,errorMessage:r.errors[0].error}:{success:!0,txHash:o}}catch(s){return{success:!1,errorMessage:s?.message&&typeof s.message=="string"?s.message:"Failed to request airdrop"}}}}const x=new R,C=(a,e)=>{const s=o=>e?e(o):P.getChainName(o),r=[];return a.forEach((o,t)=>{const n=o.calls&&o.calls.length>0,i=o.tokenTransfers&&o.tokenTransfers.length>0;if(n||i){const c={stepId:t,status:t===0?"processing":"pending",chainId:o.chainId,chainName:s(o.chainId),description:"Processing transaction"};r.push(c)}}),r},b=l.createContext(null),m=l.createContext(null),$=({children:a,provider:e,supportedChainIds:s,network:r="testnet",mode:o="7702",skipFlow:t=[],nativeChainId:n,appName:i="Spicenet",apiUrl:c,theme:u})=>{c&&x.setBaseUrl(c);const h=s??I.getChainIdsByNetwork(r),f=u??null,[w,S]=l.useState(o),T=l.useCallback(E=>S(E),[]);return g.jsx(b.Provider,{value:f,children:g.jsx(m.Provider,{value:{provider:e,supportedChainIds:h,skipFlow:t,mode:w,setMode:T,network:r,nativeChainId:n,appName:i,apiUrl:c},children:a})})};function p(a,e){const s=a.replace("#",""),r=Math.max(0,Math.round(parseInt(s.substring(0,2),16)*(1-e))),o=Math.max(0,Math.round(parseInt(s.substring(2,4),16)*(1-e))),t=Math.max(0,Math.round(parseInt(s.substring(4,6),16)*(1-e)));return`#${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${t.toString(16).padStart(2,"0")}`}function U(a,e){return{shell:e?.shell??"#141414",shellBorder:e?.shellBorder??p(e?.shell??"#141414",.35),shellInnerBorder:e?.shellInnerBorder??p(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 A(a){return{shell:"#ffffff",shellBorder:"#E9E9E9",shellInnerBorder:"#D5D5D5",cardBg:"#f9fafb",inputBg:"#ffffff",hoverBg:"#f3f4f6",textPrimary:"#111827",textSecondary:"#6b7280",inputText:"#111827",inputPlaceholder:"#9ca3af",cardBorder:"#E0E0E0",inputBorder:"#d1d5db",buttonBorder:"#0e0d0b",successBg:"#d1fae5",successBorder:"#6ee7b7",successText:"#065f46",warningBg:"#fef3c7",warningBorder:"#fcd34d",warningText:"#92400e",errorBg:"#fee2e2",errorBorder:"#fca5a5",errorText:"#dc2626",infoBg:"#dbeafe",infoBorder:"#93c5fd",infoText:"#1e40af"}}function y(a,e){const s=e?{...a,...e}:a,r=s.dark??!1,o=s.primaryColor,t=s.shell??(r?"#141414":"#ffffff");return{primaryColor:o,dark:r,fontFamily:s.fontFamily??'"Helvetica Neue", sans-serif',appName:s.appName??"Spicenet",logo:s.logo,borderRadius:s.borderRadius??"8px",shell:t,shellBorder:p(t,r?.35:.085),shellInnerBorder:p(t,r?.55:.165),card:s.card??(r?"#1e1e1e":"#f9fafb"),input:r?"#171717":"#ffffff",hover:r?"#2a2a2a":"#f3f4f6",text:s.text??(r?"#ffffff":"#111827"),textMuted:s.textMuted??(r?"#888888":"#6b7280"),inputText:r?"#e0e0e0":"#111827",inputPlaceholder:r?"#555555":"#9ca3af",border:s.border??(r?"rgba(255,255,255,0.08)":"#E0E0E0"),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":"#fcd34d",warningText:r?"#fbbf24":"#92400e",errorBg:r?"#1f0d0d":"#fee2e2",errorBorder:r?"#4a2020":"#fca5a5",errorText:r?"#f87171":"#dc2626",infoBg:r?"#0d1325":"#dbeafe",infoBorder:r?"#2a3a5a":"#93c5fd",infoText:r?"#60a5fa":"#1e40af"}}function F(a,e){const s=l.useContext(b)??void 0;return l.useMemo(()=>{const r=s??{primaryColor:"#EA4B4B"},o={...a?.primaryColor?{primaryColor:a.primaryColor}:{},...a?.fontFamily?{fontFamily:a.fontFamily}:{},...e!==void 0?{dark:e}:{}},t=y(r,o),{dark:n,primaryColor:i,appName:c}=t,u=v.createTheme(n?"dark":"light"),h={...u,colors:{...u.colors,primary:i,primaryHover:`${i}dd`},typography:{...u.typography,fontFamily:t.fontFamily}},f={shell:t.shell,shellBorder:t.shellBorder,shellInnerBorder:t.shellInnerBorder,cardBg:t.card,inputBg:t.input,hoverBg:t.hover,textPrimary:t.text,textSecondary:t.textMuted,inputText:t.inputText,inputPlaceholder:t.inputPlaceholder,cardBorder:t.border,inputBorder:t.inputBorder,buttonBorder:t.buttonBorder,successBg:t.successBg,successBorder:t.successBorder,successText:t.successText,warningBg:t.warningBg,warningBorder:t.warningBorder,warningText:t.warningText,errorBg:t.errorBg,errorBorder:t.errorBorder,errorText:t.errorText,infoBg:t.infoBg,infoBorder:t.infoBorder,infoText:t.infoText};return{brand:s,theme:h,dark:n,appName:c,primaryColor:i,dk:f,palette:f}},[s,a,e])}exports.RELAYER_API_URL=B,exports.SpiceFlowProvider=$,exports.SpiceFlowProviderContext=m,exports.SpiceflowError=d,exports.buildDarkPalette=U,exports.buildLightPalette=A,exports.createInitialSteps=C,exports.isSpiceflowError=k,exports.relayerService=x,exports.resolveTheme=y,exports.useSpiceBrand=F;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spicenet-io/spiceflow-ui",
3
- "version": "2.5.8",
3
+ "version": "2.5.9",
4
4
  "description": "Spiceflow UI SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",