@yodlpay/react-native 0.1.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/README.md +377 -0
- package/dist/index.cjs +174 -0
- package/dist/index.d.cts +128 -0
- package/dist/index.d.mts +128 -0
- package/dist/index.mjs +175 -0
- package/metro-config.cjs +96 -0
- package/package.json +76 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { ReactNode, RefObject } from "react";
|
|
2
|
+
import { ViewStyle } from "react-native";
|
|
3
|
+
import { WebView } from "react-native-webview";
|
|
4
|
+
|
|
5
|
+
//#region src/types.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Minimal EIP-1193 provider interface.
|
|
8
|
+
* Works with any wallet SDK: Privy, MetaMask, Coinbase, Rainbow, WalletConnect, etc.
|
|
9
|
+
*/
|
|
10
|
+
interface EIP1193Provider {
|
|
11
|
+
request: (args: {
|
|
12
|
+
method: string;
|
|
13
|
+
params?: unknown[];
|
|
14
|
+
}) => Promise<unknown>;
|
|
15
|
+
}
|
|
16
|
+
/** Runtime wallet connection shared across the provider, context, and WebView. */
|
|
17
|
+
interface YodlWallet {
|
|
18
|
+
/** EIP-1193 provider from the host wallet SDK. */
|
|
19
|
+
provider: EIP1193Provider;
|
|
20
|
+
/** Connected wallet address. */
|
|
21
|
+
address: string;
|
|
22
|
+
/** Chain ID the wallet is currently on. */
|
|
23
|
+
chainId: number;
|
|
24
|
+
/** Chain IDs the wallet can switch to. */
|
|
25
|
+
supportedChainIds: number[];
|
|
26
|
+
}
|
|
27
|
+
/** Event callbacks shared by the WebView components and the underlying hook. */
|
|
28
|
+
interface YodlEventHandlers {
|
|
29
|
+
/** Called after a transaction is sent. */
|
|
30
|
+
onTransactionSent?: (txHash: string) => void;
|
|
31
|
+
/** Called on RPC / payment errors. */
|
|
32
|
+
onError?: (error: Error) => void;
|
|
33
|
+
}
|
|
34
|
+
/** Props shared by the Yodl WebView components (YodlPayment, YodlDashboard). */
|
|
35
|
+
interface YodlComponentProps extends YodlEventHandlers {
|
|
36
|
+
style?: ViewStyle;
|
|
37
|
+
}
|
|
38
|
+
interface YodlWebViewRef {
|
|
39
|
+
webViewRef: RefObject<WebView | null>;
|
|
40
|
+
goBack: () => void;
|
|
41
|
+
reload: () => void;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/components/YodlDashboard.d.ts
|
|
45
|
+
type YodlDashboardProps = YodlComponentProps;
|
|
46
|
+
/**
|
|
47
|
+
* Renders the Yodl dashboard. Reads the SDK instance and wallet state from
|
|
48
|
+
* <YodlProvider> and loads the dashboard route on the configured Yodl host.
|
|
49
|
+
* The WebView is origin-locked to that host.
|
|
50
|
+
*/
|
|
51
|
+
declare const YodlDashboard: import("react").ForwardRefExoticComponent<YodlComponentProps & import("react").RefAttributes<YodlWebViewRef>>;
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/components/YodlPayment.d.ts
|
|
54
|
+
interface YodlPaymentProps extends YodlComponentProps {
|
|
55
|
+
/** Raw QR data string — the component builds the miniapp URL internally. */
|
|
56
|
+
qrData: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Renders the Yodl payment flow for a scanned QR code. Reads the SDK instance
|
|
60
|
+
* and wallet state from <YodlProvider>. The WebView is origin-locked to the
|
|
61
|
+
* configured Yodl host.
|
|
62
|
+
*/
|
|
63
|
+
declare const YodlPayment: import("react").ForwardRefExoticComponent<YodlPaymentProps & import("react").RefAttributes<YodlWebViewRef>>;
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/sdk/yodl.d.ts
|
|
66
|
+
/**
|
|
67
|
+
* App-host configuration for the Yodl React Native SDK.
|
|
68
|
+
* Injected once via {@link createSdk}.
|
|
69
|
+
*/
|
|
70
|
+
interface YodlConfig {
|
|
71
|
+
/** Base URL for the Yodl miniapp WebView (default: https://sdk-webview.yodl.me). */
|
|
72
|
+
webviewBaseUrl?: string;
|
|
73
|
+
/** Chain IDs the host wallet can switch to (default: all supported chains). */
|
|
74
|
+
supportedChainIds?: number[];
|
|
75
|
+
}
|
|
76
|
+
/** Config with defaults applied — what components read from the instance. */
|
|
77
|
+
type ResolvedYodlConfig = Required<YodlConfig>;
|
|
78
|
+
/**
|
|
79
|
+
* The Yodl SDK instance. Mirrors the namespaced shape of `@yodlpay/sdk-core`
|
|
80
|
+
* (e.g. `sdk.qr.*`) while wrapping — never re-exporting — sdk-core internals.
|
|
81
|
+
*/
|
|
82
|
+
declare class Yodl {
|
|
83
|
+
readonly config: ResolvedYodlConfig;
|
|
84
|
+
constructor(config?: YodlConfig);
|
|
85
|
+
get qr(): {
|
|
86
|
+
/**
|
|
87
|
+
* Returns true if the QR data is a Yodl-supported payment QR code.
|
|
88
|
+
* Accepts a single string or an array — true if any entry is supported.
|
|
89
|
+
*/
|
|
90
|
+
isPaymentQr(qrData: string | string[]): boolean;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Warm up SDK caches ahead of a payment. No-op today — reserved for future
|
|
94
|
+
* prefetching of rates, token lists, and processor metadata.
|
|
95
|
+
*/
|
|
96
|
+
prefetch(): Promise<void>;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Create a Yodl SDK instance. Factory pattern, consistent with
|
|
100
|
+
* `@yodlpay/sdk-core`'s `createSdk` / config-once convention.
|
|
101
|
+
*/
|
|
102
|
+
declare function createSdk(config?: YodlConfig): Yodl;
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/provider/context.d.ts
|
|
105
|
+
interface YodlContextValue extends YodlWallet {
|
|
106
|
+
/** The SDK instance created via createSdk(). */
|
|
107
|
+
sdk: Yodl;
|
|
108
|
+
}
|
|
109
|
+
interface YodlProviderProps extends Omit<YodlContextValue, 'supportedChainIds'> {
|
|
110
|
+
/** Optional override for chain IDs the wallet can switch to (falls back to the SDK config). */
|
|
111
|
+
supportedChainIds?: number[];
|
|
112
|
+
children: ReactNode;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Supplies the SDK instance and runtime wallet state (provider/address/chainId)
|
|
116
|
+
* to the Yodl components via React context.
|
|
117
|
+
*/
|
|
118
|
+
declare function YodlProvider({
|
|
119
|
+
sdk,
|
|
120
|
+
provider,
|
|
121
|
+
address,
|
|
122
|
+
chainId,
|
|
123
|
+
supportedChainIds,
|
|
124
|
+
children
|
|
125
|
+
}: YodlProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
126
|
+
//#endregion
|
|
127
|
+
export { type EIP1193Provider, Yodl, type YodlConfig, YodlDashboard, type YodlDashboardProps, YodlPayment, type YodlPaymentProps, YodlProvider, type YodlProviderProps, type YodlWebViewRef, createSdk };
|
|
128
|
+
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { ReactNode, RefObject } from "react";
|
|
2
|
+
import { ViewStyle } from "react-native";
|
|
3
|
+
import { WebView } from "react-native-webview";
|
|
4
|
+
|
|
5
|
+
//#region src/types.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Minimal EIP-1193 provider interface.
|
|
8
|
+
* Works with any wallet SDK: Privy, MetaMask, Coinbase, Rainbow, WalletConnect, etc.
|
|
9
|
+
*/
|
|
10
|
+
interface EIP1193Provider {
|
|
11
|
+
request: (args: {
|
|
12
|
+
method: string;
|
|
13
|
+
params?: unknown[];
|
|
14
|
+
}) => Promise<unknown>;
|
|
15
|
+
}
|
|
16
|
+
/** Runtime wallet connection shared across the provider, context, and WebView. */
|
|
17
|
+
interface YodlWallet {
|
|
18
|
+
/** EIP-1193 provider from the host wallet SDK. */
|
|
19
|
+
provider: EIP1193Provider;
|
|
20
|
+
/** Connected wallet address. */
|
|
21
|
+
address: string;
|
|
22
|
+
/** Chain ID the wallet is currently on. */
|
|
23
|
+
chainId: number;
|
|
24
|
+
/** Chain IDs the wallet can switch to. */
|
|
25
|
+
supportedChainIds: number[];
|
|
26
|
+
}
|
|
27
|
+
/** Event callbacks shared by the WebView components and the underlying hook. */
|
|
28
|
+
interface YodlEventHandlers {
|
|
29
|
+
/** Called after a transaction is sent. */
|
|
30
|
+
onTransactionSent?: (txHash: string) => void;
|
|
31
|
+
/** Called on RPC / payment errors. */
|
|
32
|
+
onError?: (error: Error) => void;
|
|
33
|
+
}
|
|
34
|
+
/** Props shared by the Yodl WebView components (YodlPayment, YodlDashboard). */
|
|
35
|
+
interface YodlComponentProps extends YodlEventHandlers {
|
|
36
|
+
style?: ViewStyle;
|
|
37
|
+
}
|
|
38
|
+
interface YodlWebViewRef {
|
|
39
|
+
webViewRef: RefObject<WebView | null>;
|
|
40
|
+
goBack: () => void;
|
|
41
|
+
reload: () => void;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/components/YodlDashboard.d.ts
|
|
45
|
+
type YodlDashboardProps = YodlComponentProps;
|
|
46
|
+
/**
|
|
47
|
+
* Renders the Yodl dashboard. Reads the SDK instance and wallet state from
|
|
48
|
+
* <YodlProvider> and loads the dashboard route on the configured Yodl host.
|
|
49
|
+
* The WebView is origin-locked to that host.
|
|
50
|
+
*/
|
|
51
|
+
declare const YodlDashboard: import("react").ForwardRefExoticComponent<YodlComponentProps & import("react").RefAttributes<YodlWebViewRef>>;
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/components/YodlPayment.d.ts
|
|
54
|
+
interface YodlPaymentProps extends YodlComponentProps {
|
|
55
|
+
/** Raw QR data string — the component builds the miniapp URL internally. */
|
|
56
|
+
qrData: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Renders the Yodl payment flow for a scanned QR code. Reads the SDK instance
|
|
60
|
+
* and wallet state from <YodlProvider>. The WebView is origin-locked to the
|
|
61
|
+
* configured Yodl host.
|
|
62
|
+
*/
|
|
63
|
+
declare const YodlPayment: import("react").ForwardRefExoticComponent<YodlPaymentProps & import("react").RefAttributes<YodlWebViewRef>>;
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/sdk/yodl.d.ts
|
|
66
|
+
/**
|
|
67
|
+
* App-host configuration for the Yodl React Native SDK.
|
|
68
|
+
* Injected once via {@link createSdk}.
|
|
69
|
+
*/
|
|
70
|
+
interface YodlConfig {
|
|
71
|
+
/** Base URL for the Yodl miniapp WebView (default: https://sdk-webview.yodl.me). */
|
|
72
|
+
webviewBaseUrl?: string;
|
|
73
|
+
/** Chain IDs the host wallet can switch to (default: all supported chains). */
|
|
74
|
+
supportedChainIds?: number[];
|
|
75
|
+
}
|
|
76
|
+
/** Config with defaults applied — what components read from the instance. */
|
|
77
|
+
type ResolvedYodlConfig = Required<YodlConfig>;
|
|
78
|
+
/**
|
|
79
|
+
* The Yodl SDK instance. Mirrors the namespaced shape of `@yodlpay/sdk-core`
|
|
80
|
+
* (e.g. `sdk.qr.*`) while wrapping — never re-exporting — sdk-core internals.
|
|
81
|
+
*/
|
|
82
|
+
declare class Yodl {
|
|
83
|
+
readonly config: ResolvedYodlConfig;
|
|
84
|
+
constructor(config?: YodlConfig);
|
|
85
|
+
get qr(): {
|
|
86
|
+
/**
|
|
87
|
+
* Returns true if the QR data is a Yodl-supported payment QR code.
|
|
88
|
+
* Accepts a single string or an array — true if any entry is supported.
|
|
89
|
+
*/
|
|
90
|
+
isPaymentQr(qrData: string | string[]): boolean;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Warm up SDK caches ahead of a payment. No-op today — reserved for future
|
|
94
|
+
* prefetching of rates, token lists, and processor metadata.
|
|
95
|
+
*/
|
|
96
|
+
prefetch(): Promise<void>;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Create a Yodl SDK instance. Factory pattern, consistent with
|
|
100
|
+
* `@yodlpay/sdk-core`'s `createSdk` / config-once convention.
|
|
101
|
+
*/
|
|
102
|
+
declare function createSdk(config?: YodlConfig): Yodl;
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/provider/context.d.ts
|
|
105
|
+
interface YodlContextValue extends YodlWallet {
|
|
106
|
+
/** The SDK instance created via createSdk(). */
|
|
107
|
+
sdk: Yodl;
|
|
108
|
+
}
|
|
109
|
+
interface YodlProviderProps extends Omit<YodlContextValue, 'supportedChainIds'> {
|
|
110
|
+
/** Optional override for chain IDs the wallet can switch to (falls back to the SDK config). */
|
|
111
|
+
supportedChainIds?: number[];
|
|
112
|
+
children: ReactNode;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Supplies the SDK instance and runtime wallet state (provider/address/chainId)
|
|
116
|
+
* to the Yodl components via React context.
|
|
117
|
+
*/
|
|
118
|
+
declare function YodlProvider({
|
|
119
|
+
sdk,
|
|
120
|
+
provider,
|
|
121
|
+
address,
|
|
122
|
+
chainId,
|
|
123
|
+
supportedChainIds,
|
|
124
|
+
children
|
|
125
|
+
}: YodlProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
126
|
+
//#endregion
|
|
127
|
+
export { type EIP1193Provider, Yodl, type YodlConfig, YodlDashboard, type YodlDashboardProps, YodlPayment, type YodlPaymentProps, YodlProvider, type YodlProviderProps, type YodlWebViewRef, createSdk };
|
|
128
|
+
//# sourceMappingURL=index.d.mts.map
|