@spicenet-io/spiceflow-ui 3.3.9 → 3.3.10

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.
Files changed (72) hide show
  1. package/dist/Button-CIf9le-W.js +2 -0
  2. package/dist/Button-CWv90szi.js +2 -0
  3. package/dist/auth-dynamic.cjs.js +1 -1
  4. package/dist/auth-dynamic.js +1 -1
  5. package/dist/auth-privy.cjs.js +1 -1
  6. package/dist/auth-privy.js +1 -1
  7. package/dist/components/AccountDisplay/{AccountCustomSection.d.ts → parts/AccountCustomSection.d.ts} +2 -2
  8. package/dist/components/AccountDisplay/{AccountHeader.d.ts → parts/AccountHeader.d.ts} +1 -1
  9. package/dist/components/AccountDisplay/{AccountIdleBalances.d.ts → parts/AccountIdleBalances.d.ts} +2 -2
  10. package/dist/components/AccountDisplay/{AccountPanel.d.ts → parts/AccountPanel.d.ts} +3 -3
  11. package/dist/components/AccountDisplay/{AccountPendingDeposits.d.ts → parts/AccountPendingDeposits.d.ts} +2 -2
  12. package/dist/components/AssetSelector/index.d.ts +3 -3
  13. package/dist/components/AssetSelector/{AssetDropdown.d.ts → parts/AssetDropdown.d.ts} +1 -1
  14. package/dist/components/AssetSelector/{ChainIcon.d.ts → parts/ChainIcon.d.ts} +1 -1
  15. package/dist/components/AssetSelector/{TokenIcon.d.ts → parts/TokenIcon.d.ts} +1 -1
  16. package/dist/components/ProviderLogins/index.d.ts +4 -2
  17. package/dist/components/ProviderLogins/{DynamicLogin.d.ts → parts/DynamicLogin.d.ts} +1 -1
  18. package/dist/components/ProviderLogins/{PrivyLogin.d.ts → parts/PrivyLogin.d.ts} +1 -1
  19. package/dist/components/SpiceBalance/index.d.ts +2 -2
  20. package/dist/components/SpiceDeposit/index.d.ts +3 -3
  21. package/dist/components/SpiceDeposit/{depositBatches.d.ts → lib/depositBatches.d.ts} +3 -3
  22. package/dist/components/SpiceDeposit/{executors.d.ts → lib/executors.d.ts} +3 -3
  23. package/dist/components/SpiceDeposit/{feePreview.d.ts → lib/feePreview.d.ts} +1 -1
  24. package/dist/components/SpiceDeposit/{ConnectWalletModal.d.ts → steps/ConnectWalletModal.d.ts} +1 -1
  25. package/dist/components/SpiceDeposit/{DepositModal.d.ts → steps/DepositModal.d.ts} +1 -1
  26. package/dist/components/SpiceDeposit/{DepositRecoveryPrompt.d.ts → steps/DepositRecoveryPrompt.d.ts} +1 -1
  27. package/dist/components/SpiceDeposit/{DepositStatusModal.d.ts → steps/DepositStatusModal.d.ts} +3 -3
  28. package/dist/components/SpiceDeposit/{SelectChainModal.d.ts → steps/SelectChainModal.d.ts} +1 -1
  29. package/dist/components/SpiceDeposit/{SelectTokenModal.d.ts → steps/SelectTokenModal.d.ts} +1 -1
  30. package/dist/components/SpiceLock/{executors.d.ts → lib/executors.d.ts} +13 -14
  31. package/dist/components/SpiceLock/{helpers.d.ts → lib/helpers.d.ts} +2 -2
  32. package/dist/components/SpiceLock/{LockConfirmationPanel.d.ts → parts/LockConfirmationPanel.d.ts} +1 -1
  33. package/dist/components/SpiceLock/{LockDurationSlider.d.ts → parts/LockDurationSlider.d.ts} +1 -1
  34. package/dist/components/SpiceLock/{LockExpiryRow.d.ts → parts/LockExpiryRow.d.ts} +1 -1
  35. package/dist/components/SpiceLock/{VotingPowerRow.d.ts → parts/VotingPowerRow.d.ts} +1 -1
  36. package/dist/components/SpiceSupply/{buildBatches.d.ts → lib/buildBatches.d.ts} +12 -11
  37. package/dist/components/SpiceSupply/lib/executors.d.ts +71 -0
  38. package/dist/components/SpiceSupply/{feePreview.d.ts → lib/feePreview.d.ts} +13 -12
  39. package/dist/components/SpiceSupply/{DestinationEstimate.d.ts → parts/DestinationEstimate.d.ts} +2 -2
  40. package/dist/components/SpiceSupply/{SupplyEstimate.d.ts → parts/SupplyEstimate.d.ts} +1 -1
  41. package/dist/components/SpiceWithdraw/lib/executors.d.ts +34 -0
  42. package/dist/components/SpiceWithdraw/{SelectPopover.d.ts → parts/SelectPopover.d.ts} +1 -1
  43. package/dist/components/StatusDisplay/index.d.ts +3 -2
  44. package/dist/components/StatusDisplay/{StatusIcon.d.ts → parts/StatusIcon.d.ts} +1 -1
  45. package/dist/components/StatusDisplay/{StatusPanel.d.ts → parts/StatusPanel.d.ts} +1 -1
  46. package/dist/components/StatusDisplay/{StepItem.d.ts → parts/StepItem.d.ts} +1 -1
  47. package/dist/execution/gasless.d.ts +7 -0
  48. package/dist/execution/pollIntentStep.d.ts +29 -0
  49. package/dist/hooks/useSpiceExecution.d.ts +1 -0
  50. package/dist/index.cjs.js +12 -12
  51. package/dist/index.d.ts +2 -1
  52. package/dist/index.js +16 -16
  53. package/dist/{providerWallet-Ds1PM0vC.js → providerWallet-Cv_GlhF1.js} +1 -1
  54. package/dist/{providerWallet-6FpyLYqw.js → providerWallet-IDnLJm9s.js} +1 -1
  55. package/dist/providers/dynamic.d.ts +2 -2
  56. package/dist/providers/privy.d.ts +2 -2
  57. package/dist/types/supply.d.ts +15 -0
  58. package/dist/utils/spiceConstants.d.ts +3 -0
  59. package/package.json +2 -2
  60. package/dist/Button-CkSwrat1.js +0 -2
  61. package/dist/Button-jx5yrM-s.js +0 -2
  62. package/dist/components/SpiceDeposit/views/DepositSubtitle.d.ts +0 -9
  63. package/dist/components/SpiceSupply/executors.d.ts +0 -73
  64. package/dist/components/SpiceWithdraw/executors.d.ts +0 -50
  65. /package/dist/components/AccountDisplay/{AccountActions.d.ts → parts/AccountActions.d.ts} +0 -0
  66. /package/dist/components/SpiceBalance/{AccountItem.d.ts → parts/AccountItem.d.ts} +0 -0
  67. /package/dist/components/SpiceBalance/{BalanceSection.d.ts → parts/BalanceSection.d.ts} +0 -0
  68. /package/dist/components/SpiceDeposit/{views/AssetChooserList.d.ts → parts/DepositAssetChooser.d.ts} +0 -0
  69. /package/dist/components/SpiceDeposit/{ModalHeader.d.ts → parts/ModalHeader.d.ts} +0 -0
  70. /package/dist/components/SpiceWithdraw/{helpers.d.ts → lib/helpers.d.ts} +0 -0
  71. /package/dist/components/SpiceWithdraw/{views/BalancePopover.d.ts → parts/WithdrawBalancePopover.d.ts} +0 -0
  72. /package/dist/components/SpiceWithdraw/{views → parts}/WithdrawDetailsPanel.d.ts +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"./Button-jx5yrM-s.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};
