@yodlpay/react-native 0.1.0 → 0.1.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/README.md +98 -140
- package/dist/index.cjs +66 -8
- package/dist/index.d.cts +87 -31
- package/dist/index.d.mts +87 -31
- package/dist/index.mjs +66 -9
- package/metro-config.cjs +12 -13
- package/package.json +7 -9
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ReactNode, RefObject } from "react";
|
|
2
1
|
import { ViewStyle } from "react-native";
|
|
3
|
-
import {
|
|
2
|
+
import { ReactNode } from "react";
|
|
4
3
|
|
|
5
4
|
//#region src/types.d.ts
|
|
6
5
|
/**
|
|
@@ -13,7 +12,52 @@ interface EIP1193Provider {
|
|
|
13
12
|
params?: unknown[];
|
|
14
13
|
}) => Promise<unknown>;
|
|
15
14
|
}
|
|
16
|
-
|
|
15
|
+
type SupportedChainIds = number[];
|
|
16
|
+
type YodlPaymentLifecycleStatus = 'submitted' | 'processing' | 'success' | 'failure';
|
|
17
|
+
interface YodlPaymentDetails {
|
|
18
|
+
status: YodlPaymentLifecycleStatus;
|
|
19
|
+
transaction: {
|
|
20
|
+
hash: string;
|
|
21
|
+
chainId?: string | number;
|
|
22
|
+
submittedAt?: string;
|
|
23
|
+
confirmedAt?: string;
|
|
24
|
+
};
|
|
25
|
+
payment?: {
|
|
26
|
+
processor?: string;
|
|
27
|
+
memo?: string | null;
|
|
28
|
+
recipient?: {
|
|
29
|
+
type?: string;
|
|
30
|
+
title?: string;
|
|
31
|
+
subtitle?: string;
|
|
32
|
+
iconUrl?: string | null;
|
|
33
|
+
};
|
|
34
|
+
invoice?: {
|
|
35
|
+
amount: string;
|
|
36
|
+
currency: string;
|
|
37
|
+
settlementAmount?: string;
|
|
38
|
+
settlementCurrency?: string;
|
|
39
|
+
} | null;
|
|
40
|
+
token?: {
|
|
41
|
+
symbol?: string;
|
|
42
|
+
amountGross?: string;
|
|
43
|
+
amountNet?: string;
|
|
44
|
+
};
|
|
45
|
+
senderAddress?: string;
|
|
46
|
+
receiverAddress?: string;
|
|
47
|
+
};
|
|
48
|
+
recovery?: {
|
|
49
|
+
refundTxHash?: string | null;
|
|
50
|
+
status?: 'pending' | 'success';
|
|
51
|
+
} | null;
|
|
52
|
+
rewards?: {
|
|
53
|
+
points?: number;
|
|
54
|
+
streakCount?: number;
|
|
55
|
+
streakMultiplier?: string;
|
|
56
|
+
berserMultiplier?: number;
|
|
57
|
+
};
|
|
58
|
+
raw?: unknown;
|
|
59
|
+
}
|
|
60
|
+
/** Runtime wallet connection shared across the provider, context, and Yodl UI host. */
|
|
17
61
|
interface YodlWallet {
|
|
18
62
|
/** EIP-1193 provider from the host wallet SDK. */
|
|
19
63
|
provider: EIP1193Provider;
|
|
@@ -22,45 +66,53 @@ interface YodlWallet {
|
|
|
22
66
|
/** Chain ID the wallet is currently on. */
|
|
23
67
|
chainId: number;
|
|
24
68
|
/** Chain IDs the wallet can switch to. */
|
|
25
|
-
supportedChainIds:
|
|
69
|
+
supportedChainIds: SupportedChainIds;
|
|
26
70
|
}
|
|
27
|
-
/** Event callbacks shared by the
|
|
71
|
+
/** Event callbacks shared by the Yodl UI components and the underlying hook. */
|
|
28
72
|
interface YodlEventHandlers {
|
|
29
73
|
/** Called after a transaction is sent. */
|
|
30
74
|
onTransactionSent?: (txHash: string) => void;
|
|
75
|
+
/** Called when the WebView emits Yodl payment lifecycle details. */
|
|
76
|
+
onPaymentDetails?: (details: YodlPaymentDetails) => void;
|
|
31
77
|
/** Called on RPC / payment errors. */
|
|
32
78
|
onError?: (error: Error) => void;
|
|
33
79
|
}
|
|
34
|
-
/** Props shared by the Yodl
|
|
80
|
+
/** Props shared by the Yodl UI components (YodlPayment, YodlDashboard). */
|
|
35
81
|
interface YodlComponentProps extends YodlEventHandlers {
|
|
36
82
|
style?: ViewStyle;
|
|
37
83
|
}
|
|
38
|
-
interface YodlWebViewRef {
|
|
39
|
-
webViewRef: RefObject<WebView | null>;
|
|
40
|
-
goBack: () => void;
|
|
41
|
-
reload: () => void;
|
|
42
|
-
}
|
|
43
84
|
//#endregion
|
|
44
85
|
//#region src/components/YodlDashboard.d.ts
|
|
45
86
|
type YodlDashboardProps = YodlComponentProps;
|
|
46
87
|
/**
|
|
47
88
|
* Renders the Yodl dashboard. Reads the SDK instance and wallet state from
|
|
48
89
|
* <YodlProvider> and loads the dashboard route on the configured Yodl host.
|
|
49
|
-
* The
|
|
90
|
+
* The Yodl UI is origin-locked to that host.
|
|
50
91
|
*/
|
|
51
|
-
declare
|
|
92
|
+
declare function YodlDashboard({
|
|
93
|
+
onTransactionSent,
|
|
94
|
+
onPaymentDetails,
|
|
95
|
+
onError,
|
|
96
|
+
style
|
|
97
|
+
}: YodlDashboardProps): import("react/jsx-runtime").JSX.Element;
|
|
52
98
|
//#endregion
|
|
53
99
|
//#region src/components/YodlPayment.d.ts
|
|
54
100
|
interface YodlPaymentProps extends YodlComponentProps {
|
|
55
|
-
/** Raw QR data string — the component builds the
|
|
101
|
+
/** Raw QR data string — the component builds the Yodl UI URL internally. */
|
|
56
102
|
qrData: string;
|
|
57
103
|
}
|
|
58
104
|
/**
|
|
59
105
|
* Renders the Yodl payment flow for a scanned QR code. Reads the SDK instance
|
|
60
|
-
* and wallet state from <YodlProvider>. The
|
|
106
|
+
* and wallet state from <YodlProvider>. The Yodl UI is origin-locked to the
|
|
61
107
|
* configured Yodl host.
|
|
62
108
|
*/
|
|
63
|
-
declare
|
|
109
|
+
declare function YodlPayment({
|
|
110
|
+
qrData,
|
|
111
|
+
onTransactionSent,
|
|
112
|
+
onPaymentDetails,
|
|
113
|
+
onError,
|
|
114
|
+
style
|
|
115
|
+
}: YodlPaymentProps): import("react/jsx-runtime").JSX.Element | null;
|
|
64
116
|
//#endregion
|
|
65
117
|
//#region src/sdk/yodl.d.ts
|
|
66
118
|
/**
|
|
@@ -68,20 +120,24 @@ declare const YodlPayment: import("react").ForwardRefExoticComponent<YodlPayment
|
|
|
68
120
|
* Injected once via {@link createSdk}.
|
|
69
121
|
*/
|
|
70
122
|
interface YodlConfig {
|
|
71
|
-
/**
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
|
|
123
|
+
/** Identifies the SDK integrator/wallet app in Yodl-owned request headers. */
|
|
124
|
+
integrationId: string;
|
|
125
|
+
/** Base URL for the Yodl UI (default: https://sdk-webview.yodl.me). */
|
|
126
|
+
yodlUiBaseUrl?: string;
|
|
127
|
+
/** Chain IDs the host wallet can switch to. */
|
|
128
|
+
supportedChainIds: SupportedChainIds;
|
|
75
129
|
}
|
|
76
130
|
/** Config with defaults applied — what components read from the instance. */
|
|
77
|
-
type ResolvedYodlConfig =
|
|
131
|
+
type ResolvedYodlConfig = Omit<YodlConfig, 'yodlUiBaseUrl'> & {
|
|
132
|
+
yodlUiBaseUrl: string;
|
|
133
|
+
};
|
|
78
134
|
/**
|
|
79
135
|
* The Yodl SDK instance. Mirrors the namespaced shape of `@yodlpay/sdk-core`
|
|
80
136
|
* (e.g. `sdk.qr.*`) while wrapping — never re-exporting — sdk-core internals.
|
|
81
137
|
*/
|
|
82
138
|
declare class Yodl {
|
|
83
139
|
readonly config: ResolvedYodlConfig;
|
|
84
|
-
constructor(config
|
|
140
|
+
constructor(config: YodlConfig);
|
|
85
141
|
get qr(): {
|
|
86
142
|
/**
|
|
87
143
|
* Returns true if the QR data is a Yodl-supported payment QR code.
|
|
@@ -99,16 +155,18 @@ declare class Yodl {
|
|
|
99
155
|
* Create a Yodl SDK instance. Factory pattern, consistent with
|
|
100
156
|
* `@yodlpay/sdk-core`'s `createSdk` / config-once convention.
|
|
101
157
|
*/
|
|
102
|
-
declare function createSdk(config
|
|
158
|
+
declare function createSdk(config: YodlConfig): Yodl;
|
|
103
159
|
//#endregion
|
|
104
160
|
//#region src/provider/context.d.ts
|
|
105
|
-
interface
|
|
161
|
+
interface YodlProviderProps {
|
|
106
162
|
/** The SDK instance created via createSdk(). */
|
|
107
163
|
sdk: Yodl;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
|
|
164
|
+
/** EIP-1193 provider from the host wallet SDK. */
|
|
165
|
+
provider: YodlWallet['provider'];
|
|
166
|
+
/** Connected wallet address. */
|
|
167
|
+
address: YodlWallet['address'];
|
|
168
|
+
/** Chain ID the wallet is currently on. */
|
|
169
|
+
chainId: YodlWallet['chainId'];
|
|
112
170
|
children: ReactNode;
|
|
113
171
|
}
|
|
114
172
|
/**
|
|
@@ -120,9 +178,7 @@ declare function YodlProvider({
|
|
|
120
178
|
provider,
|
|
121
179
|
address,
|
|
122
180
|
chainId,
|
|
123
|
-
supportedChainIds,
|
|
124
181
|
children
|
|
125
182
|
}: YodlProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
126
183
|
//#endregion
|
|
127
|
-
export { type EIP1193Provider, Yodl, type YodlConfig, YodlDashboard, type YodlDashboardProps, YodlPayment, type
|
|
128
|
-
//# sourceMappingURL=index.d.cts.map
|
|
184
|
+
export { type EIP1193Provider, type SupportedChainIds, Yodl, type YodlConfig, YodlDashboard, type YodlDashboardProps, YodlPayment, type YodlPaymentDetails, type YodlPaymentLifecycleStatus, type YodlPaymentProps, YodlProvider, type YodlProviderProps, createSdk };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ReactNode
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
2
|
import { ViewStyle } from "react-native";
|
|
3
|
-
import { WebView } from "react-native-webview";
|
|
4
3
|
|
|
5
4
|
//#region src/types.d.ts
|
|
6
5
|
/**
|
|
@@ -13,7 +12,52 @@ interface EIP1193Provider {
|
|
|
13
12
|
params?: unknown[];
|
|
14
13
|
}) => Promise<unknown>;
|
|
15
14
|
}
|
|
16
|
-
|
|
15
|
+
type SupportedChainIds = number[];
|
|
16
|
+
type YodlPaymentLifecycleStatus = 'submitted' | 'processing' | 'success' | 'failure';
|
|
17
|
+
interface YodlPaymentDetails {
|
|
18
|
+
status: YodlPaymentLifecycleStatus;
|
|
19
|
+
transaction: {
|
|
20
|
+
hash: string;
|
|
21
|
+
chainId?: string | number;
|
|
22
|
+
submittedAt?: string;
|
|
23
|
+
confirmedAt?: string;
|
|
24
|
+
};
|
|
25
|
+
payment?: {
|
|
26
|
+
processor?: string;
|
|
27
|
+
memo?: string | null;
|
|
28
|
+
recipient?: {
|
|
29
|
+
type?: string;
|
|
30
|
+
title?: string;
|
|
31
|
+
subtitle?: string;
|
|
32
|
+
iconUrl?: string | null;
|
|
33
|
+
};
|
|
34
|
+
invoice?: {
|
|
35
|
+
amount: string;
|
|
36
|
+
currency: string;
|
|
37
|
+
settlementAmount?: string;
|
|
38
|
+
settlementCurrency?: string;
|
|
39
|
+
} | null;
|
|
40
|
+
token?: {
|
|
41
|
+
symbol?: string;
|
|
42
|
+
amountGross?: string;
|
|
43
|
+
amountNet?: string;
|
|
44
|
+
};
|
|
45
|
+
senderAddress?: string;
|
|
46
|
+
receiverAddress?: string;
|
|
47
|
+
};
|
|
48
|
+
recovery?: {
|
|
49
|
+
refundTxHash?: string | null;
|
|
50
|
+
status?: 'pending' | 'success';
|
|
51
|
+
} | null;
|
|
52
|
+
rewards?: {
|
|
53
|
+
points?: number;
|
|
54
|
+
streakCount?: number;
|
|
55
|
+
streakMultiplier?: string;
|
|
56
|
+
berserMultiplier?: number;
|
|
57
|
+
};
|
|
58
|
+
raw?: unknown;
|
|
59
|
+
}
|
|
60
|
+
/** Runtime wallet connection shared across the provider, context, and Yodl UI host. */
|
|
17
61
|
interface YodlWallet {
|
|
18
62
|
/** EIP-1193 provider from the host wallet SDK. */
|
|
19
63
|
provider: EIP1193Provider;
|
|
@@ -22,45 +66,53 @@ interface YodlWallet {
|
|
|
22
66
|
/** Chain ID the wallet is currently on. */
|
|
23
67
|
chainId: number;
|
|
24
68
|
/** Chain IDs the wallet can switch to. */
|
|
25
|
-
supportedChainIds:
|
|
69
|
+
supportedChainIds: SupportedChainIds;
|
|
26
70
|
}
|
|
27
|
-
/** Event callbacks shared by the
|
|
71
|
+
/** Event callbacks shared by the Yodl UI components and the underlying hook. */
|
|
28
72
|
interface YodlEventHandlers {
|
|
29
73
|
/** Called after a transaction is sent. */
|
|
30
74
|
onTransactionSent?: (txHash: string) => void;
|
|
75
|
+
/** Called when the WebView emits Yodl payment lifecycle details. */
|
|
76
|
+
onPaymentDetails?: (details: YodlPaymentDetails) => void;
|
|
31
77
|
/** Called on RPC / payment errors. */
|
|
32
78
|
onError?: (error: Error) => void;
|
|
33
79
|
}
|
|
34
|
-
/** Props shared by the Yodl
|
|
80
|
+
/** Props shared by the Yodl UI components (YodlPayment, YodlDashboard). */
|
|
35
81
|
interface YodlComponentProps extends YodlEventHandlers {
|
|
36
82
|
style?: ViewStyle;
|
|
37
83
|
}
|
|
38
|
-
interface YodlWebViewRef {
|
|
39
|
-
webViewRef: RefObject<WebView | null>;
|
|
40
|
-
goBack: () => void;
|
|
41
|
-
reload: () => void;
|
|
42
|
-
}
|
|
43
84
|
//#endregion
|
|
44
85
|
//#region src/components/YodlDashboard.d.ts
|
|
45
86
|
type YodlDashboardProps = YodlComponentProps;
|
|
46
87
|
/**
|
|
47
88
|
* Renders the Yodl dashboard. Reads the SDK instance and wallet state from
|
|
48
89
|
* <YodlProvider> and loads the dashboard route on the configured Yodl host.
|
|
49
|
-
* The
|
|
90
|
+
* The Yodl UI is origin-locked to that host.
|
|
50
91
|
*/
|
|
51
|
-
declare
|
|
92
|
+
declare function YodlDashboard({
|
|
93
|
+
onTransactionSent,
|
|
94
|
+
onPaymentDetails,
|
|
95
|
+
onError,
|
|
96
|
+
style
|
|
97
|
+
}: YodlDashboardProps): import("react/jsx-runtime").JSX.Element;
|
|
52
98
|
//#endregion
|
|
53
99
|
//#region src/components/YodlPayment.d.ts
|
|
54
100
|
interface YodlPaymentProps extends YodlComponentProps {
|
|
55
|
-
/** Raw QR data string — the component builds the
|
|
101
|
+
/** Raw QR data string — the component builds the Yodl UI URL internally. */
|
|
56
102
|
qrData: string;
|
|
57
103
|
}
|
|
58
104
|
/**
|
|
59
105
|
* Renders the Yodl payment flow for a scanned QR code. Reads the SDK instance
|
|
60
|
-
* and wallet state from <YodlProvider>. The
|
|
106
|
+
* and wallet state from <YodlProvider>. The Yodl UI is origin-locked to the
|
|
61
107
|
* configured Yodl host.
|
|
62
108
|
*/
|
|
63
|
-
declare
|
|
109
|
+
declare function YodlPayment({
|
|
110
|
+
qrData,
|
|
111
|
+
onTransactionSent,
|
|
112
|
+
onPaymentDetails,
|
|
113
|
+
onError,
|
|
114
|
+
style
|
|
115
|
+
}: YodlPaymentProps): import("react/jsx-runtime").JSX.Element | null;
|
|
64
116
|
//#endregion
|
|
65
117
|
//#region src/sdk/yodl.d.ts
|
|
66
118
|
/**
|
|
@@ -68,20 +120,24 @@ declare const YodlPayment: import("react").ForwardRefExoticComponent<YodlPayment
|
|
|
68
120
|
* Injected once via {@link createSdk}.
|
|
69
121
|
*/
|
|
70
122
|
interface YodlConfig {
|
|
71
|
-
/**
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
|
|
123
|
+
/** Identifies the SDK integrator/wallet app in Yodl-owned request headers. */
|
|
124
|
+
integrationId: string;
|
|
125
|
+
/** Base URL for the Yodl UI (default: https://sdk-webview.yodl.me). */
|
|
126
|
+
yodlUiBaseUrl?: string;
|
|
127
|
+
/** Chain IDs the host wallet can switch to. */
|
|
128
|
+
supportedChainIds: SupportedChainIds;
|
|
75
129
|
}
|
|
76
130
|
/** Config with defaults applied — what components read from the instance. */
|
|
77
|
-
type ResolvedYodlConfig =
|
|
131
|
+
type ResolvedYodlConfig = Omit<YodlConfig, 'yodlUiBaseUrl'> & {
|
|
132
|
+
yodlUiBaseUrl: string;
|
|
133
|
+
};
|
|
78
134
|
/**
|
|
79
135
|
* The Yodl SDK instance. Mirrors the namespaced shape of `@yodlpay/sdk-core`
|
|
80
136
|
* (e.g. `sdk.qr.*`) while wrapping — never re-exporting — sdk-core internals.
|
|
81
137
|
*/
|
|
82
138
|
declare class Yodl {
|
|
83
139
|
readonly config: ResolvedYodlConfig;
|
|
84
|
-
constructor(config
|
|
140
|
+
constructor(config: YodlConfig);
|
|
85
141
|
get qr(): {
|
|
86
142
|
/**
|
|
87
143
|
* Returns true if the QR data is a Yodl-supported payment QR code.
|
|
@@ -99,16 +155,18 @@ declare class Yodl {
|
|
|
99
155
|
* Create a Yodl SDK instance. Factory pattern, consistent with
|
|
100
156
|
* `@yodlpay/sdk-core`'s `createSdk` / config-once convention.
|
|
101
157
|
*/
|
|
102
|
-
declare function createSdk(config
|
|
158
|
+
declare function createSdk(config: YodlConfig): Yodl;
|
|
103
159
|
//#endregion
|
|
104
160
|
//#region src/provider/context.d.ts
|
|
105
|
-
interface
|
|
161
|
+
interface YodlProviderProps {
|
|
106
162
|
/** The SDK instance created via createSdk(). */
|
|
107
163
|
sdk: Yodl;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
|
|
164
|
+
/** EIP-1193 provider from the host wallet SDK. */
|
|
165
|
+
provider: YodlWallet['provider'];
|
|
166
|
+
/** Connected wallet address. */
|
|
167
|
+
address: YodlWallet['address'];
|
|
168
|
+
/** Chain ID the wallet is currently on. */
|
|
169
|
+
chainId: YodlWallet['chainId'];
|
|
112
170
|
children: ReactNode;
|
|
113
171
|
}
|
|
114
172
|
/**
|
|
@@ -120,9 +178,7 @@ declare function YodlProvider({
|
|
|
120
178
|
provider,
|
|
121
179
|
address,
|
|
122
180
|
chainId,
|
|
123
|
-
supportedChainIds,
|
|
124
181
|
children
|
|
125
182
|
}: YodlProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
126
183
|
//#endregion
|
|
127
|
-
export { type EIP1193Provider, Yodl, type YodlConfig, YodlDashboard, type YodlDashboardProps, YodlPayment, type
|
|
128
|
-
//# sourceMappingURL=index.d.mts.map
|
|
184
|
+
export { type EIP1193Provider, type SupportedChainIds, Yodl, type YodlConfig, YodlDashboard, type YodlDashboardProps, YodlPayment, type YodlPaymentDetails, type YodlPaymentLifecycleStatus, type YodlPaymentProps, YodlProvider, type YodlProviderProps, createSdk };
|