@spicenet-io/spiceflow-ui 1.2.0 → 1.2.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/dist/auth-dynamic.js +1 -1
- package/dist/auth-privy.js +1 -1
- package/dist/components/SpiceDeposit/SpiceDeposit.d.ts +2 -3
- package/dist/components/SpiceDeposit/index.d.ts +1 -1
- package/dist/index.cjs.js +15 -36
- package/dist/index.js +16 -37
- package/package.json +11 -11
- /package/dist/{Button-aWXByNBC.js → Button-RifBkofT.js} +0 -0
package/dist/auth-dynamic.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import React, { useEffect, useState, useCallback } from 'react';
|
|
4
|
-
import { c as createTheme, B as Button } from './Button-
|
|
4
|
+
import { c as createTheme, B as Button } from './Button-RifBkofT.js';
|
|
5
5
|
import { useDynamicContext, useConnectWithOtp } from '@dynamic-labs/sdk-react-core';
|
|
6
6
|
|
|
7
7
|
const Input = ({
|
package/dist/auth-privy.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { useState, useEffect } from 'react';
|
|
4
|
-
import { B as Button, c as createTheme } from './Button-
|
|
4
|
+
import { B as Button, c as createTheme } from './Button-RifBkofT.js';
|
|
5
5
|
import { usePrivy, useLogin, useLogout } from '@privy-io/react-auth';
|
|
6
6
|
|
|
7
7
|
const PrivyLogin = ({
|
|
@@ -15,8 +15,7 @@ export interface SpiceDepositProps {
|
|
|
15
15
|
destinationTokenAddress?: string;
|
|
16
16
|
postDepositInstruction?: (bridgedAmount: string) => Promise<void> | void;
|
|
17
17
|
postDepositInstructionLabel?: string;
|
|
18
|
+
useInternalWagmi?: boolean;
|
|
18
19
|
}
|
|
19
20
|
export declare const SpiceDepositFlow: React.FC<SpiceDepositProps>;
|
|
20
|
-
export declare const SpiceDeposit: React.FC<SpiceDepositProps
|
|
21
|
-
useInternalWagmi?: boolean;
|
|
22
|
-
}>;
|
|
21
|
+
export declare const SpiceDeposit: React.FC<SpiceDepositProps>;
|
|
@@ -2,4 +2,4 @@ import { SelectChainModal } from "./SelectChainModal";
|
|
|
2
2
|
import { ConnectWalletModal } from "./ConnectWalletModal";
|
|
3
3
|
import { DepositModal } from "./DepositModal";
|
|
4
4
|
import { SpiceDeposit, SpiceDepositFlow } from "./SpiceDeposit";
|
|
5
|
-
export { SelectChainModal, ConnectWalletModal, DepositModal, SpiceDeposit, SpiceDepositFlow };
|
|
5
|
+
export { SelectChainModal, ConnectWalletModal, DepositModal, SpiceDeposit, SpiceDepositFlow, };
|
package/dist/index.cjs.js
CHANGED
|
@@ -6012,7 +6012,7 @@ const DepositModal = React.memo(
|
|
|
6012
6012
|
const address = embeddedWalletAddress || embeddedWallet?.address;
|
|
6013
6013
|
const sourceAddress = externalWalletAddress;
|
|
6014
6014
|
const { data: externalWalletClient } = wagmi.useWalletClient();
|
|
6015
|
-
|
|
6015
|
+
wagmi.useSwitchChain();
|
|
6016
6016
|
const { chain: currentChain } = wagmi.useAccount();
|
|
6017
6017
|
const currentChainRef = React.useRef(currentChain);
|
|
6018
6018
|
React.useEffect(() => {
|
|
@@ -6181,6 +6181,11 @@ const DepositModal = React.memo(
|
|
|
6181
6181
|
});
|
|
6182
6182
|
setShowConfirmation(true);
|
|
6183
6183
|
};
|
|
6184
|
+
const isChainMismatchError = (error2) => {
|
|
6185
|
+
const errorMessage = error2?.message || error2?.shortMessage || error2?.details || error2?.cause?.message || error2?.reason || String(error2 || "");
|
|
6186
|
+
const errorString = errorMessage.toLowerCase();
|
|
6187
|
+
return errorString.includes("does not match") || errorString.includes("current chain") || errorString.includes("expected chain") || errorString.includes("chain mismatch") || errorString.includes("target chain") || errorString.includes("the current chain of the wallet") || errorString.includes("chain of the wallet") || errorString.includes("chain") && errorString.includes("match") && errorString.includes("id") || error2?.code && error2.code === 4902 || error2?.name === "ChainMismatchError" || error2?.name === "ChainMismatch";
|
|
6188
|
+
};
|
|
6184
6189
|
const executeDeposit = async () => {
|
|
6185
6190
|
const validAssets = selectedDepositAssets.filter(
|
|
6186
6191
|
(a) => a.asset && a.amount && parseFloat(a.amount) > 0
|
|
@@ -6214,36 +6219,6 @@ const DepositModal = React.memo(
|
|
|
6214
6219
|
if (!externalWalletClient) {
|
|
6215
6220
|
throw new Error("External wallet not connected");
|
|
6216
6221
|
}
|
|
6217
|
-
if (currentChain?.id !== chainId) {
|
|
6218
|
-
setError("Wrong chain selected. Switching network...");
|
|
6219
|
-
try {
|
|
6220
|
-
await switchChainAsync({ chainId });
|
|
6221
|
-
let attempts = 0;
|
|
6222
|
-
const maxAttempts = 20;
|
|
6223
|
-
while (attempts < maxAttempts) {
|
|
6224
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
6225
|
-
if (currentChainRef.current?.id === chainId) {
|
|
6226
|
-
setError(null);
|
|
6227
|
-
break;
|
|
6228
|
-
}
|
|
6229
|
-
attempts++;
|
|
6230
|
-
}
|
|
6231
|
-
if (currentChainRef.current?.id !== chainId) {
|
|
6232
|
-
throw new Error(
|
|
6233
|
-
`Failed to switch to chain ${chainId}. Please switch manually in your wallet.`
|
|
6234
|
-
);
|
|
6235
|
-
}
|
|
6236
|
-
setError(null);
|
|
6237
|
-
} catch (switchError) {
|
|
6238
|
-
if (switchError.code === 4902 || switchError.name === "ChainNotConfiguredError") {
|
|
6239
|
-
throw new Error(
|
|
6240
|
-
`Chain ${chainId} is not configured in your wallet. Please add it manually.`
|
|
6241
|
-
);
|
|
6242
|
-
} else {
|
|
6243
|
-
throw switchError;
|
|
6244
|
-
}
|
|
6245
|
-
}
|
|
6246
|
-
}
|
|
6247
6222
|
if (nonEip7702Mode) {
|
|
6248
6223
|
if (!destinationChainId) {
|
|
6249
6224
|
throw new Error(
|
|
@@ -6517,16 +6492,20 @@ const DepositModal = React.memo(
|
|
|
6517
6492
|
}
|
|
6518
6493
|
} catch (error2) {
|
|
6519
6494
|
hasError = true;
|
|
6495
|
+
const errorMsgText = error2?.message || error2?.shortMessage || error2?.details || error2?.cause?.message || String(error2 || "");
|
|
6520
6496
|
let errorMessage = "Deposit failed";
|
|
6521
|
-
if (error2
|
|
6497
|
+
if (isChainMismatchError(error2)) {
|
|
6498
|
+
const chainId = validAssets[0]?.asset?.chainId;
|
|
6499
|
+
const chainConfig = chainId ? getChainConfig(chainId) : null;
|
|
6500
|
+
const chainName = chainConfig?.displayName || `Chain ${chainId}`;
|
|
6501
|
+
errorMessage = `Wrong network selected. Please switch your wallet to ${chainName} and click the DEPOSIT button again.`;
|
|
6502
|
+
} else if (error2?.code === 4001 || error2?.code === "ACTION_REJECTED") {
|
|
6522
6503
|
errorMessage = "Transaction rejected by user";
|
|
6523
6504
|
} else if (error2?.code === -32603) {
|
|
6524
6505
|
errorMessage = "Internal wallet error. Please try again.";
|
|
6525
|
-
} else if (
|
|
6506
|
+
} else if (errorMsgText.toLowerCase().includes("insufficient funds")) {
|
|
6526
6507
|
errorMessage = "Insufficient funds for transaction";
|
|
6527
|
-
} else if (
|
|
6528
|
-
errorMessage = "Transaction rejected by user";
|
|
6529
|
-
} else if (error2?.message?.includes("user rejected")) {
|
|
6508
|
+
} else if (errorMsgText.toLowerCase().includes("user rejected")) {
|
|
6530
6509
|
errorMessage = "Transaction rejected by user";
|
|
6531
6510
|
} else if (error2 instanceof Error) {
|
|
6532
6511
|
errorMessage = error2.message;
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import React, { useState, useRef, useEffect, useCallback, createContext, useContext, useTransition, forwardRef, createElement, useMemo } from 'react';
|
|
4
4
|
import { defineChain, createPublicClient, http, parseEther, parseUnits, encodeFunctionData } from 'viem';
|
|
5
|
-
import { c as createTheme, B as Button, d as defaultTheme } from './Button-
|
|
5
|
+
import { c as createTheme, B as Button, d as defaultTheme } from './Button-RifBkofT.js';
|
|
6
6
|
import { getBalance } from 'viem/actions';
|
|
7
7
|
import { basecampTestnet, citreaTestnet, baseSepolia, arbitrumSepolia, sepolia } from 'viem/chains';
|
|
8
8
|
import { createPortal } from 'react-dom';
|
|
@@ -6010,7 +6010,7 @@ const DepositModal = React.memo(
|
|
|
6010
6010
|
const address = embeddedWalletAddress || embeddedWallet?.address;
|
|
6011
6011
|
const sourceAddress = externalWalletAddress;
|
|
6012
6012
|
const { data: externalWalletClient } = useWalletClient();
|
|
6013
|
-
|
|
6013
|
+
useSwitchChain();
|
|
6014
6014
|
const { chain: currentChain } = useAccount();
|
|
6015
6015
|
const currentChainRef = React.useRef(currentChain);
|
|
6016
6016
|
React.useEffect(() => {
|
|
@@ -6179,6 +6179,11 @@ const DepositModal = React.memo(
|
|
|
6179
6179
|
});
|
|
6180
6180
|
setShowConfirmation(true);
|
|
6181
6181
|
};
|
|
6182
|
+
const isChainMismatchError = (error2) => {
|
|
6183
|
+
const errorMessage = error2?.message || error2?.shortMessage || error2?.details || error2?.cause?.message || error2?.reason || String(error2 || "");
|
|
6184
|
+
const errorString = errorMessage.toLowerCase();
|
|
6185
|
+
return errorString.includes("does not match") || errorString.includes("current chain") || errorString.includes("expected chain") || errorString.includes("chain mismatch") || errorString.includes("target chain") || errorString.includes("the current chain of the wallet") || errorString.includes("chain of the wallet") || errorString.includes("chain") && errorString.includes("match") && errorString.includes("id") || error2?.code && error2.code === 4902 || error2?.name === "ChainMismatchError" || error2?.name === "ChainMismatch";
|
|
6186
|
+
};
|
|
6182
6187
|
const executeDeposit = async () => {
|
|
6183
6188
|
const validAssets = selectedDepositAssets.filter(
|
|
6184
6189
|
(a) => a.asset && a.amount && parseFloat(a.amount) > 0
|
|
@@ -6212,36 +6217,6 @@ const DepositModal = React.memo(
|
|
|
6212
6217
|
if (!externalWalletClient) {
|
|
6213
6218
|
throw new Error("External wallet not connected");
|
|
6214
6219
|
}
|
|
6215
|
-
if (currentChain?.id !== chainId) {
|
|
6216
|
-
setError("Wrong chain selected. Switching network...");
|
|
6217
|
-
try {
|
|
6218
|
-
await switchChainAsync({ chainId });
|
|
6219
|
-
let attempts = 0;
|
|
6220
|
-
const maxAttempts = 20;
|
|
6221
|
-
while (attempts < maxAttempts) {
|
|
6222
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
6223
|
-
if (currentChainRef.current?.id === chainId) {
|
|
6224
|
-
setError(null);
|
|
6225
|
-
break;
|
|
6226
|
-
}
|
|
6227
|
-
attempts++;
|
|
6228
|
-
}
|
|
6229
|
-
if (currentChainRef.current?.id !== chainId) {
|
|
6230
|
-
throw new Error(
|
|
6231
|
-
`Failed to switch to chain ${chainId}. Please switch manually in your wallet.`
|
|
6232
|
-
);
|
|
6233
|
-
}
|
|
6234
|
-
setError(null);
|
|
6235
|
-
} catch (switchError) {
|
|
6236
|
-
if (switchError.code === 4902 || switchError.name === "ChainNotConfiguredError") {
|
|
6237
|
-
throw new Error(
|
|
6238
|
-
`Chain ${chainId} is not configured in your wallet. Please add it manually.`
|
|
6239
|
-
);
|
|
6240
|
-
} else {
|
|
6241
|
-
throw switchError;
|
|
6242
|
-
}
|
|
6243
|
-
}
|
|
6244
|
-
}
|
|
6245
6220
|
if (nonEip7702Mode) {
|
|
6246
6221
|
if (!destinationChainId) {
|
|
6247
6222
|
throw new Error(
|
|
@@ -6515,16 +6490,20 @@ const DepositModal = React.memo(
|
|
|
6515
6490
|
}
|
|
6516
6491
|
} catch (error2) {
|
|
6517
6492
|
hasError = true;
|
|
6493
|
+
const errorMsgText = error2?.message || error2?.shortMessage || error2?.details || error2?.cause?.message || String(error2 || "");
|
|
6518
6494
|
let errorMessage = "Deposit failed";
|
|
6519
|
-
if (error2
|
|
6495
|
+
if (isChainMismatchError(error2)) {
|
|
6496
|
+
const chainId = validAssets[0]?.asset?.chainId;
|
|
6497
|
+
const chainConfig = chainId ? getChainConfig(chainId) : null;
|
|
6498
|
+
const chainName = chainConfig?.displayName || `Chain ${chainId}`;
|
|
6499
|
+
errorMessage = `Wrong network selected. Please switch your wallet to ${chainName} and click the DEPOSIT button again.`;
|
|
6500
|
+
} else if (error2?.code === 4001 || error2?.code === "ACTION_REJECTED") {
|
|
6520
6501
|
errorMessage = "Transaction rejected by user";
|
|
6521
6502
|
} else if (error2?.code === -32603) {
|
|
6522
6503
|
errorMessage = "Internal wallet error. Please try again.";
|
|
6523
|
-
} else if (
|
|
6504
|
+
} else if (errorMsgText.toLowerCase().includes("insufficient funds")) {
|
|
6524
6505
|
errorMessage = "Insufficient funds for transaction";
|
|
6525
|
-
} else if (
|
|
6526
|
-
errorMessage = "Transaction rejected by user";
|
|
6527
|
-
} else if (error2?.message?.includes("user rejected")) {
|
|
6506
|
+
} else if (errorMsgText.toLowerCase().includes("user rejected")) {
|
|
6528
6507
|
errorMessage = "Transaction rejected by user";
|
|
6529
6508
|
} else if (error2 instanceof Error) {
|
|
6530
6509
|
errorMessage = error2.message;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spicenet-io/spiceflow-ui",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Spiceflow UI SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
@@ -71,14 +71,14 @@
|
|
|
71
71
|
"tslib": "^2.8.1"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
|
-
"@dynamic-labs/ethereum": ">=3.9.13",
|
|
75
|
-
"@dynamic-labs/sdk-react-core": ">=3.9.13",
|
|
76
|
-
"@dynamic-labs/wallet-connector-core": ">=3.9.13",
|
|
77
|
-
"@privy-io/react-auth": ">=2.24.0",
|
|
74
|
+
"@dynamic-labs/ethereum": ">=3.9.13 <5.0.0",
|
|
75
|
+
"@dynamic-labs/sdk-react-core": ">=3.9.13 <5.0.0",
|
|
76
|
+
"@dynamic-labs/wallet-connector-core": ">=3.9.13 <5.0.0",
|
|
77
|
+
"@privy-io/react-auth": ">=2.24.0 <4.0.0",
|
|
78
78
|
"@tanstack/react-query": ">=5.0.0",
|
|
79
79
|
"axios": ">=1.0.0",
|
|
80
|
-
"react": "
|
|
81
|
-
"react-dom": "
|
|
80
|
+
"react": "^18.0.0",
|
|
81
|
+
"react-dom": "^18.0.0",
|
|
82
82
|
"spiceflow-core-test": ">=0.1.0",
|
|
83
83
|
"viem": ">=2.21.0",
|
|
84
84
|
"wagmi": ">=2.12.0"
|
|
@@ -113,8 +113,8 @@
|
|
|
113
113
|
"rollup-plugin-esbuild": "^6.1.1",
|
|
114
114
|
"@tanstack/react-query": "^5.90.5",
|
|
115
115
|
"@types/node": "^24.3.0",
|
|
116
|
-
"@types/react": "^
|
|
117
|
-
"@types/react-dom": "^
|
|
116
|
+
"@types/react": "^18.3.3",
|
|
117
|
+
"@types/react-dom": "^18.3.0",
|
|
118
118
|
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
119
119
|
"@typescript-eslint/parser": "^6.0.0",
|
|
120
120
|
"eslint": "^8.45.0",
|
|
@@ -127,8 +127,8 @@
|
|
|
127
127
|
"postcss-import": "^16.1.1",
|
|
128
128
|
"prettier": "3.6.2",
|
|
129
129
|
"jest": "^29.6.0",
|
|
130
|
-
"react": "^
|
|
131
|
-
"react-dom": "^
|
|
130
|
+
"react": "^18.3.1",
|
|
131
|
+
"react-dom": "^18.3.1",
|
|
132
132
|
"rollup": "^4.50.0",
|
|
133
133
|
"rollup-plugin-copy": "^3.5.0",
|
|
134
134
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
File without changes
|