2
+ import{createWalletClient as l,custom as d}from"viem";import{g as c}from"./Button-CIf9le-W.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};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";const o=require("viem"),c=require("./Button-CkSwrat1.js"),a=e=>{if(!e)return!1;const t=e.connector;if(!t)return!1;if(t.isEmbeddedWallet===!0)return!0;const r=(t.key||t.connectorKey||"").toLowerCase();if(r.includes("embedded")||r.includes("turnkey"))return!0;const n=(t.name||e.walletName||"").toLowerCase();return!!(n.includes("embedded")||n.includes("turnkey"))},s=e=>(e?.connectedWallets||[]).find(t=>a(t))||(a(e?.primaryWallet)?e.primaryWallet:null),u=e=>(e?.connectedWallets||[]).find(t=>t?.address&&t?.connector&&!a(t))||null,l=async(e,t)=>{if(!e?.address)throw new Error("Wallet not available");if(typeof e.getWalletClient=="function"){const r=t===void 0?[void 0]:[String(t),t,void 0];let n=null;for(const d of r)try{const i=await e.getWalletClient(d);if(i)return i}catch(i){n=i}if(n)throw n}if(typeof e.getEthereumProvider=="function"){const r=await e.getEthereumProvider(),n=t?c.getChainConfig(t)?.viemChain:void 0;return o.createWalletClient({account:e.address,chain:n,transport:o.custom(r)})}throw new Error("Wallet client not available")},m=async(e,t)=>{if(!e?.address)throw new Error("Wallet not available");if(typeof e.getEthereumProvider=="function")return e.getEthereumProvider();const r=await l(e,t);return{request:n=>r.request(n)}},f=(e,t)=>({address:e?.address||t.address,chainId:Number(e?.chainId??t.chainId),contractAddress:e?.contractAddress||e?.delegate||t.contractAddress,nonce:BigInt(e?.nonce??t.nonce),r:e?.r,s:e?.s,yParity:(()=>{if(typeof e?.yParity=="number")return e.yParity;const r=Number(e?.v??27);return Number.isFinite(r)?r>=27?r-27:r:0})()});exports.getDynamicEmbeddedWallet=s,exports.getDynamicExternalWallet=u,exports.getProviderEthereumProvider=m,exports.getProviderWalletClient=l,exports.normalizeAuthorization=f;
2
+ "use strict";const o=require("viem"),c=require("./Button-CWv90szi.js"),a=e=>{if(!e)return!1;const t=e.connector;if(!t)return!1;if(t.isEmbeddedWallet===!0)return!0;const r=(t.key||t.connectorKey||"").toLowerCase();if(r.includes("embedded")||r.includes("turnkey"))return!0;const n=(t.name||e.walletName||"").toLowerCase();return!!(n.includes("embedded")||n.includes("turnkey"))},s=e=>(e?.connectedWallets||[]).find(t=>a(t))||(a(e?.primaryWallet)?e.primaryWallet:null),u=e=>(e?.connectedWallets||[]).find(t=>t?.address&&t?.connector&&!a(t))||null,l=async(e,t)=>{if(!e?.address)throw new Error("Wallet not available");if(typeof e.getWalletClient=="function"){const r=t===void 0?[void 0]:[String(t),t,void 0];let n=null;for(const d of r)try{const i=await e.getWalletClient(d);if(i)return i}catch(i){n=i}if(n)throw n}if(typeof e.getEthereumProvider=="function"){const r=await e.getEthereumProvider(),n=t?c.getChainConfig(t)?.viemChain:void 0;return o.createWalletClient({account:e.address,chain:n,transport:o.custom(r)})}throw new Error("Wallet client not available")},m=async(e,t)=>{if(!e?.address)throw new Error("Wallet not available");if(typeof e.getEthereumProvider=="function")return e.getEthereumProvider();const r=await l(e,t);return{request:n=>r.request(n)}},f=(e,t)=>({address:e?.address||t.address,chainId:Number(e?.chainId??t.chainId),contractAddress:e?.contractAddress||e?.delegate||t.contractAddress,nonce:BigInt(e?.nonce??t.nonce),r:e?.r,s:e?.s,yParity:(()=>{if(typeof e?.yParity=="number")return e.yParity;const r=Number(e?.v??27);return Number.isFinite(r)?r>=27?r-27:r:0})()});exports.getDynamicEmbeddedWallet=s,exports.getDynamicExternalWallet=u,exports.getProviderEthereumProvider=m,exports.getProviderWalletClient=l,exports.normalizeAuthorization=f;
@@ -1,3 +1,3 @@
1
1
  import "../globals.css";
