@spicenet-io/spiceflow-ui 2.5.12 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{auth-dynamic-CVMjONcV.js → auth-dynamic-C-_mXQTw.js} +1 -1
- package/dist/{auth-dynamic-BcyZRUD-.js → auth-dynamic-te0UmMBN.js} +1 -1
- package/dist/auth-dynamic.cjs.js +1 -1
- package/dist/auth-dynamic.js +1 -1
- package/dist/auth-privy.js +1 -1
- package/dist/auth-starknet.cjs.js +1 -1
- package/dist/auth-starknet.js +1 -1
- package/dist/components/AccountDisplay/AccountActions.d.ts +1 -1
- package/dist/components/SpiceDeposit/DepositRecoveryPrompt.d.ts +1 -0
- package/dist/components/SpiceWithdraw/SpiceWithdraw.d.ts +7 -0
- package/dist/components/ui/SpiceModalShell.d.ts +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useGaslessExecution/index.d.ts +1 -6
- package/dist/hooks/useSmartWallet.d.ts +1 -0
- package/dist/index-CmpsCAqC.js +2 -0
- package/dist/index-Uh1tWOql.js +2 -0
- package/dist/index.cjs.js +11 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -11
- package/dist/providers/SpiceFlowProvider.d.ts +2 -0
- package/dist/types/account.d.ts +3 -0
- package/dist/types/assets.d.ts +11 -0
- package/dist/types/authorization.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/rollup.d.ts +50 -0
- package/dist/types/supply.d.ts +7 -1
- package/dist/useSpiceBrand-CIwsc5dY.js +2 -0
- package/dist/useSpiceBrand-DAo6xoE2.js +2 -0
- package/dist/utils/abis/spicenet.d.ts +49 -0
- package/dist/utils/abis/spicenetWalletManager.d.ts +566 -0
- package/dist/utils/assetDisplay.d.ts +4 -0
- package/dist/utils/chains/index.d.ts +2 -0
- package/dist/utils/logos.d.ts +2 -0
- package/dist/utils/relayer/index.d.ts +8 -14
- package/dist/utils/rollupBalances.d.ts +14 -0
- package/package.json +2 -2
- package/dist/index-BMp4DXc2.js +0 -2
- package/dist/index-CUsptR1f.js +0 -2
- package/dist/useSpiceBrand-BIKnRNEV.js +0 -2
- package/dist/useSpiceBrand-CdoJxMvK.js +0 -2
- /package/dist/{Button-DjsYc4v4.js → Button-CaguAr48.js} +0 -0
|
@@ -15,6 +15,7 @@ export declare const SpiceFlowProviderContext: React.Context<{
|
|
|
15
15
|
nativeChainId?: number;
|
|
16
16
|
appName?: string;
|
|
17
17
|
apiUrl?: string;
|
|
18
|
+
rpcOverrides?: Record<number, string>;
|
|
18
19
|
} | null>;
|
|
19
20
|
export interface SpiceFlowProviderProps {
|
|
20
21
|
children: React.ReactNode;
|
|
@@ -32,5 +33,6 @@ export interface SpiceFlowProviderProps {
|
|
|
32
33
|
appName?: string;
|
|
33
34
|
apiUrl?: string;
|
|
34
35
|
theme?: SpiceTheme;
|
|
36
|
+
rpcOverrides?: Record<number, string>;
|
|
35
37
|
}
|
|
36
38
|
export declare const SpiceFlowProvider: React.FC<SpiceFlowProviderProps>;
|
package/dist/types/account.d.ts
CHANGED
|
@@ -15,8 +15,11 @@ export interface CustomSection {
|
|
|
15
15
|
export interface SpiceAsset {
|
|
16
16
|
tokenAddress: string;
|
|
17
17
|
tokenSymbol: string;
|
|
18
|
+
tokenDisplaySymbol?: string;
|
|
19
|
+
tokenDisplayName?: string;
|
|
18
20
|
tokenDecimals: number;
|
|
19
21
|
chainId: number;
|
|
22
|
+
chainDisplayName?: string;
|
|
20
23
|
balance: string;
|
|
21
24
|
balanceFormatted: number;
|
|
22
25
|
usdValue: number;
|
package/dist/types/assets.d.ts
CHANGED
|
@@ -11,6 +11,17 @@ export interface Asset {
|
|
|
11
11
|
balanceUsd: number;
|
|
12
12
|
isNative: boolean;
|
|
13
13
|
logoURI?: string;
|
|
14
|
+
displaySymbol?: string;
|
|
15
|
+
displayName?: string;
|
|
16
|
+
displayChainName?: string;
|
|
17
|
+
receiptTokenId?: string;
|
|
18
|
+
receiptTokenName?: string;
|
|
19
|
+
receiptTokenDecimals?: number;
|
|
20
|
+
chainTokens?: Record<string, {
|
|
21
|
+
name?: string;
|
|
22
|
+
decimals?: number;
|
|
23
|
+
}>;
|
|
24
|
+
isUniversal?: boolean;
|
|
14
25
|
}
|
|
15
26
|
export interface SelectedAsset {
|
|
16
27
|
asset: Asset;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Address, Hex } from "viem";
|
|
2
|
+
export interface CreateWalletRequest {
|
|
3
|
+
timestamp: number;
|
|
4
|
+
signature: Hex;
|
|
5
|
+
}
|
|
6
|
+
export interface WalletInfo {
|
|
7
|
+
address: string;
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
export interface WithdrawalIntent {
|
|
11
|
+
chainId: string;
|
|
12
|
+
signatureType: "ecdsa";
|
|
13
|
+
signature: Hex;
|
|
14
|
+
nbf: number;
|
|
15
|
+
exp: number;
|
|
16
|
+
chainBatches: Array<{
|
|
17
|
+
hash: Hex;
|
|
18
|
+
chainId: number;
|
|
19
|
+
calls: Array<{
|
|
20
|
+
to: Address;
|
|
21
|
+
value: bigint;
|
|
22
|
+
data: Hex;
|
|
23
|
+
}>;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
export interface CreateWithdrawalRequest {
|
|
27
|
+
user?: Address;
|
|
28
|
+
intent: WithdrawalIntent;
|
|
29
|
+
}
|
|
30
|
+
export interface CreateWithdrawalResponse {
|
|
31
|
+
txHash?: string;
|
|
32
|
+
requestId?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface WithdrawalStatus {
|
|
35
|
+
state: "created" | "successful" | "failed" | "cancelled" | string;
|
|
36
|
+
idempotenceKey: string;
|
|
37
|
+
chain: string;
|
|
38
|
+
forUser: string;
|
|
39
|
+
reason?: string;
|
|
40
|
+
error?: string;
|
|
41
|
+
transfers: Array<{
|
|
42
|
+
tokenIn: string;
|
|
43
|
+
tokenOut: string;
|
|
44
|
+
recipient: string;
|
|
45
|
+
amount: number;
|
|
46
|
+
}>;
|
|
47
|
+
}
|
|
48
|
+
export interface RollupTimestamp {
|
|
49
|
+
unix_timestamp: number;
|
|
50
|
+
}
|
package/dist/types/supply.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
2
|
import type { Address } from "viem";
|
|
3
|
-
import type { Call } from "./authorization";
|
|
3
|
+
import type { Call, ChainBatch } from "./authorization";
|
|
4
4
|
import type { CustomStyles } from "./theme";
|
|
5
5
|
export interface DestinationTokenConfig {
|
|
6
6
|
address: Address;
|
|
@@ -19,6 +19,12 @@ export interface SpiceSupplyProps {
|
|
|
19
19
|
onClose: () => void;
|
|
20
20
|
destinationToken: DestinationTokenConfig;
|
|
21
21
|
buildActionCalls: (amount: bigint, ctx: BuildActionCallsContext) => Call[];
|
|
22
|
+
buildSpicenetBatch?: (params: {
|
|
23
|
+
userAddress: Address;
|
|
24
|
+
destinationChainId: number;
|
|
25
|
+
deliveryToken: Address;
|
|
26
|
+
deliveryAmount: bigint;
|
|
27
|
+
}) => ChainBatch | null;
|
|
22
28
|
actionLabel: string;
|
|
23
29
|
amountDirection?: "input" | "output";
|
|
24
30
|
swapDescription?: string;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";const l=require("react"),E=require("react/jsx-runtime"),I=require("@spicenet-io/spiceflow-core"),w=require("./index-CmpsCAqC.js"),C=require("./Button-B_UpyUH-.js");class c extends Error{constructor(e,r,t={}){super(r),this.code=e,this.context=t,this.name="SpiceflowError",Error.captureStackTrace&&Error.captureStackTrace(this,c)}}function P(o){return o instanceof c}const x=typeof process<"u"&&process.env?.NEXT_PUBLIC_RELAYER_API_URL||"https://tx-api-devserver.spicenet.io",y="__SPICEFLOW_RELAYER_API_URL__";function U(){if(typeof globalThis>"u")return;const o=globalThis[y];return typeof o=="string"&&o.length>0?o:void 0}class k{constructor(){this.baseUrl=x}setBaseUrl(e){this.baseUrl=e,typeof globalThis<"u"&&(globalThis[y]=e)}getBaseUrl(){return this.getEffectiveBaseUrl()}getEffectiveBaseUrl(){return U()||this.baseUrl}async createAction(e){console.log("[SpiceRelayer] createAction:start",{baseUrl:this.getEffectiveBaseUrl(),intentCount:e.intents.length,chainAuthorizationCount:e.chainAuthorizations?.length??0});const r=await fetch(`${this.getEffectiveBaseUrl()}/actions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(a,s)=>typeof s=="bigint"?s.toString():s)});if(!r.ok){const a=await r.text();throw console.log("[SpiceRelayer] createAction:error",{baseUrl:this.getEffectiveBaseUrl(),status:r.status,errorText:a}),new c("RELAYER_ERROR",`Relayer API error: ${r.status} - ${a}`,{httpStatus:r.status,responseBody:a,endpoint:"/actions"})}const t=await r.json();return console.log("[SpiceRelayer] createAction:success",{intentIds:t.intentIds}),t}async executeStep(e,r,t,a){const s=`${this.getEffectiveBaseUrl()}/actions/${e}/intents/${r}/steps/${t}`,d=fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});let n;try{n=await Promise.race([d,new Promise((i,f)=>setTimeout(()=>f(new c("RELAYER_EXECUTE_ERROR",`Execute step request timed out after ${1e4/1e3}s`,{actionId:e,intentIndex:r,stepIndex:t,endpoint:`/actions/${e}/intents/${r}/steps/${t}`})),1e4))])}catch(i){throw i}if(!n.ok){const i=await n.text();throw new c("RELAYER_EXECUTE_ERROR",`Execute step error: ${n.status} - ${i}`,{httpStatus:n.status,responseBody:i,endpoint:`/actions/${e}/intents/${r}/steps/${t}`,actionId:e})}return{success:!0,transactionHash:(await n.json()).transactionHash}}async checkStepStatus(e,r){const t=e.split("/");let a="";if(t.length>=2){const n=t[0],i=t[1];a=`${this.getEffectiveBaseUrl()}/actions/${n}/intents/${i}/steps/${r}`}else a=`${this.getEffectiveBaseUrl()}/actions/${e}/intents/0/steps/${r}`;const s=await fetch(a);if(!s.ok)throw new c("RELAYER_STATUS_ERROR",`Intent step status check failed: ${s.status}`,{httpStatus:s.status,endpoint:a,intentId:e});const d=await s.json();return{success:!0,data:{status:d.status==="error"?"reverted":d.status,transactionHash:d.txid}}}async requestAirdrop(e){try{const r=await fetch(`${this.getEffectiveBaseUrl()}/airdrop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tag:e.tag||"default",airdrops:[{chainId:e.chainId,tokenId:e.tokenId,wallet:e.wallet,amount:e.amount||"0.0001"}]})}),t=await r.json().catch(()=>({}));if(!r.ok){const s=t?.message||t?.errors?.[0]?.error||"Failed to request airdrop";return{success:!1,errorMessage:String(s)}}const a=t?.airdrops?.[e.chainId]?.[e.tokenId]?.txHash;return t.errors&&t.errors.length>0?{success:!1,errorMessage:t.errors[0].error}:{success:!0,txHash:a}}catch(r){return{success:!1,errorMessage:r?.message&&typeof r.message=="string"?r.message:"Failed to request airdrop"}}}async createWallet(e,r){const t=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!t.ok){const a=await t.text();throw new c("RELAYER_ERROR",`Create wallet error: ${t.status} - ${a}`,{httpStatus:t.status,endpoint:`/wallets/${e}`})}return t.json()}async getWallet(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${e}`);if(!r.ok){const t=await r.text();throw new c("RELAYER_ERROR",`Get wallet error: ${r.status} - ${t}`,{httpStatus:r.status,endpoint:`/wallets/${e}`})}return r.json()}async createWithdrawal(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(t,a)=>typeof a=="bigint"?a.toString():a)});if(!r.ok){const t=await r.text();throw new c("RELAYER_ERROR",`Create withdrawal error: ${r.status} - ${t}`,{httpStatus:r.status,endpoint:"/withdrawals"})}return r.json()}async getWithdrawal(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals/${e}`);if(!r.ok){const t=await r.text();throw new c("RELAYER_ERROR",`Get withdrawal error: ${r.status} - ${t}`,{httpStatus:r.status,endpoint:`/withdrawals/${e}`})}return r.json()}async getRollupTimestamp(){const e=await fetch(`${this.getEffectiveBaseUrl()}/time`);if(!e.ok)throw new c("RELAYER_ERROR",`Get rollup timestamp error: ${e.status}`,{httpStatus:e.status,endpoint:"/time"});return e.json()}}const h=new k,A=(o,e)=>{const r=a=>e?e(a):w.getChainName(a),t=[];return o.forEach((a,s)=>{const d=a.calls&&a.calls.length>0,n=a.tokenTransfers&&a.tokenTransfers.length>0;if(d||n){const i={stepId:s,status:s===0?"processing":"pending",chainId:a.chainId,chainName:r(a.chainId),description:"Processing transaction"};t.push(i)}}),t},R=l.createContext(null),m=l.createContext(null),_=({children:o,provider:e,supportedChainIds:r,network:t="testnet",mode:a="7702",skipFlow:s=[],nativeChainId:d,appName:n="Spicenet",apiUrl:i,theme:f,rpcOverrides:u})=>{l.useEffect(()=>{if(!i)return;const B=h.getBaseUrl();return h.setBaseUrl(i),()=>h.setBaseUrl(B)},[i]),l.useEffect(()=>(w.setRpcOverrides(u),()=>w.setRpcOverrides(void 0)),[u]);const p=r??I.getChainIdsByNetwork(t),S=f??null,[T,v]=l.useState(a),$=l.useCallback(B=>v(B),[]);return E.jsx(R.Provider,{value:S,children:E.jsx(m.Provider,{value:{provider:e,supportedChainIds:p,skipFlow:s,mode:T,setMode:$,network:t,nativeChainId:d,appName:n,apiUrl:i,rpcOverrides:u},children:o})})};function g(o,e){const r=o.replace("#",""),t=Math.max(0,Math.round(parseInt(r.substring(0,2),16)*(1-e))),a=Math.max(0,Math.round(parseInt(r.substring(2,4),16)*(1-e))),s=Math.max(0,Math.round(parseInt(r.substring(4,6),16)*(1-e)));return`#${t.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`}function O(o,e){return{shell:e?.shell??"#141414",shellBorder:e?.shellBorder??g(e?.shell??"#141414",.35),shellInnerBorder:e?.shellInnerBorder??g(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 L(o){return{shell:"#ffffff",shellBorder:"#E9E9E9",shellInnerBorder:"#D5D5D5",cardBg:"#f9fafb",inputBg:"#ffffff",hoverBg:"#f3f4f6",textPrimary:"#111827",textSecondary:"#6b7280",inputText:"#111827",inputPlaceholder:"#9ca3af",cardBorder:"#E0E0E0",inputBorder:"#d1d5db",buttonBorder:"#0e0d0b",successBg:"#d1fae5",successBorder:"#6ee7b7",successText:"#065f46",warningBg:"#fef3c7",warningBorder:"#fcd34d",warningText:"#92400e",errorBg:"#fee2e2",errorBorder:"#fca5a5",errorText:"#dc2626",infoBg:"#dbeafe",infoBorder:"#93c5fd",infoText:"#1e40af"}}function b(o,e){const r=e?{...o,...e}:o,t=r.dark??!1,a=r.primaryColor,s=r.shell??(t?"#141414":"#ffffff");return{primaryColor:a,dark:t,fontFamily:r.fontFamily??'"Helvetica Neue", sans-serif',appName:r.appName??"Spicenet",logo:r.logo,borderRadius:r.borderRadius??"8px",shell:s,shellBorder:g(s,t?.35:.085),shellInnerBorder:g(s,t?.55:.165),card:r.card??(t?"#1e1e1e":"#f9fafb"),input:t?"#171717":"#ffffff",hover:t?"#2a2a2a":"#f3f4f6",text:r.text??(t?"#ffffff":"#111827"),textMuted:r.textMuted??(t?"#888888":"#6b7280"),inputText:t?"#e0e0e0":"#111827",inputPlaceholder:t?"#555555":"#9ca3af",border:r.border??(t?"rgba(255,255,255,0.08)":"#E0E0E0"),inputBorder:t?"rgba(255,255,255,0.10)":"#d1d5db",buttonBorder:t?"rgba(255,255,255,0.12)":"#0e0d0b",successBg:t?"#0a1f18":"#d1fae5",successBorder:t?"#1a4a3a":"#6ee7b7",successText:t?"#6ee7b7":"#065f46",warningBg:t?"#1f1a0d":"#fef3c7",warningBorder:t?"#4a3820":"#fcd34d",warningText:t?"#fbbf24":"#92400e",errorBg:t?"#1f0d0d":"#fee2e2",errorBorder:t?"#4a2020":"#fca5a5",errorText:t?"#f87171":"#dc2626",infoBg:t?"#0d1325":"#dbeafe",infoBorder:t?"#2a3a5a":"#93c5fd",infoText:t?"#60a5fa":"#1e40af"}}function j(o,e){const r=l.useContext(R)??void 0;return l.useMemo(()=>{const t=r??{primaryColor:"#EA4B4B"},a={...o?.primaryColor?{primaryColor:o.primaryColor}:{},...o?.fontFamily?{fontFamily:o.fontFamily}:{},...e!==void 0?{dark:e}:{}},s=b(t,a),{dark:d,primaryColor:n,appName:i}=s,f=C.createTheme(d?"dark":"light"),u={...f,colors:{...f.colors,primary:n,primaryHover:`${n}dd`},typography:{...f.typography,fontFamily:s.fontFamily}},p={shell:s.shell,shellBorder:s.shellBorder,shellInnerBorder:s.shellInnerBorder,cardBg:s.card,inputBg:s.input,hoverBg:s.hover,textPrimary:s.text,textSecondary:s.textMuted,inputText:s.inputText,inputPlaceholder:s.inputPlaceholder,cardBorder:s.border,inputBorder:s.inputBorder,buttonBorder:s.buttonBorder,successBg:s.successBg,successBorder:s.successBorder,successText:s.successText,warningBg:s.warningBg,warningBorder:s.warningBorder,warningText:s.warningText,errorBg:s.errorBg,errorBorder:s.errorBorder,errorText:s.errorText,infoBg:s.infoBg,infoBorder:s.infoBorder,infoText:s.infoText};return{brand:r,theme:u,dark:d,appName:i,primaryColor:n,dk:p,palette:p}},[r,o,e])}exports.RELAYER_API_URL=x,exports.SpiceFlowProvider=_,exports.SpiceFlowProviderContext=m,exports.SpiceflowError=c,exports.buildDarkPalette=O,exports.buildLightPalette=L,exports.createInitialSteps=A,exports.isSpiceflowError=P,exports.relayerService=h,exports.resolveTheme=b,exports.useSpiceBrand=j;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{createContext as B,useEffect as w,useState as U,useCallback as C,useContext as k,useMemo as P}from"react";import{jsx as E}from"react/jsx-runtime";import{getChainIdsByNetwork as A}from"@spicenet-io/spiceflow-core";import{g as _,s as m}from"./index-Uh1tWOql.js";import{c as O}from"./Button-CaguAr48.js";class c extends Error{constructor(e,r,t={}){super(r),this.code=e,this.context=t,this.name="SpiceflowError",Error.captureStackTrace&&Error.captureStackTrace(this,c)}}function L(o){return o instanceof c}const x=typeof process<"u"&&process.env?.NEXT_PUBLIC_RELAYER_API_URL||"https://tx-api-devserver.spicenet.io",y="__SPICEFLOW_RELAYER_API_URL__";function N(){if(typeof globalThis>"u")return;const o=globalThis[y];return typeof o=="string"&&o.length>0?o:void 0}class j{constructor(){this.baseUrl=x}setBaseUrl(e){this.baseUrl=e,typeof globalThis<"u"&&(globalThis[y]=e)}getBaseUrl(){return this.getEffectiveBaseUrl()}getEffectiveBaseUrl(){return N()||this.baseUrl}async createAction(e){console.log("[SpiceRelayer] createAction:start",{baseUrl:this.getEffectiveBaseUrl(),intentCount:e.intents.length,chainAuthorizationCount:e.chainAuthorizations?.length??0});const r=await fetch(`${this.getEffectiveBaseUrl()}/actions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(a,s)=>typeof s=="bigint"?s.toString():s)});if(!r.ok){const a=await r.text();throw console.log("[SpiceRelayer] createAction:error",{baseUrl:this.getEffectiveBaseUrl(),status:r.status,errorText:a}),new c("RELAYER_ERROR",`Relayer API error: ${r.status} - ${a}`,{httpStatus:r.status,responseBody:a,endpoint:"/actions"})}const t=await r.json();return console.log("[SpiceRelayer] createAction:success",{intentIds:t.intentIds}),t}async executeStep(e,r,t,a){const s=`${this.getEffectiveBaseUrl()}/actions/${e}/intents/${r}/steps/${t}`,d=fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});let n;try{n=await Promise.race([d,new Promise((i,l)=>setTimeout(()=>l(new c("RELAYER_EXECUTE_ERROR",`Execute step request timed out after ${1e4/1e3}s`,{actionId:e,intentIndex:r,stepIndex:t,endpoint:`/actions/${e}/intents/${r}/steps/${t}`})),1e4))])}catch(i){throw i}if(!n.ok){const i=await n.text();throw new c("RELAYER_EXECUTE_ERROR",`Execute step error: ${n.status} - ${i}`,{httpStatus:n.status,responseBody:i,endpoint:`/actions/${e}/intents/${r}/steps/${t}`,actionId:e})}return{success:!0,transactionHash:(await n.json()).transactionHash}}async checkStepStatus(e,r){const t=e.split("/");let a="";if(t.length>=2){const n=t[0],i=t[1];a=`${this.getEffectiveBaseUrl()}/actions/${n}/intents/${i}/steps/${r}`}else a=`${this.getEffectiveBaseUrl()}/actions/${e}/intents/0/steps/${r}`;const s=await fetch(a);if(!s.ok)throw new c("RELAYER_STATUS_ERROR",`Intent step status check failed: ${s.status}`,{httpStatus:s.status,endpoint:a,intentId:e});const d=await s.json();return{success:!0,data:{status:d.status==="error"?"reverted":d.status,transactionHash:d.txid}}}async requestAirdrop(e){try{const r=await fetch(`${this.getEffectiveBaseUrl()}/airdrop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tag:e.tag||"default",airdrops:[{chainId:e.chainId,tokenId:e.tokenId,wallet:e.wallet,amount:e.amount||"0.0001"}]})}),t=await r.json().catch(()=>({}));if(!r.ok){const s=t?.message||t?.errors?.[0]?.error||"Failed to request airdrop";return{success:!1,errorMessage:String(s)}}const a=t?.airdrops?.[e.chainId]?.[e.tokenId]?.txHash;return t.errors&&t.errors.length>0?{success:!1,errorMessage:t.errors[0].error}:{success:!0,txHash:a}}catch(r){return{success:!1,errorMessage:r?.message&&typeof r.message=="string"?r.message:"Failed to request airdrop"}}}async createWallet(e,r){const t=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!t.ok){const a=await t.text();throw new c("RELAYER_ERROR",`Create wallet error: ${t.status} - ${a}`,{httpStatus:t.status,endpoint:`/wallets/${e}`})}return t.json()}async getWallet(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${e}`);if(!r.ok){const t=await r.text();throw new c("RELAYER_ERROR",`Get wallet error: ${r.status} - ${t}`,{httpStatus:r.status,endpoint:`/wallets/${e}`})}return r.json()}async createWithdrawal(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(t,a)=>typeof a=="bigint"?a.toString():a)});if(!r.ok){const t=await r.text();throw new c("RELAYER_ERROR",`Create withdrawal error: ${r.status} - ${t}`,{httpStatus:r.status,endpoint:"/withdrawals"})}return r.json()}async getWithdrawal(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals/${e}`);if(!r.ok){const t=await r.text();throw new c("RELAYER_ERROR",`Get withdrawal error: ${r.status} - ${t}`,{httpStatus:r.status,endpoint:`/withdrawals/${e}`})}return r.json()}async getRollupTimestamp(){const e=await fetch(`${this.getEffectiveBaseUrl()}/time`);if(!e.ok)throw new c("RELAYER_ERROR",`Get rollup timestamp error: ${e.status}`,{httpStatus:e.status,endpoint:"/time"});return e.json()}}const p=new j,F=(o,e)=>{const r=a=>e?e(a):_(a),t=[];return o.forEach((a,s)=>{const d=a.calls&&a.calls.length>0,n=a.tokenTransfers&&a.tokenTransfers.length>0;if(d||n){const i={stepId:s,status:s===0?"processing":"pending",chainId:a.chainId,chainName:r(a.chainId),description:"Processing transaction"};t.push(i)}}),t},R=B(null),b=B(null),M=({children:o,provider:e,supportedChainIds:r,network:t="testnet",mode:a="7702",skipFlow:s=[],nativeChainId:d,appName:n="Spicenet",apiUrl:i,theme:l,rpcOverrides:f})=>{w(()=>{if(!i)return;const g=p.getBaseUrl();return p.setBaseUrl(i),()=>p.setBaseUrl(g)},[i]),w(()=>(m(f),()=>m(void 0)),[f]);const u=r??A(t),S=l??null,[$,v]=U(a),I=C(g=>v(g),[]);return E(R.Provider,{value:S,children:E(b.Provider,{value:{provider:e,supportedChainIds:u,skipFlow:s,mode:$,setMode:I,network:t,nativeChainId:d,appName:n,apiUrl:i,rpcOverrides:f},children:o})})};function h(o,e){const r=o.replace("#",""),t=Math.max(0,Math.round(parseInt(r.substring(0,2),16)*(1-e))),a=Math.max(0,Math.round(parseInt(r.substring(2,4),16)*(1-e))),s=Math.max(0,Math.round(parseInt(r.substring(4,6),16)*(1-e)));return`#${t.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`}function Y(o,e){return{shell:e?.shell??"#141414",shellBorder:e?.shellBorder??h(e?.shell??"#141414",.35),shellInnerBorder:e?.shellInnerBorder??h(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 H(o){return{shell:"#ffffff",shellBorder:"#E9E9E9",shellInnerBorder:"#D5D5D5",cardBg:"#f9fafb",inputBg:"#ffffff",hoverBg:"#f3f4f6",textPrimary:"#111827",textSecondary:"#6b7280",inputText:"#111827",inputPlaceholder:"#9ca3af",cardBorder:"#E0E0E0",inputBorder:"#d1d5db",buttonBorder:"#0e0d0b",successBg:"#d1fae5",successBorder:"#6ee7b7",successText:"#065f46",warningBg:"#fef3c7",warningBorder:"#fcd34d",warningText:"#92400e",errorBg:"#fee2e2",errorBorder:"#fca5a5",errorText:"#dc2626",infoBg:"#dbeafe",infoBorder:"#93c5fd",infoText:"#1e40af"}}function T(o,e){const r=e?{...o,...e}:o,t=r.dark??!1,a=r.primaryColor,s=r.shell??(t?"#141414":"#ffffff");return{primaryColor:a,dark:t,fontFamily:r.fontFamily??'"Helvetica Neue", sans-serif',appName:r.appName??"Spicenet",logo:r.logo,borderRadius:r.borderRadius??"8px",shell:s,shellBorder:h(s,t?.35:.085),shellInnerBorder:h(s,t?.55:.165),card:r.card??(t?"#1e1e1e":"#f9fafb"),input:t?"#171717":"#ffffff",hover:t?"#2a2a2a":"#f3f4f6",text:r.text??(t?"#ffffff":"#111827"),textMuted:r.textMuted??(t?"#888888":"#6b7280"),inputText:t?"#e0e0e0":"#111827",inputPlaceholder:t?"#555555":"#9ca3af",border:r.border??(t?"rgba(255,255,255,0.08)":"#E0E0E0"),inputBorder:t?"rgba(255,255,255,0.10)":"#d1d5db",buttonBorder:t?"rgba(255,255,255,0.12)":"#0e0d0b",successBg:t?"#0a1f18":"#d1fae5",successBorder:t?"#1a4a3a":"#6ee7b7",successText:t?"#6ee7b7":"#065f46",warningBg:t?"#1f1a0d":"#fef3c7",warningBorder:t?"#4a3820":"#fcd34d",warningText:t?"#fbbf24":"#92400e",errorBg:t?"#1f0d0d":"#fee2e2",errorBorder:t?"#4a2020":"#fca5a5",errorText:t?"#f87171":"#dc2626",infoBg:t?"#0d1325":"#dbeafe",infoBorder:t?"#2a3a5a":"#93c5fd",infoText:t?"#60a5fa":"#1e40af"}}function J(o,e){const r=k(R)??void 0;return P(()=>{const t=r??{primaryColor:"#EA4B4B"},a={...o?.primaryColor?{primaryColor:o.primaryColor}:{},...o?.fontFamily?{fontFamily:o.fontFamily}:{},...e!==void 0?{dark:e}:{}},s=T(t,a),{dark:d,primaryColor:n,appName:i}=s,l=O(d?"dark":"light"),f={...l,colors:{...l.colors,primary:n,primaryHover:`${n}dd`},typography:{...l.typography,fontFamily:s.fontFamily}},u={shell:s.shell,shellBorder:s.shellBorder,shellInnerBorder:s.shellInnerBorder,cardBg:s.card,inputBg:s.input,hoverBg:s.hover,textPrimary:s.text,textSecondary:s.textMuted,inputText:s.inputText,inputPlaceholder:s.inputPlaceholder,cardBorder:s.border,inputBorder:s.inputBorder,buttonBorder:s.buttonBorder,successBg:s.successBg,successBorder:s.successBorder,successText:s.successText,warningBg:s.warningBg,warningBorder:s.warningBorder,warningText:s.warningText,errorBg:s.errorBg,errorBorder:s.errorBorder,errorText:s.errorText,infoBg:s.infoBg,infoBorder:s.infoBorder,infoText:s.infoText};return{brand:r,theme:f,dark:d,appName:i,primaryColor:n,dk:u,palette:u}},[r,o,e])}export{x as R,b as S,H as a,Y as b,F as c,c as d,M as e,T as f,L as i,p as r,J as u};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export declare const spicenetAbi: readonly [{
|
|
2
|
+
readonly type: "function";
|
|
3
|
+
readonly name: "createWithdrawalRequest";
|
|
4
|
+
readonly inputs: readonly [{
|
|
5
|
+
readonly name: "request";
|
|
6
|
+
readonly type: "tuple";
|
|
7
|
+
readonly internalType: "struct Spicenet.CreateWithdrawalRequestArgs";
|
|
8
|
+
readonly components: readonly [{
|
|
9
|
+
readonly name: "chainId";
|
|
10
|
+
readonly type: "string";
|
|
11
|
+
readonly internalType: "string";
|
|
12
|
+
}, {
|
|
13
|
+
readonly name: "idempotenceKey";
|
|
14
|
+
readonly type: "bytes32";
|
|
15
|
+
readonly internalType: "bytes32";
|
|
16
|
+
}, {
|
|
17
|
+
readonly name: "nbf";
|
|
18
|
+
readonly type: "uint256";
|
|
19
|
+
readonly internalType: "uint256";
|
|
20
|
+
}, {
|
|
21
|
+
readonly name: "exp";
|
|
22
|
+
readonly type: "uint256";
|
|
23
|
+
readonly internalType: "uint256";
|
|
24
|
+
}, {
|
|
25
|
+
readonly name: "metadata";
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
readonly internalType: "string";
|
|
28
|
+
}, {
|
|
29
|
+
readonly name: "transfers";
|
|
30
|
+
readonly type: "tuple[]";
|
|
31
|
+
readonly internalType: "struct Spicenet.CreateTokenTransfer[]";
|
|
32
|
+
readonly components: readonly [{
|
|
33
|
+
readonly name: "token";
|
|
34
|
+
readonly type: "string";
|
|
35
|
+
readonly internalType: "string";
|
|
36
|
+
}, {
|
|
37
|
+
readonly name: "to";
|
|
38
|
+
readonly type: "string";
|
|
39
|
+
readonly internalType: "string";
|
|
40
|
+
}, {
|
|
41
|
+
readonly name: "amount";
|
|
42
|
+
readonly type: "uint256";
|
|
43
|
+
readonly internalType: "uint256";
|
|
44
|
+
}];
|
|
45
|
+
}];
|
|
46
|
+
}];
|
|
47
|
+
readonly outputs: readonly [];
|
|
48
|
+
readonly stateMutability: "nonpayable";
|
|
49
|
+
}];
|