@spicenet-io/spiceflow-ui 3.1.1 → 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth-dynamic.js +1 -1
- package/dist/auth-privy.js +1 -1
- package/dist/auth-starknet.cjs.js +1 -1
- package/dist/auth-starknet.js +1 -1
- package/dist/hooks/useSupplyQuote.d.ts +0 -7
- package/dist/index.cjs.js +11 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.js +13 -13
- package/dist/{providerWallet-Dxki0e9w.js → providerWallet-BlhIbvVk.js} +1 -1
- package/dist/types/authorization.d.ts +1 -0
- package/dist/types/deposit.d.ts +27 -0
- package/dist/types/unified.d.ts +2 -2
- package/dist/useSpiceBrand-CsEv5pNz.js +2 -0
- package/dist/useSpiceBrand-fWPbO0Pf.js +2 -0
- package/dist/utils/formatting/index.d.ts +0 -1
- package/dist/utils/relayer/index.d.ts +13 -2
- package/package.json +2 -2
- package/dist/useSpiceBrand-C8U32f9J.js +0 -2
- package/dist/useSpiceBrand-CxKzcCkA.js +0 -2
- /package/dist/{Button-CaguAr48.js → Button-DjsYc4v4.js} +0 -0
- /package/dist/{index-Bv5PiWia.js → index-D2i8C5Pt.js} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{createWalletClient as l,custom as d}from"viem";import{g as c}from"./index-
|
|
2
|
+
import{createWalletClient as l,custom as d}from"viem";import{g as c}from"./index-D2i8C5Pt.js";const o=t=>{if(!t)return!1;const e=t.connector;if(!e)return!1;if(e.isEmbeddedWallet===!0)return!0;const r=(e.key||e.connectorKey||"").toLowerCase();if(r.includes("embedded")||r.includes("turnkey"))return!0;const n=(e.name||t.walletName||"").toLowerCase();return!!(n.includes("embedded")||n.includes("turnkey"))},u=t=>(t?.connectedWallets||[]).find(e=>o(e))||(o(t?.primaryWallet)?t.primaryWallet:null),f=t=>(t?.connectedWallets||[]).find(e=>e?.address&&e?.connector&&!o(e))||null,i=async(t,e)=>{if(!t?.address)throw new Error("Wallet not available");if(typeof t.getWalletClient=="function"){const r=e===void 0?[void 0]:[String(e),e,void 0];let n=null;for(const s of r)try{const a=await t.getWalletClient(s);if(a)return a}catch(a){n=a}if(n)throw n}if(typeof t.getEthereumProvider=="function"){const r=await t.getEthereumProvider(),n=e?c(e)?.viemChain:void 0;return l({account:t.address,chain:n,transport:d(r)})}throw new Error("Wallet client not available")},m=async(t,e)=>{if(!t?.address)throw new Error("Wallet not available");if(typeof t.getEthereumProvider=="function")return t.getEthereumProvider();const r=await i(t,e);return{request:n=>r.request(n)}},y=(t,e)=>({address:t?.address||e.address,chainId:Number(t?.chainId??e.chainId),contractAddress:t?.contractAddress||t?.delegate||e.contractAddress,nonce:BigInt(t?.nonce??e.nonce),r:t?.r,s:t?.s,yParity:(()=>{if(typeof t?.yParity=="number")return t.yParity;const r=Number(t?.v??27);return Number.isFinite(r)?r>=27?r-27:r:0})()});export{m as a,f as b,i as c,u as g,y as n};
|
package/dist/types/deposit.d.ts
CHANGED
|
@@ -20,16 +20,43 @@ export interface SpiceDepositRequest {
|
|
|
20
20
|
tokenAddress: string;
|
|
21
21
|
chainId: number;
|
|
22
22
|
amount: string;
|
|
23
|
+
amountMode?: "gross_input" | "net_input";
|
|
23
24
|
}
|
|
24
25
|
export interface SpiceDepositResponse {
|
|
25
26
|
success: boolean;
|
|
26
27
|
data?: {
|
|
27
28
|
creditedAmount?: string;
|
|
29
|
+
feeEstimate?: {
|
|
30
|
+
amountMode: "gross_input" | "net_input";
|
|
31
|
+
intents: Array<{
|
|
32
|
+
intentIndex: number;
|
|
33
|
+
batches: Array<{
|
|
34
|
+
chainId: number;
|
|
35
|
+
amountMode: "gross_input" | "net_input";
|
|
36
|
+
outputToken: string;
|
|
37
|
+
grossOutput: string;
|
|
38
|
+
netOutput: string;
|
|
39
|
+
totalFee: string;
|
|
40
|
+
gasQuoteSource: "estimated" | "configured_fallback" | "static_zero";
|
|
41
|
+
feeBreakdown: {
|
|
42
|
+
spicenetFee: string;
|
|
43
|
+
gasFee: string;
|
|
44
|
+
};
|
|
45
|
+
}>;
|
|
46
|
+
}>;
|
|
47
|
+
};
|
|
28
48
|
};
|
|
29
49
|
error?: {
|
|
30
50
|
message: string;
|
|
31
51
|
};
|
|
32
52
|
}
|
|
53
|
+
export interface SpiceDepositFeeEstimateRequest {
|
|
54
|
+
user: string;
|
|
55
|
+
chainId: number;
|
|
56
|
+
tokenAddress: string;
|
|
57
|
+
amount: string;
|
|
58
|
+
amountMode?: "gross_input" | "net_input";
|
|
59
|
+
}
|
|
33
60
|
export interface DepositWidgetProps {
|
|
34
61
|
depositBatches: ChainBatch[];
|
|
35
62
|
tokenAddress: Address;
|
package/dist/types/unified.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export interface CreateActionRequest {
|
|
|
37
37
|
}
|
|
38
38
|
export interface FeeEstimateBatch {
|
|
39
39
|
chainId: number;
|
|
40
|
-
amountMode: "gross_input";
|
|
40
|
+
amountMode: "gross_input" | "net_input";
|
|
41
41
|
outputToken: Address;
|
|
42
42
|
grossOutput: string;
|
|
43
43
|
netOutput: string;
|
|
@@ -53,7 +53,7 @@ export interface FeeEstimateIntent {
|
|
|
53
53
|
batches: FeeEstimateBatch[];
|
|
54
54
|
}
|
|
55
55
|
export interface FeeEstimateSummary {
|
|
56
|
-
amountMode: "gross_input";
|
|
56
|
+
amountMode: "gross_input" | "net_input";
|
|
57
57
|
intents: FeeEstimateIntent[];
|
|
58
58
|
}
|
|
59
59
|
export interface CreateActionResponse {
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{createContext as B,useEffect as w,useState as U,useCallback as k,useContext as C,useMemo as P}from"react";import{jsx as m}from"react/jsx-runtime";import{getChainIdsByNetwork as O}from"@spicenet-io/spiceflow-core";import{a as A,s as y}from"./index-D2i8C5Pt.js";import{c as _}from"./Button-DjsYc4v4.js";class c extends Error{constructor(t,r,e={}){super(r),this.code=t,this.context=e,this.name="SpiceflowError",Error.captureStackTrace&&Error.captureStackTrace(this,c)}}function j(o){return o instanceof c}const E=typeof process<"u"&&process.env?.NEXT_PUBLIC_RELAYER_API_URL||"https://tx-api-devserver.spicenet.io",x="__SPICEFLOW_RELAYER_API_URL__";function N(){if(typeof globalThis>"u")return;const o=globalThis[x];return typeof o=="string"&&o.length>0?o:void 0}class F{constructor(){this.baseUrl=E}setBaseUrl(t){this.baseUrl=t,typeof globalThis<"u"&&(globalThis[x]=t)}getBaseUrl(){return this.getEffectiveBaseUrl()}getEffectiveBaseUrl(){return N()||this.baseUrl}async createAction(t){console.log("[SpiceRelayer] createAction:start",{baseUrl:this.getEffectiveBaseUrl(),intentCount:t.intents.length,chainAuthorizationCount:t.chainAuthorizations?.length??0});const r=await fetch(`${this.getEffectiveBaseUrl()}/actions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t,(a,s)=>typeof s=="bigint"?s.toString():s)});if(!r.ok){const a=await r.text();throw console.log("[SpiceRelayer] createAction:error",{baseUrl:this.getEffectiveBaseUrl(),status:r.status,errorText:a}),new c("RELAYER_ERROR",`Relayer API error: ${r.status} - ${a}`,{httpStatus:r.status,responseBody:a,endpoint:"/actions"})}const e=await r.json();return console.log("[SpiceRelayer] createAction:success",{intentIds:e.intentIds}),e}async estimateActionFees(t){const r=await fetch(`${this.getEffectiveBaseUrl()}/actions/fees/estimate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t,(a,s)=>typeof s=="bigint"?s.toString():s)}),e=await r.json();if(!r.ok||!e.success||!e.data?.feeEstimate){const a=e.error?.message||`Relayer fee estimate error: ${r.status}`;throw new c("RELAYER_ERROR",a,{httpStatus:r.status,responseBody:JSON.stringify(e),endpoint:"/actions/fees/estimate"})}return e.data.feeEstimate}async estimateSpiceDepositFees(t){const r=await fetch(`${this.getEffectiveBaseUrl()}/spicedeposit/fees/estimate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t,(a,s)=>typeof s=="bigint"?s.toString():s)}),e=await r.json();if(!r.ok||!e.success||!e.data?.feeEstimate){const a=e.error?.message||`Deposit fee estimate error: ${r.status}`;throw new c("RELAYER_ERROR",a,{httpStatus:r.status,responseBody:JSON.stringify(e),endpoint:"/spicedeposit/fees/estimate"})}return e.data.feeEstimate}async executeStep(t,r,e,a){const s=`${this.getEffectiveBaseUrl()}/actions/${t}/intents/${r}/steps/${e}`,d=fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});let n;try{n=await Promise.race([d,new Promise((i,f)=>setTimeout(()=>f(new c("RELAYER_EXECUTE_ERROR",`Execute step request timed out after ${1e4/1e3}s`,{actionId:t,intentIndex:r,stepIndex:e,endpoint:`/actions/${t}/intents/${r}/steps/${e}`})),1e4))])}catch(i){throw i}if(!n.ok){const i=await n.text();throw new c("RELAYER_EXECUTE_ERROR",`Execute step error: ${n.status} - ${i}`,{httpStatus:n.status,responseBody:i,endpoint:`/actions/${t}/intents/${r}/steps/${e}`,actionId:t})}return{success:!0,transactionHash:(await n.json()).transactionHash}}async checkStepStatus(t,r){const e=t.split("/");let a="";if(e.length>=2){const n=e[0],i=e[1];a=`${this.getEffectiveBaseUrl()}/actions/${n}/intents/${i}/steps/${r}`}else a=`${this.getEffectiveBaseUrl()}/actions/${t}/intents/0/steps/${r}`;const s=await fetch(a);if(!s.ok)throw new c("RELAYER_STATUS_ERROR",`Intent step status check failed: ${s.status}`,{httpStatus:s.status,endpoint:a,intentId:t});const d=await s.json();return{success:!0,data:{status:d.status==="error"?"reverted":d.status,transactionHash:d.txid}}}async submitSpiceDeposit(t){const r=t.isDeposit?"deposit":"withdrawal";try{const e=await fetch(`${this.getEffectiveBaseUrl()}/spicedeposit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),a=await e.json();return!e.ok||!a.success?(console.error(`Failed to submit ${r} request to API:`,a.error?.message),{success:!1,error:a.error}):a}catch(e){return console.error(`Error submitting ${r} request to API:`,e),{success:!1,error:{message:e instanceof Error?e.message:"Unknown error"}}}}async requestSpiceUsdAirdrop(t){try{const r=await fetch(`${this.getEffectiveBaseUrl()}/airdrop/${t.chainId}/spiceUsd`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({wallet:t.address})}),e=await r.json().catch(()=>({}));if(!r.ok){const a=e&&(e.error||e.message)||"Failed to request airdrop";return{success:!1,errorMessage:String(a)}}return e&&typeof e.error=="string"?{success:!1,errorMessage:e.error}:e&&(e.txHash||e.amount)?{success:!0,txHash:e.txHash,amount:e.amount}:{success:!0}}catch(r){return{success:!1,errorMessage:r?.message&&typeof r.message=="string"?r.message:"Failed to request airdrop"}}}async requestAirdrop(t){try{const r=await fetch(`${this.getEffectiveBaseUrl()}/airdrop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tag:t.tag||"default",airdrops:[{chainId:t.chainId,tokenId:t.tokenId,wallet:t.wallet,amount:t.amount||"0.0001"}]})}),e=await r.json().catch(()=>({}));if(!r.ok){const s=e?.message||e?.errors?.[0]?.error||"Failed to request airdrop";return{success:!1,errorMessage:String(s)}}const a=e?.airdrops?.[t.chainId]?.[t.tokenId]?.txHash;return e.errors&&e.errors.length>0?{success:!1,errorMessage:e.errors[0].error}:{success:!0,txHash:a}}catch(r){return{success:!1,errorMessage:r?.message&&typeof r.message=="string"?r.message:"Failed to request airdrop"}}}async createWallet(t,r){const e=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!e.ok){const a=await e.text();throw new c("RELAYER_ERROR",`Create wallet error: ${e.status} - ${a}`,{httpStatus:e.status,endpoint:`/wallets/${t}`})}return e.json()}async getWallet(t){const r=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${t}`);if(!r.ok){const e=await r.text();throw new c("RELAYER_ERROR",`Get wallet error: ${r.status} - ${e}`,{httpStatus:r.status,endpoint:`/wallets/${t}`})}return r.json()}async createWithdrawal(t){const r=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t,(e,a)=>typeof a=="bigint"?a.toString():a)});if(!r.ok){const e=await r.text();throw new c("RELAYER_ERROR",`Create withdrawal error: ${r.status} - ${e}`,{httpStatus:r.status,endpoint:"/withdrawals"})}return r.json()}async getWithdrawal(t){const r=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals/${t}`);if(!r.ok){const e=await r.text();throw new c("RELAYER_ERROR",`Get withdrawal error: ${r.status} - ${e}`,{httpStatus:r.status,endpoint:`/withdrawals/${t}`})}return r.json()}async getRollupTimestamp(){const t=await fetch(`${this.getEffectiveBaseUrl()}/time`);if(!t.ok)throw new c("RELAYER_ERROR",`Get rollup timestamp error: ${t.status}`,{httpStatus:t.status,endpoint:"/time"});return t.json()}}const p=new F,L=(o,t)=>{const r=a=>t?t(a):A(a),e=[];return o.forEach((a,s)=>{const d=a.calls&&a.calls.length>0,n=a.tokenTransfers&&a.tokenTransfers.length>0;if(d||n){const i={stepId:s,status:s===0?"processing":"pending",chainId:a.chainId,chainName:r(a.chainId),description:"Processing transaction"};e.push(i)}}),e},R=B(null),S=B(null),M=({children:o,provider:t,supportedChainIds:r,network:e="testnet",mode:a="7702",skipFlow:s=[],nativeChainId:d,appName:n="Spicenet",apiUrl:i,theme:f,rpcOverrides:l})=>{w(()=>{if(!i)return;const g=p.getBaseUrl();return p.setBaseUrl(i),()=>p.setBaseUrl(g)},[i]),w(()=>(y(l),()=>y(void 0)),[l]);const u=r??O(e),T=f??null,[$,v]=U(a),I=k(g=>v(g),[]);return m(R.Provider,{value:T,children:m(S.Provider,{value:{provider:t,supportedChainIds:u,skipFlow:s,mode:$,setMode:I,network:e,nativeChainId:d,appName:n,apiUrl:i,rpcOverrides:l},children:o})})};function h(o,t){const r=o.replace("#",""),e=Math.max(0,Math.round(parseInt(r.substring(0,2),16)*(1-t))),a=Math.max(0,Math.round(parseInt(r.substring(2,4),16)*(1-t))),s=Math.max(0,Math.round(parseInt(r.substring(4,6),16)*(1-t)));return`#${e.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`}function Y(o,t){return{shell:t?.shell??"#141414",shellBorder:t?.shellBorder??h(t?.shell??"#141414",.35),shellInnerBorder:t?.shellInnerBorder??h(t?.shell??"#141414",.55),cardBg:t?.cardBg??"#1e1e1e",inputBg:t?.inputBg??"#171717",hoverBg:t?.hoverBg??"#2a2a2a",textPrimary:t?.textPrimary??"#ffffff",textSecondary:t?.textSecondary??"#888888",inputText:t?.inputText??"#e0e0e0",inputPlaceholder:t?.inputPlaceholder??"#555555",cardBorder:t?.cardBorder??"rgba(255,255,255,0.08)",inputBorder:t?.inputBorder??"rgba(255,255,255,0.10)",buttonBorder:t?.buttonBorder??"rgba(255,255,255,0.12)",successBg:t?.successBg??"#0a1f18",successBorder:t?.successBorder??"#1a4a3a",successText:t?.successText??"#6ee7b7",warningBg:t?.warningBg??"#1f1a0d",warningBorder:t?.warningBorder??"#4a3820",warningText:t?.warningText??"#fbbf24",errorBg:t?.errorBg??"#1f0d0d",errorBorder:t?.errorBorder??"#4a2020",errorText:t?.errorText??"#f87171",infoBg:t?.infoBg??"#0d1325",infoBorder:t?.infoBorder??"#2a3a5a",infoText:t?.infoText??"#60a5fa"}}function J(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 b(o,t){const r=t?{...o,...t}:o,e=r.dark??!1,a=r.primaryColor,s=r.shell??(e?"#141414":"#ffffff");return{primaryColor:a,dark:e,fontFamily:r.fontFamily??'"Helvetica Neue", sans-serif',appName:r.appName??"Spicenet",logo:r.logo,borderRadius:r.borderRadius??"8px",shell:s,shellBorder:h(s,e?.35:.085),shellInnerBorder:h(s,e?.55:.165),card:r.card??(e?"#1e1e1e":"#f9fafb"),input:e?"#171717":"#ffffff",hover:e?"#2a2a2a":"#f3f4f6",text:r.text??(e?"#ffffff":"#111827"),textMuted:r.textMuted??(e?"#888888":"#6b7280"),inputText:e?"#e0e0e0":"#111827",inputPlaceholder:e?"#555555":"#9ca3af",border:r.border??(e?"rgba(255,255,255,0.08)":"#E0E0E0"),inputBorder:e?"rgba(255,255,255,0.10)":"#d1d5db",buttonBorder:e?"rgba(255,255,255,0.12)":"#0e0d0b",successBg:e?"#0a1f18":"#d1fae5",successBorder:e?"#1a4a3a":"#6ee7b7",successText:e?"#6ee7b7":"#065f46",warningBg:e?"#1f1a0d":"#fef3c7",warningBorder:e?"#4a3820":"#fcd34d",warningText:e?"#fbbf24":"#92400e",errorBg:e?"#1f0d0d":"#fee2e2",errorBorder:e?"#4a2020":"#fca5a5",errorText:e?"#f87171":"#dc2626",infoBg:e?"#0d1325":"#dbeafe",infoBorder:e?"#2a3a5a":"#93c5fd",infoText:e?"#60a5fa":"#1e40af"}}function H(o,t){const r=C(R)??void 0;return P(()=>{const e=r??{primaryColor:"#EA4B4B"},a={...o?.primaryColor?{primaryColor:o.primaryColor}:{},...o?.fontFamily?{fontFamily:o.fontFamily}:{},...t!==void 0?{dark:t}:{}},s=b(e,a),{dark:d,primaryColor:n,appName:i}=s,f=_(d?"dark":"light"),l={...f,colors:{...f.colors,primary:n,primaryHover:`${n}dd`},typography:{...f.typography,fontFamily:s.fontFamily}},u={shell:s.shell,shellBorder:s.shellBorder,shellInnerBorder:s.shellInnerBorder,cardBg:s.card,inputBg:s.input,hoverBg:s.hover,textPrimary:s.text,textSecondary:s.textMuted,inputText:s.inputText,inputPlaceholder:s.inputPlaceholder,cardBorder:s.border,inputBorder:s.inputBorder,buttonBorder:s.buttonBorder,successBg:s.successBg,successBorder:s.successBorder,successText:s.successText,warningBg:s.warningBg,warningBorder:s.warningBorder,warningText:s.warningText,errorBg:s.errorBg,errorBorder:s.errorBorder,errorText:s.errorText,infoBg:s.infoBg,infoBorder:s.infoBorder,infoText:s.infoText};return{brand:r,theme:l,dark:d,appName:i,primaryColor:n,dk:u,palette:u}},[r,o,t])}export{E as R,S,J as a,Y as b,L as c,c as d,M as e,b as f,j as i,p as r,H as u};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";const l=require("react"),y=require("react/jsx-runtime"),I=require("@spicenet-io/spiceflow-core"),w=require("./index-BEUnI98r.js"),P=require("./Button-B_UpyUH-.js");class c extends Error{constructor(t,r,e={}){super(r),this.code=t,this.context=e,this.name="SpiceflowError",Error.captureStackTrace&&Error.captureStackTrace(this,c)}}function U(o){return o instanceof c}const m=typeof process<"u"&&process.env?.NEXT_PUBLIC_RELAYER_API_URL||"https://tx-api-devserver.spicenet.io",E="__SPICEFLOW_RELAYER_API_URL__";function C(){if(typeof globalThis>"u")return;const o=globalThis[E];return typeof o=="string"&&o.length>0?o:void 0}class k{constructor(){this.baseUrl=m}setBaseUrl(t){this.baseUrl=t,typeof globalThis<"u"&&(globalThis[E]=t)}getBaseUrl(){return this.getEffectiveBaseUrl()}getEffectiveBaseUrl(){return C()||this.baseUrl}async createAction(t){console.log("[SpiceRelayer] createAction:start",{baseUrl:this.getEffectiveBaseUrl(),intentCount:t.intents.length,chainAuthorizationCount:t.chainAuthorizations?.length??0});const r=await fetch(`${this.getEffectiveBaseUrl()}/actions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t,(a,s)=>typeof s=="bigint"?s.toString():s)});if(!r.ok){const a=await r.text();throw console.log("[SpiceRelayer] createAction:error",{baseUrl:this.getEffectiveBaseUrl(),status:r.status,errorText:a}),new c("RELAYER_ERROR",`Relayer API error: ${r.status} - ${a}`,{httpStatus:r.status,responseBody:a,endpoint:"/actions"})}const e=await r.json();return console.log("[SpiceRelayer] createAction:success",{intentIds:e.intentIds}),e}async estimateActionFees(t){const r=await fetch(`${this.getEffectiveBaseUrl()}/actions/fees/estimate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t,(a,s)=>typeof s=="bigint"?s.toString():s)}),e=await r.json();if(!r.ok||!e.success||!e.data?.feeEstimate){const a=e.error?.message||`Relayer fee estimate error: ${r.status}`;throw new c("RELAYER_ERROR",a,{httpStatus:r.status,responseBody:JSON.stringify(e),endpoint:"/actions/fees/estimate"})}return e.data.feeEstimate}async estimateSpiceDepositFees(t){const r=await fetch(`${this.getEffectiveBaseUrl()}/spicedeposit/fees/estimate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t,(a,s)=>typeof s=="bigint"?s.toString():s)}),e=await r.json();if(!r.ok||!e.success||!e.data?.feeEstimate){const a=e.error?.message||`Deposit fee estimate error: ${r.status}`;throw new c("RELAYER_ERROR",a,{httpStatus:r.status,responseBody:JSON.stringify(e),endpoint:"/spicedeposit/fees/estimate"})}return e.data.feeEstimate}async executeStep(t,r,e,a){const s=`${this.getEffectiveBaseUrl()}/actions/${t}/intents/${r}/steps/${e}`,d=fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});let n;try{n=await Promise.race([d,new Promise((i,f)=>setTimeout(()=>f(new c("RELAYER_EXECUTE_ERROR",`Execute step request timed out after ${1e4/1e3}s`,{actionId:t,intentIndex:r,stepIndex:e,endpoint:`/actions/${t}/intents/${r}/steps/${e}`})),1e4))])}catch(i){throw i}if(!n.ok){const i=await n.text();throw new c("RELAYER_EXECUTE_ERROR",`Execute step error: ${n.status} - ${i}`,{httpStatus:n.status,responseBody:i,endpoint:`/actions/${t}/intents/${r}/steps/${e}`,actionId:t})}return{success:!0,transactionHash:(await n.json()).transactionHash}}async checkStepStatus(t,r){const e=t.split("/");let a="";if(e.length>=2){const n=e[0],i=e[1];a=`${this.getEffectiveBaseUrl()}/actions/${n}/intents/${i}/steps/${r}`}else a=`${this.getEffectiveBaseUrl()}/actions/${t}/intents/0/steps/${r}`;const s=await fetch(a);if(!s.ok)throw new c("RELAYER_STATUS_ERROR",`Intent step status check failed: ${s.status}`,{httpStatus:s.status,endpoint:a,intentId:t});const d=await s.json();return{success:!0,data:{status:d.status==="error"?"reverted":d.status,transactionHash:d.txid}}}async submitSpiceDeposit(t){const r=t.isDeposit?"deposit":"withdrawal";try{const e=await fetch(`${this.getEffectiveBaseUrl()}/spicedeposit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),a=await e.json();return!e.ok||!a.success?(console.error(`Failed to submit ${r} request to API:`,a.error?.message),{success:!1,error:a.error}):a}catch(e){return console.error(`Error submitting ${r} request to API:`,e),{success:!1,error:{message:e instanceof Error?e.message:"Unknown error"}}}}async requestSpiceUsdAirdrop(t){try{const r=await fetch(`${this.getEffectiveBaseUrl()}/airdrop/${t.chainId}/spiceUsd`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({wallet:t.address})}),e=await r.json().catch(()=>({}));if(!r.ok){const a=e&&(e.error||e.message)||"Failed to request airdrop";return{success:!1,errorMessage:String(a)}}return e&&typeof e.error=="string"?{success:!1,errorMessage:e.error}:e&&(e.txHash||e.amount)?{success:!0,txHash:e.txHash,amount:e.amount}:{success:!0}}catch(r){return{success:!1,errorMessage:r?.message&&typeof r.message=="string"?r.message:"Failed to request airdrop"}}}async requestAirdrop(t){try{const r=await fetch(`${this.getEffectiveBaseUrl()}/airdrop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tag:t.tag||"default",airdrops:[{chainId:t.chainId,tokenId:t.tokenId,wallet:t.wallet,amount:t.amount||"0.0001"}]})}),e=await r.json().catch(()=>({}));if(!r.ok){const s=e?.message||e?.errors?.[0]?.error||"Failed to request airdrop";return{success:!1,errorMessage:String(s)}}const a=e?.airdrops?.[t.chainId]?.[t.tokenId]?.txHash;return e.errors&&e.errors.length>0?{success:!1,errorMessage:e.errors[0].error}:{success:!0,txHash:a}}catch(r){return{success:!1,errorMessage:r?.message&&typeof r.message=="string"?r.message:"Failed to request airdrop"}}}async createWallet(t,r){const e=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!e.ok){const a=await e.text();throw new c("RELAYER_ERROR",`Create wallet error: ${e.status} - ${a}`,{httpStatus:e.status,endpoint:`/wallets/${t}`})}return e.json()}async getWallet(t){const r=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${t}`);if(!r.ok){const e=await r.text();throw new c("RELAYER_ERROR",`Get wallet error: ${r.status} - ${e}`,{httpStatus:r.status,endpoint:`/wallets/${t}`})}return r.json()}async createWithdrawal(t){const r=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t,(e,a)=>typeof a=="bigint"?a.toString():a)});if(!r.ok){const e=await r.text();throw new c("RELAYER_ERROR",`Create withdrawal error: ${r.status} - ${e}`,{httpStatus:r.status,endpoint:"/withdrawals"})}return r.json()}async getWithdrawal(t){const r=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals/${t}`);if(!r.ok){const e=await r.text();throw new c("RELAYER_ERROR",`Get withdrawal error: ${r.status} - ${e}`,{httpStatus:r.status,endpoint:`/withdrawals/${t}`})}return r.json()}async getRollupTimestamp(){const t=await fetch(`${this.getEffectiveBaseUrl()}/time`);if(!t.ok)throw new c("RELAYER_ERROR",`Get rollup timestamp error: ${t.status}`,{httpStatus:t.status,endpoint:"/time"});return t.json()}}const h=new k,O=(o,t)=>{const r=a=>t?t(a):w.getChainName(a),e=[];return o.forEach((a,s)=>{const d=a.calls&&a.calls.length>0,n=a.tokenTransfers&&a.tokenTransfers.length>0;if(d||n){const i={stepId:s,status:s===0?"processing":"pending",chainId:a.chainId,chainName:r(a.chainId),description:"Processing transaction"};e.push(i)}}),e},x=l.createContext(null),R=l.createContext(null),A=({children:o,provider:t,supportedChainIds:r,network:e="testnet",mode:a="7702",skipFlow:s=[],nativeChainId:d,appName:n="Spicenet",apiUrl:i,theme:f,rpcOverrides:u})=>{l.useEffect(()=>{if(!i)return;const B=h.getBaseUrl();return h.setBaseUrl(i),()=>h.setBaseUrl(B)},[i]),l.useEffect(()=>(w.setRpcOverrides(u),()=>w.setRpcOverrides(void 0)),[u]);const p=r??I.getChainIdsByNetwork(e),b=f??null,[T,$]=l.useState(a),v=l.useCallback(B=>$(B),[]);return y.jsx(x.Provider,{value:b,children:y.jsx(R.Provider,{value:{provider:t,supportedChainIds:p,skipFlow:s,mode:T,setMode:v,network:e,nativeChainId:d,appName:n,apiUrl:i,rpcOverrides:u},children:o})})};function g(o,t){const r=o.replace("#",""),e=Math.max(0,Math.round(parseInt(r.substring(0,2),16)*(1-t))),a=Math.max(0,Math.round(parseInt(r.substring(2,4),16)*(1-t))),s=Math.max(0,Math.round(parseInt(r.substring(4,6),16)*(1-t)));return`#${e.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`}function _(o,t){return{shell:t?.shell??"#141414",shellBorder:t?.shellBorder??g(t?.shell??"#141414",.35),shellInnerBorder:t?.shellInnerBorder??g(t?.shell??"#141414",.55),cardBg:t?.cardBg??"#1e1e1e",inputBg:t?.inputBg??"#171717",hoverBg:t?.hoverBg??"#2a2a2a",textPrimary:t?.textPrimary??"#ffffff",textSecondary:t?.textSecondary??"#888888",inputText:t?.inputText??"#e0e0e0",inputPlaceholder:t?.inputPlaceholder??"#555555",cardBorder:t?.cardBorder??"rgba(255,255,255,0.08)",inputBorder:t?.inputBorder??"rgba(255,255,255,0.10)",buttonBorder:t?.buttonBorder??"rgba(255,255,255,0.12)",successBg:t?.successBg??"#0a1f18",successBorder:t?.successBorder??"#1a4a3a",successText:t?.successText??"#6ee7b7",warningBg:t?.warningBg??"#1f1a0d",warningBorder:t?.warningBorder??"#4a3820",warningText:t?.warningText??"#fbbf24",errorBg:t?.errorBg??"#1f0d0d",errorBorder:t?.errorBorder??"#4a2020",errorText:t?.errorText??"#f87171",infoBg:t?.infoBg??"#0d1325",infoBorder:t?.infoBorder??"#2a3a5a",infoText:t?.infoText??"#60a5fa"}}function j(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 S(o,t){const r=t?{...o,...t}:o,e=r.dark??!1,a=r.primaryColor,s=r.shell??(e?"#141414":"#ffffff");return{primaryColor:a,dark:e,fontFamily:r.fontFamily??'"Helvetica Neue", sans-serif',appName:r.appName??"Spicenet",logo:r.logo,borderRadius:r.borderRadius??"8px",shell:s,shellBorder:g(s,e?.35:.085),shellInnerBorder:g(s,e?.55:.165),card:r.card??(e?"#1e1e1e":"#f9fafb"),input:e?"#171717":"#ffffff",hover:e?"#2a2a2a":"#f3f4f6",text:r.text??(e?"#ffffff":"#111827"),textMuted:r.textMuted??(e?"#888888":"#6b7280"),inputText:e?"#e0e0e0":"#111827",inputPlaceholder:e?"#555555":"#9ca3af",border:r.border??(e?"rgba(255,255,255,0.08)":"#E0E0E0"),inputBorder:e?"rgba(255,255,255,0.10)":"#d1d5db",buttonBorder:e?"rgba(255,255,255,0.12)":"#0e0d0b",successBg:e?"#0a1f18":"#d1fae5",successBorder:e?"#1a4a3a":"#6ee7b7",successText:e?"#6ee7b7":"#065f46",warningBg:e?"#1f1a0d":"#fef3c7",warningBorder:e?"#4a3820":"#fcd34d",warningText:e?"#fbbf24":"#92400e",errorBg:e?"#1f0d0d":"#fee2e2",errorBorder:e?"#4a2020":"#fca5a5",errorText:e?"#f87171":"#dc2626",infoBg:e?"#0d1325":"#dbeafe",infoBorder:e?"#2a3a5a":"#93c5fd",infoText:e?"#60a5fa":"#1e40af"}}function L(o,t){const r=l.useContext(x)??void 0;return l.useMemo(()=>{const e=r??{primaryColor:"#EA4B4B"},a={...o?.primaryColor?{primaryColor:o.primaryColor}:{},...o?.fontFamily?{fontFamily:o.fontFamily}:{},...t!==void 0?{dark:t}:{}},s=S(e,a),{dark:d,primaryColor:n,appName:i}=s,f=P.createTheme(d?"dark":"light"),u={...f,colors:{...f.colors,primary:n,primaryHover:`${n}dd`},typography:{...f.typography,fontFamily:s.fontFamily}},p={shell:s.shell,shellBorder:s.shellBorder,shellInnerBorder:s.shellInnerBorder,cardBg:s.card,inputBg:s.input,hoverBg:s.hover,textPrimary:s.text,textSecondary:s.textMuted,inputText:s.inputText,inputPlaceholder:s.inputPlaceholder,cardBorder:s.border,inputBorder:s.inputBorder,buttonBorder:s.buttonBorder,successBg:s.successBg,successBorder:s.successBorder,successText:s.successText,warningBg:s.warningBg,warningBorder:s.warningBorder,warningText:s.warningText,errorBg:s.errorBg,errorBorder:s.errorBorder,errorText:s.errorText,infoBg:s.infoBg,infoBorder:s.infoBorder,infoText:s.infoText};return{brand:r,theme:u,dark:d,appName:i,primaryColor:n,dk:p,palette:p}},[r,o,t])}exports.RELAYER_API_URL=m,exports.SpiceFlowProvider=A,exports.SpiceFlowProviderContext=R,exports.SpiceflowError=c,exports.buildDarkPalette=_,exports.buildLightPalette=j,exports.createInitialSteps=O,exports.isSpiceflowError=U,exports.relayerService=h,exports.resolveTheme=S,exports.useSpiceBrand=L;
|
|
@@ -3,5 +3,4 @@ export declare const formatUsd: (amount: number) => string;
|
|
|
3
3
|
export declare const truncateAddress: (address: string, startChars?: number, endChars?: number) => string;
|
|
4
4
|
export declare const formatTransactionHash: (hash: string) => string;
|
|
5
5
|
export declare const parseNumericInput: (value: string) => string;
|
|
6
|
-
export declare const formatDecimalInput: (value: number, decimals?: number) => string;
|
|
7
6
|
export declare const copyToClipboard: (text: string) => Promise<boolean>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CreateActionRequest, CreateActionResponse, EstimateActionFeesResponse, ExecuteStepRequest
|
|
1
|
+
import { CreateActionRequest, CreateActionResponse, EstimateActionFeesResponse, ExecuteStepRequest } from "../../types/unified";
|
|
2
|
+
import { SpiceDepositFeeEstimateRequest, SpiceDepositResponse } from "../../types/deposit";
|
|
2
3
|
import { SwapStep } from "../../types/status";
|
|
3
4
|
import { ChainBatch } from "../../types/authorization";
|
|
4
5
|
import { CreateWalletRequest, WalletInfo, CreateWithdrawalRequest, CreateWithdrawalResponse, WithdrawalStatus, RollupTimestamp } from "../../types/rollup";
|
|
5
6
|
export declare const RELAYER_API_URL: string;
|
|
6
|
-
export declare function hasReducedFeeOutput(feeEstimate: FeeEstimateSummary): boolean;
|
|
7
7
|
export declare class RelayerService {
|
|
8
8
|
private baseUrl;
|
|
9
9
|
constructor();
|
|
@@ -12,6 +12,7 @@ export declare class RelayerService {
|
|
|
12
12
|
private getEffectiveBaseUrl;
|
|
13
13
|
createAction(request: CreateActionRequest): Promise<CreateActionResponse>;
|
|
14
14
|
estimateActionFees(request: CreateActionRequest): Promise<NonNullable<EstimateActionFeesResponse["data"]>["feeEstimate"]>;
|
|
15
|
+
estimateSpiceDepositFees(request: SpiceDepositFeeEstimateRequest): Promise<NonNullable<EstimateActionFeesResponse["data"]>["feeEstimate"]>;
|
|
15
16
|
executeStep(actionId: string, intentIndex: number, stepIndex: number, request: ExecuteStepRequest): Promise<{
|
|
16
17
|
success: true;
|
|
17
18
|
transactionHash?: string;
|
|
@@ -23,6 +24,16 @@ export declare class RelayerService {
|
|
|
23
24
|
transactionHash?: string;
|
|
24
25
|
};
|
|
25
26
|
}>;
|
|
27
|
+
submitSpiceDeposit(request: {
|
|
28
|
+
user: string;
|
|
29
|
+
txHash: string;
|
|
30
|
+
sender: string;
|
|
31
|
+
tokenAddress: string;
|
|
32
|
+
chainId: number;
|
|
33
|
+
amount: string;
|
|
34
|
+
amountMode?: "gross_input" | "net_input";
|
|
35
|
+
isDeposit?: boolean;
|
|
36
|
+
}): Promise<SpiceDepositResponse>;
|
|
26
37
|
requestSpiceUsdAirdrop(params: {
|
|
27
38
|
chainId: number;
|
|
28
39
|
address: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spicenet-io/spiceflow-ui",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"description": "Spiceflow UI SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"author": "",
|
|
66
66
|
"license": "MIT",
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@spicenet-io/spiceflow-core": "^0.3.
|
|
68
|
+
"@spicenet-io/spiceflow-core": "^0.3.5",
|
|
69
69
|
"lucide-react": "^0.562.0",
|
|
70
70
|
"tslib": "^2.8.1"
|
|
71
71
|
},
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";const p=require("react"),b=require("react/jsx-runtime"),R=require("@spicenet-io/spiceflow-core"),g=require("./index-BEUnI98r.js"),T=require("viem"),U=require("./Button-B_UpyUH-.js");class d extends Error{constructor(e,r,t={}){super(r),this.code=e,this.context=t,this.name="SpiceflowError",Error.captureStackTrace&&Error.captureStackTrace(this,d)}}function O(o){return o instanceof d}const $=typeof process<"u"&&process.env?.NEXT_PUBLIC_RELAYER_API_URL||"https://tx-api-devserver.spicenet.io",v="__SPICEFLOW_RELAYER_API_URL__";function A(o,e){const r=e.match(/Output amount (\d+) is insufficient after fees (\d+) on chain (\d+)/);if(!r)return e;const[,t,a,s]=r,c=Number(s),n=BigInt(t),i=BigInt(a);let f;for(const u of o.intents){const S=u.chainBatches.find(P=>P.chainId===c);if(S){f=S;break}}const l=f?.tokenTransfers.find(u=>u.from==="solver"&&u.to.toLowerCase()===o.user.toLowerCase()&&!R.isNativeToken(u.token));if(!l)return`Amount is too small to cover the estimated fee on ${g.getChainName(c)}.`;const h=R.getTokenByAddress(l.token,c),B=h?.decimals??18,m=h?.symbol??"tokens",E=T.formatUnits(n,B),x=T.formatUnits(i,B);return`Amount is too small to cover the estimated fee on ${g.getChainName(c)}. Amount: ${E} ${m}. Estimated fee: ${x} ${m}.`}function _(o){return o.intents.some(e=>e.batches.some(r=>BigInt(r.netOutput)<BigInt(r.grossOutput)))}function L(){if(typeof globalThis>"u")return;const o=globalThis[v];return typeof o=="string"&&o.length>0?o:void 0}class N{constructor(){this.baseUrl=$}setBaseUrl(e){this.baseUrl=e,typeof globalThis<"u"&&(globalThis[v]=e)}getBaseUrl(){return this.getEffectiveBaseUrl()}getEffectiveBaseUrl(){return L()||this.baseUrl}async createAction(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/actions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(t,a)=>typeof a=="bigint"?a.toString():a)});if(!r.ok){const t=await r.text();throw new d("RELAYER_ERROR",`Relayer API error: ${r.status} - ${t}`,{httpStatus:r.status,responseBody:t,endpoint:"/actions"})}return await r.json()}async estimateActionFees(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/actions/fees/estimate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(a,s)=>typeof s=="bigint"?s.toString():s)}),t=await r.json();if(!r.ok||!t.success||!t.data?.feeEstimate){const a=t.error?.message||`Relayer fee estimate error: ${r.status}`,s=A(e,a);throw new d("RELAYER_ERROR",s,{httpStatus:r.status,responseBody:JSON.stringify(t),endpoint:"/actions/fees/estimate"})}return t.data.feeEstimate}async executeStep(e,r,t,a){const s=`${this.getEffectiveBaseUrl()}/actions/${e}/intents/${r}/steps/${t}`,c=fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});let n;try{n=await Promise.race([c,new Promise((i,f)=>setTimeout(()=>f(new d("RELAYER_EXECUTE_ERROR",`Execute step request timed out after ${1e4/1e3}s`,{actionId:e,intentIndex:r,stepIndex:t,endpoint:`/actions/${e}/intents/${r}/steps/${t}`})),1e4))])}catch(i){throw i}if(!n.ok){const i=await n.text();throw new d("RELAYER_EXECUTE_ERROR",`Execute step error: ${n.status} - ${i}`,{httpStatus:n.status,responseBody:i,endpoint:`/actions/${e}/intents/${r}/steps/${t}`,actionId:e})}return{success:!0,transactionHash:(await n.json()).transactionHash}}async checkStepStatus(e,r){const t=e.split("/");let a="";if(t.length>=2){const n=t[0],i=t[1];a=`${this.getEffectiveBaseUrl()}/actions/${n}/intents/${i}/steps/${r}`}else a=`${this.getEffectiveBaseUrl()}/actions/${e}/intents/0/steps/${r}`;const s=await fetch(a);if(!s.ok)throw new d("RELAYER_STATUS_ERROR",`Intent step status check failed: ${s.status}`,{httpStatus:s.status,endpoint:a,intentId:e});const c=await s.json();return{success:!0,data:{status:c.status==="error"?"reverted":c.status,transactionHash:c.txid}}}async requestSpiceUsdAirdrop(e){try{const r=await fetch(`${this.getEffectiveBaseUrl()}/airdrop/${e.chainId}/spiceUsd`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({wallet:e.address})}),t=await r.json().catch(()=>({}));if(!r.ok){const a=t&&(t.error||t.message)||"Failed to request airdrop";return{success:!1,errorMessage:String(a)}}return t&&typeof t.error=="string"?{success:!1,errorMessage:t.error}:t&&(t.txHash||t.amount)?{success:!0,txHash:t.txHash,amount:t.amount}:{success:!0}}catch(r){return{success:!1,errorMessage:r?.message&&typeof r.message=="string"?r.message:"Failed to request airdrop"}}}async requestAirdrop(e){try{const r=await fetch(`${this.getEffectiveBaseUrl()}/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"}]})}),t=await r.json().catch(()=>({}));if(!r.ok){const s=t?.message||t?.errors?.[0]?.error||"Failed to request airdrop";return{success:!1,errorMessage:String(s)}}const a=t?.airdrops?.[e.chainId]?.[e.tokenId]?.txHash;return t.errors&&t.errors.length>0?{success:!1,errorMessage:t.errors[0].error}:{success:!0,txHash:a}}catch(r){return{success:!1,errorMessage:r?.message&&typeof r.message=="string"?r.message:"Failed to request airdrop"}}}async createWallet(e,r){const t=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!t.ok){const a=await t.text();throw new d("RELAYER_ERROR",`Create wallet error: ${t.status} - ${a}`,{httpStatus:t.status,endpoint:`/wallets/${e}`})}return t.json()}async getWallet(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${e}`);if(!r.ok){const t=await r.text();throw new d("RELAYER_ERROR",`Get wallet error: ${r.status} - ${t}`,{httpStatus:r.status,endpoint:`/wallets/${e}`})}return r.json()}async createWithdrawal(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(t,a)=>typeof a=="bigint"?a.toString():a)});if(!r.ok){const t=await r.text();throw new d("RELAYER_ERROR",`Create withdrawal error: ${r.status} - ${t}`,{httpStatus:r.status,endpoint:"/withdrawals"})}return r.json()}async getWithdrawal(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals/${e}`);if(!r.ok){const t=await r.text();throw new d("RELAYER_ERROR",`Get withdrawal error: ${r.status} - ${t}`,{httpStatus:r.status,endpoint:`/withdrawals/${e}`})}return r.json()}async getRollupTimestamp(){const e=await fetch(`${this.getEffectiveBaseUrl()}/time`);if(!e.ok)throw new d("RELAYER_ERROR",`Get rollup timestamp error: ${e.status}`,{httpStatus:e.status,endpoint:"/time"});return e.json()}}const w=new N,F=(o,e)=>{const r=a=>e?e(a):g.getChainName(a),t=[];return o.forEach((a,s)=>{const c=a.calls&&a.calls.length>0,n=a.tokenTransfers&&a.tokenTransfers.length>0;if(c||n){const i={stepId:s,status:s===0?"processing":"pending",chainId:a.chainId,chainName:r(a.chainId),description:"Processing transaction"};t.push(i)}}),t},I=p.createContext(null),k=p.createContext(null),j=({children:o,provider:e,supportedChainIds:r,network:t="testnet",mode:a="7702",skipFlow:s=[],nativeChainId:c,appName:n="Spicenet",apiUrl:i,theme:f,rpcOverrides:l})=>{p.useEffect(()=>{if(!i)return;const u=w.getBaseUrl();return w.setBaseUrl(i),()=>w.setBaseUrl(u)},[i]),p.useEffect(()=>(g.setRpcOverrides(l),()=>g.setRpcOverrides(void 0)),[l]);const h=r??R.getChainIdsByNetwork(t),B=f??null,[m,E]=p.useState(a),x=p.useCallback(u=>E(u),[]);return b.jsx(I.Provider,{value:B,children:b.jsx(k.Provider,{value:{provider:e,supportedChainIds:h,skipFlow:s,mode:m,setMode:x,network:t,nativeChainId:c,appName:n,apiUrl:i,rpcOverrides:l},children:o})})};function y(o,e){const r=o.replace("#",""),t=Math.max(0,Math.round(parseInt(r.substring(0,2),16)*(1-e))),a=Math.max(0,Math.round(parseInt(r.substring(2,4),16)*(1-e))),s=Math.max(0,Math.round(parseInt(r.substring(4,6),16)*(1-e)));return`#${t.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`}function M(o,e){return{shell:e?.shell??"#141414",shellBorder:e?.shellBorder??y(e?.shell??"#141414",.35),shellInnerBorder:e?.shellInnerBorder??y(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 Y(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 C(o,e){const r=e?{...o,...e}:o,t=r.dark??!1,a=r.primaryColor,s=r.shell??(t?"#141414":"#ffffff");return{primaryColor:a,dark:t,fontFamily:r.fontFamily??'"Helvetica Neue", sans-serif',appName:r.appName??"Spicenet",logo:r.logo,borderRadius:r.borderRadius??"8px",shell:s,shellBorder:y(s,t?.35:.085),shellInnerBorder:y(s,t?.55:.165),card:r.card??(t?"#1e1e1e":"#f9fafb"),input:t?"#171717":"#ffffff",hover:t?"#2a2a2a":"#f3f4f6",text:r.text??(t?"#ffffff":"#111827"),textMuted:r.textMuted??(t?"#888888":"#6b7280"),inputText:t?"#e0e0e0":"#111827",inputPlaceholder:t?"#555555":"#9ca3af",border:r.border??(t?"rgba(255,255,255,0.08)":"#E0E0E0"),inputBorder:t?"rgba(255,255,255,0.10)":"#d1d5db",buttonBorder:t?"rgba(255,255,255,0.12)":"#0e0d0b",successBg:t?"#0a1f18":"#d1fae5",successBorder:t?"#1a4a3a":"#6ee7b7",successText:t?"#6ee7b7":"#065f46",warningBg:t?"#1f1a0d":"#fef3c7",warningBorder:t?"#4a3820":"#fcd34d",warningText:t?"#fbbf24":"#92400e",errorBg:t?"#1f0d0d":"#fee2e2",errorBorder:t?"#4a2020":"#fca5a5",errorText:t?"#f87171":"#dc2626",infoBg:t?"#0d1325":"#dbeafe",infoBorder:t?"#2a3a5a":"#93c5fd",infoText:t?"#60a5fa":"#1e40af"}}function q(o,e){const r=p.useContext(I)??void 0;return p.useMemo(()=>{const t=r??{primaryColor:"#EA4B4B"},a={...o?.primaryColor?{primaryColor:o.primaryColor}:{},...o?.fontFamily?{fontFamily:o.fontFamily}:{},...e!==void 0?{dark:e}:{}},s=C(t,a),{dark:c,primaryColor:n,appName:i}=s,f=U.createTheme(c?"dark":"light"),l={...f,colors:{...f.colors,primary:n,primaryHover:`${n}dd`},typography:{...f.typography,fontFamily:s.fontFamily}},h={shell:s.shell,shellBorder:s.shellBorder,shellInnerBorder:s.shellInnerBorder,cardBg:s.card,inputBg:s.input,hoverBg:s.hover,textPrimary:s.text,textSecondary:s.textMuted,inputText:s.inputText,inputPlaceholder:s.inputPlaceholder,cardBorder:s.border,inputBorder:s.inputBorder,buttonBorder:s.buttonBorder,successBg:s.successBg,successBorder:s.successBorder,successText:s.successText,warningBg:s.warningBg,warningBorder:s.warningBorder,warningText:s.warningText,errorBg:s.errorBg,errorBorder:s.errorBorder,errorText:s.errorText,infoBg:s.infoBg,infoBorder:s.infoBorder,infoText:s.infoText};return{brand:r,theme:l,dark:c,appName:i,primaryColor:n,dk:h,palette:h}},[r,o,e])}exports.RELAYER_API_URL=$,exports.SpiceFlowProvider=j,exports.SpiceFlowProviderContext=k,exports.SpiceflowError=d,exports.buildDarkPalette=M,exports.buildLightPalette=Y,exports.createInitialSteps=F,exports.hasReducedFeeOutput=_,exports.isSpiceflowError=O,exports.relayerService=w,exports.resolveTheme=C,exports.useSpiceBrand=q;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import{createContext as R,useEffect as b,useState as O,useCallback as A,useContext as _,useMemo as L}from"react";import{jsx as T}from"react/jsx-runtime";import{isNativeToken as N,getTokenByAddress as j,getChainIdsByNetwork as F}from"@spicenet-io/spiceflow-core";import{a as E,s as S}from"./index-Bv5PiWia.js";import{formatUnits as $}from"viem";import{c as M}from"./Button-CaguAr48.js";class d extends Error{constructor(e,r,t={}){super(r),this.code=e,this.context=t,this.name="SpiceflowError",Error.captureStackTrace&&Error.captureStackTrace(this,d)}}function Y(o){return o instanceof d}const v=typeof process<"u"&&process.env?.NEXT_PUBLIC_RELAYER_API_URL||"https://tx-api-devserver.spicenet.io",I="__SPICEFLOW_RELAYER_API_URL__";function H(o,e){const r=e.match(/Output amount (\d+) is insufficient after fees (\d+) on chain (\d+)/);if(!r)return e;const[,t,a,s]=r,c=Number(s),n=BigInt(t),i=BigInt(a);let f;for(const u of o.intents){const x=u.chainBatches.find(P=>P.chainId===c);if(x){f=x;break}}const l=f?.tokenTransfers.find(u=>u.from==="solver"&&u.to.toLowerCase()===o.user.toLowerCase()&&!N(u.token));if(!l)return`Amount is too small to cover the estimated fee on ${E(c)}.`;const p=j(l.token,c),h=p?.decimals??18,g=p?.symbol??"tokens",w=$(n,h),y=$(i,h);return`Amount is too small to cover the estimated fee on ${E(c)}. Amount: ${w} ${g}. Estimated fee: ${y} ${g}.`}function J(o){return o.intents.some(e=>e.batches.some(r=>BigInt(r.netOutput)<BigInt(r.grossOutput)))}function q(){if(typeof globalThis>"u")return;const o=globalThis[I];return typeof o=="string"&&o.length>0?o:void 0}class W{constructor(){this.baseUrl=v}setBaseUrl(e){this.baseUrl=e,typeof globalThis<"u"&&(globalThis[I]=e)}getBaseUrl(){return this.getEffectiveBaseUrl()}getEffectiveBaseUrl(){return q()||this.baseUrl}async createAction(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/actions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(t,a)=>typeof a=="bigint"?a.toString():a)});if(!r.ok){const t=await r.text();throw new d("RELAYER_ERROR",`Relayer API error: ${r.status} - ${t}`,{httpStatus:r.status,responseBody:t,endpoint:"/actions"})}return await r.json()}async estimateActionFees(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/actions/fees/estimate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(a,s)=>typeof s=="bigint"?s.toString():s)}),t=await r.json();if(!r.ok||!t.success||!t.data?.feeEstimate){const a=t.error?.message||`Relayer fee estimate error: ${r.status}`,s=H(e,a);throw new d("RELAYER_ERROR",s,{httpStatus:r.status,responseBody:JSON.stringify(t),endpoint:"/actions/fees/estimate"})}return t.data.feeEstimate}async executeStep(e,r,t,a){const s=`${this.getEffectiveBaseUrl()}/actions/${e}/intents/${r}/steps/${t}`,c=fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});let n;try{n=await Promise.race([c,new Promise((i,f)=>setTimeout(()=>f(new d("RELAYER_EXECUTE_ERROR",`Execute step request timed out after ${1e4/1e3}s`,{actionId:e,intentIndex:r,stepIndex:t,endpoint:`/actions/${e}/intents/${r}/steps/${t}`})),1e4))])}catch(i){throw i}if(!n.ok){const i=await n.text();throw new d("RELAYER_EXECUTE_ERROR",`Execute step error: ${n.status} - ${i}`,{httpStatus:n.status,responseBody:i,endpoint:`/actions/${e}/intents/${r}/steps/${t}`,actionId:e})}return{success:!0,transactionHash:(await n.json()).transactionHash}}async checkStepStatus(e,r){const t=e.split("/");let a="";if(t.length>=2){const n=t[0],i=t[1];a=`${this.getEffectiveBaseUrl()}/actions/${n}/intents/${i}/steps/${r}`}else a=`${this.getEffectiveBaseUrl()}/actions/${e}/intents/0/steps/${r}`;const s=await fetch(a);if(!s.ok)throw new d("RELAYER_STATUS_ERROR",`Intent step status check failed: ${s.status}`,{httpStatus:s.status,endpoint:a,intentId:e});const c=await s.json();return{success:!0,data:{status:c.status==="error"?"reverted":c.status,transactionHash:c.txid}}}async requestSpiceUsdAirdrop(e){try{const r=await fetch(`${this.getEffectiveBaseUrl()}/airdrop/${e.chainId}/spiceUsd`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({wallet:e.address})}),t=await r.json().catch(()=>({}));if(!r.ok){const a=t&&(t.error||t.message)||"Failed to request airdrop";return{success:!1,errorMessage:String(a)}}return t&&typeof t.error=="string"?{success:!1,errorMessage:t.error}:t&&(t.txHash||t.amount)?{success:!0,txHash:t.txHash,amount:t.amount}:{success:!0}}catch(r){return{success:!1,errorMessage:r?.message&&typeof r.message=="string"?r.message:"Failed to request airdrop"}}}async requestAirdrop(e){try{const r=await fetch(`${this.getEffectiveBaseUrl()}/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"}]})}),t=await r.json().catch(()=>({}));if(!r.ok){const s=t?.message||t?.errors?.[0]?.error||"Failed to request airdrop";return{success:!1,errorMessage:String(s)}}const a=t?.airdrops?.[e.chainId]?.[e.tokenId]?.txHash;return t.errors&&t.errors.length>0?{success:!1,errorMessage:t.errors[0].error}:{success:!0,txHash:a}}catch(r){return{success:!1,errorMessage:r?.message&&typeof r.message=="string"?r.message:"Failed to request airdrop"}}}async createWallet(e,r){const t=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!t.ok){const a=await t.text();throw new d("RELAYER_ERROR",`Create wallet error: ${t.status} - ${a}`,{httpStatus:t.status,endpoint:`/wallets/${e}`})}return t.json()}async getWallet(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${e}`);if(!r.ok){const t=await r.text();throw new d("RELAYER_ERROR",`Get wallet error: ${r.status} - ${t}`,{httpStatus:r.status,endpoint:`/wallets/${e}`})}return r.json()}async createWithdrawal(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(t,a)=>typeof a=="bigint"?a.toString():a)});if(!r.ok){const t=await r.text();throw new d("RELAYER_ERROR",`Create withdrawal error: ${r.status} - ${t}`,{httpStatus:r.status,endpoint:"/withdrawals"})}return r.json()}async getWithdrawal(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals/${e}`);if(!r.ok){const t=await r.text();throw new d("RELAYER_ERROR",`Get withdrawal error: ${r.status} - ${t}`,{httpStatus:r.status,endpoint:`/withdrawals/${e}`})}return r.json()}async getRollupTimestamp(){const e=await fetch(`${this.getEffectiveBaseUrl()}/time`);if(!e.ok)throw new d("RELAYER_ERROR",`Get rollup timestamp error: ${e.status}`,{httpStatus:e.status,endpoint:"/time"});return e.json()}}const B=new W,D=(o,e)=>{const r=a=>e?e(a):E(a),t=[];return o.forEach((a,s)=>{const c=a.calls&&a.calls.length>0,n=a.tokenTransfers&&a.tokenTransfers.length>0;if(c||n){const i={stepId:s,status:s===0?"processing":"pending",chainId:a.chainId,chainName:r(a.chainId),description:"Processing transaction"};t.push(i)}}),t},k=R(null),U=R(null),G=({children:o,provider:e,supportedChainIds:r,network:t="testnet",mode:a="7702",skipFlow:s=[],nativeChainId:c,appName:n="Spicenet",apiUrl:i,theme:f,rpcOverrides:l})=>{b(()=>{if(!i)return;const u=B.getBaseUrl();return B.setBaseUrl(i),()=>B.setBaseUrl(u)},[i]),b(()=>(S(l),()=>S(void 0)),[l]);const p=r??F(t),h=f??null,[g,w]=O(a),y=A(u=>w(u),[]);return T(k.Provider,{value:h,children:T(U.Provider,{value:{provider:e,supportedChainIds:p,skipFlow:s,mode:g,setMode:y,network:t,nativeChainId:c,appName:n,apiUrl:i,rpcOverrides:l},children:o})})};function m(o,e){const r=o.replace("#",""),t=Math.max(0,Math.round(parseInt(r.substring(0,2),16)*(1-e))),a=Math.max(0,Math.round(parseInt(r.substring(2,4),16)*(1-e))),s=Math.max(0,Math.round(parseInt(r.substring(4,6),16)*(1-e)));return`#${t.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`}function X(o,e){return{shell:e?.shell??"#141414",shellBorder:e?.shellBorder??m(e?.shell??"#141414",.35),shellInnerBorder:e?.shellInnerBorder??m(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 z(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 C(o,e){const r=e?{...o,...e}:o,t=r.dark??!1,a=r.primaryColor,s=r.shell??(t?"#141414":"#ffffff");return{primaryColor:a,dark:t,fontFamily:r.fontFamily??'"Helvetica Neue", sans-serif',appName:r.appName??"Spicenet",logo:r.logo,borderRadius:r.borderRadius??"8px",shell:s,shellBorder:m(s,t?.35:.085),shellInnerBorder:m(s,t?.55:.165),card:r.card??(t?"#1e1e1e":"#f9fafb"),input:t?"#171717":"#ffffff",hover:t?"#2a2a2a":"#f3f4f6",text:r.text??(t?"#ffffff":"#111827"),textMuted:r.textMuted??(t?"#888888":"#6b7280"),inputText:t?"#e0e0e0":"#111827",inputPlaceholder:t?"#555555":"#9ca3af",border:r.border??(t?"rgba(255,255,255,0.08)":"#E0E0E0"),inputBorder:t?"rgba(255,255,255,0.10)":"#d1d5db",buttonBorder:t?"rgba(255,255,255,0.12)":"#0e0d0b",successBg:t?"#0a1f18":"#d1fae5",successBorder:t?"#1a4a3a":"#6ee7b7",successText:t?"#6ee7b7":"#065f46",warningBg:t?"#1f1a0d":"#fef3c7",warningBorder:t?"#4a3820":"#fcd34d",warningText:t?"#fbbf24":"#92400e",errorBg:t?"#1f0d0d":"#fee2e2",errorBorder:t?"#4a2020":"#fca5a5",errorText:t?"#f87171":"#dc2626",infoBg:t?"#0d1325":"#dbeafe",infoBorder:t?"#2a3a5a":"#93c5fd",infoText:t?"#60a5fa":"#1e40af"}}function K(o,e){const r=_(k)??void 0;return L(()=>{const t=r??{primaryColor:"#EA4B4B"},a={...o?.primaryColor?{primaryColor:o.primaryColor}:{},...o?.fontFamily?{fontFamily:o.fontFamily}:{},...e!==void 0?{dark:e}:{}},s=C(t,a),{dark:c,primaryColor:n,appName:i}=s,f=M(c?"dark":"light"),l={...f,colors:{...f.colors,primary:n,primaryHover:`${n}dd`},typography:{...f.typography,fontFamily:s.fontFamily}},p={shell:s.shell,shellBorder:s.shellBorder,shellInnerBorder:s.shellInnerBorder,cardBg:s.card,inputBg:s.input,hoverBg:s.hover,textPrimary:s.text,textSecondary:s.textMuted,inputText:s.inputText,inputPlaceholder:s.inputPlaceholder,cardBorder:s.border,inputBorder:s.inputBorder,buttonBorder:s.buttonBorder,successBg:s.successBg,successBorder:s.successBorder,successText:s.successText,warningBg:s.warningBg,warningBorder:s.warningBorder,warningText:s.warningText,errorBg:s.errorBg,errorBorder:s.errorBorder,errorText:s.errorText,infoBg:s.infoBg,infoBorder:s.infoBorder,infoText:s.infoText};return{brand:r,theme:l,dark:c,appName:i,primaryColor:n,dk:p,palette:p}},[r,o,e])}export{v as R,U as S,z as a,X as b,D as c,d,G as e,C as f,J as h,Y as i,B as r,K as u};
|
|
File without changes
|
|
File without changes
|