@dj-test/payment-sdk 1.0.6 → 1.0.8
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 +62 -2
- package/dist/index.d.mts +52 -3
- package/dist/index.d.ts +52 -3
- package/dist/index.js +74 -25
- package/dist/index.mjs +69 -26
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -222,13 +222,73 @@ function AutoDetectPayment({ depositAddress }: { depositAddress: string }) {
|
|
|
222
222
|
|
|
223
223
|
### EVM Wallets
|
|
224
224
|
- **Injected Wallets**: MetaMask, Trust Wallet, Brave Wallet
|
|
225
|
-
- **
|
|
226
|
-
- **
|
|
225
|
+
- **Desktop**: Browser extensions (MetaMask, etc.)
|
|
226
|
+
- **Mobile Web**: In-app browsers + deep links (MetaMask app)
|
|
227
227
|
|
|
228
228
|
### Tron Wallets
|
|
229
229
|
- **TronLink**: Official Tron wallet extension
|
|
230
230
|
- **TronLink Pro**: Mobile wallet with WalletConnect support
|
|
231
231
|
|
|
232
|
+
## Mobile Web Support
|
|
233
|
+
|
|
234
|
+
SDK follows **Daimo Pay approach** for mobile web:
|
|
235
|
+
- ✅ **In-app browser detection**: Auto-detects MetaMask in-app browser
|
|
236
|
+
- ✅ **Deep link support**: Opens MetaMask app from regular mobile browsers
|
|
237
|
+
- ✅ **No WalletConnect needed**: Lightweight solution without WC dependency
|
|
238
|
+
|
|
239
|
+
### Mobile Web Flow
|
|
240
|
+
|
|
241
|
+
**Option 1: MetaMask In-App Browser** (Recommended)
|
|
242
|
+
```
|
|
243
|
+
User opens your site in MetaMask app browser
|
|
244
|
+
→ SDK detects window.ethereum
|
|
245
|
+
→ Direct wallet connection works
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
**Option 2: Regular Mobile Browser**
|
|
249
|
+
```tsx
|
|
250
|
+
import { getConnectionStrategy, openMetaMaskDeepLink } from 'payment-sdk';
|
|
251
|
+
|
|
252
|
+
function ConnectButton() {
|
|
253
|
+
const strategy = getConnectionStrategy();
|
|
254
|
+
|
|
255
|
+
const handleConnect = () => {
|
|
256
|
+
if (strategy.type === 'deeplink') {
|
|
257
|
+
// Opens MetaMask app
|
|
258
|
+
openMetaMaskDeepLink();
|
|
259
|
+
} else if (strategy.type === 'injected') {
|
|
260
|
+
// Use wagmi connect
|
|
261
|
+
connect();
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
return <button onClick={handleConnect}>{strategy.message}</button>;
|
|
266
|
+
}
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Mobile Utilities
|
|
270
|
+
|
|
271
|
+
```tsx
|
|
272
|
+
import {
|
|
273
|
+
isMobile,
|
|
274
|
+
isMetaMaskBrowser,
|
|
275
|
+
isMetaMaskAvailable,
|
|
276
|
+
shouldUseDeepLink,
|
|
277
|
+
} from 'payment-sdk';
|
|
278
|
+
|
|
279
|
+
// Check if on mobile device
|
|
280
|
+
const mobile = isMobile();
|
|
281
|
+
|
|
282
|
+
// Check if in MetaMask in-app browser
|
|
283
|
+
const inMetaMask = isMetaMaskBrowser();
|
|
284
|
+
|
|
285
|
+
// Check if MetaMask is available (extension or in-app)
|
|
286
|
+
const hasMetaMask = isMetaMaskAvailable();
|
|
287
|
+
|
|
288
|
+
// Determine if should use deep link
|
|
289
|
+
const useDeepLink = shouldUseDeepLink();
|
|
290
|
+
```
|
|
291
|
+
|
|
232
292
|
## API Reference
|
|
233
293
|
|
|
234
294
|
### PaymentProvider Props
|
package/dist/index.d.mts
CHANGED
|
@@ -1638,7 +1638,20 @@ declare const supportedChains: ({
|
|
|
1638
1638
|
};
|
|
1639
1639
|
readonly network: "base-sepolia";
|
|
1640
1640
|
})[];
|
|
1641
|
-
|
|
1641
|
+
/**
|
|
1642
|
+
* Create wagmi config following Daimo Pay approach
|
|
1643
|
+
* Uses injected connector + deep links, no WalletConnect dependency
|
|
1644
|
+
*
|
|
1645
|
+
* Mobile web flow:
|
|
1646
|
+
* 1. User clicks "Connect Wallet" in mobile browser
|
|
1647
|
+
* 2. If in MetaMask in-app browser -> injected connector detects window.ethereum
|
|
1648
|
+
* 3. If in regular browser -> Use deep link to open MetaMask app (handled by UI layer)
|
|
1649
|
+
*
|
|
1650
|
+
* Desktop flow:
|
|
1651
|
+
* 1. MetaMask extension -> injected connector detects window.ethereum
|
|
1652
|
+
* 2. Other wallets -> injected connector detects their providers
|
|
1653
|
+
*/
|
|
1654
|
+
declare const createWagmiConfig: () => Config$1;
|
|
1642
1655
|
declare const getEvmChainById: (chainId: number) => {
|
|
1643
1656
|
blockExplorers: {
|
|
1644
1657
|
readonly default: {
|
|
@@ -3594,7 +3607,6 @@ declare const PaymentModal: React.FC<PaymentModalProps>;
|
|
|
3594
3607
|
|
|
3595
3608
|
interface WalletProviderProps {
|
|
3596
3609
|
children: ReactNode;
|
|
3597
|
-
projectId?: string;
|
|
3598
3610
|
queryClient?: QueryClient;
|
|
3599
3611
|
}
|
|
3600
3612
|
declare const WalletProvider: React.FC<WalletProviderProps>;
|
|
@@ -3901,4 +3913,41 @@ declare function generatePaymentQRUrl(publicOrderId: string): string;
|
|
|
3901
3913
|
*/
|
|
3902
3914
|
declare function getPaymentDomain(): string;
|
|
3903
3915
|
|
|
3904
|
-
|
|
3916
|
+
/**
|
|
3917
|
+
* Mobile wallet utilities for deep links and mobile detection
|
|
3918
|
+
* Following Daimo Pay approach for mobile web wallet connections
|
|
3919
|
+
*/
|
|
3920
|
+
/**
|
|
3921
|
+
* Detect if user is on mobile device
|
|
3922
|
+
*/
|
|
3923
|
+
declare const isMobile: () => boolean;
|
|
3924
|
+
/**
|
|
3925
|
+
* Detect if user is in MetaMask in-app browser
|
|
3926
|
+
*/
|
|
3927
|
+
declare const isMetaMaskBrowser: () => boolean;
|
|
3928
|
+
/**
|
|
3929
|
+
* Detect if MetaMask is available (extension or in-app browser)
|
|
3930
|
+
*/
|
|
3931
|
+
declare const isMetaMaskAvailable: () => boolean;
|
|
3932
|
+
/**
|
|
3933
|
+
* Open MetaMask mobile app via deep link
|
|
3934
|
+
* Used when user is on mobile browser but not in MetaMask in-app browser
|
|
3935
|
+
*
|
|
3936
|
+
* @param returnUrl - The URL to return to after wallet connection (optional)
|
|
3937
|
+
*/
|
|
3938
|
+
declare const openMetaMaskDeepLink: (returnUrl?: string) => void;
|
|
3939
|
+
/**
|
|
3940
|
+
* Get connection strategy based on environment
|
|
3941
|
+
* Returns the recommended action for connecting wallet
|
|
3942
|
+
*/
|
|
3943
|
+
declare const getConnectionStrategy: () => {
|
|
3944
|
+
type: "injected" | "deeplink" | "unavailable";
|
|
3945
|
+
message: string;
|
|
3946
|
+
action?: () => void;
|
|
3947
|
+
};
|
|
3948
|
+
/**
|
|
3949
|
+
* Check if we should use deep link for wallet connection
|
|
3950
|
+
*/
|
|
3951
|
+
declare const shouldUseDeepLink: () => boolean;
|
|
3952
|
+
|
|
3953
|
+
export { APIError, API_ENDPOINTS, ChainType, ChainType as ChainTypes, type CoinChain, type CoinChainResponse, type ConnectorInfo, type CreateOrderParams, DEFAULT_TIMEOUT, ENVIRONMENT_URLS, ERROR_CODES, EvmWalletAdapter, type IWalletAdapter, MIN_WITHDRAWAL_AMOUNT, ORDER_EXPIRY_MINUTES, type Order, type OrderCreateRequest, type OrderDetailResponse, OrderPayment, type OrderResponse, OrderStatus, PAYMENT_DOMAINS, PayWithAddress, type PayWithAddressParams, PayWithWallet, type PayWithWalletParams, PaymentButton, PaymentContext, PaymentFlow, type PaymentMethod$1 as PaymentMethod, type PaymentMethodType, PaymentModal, type PaymentMode, PaymentProvider, PaymentQRCode, type PaymentQRCodeProps, PaymentQRModal, type PaymentQRModalProps, type PaymentSession, type PaymentStatus, type PaymentTransaction, type PaymentTransactionParams, type SDKConfig, type SDKContext, SDKError, SDK_VERSION, SUPPORTED_CHAINS, type SupportedChain, TRON_NETWORKS, type TransactionResult, type TransactionResultInfo, TronWalletAdapter, type UseWalletAdapterOptions, ValidationError, type ValidationResult, WalletAdapterFactory, type WalletBalance, type WalletConnectionInfo, type WalletInfo, WalletProvider, WalletType, WalletType as WalletTypes, type WebhookPayload, type WithdrawalParams, coins as coinsAPI, config, createWagmiConfig, detectChainType, generatePaymentQRUrl, getChainById, getConnectionStrategy, getErrorMessage, getEvmChainById, getPaymentDomain, handleAPIError, isEvmAddress, isMetaMaskAvailable, isMetaMaskBrowser, isMobile, isTronAddress, isValidAddress, openMetaMaskDeepLink, orders as ordersAPI, shouldUseDeepLink, supportedChains, supportedEvmChains, useOrder, usePayment, useWallet, useWalletAdapter, useWalletContext, validation };
|
package/dist/index.d.ts
CHANGED
|
@@ -1638,7 +1638,20 @@ declare const supportedChains: ({
|
|
|
1638
1638
|
};
|
|
1639
1639
|
readonly network: "base-sepolia";
|
|
1640
1640
|
})[];
|
|
1641
|
-
|
|
1641
|
+
/**
|
|
1642
|
+
* Create wagmi config following Daimo Pay approach
|
|
1643
|
+
* Uses injected connector + deep links, no WalletConnect dependency
|
|
1644
|
+
*
|
|
1645
|
+
* Mobile web flow:
|
|
1646
|
+
* 1. User clicks "Connect Wallet" in mobile browser
|
|
1647
|
+
* 2. If in MetaMask in-app browser -> injected connector detects window.ethereum
|
|
1648
|
+
* 3. If in regular browser -> Use deep link to open MetaMask app (handled by UI layer)
|
|
1649
|
+
*
|
|
1650
|
+
* Desktop flow:
|
|
1651
|
+
* 1. MetaMask extension -> injected connector detects window.ethereum
|
|
1652
|
+
* 2. Other wallets -> injected connector detects their providers
|
|
1653
|
+
*/
|
|
1654
|
+
declare const createWagmiConfig: () => Config$1;
|
|
1642
1655
|
declare const getEvmChainById: (chainId: number) => {
|
|
1643
1656
|
blockExplorers: {
|
|
1644
1657
|
readonly default: {
|
|
@@ -3594,7 +3607,6 @@ declare const PaymentModal: React.FC<PaymentModalProps>;
|
|
|
3594
3607
|
|
|
3595
3608
|
interface WalletProviderProps {
|
|
3596
3609
|
children: ReactNode;
|
|
3597
|
-
projectId?: string;
|
|
3598
3610
|
queryClient?: QueryClient;
|
|
3599
3611
|
}
|
|
3600
3612
|
declare const WalletProvider: React.FC<WalletProviderProps>;
|
|
@@ -3901,4 +3913,41 @@ declare function generatePaymentQRUrl(publicOrderId: string): string;
|
|
|
3901
3913
|
*/
|
|
3902
3914
|
declare function getPaymentDomain(): string;
|
|
3903
3915
|
|
|
3904
|
-
|
|
3916
|
+
/**
|
|
3917
|
+
* Mobile wallet utilities for deep links and mobile detection
|
|
3918
|
+
* Following Daimo Pay approach for mobile web wallet connections
|
|
3919
|
+
*/
|
|
3920
|
+
/**
|
|
3921
|
+
* Detect if user is on mobile device
|
|
3922
|
+
*/
|
|
3923
|
+
declare const isMobile: () => boolean;
|
|
3924
|
+
/**
|
|
3925
|
+
* Detect if user is in MetaMask in-app browser
|
|
3926
|
+
*/
|
|
3927
|
+
declare const isMetaMaskBrowser: () => boolean;
|
|
3928
|
+
/**
|
|
3929
|
+
* Detect if MetaMask is available (extension or in-app browser)
|
|
3930
|
+
*/
|
|
3931
|
+
declare const isMetaMaskAvailable: () => boolean;
|
|
3932
|
+
/**
|
|
3933
|
+
* Open MetaMask mobile app via deep link
|
|
3934
|
+
* Used when user is on mobile browser but not in MetaMask in-app browser
|
|
3935
|
+
*
|
|
3936
|
+
* @param returnUrl - The URL to return to after wallet connection (optional)
|
|
3937
|
+
*/
|
|
3938
|
+
declare const openMetaMaskDeepLink: (returnUrl?: string) => void;
|
|
3939
|
+
/**
|
|
3940
|
+
* Get connection strategy based on environment
|
|
3941
|
+
* Returns the recommended action for connecting wallet
|
|
3942
|
+
*/
|
|
3943
|
+
declare const getConnectionStrategy: () => {
|
|
3944
|
+
type: "injected" | "deeplink" | "unavailable";
|
|
3945
|
+
message: string;
|
|
3946
|
+
action?: () => void;
|
|
3947
|
+
};
|
|
3948
|
+
/**
|
|
3949
|
+
* Check if we should use deep link for wallet connection
|
|
3950
|
+
*/
|
|
3951
|
+
declare const shouldUseDeepLink: () => boolean;
|
|
3952
|
+
|
|
3953
|
+
export { APIError, API_ENDPOINTS, ChainType, ChainType as ChainTypes, type CoinChain, type CoinChainResponse, type ConnectorInfo, type CreateOrderParams, DEFAULT_TIMEOUT, ENVIRONMENT_URLS, ERROR_CODES, EvmWalletAdapter, type IWalletAdapter, MIN_WITHDRAWAL_AMOUNT, ORDER_EXPIRY_MINUTES, type Order, type OrderCreateRequest, type OrderDetailResponse, OrderPayment, type OrderResponse, OrderStatus, PAYMENT_DOMAINS, PayWithAddress, type PayWithAddressParams, PayWithWallet, type PayWithWalletParams, PaymentButton, PaymentContext, PaymentFlow, type PaymentMethod$1 as PaymentMethod, type PaymentMethodType, PaymentModal, type PaymentMode, PaymentProvider, PaymentQRCode, type PaymentQRCodeProps, PaymentQRModal, type PaymentQRModalProps, type PaymentSession, type PaymentStatus, type PaymentTransaction, type PaymentTransactionParams, type SDKConfig, type SDKContext, SDKError, SDK_VERSION, SUPPORTED_CHAINS, type SupportedChain, TRON_NETWORKS, type TransactionResult, type TransactionResultInfo, TronWalletAdapter, type UseWalletAdapterOptions, ValidationError, type ValidationResult, WalletAdapterFactory, type WalletBalance, type WalletConnectionInfo, type WalletInfo, WalletProvider, WalletType, WalletType as WalletTypes, type WebhookPayload, type WithdrawalParams, coins as coinsAPI, config, createWagmiConfig, detectChainType, generatePaymentQRUrl, getChainById, getConnectionStrategy, getErrorMessage, getEvmChainById, getPaymentDomain, handleAPIError, isEvmAddress, isMetaMaskAvailable, isMetaMaskBrowser, isMobile, isTronAddress, isValidAddress, openMetaMaskDeepLink, orders as ordersAPI, shouldUseDeepLink, supportedChains, supportedEvmChains, useOrder, usePayment, useWallet, useWalletAdapter, useWalletContext, validation };
|
package/dist/index.js
CHANGED
|
@@ -62,14 +62,20 @@ __export(index_exports, {
|
|
|
62
62
|
detectChainType: () => detectChainType,
|
|
63
63
|
generatePaymentQRUrl: () => generatePaymentQRUrl,
|
|
64
64
|
getChainById: () => getChainById,
|
|
65
|
+
getConnectionStrategy: () => getConnectionStrategy,
|
|
65
66
|
getErrorMessage: () => getErrorMessage,
|
|
66
67
|
getEvmChainById: () => getEvmChainById,
|
|
67
68
|
getPaymentDomain: () => getPaymentDomain,
|
|
68
69
|
handleAPIError: () => handleAPIError,
|
|
69
70
|
isEvmAddress: () => isEvmAddress,
|
|
71
|
+
isMetaMaskAvailable: () => isMetaMaskAvailable,
|
|
72
|
+
isMetaMaskBrowser: () => isMetaMaskBrowser,
|
|
73
|
+
isMobile: () => isMobile,
|
|
70
74
|
isTronAddress: () => isTronAddress,
|
|
71
75
|
isValidAddress: () => isValidAddress,
|
|
76
|
+
openMetaMaskDeepLink: () => openMetaMaskDeepLink,
|
|
72
77
|
ordersAPI: () => orders_exports,
|
|
78
|
+
shouldUseDeepLink: () => shouldUseDeepLink,
|
|
73
79
|
supportedChains: () => supportedChains,
|
|
74
80
|
supportedEvmChains: () => supportedEvmChains,
|
|
75
81
|
useOrder: () => useOrder,
|
|
@@ -166,28 +172,23 @@ var supportedEvmChains = [
|
|
|
166
172
|
import_chains.baseSepolia
|
|
167
173
|
];
|
|
168
174
|
var supportedChains = supportedEvmChains;
|
|
169
|
-
var createWagmiConfig = (
|
|
170
|
-
const connectors = [(0, import_connectors.injected)()];
|
|
171
|
-
if (projectId) {
|
|
172
|
-
const sdkConfig = config.getConfig();
|
|
173
|
-
const environment = sdkConfig.environment || "sandbox";
|
|
174
|
-
const paymentDomain = PAYMENT_DOMAINS[environment];
|
|
175
|
-
connectors.push(
|
|
176
|
-
(0, import_connectors.walletConnect)({
|
|
177
|
-
projectId,
|
|
178
|
-
metadata: {
|
|
179
|
-
name: "Payment SDK",
|
|
180
|
-
description: "Multi-chain Payment SDK",
|
|
181
|
-
url: paymentDomain,
|
|
182
|
-
icons: [`${paymentDomain}/icon.png`]
|
|
183
|
-
},
|
|
184
|
-
showQrModal: true
|
|
185
|
-
})
|
|
186
|
-
);
|
|
187
|
-
}
|
|
175
|
+
var createWagmiConfig = () => {
|
|
188
176
|
return (0, import_wagmi.createConfig)({
|
|
189
177
|
chains: [import_chains.mainnet, import_chains.sepolia, import_chains.polygon, import_chains.polygonAmoy, import_chains.base, import_chains.baseSepolia],
|
|
190
|
-
connectors
|
|
178
|
+
connectors: [
|
|
179
|
+
// Injected connector - works for all wallets (MetaMask, Trust Wallet, etc.)
|
|
180
|
+
// Mobile: detects in-app browser's window.ethereum
|
|
181
|
+
// Desktop: detects browser extension's window.ethereum
|
|
182
|
+
(0, import_connectors.injected)({
|
|
183
|
+
target() {
|
|
184
|
+
return {
|
|
185
|
+
id: "injected",
|
|
186
|
+
name: "Browser Wallet",
|
|
187
|
+
provider: typeof window !== "undefined" ? window.ethereum : void 0
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
})
|
|
191
|
+
],
|
|
191
192
|
transports: {
|
|
192
193
|
[import_chains.mainnet.id]: (0, import_wagmi.http)(),
|
|
193
194
|
[import_chains.sepolia.id]: (0, import_wagmi.http)(),
|
|
@@ -3515,13 +3516,9 @@ var defaultQueryClient = new import_react_query.QueryClient({
|
|
|
3515
3516
|
});
|
|
3516
3517
|
var WalletProvider = ({
|
|
3517
3518
|
children,
|
|
3518
|
-
projectId,
|
|
3519
3519
|
queryClient = defaultQueryClient
|
|
3520
3520
|
}) => {
|
|
3521
|
-
const wagmiConfig = (0, import_react12.useMemo)(
|
|
3522
|
-
() => createWagmiConfig(projectId),
|
|
3523
|
-
[projectId]
|
|
3524
|
-
);
|
|
3521
|
+
const wagmiConfig = (0, import_react12.useMemo)(() => createWagmiConfig(), []);
|
|
3525
3522
|
const adapterFactory = (0, import_react12.useMemo)(() => {
|
|
3526
3523
|
const factory = new WalletAdapterFactory();
|
|
3527
3524
|
factory.initializeEvmAdapter(wagmiConfig);
|
|
@@ -3840,6 +3837,52 @@ var useWallet = () => {
|
|
|
3840
3837
|
// EVM만 체크
|
|
3841
3838
|
};
|
|
3842
3839
|
};
|
|
3840
|
+
|
|
3841
|
+
// src/utils/mobile.ts
|
|
3842
|
+
var isMobile = () => {
|
|
3843
|
+
if (typeof window === "undefined") return false;
|
|
3844
|
+
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
|
3845
|
+
navigator.userAgent
|
|
3846
|
+
);
|
|
3847
|
+
};
|
|
3848
|
+
var isMetaMaskBrowser = () => {
|
|
3849
|
+
if (typeof window === "undefined") return false;
|
|
3850
|
+
const { ethereum } = window;
|
|
3851
|
+
return Boolean(ethereum && ethereum.isMetaMask);
|
|
3852
|
+
};
|
|
3853
|
+
var isMetaMaskAvailable = () => {
|
|
3854
|
+
if (typeof window === "undefined") return false;
|
|
3855
|
+
const { ethereum } = window;
|
|
3856
|
+
return Boolean(ethereum && ethereum.isMetaMask);
|
|
3857
|
+
};
|
|
3858
|
+
var openMetaMaskDeepLink = (returnUrl) => {
|
|
3859
|
+
if (typeof window === "undefined") return;
|
|
3860
|
+
const url = returnUrl || window.location.href;
|
|
3861
|
+
const deepLink = `https://metamask.app.link/dapp/${url.replace(/^https?:\/\//, "")}`;
|
|
3862
|
+
window.location.href = deepLink;
|
|
3863
|
+
};
|
|
3864
|
+
var getConnectionStrategy = () => {
|
|
3865
|
+
if (!isMobile() || isMetaMaskBrowser()) {
|
|
3866
|
+
if (isMetaMaskAvailable()) {
|
|
3867
|
+
return {
|
|
3868
|
+
type: "injected",
|
|
3869
|
+
message: "Connect with browser wallet"
|
|
3870
|
+
};
|
|
3871
|
+
}
|
|
3872
|
+
return {
|
|
3873
|
+
type: "unavailable",
|
|
3874
|
+
message: "Please install MetaMask extension"
|
|
3875
|
+
};
|
|
3876
|
+
}
|
|
3877
|
+
return {
|
|
3878
|
+
type: "deeplink",
|
|
3879
|
+
message: "Open in MetaMask app",
|
|
3880
|
+
action: () => openMetaMaskDeepLink()
|
|
3881
|
+
};
|
|
3882
|
+
};
|
|
3883
|
+
var shouldUseDeepLink = () => {
|
|
3884
|
+
return isMobile() && !isMetaMaskBrowser();
|
|
3885
|
+
};
|
|
3843
3886
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3844
3887
|
0 && (module.exports = {
|
|
3845
3888
|
API_ENDPOINTS,
|
|
@@ -3874,14 +3917,20 @@ var useWallet = () => {
|
|
|
3874
3917
|
detectChainType,
|
|
3875
3918
|
generatePaymentQRUrl,
|
|
3876
3919
|
getChainById,
|
|
3920
|
+
getConnectionStrategy,
|
|
3877
3921
|
getErrorMessage,
|
|
3878
3922
|
getEvmChainById,
|
|
3879
3923
|
getPaymentDomain,
|
|
3880
3924
|
handleAPIError,
|
|
3881
3925
|
isEvmAddress,
|
|
3926
|
+
isMetaMaskAvailable,
|
|
3927
|
+
isMetaMaskBrowser,
|
|
3928
|
+
isMobile,
|
|
3882
3929
|
isTronAddress,
|
|
3883
3930
|
isValidAddress,
|
|
3931
|
+
openMetaMaskDeepLink,
|
|
3884
3932
|
ordersAPI,
|
|
3933
|
+
shouldUseDeepLink,
|
|
3885
3934
|
supportedChains,
|
|
3886
3935
|
supportedEvmChains,
|
|
3887
3936
|
useOrder,
|
package/dist/index.mjs
CHANGED
|
@@ -86,7 +86,7 @@ import {
|
|
|
86
86
|
base,
|
|
87
87
|
baseSepolia
|
|
88
88
|
} from "wagmi/chains";
|
|
89
|
-
import { injected
|
|
89
|
+
import { injected } from "@wagmi/connectors";
|
|
90
90
|
var supportedEvmChains = [
|
|
91
91
|
mainnet,
|
|
92
92
|
sepolia,
|
|
@@ -96,28 +96,23 @@ var supportedEvmChains = [
|
|
|
96
96
|
baseSepolia
|
|
97
97
|
];
|
|
98
98
|
var supportedChains = supportedEvmChains;
|
|
99
|
-
var createWagmiConfig = (
|
|
100
|
-
const connectors = [injected()];
|
|
101
|
-
if (projectId) {
|
|
102
|
-
const sdkConfig = config.getConfig();
|
|
103
|
-
const environment = sdkConfig.environment || "sandbox";
|
|
104
|
-
const paymentDomain = PAYMENT_DOMAINS[environment];
|
|
105
|
-
connectors.push(
|
|
106
|
-
walletConnect({
|
|
107
|
-
projectId,
|
|
108
|
-
metadata: {
|
|
109
|
-
name: "Payment SDK",
|
|
110
|
-
description: "Multi-chain Payment SDK",
|
|
111
|
-
url: paymentDomain,
|
|
112
|
-
icons: [`${paymentDomain}/icon.png`]
|
|
113
|
-
},
|
|
114
|
-
showQrModal: true
|
|
115
|
-
})
|
|
116
|
-
);
|
|
117
|
-
}
|
|
99
|
+
var createWagmiConfig = () => {
|
|
118
100
|
return createConfig({
|
|
119
101
|
chains: [mainnet, sepolia, polygon, polygonAmoy, base, baseSepolia],
|
|
120
|
-
connectors
|
|
102
|
+
connectors: [
|
|
103
|
+
// Injected connector - works for all wallets (MetaMask, Trust Wallet, etc.)
|
|
104
|
+
// Mobile: detects in-app browser's window.ethereum
|
|
105
|
+
// Desktop: detects browser extension's window.ethereum
|
|
106
|
+
injected({
|
|
107
|
+
target() {
|
|
108
|
+
return {
|
|
109
|
+
id: "injected",
|
|
110
|
+
name: "Browser Wallet",
|
|
111
|
+
provider: typeof window !== "undefined" ? window.ethereum : void 0
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
],
|
|
121
116
|
transports: {
|
|
122
117
|
[mainnet.id]: http(),
|
|
123
118
|
[sepolia.id]: http(),
|
|
@@ -3456,13 +3451,9 @@ var defaultQueryClient = new QueryClient({
|
|
|
3456
3451
|
});
|
|
3457
3452
|
var WalletProvider = ({
|
|
3458
3453
|
children,
|
|
3459
|
-
projectId,
|
|
3460
3454
|
queryClient = defaultQueryClient
|
|
3461
3455
|
}) => {
|
|
3462
|
-
const wagmiConfig = useMemo2(
|
|
3463
|
-
() => createWagmiConfig(projectId),
|
|
3464
|
-
[projectId]
|
|
3465
|
-
);
|
|
3456
|
+
const wagmiConfig = useMemo2(() => createWagmiConfig(), []);
|
|
3466
3457
|
const adapterFactory = useMemo2(() => {
|
|
3467
3458
|
const factory = new WalletAdapterFactory();
|
|
3468
3459
|
factory.initializeEvmAdapter(wagmiConfig);
|
|
@@ -3781,6 +3772,52 @@ var useWallet = () => {
|
|
|
3781
3772
|
// EVM만 체크
|
|
3782
3773
|
};
|
|
3783
3774
|
};
|
|
3775
|
+
|
|
3776
|
+
// src/utils/mobile.ts
|
|
3777
|
+
var isMobile = () => {
|
|
3778
|
+
if (typeof window === "undefined") return false;
|
|
3779
|
+
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
|
3780
|
+
navigator.userAgent
|
|
3781
|
+
);
|
|
3782
|
+
};
|
|
3783
|
+
var isMetaMaskBrowser = () => {
|
|
3784
|
+
if (typeof window === "undefined") return false;
|
|
3785
|
+
const { ethereum } = window;
|
|
3786
|
+
return Boolean(ethereum && ethereum.isMetaMask);
|
|
3787
|
+
};
|
|
3788
|
+
var isMetaMaskAvailable = () => {
|
|
3789
|
+
if (typeof window === "undefined") return false;
|
|
3790
|
+
const { ethereum } = window;
|
|
3791
|
+
return Boolean(ethereum && ethereum.isMetaMask);
|
|
3792
|
+
};
|
|
3793
|
+
var openMetaMaskDeepLink = (returnUrl) => {
|
|
3794
|
+
if (typeof window === "undefined") return;
|
|
3795
|
+
const url = returnUrl || window.location.href;
|
|
3796
|
+
const deepLink = `https://metamask.app.link/dapp/${url.replace(/^https?:\/\//, "")}`;
|
|
3797
|
+
window.location.href = deepLink;
|
|
3798
|
+
};
|
|
3799
|
+
var getConnectionStrategy = () => {
|
|
3800
|
+
if (!isMobile() || isMetaMaskBrowser()) {
|
|
3801
|
+
if (isMetaMaskAvailable()) {
|
|
3802
|
+
return {
|
|
3803
|
+
type: "injected",
|
|
3804
|
+
message: "Connect with browser wallet"
|
|
3805
|
+
};
|
|
3806
|
+
}
|
|
3807
|
+
return {
|
|
3808
|
+
type: "unavailable",
|
|
3809
|
+
message: "Please install MetaMask extension"
|
|
3810
|
+
};
|
|
3811
|
+
}
|
|
3812
|
+
return {
|
|
3813
|
+
type: "deeplink",
|
|
3814
|
+
message: "Open in MetaMask app",
|
|
3815
|
+
action: () => openMetaMaskDeepLink()
|
|
3816
|
+
};
|
|
3817
|
+
};
|
|
3818
|
+
var shouldUseDeepLink = () => {
|
|
3819
|
+
return isMobile() && !isMetaMaskBrowser();
|
|
3820
|
+
};
|
|
3784
3821
|
export {
|
|
3785
3822
|
API_ENDPOINTS,
|
|
3786
3823
|
ChainType as ChainTypes,
|
|
@@ -3814,14 +3851,20 @@ export {
|
|
|
3814
3851
|
detectChainType,
|
|
3815
3852
|
generatePaymentQRUrl,
|
|
3816
3853
|
getChainById,
|
|
3854
|
+
getConnectionStrategy,
|
|
3817
3855
|
getErrorMessage,
|
|
3818
3856
|
getEvmChainById,
|
|
3819
3857
|
getPaymentDomain,
|
|
3820
3858
|
handleAPIError,
|
|
3821
3859
|
isEvmAddress,
|
|
3860
|
+
isMetaMaskAvailable,
|
|
3861
|
+
isMetaMaskBrowser,
|
|
3862
|
+
isMobile,
|
|
3822
3863
|
isTronAddress,
|
|
3823
3864
|
isValidAddress,
|
|
3865
|
+
openMetaMaskDeepLink,
|
|
3824
3866
|
orders_exports as ordersAPI,
|
|
3867
|
+
shouldUseDeepLink,
|
|
3825
3868
|
supportedChains,
|
|
3826
3869
|
supportedEvmChains,
|
|
3827
3870
|
useOrder,
|