2
- export { DynamicLogin } from "../components/ProviderLogins/DynamicLogin";
3
- export type { DynamicLoginProps } from "../components/ProviderLogins/DynamicLogin";
2
+ export { DynamicLogin } from "../components/ProviderLogins";
3
+ export type { DynamicLoginProps } from "../components/ProviderLogins";
@@ -1,3 +1,3 @@
1
1
  import "../globals.css";
2
- export { PrivyLogin } from "../components/ProviderLogins/PrivyLogin";
3
- export type { PrivyLoginProps } from "../components/ProviderLogins/PrivyLogin";
2
+ export { PrivyLogin } from "../components/ProviderLogins";
3
+ export type { PrivyLoginProps } from "../components/ProviderLogins";
@@ -14,6 +14,20 @@ export interface BuildActionCallsContext {
14
14
  userAddress: Address;
15
15
  chainId: number;
16
16
  destinationToken: Address;
17
+ grossAmount?: bigint;
18
+ netAmount?: bigint;
19
+ combinedFeeAmount?: bigint;
20
+ feeExecutionMode?: "backend-transfer" | "user-transfer";
21
+ feeBreakdown?: {
22
+ spicenetFee: bigint;
23
+ gasFee: bigint;
24
+ bridgeFee: bigint;
25
+ };
26
+ }
27
+ export interface SupplyBatchBuildOptions {
28
+ actionAmountOverride?: bigint;
29
+ fundingAmountOverride?: bigint;
30
+ actionContextOverride?: Partial<BuildActionCallsContext>;
17
31
  }
