@spicenet-io/spiceflow-ui 3.3.1 → 3.3.2
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/README.md +7 -7
- package/dist/Button-B--Fjq1m.js +2 -0
- package/dist/Button-dU4UsC56.js +2 -0
- package/dist/auth-dynamic.cjs.js +1 -1
- package/dist/auth-dynamic.js +1 -1
- package/dist/auth-privy.cjs.js +1 -1
- package/dist/auth-privy.js +1 -1
- package/dist/index.cjs.js +12 -12
- package/dist/index.d.ts +1 -3
- package/dist/index.js +12 -12
- package/dist/{providerWallet-BMCMyG4_.js → providerWallet-DDywdl9_.js} +1 -1
- package/dist/{providerWallet-BMOS9yt1.js → providerWallet-cDeDz-zR.js} +1 -1
- package/dist/types/supply.d.ts +1 -2
- package/dist/types/ui.d.ts +0 -1
- package/dist/types/unified.d.ts +0 -1
- package/dist/utils/abis/spicenet.d.ts +0 -66
- package/dist/utils/relayer/index.d.ts +0 -5
- package/dist/utils/tokenResolution.d.ts +1 -1
- package/package.json +46 -46
- package/dist/Button-Ba4gIhbT.js +0 -2
- package/dist/Button-Davf3Lcw.js +0 -2
- package/dist/utils/fees.d.ts +0 -9
- package/dist/utils/rebalancing/index.d.ts +0 -70
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{createWalletClient as l,custom as d}from"viem";import{g as c}from"./Button-
|
|
2
|
+
import{createWalletClient as l,custom as d}from"viem";import{g as c}from"./Button-dU4UsC56.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-
|
|
2
|
+
"use strict";const o=require("viem"),c=require("./Button-B--Fjq1m.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;
|
package/dist/types/supply.d.ts
CHANGED
|
@@ -38,8 +38,7 @@ export interface SpiceSupplyProps {
|
|
|
38
38
|
deliveryToken: Address;
|
|
39
39
|
deliveryAmount: bigint;
|
|
40
40
|
deliveryRecipient: Address;
|
|
41
|
-
|
|
42
|
-
}) => ChainBatch | null | Promise<ChainBatch | null>;
|
|
41
|
+
}) => ChainBatch | null;
|
|
43
42
|
onPayExecute?: (ctx: PayExecuteContext) => Promise<string | void>;
|
|
44
43
|
actionLabel: string;
|
|
45
44
|
amountDirection?: "input" | "output";
|
package/dist/types/ui.d.ts
CHANGED
package/dist/types/unified.d.ts
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
export declare const spicenetAbi: readonly [{
|
|
2
|
-
readonly type: "function";
|
|
3
|
-
readonly name: "closeRebalancingRequest";
|
|
4
|
-
readonly inputs: readonly [{
|
|
5
|
-
readonly name: "args";
|
|
6
|
-
readonly type: "tuple";
|
|
7
|
-
readonly internalType: "struct Spicenet.CloseRebalancingRequestArgs";
|
|
8
|
-
readonly components: readonly [{
|
|
9
|
-
readonly name: "idempotenceKey";
|
|
10
|
-
readonly type: "bytes32";
|
|
11
|
-
readonly internalType: "bytes32";
|
|
12
|
-
}, {
|
|
13
|
-
readonly name: "repaymentChainTokenAmount";
|
|
14
|
-
readonly type: "uint256";
|
|
15
|
-
readonly internalType: "uint256";
|
|
16
|
-
}];
|
|
17
|
-
}];
|
|
18
|
-
readonly outputs: readonly [];
|
|
19
|
-
readonly stateMutability: "nonpayable";
|
|
20
|
-
}, {
|
|
21
2
|
readonly type: "function";
|
|
22
3
|
readonly name: "createWithdrawalRequest";
|
|
23
4
|
readonly inputs: readonly [{
|
|
@@ -65,51 +46,4 @@ export declare const spicenetAbi: readonly [{
|
|
|
65
46
|
}];
|
|
66
47
|
readonly outputs: readonly [];
|
|
67
48
|
readonly stateMutability: "nonpayable";
|
|
68
|
-
}, {
|
|
69
|
-
readonly type: "function";
|
|
70
|
-
readonly name: "createRebalancingRequest";
|
|
71
|
-
readonly inputs: readonly [{
|
|
72
|
-
readonly name: "request";
|
|
73
|
-
readonly type: "tuple";
|
|
74
|
-
readonly internalType: "struct Spicenet.CreateRebalancingRequestArgs";
|
|
75
|
-
readonly components: readonly [{
|
|
76
|
-
readonly name: "idempotenceKey";
|
|
77
|
-
readonly type: "bytes32";
|
|
78
|
-
readonly internalType: "bytes32";
|
|
79
|
-
}, {
|
|
80
|
-
readonly name: "nbf";
|
|
81
|
-
readonly type: "uint256";
|
|
82
|
-
readonly internalType: "uint256";
|
|
83
|
-
}, {
|
|
84
|
-
readonly name: "exp";
|
|
85
|
-
readonly type: "uint256";
|
|
86
|
-
readonly internalType: "uint256";
|
|
87
|
-
}, {
|
|
88
|
-
readonly name: "metadata";
|
|
89
|
-
readonly type: "string";
|
|
90
|
-
readonly internalType: "string";
|
|
91
|
-
}, {
|
|
92
|
-
readonly name: "recipient";
|
|
93
|
-
readonly type: "string";
|
|
94
|
-
readonly internalType: "string";
|
|
95
|
-
}, {
|
|
96
|
-
readonly name: "fromChainToken";
|
|
97
|
-
readonly type: "string";
|
|
98
|
-
readonly internalType: "string";
|
|
99
|
-
}, {
|
|
100
|
-
readonly name: "fromChainTokenAmount";
|
|
101
|
-
readonly type: "uint256";
|
|
102
|
-
readonly internalType: "uint256";
|
|
103
|
-
}, {
|
|
104
|
-
readonly name: "toChainToken";
|
|
105
|
-
readonly type: "string";
|
|
106
|
-
readonly internalType: "string";
|
|
107
|
-
}, {
|
|
108
|
-
readonly name: "toChainTokenAmountMin";
|
|
109
|
-
readonly type: "uint256";
|
|
110
|
-
readonly internalType: "uint256";
|
|
111
|
-
}];
|
|
112
|
-
}];
|
|
113
|
-
readonly outputs: readonly [];
|
|
114
|
-
readonly stateMutability: "nonpayable";
|
|
115
49
|
}];
|
|
@@ -49,9 +49,4 @@ export declare class RelayerService {
|
|
|
49
49
|
getRollupTimestamp(): Promise<RollupTimestamp>;
|
|
50
50
|
}
|
|
51
51
|
export declare const relayerService: RelayerService;
|
|
52
|
-
type SmartWalletSigner = (message: string) => Promise<string | {
|
|
53
|
-
signature?: string;
|
|
54
|
-
}>;
|
|
55
|
-
export declare function ensureSmartWallet(address: string, signMessage: SmartWalletSigner): Promise<void>;
|
|
56
52
|
export declare const createInitialSteps: (chainBatches: ChainBatch[], customGetChainName?: (chainId: number) => string) => SwapStep[];
|
|
57
|
-
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Address } from "viem";
|
|
2
2
|
import type { Asset } from "../types/assets";
|
|
3
3
|
import type { ChainToken } from "@spicenet-io/spiceflow-core";
|
|
4
4
|
type AssetTokenInput = Pick<Asset, "address" | "symbol" | "name" | "decimals" | "chainId" | "displaySymbol" | "displayName" | "receiptTokenName" | "chainTokens" | "isUniversal">;
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spicenet-io/spiceflow-ui",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.2",
|
|
4
4
|
"description": "Spiceflow UI SDK",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"packageManager": "bun@1.3.13",
|
|
7
6
|
"main": "dist/index.cjs.js",
|
|
8
7
|
"module": "dist/index.js",
|
|
9
8
|
"types": "dist/index.d.ts",
|
|
@@ -35,14 +34,15 @@
|
|
|
35
34
|
"./dist/providers/custom.css"
|
|
36
35
|
],
|
|
37
36
|
"files": [
|
|
38
|
-
"dist"
|
|
37
|
+
"dist",
|
|
38
|
+
".npmrc"
|
|
39
39
|
],
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "rm -rf dist && tsc -p tsconfig.build.json --emitDeclarationOnly && rollup -c rollup.config.mjs",
|
|
42
42
|
"dev": "rollup -c rollup.config.mjs --watch",
|
|
43
|
-
"dev:link": "
|
|
43
|
+
"dev:link": "npm run build && npm link && echo '✅ SDK linked globally. Run: npm link @spicenet-io/spiceflow-ui in your project'",
|
|
44
44
|
"clean": "rm -rf dist",
|
|
45
|
-
"prepublishOnly": "
|
|
45
|
+
"prepublishOnly": "npm run build"
|
|
46
46
|
},
|
|
47
47
|
"keywords": [
|
|
48
48
|
"react",
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
"author": "",
|
|
59
59
|
"license": "MIT",
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@spicenet-io/spiceflow-core": "0.3.10",
|
|
62
|
-
"lucide-react": "0.562.0",
|
|
63
|
-
"tslib": "2.8.1"
|
|
61
|
+
"@spicenet-io/spiceflow-core": "^0.3.10",
|
|
62
|
+
"lucide-react": "^0.562.0",
|
|
63
|
+
"tslib": "^2.8.1"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"@dynamic-labs/ethereum": ">=4.15.0 <5.0.0",
|
|
@@ -89,46 +89,46 @@
|
|
|
89
89
|
}
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
|
-
"@dynamic-labs/ethereum": "4.70.0",
|
|
93
|
-
"@dynamic-labs/sdk-react-core": "4.70.0",
|
|
94
|
-
"@dynamic-labs/wallet-connector-core": "4.70.0",
|
|
95
|
-
"@privy-io/react-auth": "2.
|
|
96
|
-
"@rollup/plugin-commonjs": "28.0.
|
|
97
|
-
"@rollup/plugin-image": "3.0.3",
|
|
98
|
-
"@rollup/plugin-json": "6.1.0",
|
|
99
|
-
"@rollup/plugin-node-resolve": "16.0.
|
|
100
|
-
"@rollup/plugin-replace": "6.0.
|
|
101
|
-
"@rollup/plugin-typescript": "12.
|
|
102
|
-
"@tanstack/react-query": "5.90.
|
|
103
|
-
"@types/node": "24.
|
|
104
|
-
"@types/react": "18.3.
|
|
105
|
-
"@types/react-dom": "18.3.
|
|
106
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
107
|
-
"@typescript-eslint/parser": "6.
|
|
108
|
-
"axios": "1.
|
|
109
|
-
"esbuild": "0.24.
|
|
110
|
-
"eslint": "8.
|
|
111
|
-
"eslint-config-prettier": "10.1.8",
|
|
112
|
-
"eslint-plugin-react": "7.
|
|
113
|
-
"eslint-plugin-react-hooks": "4.6.
|
|
114
|
-
"husky": "9.1.7",
|
|
115
|
-
"jest": "29.
|
|
116
|
-
"lint-staged": "16.2.
|
|
117
|
-
"postcss": "8.5.6",
|
|
118
|
-
"postcss-import": "16.1.1",
|
|
92
|
+
"@dynamic-labs/ethereum": "^4.70.0",
|
|
93
|
+
"@dynamic-labs/sdk-react-core": "^4.70.0",
|
|
94
|
+
"@dynamic-labs/wallet-connector-core": "^4.70.0",
|
|
95
|
+
"@privy-io/react-auth": "^2.24.0",
|
|
96
|
+
"@rollup/plugin-commonjs": "^28.0.6",
|
|
97
|
+
"@rollup/plugin-image": "^3.0.3",
|
|
98
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
99
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
100
|
+
"@rollup/plugin-replace": "^6.0.2",
|
|
101
|
+
"@rollup/plugin-typescript": "^12.1.4",
|
|
102
|
+
"@tanstack/react-query": "^5.90.5",
|
|
103
|
+
"@types/node": "^24.3.0",
|
|
104
|
+
"@types/react": "^18.3.3",
|
|
105
|
+
"@types/react-dom": "^18.3.0",
|
|
106
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
107
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
108
|
+
"axios": "^1.11.0",
|
|
109
|
+
"esbuild": "^0.24.0",
|
|
110
|
+
"eslint": "^8.45.0",
|
|
111
|
+
"eslint-config-prettier": "^10.1.8",
|
|
112
|
+
"eslint-plugin-react": "^7.33.0",
|
|
113
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
114
|
+
"husky": "^9.1.7",
|
|
115
|
+
"jest": "^29.6.0",
|
|
116
|
+
"lint-staged": "^16.2.5",
|
|
117
|
+
"postcss": "^8.5.6",
|
|
118
|
+
"postcss-import": "^16.1.1",
|
|
119
119
|
"prettier": "3.6.2",
|
|
120
|
-
"react": "18.3.1",
|
|
121
|
-
"react-dom": "18.3.1",
|
|
122
|
-
"rollup": "4.
|
|
123
|
-
"rollup-plugin-copy": "3.5.0",
|
|
124
|
-
"rollup-plugin-esbuild": "6.
|
|
125
|
-
"rollup-plugin-peer-deps-external": "2.2.4",
|
|
126
|
-
"rollup-plugin-postcss": "4.0.2",
|
|
127
|
-
"sharp": "0.34.5",
|
|
128
|
-
"ts-node": "10.9.2",
|
|
129
|
-
"typescript": "5.9.
|
|
120
|
+
"react": "^18.3.1",
|
|
121
|
+
"react-dom": "^18.3.1",
|
|
122
|
+
"rollup": "^4.50.0",
|
|
123
|
+
"rollup-plugin-copy": "^3.5.0",
|
|
124
|
+
"rollup-plugin-esbuild": "^6.1.1",
|
|
125
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
126
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
127
|
+
"sharp": "^0.34.5",
|
|
128
|
+
"ts-node": "^10.9.2",
|
|
129
|
+
"typescript": "^5.9.2",
|
|
130
130
|
"viem": "2.33.1",
|
|
131
|
-
"wagmi": "2.
|
|
131
|
+
"wagmi": "^2.18.2"
|
|
132
132
|
},
|
|
133
133
|
"lint-staged": {
|
|
134
134
|
"*.{ts,tsx,js,jsx,json,md}": "prettier --write"
|
package/dist/Button-Ba4gIhbT.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";const v=require("react/jsx-runtime"),h=require("react"),y=require("@spicenet-io/spiceflow-core"),b=require("viem"),ie=require("viem/actions");class f extends Error{constructor(e,a,t={}){super(a),this.code=e,this.context=t,this.name="SpiceflowError",Error.captureStackTrace&&Error.captureStackTrace(this,f)}}function ce(r){return r instanceof f}const j=[{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"}],le="0xcA11bde05977b3631167028862bE2a173976CA11",de={4114:"0x860aFc632a6D625B95d8B96f39ECC48E988c6962"},ue=new Set([5115]);function fe(r){const e=de[r.id]??(ue.has(r.id)?void 0:le);return b.defineChain({id:r.id,name:r.name,nativeCurrency:r.nativeCurrency,rpcUrls:{default:{http:[r.rpcUrl]}},blockExplorers:{default:{name:r.displayName,url:r.blockExplorer}},testnet:r.network==="testnet",...e?{contracts:{multicall3:{address:e}}}:{}})}const pe=[1,8453,42161,4114,11155111,421614,84532,5115,123420001114,688688,688689],k=Object.fromEntries(pe.map(r=>y.getChainMeta(r)).filter(r=>r!=null).map(r=>[r.id,{...r,viemChain:fe(r),supportedTokens:y.getTokensForChain(r.id)}])),me=k;let D={};const F=new Map,W=r=>{D={...r||{}},F.clear()},_=r=>{const e=D[r];return e&&typeof e=="string"&&e.length>0?e:k[r]?.rpcUrl},R=r=>k[r],I=r=>{const e=y.getChainMeta(r);return e?.displayName||e?.name||`Chain ${r}`},ge=r=>{const e=y.getDelegateContract(r);if(!e)throw new Error(`Unsupported chain ID: ${r}`);return e},he=(r,e,a)=>{const t=R(r);return t?.blockExplorer?`${t.blockExplorer}/tx/${e}`:"#"},z=r=>{const e=R(r);if(!e)throw new Error(`Unsupported chain ID: ${r}`);const a=_(r);if(!a)throw new Error(`No RPC URL configured for chain ID: ${r}`);const t=`${r}:${a}`,o=F.get(t);if(o)return o;const s=b.createPublicClient({chain:e.viemChain,transport:b.http(a,{timeout:15e3,retryCount:2,retryDelay:300}),batch:{multicall:{wait:16}}});return F.set(t,s),s},ye=()=>{const r={};return Object.values(k).forEach(e=>{r[e.id]={name:e.name,moralisName:e.moralisId||"",chain:e.viemChain,rpcUrl:_(e.id)||e.rpcUrl}}),r},be=(r,e=[])=>{const a=R(r);if(!a)return[];const t=[];if(![11155111,421614,84532,688689].includes(r)){const s=e.find(n=>n.chainId===r&&n.isNative);s?t.push(s):t.push({address:y.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:r})}if(!a.supportedTokens)return t;const o=t.some(s=>s.isNative);return a.supportedTokens.forEach(s=>{if(o&&y.isNativeToken(s.address))return;const n=e.find(l=>l.chainId===r&&l.address.toLowerCase()===s.address.toLowerCase());n?t.push(n):t.push({address:s.address,name:s.name,symbol:s.symbol,decimals:s.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:s.logo,isNative:!1,chainId:r})}),t},we=async(r,e)=>{const a=R(r);if(!a)throw new Error(`Unsupported chain ID: ${r}`);const t=e.toLowerCase();if(y.isNativeToken(t)){if(!a.nativeCurrency?.decimals)throw new Error(`Native currency decimals not configured for chain ${r}`);return a.nativeCurrency.decimals}if(a.supportedTokens){const o=a.supportedTokens.find(s=>s.address.toLowerCase()===t);if(o)return o.decimals}try{if(!b.isAddress(e,{strict:!1}))throw new Error(`Invalid token address: ${e}`);const o=b.getAddress(e),s=z(r),n=await ie.readContract(s,{address:o,abi:j,functionName:"decimals"});return Number(n)}catch{throw new Error(`Could not determine decimals for token ${e} on chain ${r}`)}},J=typeof process<"u"&&process.env?.NEXT_PUBLIC_RELAYER_API_URL||"https://tx-api-devserver.spicenet.io",Y="__SPICEFLOW_RELAYER_API_URL__";function xe(r,e){const a=e.match(/Output amount (\d+) is insufficient after fees (\d+) on chain (\d+)/);if(!a)return e;const[,t,o,s]=a,n=Number(s),l=BigInt(t),d=BigInt(o);let c;for(const u of r.intents){const E=u.chainBatches.find(T=>T.chainId===n);if(E){c=E;break}}const m=c?.tokenTransfers.find(u=>u.from==="escrow"&&u.to.toLowerCase()===r.user.toLowerCase()&&!y.isNativeToken(u.token));if(!m)return`Amount is too small to cover the estimated fee on ${I(n)}.`;const p=y.getTokenByAddress(m.token,n),x=p?.decimals??18,B=p?.symbol??"tokens",S=b.formatUnits(l,x),i=b.formatUnits(d,x);return`Amount is too small to cover the estimated fee on ${I(n)}. Amount: ${S} ${B}. Estimated fee: ${i} ${B}.`}function Be(r){return!1}function Ee(){if(typeof globalThis>"u")return;const r=globalThis[Y];return typeof r=="string"&&r.length>0?r:void 0}class Se{constructor(){this.baseUrl=J}setBaseUrl(e){this.baseUrl=e,typeof globalThis<"u"&&(globalThis[Y]=e)}getBaseUrl(){return this.getEffectiveBaseUrl()}getEffectiveBaseUrl(){return Ee()||this.baseUrl}async createAction(e){const a=await fetch(`${this.getEffectiveBaseUrl()}/actions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(o,s)=>typeof s=="bigint"?s.toString():s)}),t=await a.json();if(!a.ok||t.success===!1)throw new f("RELAYER_ERROR",t.error?.message||`Relayer API error: ${a.status}`,{httpStatus:a.status,responseBody:JSON.stringify(t),endpoint:"/actions"});return t}async estimateActionFees(e){const a=await fetch(`${this.getEffectiveBaseUrl()}/actions/fees/estimate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(o,s)=>typeof s=="bigint"?s.toString():s)}),t=await a.json();if(!a.ok||!t.success||!t.data?.feeEstimate){const o=t.error?.message||`Relayer fee estimate error: ${a.status}`,s=xe(e,o);throw new f("RELAYER_ERROR",s,{httpStatus:a.status,responseBody:JSON.stringify(t),endpoint:"/actions/fees/estimate"})}return t.data.feeEstimate}async estimateBatchGas(e){const a=await fetch(`${this.getEffectiveBaseUrl()}/actions/gas/estimate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(o,s)=>typeof s=="bigint"?s.toString():s)}),t=await a.json();if(!a.ok||!t.success||!t.data?.gasFee){const o=t.error?.message||`Relayer gas estimate error: ${a.status}`;throw new f("RELAYER_ERROR",o,{httpStatus:a.status,responseBody:JSON.stringify(t),endpoint:"/actions/gas/estimate"})}return{gasFee:BigInt(t.data.gasFee),gasQuoteSource:t.data.gasQuoteSource}}async executeStep(e,a,t,o){const s=`${this.getEffectiveBaseUrl()}/actions/${e}/intents/${a}/steps/${t}`,n=fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});let l;try{l=await Promise.race([n,new Promise((c,m)=>setTimeout(()=>m(new f("RELAYER_EXECUTE_ERROR",`Execute step request timed out after ${1e4/1e3}s`,{actionId:e,intentIndex:a,stepIndex:t,endpoint:`/actions/${e}/intents/${a}/steps/${t}`})),1e4))])}catch(c){throw c}const d=await l.json();if(!l.ok||d.success===!1)throw new f("RELAYER_EXECUTE_ERROR",d.error?.message||`Execute step error: ${l.status}`,{httpStatus:l.status,responseBody:JSON.stringify(d),endpoint:`/actions/${e}/intents/${a}/steps/${t}`,actionId:e});return{success:!0,transactionHash:d.transactionHash}}async checkStepStatus(e,a){const t=e.split("/");let o="";if(t.length>=2){const l=t[0],d=t[1];o=`${this.getEffectiveBaseUrl()}/actions/${l}/intents/${d}/steps/${a}`}else o=`${this.getEffectiveBaseUrl()}/actions/${e}/intents/0/steps/${a}`;const s=await fetch(o),n=await s.json();if(!s.ok||n.success===!1)throw new f("RELAYER_STATUS_ERROR",n.error?.message||`Intent step status check failed: ${s.status}`,{httpStatus:s.status,responseBody:JSON.stringify(n),endpoint:o,intentId:e});return{success:!0,data:{status:n.status==="error"?"reverted":n.status,transactionHash:n.txid}}}async createWallet(e,a){const t=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),o=await t.json();if(!t.ok||o.success===!1)throw new f("RELAYER_ERROR",o.error?.message||`Create wallet error: ${t.status}`,{httpStatus:t.status,responseBody:JSON.stringify(o),endpoint:`/wallets/${e}`});return o}async getWallet(e){const a=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${e}`),t=await a.json();if(!a.ok||t.success===!1)throw new f("RELAYER_ERROR",t.error?.message||`Get wallet error: ${a.status}`,{httpStatus:a.status,responseBody:JSON.stringify(t),endpoint:`/wallets/${e}`});return t}async createWithdrawal(e){const a=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(o,s)=>typeof s=="bigint"?s.toString():s)}),t=await a.json();if(!a.ok||t.success===!1)throw new f("RELAYER_ERROR",t.error?.message||`Create withdrawal error: ${a.status}`,{httpStatus:a.status,responseBody:JSON.stringify(t),endpoint:"/withdrawals"});return t}async getWithdrawal(e){const a=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals/${e}`),t=await a.json();if(!a.ok||t.success===!1)throw new f("RELAYER_ERROR",t.error?.message||`Get withdrawal error: ${a.status}`,{httpStatus:a.status,responseBody:JSON.stringify(t),endpoint:`/withdrawals/${e}`});return t}async getRollupTimestamp(){const e=await fetch(`${this.getEffectiveBaseUrl()}/time`),a=await e.json();if(!e.ok||a.success===!1)throw new f("RELAYER_ERROR",a.error?.message||`Get rollup timestamp error: ${e.status}`,{httpStatus:e.status,responseBody:JSON.stringify(a),endpoint:"/time"});return a}}const w=new Se,M=new Map;async function Ce(r,e){const a=r.toLowerCase(),t=M.get(a);if(t)return t;const o=(async()=>{try{await w.getWallet(r);return}catch{}const{unix_timestamp:s}=await w.getRollupTimestamp(),n=`I am creating a new smart wallet and adding an admin wallet ethereum:0x${r.slice(2).toLowerCase()}. Nonce: ${s}`,l=await e(n),d=typeof l=="string"?l:l.signature;if(!d)throw new Error("Wallet returned no smart wallet signature");await w.createWallet(r,{timestamp:s,signature:d})})();M.set(a,o);try{await o}finally{M.delete(a)}}const $e=(r,e)=>{const a=o=>e?e(o):I(o),t=[];return r.forEach((o,s)=>{const n=o.calls&&o.calls.length>0,l=o.tokenTransfers&&o.tokenTransfers.length>0;if(n||l){const d={stepId:s,status:s===0?"processing":"pending",chainId:o.chainId,chainName:a(o.chainId),description:"Processing transaction"};t.push(d)}}),t},H="spiceflow-mode",G=()=>{if(typeof window>"u")return null;try{const r=window.localStorage.getItem(H);return r==="embedded"?"7702":r==="external"?"ondemand":null}catch{return null}},ve=r=>{if(!(typeof window>"u"))try{window.localStorage.setItem(H,r==="7702"?"embedded":"external")}catch{}},Re=()=>G()!==null,q=h.createContext(null),X=h.createContext(null),Te=({children:r,provider:e,supportedChainIds:a,network:t="testnet",mode:o="7702",skipFlow:s=[],nativeChainId:n,appName:l="Spicenet",apiUrl:d,theme:c,rpcOverrides:m})=>{h.useEffect(()=>{if(!d)return;const u=w.getBaseUrl();return w.setBaseUrl(d),()=>w.setBaseUrl(u)},[d]),h.useEffect(()=>(W(m),()=>W(void 0)),[m]);const p=a??y.getChainIdsByNetwork(t),x=c??null,[B,S]=h.useState(()=>G()??o),i=h.useCallback(u=>{S(u),ve(u)},[]);return v.jsx(q.Provider,{value:x,children:v.jsx(X.Provider,{value:{provider:e,supportedChainIds:p,skipFlow:s,mode:B,setMode:i,network:t,nativeChainId:n,appName:l,apiUrl:d,rpcOverrides:m},children:r})})},ke={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"}},Ie={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"},Ne={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"},Q=(r="light")=>({mode:r,...ke,colors:r==="light"?Ie:Ne});function N(r,e){const a=r.replace("#",""),t=Math.max(0,Math.round(parseInt(a.substring(0,2),16)*(1-e))),o=Math.max(0,Math.round(parseInt(a.substring(2,4),16)*(1-e))),s=Math.max(0,Math.round(parseInt(a.substring(4,6),16)*(1-e)));return`#${t.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`}function Ue(r,e){return{shell:e?.shell??"#141414",shellBorder:e?.shellBorder??N(e?.shell??"#141414",.35),shellInnerBorder:e?.shellInnerBorder??N(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 Ae(r){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 Z(r,e){const a=e?{...r,...e}:r,t=a.dark??!1,o=a.primaryColor,s=a.shell??(t?"#141414":"#ffffff");return{primaryColor:o,dark:t,fontFamily:a.fontFamily??'"Helvetica Neue", sans-serif',appName:a.appName??"Spicenet",logo:a.logo,borderRadius:a.borderRadius??"8px",shell:s,shellBorder:N(s,t?.35:.085),shellInnerBorder:N(s,t?.55:.165),card:a.card??(t?"#1e1e1e":"#f9fafb"),input:t?"#171717":"#ffffff",hover:t?"#2a2a2a":"#f3f4f6",text:a.text??(t?"#ffffff":"#111827"),textMuted:a.textMuted??(t?"#888888":"#6b7280"),inputText:t?"#e0e0e0":"#111827",inputPlaceholder:t?"#555555":"#9ca3af",border:a.border??(t?"rgba(255,255,255,0.08)":"#e5e7eb"),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":"#fde68a",warningText:t?"#fbbf24":"#92400e",errorBg:t?"#1f0d0d":"#fef2f2",errorBorder:t?"#4a2020":"#fecaca",errorText:t?"#f87171":"#dc2626",infoBg:t?"#0d1325":"#dbeafe",infoBorder:t?"#2a3a5a":"#93c5fd",infoText:t?"#60a5fa":"#1e40af"}}function K(r,e){const a=h.useContext(q)??void 0;return h.useMemo(()=>{const t=a??{primaryColor:"#EA4B4B"},o={...r?.primaryColor?{primaryColor:r.primaryColor}:{},...r?.fontFamily?{fontFamily:r.fontFamily}:{},...e!==void 0?{dark:e}:{}},s=Z(t,o),{dark:n,primaryColor:l,appName:d}=s,c=Q(n?"dark":"light"),m={...c,colors:{...c.colors,primary:l,primaryHover:`${l}dd`},typography:{...c.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:a,theme:m,dark:n,appName:d,primaryColor:l,dk:p,palette:p}},[a,r,e])}const V="spiceflow-spinner-keyframes";function Oe(){if(typeof document>"u"||document.getElementById(V))return;const r=document.createElement("style");r.id=V,r.textContent="@keyframes spiceflow-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}",document.head.appendChild(r)}const ee=({size:r=16,borderWidth:e=2,color:a="currentColor",style:t})=>{const o=h.useRef(!1);return h.useEffect(()=>{o.current||(Oe(),o.current=!0)},[]),v.jsx("div",{role:"status","aria-label":"Loading",style:{width:`${r}px`,height:`${r}px`,border:`${e}px solid ${a}`,borderTop:`${e}px solid transparent`,borderRadius:"50%",animation:"spiceflow-spin 1s linear infinite",flexShrink:0,...t}})},Fe=({variant:r="primary",size:e="md",loading:a=!1,fullWidth:t=!1,disabled:o,children:s,className:n="",style:l,theme:d,styles:c,dark:m,...p})=>{const{theme:x,dark:B,palette:S}=K(c,m),i=d||x,u=m??B,[E,T]=h.useState(!1),[U,A]=h.useState(!1),O=u?S.shell:"white",te=()=>{switch(r){case"primary":return{backgroundColor:c?.button?.backgroundColor||i.colors.primary,color:c?.button?.color||"#ffffff",border:`1px solid ${c?.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=c?.button?.backgroundColor||i.colors.primary,L=c?.button?.color||(u?"#ffffff":"#0e0d0b"),C=c?.button?.borderColor||(u?`${i.colors.primary}88`:"#0e0d0b"),$=o||a,se=u?"1px":"1.5px",oe=c?.button?.disabledBackgroundColor||`${g}88`,ne=c?.button?.disabledColor||L;return{height:"56px",backgroundColor:$?oe:U?`${g}cc`:E?`${g}ee`:g,color:$?ne:L,border:`${se} solid ${C}`,borderRadius:c?.button?.borderRadius||"12px",fontSize:"22px",fontWeight:500,fontFamily:'"IBM Plex Mono", monospace',opacity:$?.78:1,transform:$?"none":U?"scale(0.98)":E?"translateY(-2px)":"none",boxShadow:$?`3px 3px 0px ${O}, 4px 4px 0px ${C}`:U?`2px 2px 0px ${C}`:E?`5px 5px 0px ${O}, 6px 6px 0px ${C}`:`3px 3px 0px ${O}, 4px 4px 0px ${C}`,transition:"transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease, border-color 150ms ease, color 150ms ease"}}default:return{}}},re=()=>{if(r==="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{}}},ae={borderRadius:c?.button?.borderRadius||i.borderRadius.md,fontWeight:c?.button?.fontWeight||i.typography.fontWeight.medium,fontFamily:c?.button?.fontFamily||i.typography.fontFamily,fontSize:c?.button?.fontSize||void 0,transition:"background-color 150ms ease, border-color 150ms ease, color 150ms ease, opacity 150ms ease",cursor:o||a?"not-allowed":"pointer",opacity:(o||a)&&r!=="outline"?.6:1,width:t?"100%":"auto",display:"flex",alignItems:"center",justifyContent:"center",gap:i.spacing.sm,...te(),...re(),...c?.button?.fontSize&&{fontSize:c.button.fontSize}},P=o||a;return v.jsxs("button",{type:p.type??"button","data-spiceflow-focus":!0,"aria-busy":a||void 0,"aria-disabled":P||void 0,style:{...ae,...l},className:n,disabled:P,onMouseEnter:g=>{T(!0),p.onMouseEnter?.(g)},onMouseLeave:g=>{T(!1),A(!1),p.onMouseLeave?.(g)},onMouseDown:g=>{A(!0),p.onMouseDown?.(g)},onMouseUp:g=>{A(!1),p.onMouseUp?.(g)},...p,children:[a&&v.jsx(ee,{size:16}),s]})};exports.Button=Fe,exports.CHAIN_CONFIGS=me,exports.RELAYER_API_URL=J,exports.SpiceFlowProvider=Te,exports.SpiceFlowProviderContext=X,exports.SpiceflowError=f,exports.Spinner=ee,exports.buildDarkPalette=Ue,exports.buildLightPalette=Ae,exports.createInitialSteps=$e,exports.createTheme=Q,exports.ensureSmartWallet=Ce,exports.getAllAssetsForChain=be,exports.getChainConfig=R,exports.getChainName=I,exports.getChainsForAssets=ye,exports.getClientForChain=z,exports.getDelegateContractAddress=ge,exports.getExplorerUrl=he,exports.getRpcUrlForChain=_,exports.getTokenDecimals=we,exports.hasReducedFeeOutput=Be,exports.hasStoredSpiceFlowMode=Re,exports.isSpiceflowError=ce,exports.j=j,exports.relayerService=w,exports.resolveTheme=Z,exports.useSpiceBrand=K;
|
package/dist/Button-Davf3Lcw.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import{jsx as v,jsxs as le}from"react/jsx-runtime";import{createContext as j,useEffect as N,useState as O,useCallback as ue,useContext as fe,useMemo as pe,useRef as me}from"react";import{getChainMeta as D,getTokensForChain as ge,getDelegateContract as he,ZERO_ADDRESS as ye,isNativeToken as A,getTokenByAddress as be,getChainIdsByNetwork as we}from"@spicenet-io/spiceflow-core";import{defineChain as xe,createPublicClient as Be,http as Ee,isAddress as $e,getAddress as Se,formatUnits as W}from"viem";import{readContract as ve}from"viem/actions";class f extends Error{constructor(e,a,t={}){super(a),this.code=e,this.context=t,this.name="SpiceflowError",Error.captureStackTrace&&Error.captureStackTrace(this,f)}}function Ce(r){return r instanceof f}const z=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{payable:!0,stateMutability:"payable",type:"fallback"},{anonymous:!1,inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Transfer",type:"event"}],Re="0xcA11bde05977b3631167028862bE2a173976CA11",Te={4114:"0x860aFc632a6D625B95d8B96f39ECC48E988c6962"},ke=new Set([5115]);function Ie(r){const e=Te[r.id]??(ke.has(r.id)?void 0:Re);return xe({id:r.id,name:r.name,nativeCurrency:r.nativeCurrency,rpcUrls:{default:{http:[r.rpcUrl]}},blockExplorers:{default:{name:r.displayName,url:r.blockExplorer}},testnet:r.network==="testnet",...e?{contracts:{multicall3:{address:e}}}:{}})}const Ue=[1,8453,42161,4114,11155111,421614,84532,5115,123420001114,688688,688689],C=Object.fromEntries(Ue.map(r=>D(r)).filter(r=>r!=null).map(r=>[r.id,{...r,viemChain:Ie(r),supportedTokens:ge(r.id)}])),Ne=C;let J={};const _=new Map,Y=r=>{J={...r||{}},_.clear()},M=r=>{const e=J[r];return e&&typeof e=="string"&&e.length>0?e:C[r]?.rpcUrl},$=r=>C[r],R=r=>{const e=D(r);return e?.displayName||e?.name||`Chain ${r}`},Oe=r=>{const e=he(r);if(!e)throw new Error(`Unsupported chain ID: ${r}`);return e},Ae=(r,e,a)=>{const t=$(r);return t?.blockExplorer?`${t.blockExplorer}/tx/${e}`:"#"},H=r=>{const e=$(r);if(!e)throw new Error(`Unsupported chain ID: ${r}`);const a=M(r);if(!a)throw new Error(`No RPC URL configured for chain ID: ${r}`);const t=`${r}:${a}`,o=_.get(t);if(o)return o;const s=Be({chain:e.viemChain,transport:Ee(a,{timeout:15e3,retryCount:2,retryDelay:300}),batch:{multicall:{wait:16}}});return _.set(t,s),s},_e=()=>{const r={};return Object.values(C).forEach(e=>{r[e.id]={name:e.name,moralisName:e.moralisId||"",chain:e.viemChain,rpcUrl:M(e.id)||e.rpcUrl}}),r},Me=(r,e=[])=>{const a=$(r);if(!a)return[];const t=[];if(![11155111,421614,84532,688689].includes(r)){const s=e.find(n=>n.chainId===r&&n.isNative);s?t.push(s):t.push({address:ye,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:r})}if(!a.supportedTokens)return t;const o=t.some(s=>s.isNative);return a.supportedTokens.forEach(s=>{if(o&&A(s.address))return;const n=e.find(d=>d.chainId===r&&d.address.toLowerCase()===s.address.toLowerCase());n?t.push(n):t.push({address:s.address,name:s.name,symbol:s.symbol,decimals:s.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:s.logo,isNative:!1,chainId:r})}),t},Fe=async(r,e)=>{const a=$(r);if(!a)throw new Error(`Unsupported chain ID: ${r}`);const t=e.toLowerCase();if(A(t)){if(!a.nativeCurrency?.decimals)throw new Error(`Native currency decimals not configured for chain ${r}`);return a.nativeCurrency.decimals}if(a.supportedTokens){const o=a.supportedTokens.find(s=>s.address.toLowerCase()===t);if(o)return o.decimals}try{if(!$e(e,{strict:!1}))throw new Error(`Invalid token address: ${e}`);const o=Se(e),s=H(r),n=await ve(s,{address:o,abi:z,functionName:"decimals"});return Number(n)}catch{throw new Error(`Could not determine decimals for token ${e} on chain ${r}`)}},G=typeof process<"u"&&process.env?.NEXT_PUBLIC_RELAYER_API_URL||"https://tx-api-devserver.spicenet.io",X="__SPICEFLOW_RELAYER_API_URL__";function Pe(r,e){const a=e.match(/Output amount (\d+) is insufficient after fees (\d+) on chain (\d+)/);if(!a)return e;const[,t,o,s]=a,n=Number(s),d=BigInt(t),l=BigInt(o);let c;for(const u of r.intents){const w=u.chainBatches.find(S=>S.chainId===n);if(w){c=w;break}}const m=c?.tokenTransfers.find(u=>u.from==="escrow"&&u.to.toLowerCase()===r.user.toLowerCase()&&!A(u.token));if(!m)return`Amount is too small to cover the estimated fee on ${R(n)}.`;const p=be(m.token,n),y=p?.decimals??18,b=p?.symbol??"tokens",x=W(d,y),i=W(l,y);return`Amount is too small to cover the estimated fee on ${R(n)}. Amount: ${x} ${b}. Estimated fee: ${i} ${b}.`}function Le(r){return!1}function je(){if(typeof globalThis>"u")return;const r=globalThis[X];return typeof r=="string"&&r.length>0?r:void 0}class De{constructor(){this.baseUrl=G}setBaseUrl(e){this.baseUrl=e,typeof globalThis<"u"&&(globalThis[X]=e)}getBaseUrl(){return this.getEffectiveBaseUrl()}getEffectiveBaseUrl(){return je()||this.baseUrl}async createAction(e){const a=await fetch(`${this.getEffectiveBaseUrl()}/actions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(o,s)=>typeof s=="bigint"?s.toString():s)}),t=await a.json();if(!a.ok||t.success===!1)throw new f("RELAYER_ERROR",t.error?.message||`Relayer API error: ${a.status}`,{httpStatus:a.status,responseBody:JSON.stringify(t),endpoint:"/actions"});return t}async estimateActionFees(e){const a=await fetch(`${this.getEffectiveBaseUrl()}/actions/fees/estimate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(o,s)=>typeof s=="bigint"?s.toString():s)}),t=await a.json();if(!a.ok||!t.success||!t.data?.feeEstimate){const o=t.error?.message||`Relayer fee estimate error: ${a.status}`,s=Pe(e,o);throw new f("RELAYER_ERROR",s,{httpStatus:a.status,responseBody:JSON.stringify(t),endpoint:"/actions/fees/estimate"})}return t.data.feeEstimate}async estimateBatchGas(e){const a=await fetch(`${this.getEffectiveBaseUrl()}/actions/gas/estimate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(o,s)=>typeof s=="bigint"?s.toString():s)}),t=await a.json();if(!a.ok||!t.success||!t.data?.gasFee){const o=t.error?.message||`Relayer gas estimate error: ${a.status}`;throw new f("RELAYER_ERROR",o,{httpStatus:a.status,responseBody:JSON.stringify(t),endpoint:"/actions/gas/estimate"})}return{gasFee:BigInt(t.data.gasFee),gasQuoteSource:t.data.gasQuoteSource}}async executeStep(e,a,t,o){const s=`${this.getEffectiveBaseUrl()}/actions/${e}/intents/${a}/steps/${t}`,n=fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});let d;try{d=await Promise.race([n,new Promise((c,m)=>setTimeout(()=>m(new f("RELAYER_EXECUTE_ERROR",`Execute step request timed out after ${1e4/1e3}s`,{actionId:e,intentIndex:a,stepIndex:t,endpoint:`/actions/${e}/intents/${a}/steps/${t}`})),1e4))])}catch(c){throw c}const l=await d.json();if(!d.ok||l.success===!1)throw new f("RELAYER_EXECUTE_ERROR",l.error?.message||`Execute step error: ${d.status}`,{httpStatus:d.status,responseBody:JSON.stringify(l),endpoint:`/actions/${e}/intents/${a}/steps/${t}`,actionId:e});return{success:!0,transactionHash:l.transactionHash}}async checkStepStatus(e,a){const t=e.split("/");let o="";if(t.length>=2){const d=t[0],l=t[1];o=`${this.getEffectiveBaseUrl()}/actions/${d}/intents/${l}/steps/${a}`}else o=`${this.getEffectiveBaseUrl()}/actions/${e}/intents/0/steps/${a}`;const s=await fetch(o),n=await s.json();if(!s.ok||n.success===!1)throw new f("RELAYER_STATUS_ERROR",n.error?.message||`Intent step status check failed: ${s.status}`,{httpStatus:s.status,responseBody:JSON.stringify(n),endpoint:o,intentId:e});return{success:!0,data:{status:n.status==="error"?"reverted":n.status,transactionHash:n.txid}}}async createWallet(e,a){const t=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),o=await t.json();if(!t.ok||o.success===!1)throw new f("RELAYER_ERROR",o.error?.message||`Create wallet error: ${t.status}`,{httpStatus:t.status,responseBody:JSON.stringify(o),endpoint:`/wallets/${e}`});return o}async getWallet(e){const a=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${e}`),t=await a.json();if(!a.ok||t.success===!1)throw new f("RELAYER_ERROR",t.error?.message||`Get wallet error: ${a.status}`,{httpStatus:a.status,responseBody:JSON.stringify(t),endpoint:`/wallets/${e}`});return t}async createWithdrawal(e){const a=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(o,s)=>typeof s=="bigint"?s.toString():s)}),t=await a.json();if(!a.ok||t.success===!1)throw new f("RELAYER_ERROR",t.error?.message||`Create withdrawal error: ${a.status}`,{httpStatus:a.status,responseBody:JSON.stringify(t),endpoint:"/withdrawals"});return t}async getWithdrawal(e){const a=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals/${e}`),t=await a.json();if(!a.ok||t.success===!1)throw new f("RELAYER_ERROR",t.error?.message||`Get withdrawal error: ${a.status}`,{httpStatus:a.status,responseBody:JSON.stringify(t),endpoint:`/withdrawals/${e}`});return t}async getRollupTimestamp(){const e=await fetch(`${this.getEffectiveBaseUrl()}/time`),a=await e.json();if(!e.ok||a.success===!1)throw new f("RELAYER_ERROR",a.error?.message||`Get rollup timestamp error: ${e.status}`,{httpStatus:e.status,responseBody:JSON.stringify(a),endpoint:"/time"});return a}}const h=new De,F=new Map;async function We(r,e){const a=r.toLowerCase(),t=F.get(a);if(t)return t;const o=(async()=>{try{await h.getWallet(r);return}catch{}const{unix_timestamp:s}=await h.getRollupTimestamp(),n=`I am creating a new smart wallet and adding an admin wallet ethereum:0x${r.slice(2).toLowerCase()}. Nonce: ${s}`,d=await e(n),l=typeof d=="string"?d:d.signature;if(!l)throw new Error("Wallet returned no smart wallet signature");await h.createWallet(r,{timestamp:s,signature:l})})();F.set(a,o);try{await o}finally{F.delete(a)}}const ze=(r,e)=>{const a=o=>e?e(o):R(o),t=[];return r.forEach((o,s)=>{const n=o.calls&&o.calls.length>0,d=o.tokenTransfers&&o.tokenTransfers.length>0;if(n||d){const l={stepId:s,status:s===0?"processing":"pending",chainId:o.chainId,chainName:a(o.chainId),description:"Processing transaction"};t.push(l)}}),t},q="spiceflow-mode",Q=()=>{if(typeof window>"u")return null;try{const r=window.localStorage.getItem(q);return r==="embedded"?"7702":r==="external"?"ondemand":null}catch{return null}},Je=r=>{if(!(typeof window>"u"))try{window.localStorage.setItem(q,r==="7702"?"embedded":"external")}catch{}},Ye=()=>Q()!==null,Z=j(null),K=j(null),He=({children:r,provider:e,supportedChainIds:a,network:t="testnet",mode:o="7702",skipFlow:s=[],nativeChainId:n,appName:d="Spicenet",apiUrl:l,theme:c,rpcOverrides:m})=>{N(()=>{if(!l)return;const u=h.getBaseUrl();return h.setBaseUrl(l),()=>h.setBaseUrl(u)},[l]),N(()=>(Y(m),()=>Y(void 0)),[m]);const p=a??we(t),y=c??null,[b,x]=O(()=>Q()??o),i=ue(u=>{x(u),Je(u)},[]);return v(Z.Provider,{value:y,children:v(K.Provider,{value:{provider:e,supportedChainIds:p,skipFlow:s,mode:b,setMode:i,network:t,nativeChainId:n,appName:d,apiUrl:l,rpcOverrides:m},children:r})})},Ge={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"}},Xe={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"},qe={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"},V=(r="light")=>({mode:r,...Ge,colors:r==="light"?Xe:qe});function T(r,e){const a=r.replace("#",""),t=Math.max(0,Math.round(parseInt(a.substring(0,2),16)*(1-e))),o=Math.max(0,Math.round(parseInt(a.substring(2,4),16)*(1-e))),s=Math.max(0,Math.round(parseInt(a.substring(4,6),16)*(1-e)));return`#${t.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`}function Qe(r,e){return{shell:e?.shell??"#141414",shellBorder:e?.shellBorder??T(e?.shell??"#141414",.35),shellInnerBorder:e?.shellInnerBorder??T(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 Ze(r){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 ee(r,e){const a=e?{...r,...e}:r,t=a.dark??!1,o=a.primaryColor,s=a.shell??(t?"#141414":"#ffffff");return{primaryColor:o,dark:t,fontFamily:a.fontFamily??'"Helvetica Neue", sans-serif',appName:a.appName??"Spicenet",logo:a.logo,borderRadius:a.borderRadius??"8px",shell:s,shellBorder:T(s,t?.35:.085),shellInnerBorder:T(s,t?.55:.165),card:a.card??(t?"#1e1e1e":"#f9fafb"),input:t?"#171717":"#ffffff",hover:t?"#2a2a2a":"#f3f4f6",text:a.text??(t?"#ffffff":"#111827"),textMuted:a.textMuted??(t?"#888888":"#6b7280"),inputText:t?"#e0e0e0":"#111827",inputPlaceholder:t?"#555555":"#9ca3af",border:a.border??(t?"rgba(255,255,255,0.08)":"#e5e7eb"),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":"#fde68a",warningText:t?"#fbbf24":"#92400e",errorBg:t?"#1f0d0d":"#fef2f2",errorBorder:t?"#4a2020":"#fecaca",errorText:t?"#f87171":"#dc2626",infoBg:t?"#0d1325":"#dbeafe",infoBorder:t?"#2a3a5a":"#93c5fd",infoText:t?"#60a5fa":"#1e40af"}}function te(r,e){const a=fe(Z)??void 0;return pe(()=>{const t=a??{primaryColor:"#EA4B4B"},o={...r?.primaryColor?{primaryColor:r.primaryColor}:{},...r?.fontFamily?{fontFamily:r.fontFamily}:{},...e!==void 0?{dark:e}:{}},s=ee(t,o),{dark:n,primaryColor:d,appName:l}=s,c=V(n?"dark":"light"),m={...c,colors:{...c.colors,primary:d,primaryHover:`${d}dd`},typography:{...c.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:a,theme:m,dark:n,appName:l,primaryColor:d,dk:p,palette:p}},[a,r,e])}const re="spiceflow-spinner-keyframes";function Ke(){if(typeof document>"u"||document.getElementById(re))return;const r=document.createElement("style");r.id=re,r.textContent="@keyframes spiceflow-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}",document.head.appendChild(r)}const ae=({size:r=16,borderWidth:e=2,color:a="currentColor",style:t})=>{const o=me(!1);return N(()=>{o.current||(Ke(),o.current=!0)},[]),v("div",{role:"status","aria-label":"Loading",style:{width:`${r}px`,height:`${r}px`,border:`${e}px solid ${a}`,borderTop:`${e}px solid transparent`,borderRadius:"50%",animation:"spiceflow-spin 1s linear infinite",flexShrink:0,...t}})},Ve=({variant:r="primary",size:e="md",loading:a=!1,fullWidth:t=!1,disabled:o,children:s,className:n="",style:d,theme:l,styles:c,dark:m,...p})=>{const{theme:y,dark:b,palette:x}=te(c,m),i=l||y,u=m??b,[w,S]=O(!1),[k,I]=O(!1),U=u?x.shell:"white",se=()=>{switch(r){case"primary":return{backgroundColor:c?.button?.backgroundColor||i.colors.primary,color:c?.button?.color||"#ffffff",border:`1px solid ${c?.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=c?.button?.backgroundColor||i.colors.primary,L=c?.button?.color||(u?"#ffffff":"#0e0d0b"),B=c?.button?.borderColor||(u?`${i.colors.primary}88`:"#0e0d0b"),E=o||a,ie=u?"1px":"1.5px",ce=c?.button?.disabledBackgroundColor||`${g}88`,de=c?.button?.disabledColor||L;return{height:"56px",backgroundColor:E?ce:k?`${g}cc`:w?`${g}ee`:g,color:E?de:L,border:`${ie} solid ${B}`,borderRadius:c?.button?.borderRadius||"12px",fontSize:"22px",fontWeight:500,fontFamily:'"IBM Plex Mono", monospace',opacity:E?.78:1,transform:E?"none":k?"scale(0.98)":w?"translateY(-2px)":"none",boxShadow:E?`3px 3px 0px ${U}, 4px 4px 0px ${B}`:k?`2px 2px 0px ${B}`:w?`5px 5px 0px ${U}, 6px 6px 0px ${B}`:`3px 3px 0px ${U}, 4px 4px 0px ${B}`,transition:"transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease, border-color 150ms ease, color 150ms ease"}}default:return{}}},oe=()=>{if(r==="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{}}},ne={borderRadius:c?.button?.borderRadius||i.borderRadius.md,fontWeight:c?.button?.fontWeight||i.typography.fontWeight.medium,fontFamily:c?.button?.fontFamily||i.typography.fontFamily,fontSize:c?.button?.fontSize||void 0,transition:"background-color 150ms ease, border-color 150ms ease, color 150ms ease, opacity 150ms ease",cursor:o||a?"not-allowed":"pointer",opacity:(o||a)&&r!=="outline"?.6:1,width:t?"100%":"auto",display:"flex",alignItems:"center",justifyContent:"center",gap:i.spacing.sm,...se(),...oe(),...c?.button?.fontSize&&{fontSize:c.button.fontSize}},P=o||a;return le("button",{type:p.type??"button","data-spiceflow-focus":!0,"aria-busy":a||void 0,"aria-disabled":P||void 0,style:{...ne,...d},className:n,disabled:P,onMouseEnter:g=>{S(!0),p.onMouseEnter?.(g)},onMouseLeave:g=>{S(!1),I(!1),p.onMouseLeave?.(g)},onMouseDown:g=>{I(!0),p.onMouseDown?.(g)},onMouseUp:g=>{I(!1),p.onMouseUp?.(g)},...p,children:[a&&v(ae,{size:16}),s]})};export{Ve as B,Ne as C,G as R,ae as S,_e as a,H as b,V as c,K as d,We as e,R as f,$ as g,Ae as h,Ce as i,z as j,Me as k,M as l,Oe as m,Fe as n,ze as o,f as p,Le as q,h as r,Ye as s,He as t,te as u,ee as v,Qe as w,Ze as x};
|
package/dist/utils/fees.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { FeeEstimateBatch } from "../types/unified";
|
|
2
|
-
export declare function getBatchFees(batch: FeeEstimateBatch): {
|
|
3
|
-
spicenetFee: bigint;
|
|
4
|
-
gasFee: bigint;
|
|
5
|
-
bridgeFee: bigint;
|
|
6
|
-
totalFee: bigint;
|
|
7
|
-
};
|
|
8
|
-
export declare function hasFeeValue(batch: FeeEstimateBatch): boolean;
|
|
9
|
-
export declare function getBatchGrossDebit(batch: FeeEstimateBatch): bigint;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { type Address } from "viem";
|
|
2
|
-
import type { ChainBatch } from "../../types/authorization";
|
|
3
|
-
import type { Asset } from "../../types/assets";
|
|
4
|
-
export declare const DEFAULT_BRIDGE_FEE_BUFFER_BPS = 1500;
|
|
5
|
-
export declare const DEFAULT_SQUID_INTEGRATOR_ID = "spiceflow-75f053db-70ab-4f37-83cc-abf68cb5b70d";
|
|
6
|
-
export type BridgeProvider = "cctp" | "squid";
|
|
7
|
-
export type CctpTransferMode = "fast" | "standard";
|
|
8
|
-
export interface BridgeFeeQuote {
|
|
9
|
-
provider: BridgeProvider;
|
|
10
|
-
sourceChainId: number;
|
|
11
|
-
destinationChainId: number;
|
|
12
|
-
tokenIn: Address;
|
|
13
|
-
tokenOut: Address;
|
|
14
|
-
amountIn: bigint;
|
|
15
|
-
estimatedAmountOut: bigint;
|
|
16
|
-
quotedBridgeFee: bigint;
|
|
17
|
-
bufferedBridgeFee: bigint;
|
|
18
|
-
bufferBps: number;
|
|
19
|
-
quoteId?: string;
|
|
20
|
-
route?: string;
|
|
21
|
-
minFinalityThreshold?: 1000 | 2000;
|
|
22
|
-
metadata?: Record<string, unknown>;
|
|
23
|
-
}
|
|
24
|
-
export interface SquidQuoteParams {
|
|
25
|
-
sourceChainId: number;
|
|
26
|
-
destinationChainId: number;
|
|
27
|
-
tokenIn: Address;
|
|
28
|
-
tokenOut: Address;
|
|
29
|
-
amountIn: bigint;
|
|
30
|
-
fromAddress: Address;
|
|
31
|
-
toAddress: Address;
|
|
32
|
-
integratorId?: string;
|
|
33
|
-
slippage?: number;
|
|
34
|
-
bufferBps?: number;
|
|
35
|
-
quoteOnly?: boolean;
|
|
36
|
-
baseUrl?: string;
|
|
37
|
-
fetchImpl?: typeof fetch;
|
|
38
|
-
}
|
|
39
|
-
export interface RebalancingRequestParams {
|
|
40
|
-
spicenetChainId: number;
|
|
41
|
-
recipient: Address;
|
|
42
|
-
fromChainId: number;
|
|
43
|
-
fromToken: Address;
|
|
44
|
-
fromAmount: bigint;
|
|
45
|
-
toChainId: number;
|
|
46
|
-
toToken: Address;
|
|
47
|
-
toAmountMin: bigint;
|
|
48
|
-
metadata?: Record<string, unknown>;
|
|
49
|
-
nbf?: bigint;
|
|
50
|
-
exp?: bigint;
|
|
51
|
-
idempotenceKey?: `0x${string}`;
|
|
52
|
-
}
|
|
53
|
-
export declare function quoteCctpFee(params: {
|
|
54
|
-
sourceChainId: number;
|
|
55
|
-
destinationChainId: number;
|
|
56
|
-
tokenIn: Address;
|
|
57
|
-
tokenOut: Address;
|
|
58
|
-
amountIn: bigint;
|
|
59
|
-
transferMode?: CctpTransferMode;
|
|
60
|
-
bufferBps?: number;
|
|
61
|
-
fetchImpl?: typeof fetch;
|
|
62
|
-
}): Promise<BridgeFeeQuote>;
|
|
63
|
-
export declare function quoteSquidFee(params: SquidQuoteParams): Promise<BridgeFeeQuote>;
|
|
64
|
-
export declare function buildRebalancingMetadata(params: {
|
|
65
|
-
bridgeQuote: BridgeFeeQuote;
|
|
66
|
-
sourceAsset?: Pick<Asset, "symbol" | "chainId" | "address" | "decimals">;
|
|
67
|
-
reason?: string;
|
|
68
|
-
extra?: Record<string, unknown>;
|
|
69
|
-
}): Record<string, unknown>;
|
|
70
|
-
export declare function buildRebalancingBatch(params: RebalancingRequestParams): ChainBatch;
|