@spicenet-io/spiceflow-ui 3.3.54 → 3.3.55-next.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.js +1 -1
- package/dist/auth-privy.js +1 -1
- package/dist/components/SpiceSupply/lib/buildBatches.d.ts +1 -0
- package/dist/components/SpiceSupply/lib/executors.d.ts +1 -0
- package/dist/components/SpiceSupply/lib/feePreview.d.ts +1 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/useSpiceAction.d.ts +55 -0
- package/dist/hooks/useSupplyAssets.d.ts +8 -2
- package/dist/index.cjs.js +12 -12
- package/dist/index.d.ts +8 -2
- package/dist/index.js +10 -10
- package/package.json +1 -1
- /package/dist/{Button-DPSbq78S.js → Button-BP9ffiuk.js} +0 -0
package/dist/auth-dynamic.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as g}from"react/jsx-runtime";import A,{useState as N,useEffect as f}from"react";import{B as d,c as S,g as j,S as b}from"./Button-
|
|
2
|
+
import{jsx as e,jsxs as g}from"react/jsx-runtime";import A,{useState as N,useEffect as f}from"react";import{B as d,c as S,g as j,S as b}from"./Button-BP9ffiuk.js";import{useDynamicContext as z}from"@dynamic-labs/sdk-react-core";import"@spicenet-io/spiceflow-core";import"viem";import"viem/actions";import"@tanstack/react-query";import"@privy-io/react-auth";import"wagmi";const M=({onAuthSuccess:a,onAuthError:t,theme:m="light",className:r="",buttonText:o="Login with Dynamic",autoTrigger:s=!1})=>{const i=S(m),[h,C]=N(!1),[x,E]=N(!1),L=z(),{user:W,primaryWallet:v,connectedWallets:k,handleLogOut:F,setShowAuthFlow:p,sdkHasLoaded:u,showAuthFlow:D}=L,n=(j({connectedWallets:k,primaryWallet:v})||v)?.address,w=!!W,l=w&&!!n;return f(()=>{C(!0)},[]),f(()=>{l&&n&&a&&a(n)},[l,n,a]),f(()=>{s&&u&&h&&!l&&!D&&!x&&(E(!0),p(!0))},[s,u,h,l,D,x,p]),h?u?w&&!n?e("div",{className:r,children:g("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e(b,{size:40,borderWidth:3,color:i.colors.primary}),e("p",{style:{color:i.colors.textMuted,fontSize:"14px"},children:"Finishing wallet setup..."})]})}):l&&n?e("div",{className:r,children:g(d,{variant:"primary",onClick:async()=>{try{await F()}catch(y){const c=`Dynamic logout failed: ${String(y)}`;t?t(c):console.error(c)}},theme:i,children:["Logout (",n.slice(0,6),"...",n.slice(-4),")"]})}):s?e("div",{className:r,children:g("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e(b,{size:40,borderWidth:3,color:i.colors.primary}),e("p",{style:{color:i.colors.textMuted,fontSize:"14px"},children:"Opening login..."})]})}):e("div",{className:r,children:e(d,{variant:"primary",onClick:()=>{try{p(!0)}catch(y){const c=`Dynamic login failed: ${String(y)}`;t?t(c):console.error(c)}},theme:i,children:o})}):e("div",{className:r,children:e(d,{variant:"primary",disabled:!0,theme:i,children:"Loading..."})}):e("div",{className:r,children:e(d,{variant:"primary",disabled:!0,theme:i,children:o})})};class T extends A.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}}const B=a=>{const{theme:t="light",className:m="",buttonText:r="Login with Dynamic",onAuthError:o}=a,s=S(t);return e(T,{fallback:e("div",{className:m,children:e(d,{variant:"primary",onClick:()=>{o&&o('DynamicLogin must be used within SpiceFlowProvider provider="dynamic" and a mounted DynamicContextProvider.')},theme:s,children:r})}),children:e(M,{...a})})};export{B as DynamicLogin};
|
package/dist/auth-privy.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as r,jsxs as y}from"react/jsx-runtime";import{useState as v,useEffect as c}from"react";import{B as d,c as P,S as $}from"./Button-
|
|
2
|
+
import{jsx as r,jsxs as y}from"react/jsx-runtime";import{useState as v,useEffect as c}from"react";import{B as d,c as P,S as $}from"./Button-BP9ffiuk.js";import{usePrivy as j,useLogin as w,useLogout as B}from"@privy-io/react-auth";import"@spicenet-io/spiceflow-core";import"viem";import"viem/actions";import"@tanstack/react-query";import"@dynamic-labs/sdk-react-core";import"wagmi";const T=({onAuthSuccess:m,onAuthError:n,theme:x="light",className:a="",buttonText:p="Login with Privy",autoTrigger:u=!1})=>{const l=P(x),[h,L]=v(!1),[g,b]=v(!1),{ready:o,authenticated:s,user:t}=j(),{login:S}=w(),{logout:N}=B();c(()=>{L(!0)},[]),c(()=>{u&&o&&!s&&h&&!g&&(b(!0),f())},[u,o,s,h,g]),c(()=>{if(o&&s&&t&&m){const e=t.wallet?.address||t.email?.address;e&&m(e)}},[o,s,t,m]),c(()=>{},[o,s,n]);const f=()=>{try{S()}catch(e){const i=`Login failed: ${String(e)}`;n?n(i):console.error(i)}},C=()=>{try{N()}catch(e){const i=`Logout failed: ${String(e)}`;n?n(i):console.error(i)}};if(!h)return r("div",{className:a,children:r(d,{variant:"primary",disabled:!0,theme:l,children:p})});if(!o)return r("div",{className:a,children:r(d,{variant:"primary",disabled:!0,theme:l,children:"Loading..."})});if(s&&t){const e=t.wallet?.address||t.email?.address,i=e?`${e.slice(0,6)}...${e.slice(-4)}`:"Connected";return r("div",{className:a,children:y(d,{variant:"primary",onClick:C,theme:l,children:["Logout (",i,")"]})})}return u?r("div",{className:a,children:y("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[r($,{size:40,borderWidth:3,color:"#3b82f6"}),r("p",{style:{color:"#6b7280",fontSize:"14px"},children:"Opening login..."})]})}):r("div",{className:a,children:r(d,{variant:"primary",onClick:f,theme:l,children:p})})};export{T as PrivyLogin};
|
|
@@ -16,6 +16,7 @@ export interface BatchBuilderContext {
|
|
|
16
16
|
providerEmbeddedAddress: string | null | undefined;
|
|
17
17
|
externalWalletAddress: string | null | undefined;
|
|
18
18
|
address: string | null | undefined;
|
|
19
|
+
recipient?: Address;
|
|
19
20
|
isNon7702: boolean;
|
|
20
21
|
isPayMode: boolean;
|
|
21
22
|
resolvedChainId: number;
|
|
@@ -40,6 +40,7 @@ export type ExecutorContext = {
|
|
|
40
40
|
provider: string | null | undefined;
|
|
41
41
|
resolvedChainId: number;
|
|
42
42
|
executionTokenAddress: Address;
|
|
43
|
+
recipient?: Address;
|
|
43
44
|
gasless: GaslessRunner & {
|
|
44
45
|
buildPayChainBatches: BuildPayBatchesFn;
|
|
45
46
|
buildSupplyChainBatches: BuildSupplyBatchesFn;
|
|
@@ -46,6 +46,7 @@ export interface FeePreviewContext {
|
|
|
46
46
|
resolvedSwap: ResolvedSwap | null;
|
|
47
47
|
isQuoting: boolean;
|
|
48
48
|
executionTokenAddress: Address;
|
|
49
|
+
recipient?: Address;
|
|
49
50
|
buildPayChainBatches: BuildPayBatchesFn;
|
|
50
51
|
buildSupplyChainBatches: BuildSupplyBatchesFn;
|
|
51
52
|
estimateGasless: EstimateGaslessFn;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -18,3 +18,8 @@ export { useSpiceBrand } from "./useSpiceBrand";
|
|
|
18
18
|
export { useSmartWallet } from "./useSmartWallet";
|
|
19
19
|
export { useIsUserWhitelisted } from "./useIsUserWhitelisted";
|
|
20
20
|
export type { PartnerWhitelistCheckResponse, UseIsUserWhitelistedOptions, } from "./useIsUserWhitelisted";
|
|
21
|
+
export { useSupplyAssets, isSupportedSupplyAsset } from "./useSupplyAssets";
|
|
22
|
+
export { useSupplyQuote, resolveInputSupplySwapQuote, } from "./useSupplyQuote";
|
|
23
|
+
export type { UseSupplyQuoteOpts, SupplyQuoteResult, } from "./useSupplyQuote";
|
|
24
|
+
export { useSpiceAction, useSupply, usePay, useRepay, } from "./useSpiceAction";
|
|
25
|
+
export type { UseSpiceActionOpts, UseSpiceActionReturn, SpiceActionQuote, UseSupplyOpts, UsePayOpts, UseRepayOpts, } from "./useSpiceAction";
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type Address } from "viem";
|
|
2
|
+
import { type SupplyStep, type PaymentResult } from "../components/SpiceSupply/lib/executors";
|
|
3
|
+
import type { SpiceSupplyProps, DestinationTokenConfig } from "../types/supply";
|
|
4
|
+
import type { Asset, SelectedAsset } from "../types/assets";
|
|
5
|
+
import type { FeePreview } from "../types/ui";
|
|
6
|
+
export interface UseSpiceActionOpts {
|
|
7
|
+
destinationToken: DestinationTokenConfig;
|
|
8
|
+
recipient?: Address;
|
|
9
|
+
buildActionCalls: SpiceSupplyProps["buildActionCalls"];
|
|
10
|
+
buildSpicenetBatch?: SpiceSupplyProps["buildSpicenetBatch"];
|
|
11
|
+
amountMode: "exact-input" | "exact-output";
|
|
12
|
+
amount: string;
|
|
13
|
+
sourceChains?: number[];
|
|
14
|
+
supportedSourceAssets?: string[];
|
|
15
|
+
feeExecutionMode?: SpiceSupplyProps["feeExecutionMode"];
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
onSuccess?: (txHash: string) => void;
|
|
18
|
+
onError?: (e: Error) => void;
|
|
19
|
+
}
|
|
20
|
+
export interface SpiceActionQuote {
|
|
21
|
+
isQuoting: boolean;
|
|
22
|
+
error: string | null;
|
|
23
|
+
estimatedInput: string | null;
|
|
24
|
+
estimatedOutput: string | null;
|
|
25
|
+
isDirect: boolean;
|
|
26
|
+
needsSwap: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface UseSpiceActionReturn {
|
|
29
|
+
sources: (Asset & {
|
|
30
|
+
_source?: "wallet" | "spice";
|
|
31
|
+
_fundingWallet?: "embedded" | "external";
|
|
32
|
+
})[];
|
|
33
|
+
selectedAsset: SelectedAsset | null;
|
|
34
|
+
setSelectedAsset: (a: SelectedAsset | null) => void;
|
|
35
|
+
selectAsset: (asset: Asset) => void;
|
|
36
|
+
quote: SpiceActionQuote;
|
|
37
|
+
feePreview: FeePreview | null;
|
|
38
|
+
isFeePreviewLoading: boolean;
|
|
39
|
+
feePreviewError: string | null;
|
|
40
|
+
canSubmit: boolean;
|
|
41
|
+
execute: () => Promise<void>;
|
|
42
|
+
isExecuting: boolean;
|
|
43
|
+
step: SupplyStep;
|
|
44
|
+
statusMsg: string;
|
|
45
|
+
txHash: string | null;
|
|
46
|
+
paymentResult: PaymentResult | null;
|
|
47
|
+
refreshAssets: () => void;
|
|
48
|
+
}
|
|
49
|
+
export declare function useSpiceAction(opts: UseSpiceActionOpts): UseSpiceActionReturn;
|
|
50
|
+
export type UseSupplyOpts = Omit<UseSpiceActionOpts, "amountMode">;
|
|
51
|
+
export type UsePayOpts = Omit<UseSpiceActionOpts, "amountMode">;
|
|
52
|
+
export type UseRepayOpts = Omit<UseSpiceActionOpts, "amountMode">;
|
|
53
|
+
export declare function useSupply(opts: UseSupplyOpts): UseSpiceActionReturn;
|
|
54
|
+
export declare function usePay(opts: UsePayOpts): UseSpiceActionReturn;
|
|
55
|
+
export declare function useRepay(opts: UseRepayOpts): UseSpiceActionReturn;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { type Address } from "viem";
|
|
2
2
|
import type { Asset } from "../types/assets";
|
|
3
|
-
|
|
3
|
+
type FundingWallet = "embedded" | "external";
|
|
4
|
+
type WalletSourcedAsset = Asset & {
|
|
5
|
+
_fundingWallet: FundingWallet;
|
|
6
|
+
};
|
|
7
|
+
export declare function isSupportedSupplyAsset(asset: Pick<Asset, "address" | "chainTokens" | "symbol">, supportedSourceAssets?: string[]): boolean;
|
|
4
8
|
export declare function useSupplyAssets(opts: {
|
|
5
9
|
address: string | undefined;
|
|
6
10
|
destinationToken: {
|
|
@@ -16,12 +20,14 @@ export declare function useSupplyAssets(opts: {
|
|
|
16
20
|
}): {
|
|
17
21
|
displayAssets: (Asset & {
|
|
18
22
|
_source: "wallet" | "spice";
|
|
23
|
+
_fundingWallet?: FundingWallet;
|
|
19
24
|
})[];
|
|
20
25
|
filteredSpiceAssets: Asset[];
|
|
21
|
-
walletAssets:
|
|
26
|
+
walletAssets: WalletSourcedAsset[];
|
|
22
27
|
embeddedWalletAddress: `0x${string}` | undefined;
|
|
23
28
|
externalAddress: `0x${string}` | undefined;
|
|
24
29
|
isNon7702: boolean;
|
|
25
30
|
refreshSpiceAssets: () => Promise<void>;
|
|
26
31
|
refreshWalletAssets: () => void;
|
|
27
32
|
};
|
|
33
|
+
export {};
|