18
32
  export interface PayExecuteContext {
19
33
  asset: Asset;
@@ -32,6 +46,7 @@ export interface SpiceSupplyProps {
32
46
  onClose: () => void;
33
47
  destinationToken: DestinationTokenConfig;
34
48
  buildActionCalls: (amount: bigint, ctx: BuildActionCallsContext) => Call[];
49
+ feeExecutionMode?: "backend-transfer" | "user-transfer";
35
50
  buildSpicenetBatch?: (params: {
36
51
  userAddress: Address;
37
52
  destinationChainId: number;
@@ -0,0 +1,3 @@
1
+ import type { Address } from "viem";
2
+ export declare const SPICE_SOLVER_ADDRESS: Address;
3
+ export declare const SPICE_COMBINED_FEE_RECIPIENT: `0x${string}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spicenet-io/spiceflow-ui",
3
- "version": "3.3.9",
3
+ "version": "3.3.10",
4
4
  "description": "Spiceflow UI SDK",
5
5
  "type": "module",
6
6
  "packageManager": "bun@1.3.13",
@@ -42,7 +42,7 @@
42
42
  "dev": "rollup -c rollup.config.mjs --watch",
43
43
  "dev:link": "bun run build && bun link && echo 'SDK linked globally. Run: bun link @spicenet-io/spiceflow-ui in your project'",
44
44
  "clean": "rm -rf dist",
45
- "prepublishOnly": "npm run build"
45
+ "prepublishOnly": "bun run build"
46
46
  },
47
47
  "keywords": [
48
48
  "react",
@@ -1,2 +0,0 @@
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 W=[{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 M=new Map,H=t=>{J={...t||{}},M.clear()},P=t=>{const e=J[t];return e&&typeof e=="string"&&e.length>0?e:N[t]?.rpcUrl},S=t=>N[t],_=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:[P(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=P(t);if(!a)throw new Error(`No RPC URL configured for chain ID: ${t}`);const r=`${t}:${a}`,s=M.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 M.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:P(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:W,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=_(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):_(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"},Fe={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:Fe});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 Me(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 Pe(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 _e='"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:_e,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),F=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,z=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||z;return{height:"56px",backgroundColor:k?de:R?`${g}cc`:m?`${g}ee`:g,color:k?le:z,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 ${F}, 4px 4px 0px ${v}`:R?`2px 2px 0px ${v}`:m?`5px 5px 0px ${F}, 6px 6px 0px ${v}`:`3px 3px 0px ${F}, 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.addressesEqual=I,exports.buildDarkPalette=Me,exports.buildLightPalette=Pe,exports.createInitialSteps=Te,exports.createTheme=ee,exports.ensureSmartWallet=ke,exports.ensureWalletOnChain=xe,exports.getAllAssetsForChain=Ee,exports.getChainConfig=S,exports.getChainName=_,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,exports.z=W;
@@ -1,2 +0,0 @@
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,Le as a,V as b,ne as c,se as d,Ye as e,Pe as f,B as g,v as h,K as i,Fe as j,_e as k,j 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,G as z};
@@ -1,9 +0,0 @@
1
- import React from "react";
2
- import type { ResolvedDarkPalette } from "../../../utils/theme";
3
- interface DepositSubtitleProps {
4
- appName: string;
5
- dark: boolean;
6
- dk: ResolvedDarkPalette;
7
- }
8
- export declare const DepositSubtitle: React.FC<DepositSubtitleProps>;
9
- export {};
@@ -1,73 +0,0 @@
1
- import type { Dispatch, MutableRefObject, SetStateAction } from "react";
2
- import { type Address } from "viem";
3
- import { type FeeEstimateSummary } from "@spicenet-io/spiceflow-core";
4
- import type { ChainBatch } from "../../types/authorization";
5
- import type { SelectedAsset } from "../../types/assets";
6
- import type { SpiceSupplyProps } from "../../types/supply";
7
- import type { ResolvedExactOutputSwap } from "../../utils/swapQuotes";
8
- import type { GaslessExecutionOptions, GaslessProgress } from "../../hooks/useSpiceExecution";
9
- export type SupplyStep = "idle" | "signing-delegation" | "signing-intent" | "submitting" | "executing" | "success" | "error";
10
- export type PaymentResult = {
11
- status: "processing" | "success" | "failed";
12
- txHash?: string;
13
- error?: string;
14
- };
15
- type EstimateGaslessFn = (chainBatches: ChainBatch[], tokenAddress: string, tokenTransferAmount: bigint, options?: GaslessExecutionOptions) => Promise<FeeEstimateSummary>;
16
- type ExecuteGaslessFn = (chainBatches: ChainBatch[], tokenAddress: string, tokenTransferAmount: bigint, onProgress?: (progress: GaslessProgress) => void, signal?: AbortSignal, options?: GaslessExecutionOptions) => Promise<string>;
17
- type BuildPayBatchesFn = (options?: {
18
- actionAmountOverride?: bigint;
19
- fundingAmountOverride?: bigint;
20
- }) => Promise<ChainBatch[]>;
21
- type BuildSupplyBatchesFn = (spicenetFundingAmount?: bigint) => Promise<ChainBatch[]>;
22
- type EstimateRequiredGrossFundingFn = (requiredNetFunding: bigint, buildBatches: (grossFundingAmount: bigint) => ChainBatch[] | Promise<ChainBatch[]>, fundingToken: Address, gaslessOptions?: Pick<GaslessExecutionOptions, "useCustomTransfers" | "userOverride">) => Promise<bigint>;
23
- export interface ExecutorContext {
24
- selectedAsset: SelectedAsset | null;
25
- parsedAmount: number;
26
- currentPaymentAmount: string;
27
- isInsufficientBalance: boolean;
28
- isPayMode: boolean;
29
- isNon7702: boolean;
30
- isSourceDestToken: boolean;
31
- needsSwap: boolean;
32
- exactOutputSwap: ResolvedExactOutputSwap | null;
33
- selectedIsEquivalent: boolean;
34
- resolvedTokenIn: Address | null;
35
- embeddedWalletAddress: string | null | undefined;
36
- providerEmbeddedAddress: string | null | undefined;
37
- externalWallet: {
38
- getEthereumProvider: () => Promise<any>;
39
- } | null | undefined;
40
- externalWalletAddress: string | null | undefined;
41
- address: string | null | undefined;
42
- isConnected: boolean;
43
- ready: boolean;
44
- authenticated: boolean;
45
- provider: string | null | undefined;
46
- resolvedChainId: number;
47
- executionTokenAddress: Address;
48
- destinationToken: SpiceSupplyProps["destinationToken"];
49
- buildActionCalls: SpiceSupplyProps["buildActionCalls"];
50
- buildSpicenetBatch: SpiceSupplyProps["buildSpicenetBatch"];
51
- onPayExecute?: SpiceSupplyProps["onPayExecute"];
52
- onError?: (err: Error) => void;
53
- buildPayChainBatches: BuildPayBatchesFn;
54
- buildSupplyChainBatches: BuildSupplyBatchesFn;
55
- estimateGasless: EstimateGaslessFn;
56
- executeGasless: ExecuteGaslessFn;
57
- estimateRequiredGrossFunding: EstimateRequiredGrossFundingFn;
58
- handleProgressCallback: (progress: GaslessProgress) => void;
59
- setError: Dispatch<SetStateAction<string | null>>;
60
- setStep: Dispatch<SetStateAction<SupplyStep>>;
61
- setStatusMsg: Dispatch<SetStateAction<string>>;
62
- setTxHash: Dispatch<SetStateAction<string | null>>;
63
- setIsExecuting: Dispatch<SetStateAction<boolean>>;
64
- setShowStatusPanel: Dispatch<SetStateAction<boolean>>;
65
- setPaymentResult: Dispatch<SetStateAction<PaymentResult | null>>;
66
- spiceDepositSubmittedRef: MutableRefObject<boolean>;
67
- abortControllerRef: MutableRefObject<AbortController | null>;
68
- }
69
- export declare function executeSupply(ctx: ExecutorContext): Promise<void>;
70
- export declare function executeDirectExternalAction(ctx: ExecutorContext): Promise<`0x${string}` | undefined>;
71
- export declare function executeNon7702Pay(ctx: ExecutorContext): Promise<string>;
72
- export declare function executePay(ctx: ExecutorContext): Promise<void>;
73
- export {};
@@ -1,50 +0,0 @@
1
- import type { Dispatch, MutableRefObject, SetStateAction } from "react";
2
- import { type FeeEstimateSummary } from "@spicenet-io/spiceflow-core";
3
- import type { Address } from "viem";
4
- import type { ChainBatch } from "../../types/authorization";
5
- import type { DestinationToken } from "../../types/withdraw";
6
- import type { GaslessExecutionOptions, GaslessProgress } from "../../hooks/useSpiceExecution";
7
- export type WithdrawalExecutionContext = {
8
- actionId: string;
9
- intentId: string;
10
- intentIndex: number;
11
- totalSteps: number;
12
- };
13
- type EstimateGaslessFn = (chainBatches: ChainBatch[], tokenAddress: string, tokenTransferAmount: bigint, options?: GaslessExecutionOptions) => Promise<FeeEstimateSummary>;
14
- type ExecuteGaslessFn = (chainBatches: ChainBatch[], tokenAddress: string, tokenTransferAmount: bigint, onProgress?: (progress: GaslessProgress) => void, signal?: AbortSignal, options?: GaslessExecutionOptions) => Promise<string>;
15
- export interface WithdrawExecutorContext {
16
- computedWithdrawBatches: ChainBatch[];
17
- walletAddress: string | null | undefined;
18
- recipientAddress: string | null | undefined;
19
- selectedDestToken: DestinationToken | null;
20
- selectedChainId: number | null;
21
- amount: string;
22
- receiveAmountRaw: bigint;
23
- gasFee: bigint | null;
24
- isNon7702: boolean;
25
- onWithdrawExecute?: (amount: string) => Promise<void> | void;
26
- onWithdrawSuccess?: (info: {
27
- token: string;
28
- amount: string;
29
- chainId: number;
30
- }) => void;
31
- onWithdrawError?: (msg: string) => void;
32
- buildSpicenetBatch?: (params: {
33
- destinationChainId: number;
34
- deliveryToken: Address;
35
- deliveryAmount: bigint;
36
- deliveryRecipient: Address;
37
- }) => ChainBatch | null;
38
- buildWithdrawBatches: (spicenetFundingAmount?: bigint) => ChainBatch[];
39
- estimateGasless: EstimateGaslessFn;
40
- executeGasless: ExecuteGaslessFn;
41
- setIsExecuting: Dispatch<SetStateAction<boolean>>;
42
- setExecutionError: Dispatch<SetStateAction<string | null>>;
43
- setExecutionProgress: Dispatch<SetStateAction<GaslessProgress | null>>;
44
- setLockedGasFee: Dispatch<SetStateAction<bigint | null>>;
45
- executionContextRef: MutableRefObject<WithdrawalExecutionContext | null>;
46
- isMountedRef: MutableRefObject<boolean>;
47
- }
48
- export declare function executeWithdraw(ctx: WithdrawExecutorContext): Promise<void>;
49
- export declare function retryWithdraw(ctx: WithdrawExecutorContext): Promise<void>;
50
- export {};