@yodlpay/react-native 0.3.0 → 0.5.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 +102 -12
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +119 -10
- package/dist/index.d.mts +119 -10
- package/dist/index.mjs +2 -2
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ The provider interface is always plain **EIP-1193**. Transaction **batching and
|
|
|
18
18
|
import { createSdk, YodlProvider, YodlPayment } from '@yodlpay/react-native';
|
|
19
19
|
|
|
20
20
|
const sdk = createSdk({
|
|
21
|
-
|
|
21
|
+
integrationAddress: '0x000000000000000000000000000000000000dEaD',
|
|
22
22
|
supportedChainIds: [1, 8453],
|
|
23
23
|
});
|
|
24
24
|
|
|
@@ -38,6 +38,7 @@ const sdk = createSdk({
|
|
|
38
38
|
- [Platform Notes](#platform-notes)
|
|
39
39
|
- [Usage](#usage)
|
|
40
40
|
- [Signup flow](#signup-flow)
|
|
41
|
+
- [Hosted UI theming](#hosted-ui-theming)
|
|
41
42
|
- [Full example](#full-example)
|
|
42
43
|
- [Optional EIP-7702 fallback](#optional-eip-7702-fallback)
|
|
43
44
|
- [API Reference](#api-reference)
|
|
@@ -84,7 +85,7 @@ import { createSdk, isPaymentQr, YodlProvider, YodlPayment } from '@yodlpay/reac
|
|
|
84
85
|
|
|
85
86
|
// 1. Create the SDK once, app-wide.
|
|
86
87
|
const sdk = createSdk({
|
|
87
|
-
|
|
88
|
+
integrationAddress: '0x000000000000000000000000000000000000dEaD', // your integration wallet address
|
|
88
89
|
supportedChainIds: [1, 8453],
|
|
89
90
|
});
|
|
90
91
|
|
|
@@ -176,6 +177,82 @@ export function SignupScreen() {
|
|
|
176
177
|
|
|
177
178
|
`<YodlSignup />` shows the Yodl signup flow and calls `onSignedUp` when the user is finished. The SDK does not expose account details from the hosted flow. If you need to remember that the user signed up, save completion in your own app state, storage, or backend.
|
|
178
179
|
|
|
180
|
+
### Hosted UI theming
|
|
181
|
+
|
|
182
|
+
Theming is **opt-in**. Set `theme`, `themeMode`, or both on `<YodlProvider>` (or on any hosted component) to style the Yodl UI. Omit them and the hosted UI keeps its own appearance. Every field is optional.
|
|
183
|
+
|
|
184
|
+
```tsx
|
|
185
|
+
import type { YodlTheme } from '@yodlpay/react-native';
|
|
186
|
+
import { YodlPayment, YodlProvider } from '@yodlpay/react-native';
|
|
187
|
+
|
|
188
|
+
// A small, representative subset of tokens — see "Tokens" for the full list.
|
|
189
|
+
const brandTheme: YodlTheme = {
|
|
190
|
+
name: 'acme',
|
|
191
|
+
light: { bg: '#ffffff', surface: '#f4f4f5', text: '#18181b', accent: '#6d4fc0' },
|
|
192
|
+
dark: { bg: '#18181b', surface: '#27272a', text: '#fafafa', accent: '#9662ff' },
|
|
193
|
+
images: {
|
|
194
|
+
light: { loading: 'https://cdn.example.com/yodl-loading-light.mp4' },
|
|
195
|
+
dark: { loading: 'https://cdn.example.com/yodl-loading-dark.mp4' },
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
<YodlProvider
|
|
200
|
+
sdk={sdk}
|
|
201
|
+
provider={provider}
|
|
202
|
+
address={address}
|
|
203
|
+
chainId={chainId}
|
|
204
|
+
theme={brandTheme}
|
|
205
|
+
themeMode="system"
|
|
206
|
+
>
|
|
207
|
+
<YodlPayment qrData={qrData} />
|
|
208
|
+
</YodlProvider>;
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
#### Modes
|
|
212
|
+
|
|
213
|
+
`themeMode` is `'system'` (follow the device), `'light'`, or `'dark'`. The two props combine as:
|
|
214
|
+
|
|
215
|
+
| `theme` | `themeMode` | Result |
|
|
216
|
+
| --- | --- | --- |
|
|
217
|
+
| Omitted | Omitted | Hosted UI keeps its own appearance |
|
|
218
|
+
| Set | Omitted | Your palette, following the device |
|
|
219
|
+
| Omitted | Set | Stock Yodl palette, pinned to that mode |
|
|
220
|
+
| Set | Set | Your palette, pinned to that mode |
|
|
221
|
+
|
|
222
|
+
#### Defaults and overrides
|
|
223
|
+
|
|
224
|
+
- `theme` / `themeMode` on `<YodlProvider>` are defaults for every hosted component under it.
|
|
225
|
+
- The same props on `<YodlSignup>`, `<YodlPayment>`, and `<YodlDashboard>` override the provider **per prop** — set one and the other still inherits.
|
|
226
|
+
- Remove `theme` and `themeMode` from both the component and its provider to hand appearance control back to the hosted UI.
|
|
227
|
+
|
|
228
|
+
```tsx
|
|
229
|
+
// Provider follows the device; this one screen pins dark but keeps the palette.
|
|
230
|
+
<YodlProvider sdk={sdk} provider={provider} address={address} chainId={chainId} theme={brandTheme}>
|
|
231
|
+
<YodlPayment qrData={qrData} themeMode="dark" />
|
|
232
|
+
</YodlProvider>;
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
#### Tokens
|
|
236
|
+
|
|
237
|
+
`name` is an optional label (≤64 chars). Set colors per mode under `light` and `dark`; omitted tokens keep their stock value. The 21 keys:
|
|
238
|
+
|
|
239
|
+
- **Core:** `bg` `surface` `surfaceSecondary` `text` `textSecondary` `textMuted` `border` `success` `error` `warning` `accent`
|
|
240
|
+
- **Fine-tune** (derived from core when omitted): `bgDeep` `surfaceHover` `skeleton` `accentStrong` `accentDeep`
|
|
241
|
+
- **Brand:** `brandSurface` `brandSheet` `brandText` `brandButton` `brandButtonText`
|
|
242
|
+
|
|
243
|
+
#### Validation
|
|
244
|
+
|
|
245
|
+
- Colors must be `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`, `rgb(…)`, or `rgba(…)`.
|
|
246
|
+
- Images go under `images.light` / `images.dark`, each with `payBackground`, `loading`, and `processing` slots (`processing` is only used when `loading` is unset). A `.mp4` URL plays as a looping muted video; anything else is an image.
|
|
247
|
+
- Image URLs must be `https://`, at most 2048 characters, with no whitespace, quotes, or backslashes.
|
|
248
|
+
- An invalid `theme` or `themeMode` never crashes — it falls back to stock Yodl and logs the error in `__DEV__`.
|
|
249
|
+
|
|
250
|
+
#### Live updates
|
|
251
|
+
|
|
252
|
+
Changing `theme` / `themeMode` on a mounted component applies over the bridge **without reloading** — the active flow keeps its state.
|
|
253
|
+
|
|
254
|
+
> **Compatibility.** `yodlUiBaseUrl` must point at a current hosted UI that supports correlated readiness. Against an older build the WebView never reveals and the loading spinner stays up. See [Troubleshooting](#troubleshooting).
|
|
255
|
+
|
|
179
256
|
### Full example
|
|
180
257
|
|
|
181
258
|
**`sdk.ts`** — create the instance once, app-wide:
|
|
@@ -184,7 +261,7 @@ export function SignupScreen() {
|
|
|
184
261
|
import { createSdk } from '@yodlpay/react-native';
|
|
185
262
|
|
|
186
263
|
export const sdk = createSdk({
|
|
187
|
-
|
|
264
|
+
integrationAddress: '0x000000000000000000000000000000000000dEaD',
|
|
188
265
|
// yodlUiBaseUrl defaults to https://sdk-webview.yodl.me
|
|
189
266
|
supportedChainIds: [1, 42161, 8453, 137, 10, 56, 100],
|
|
190
267
|
});
|
|
@@ -295,14 +372,14 @@ Returns a `Yodl` instance.
|
|
|
295
372
|
|
|
296
373
|
| Option | Type | Required | Default | Description |
|
|
297
374
|
| ------------------- | ----------------------------- | -------- | ----------------------------- | -------------------------------------------------------------------------- |
|
|
298
|
-
| `
|
|
375
|
+
| `integrationAddress` | `string` | Yes | — | Your integration wallet address. Identifies you to Yodl and attributes payments on chain |
|
|
299
376
|
| `supportedChainIds` | `number[]` | Yes | — | Chain IDs the wallet can switch to |
|
|
300
377
|
| `yodlUiBaseUrl` | `string` | No | `https://sdk-webview.yodl.me` | Base URL for the Yodl UI |
|
|
301
378
|
|
|
302
|
-
`
|
|
379
|
+
`integrationAddress` must be a non-empty `0x` address. The SDK sends it with package metadata on Yodl-owned requests:
|
|
303
380
|
|
|
304
381
|
```txt
|
|
305
|
-
X-Yodl-Integration-Id:
|
|
382
|
+
X-Yodl-Integration-Id: 0x000000000000000000000000000000000000dEaD
|
|
306
383
|
X-Yodl-SDK-Name: @yodlpay/react-native
|
|
307
384
|
X-Yodl-SDK-Version: <installed package version>
|
|
308
385
|
```
|
|
@@ -331,12 +408,27 @@ Supplies the SDK instance and wallet state to the components. Render it once, hi
|
|
|
331
408
|
| `provider` | `EIP1193Provider` | Yes | EIP-1193 provider from any wallet SDK. Prefer the wallet's native EIP-5792 support; only if it lacks it, wrap with `withYodl7702(...)` for the [EIP-7702 fallback](#optional-eip-7702-fallback) |
|
|
332
409
|
| `address` | `string` | Yes | Connected wallet address |
|
|
333
410
|
| `chainId` | `number` | Yes | Chain ID the wallet is currently on |
|
|
411
|
+
| `theme` | `YodlTheme` | No | Default custom hosted-UI palette; all fields are optional |
|
|
412
|
+
| `themeMode` | `'system' \| 'light' \| 'dark'` | No | Default host-controlled mode |
|
|
334
413
|
|
|
335
414
|
`address` and `chainId` are the wallet's **live** account and chain — pass them straight from your wallet SDK's hooks (e.g. `useWallets()`, `useAccount()`), not as fixed values. They tell the embedded Yodl UI who is connected and on which chain, and the SDK pushes `accountsChanged` / `chainChanged` into the UI whenever they change — so keep them updated when the user switches account or network. (The `provider` is used only as the RPC/signing transport.)
|
|
336
415
|
|
|
416
|
+
`theme` and `themeMode` are also available on `<YodlSignup>`, `<YodlPayment>`, and `<YodlDashboard>` as per-component overrides — along with `backgroundColor` and `style`. See [Shared visual props](#shared-visual-props) and [Hosted UI theming](#hosted-ui-theming).
|
|
417
|
+
|
|
418
|
+
### Shared visual props
|
|
419
|
+
|
|
420
|
+
`<YodlSignup>`, `<YodlPayment>`, and `<YodlDashboard>` all accept the same visual props. They are listed here once rather than repeated in each component's table below.
|
|
421
|
+
|
|
422
|
+
| Prop | Type | Required | Description |
|
|
423
|
+
| ----------------- | ------------------------------- | -------- | --------------------------------------------------------------------------------- |
|
|
424
|
+
| `theme` | `YodlTheme` | No | Palette override; inherits the provider `theme` when omitted |
|
|
425
|
+
| `themeMode` | `'system' \| 'light' \| 'dark'` | No | Mode override; inherits the provider `themeMode` when omitted |
|
|
426
|
+
| `backgroundColor` | `string` | No | Color behind the WebView before first paint; overrides the theme background |
|
|
427
|
+
| `style` | `ViewStyle` | No | Container style |
|
|
428
|
+
|
|
337
429
|
### `<YodlSignup />`
|
|
338
430
|
|
|
339
|
-
Renders the hosted signup flow. Use this as a full-screen component inside `<YodlProvider>`.
|
|
431
|
+
Renders the hosted signup flow. Use this as a full-screen component inside `<YodlProvider>`. Also accepts all [shared visual props](#shared-visual-props).
|
|
340
432
|
|
|
341
433
|
| Prop | Type | Required | Description |
|
|
342
434
|
| ---------------- | ---------------------------------------------------------------------------- | -------- | ----------------------------------------------------- |
|
|
@@ -344,11 +436,10 @@ Renders the hosted signup flow. Use this as a full-screen component inside `<Yod
|
|
|
344
436
|
| `onSignedUp` | `() => void` | No | Called when signup completes |
|
|
345
437
|
| `onDismiss` | `() => void` | No | Called when the hosted success screen is dismissed |
|
|
346
438
|
| `onError` | `(error: Error) => void` | No | Called on SIWE, registration, verification, or RPC errors |
|
|
347
|
-
| `style` | `ViewStyle` | No | Container style |
|
|
348
439
|
|
|
349
440
|
### `<YodlPayment />`
|
|
350
441
|
|
|
351
|
-
Renders the payment flow for a scanned QR code. Renders nothing if `qrData` is empty or unsupported.
|
|
442
|
+
Renders the payment flow for a scanned QR code. Renders nothing if `qrData` is empty or unsupported. Also accepts all [shared visual props](#shared-visual-props).
|
|
352
443
|
|
|
353
444
|
| Prop | Type | Required | Description |
|
|
354
445
|
| ------------------- | --------------------------------------- | -------- | -------------------------------------------------- |
|
|
@@ -356,18 +447,16 @@ Renders the payment flow for a scanned QR code. Renders nothing if `qrData` is e
|
|
|
356
447
|
| `onTransactionSent` | `(txHash: string) => void` | No | Called after a transaction is sent |
|
|
357
448
|
| `onPaymentDetails` | `(details: YodlPaymentDetails) => void` | No | Called with payment lifecycle details from the UI |
|
|
358
449
|
| `onError` | `(error: Error) => void` | No | Called on RPC / payment errors |
|
|
359
|
-
| `style` | `ViewStyle` | No | Container style |
|
|
360
450
|
|
|
361
451
|
### `<YodlDashboard />`
|
|
362
452
|
|
|
363
|
-
Renders the full Yodl account dashboard.
|
|
453
|
+
Renders the full Yodl account dashboard. Also accepts all [shared visual props](#shared-visual-props).
|
|
364
454
|
|
|
365
455
|
| Prop | Type | Required | Description |
|
|
366
456
|
| ------------------- | --------------------------------------- | -------- | -------------------------------------------------- |
|
|
367
457
|
| `onTransactionSent` | `(txHash: string) => void` | No | Called after a transaction is sent |
|
|
368
458
|
| `onPaymentDetails` | `(details: YodlPaymentDetails) => void` | No | Called with payment lifecycle details from the UI |
|
|
369
459
|
| `onError` | `(error: Error) => void` | No | Called on RPC errors |
|
|
370
|
-
| `style` | `ViewStyle` | No | Container style |
|
|
371
460
|
|
|
372
461
|
### Payment details events
|
|
373
462
|
|
|
@@ -390,6 +479,7 @@ The bridge forwards EIP-5792 (`wallet_sendCalls`, `wallet_getCallsStatus`, `wall
|
|
|
390
479
|
| `Yodl components must be rendered inside <YodlProvider>` | A component is mounted outside the provider. Wrap it in `<YodlProvider>`. |
|
|
391
480
|
| Payment screen renders blank | `qrData` isn't a Yodl payment QR. Guard with `isPaymentQr(qrData)` before rendering `<YodlPayment>`. |
|
|
392
481
|
| `webview-action providers are not supported yet` | The scanned QR maps to a provider whose hosted webview flow isn't supported yet. Catch it (e.g. via `onError` or an error boundary) and prompt a retry. |
|
|
482
|
+
| Loading overlay never lifts (spinner stays forever) | The hosted UI at `yodlUiBaseUrl` doesn't support correlated readiness. Point it at a current hosted build. See [Hosted UI theming](#hosted-ui-theming). |
|
|
393
483
|
|
|
394
484
|
## License
|
|
395
485
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react"),t=require("react
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react"),t=require("react-native"),n=require("react/jsx-runtime"),r=require("react-native-webview");const i=/^(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\(\s*[\d.%\s,/]+\s*\))$/i,a=/^https:\/\/[^\s"\\]+$/,o=[`bg`,`surface`,`surfaceSecondary`,`text`,`textSecondary`,`textMuted`,`border`,`success`,`error`,`warning`,`accent`,`bgDeep`,`surfaceHover`,`skeleton`,`accentStrong`,`accentDeep`,`brandSurface`,`brandSheet`,`brandText`,`brandButton`,`brandButtonText`],s=[`payBackground`,`processing`,`loading`];function c(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function l(e,t){if(!c(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of o){let a=e[r];if(a!==void 0){if(typeof a!=`string`||!i.test(a))return{success:!1,error:`${t}.${r}: colors must be hex, rgb() or rgba()`};n[r]=a}}return{success:!0,data:n}}function u(e,t){if(!c(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of s){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>2048||!a.test(i))return{success:!1,error:`${t}.${r}: images must be https:// URLs`};n[r]=i}}return{success:!0,data:n}}function d(e){if(!c(e))return{success:!1,error:`images: expected an object`};let t=Object.keys(e).find(e=>e!==`light`&&e!==`dark`);if(t)return{success:!1,error:`images.${t}: unknown key`};let n={};for(let t of[`light`,`dark`]){if(e[t]===void 0)continue;let r=u(e[t],`images.${t}`);if(!r.success)return r;n[t]=r.data}return{success:!0,data:n}}function f(e){if(!c(e))return{success:!1,error:`(root): expected an object`};let t={};if(e.name!==void 0){if(typeof e.name!=`string`||e.name.length>64)return{success:!1,error:`name: must be a string of at most 64 characters`};t.name=e.name}for(let n of[`light`,`dark`]){if(e[n]===void 0)continue;let r=l(e[n],n);if(!r.success)return r;t[n]=r.data}if(e.images!==void 0){let n=d(e.images);if(!n.success)return n;t.images=n.data}return{success:!0,data:t}}function p(e){return!c(e)||Object.keys(e).length!==3?!1:e.type===`yodl_ready`&&e.version===1&&typeof e.sessionId==`string`&&e.sessionId.length>=1&&e.sessionId.length<=128}const m={light:{background:`#f8f8fc`,spinner:`#52525b`},dark:{background:`#18181b`,spinner:`#a1a1aa`}};function h(e,t){return e===`system`?t===`light`?`light`:`dark`:e}function g(e,t,n){if(e===void 0&&t===void 0)return{envelope:null,error:null};let r=e===void 0?null:f(e),i=t===void 0||t===`system`||t===`light`||t===`dark`,a=i?t??`system`:`system`,o=[r&&!r.success?`Invalid Yodl theme — ${r.error}`:null,i?null:`Invalid Yodl themeMode — themeMode must be system, light or dark`].filter(e=>e!==null);return{envelope:{version:1,authority:`host`,theme:r?.success?r.data:null,preference:a,resolved:h(a,n)},error:o.length>0?o.join(`; `):null}}function _(e,t){let n=m[e?e.resolved:`dark`],r=e?.theme?.[e.resolved];return{background:t??r?.bg??n.background,spinner:r?.textSecondary??n.spinner}}function v(e,t,n){return{yodl:{version:1,sessionId:e,...t?{hostTheme:t}:{},...n?{integrationAddress:n}:{}}}}function y(e,t){return t?{channel:`yodl`,sessionId:e,type:`theme:update`,payload:t}:{channel:`yodl`,sessionId:e,type:`theme:release`}}function b(e,t){return JSON.stringify(y(e,t))}function x(e,t,n,r){let{envelope:i,error:a}=g(e,t,n);return a&&r?.(a),i}function S(e,t,n,r,i){if(t===void 0&&n===void 0)return e;let{envelope:a,error:o}=g(t??e?.theme??void 0,n??e?.preference,r);return o&&i?.(o),a}function C(e){typeof __DEV__<`u`&&__DEV__&&console.error(`[@yodlpay/react-native] ${e}`)}const w=(0,e.createContext)(null);function T({sdk:r,provider:i,address:a,chainId:o,theme:s,themeMode:c,children:l}){let u=(0,t.useColorScheme)(),d=(0,e.useMemo)(()=>x(s,c,u,C),[s,c,u]),f=(0,e.useMemo)(()=>({sdk:r,provider:i,address:a,chainId:o,supportedChainIds:r.config.supportedChainIds,hostTheme:d,systemScheme:u}),[r,i,a,o,d,u]);return(0,n.jsx)(w.Provider,{value:f,children:l})}function E(){let t=(0,e.useContext)(w);if(!t)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return t}function D(t,n){let r=E(),i=(0,e.useMemo)(()=>S(r.hostTheme,t,n,r.systemScheme,C),[r.hostTheme,r.systemScheme,t,n]);return{...r,hostTheme:i}}function O(e){if(e.code===4001)return!0;let t=e.message.toLowerCase();return t.includes(`rejected`)||t.includes(`denied`)}function k(e,t){if(e instanceof Error)return e;if(typeof e==`object`&&e){let t=e;if(typeof t.message==`string`){let e=Error(t.message);return typeof t.code==`number`&&(e.code=t.code),e}}return Error(t)}function A(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function j(e){if(typeof e!=`string`||!/^0x(?:0|[1-9a-f][0-9a-f]*)$/i.test(e))return;let t=Number.parseInt(e,16);return Number.isSafeInteger(t)?t:void 0}function M(e){let t=e.code;if(t===4200||t===-32601)return!0;let n=e.message.toLowerCase();return n.includes(`method not found`)||n.includes(`method not supported`)||n.includes(`unsupported method`)||n.includes(`unsupported wc_ method`)||n.includes(`not supported`)||n.includes(`does not exist`)||n.includes(`not available`)}function ee(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function te(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}const ne=/^0x[a-fA-F0-9]{40}$/;function N(e){let t=e?.integrationAddress?.trim();if(!t)throw Error(`Yodl integrationAddress is required`);if(!ne.test(t))throw Error(`Yodl integrationAddress is not a valid address: ${t}`);return t}function re(e){return{"X-Yodl-Integration-Id":N(e),"X-Yodl-SDK-Name":`@yodlpay/react-native`,"X-Yodl-SDK-Version":`0.5.0`}}function ie(e,t){let n=e.yodlUiBaseUrl?ee(e.yodlUiBaseUrl):null;if(!(!n||!te(t,n)))return re(e)}let P=0;function F(){return P+=1,`yodl-${Date.now().toString(36)}-${P.toString(36)}`}function ae(e,t,n,r=F){return e?.uri===t?e:{uri:t,sessionId:r(),initialHostTheme:n}}function oe(e,t,n,r,i=F){return r?{uri:t,sessionId:i(),initialHostTheme:n}:e}function I(e){return`0x${e.toString(16)}`}function se(e,t=`unsupported`){let n={};for(let r of e)n[I(r)]={atomic:{status:t}};return n}const ce=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function le(e){return ce.some(t=>t===e)}function ue(e,t,n){if(!le(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=j((t[0]??{}).chainId);if(typeof r!=`number`)return{error:{code:-32602,message:`Missing or invalid chainId parameter`}};if(!n.includes(r))return{error:{code:4902,message:`Chain ${r} not supported`}};let i=I(r);return{providerMethod:e,providerParams:e===`wallet_switchEthereumChain`?[{chainId:i}]:t,requestedChainId:r,chainIdHex:i,switchesActiveChain:e===`wallet_switchEthereumChain`}}function de(e,t){let n=e[1];return Array.isArray(n)?n.map(e=>j(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function fe(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function pe(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function me(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!fe(t))return;let n=t.receipts;if(n?.length&&!n.some(pe))return n[n.length-1]?.transactionHash}function he(e){let t=I(e.chainId);return`(function() {
|
|
2
2
|
if (window.ethereum) return;
|
|
3
3
|
|
|
4
4
|
var _address = ${JSON.stringify(e.address.toLowerCase())};
|
|
@@ -225,4 +225,4 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require
|
|
|
225
225
|
announceProvider();
|
|
226
226
|
window.addEventListener("eip6963:requestProvider", announceProvider);
|
|
227
227
|
})();
|
|
228
|
-
true;`}function D(e){return e.toLowerCase()}function O(e,t){let n=D(t.address),r=e.address!==n,i=e.propChainId!==t.chainId;if(!r&&!i)return null;let a=i&&e.activeChainId!==t.chainId;return{nextAddress:n,nextPropChainId:t.chainId,nextActiveChainId:a?t.chainId:e.activeChainId,...r?{accountsChanged:[n]}:{},...a?{chainChanged:{chainId:t.chainId,chainIdHex:_(t.chainId)}}:{}}}function k(e,t,n,r){let i=r?{id:t,error:r}:{id:t,result:n};e.current?.injectJavaScript(`window.ethereum._handleResponse(${JSON.stringify(i)});true;`)}function A(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function j(t){let{provider:n,address:r,chainId:i,supportedChainIds:a,onTransactionSent:o,onPaymentDetails:u,onSignupStatusChange:f,onSignedUp:p,onSignupDismissed:m,onError:h,onReady:g}=t,y=(0,e.useRef)(null),C=(0,e.useRef)(D(r)),w=(0,e.useRef)(i),j=(0,e.useRef)(i),M=(0,e.useRef)(new Set),N=(0,e.useCallback)(e=>{M.current.has(e)||(M.current.add(e),o?.(e))},[o]);(0,e.useEffect)(()=>{let e=O({address:C.current,propChainId:w.current,activeChainId:j.current},{address:r,chainId:i});e&&(C.current=e.nextAddress,w.current=e.nextPropChainId,j.current=e.nextActiveChainId,e.accountsChanged&&A(y,`accountsChanged`,e.accountsChanged),e.chainChanged&&A(y,`chainChanged`,e.chainChanged.chainIdHex))},[r,i]);let P=(0,e.useMemo)(()=>E({address:r,chainId:i}),[r,i]),F=(0,e.useCallback)(async(e,t,r)=>{try{let i=x(t,r,a);if(`error`in i){k(y,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),k(y,e,null),i.switchesActiveChain&&(j.current=i.requestedChainId,A(y,`chainChanged`,i.chainIdHex))}catch(t){let n=c(t,`Chain request failed`);k(y,e,void 0,l(n)),h?.(n)}},[n,a,h]),I=(0,e.useCallback)(async(e,t)=>{try{let i=t.length>0?t:[r,a.map(e=>_(e))];k(y,e,await n.request({method:`wallet_getCapabilities`,params:i}))}catch(n){let r=c(n,`Capabilities unavailable`);if(!d(r)){k(y,e,void 0,l(r));return}k(y,e,v(S(t,a),`unsupported`))}},[n,r,a]),L=(0,e.useCallback)(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=T(r);i&&N(i),k(y,e,r)}catch(t){k(y,e,void 0,l(c(t,`Failed to get call status`)))}},[n,N]),R=(0,e.useCallback)(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&N(i),k(y,e,i)}catch(t){let n=c(t,`Request failed`),r=s(n);k(y,e,void 0,r?{code:4001,message:n.message}:l(n)),r||h?.(n)}},[n,N,h]);return{uiRef:y,injectedJavaScript:P,onMessage:(0,e.useCallback)(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(t.type===`yodl_ready`){g?.();return}if(t.type===`yodl_payment_details`){u?.(t.details);return}if(t.type===`yodl_payment_error`){let e=t.error?.message??`Payment details error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),h?.(n);return}if(t.type===`yodl_signup_status`){f?.(t.status);return}if(t.type===`yodl_signup_complete`){p?.();return}if(t.type===`yodl_signup_error`){let e=t.error?.message??`Signup error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),h?.(n);return}if(t.type===`yodl_signup_dismissed`){m?.();return}if(t.type!==`ethereum_rpc_request`)return;let{id:n,method:r,params:i}=t;b(r)?F(n,r,i):r===`wallet_getCapabilities`?I(n,i):r===`wallet_getCallsStatus`?L(n,i):R(n,r,i)},[F,I,L,R,u,f,p,m,h,g])}}function M({uri:i,sdkConfig:a,provider:o,address:s,chainId:c,supportedChainIds:l,onTransactionSent:u,onPaymentDetails:d,onSignupStatusChange:m,onSignedUp:h,onSignupDismissed:_,onError:v,style:y,backgroundColor:b=`#18181b`,sharedCookiesEnabled:x=!0,thirdPartyCookiesEnabled:S=!0,...C}){let[w,T]=(0,e.useState)(!1),E=(0,e.useCallback)(()=>T(!0),[]),{uiRef:D,injectedJavaScript:O,onMessage:k}=j({provider:o,address:s,chainId:c,supportedChainIds:l,onReady:E,...u!==void 0&&{onTransactionSent:u},...d!==void 0&&{onPaymentDetails:d},...m!==void 0&&{onSignupStatusChange:m},...h!==void 0&&{onSignedUp:h},..._!==void 0&&{onSignupDismissed:_},...v!==void 0&&{onError:v}});(0,e.useEffect)(()=>{if(w)return;let e=setTimeout(E,8e3);return()=>clearTimeout(e)},[w,E]);let A=(0,e.useMemo)(()=>f(i),[i]),M=(0,e.useMemo)(()=>{let e=g(a,i);return e?{uri:i,headers:e}:{uri:i}},[a,i]),P=(0,e.useMemo)(()=>e=>A?p(e.url,A)||e.url.startsWith(`about:`):!1,[A]);return(0,t.jsxs)(n.View,{style:[N.container,{backgroundColor:b},y],children:[(0,t.jsx)(r.WebView,{ref:D,source:M,originWhitelist:A?[A]:[],onShouldStartLoadWithRequest:P,javaScriptEnabled:!0,sharedCookiesEnabled:x,thirdPartyCookiesEnabled:S,injectedJavaScriptBeforeContentLoaded:O,onMessage:k,onLoadEnd:E,style:[N.ui,{backgroundColor:b}],...C}),w?null:(0,t.jsx)(n.View,{style:[N.overlay,{backgroundColor:b}],children:(0,t.jsx)(n.ActivityIndicator,{color:`#a1a1aa`})})]})}const N=n.StyleSheet.create({container:{flex:1},ui:{flex:1},overlay:{...n.StyleSheet.absoluteFillObject,alignItems:`center`,justifyContent:`center`}});function P({onTransactionSent:n,onPaymentDetails:r,onError:i,style:a,backgroundColor:s}){let{provider:c,address:l,chainId:u,supportedChainIds:d,sdk:f}=o();return(0,t.jsx)(M,{uri:(0,e.useMemo)(()=>f.config.yodlUiBaseUrl.replace(/\/$/,``),[f.config.yodlUiBaseUrl]),sdkConfig:f.config,provider:c,address:l,chainId:u,supportedChainIds:d,...n!==void 0&&{onTransactionSent:n},...r!==void 0&&{onPaymentDetails:r},...i!==void 0&&{onError:i},...a!==void 0&&{style:a},...s!==void 0&&{backgroundColor:s}})}function F(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function I(e){if(Array.isArray(e))return e}function L(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function R(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ee(e,t,n){return t&&R(e.prototype,t),n&&R(e,n),e}function te(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function ne(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function re(e,t){return I(e)||te(e,t)||ae(e,t)||ne()}function ie(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function ae(e,t){if(e){if(typeof e==`string`)return F(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return F(e,t)}}var z=Object.defineProperty,oe=function(e,t,n){return t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},B=function(e,t){for(var n in t)z(e,n,{get:t[n],enumerable:!0})},V=function(e,t,n){return oe(e,(t===void 0?`undefined`:ie(t))===`symbol`?t:t+``,n)},se=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];function ce(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0)t=se[(o.value.charCodeAt(0)^t>>8)&255]^t<<8}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return(t^0)&65535}function H(e){for(var t=[],n=0;n<e.length;){var r=e.substring(n),i=r.substring(0,2),a=parseInt(r.substring(2,4)),o=r.substring(4,4+a);t.push({id:i,length:a,value:o}),n+=a+4}return t}function U(e){var t=``,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0){var s=o.value;if(t+=s.id,t+=(`00`+s.length).slice(-2),s.subTags){t+=U(s.subTags);continue}t+=s.value}}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return t}function W(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=ce(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function G(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=W(e,n),e}function le(e,t,n){var r=e.find(function(e){return e.id==t});return n?r?.subTags?.find(function(e){return e.id==n}):r}function K(e,t){return{id:e,length:t.length,value:t}}function q(e){var t=e.billerId,n=e.amount,r=e.ref1,i=e.ref2,a=e.ref3,o=[K(`00`,`A000000677010112`),K(`01`,t),K(`02`,r)];i&&o.push(K(`03`,i));var s=[K(`00`,`01`),K(`01`,n?`12`:`11`),K(`30`,U(o)),K(`53`,`764`),K(`58`,`TH`)];return n&&s.push(K(`54`,Number(n).toFixed(2))),a&&s.push(K(`62`,U([K(`07`,a)]))),G(U(s),`63`)}var ue=function(){"use strict";function e(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;L(this,e),V(this,`billerId`),V(this,`ref1`),V(this,`ref2`),V(this,`amount`),this.billerId=t,this.ref1=n,this.ref2=r,this.amount=i}return ee(e,[{key:`toString`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount,a=i?String(Number(i.toFixed(2))*100):`0`;return`|${t}\r${n}\r${r??``}\r${a}`}},{key:`toQrTag30`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return q({billerId:t,ref1:n,ref2:r??void 0,amount:i??void 0})}}],[{key:`fromString`,value:function(t){if(!t.startsWith(`|`))return null;var n=t.slice(1).split(`\r`,4);if(n.length!=4)return null;var r=re(n,4),i=r[0],a=r[1],o=r[2],s=r[3];return new e(i,a,o.length>0?o:null,s==`0`?null:Number((parseInt(s)/100).toFixed(2)))}}]),e}(),J=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(J||{});function de(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=U([K(`00`,`A000000677010111`),K(J[t],n)]),a=[K(`00`,`01`),K(`01`,r?`12`:`11`),K(`29`,i),K(`53`,`764`),K(`58`,`TH`)];return r&&a.push(K(`54`,Number(r).toFixed(2))),G(U(a),`63`)}B({},{ProxyType:function(){return J},anyId:function(){return de},billPayment:function(){return q},botBarcode:function(){return fe},slipVerify:function(){return pe},trueMoney:function(){return he},trueMoneySlipVerify:function(){return ge}});function fe(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new ue(t,n,r,i).toString()}function pe(e){var t=e.sendingBank,n=e.transRef;return G(U([K(`00`,U([K(`00`,`000001`),K(`01`,t),K(`02`,n)])),K(`51`,`TH`)]),`91`)}function me(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function he(e){var t=e.mobileNo,n=e.amount,r=e.message,i=U([K(`00`,`A000000677010111`),K(`03`,`14000${t}`)]),a=[K(`00`,`01`),K(`01`,n?`12`:`11`),K(`29`,i),K(`53`,`764`),K(`58`,`TH`)];return n&&a.push(K(`54`,Number(n).toFixed(2))),r&&a.push(K(`81`,me(r))),G(U(a),`63`)}function ge(e){var t=e.eventType,n=e.transactionId,r=e.date;return G(U([K(`00`,U([K(`00`,`01`),K(`01`,`01`),K(`02`,t),K(`03`,n),K(`04`,r)]))]),`91`,!1)}function Y(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function _e(e){if(Array.isArray(e))return e}function ve(e){if(Array.isArray(e))return Y(e)}function ye(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function X(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function be(e,t,n){return t&&X(e.prototype,t),n&&X(e,n),e}function xe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Se(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Ce(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function we(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Te(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){xe(e,t,n[t])})}return e}function Q(e,t){return _e(e)||Ce(e,t)||De(e,t)||we()}function Ee(e){return ve(e)||Se(e)||De(e)||Te()}function De(e,t){if(e){if(typeof e==`string`)return Y(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Y(e,t)}}B({},{anyId:function(){return Ae},bcelOneProof:function(){return ke},billPayment:function(){return je},slipVerify:function(){return Me},trueMoneySlipVerify:function(){return Ne}});var Oe=function(){"use strict";function e(t,n){ye(this,e),V(this,`payload`),V(this,`tags`),this.payload=t,this.tags=n}return be(e,[{key:`getTag`,value:function(e,t){return le(this.tags,e,t)}},{key:`getTagValue`,value:function(e,t){return this.getTag(e,t)?.value}},{key:`getTags`,value:function(){return this.tags}},{key:`getPayload`,value:function(){return this.payload}},{key:`validate`,value:function(e){var t=G(U(Ee(this.tags).filter(function(t){return t.id!=e})),e);return this.payload===t}}]),e}();function $(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e.match(/^\d{4}.+/)||t&&e.slice(-4).toUpperCase()!=W(e.slice(0,-4)))return null;var r=H(e);if(r.length==0)return null;if(n){var i=!0,a=!1,o=void 0;try{for(var s=r[Symbol.iterator](),c;!(i=(c=s.next()).done);i=!0){var l=c.value;if(!(typeof l.value!=`string`||!l.value.match(/^\d{4}.+/))){var u=H(l.value);u.every(function(e){return e.length>0&&e.length===e.value.length})&&(l.subTags=u)}}}catch(e){a=!0,o=e}finally{try{!i&&s.return!=null&&s.return()}finally{if(a)throw o}}}return new Oe(e,r)}function ke(e){var t=$(e,!0),n=t?.getTagValue(`33`,`02`),r=t?.getTagValue(`33`,`03`),i=t?.getTagValue(`33`,`04`);return t?.getTagValue(`00`)!==`01`&&t?.getTagValue(`01`)!==`11`&&t?.getTagValue(`33`,`00`)!==`BCEL`&&t?.getTagValue(`33`,`00`)!==`ONEPROOF`?null:{type:n,ticket:r,fccref:i}}function Ae(e){var t=$(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`29`,`00`);if(n!==`01`||r!==`A000000677010111`)return null;var i=Object.entries(J).find(function(e){var n=Q(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=Q(i,2),o=a[0],s=a[1],c=t.getTagValue(`29`,s);o===`MSISDN`&&c.length==13&&c.startsWith(`0066`)&&(c=`0`+c.slice(-9));var l=t?.getTagValue(`54`),u=l===void 0?void 0:parseFloat(l);return Z({type:o,target:c},u!==void 0&&{amount:u})}function je(e){var t=$(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`30`,`00`),i=t?.getTagValue(`30`,`01`),a=t?.getTagValue(`30`,`02`);if(n!==`01`||r!==`A000000677010112`||!i||!a)return null;var o=t?.getTagValue(`30`,`03`),s=t?.getTagValue(`62`,`07`),c=t?.getTagValue(`54`),l=c===void 0?void 0:parseFloat(c);return Z({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function Me(e){if(!(arguments.length>1&&arguments[1]!==void 0)||arguments[1]){var t=e.lastIndexOf(`9104`);if(t!=-1){var n=e.substring(t+4);n.length>0&&n.length<4&&(e=e.substring(0,t+4)+n.padStart(4,`0`))}}var r=$(e,!0),i=r?.getTagValue(`00`,`00`),a=r?.getTagValue(`00`,`01`),o=r?.getTagValue(`00`,`02`);return i!==`000001`||!a||!o?null:{sendingBank:a,transRef:o}}function Ne(e){var t=$(e,!0),n=t?.getTagValue(`00`,`02`),r=t?.getTagValue(`00`,`03`),i=t?.getTagValue(`00`,`04`);return t?.getTagValue(`00`,`00`)!==`01`&&t?.getTagValue(`00`,`01`)!==`01`?null:{eventType:n,transactionId:r,date:i}}const Pe={aeon:[`PH`,`VN`,`BR`,`AR`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`]};function Fe(e){return e?e.getTagValue(`58`)??null:null}function Ie(e){let t=[];for(let[n,r]of Object.entries(Pe))r.includes(e)&&t.push(n);return t}function Le(e,t,n){if(!e||typeof e!=`string`||e.trim().length===0)return[];let r=e.trim(),i=[];try{let e=Fe($(r));if(e){let n=Ie(e);for(let e of n)(!t||t.includes(e))&&i.push({provider:e,action:`resolve`});if(i.length>0)return i}}catch{}if(n){let e=n(r);e&&(!t||t.includes(`bcpilot`))&&i.push(e)}return i}function Re(e,t){return!e||typeof e!=`string`||e.trim().length===0||!Le(e).find(e=>e.action===`resolve`)?null:`${t.replace(/\/$/,``)}/resolve?data=${encodeURIComponent(e)}`}function ze({qrData:n,onTransactionSent:r,onPaymentDetails:i,onError:a,style:s,backgroundColor:c}){let{provider:l,address:u,chainId:d,supportedChainIds:f,sdk:p}=o(),m=(0,e.useMemo)(()=>Re(n,p.config.yodlUiBaseUrl),[n,p.config.yodlUiBaseUrl]);return m?(0,t.jsx)(M,{uri:m,sdkConfig:p.config,provider:l,address:u,chainId:d,supportedChainIds:f,...r!==void 0&&{onTransactionSent:r},...i!==void 0&&{onPaymentDetails:i},...a!==void 0&&{onError:a},...s!==void 0&&{style:s},...c!==void 0&&{backgroundColor:c}}):null}function Be(e){return`${e.replace(/\/$/,``)}/sdk/signup`}function Ve({onStatusChange:n,onSignedUp:r,onError:i,onDismiss:a,style:s,backgroundColor:c}){let{provider:l,address:u,chainId:d,supportedChainIds:f,sdk:p}=o();return(0,t.jsx)(M,{uri:(0,e.useMemo)(()=>Be(p.config.yodlUiBaseUrl),[p.config.yodlUiBaseUrl]),sdkConfig:p.config,provider:l,address:u,chainId:d,supportedChainIds:f,...n!==void 0&&{onSignupStatusChange:n},...r!==void 0&&{onSignedUp:r},...i!==void 0&&{onError:i},...a!==void 0&&{onSignupDismissed:a},...s!==void 0&&{style:s},...c!==void 0&&{backgroundColor:c}})}function He(e){return(Array.isArray(e)?e:[e]).some(e=>Le(e).some(e=>e.action===`resolve`))}var Ue=class{config;constructor(e){let t=m(e),n=e.supportedChainIds;if(!Array.isArray(n)||n.length===0)throw Error(`Yodl supportedChainIds is required — provide at least one chain id`);this.config={integrationId:t,yodlUiBaseUrl:e.yodlUiBaseUrl??`https://sdk-webview.yodl.me`,supportedChainIds:[...n]}}};function We(e){return new Ue(e)}exports.Yodl=Ue,exports.YodlDashboard=P,exports.YodlPayment=ze,exports.YodlProvider=a,exports.YodlSignup=Ve,exports.createSdk=We,exports.isPaymentQr=He;
|
|
228
|
+
true;`}function L(e){return JSON.stringify(e)}function R(e){return{state:e,message:null,readyAccepted:!1}}function z(e,t){return e.currentFingerprint===e.deliveredFingerprint?{state:e,message:null,readyAccepted:t}:{state:{...e,deliveredFingerprint:e.currentFingerprint},message:b(e.sessionId,e.currentTheme),readyAccepted:t}}function B(e,t){let n=L(t);return{sessionId:e,currentTheme:t,currentFingerprint:n,deliveredFingerprint:n,ready:!1}}function ge(e,t){let n=L(t);if(n===e.currentFingerprint)return R(e);let r={...e,currentTheme:t,currentFingerprint:n};return r.ready?z(r,!1):R(r)}function _e(e,t){return!p(t)||t.sessionId!==e.sessionId||e.ready?R(e):z({...e,ready:!0},!0)}function ve(e){return e.toLowerCase()}function ye(e,t){let n=ve(t.address),r=e.address!==n,i=e.propChainId!==t.chainId;if(!r&&!i)return null;let a=i&&e.activeChainId!==t.chainId;return{nextAddress:n,nextPropChainId:t.chainId,nextActiveChainId:a?t.chainId:e.activeChainId,...r?{accountsChanged:[n]}:{},...a?{chainChanged:{chainId:t.chainId,chainIdHex:I(t.chainId)}}:{}}}function V(e,t,n,r){let i=r?{id:t,error:r}:{id:t,result:n};e.current?.injectJavaScript(`window.ethereum._handleResponse(${JSON.stringify(i)});true;`)}function H(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function be(t){let{provider:n,address:r,chainId:i,supportedChainIds:a,onTransactionSent:o,onPaymentDetails:s,onSignupStatusChange:c,onSignedUp:l,onSignupDismissed:u,onError:d,onReady:f,sessionId:p,hostTheme:m=null,initialHostTheme:h=null}=t,g=(0,e.useRef)(null),_=(0,e.useRef)(ve(r)),v=(0,e.useRef)(i),y=(0,e.useRef)(i),b=(0,e.useRef)(new Set),x=(0,e.useRef)(m),S=(0,e.useRef)(p?B(p,h):null);(0,e.useLayoutEffect)(()=>{x.current=m},[m]),(0,e.useLayoutEffect)(()=>{S.current=p?B(p,h):null},[h,p]);let C=(0,e.useCallback)(e=>{b.current.has(e)||(b.current.add(e),o?.(e))},[o]);(0,e.useEffect)(()=>{let e=ye({address:_.current,propChainId:v.current,activeChainId:y.current},{address:r,chainId:i});e&&(_.current=e.nextAddress,v.current=e.nextPropChainId,y.current=e.nextActiveChainId,e.accountsChanged&&H(g,`accountsChanged`,e.accountsChanged),e.chainChanged&&H(g,`chainChanged`,e.chainChanged.chainIdHex))},[r,i]),(0,e.useEffect)(()=>{if(!S.current)return;let e=ge(S.current,m);S.current=e.state,e.message&&g.current?.postMessage(e.message)},[m]);let w=(0,e.useMemo)(()=>he({address:r,chainId:i}),[r,i]),T=(0,e.useCallback)(async(e,t,r)=>{try{let i=ue(t,r,a);if(`error`in i){V(g,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),V(g,e,null),i.switchesActiveChain&&(y.current=i.requestedChainId,H(g,`chainChanged`,i.chainIdHex))}catch(t){let n=k(t,`Chain request failed`);V(g,e,void 0,A(n)),d?.(n)}},[n,a,d]),E=(0,e.useCallback)(async(e,t)=>{try{let i=t.length>0?t:[r,a.map(e=>I(e))];V(g,e,await n.request({method:`wallet_getCapabilities`,params:i}))}catch(n){let r=k(n,`Capabilities unavailable`);if(!M(r)){V(g,e,void 0,A(r));return}V(g,e,se(de(t,a),`unsupported`))}},[n,r,a]),D=(0,e.useCallback)(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=me(r);i&&C(i),V(g,e,r)}catch(t){V(g,e,void 0,A(k(t,`Failed to get call status`)))}},[n,C]),j=(0,e.useCallback)(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&C(i),V(g,e,i)}catch(t){let n=k(t,`Request failed`),r=O(n);V(g,e,void 0,r?{code:4001,message:n.message}:A(n)),r||d?.(n)}},[n,C,d]);return{uiRef:g,injectedJavaScript:w,onMessage:(0,e.useCallback)(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(!t||typeof t!=`object`||!(`type`in t))return;if(t.type===`yodl_ready`){if(!S.current){f?.();return}let e=ge(S.current,x.current);S.current=e.state,e.message&&g.current?.postMessage(e.message);let n=_e(S.current,t);if(S.current=n.state,!n.readyAccepted)return;n.message&&g.current?.postMessage(n.message),f?.();return}if(t.type===`yodl_payment_details`){s?.(t.details);return}if(t.type===`yodl_payment_error`){let e=t.error?.message??`Payment details error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),d?.(n);return}if(t.type===`yodl_signup_status`){c?.(t.status);return}if(t.type===`yodl_signup_complete`){l?.();return}if(t.type===`yodl_signup_error`){let e=t.error?.message??`Signup error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),d?.(n);return}if(t.type===`yodl_signup_dismissed`){u?.();return}if(t.type!==`ethereum_rpc_request`)return;let{id:n,method:r,params:i}=t;le(r)?T(n,r,i):r===`wallet_getCapabilities`?E(n,i):r===`wallet_getCallsStatus`?D(n,i):j(n,r,i)},[T,E,D,j,s,c,l,u,d,f])}}function U(e){return(0,n.jsx)(xe,{...e},e.uri)}function xe({uri:i,sdkConfig:a,provider:o,address:s,chainId:c,supportedChainIds:l,onTransactionSent:u,onPaymentDetails:d,onSignupStatusChange:f,onSignedUp:p,onSignupDismissed:m,onError:h,style:g,backgroundColor:y,hostTheme:b=null,sharedCookiesEnabled:x=!0,thirdPartyCookiesEnabled:S=!0,onLoadStart:C,...w}){let[T,E]=(0,e.useState)(()=>ae(null,i,b)),D=_(b,y),O=D.background,[k,A]=(0,e.useState)(null),j=k===T.sessionId,M=(0,e.useCallback)(()=>{A(T.sessionId)},[T.sessionId]),ne=(0,e.useCallback)(e=>{let t=e?.nativeEvent?.url;t&&(C?.(e),E(e=>oe(e,t,b,k===e.sessionId)))},[b,C,k]),{uiRef:N,injectedJavaScript:re,onMessage:P}=be({provider:o,address:s,chainId:c,supportedChainIds:l,onReady:M,sessionId:T.sessionId,hostTheme:b,initialHostTheme:T.initialHostTheme,...u!==void 0&&{onTransactionSent:u},...d!==void 0&&{onPaymentDetails:d},...f!==void 0&&{onSignupStatusChange:f},...p!==void 0&&{onSignedUp:p},...m!==void 0&&{onSignupDismissed:m},...h!==void 0&&{onError:h}}),F=(0,e.useMemo)(()=>ee(i),[i]),I=(0,e.useMemo)(()=>{let e=ie(a,T.uri);return e?{uri:T.uri,headers:e}:{uri:T.uri}},[a,T.uri]),se=(0,e.useMemo)(()=>e=>!F||!e?.url?!1:te(e.url,F)||e.url.startsWith(`about:`),[F]);return(0,n.jsxs)(t.View,{style:[W.container,{backgroundColor:O},g],children:[(0,n.jsx)(r.WebView,{ref:N,source:I,originWhitelist:F?[F]:[],onShouldStartLoadWithRequest:se,javaScriptEnabled:!0,sharedCookiesEnabled:x,thirdPartyCookiesEnabled:S,injectedJavaScriptBeforeContentLoaded:re,injectedJavaScriptObject:v(T.sessionId,T.initialHostTheme,a.integrationAddress),onMessage:P,onLoadStart:ne,style:[W.ui,{backgroundColor:O}],...w},T.sessionId),j?null:(0,n.jsx)(t.View,{style:[W.overlay,{backgroundColor:O}],children:(0,n.jsx)(t.ActivityIndicator,{color:D.spinner})})]})}const W=t.StyleSheet.create({container:{flex:1},ui:{flex:1},overlay:{...t.StyleSheet.absoluteFillObject,alignItems:`center`,justifyContent:`center`}});function Se({onTransactionSent:t,onPaymentDetails:r,onError:i,style:a,backgroundColor:o,theme:s,themeMode:c}){let{provider:l,address:u,chainId:d,supportedChainIds:f,sdk:p,hostTheme:m}=D(s,c);return(0,n.jsx)(U,{uri:(0,e.useMemo)(()=>p.config.yodlUiBaseUrl.replace(/\/$/,``),[p.config.yodlUiBaseUrl]),sdkConfig:p.config,provider:l,address:u,chainId:d,supportedChainIds:f,hostTheme:m,...t!==void 0&&{onTransactionSent:t},...r!==void 0&&{onPaymentDetails:r},...i!==void 0&&{onError:i},...a!==void 0&&{style:a},...o!==void 0&&{backgroundColor:o}})}function Ce(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function we(e){if(Array.isArray(e))return e}function Te(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Ee(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function De(e,t,n){return t&&Ee(e.prototype,t),n&&Ee(e,n),e}function Oe(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function ke(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ae(e,t){return we(e)||Oe(e,t)||Me(e,t)||ke()}function je(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function Me(e,t){if(e){if(typeof e==`string`)return Ce(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ce(e,t)}}var G=Object.defineProperty,Ne=function(e,t,n){return t in e?G(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},Pe=function(e,t){for(var n in t)G(e,n,{get:t[n],enumerable:!0})},K=function(e,t,n){return Ne(e,(t===void 0?`undefined`:je(t))===`symbol`?t:t+``,n)},Fe=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];function Ie(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0)t=Fe[(o.value.charCodeAt(0)^t>>8)&255]^t<<8}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return(t^0)&65535}function Le(e){for(var t=[],n=0;n<e.length;){var r=e.substring(n),i=r.substring(0,2),a=parseInt(r.substring(2,4)),o=r.substring(4,4+a);t.push({id:i,length:a,value:o}),n+=a+4}return t}function q(e){var t=``,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0){var s=o.value;if(t+=s.id,t+=(`00`+s.length).slice(-2),s.subTags){t+=q(s.subTags);continue}t+=s.value}}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return t}function Re(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=Ie(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function J(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=Re(e,n),e}function ze(e,t,n){var r=e.find(function(e){return e.id==t});return n?r?.subTags?.find(function(e){return e.id==n}):r}function Y(e,t){return{id:e,length:t.length,value:t}}function Be(e){var t=e.billerId,n=e.amount,r=e.ref1,i=e.ref2,a=e.ref3,o=[Y(`00`,`A000000677010112`),Y(`01`,t),Y(`02`,r)];i&&o.push(Y(`03`,i));var s=[Y(`00`,`01`),Y(`01`,n?`12`:`11`),Y(`30`,q(o)),Y(`53`,`764`),Y(`58`,`TH`)];return n&&s.push(Y(`54`,Number(n).toFixed(2))),a&&s.push(Y(`62`,q([Y(`07`,a)]))),J(q(s),`63`)}var Ve=function(){"use strict";function e(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;Te(this,e),K(this,`billerId`),K(this,`ref1`),K(this,`ref2`),K(this,`amount`),this.billerId=t,this.ref1=n,this.ref2=r,this.amount=i}return De(e,[{key:`toString`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount,a=i?String(Number(i.toFixed(2))*100):`0`;return`|${t}\r${n}\r${r??``}\r${a}`}},{key:`toQrTag30`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return Be({billerId:t,ref1:n,ref2:r??void 0,amount:i??void 0})}}],[{key:`fromString`,value:function(t){if(!t.startsWith(`|`))return null;var n=t.slice(1).split(`\r`,4);if(n.length!=4)return null;var r=Ae(n,4),i=r[0],a=r[1],o=r[2],s=r[3];return new e(i,a,o.length>0?o:null,s==`0`?null:Number((parseInt(s)/100).toFixed(2)))}}]),e}(),X=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(X||{});function He(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=q([Y(`00`,`A000000677010111`),Y(X[t],n)]),a=[Y(`00`,`01`),Y(`01`,r?`12`:`11`),Y(`29`,i),Y(`53`,`764`),Y(`58`,`TH`)];return r&&a.push(Y(`54`,Number(r).toFixed(2))),J(q(a),`63`)}Pe({},{ProxyType:function(){return X},anyId:function(){return He},billPayment:function(){return Be},botBarcode:function(){return Ue},slipVerify:function(){return We},trueMoney:function(){return Ke},trueMoneySlipVerify:function(){return qe}});function Ue(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new Ve(t,n,r,i).toString()}function We(e){var t=e.sendingBank,n=e.transRef;return J(q([Y(`00`,q([Y(`00`,`000001`),Y(`01`,t),Y(`02`,n)])),Y(`51`,`TH`)]),`91`)}function Ge(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function Ke(e){var t=e.mobileNo,n=e.amount,r=e.message,i=q([Y(`00`,`A000000677010111`),Y(`03`,`14000${t}`)]),a=[Y(`00`,`01`),Y(`01`,n?`12`:`11`),Y(`29`,i),Y(`53`,`764`),Y(`58`,`TH`)];return n&&a.push(Y(`54`,Number(n).toFixed(2))),r&&a.push(Y(`81`,Ge(r))),J(q(a),`63`)}function qe(e){var t=e.eventType,n=e.transactionId,r=e.date;return J(q([Y(`00`,q([Y(`00`,`01`),Y(`01`,`01`),Y(`02`,t),Y(`03`,n),Y(`04`,r)]))]),`91`,!1)}function Z(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Je(e){if(Array.isArray(e))return e}function Ye(e){if(Array.isArray(e))return Z(e)}function Xe(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Ze(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Qe(e,t,n){return t&&Ze(e.prototype,t),n&&Ze(e,n),e}function $e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function et(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function tt(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function nt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function rt(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function it(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){$e(e,t,n[t])})}return e}function at(e,t){return Je(e)||tt(e,t)||st(e,t)||nt()}function ot(e){return Ye(e)||et(e)||st(e)||rt()}function st(e,t){if(e){if(typeof e==`string`)return Z(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Z(e,t)}}Pe({},{anyId:function(){return ut},bcelOneProof:function(){return lt},billPayment:function(){return dt},slipVerify:function(){return ft},trueMoneySlipVerify:function(){return pt}});var ct=function(){"use strict";function e(t,n){Xe(this,e),K(this,`payload`),K(this,`tags`),this.payload=t,this.tags=n}return Qe(e,[{key:`getTag`,value:function(e,t){return ze(this.tags,e,t)}},{key:`getTagValue`,value:function(e,t){return this.getTag(e,t)?.value}},{key:`getTags`,value:function(){return this.tags}},{key:`getPayload`,value:function(){return this.payload}},{key:`validate`,value:function(e){var t=J(q(ot(this.tags).filter(function(t){return t.id!=e})),e);return this.payload===t}}]),e}();function Q(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e.match(/^\d{4}.+/)||t&&e.slice(-4).toUpperCase()!=Re(e.slice(0,-4)))return null;var r=Le(e);if(r.length==0)return null;if(n){var i=!0,a=!1,o=void 0;try{for(var s=r[Symbol.iterator](),c;!(i=(c=s.next()).done);i=!0){var l=c.value;if(!(typeof l.value!=`string`||!l.value.match(/^\d{4}.+/))){var u=Le(l.value);u.every(function(e){return e.length>0&&e.length===e.value.length})&&(l.subTags=u)}}}catch(e){a=!0,o=e}finally{try{!i&&s.return!=null&&s.return()}finally{if(a)throw o}}}return new ct(e,r)}function lt(e){var t=Q(e,!0),n=t?.getTagValue(`33`,`02`),r=t?.getTagValue(`33`,`03`),i=t?.getTagValue(`33`,`04`);return t?.getTagValue(`00`)!==`01`&&t?.getTagValue(`01`)!==`11`&&t?.getTagValue(`33`,`00`)!==`BCEL`&&t?.getTagValue(`33`,`00`)!==`ONEPROOF`?null:{type:n,ticket:r,fccref:i}}function ut(e){var t=Q(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`29`,`00`);if(n!==`01`||r!==`A000000677010111`)return null;var i=Object.entries(X).find(function(e){var n=at(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=at(i,2),o=a[0],s=a[1],c=t.getTagValue(`29`,s);o===`MSISDN`&&c.length==13&&c.startsWith(`0066`)&&(c=`0`+c.slice(-9));var l=t?.getTagValue(`54`),u=l===void 0?void 0:parseFloat(l);return it({type:o,target:c},u!==void 0&&{amount:u})}function dt(e){var t=Q(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`30`,`00`),i=t?.getTagValue(`30`,`01`),a=t?.getTagValue(`30`,`02`);if(n!==`01`||r!==`A000000677010112`||!i||!a)return null;var o=t?.getTagValue(`30`,`03`),s=t?.getTagValue(`62`,`07`),c=t?.getTagValue(`54`),l=c===void 0?void 0:parseFloat(c);return it({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function ft(e){if(!(arguments.length>1&&arguments[1]!==void 0)||arguments[1]){var t=e.lastIndexOf(`9104`);if(t!=-1){var n=e.substring(t+4);n.length>0&&n.length<4&&(e=e.substring(0,t+4)+n.padStart(4,`0`))}}var r=Q(e,!0),i=r?.getTagValue(`00`,`00`),a=r?.getTagValue(`00`,`01`),o=r?.getTagValue(`00`,`02`);return i!==`000001`||!a||!o?null:{sendingBank:a,transRef:o}}function pt(e){var t=Q(e,!0),n=t?.getTagValue(`00`,`02`),r=t?.getTagValue(`00`,`03`),i=t?.getTagValue(`00`,`04`);return t?.getTagValue(`00`,`00`)!==`01`&&t?.getTagValue(`00`,`01`)!==`01`?null:{eventType:n,transactionId:r,date:i}}const mt={aeon:[`PH`,`VN`,`BR`,`AR`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`]};function ht(e){return e?e.getTagValue(`58`)??null:null}function gt(e){let t=[];for(let[n,r]of Object.entries(mt))r.includes(e)&&t.push(n);return t}function _t(e,t,n){if(!e||typeof e!=`string`||e.trim().length===0)return[];let r=e.trim(),i=[];try{let e=ht(Q(r));if(e){let n=gt(e);for(let e of n)(!t||t.includes(e))&&i.push({provider:e,action:`resolve`});if(i.length>0)return i}}catch{}if(n){let e=n(r);e&&(!t||t.includes(`bcpilot`))&&i.push(e)}return i}function vt(e,t){return!e||typeof e!=`string`||e.trim().length===0||!_t(e).find(e=>e.action===`resolve`)?null:`${t.replace(/\/$/,``)}/resolve?data=${encodeURIComponent(e)}`}function yt({qrData:t,onTransactionSent:r,onPaymentDetails:i,onError:a,style:o,backgroundColor:s,theme:c,themeMode:l}){let{provider:u,address:d,chainId:f,supportedChainIds:p,sdk:m,hostTheme:h}=D(c,l),g=(0,e.useMemo)(()=>vt(t,m.config.yodlUiBaseUrl),[t,m.config.yodlUiBaseUrl]);return g?(0,n.jsx)(U,{uri:g,sdkConfig:m.config,provider:u,address:d,chainId:f,supportedChainIds:p,hostTheme:h,...r!==void 0&&{onTransactionSent:r},...i!==void 0&&{onPaymentDetails:i},...a!==void 0&&{onError:a},...o!==void 0&&{style:o},...s!==void 0&&{backgroundColor:s}}):null}function bt(e){return`${e.replace(/\/$/,``)}/sdk/signup`}function xt({onStatusChange:t,onSignedUp:r,onError:i,onDismiss:a,style:o,backgroundColor:s,theme:c,themeMode:l}){let{provider:u,address:d,chainId:f,supportedChainIds:p,sdk:m,hostTheme:h}=D(c,l);return(0,n.jsx)(U,{uri:(0,e.useMemo)(()=>bt(m.config.yodlUiBaseUrl),[m.config.yodlUiBaseUrl]),sdkConfig:m.config,provider:u,address:d,chainId:f,supportedChainIds:p,hostTheme:h,...t!==void 0&&{onSignupStatusChange:t},...r!==void 0&&{onSignedUp:r},...i!==void 0&&{onError:i},...a!==void 0&&{onSignupDismissed:a},...o!==void 0&&{style:o},...s!==void 0&&{backgroundColor:s}})}function St(e){return(Array.isArray(e)?e:[e]).some(e=>_t(e).some(e=>e.action===`resolve`))}var $=class{config;constructor(e){let t=N(e),n=e.supportedChainIds;if(!Array.isArray(n)||n.length===0)throw Error(`Yodl supportedChainIds is required — provide at least one chain id`);this.config={integrationAddress:t,yodlUiBaseUrl:e.yodlUiBaseUrl??`https://sdk-webview.yodl.me`,supportedChainIds:[...n]}}};function Ct(e){return new $(e)}exports.Yodl=$,exports.YodlDashboard=Se,exports.YodlPayment=yt,exports.YodlProvider=T,exports.YodlSignup=xt,exports.createSdk=Ct,exports.isPaymentQr=St;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,89 @@
|
|
|
1
|
+
import { output, z } from "zod";
|
|
1
2
|
import { ViewStyle } from "react-native";
|
|
2
3
|
import { ReactNode } from "react";
|
|
3
4
|
|
|
5
|
+
//#region ../sdk-core/dist/validate-CNVgf-WX.d.mts
|
|
6
|
+
//#region src/theme/schemas.d.ts
|
|
7
|
+
/** What a host may ask for: an explicit mode, or "follow the host appearance". */
|
|
8
|
+
declare const yodlThemeModeSchema: z.ZodEnum<{
|
|
9
|
+
system: "system";
|
|
10
|
+
light: "light";
|
|
11
|
+
dark: "dark";
|
|
12
|
+
}>;
|
|
13
|
+
/** What `system` resolves to once the host appearance is known. */
|
|
14
|
+
/** One customizable Yodl theme: a light/dark palette pair plus optional media. */
|
|
15
|
+
declare const yodlThemeSchema: z.ZodObject<{
|
|
16
|
+
name: z.ZodOptional<z.ZodString>;
|
|
17
|
+
light: z.ZodOptional<z.ZodObject<{
|
|
18
|
+
bg: z.ZodOptional<z.ZodString>;
|
|
19
|
+
surface: z.ZodOptional<z.ZodString>;
|
|
20
|
+
surfaceSecondary: z.ZodOptional<z.ZodString>;
|
|
21
|
+
text: z.ZodOptional<z.ZodString>;
|
|
22
|
+
textSecondary: z.ZodOptional<z.ZodString>;
|
|
23
|
+
textMuted: z.ZodOptional<z.ZodString>;
|
|
24
|
+
border: z.ZodOptional<z.ZodString>;
|
|
25
|
+
success: z.ZodOptional<z.ZodString>;
|
|
26
|
+
error: z.ZodOptional<z.ZodString>;
|
|
27
|
+
warning: z.ZodOptional<z.ZodString>;
|
|
28
|
+
accent: z.ZodOptional<z.ZodString>;
|
|
29
|
+
bgDeep: z.ZodOptional<z.ZodString>;
|
|
30
|
+
surfaceHover: z.ZodOptional<z.ZodString>;
|
|
31
|
+
skeleton: z.ZodOptional<z.ZodString>;
|
|
32
|
+
accentStrong: z.ZodOptional<z.ZodString>;
|
|
33
|
+
accentDeep: z.ZodOptional<z.ZodString>;
|
|
34
|
+
brandSurface: z.ZodOptional<z.ZodString>;
|
|
35
|
+
brandSheet: z.ZodOptional<z.ZodString>;
|
|
36
|
+
brandText: z.ZodOptional<z.ZodString>;
|
|
37
|
+
brandButton: z.ZodOptional<z.ZodString>;
|
|
38
|
+
brandButtonText: z.ZodOptional<z.ZodString>;
|
|
39
|
+
}, z.core.$strip>>;
|
|
40
|
+
dark: z.ZodOptional<z.ZodObject<{
|
|
41
|
+
bg: z.ZodOptional<z.ZodString>;
|
|
42
|
+
surface: z.ZodOptional<z.ZodString>;
|
|
43
|
+
surfaceSecondary: z.ZodOptional<z.ZodString>;
|
|
44
|
+
text: z.ZodOptional<z.ZodString>;
|
|
45
|
+
textSecondary: z.ZodOptional<z.ZodString>;
|
|
46
|
+
textMuted: z.ZodOptional<z.ZodString>;
|
|
47
|
+
border: z.ZodOptional<z.ZodString>;
|
|
48
|
+
success: z.ZodOptional<z.ZodString>;
|
|
49
|
+
error: z.ZodOptional<z.ZodString>;
|
|
50
|
+
warning: z.ZodOptional<z.ZodString>;
|
|
51
|
+
accent: z.ZodOptional<z.ZodString>;
|
|
52
|
+
bgDeep: z.ZodOptional<z.ZodString>;
|
|
53
|
+
surfaceHover: z.ZodOptional<z.ZodString>;
|
|
54
|
+
skeleton: z.ZodOptional<z.ZodString>;
|
|
55
|
+
accentStrong: z.ZodOptional<z.ZodString>;
|
|
56
|
+
accentDeep: z.ZodOptional<z.ZodString>;
|
|
57
|
+
brandSurface: z.ZodOptional<z.ZodString>;
|
|
58
|
+
brandSheet: z.ZodOptional<z.ZodString>;
|
|
59
|
+
brandText: z.ZodOptional<z.ZodString>;
|
|
60
|
+
brandButton: z.ZodOptional<z.ZodString>;
|
|
61
|
+
brandButtonText: z.ZodOptional<z.ZodString>;
|
|
62
|
+
}, z.core.$strip>>;
|
|
63
|
+
images: z.ZodOptional<z.ZodObject<{
|
|
64
|
+
light: z.ZodOptional<z.ZodObject<{
|
|
65
|
+
payBackground: z.ZodOptional<z.ZodString>;
|
|
66
|
+
processing: z.ZodOptional<z.ZodString>;
|
|
67
|
+
loading: z.ZodOptional<z.ZodString>;
|
|
68
|
+
}, z.core.$strip>>;
|
|
69
|
+
dark: z.ZodOptional<z.ZodObject<{
|
|
70
|
+
payBackground: z.ZodOptional<z.ZodString>;
|
|
71
|
+
processing: z.ZodOptional<z.ZodString>;
|
|
72
|
+
loading: z.ZodOptional<z.ZodString>;
|
|
73
|
+
}, z.core.$strip>>;
|
|
74
|
+
}, z.core.$strict>>;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
/**
|
|
77
|
+
* The complete host-controlled theme state for one hosted session. `theme: null` means
|
|
78
|
+
* host-controlled stock Yodl, which is distinct from "no host authority at all" — the
|
|
79
|
+
* latter is expressed by not sending an envelope. Versioned so the protocol can change
|
|
80
|
+
* without silently misinterpreting older payloads.
|
|
81
|
+
*/
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/theme/contract.d.ts
|
|
84
|
+
type YodlThemeMode = output<typeof yodlThemeModeSchema>;
|
|
85
|
+
type YodlTheme = output<typeof yodlThemeSchema>;
|
|
86
|
+
//#endregion
|
|
4
87
|
//#region src/types.d.ts
|
|
5
88
|
/** Any JSON-RPC payload value — used wherever provider params/results cross the wire. */
|
|
6
89
|
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
@@ -73,6 +156,24 @@ interface YodlWallet {
|
|
|
73
156
|
/** Chain IDs the wallet can switch to. */
|
|
74
157
|
supportedChainIds: SupportedChainIds;
|
|
75
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Optional host-owned theming for the hosted Yodl UI. Both props are optional and
|
|
161
|
+
* independent: supplying either one puts the host in charge of the hosted theme;
|
|
162
|
+
* omitting both leaves the Yodl UI's own theme behavior untouched.
|
|
163
|
+
*/
|
|
164
|
+
interface YodlHostThemeProps {
|
|
165
|
+
/**
|
|
166
|
+
* A light/dark palette pair (plus optional media) applied to the hosted Yodl UI.
|
|
167
|
+
* Without `themeMode` it follows the device appearance. Keep the object stable
|
|
168
|
+
* across renders (module constant or memo) to avoid redundant theme updates.
|
|
169
|
+
*/
|
|
170
|
+
theme?: YodlTheme;
|
|
171
|
+
/**
|
|
172
|
+
* Which mode the hosted UI paints: `'system'` follows the device appearance,
|
|
173
|
+
* `'light'`/`'dark'` pin it. Supplied without `theme`, it controls stock Yodl.
|
|
174
|
+
*/
|
|
175
|
+
themeMode?: YodlThemeMode;
|
|
176
|
+
}
|
|
76
177
|
/** Event callbacks shared by the Yodl UI components and the underlying hook. */
|
|
77
178
|
interface YodlEventHandlers {
|
|
78
179
|
/** Called after a transaction is sent. */
|
|
@@ -83,7 +184,7 @@ interface YodlEventHandlers {
|
|
|
83
184
|
onError?: (error: Error) => void;
|
|
84
185
|
}
|
|
85
186
|
/** Visual props shared by all Yodl UI components. */
|
|
86
|
-
interface YodlVisualProps {
|
|
187
|
+
interface YodlVisualProps extends YodlHostThemeProps {
|
|
87
188
|
style?: ViewStyle;
|
|
88
189
|
/**
|
|
89
190
|
* Color painted behind the WebView and in the loading overlay while the Yodl
|
|
@@ -107,7 +208,9 @@ declare function YodlDashboard({
|
|
|
107
208
|
onPaymentDetails,
|
|
108
209
|
onError,
|
|
109
210
|
style,
|
|
110
|
-
backgroundColor
|
|
211
|
+
backgroundColor,
|
|
212
|
+
theme,
|
|
213
|
+
themeMode
|
|
111
214
|
}: YodlDashboardProps): import("react/jsx-runtime").JSX.Element;
|
|
112
215
|
//#endregion
|
|
113
216
|
//#region src/components/YodlPayment.d.ts
|
|
@@ -127,7 +230,9 @@ declare function YodlPayment({
|
|
|
127
230
|
onPaymentDetails,
|
|
128
231
|
onError,
|
|
129
232
|
style,
|
|
130
|
-
backgroundColor
|
|
233
|
+
backgroundColor,
|
|
234
|
+
theme,
|
|
235
|
+
themeMode
|
|
131
236
|
}: YodlPaymentProps): import("react/jsx-runtime").JSX.Element | null;
|
|
132
237
|
//#endregion
|
|
133
238
|
//#region src/components/YodlSignup.d.ts
|
|
@@ -152,7 +257,9 @@ declare function YodlSignup({
|
|
|
152
257
|
onError,
|
|
153
258
|
onDismiss,
|
|
154
259
|
style,
|
|
155
|
-
backgroundColor
|
|
260
|
+
backgroundColor,
|
|
261
|
+
theme,
|
|
262
|
+
themeMode
|
|
156
263
|
}: YodlSignupProps): import("react/jsx-runtime").JSX.Element;
|
|
157
264
|
//#endregion
|
|
158
265
|
//#region src/sdk/yodl.d.ts
|
|
@@ -165,8 +272,8 @@ declare function YodlSignup({
|
|
|
165
272
|
* methods to the host wallet.
|
|
166
273
|
*/
|
|
167
274
|
interface YodlConfig {
|
|
168
|
-
/**
|
|
169
|
-
|
|
275
|
+
/** Your integration wallet address. Identifies you to Yodl and attributes payments on chain. */
|
|
276
|
+
integrationAddress: `0x${string}`;
|
|
170
277
|
/** Base URL for the Yodl UI (default: https://sdk-webview.yodl.me). */
|
|
171
278
|
yodlUiBaseUrl?: string;
|
|
172
279
|
/** Chain IDs the host wallet can switch to. */
|
|
@@ -192,7 +299,7 @@ declare class Yodl {
|
|
|
192
299
|
declare function createSdk(config: YodlConfig): Yodl;
|
|
193
300
|
//#endregion
|
|
194
301
|
//#region src/provider/context.d.ts
|
|
195
|
-
interface YodlProviderProps {
|
|
302
|
+
interface YodlProviderProps extends YodlHostThemeProps {
|
|
196
303
|
/** The SDK instance created via createSdk(). */
|
|
197
304
|
sdk: Yodl;
|
|
198
305
|
/** EIP-1193 provider from the host wallet SDK. */
|
|
@@ -204,14 +311,16 @@ interface YodlProviderProps {
|
|
|
204
311
|
children: ReactNode;
|
|
205
312
|
}
|
|
206
313
|
/**
|
|
207
|
-
* Supplies the SDK instance
|
|
208
|
-
* to the Yodl components via React context.
|
|
314
|
+
* Supplies the SDK instance, runtime wallet state (provider/address/chainId), and
|
|
315
|
+
* the optional host theme state to the Yodl components via React context.
|
|
209
316
|
*/
|
|
210
317
|
declare function YodlProvider({
|
|
211
318
|
sdk,
|
|
212
319
|
provider,
|
|
213
320
|
address,
|
|
214
321
|
chainId,
|
|
322
|
+
theme,
|
|
323
|
+
themeMode,
|
|
215
324
|
children
|
|
216
325
|
}: YodlProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
217
326
|
//#endregion
|
|
@@ -227,4 +336,4 @@ declare function YodlProvider({
|
|
|
227
336
|
*/
|
|
228
337
|
declare function isPaymentQr(qrData: string | string[]): boolean;
|
|
229
338
|
//#endregion
|
|
230
|
-
export { type EIP1193Provider, type SupportedChainIds, Yodl, type YodlConfig, YodlDashboard, type YodlDashboardProps, YodlPayment, type YodlPaymentDetails, type YodlPaymentLifecycleStatus, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSignup, type YodlSignupProps, type YodlSignupStatus, createSdk, isPaymentQr };
|
|
339
|
+
export { type EIP1193Provider, type SupportedChainIds, Yodl, type YodlConfig, YodlDashboard, type YodlDashboardProps, YodlPayment, type YodlPaymentDetails, type YodlPaymentLifecycleStatus, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSignup, type YodlSignupProps, type YodlSignupStatus, type YodlTheme, type YodlThemeMode, createSdk, isPaymentQr };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,89 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { ViewStyle } from "react-native";
|
|
3
|
+
import { output, z } from "zod";
|
|
3
4
|
|
|
5
|
+
//#region ../sdk-core/dist/validate-CNVgf-WX.d.mts
|
|
6
|
+
//#region src/theme/schemas.d.ts
|
|
7
|
+
/** What a host may ask for: an explicit mode, or "follow the host appearance". */
|
|
8
|
+
declare const yodlThemeModeSchema: z.ZodEnum<{
|
|
9
|
+
system: "system";
|
|
10
|
+
light: "light";
|
|
11
|
+
dark: "dark";
|
|
12
|
+
}>;
|
|
13
|
+
/** What `system` resolves to once the host appearance is known. */
|
|
14
|
+
/** One customizable Yodl theme: a light/dark palette pair plus optional media. */
|
|
15
|
+
declare const yodlThemeSchema: z.ZodObject<{
|
|
16
|
+
name: z.ZodOptional<z.ZodString>;
|
|
17
|
+
light: z.ZodOptional<z.ZodObject<{
|
|
18
|
+
bg: z.ZodOptional<z.ZodString>;
|
|
19
|
+
surface: z.ZodOptional<z.ZodString>;
|
|
20
|
+
surfaceSecondary: z.ZodOptional<z.ZodString>;
|
|
21
|
+
text: z.ZodOptional<z.ZodString>;
|
|
22
|
+
textSecondary: z.ZodOptional<z.ZodString>;
|
|
23
|
+
textMuted: z.ZodOptional<z.ZodString>;
|
|
24
|
+
border: z.ZodOptional<z.ZodString>;
|
|
25
|
+
success: z.ZodOptional<z.ZodString>;
|
|
26
|
+
error: z.ZodOptional<z.ZodString>;
|
|
27
|
+
warning: z.ZodOptional<z.ZodString>;
|
|
28
|
+
accent: z.ZodOptional<z.ZodString>;
|
|
29
|
+
bgDeep: z.ZodOptional<z.ZodString>;
|
|
30
|
+
surfaceHover: z.ZodOptional<z.ZodString>;
|
|
31
|
+
skeleton: z.ZodOptional<z.ZodString>;
|
|
32
|
+
accentStrong: z.ZodOptional<z.ZodString>;
|
|
33
|
+
accentDeep: z.ZodOptional<z.ZodString>;
|
|
34
|
+
brandSurface: z.ZodOptional<z.ZodString>;
|
|
35
|
+
brandSheet: z.ZodOptional<z.ZodString>;
|
|
36
|
+
brandText: z.ZodOptional<z.ZodString>;
|
|
37
|
+
brandButton: z.ZodOptional<z.ZodString>;
|
|
38
|
+
brandButtonText: z.ZodOptional<z.ZodString>;
|
|
39
|
+
}, z.core.$strip>>;
|
|
40
|
+
dark: z.ZodOptional<z.ZodObject<{
|
|
41
|
+
bg: z.ZodOptional<z.ZodString>;
|
|
42
|
+
surface: z.ZodOptional<z.ZodString>;
|
|
43
|
+
surfaceSecondary: z.ZodOptional<z.ZodString>;
|
|
44
|
+
text: z.ZodOptional<z.ZodString>;
|
|
45
|
+
textSecondary: z.ZodOptional<z.ZodString>;
|
|
46
|
+
textMuted: z.ZodOptional<z.ZodString>;
|
|
47
|
+
border: z.ZodOptional<z.ZodString>;
|
|
48
|
+
success: z.ZodOptional<z.ZodString>;
|
|
49
|
+
error: z.ZodOptional<z.ZodString>;
|
|
50
|
+
warning: z.ZodOptional<z.ZodString>;
|
|
51
|
+
accent: z.ZodOptional<z.ZodString>;
|
|
52
|
+
bgDeep: z.ZodOptional<z.ZodString>;
|
|
53
|
+
surfaceHover: z.ZodOptional<z.ZodString>;
|
|
54
|
+
skeleton: z.ZodOptional<z.ZodString>;
|
|
55
|
+
accentStrong: z.ZodOptional<z.ZodString>;
|
|
56
|
+
accentDeep: z.ZodOptional<z.ZodString>;
|
|
57
|
+
brandSurface: z.ZodOptional<z.ZodString>;
|
|
58
|
+
brandSheet: z.ZodOptional<z.ZodString>;
|
|
59
|
+
brandText: z.ZodOptional<z.ZodString>;
|
|
60
|
+
brandButton: z.ZodOptional<z.ZodString>;
|
|
61
|
+
brandButtonText: z.ZodOptional<z.ZodString>;
|
|
62
|
+
}, z.core.$strip>>;
|
|
63
|
+
images: z.ZodOptional<z.ZodObject<{
|
|
64
|
+
light: z.ZodOptional<z.ZodObject<{
|
|
65
|
+
payBackground: z.ZodOptional<z.ZodString>;
|
|
66
|
+
processing: z.ZodOptional<z.ZodString>;
|
|
67
|
+
loading: z.ZodOptional<z.ZodString>;
|
|
68
|
+
}, z.core.$strip>>;
|
|
69
|
+
dark: z.ZodOptional<z.ZodObject<{
|
|
70
|
+
payBackground: z.ZodOptional<z.ZodString>;
|
|
71
|
+
processing: z.ZodOptional<z.ZodString>;
|
|
72
|
+
loading: z.ZodOptional<z.ZodString>;
|
|
73
|
+
}, z.core.$strip>>;
|
|
74
|
+
}, z.core.$strict>>;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
/**
|
|
77
|
+
* The complete host-controlled theme state for one hosted session. `theme: null` means
|
|
78
|
+
* host-controlled stock Yodl, which is distinct from "no host authority at all" — the
|
|
79
|
+
* latter is expressed by not sending an envelope. Versioned so the protocol can change
|
|
80
|
+
* without silently misinterpreting older payloads.
|
|
81
|
+
*/
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/theme/contract.d.ts
|
|
84
|
+
type YodlThemeMode = output<typeof yodlThemeModeSchema>;
|
|
85
|
+
type YodlTheme = output<typeof yodlThemeSchema>;
|
|
86
|
+
//#endregion
|
|
4
87
|
//#region src/types.d.ts
|
|
5
88
|
/** Any JSON-RPC payload value — used wherever provider params/results cross the wire. */
|
|
6
89
|
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
@@ -73,6 +156,24 @@ interface YodlWallet {
|
|
|
73
156
|
/** Chain IDs the wallet can switch to. */
|
|
74
157
|
supportedChainIds: SupportedChainIds;
|
|
75
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Optional host-owned theming for the hosted Yodl UI. Both props are optional and
|
|
161
|
+
* independent: supplying either one puts the host in charge of the hosted theme;
|
|
162
|
+
* omitting both leaves the Yodl UI's own theme behavior untouched.
|
|
163
|
+
*/
|
|
164
|
+
interface YodlHostThemeProps {
|
|
165
|
+
/**
|
|
166
|
+
* A light/dark palette pair (plus optional media) applied to the hosted Yodl UI.
|
|
167
|
+
* Without `themeMode` it follows the device appearance. Keep the object stable
|
|
168
|
+
* across renders (module constant or memo) to avoid redundant theme updates.
|
|
169
|
+
*/
|
|
170
|
+
theme?: YodlTheme;
|
|
171
|
+
/**
|
|
172
|
+
* Which mode the hosted UI paints: `'system'` follows the device appearance,
|
|
173
|
+
* `'light'`/`'dark'` pin it. Supplied without `theme`, it controls stock Yodl.
|
|
174
|
+
*/
|
|
175
|
+
themeMode?: YodlThemeMode;
|
|
176
|
+
}
|
|
76
177
|
/** Event callbacks shared by the Yodl UI components and the underlying hook. */
|
|
77
178
|
interface YodlEventHandlers {
|
|
78
179
|
/** Called after a transaction is sent. */
|
|
@@ -83,7 +184,7 @@ interface YodlEventHandlers {
|
|
|
83
184
|
onError?: (error: Error) => void;
|
|
84
185
|
}
|
|
85
186
|
/** Visual props shared by all Yodl UI components. */
|
|
86
|
-
interface YodlVisualProps {
|
|
187
|
+
interface YodlVisualProps extends YodlHostThemeProps {
|
|
87
188
|
style?: ViewStyle;
|
|
88
189
|
/**
|
|
89
190
|
* Color painted behind the WebView and in the loading overlay while the Yodl
|
|
@@ -107,7 +208,9 @@ declare function YodlDashboard({
|
|
|
107
208
|
onPaymentDetails,
|
|
108
209
|
onError,
|
|
109
210
|
style,
|
|
110
|
-
backgroundColor
|
|
211
|
+
backgroundColor,
|
|
212
|
+
theme,
|
|
213
|
+
themeMode
|
|
111
214
|
}: YodlDashboardProps): import("react/jsx-runtime").JSX.Element;
|
|
112
215
|
//#endregion
|
|
113
216
|
//#region src/components/YodlPayment.d.ts
|
|
@@ -127,7 +230,9 @@ declare function YodlPayment({
|
|
|
127
230
|
onPaymentDetails,
|
|
128
231
|
onError,
|
|
129
232
|
style,
|
|
130
|
-
backgroundColor
|
|
233
|
+
backgroundColor,
|
|
234
|
+
theme,
|
|
235
|
+
themeMode
|
|
131
236
|
}: YodlPaymentProps): import("react/jsx-runtime").JSX.Element | null;
|
|
132
237
|
//#endregion
|
|
133
238
|
//#region src/components/YodlSignup.d.ts
|
|
@@ -152,7 +257,9 @@ declare function YodlSignup({
|
|
|
152
257
|
onError,
|
|
153
258
|
onDismiss,
|
|
154
259
|
style,
|
|
155
|
-
backgroundColor
|
|
260
|
+
backgroundColor,
|
|
261
|
+
theme,
|
|
262
|
+
themeMode
|
|
156
263
|
}: YodlSignupProps): import("react/jsx-runtime").JSX.Element;
|
|
157
264
|
//#endregion
|
|
158
265
|
//#region src/sdk/yodl.d.ts
|
|
@@ -165,8 +272,8 @@ declare function YodlSignup({
|
|
|
165
272
|
* methods to the host wallet.
|
|
166
273
|
*/
|
|
167
274
|
interface YodlConfig {
|
|
168
|
-
/**
|
|
169
|
-
|
|
275
|
+
/** Your integration wallet address. Identifies you to Yodl and attributes payments on chain. */
|
|
276
|
+
integrationAddress: `0x${string}`;
|
|
170
277
|
/** Base URL for the Yodl UI (default: https://sdk-webview.yodl.me). */
|
|
171
278
|
yodlUiBaseUrl?: string;
|
|
172
279
|
/** Chain IDs the host wallet can switch to. */
|
|
@@ -192,7 +299,7 @@ declare class Yodl {
|
|
|
192
299
|
declare function createSdk(config: YodlConfig): Yodl;
|
|
193
300
|
//#endregion
|
|
194
301
|
//#region src/provider/context.d.ts
|
|
195
|
-
interface YodlProviderProps {
|
|
302
|
+
interface YodlProviderProps extends YodlHostThemeProps {
|
|
196
303
|
/** The SDK instance created via createSdk(). */
|
|
197
304
|
sdk: Yodl;
|
|
198
305
|
/** EIP-1193 provider from the host wallet SDK. */
|
|
@@ -204,14 +311,16 @@ interface YodlProviderProps {
|
|
|
204
311
|
children: ReactNode;
|
|
205
312
|
}
|
|
206
313
|
/**
|
|
207
|
-
* Supplies the SDK instance
|
|
208
|
-
* to the Yodl components via React context.
|
|
314
|
+
* Supplies the SDK instance, runtime wallet state (provider/address/chainId), and
|
|
315
|
+
* the optional host theme state to the Yodl components via React context.
|
|
209
316
|
*/
|
|
210
317
|
declare function YodlProvider({
|
|
211
318
|
sdk,
|
|
212
319
|
provider,
|
|
213
320
|
address,
|
|
214
321
|
chainId,
|
|
322
|
+
theme,
|
|
323
|
+
themeMode,
|
|
215
324
|
children
|
|
216
325
|
}: YodlProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
217
326
|
//#endregion
|
|
@@ -227,4 +336,4 @@ declare function YodlProvider({
|
|
|
227
336
|
*/
|
|
228
337
|
declare function isPaymentQr(qrData: string | string[]): boolean;
|
|
229
338
|
//#endregion
|
|
230
|
-
export { type EIP1193Provider, type SupportedChainIds, Yodl, type YodlConfig, YodlDashboard, type YodlDashboardProps, YodlPayment, type YodlPaymentDetails, type YodlPaymentLifecycleStatus, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSignup, type YodlSignupProps, type YodlSignupStatus, createSdk, isPaymentQr };
|
|
339
|
+
export { type EIP1193Provider, type SupportedChainIds, Yodl, type YodlConfig, YodlDashboard, type YodlDashboardProps, YodlPayment, type YodlPaymentDetails, type YodlPaymentLifecycleStatus, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSignup, type YodlSignupProps, type YodlSignupStatus, type YodlTheme, type YodlThemeMode, createSdk, isPaymentQr };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createContext as e,useCallback as t,useContext as n,useEffect as r,
|
|
1
|
+
import{createContext as e,useCallback as t,useContext as n,useEffect as r,useLayoutEffect as i,useMemo as a,useRef as o,useState as s}from"react";import{ActivityIndicator as c,StyleSheet as l,View as u,useColorScheme as d}from"react-native";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{WebView as m}from"react-native-webview";const h=/^(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\(\s*[\d.%\s,/]+\s*\))$/i,g=/^https:\/\/[^\s"\\]+$/,_=[`bg`,`surface`,`surfaceSecondary`,`text`,`textSecondary`,`textMuted`,`border`,`success`,`error`,`warning`,`accent`,`bgDeep`,`surfaceHover`,`skeleton`,`accentStrong`,`accentDeep`,`brandSurface`,`brandSheet`,`brandText`,`brandButton`,`brandButtonText`],v=[`payBackground`,`processing`,`loading`];function y(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function b(e,t){if(!y(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of _){let i=e[r];if(i!==void 0){if(typeof i!=`string`||!h.test(i))return{success:!1,error:`${t}.${r}: colors must be hex, rgb() or rgba()`};n[r]=i}}return{success:!0,data:n}}function x(e,t){if(!y(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of v){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>2048||!g.test(i))return{success:!1,error:`${t}.${r}: images must be https:// URLs`};n[r]=i}}return{success:!0,data:n}}function S(e){if(!y(e))return{success:!1,error:`images: expected an object`};let t=Object.keys(e).find(e=>e!==`light`&&e!==`dark`);if(t)return{success:!1,error:`images.${t}: unknown key`};let n={};for(let t of[`light`,`dark`]){if(e[t]===void 0)continue;let r=x(e[t],`images.${t}`);if(!r.success)return r;n[t]=r.data}return{success:!0,data:n}}function C(e){if(!y(e))return{success:!1,error:`(root): expected an object`};let t={};if(e.name!==void 0){if(typeof e.name!=`string`||e.name.length>64)return{success:!1,error:`name: must be a string of at most 64 characters`};t.name=e.name}for(let n of[`light`,`dark`]){if(e[n]===void 0)continue;let r=b(e[n],n);if(!r.success)return r;t[n]=r.data}if(e.images!==void 0){let n=S(e.images);if(!n.success)return n;t.images=n.data}return{success:!0,data:t}}function w(e){return!y(e)||Object.keys(e).length!==3?!1:e.type===`yodl_ready`&&e.version===1&&typeof e.sessionId==`string`&&e.sessionId.length>=1&&e.sessionId.length<=128}const T={light:{background:`#f8f8fc`,spinner:`#52525b`},dark:{background:`#18181b`,spinner:`#a1a1aa`}};function E(e,t){return e===`system`?t===`light`?`light`:`dark`:e}function D(e,t,n){if(e===void 0&&t===void 0)return{envelope:null,error:null};let r=e===void 0?null:C(e),i=t===void 0||t===`system`||t===`light`||t===`dark`,a=i?t??`system`:`system`,o=[r&&!r.success?`Invalid Yodl theme — ${r.error}`:null,i?null:`Invalid Yodl themeMode — themeMode must be system, light or dark`].filter(e=>e!==null);return{envelope:{version:1,authority:`host`,theme:r?.success?r.data:null,preference:a,resolved:E(a,n)},error:o.length>0?o.join(`; `):null}}function ee(e,t){let n=T[e?e.resolved:`dark`],r=e?.theme?.[e.resolved];return{background:t??r?.bg??n.background,spinner:r?.textSecondary??n.spinner}}function O(e,t,n){return{yodl:{version:1,sessionId:e,...t?{hostTheme:t}:{},...n?{integrationAddress:n}:{}}}}function k(e,t){return t?{channel:`yodl`,sessionId:e,type:`theme:update`,payload:t}:{channel:`yodl`,sessionId:e,type:`theme:release`}}function A(e,t){return JSON.stringify(k(e,t))}function j(e,t,n,r){let{envelope:i,error:a}=D(e,t,n);return a&&r?.(a),i}function M(e,t,n,r,i){if(t===void 0&&n===void 0)return e;let{envelope:a,error:o}=D(t??e?.theme??void 0,n??e?.preference,r);return o&&i?.(o),a}function N(e){typeof __DEV__<`u`&&__DEV__&&console.error(`[@yodlpay/react-native] ${e}`)}const P=e(null);function te({sdk:e,provider:t,address:n,chainId:r,theme:i,themeMode:o,children:s}){let c=d(),l=a(()=>j(i,o,c,N),[i,o,c]),u=a(()=>({sdk:e,provider:t,address:n,chainId:r,supportedChainIds:e.config.supportedChainIds,hostTheme:l,systemScheme:c}),[e,t,n,r,l,c]);return f(P.Provider,{value:u,children:s})}function ne(){let e=n(P);if(!e)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return e}function F(e,t){let n=ne(),r=a(()=>M(n.hostTheme,e,t,n.systemScheme,N),[n.hostTheme,n.systemScheme,e,t]);return{...n,hostTheme:r}}function I(e){if(e.code===4001)return!0;let t=e.message.toLowerCase();return t.includes(`rejected`)||t.includes(`denied`)}function L(e,t){if(e instanceof Error)return e;if(typeof e==`object`&&e){let t=e;if(typeof t.message==`string`){let e=Error(t.message);return typeof t.code==`number`&&(e.code=t.code),e}}return Error(t)}function R(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function z(e){if(typeof e!=`string`||!/^0x(?:0|[1-9a-f][0-9a-f]*)$/i.test(e))return;let t=Number.parseInt(e,16);return Number.isSafeInteger(t)?t:void 0}function re(e){let t=e.code;if(t===4200||t===-32601)return!0;let n=e.message.toLowerCase();return n.includes(`method not found`)||n.includes(`method not supported`)||n.includes(`unsupported method`)||n.includes(`unsupported wc_ method`)||n.includes(`not supported`)||n.includes(`does not exist`)||n.includes(`not available`)}function ie(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function ae(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}const oe=/^0x[a-fA-F0-9]{40}$/;function se(e){let t=e?.integrationAddress?.trim();if(!t)throw Error(`Yodl integrationAddress is required`);if(!oe.test(t))throw Error(`Yodl integrationAddress is not a valid address: ${t}`);return t}function ce(e){return{"X-Yodl-Integration-Id":se(e),"X-Yodl-SDK-Name":`@yodlpay/react-native`,"X-Yodl-SDK-Version":`0.5.0`}}function le(e,t){let n=e.yodlUiBaseUrl?ie(e.yodlUiBaseUrl):null;if(!(!n||!ae(t,n)))return ce(e)}let ue=0;function de(){return ue+=1,`yodl-${Date.now().toString(36)}-${ue.toString(36)}`}function fe(e,t,n,r=de){return e?.uri===t?e:{uri:t,sessionId:r(),initialHostTheme:n}}function pe(e,t,n,r,i=de){return r?{uri:t,sessionId:i(),initialHostTheme:n}:e}function B(e){return`0x${e.toString(16)}`}function me(e,t=`unsupported`){let n={};for(let r of e)n[B(r)]={atomic:{status:t}};return n}const he=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function ge(e){return he.some(t=>t===e)}function _e(e,t,n){if(!ge(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=z((t[0]??{}).chainId);if(typeof r!=`number`)return{error:{code:-32602,message:`Missing or invalid chainId parameter`}};if(!n.includes(r))return{error:{code:4902,message:`Chain ${r} not supported`}};let i=B(r);return{providerMethod:e,providerParams:e===`wallet_switchEthereumChain`?[{chainId:i}]:t,requestedChainId:r,chainIdHex:i,switchesActiveChain:e===`wallet_switchEthereumChain`}}function ve(e,t){let n=e[1];return Array.isArray(n)?n.map(e=>z(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function ye(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function be(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function xe(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!ye(t))return;let n=t.receipts;if(n?.length&&!n.some(be))return n[n.length-1]?.transactionHash}function Se(e){let t=B(e.chainId);return`(function() {
|
|
2
2
|
if (window.ethereum) return;
|
|
3
3
|
|
|
4
4
|
var _address = ${JSON.stringify(e.address.toLowerCase())};
|
|
@@ -225,4 +225,4 @@ import{createContext as e,useCallback as t,useContext as n,useEffect as r,useMem
|
|
|
225
225
|
announceProvider();
|
|
226
226
|
window.addEventListener("eip6963:requestProvider", announceProvider);
|
|
227
227
|
})();
|
|
228
|
-
true;`}function P(e){return e.toLowerCase()}function F(e,t){let n=P(t.address),r=e.address!==n,i=e.propChainId!==t.chainId;if(!r&&!i)return null;let a=i&&e.activeChainId!==t.chainId;return{nextAddress:n,nextPropChainId:t.chainId,nextActiveChainId:a?t.chainId:e.activeChainId,...r?{accountsChanged:[n]}:{},...a?{chainChanged:{chainId:t.chainId,chainIdHex:E(t.chainId)}}:{}}}function I(e,t,n,r){let i=r?{id:t,error:r}:{id:t,result:n};e.current?.injectJavaScript(`window.ethereum._handleResponse(${JSON.stringify(i)});true;`)}function L(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function R(e){let{provider:n,address:o,chainId:s,supportedChainIds:c,onTransactionSent:l,onPaymentDetails:u,onSignupStatusChange:d,onSignedUp:f,onSignupDismissed:p,onError:m,onReady:h}=e,y=a(null),x=a(P(o)),S=a(s),C=a(s),w=a(new Set),T=t(e=>{w.current.has(e)||(w.current.add(e),l?.(e))},[l]);r(()=>{let e=F({address:x.current,propChainId:S.current,activeChainId:C.current},{address:o,chainId:s});e&&(x.current=e.nextAddress,S.current=e.nextPropChainId,C.current=e.nextActiveChainId,e.accountsChanged&&L(y,`accountsChanged`,e.accountsChanged),e.chainChanged&&L(y,`chainChanged`,e.chainChanged.chainIdHex))},[o,s]);let D=i(()=>N({address:o,chainId:s}),[o,s]),A=t(async(e,t,r)=>{try{let i=te(t,r,c);if(`error`in i){I(y,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),I(y,e,null),i.switchesActiveChain&&(C.current=i.requestedChainId,L(y,`chainChanged`,i.chainIdHex))}catch(t){let n=_(t,`Chain request failed`);I(y,e,void 0,v(n)),m?.(n)}},[n,c,m]),j=t(async(e,t)=>{try{let r=t.length>0?t:[o,c.map(e=>E(e))];I(y,e,await n.request({method:`wallet_getCapabilities`,params:r}))}catch(n){let r=_(n,`Capabilities unavailable`);if(!b(r)){I(y,e,void 0,v(r));return}I(y,e,ee(k(t,c),`unsupported`))}},[n,o,c]),R=t(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=M(r);i&&T(i),I(y,e,r)}catch(t){I(y,e,void 0,v(_(t,`Failed to get call status`)))}},[n,T]),z=t(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&T(i),I(y,e,i)}catch(t){let n=_(t,`Request failed`),r=g(n);I(y,e,void 0,r?{code:4001,message:n.message}:v(n)),r||m?.(n)}},[n,T,m]);return{uiRef:y,injectedJavaScript:D,onMessage:t(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(t.type===`yodl_ready`){h?.();return}if(t.type===`yodl_payment_details`){u?.(t.details);return}if(t.type===`yodl_payment_error`){let e=t.error?.message??`Payment details error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),m?.(n);return}if(t.type===`yodl_signup_status`){d?.(t.status);return}if(t.type===`yodl_signup_complete`){f?.();return}if(t.type===`yodl_signup_error`){let e=t.error?.message??`Signup error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),m?.(n);return}if(t.type===`yodl_signup_dismissed`){p?.();return}if(t.type!==`ethereum_rpc_request`)return;let{id:n,method:r,params:i}=t;O(r)?A(n,r,i):r===`wallet_getCapabilities`?j(n,i):r===`wallet_getCallsStatus`?R(n,i):z(n,r,i)},[A,j,R,z,u,d,f,p,m,h])}}function z({uri:e,sdkConfig:n,provider:a,address:u,chainId:p,supportedChainIds:m,onTransactionSent:h,onPaymentDetails:g,onSignupStatusChange:_,onSignedUp:v,onSignupDismissed:y,onError:b,style:C,backgroundColor:w=`#18181b`,sharedCookiesEnabled:E=!0,thirdPartyCookiesEnabled:ee=!0,...D}){let[O,te]=o(!1),k=t(()=>te(!0),[]),{uiRef:A,injectedJavaScript:j,onMessage:M}=R({provider:a,address:u,chainId:p,supportedChainIds:m,onReady:k,...h!==void 0&&{onTransactionSent:h},...g!==void 0&&{onPaymentDetails:g},..._!==void 0&&{onSignupStatusChange:_},...v!==void 0&&{onSignedUp:v},...y!==void 0&&{onSignupDismissed:y},...b!==void 0&&{onError:b}});r(()=>{if(O)return;let e=setTimeout(k,8e3);return()=>clearTimeout(e)},[O,k]);let N=i(()=>x(e),[e]),P=i(()=>{let t=T(n,e);return t?{uri:e,headers:t}:{uri:e}},[n,e]),F=i(()=>e=>N?S(e.url,N)||e.url.startsWith(`about:`):!1,[N]);return c(d,{style:[B.container,{backgroundColor:w},C],children:[s(f,{ref:A,source:P,originWhitelist:N?[N]:[],onShouldStartLoadWithRequest:F,javaScriptEnabled:!0,sharedCookiesEnabled:E,thirdPartyCookiesEnabled:ee,injectedJavaScriptBeforeContentLoaded:j,onMessage:M,onLoadEnd:k,style:[B.ui,{backgroundColor:w}],...D}),O?null:s(d,{style:[B.overlay,{backgroundColor:w}],children:s(l,{color:`#a1a1aa`})})]})}const B=u.create({container:{flex:1},ui:{flex:1},overlay:{...u.absoluteFillObject,alignItems:`center`,justifyContent:`center`}});function ne({onTransactionSent:e,onPaymentDetails:t,onError:n,style:r,backgroundColor:a}){let{provider:o,address:c,chainId:l,supportedChainIds:u,sdk:d}=h();return s(z,{uri:i(()=>d.config.yodlUiBaseUrl.replace(/\/$/,``),[d.config.yodlUiBaseUrl]),sdkConfig:d.config,provider:o,address:c,chainId:l,supportedChainIds:u,...e!==void 0&&{onTransactionSent:e},...t!==void 0&&{onPaymentDetails:t},...n!==void 0&&{onError:n},...r!==void 0&&{style:r},...a!==void 0&&{backgroundColor:a}})}function V(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function re(e){if(Array.isArray(e))return e}function ie(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function H(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ae(e,t,n){return t&&H(e.prototype,t),n&&H(e,n),e}function oe(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function se(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ce(e,t){return re(e)||oe(e,t)||ue(e,t)||se()}function le(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function ue(e,t){if(e){if(typeof e==`string`)return V(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return V(e,t)}}var U=Object.defineProperty,de=function(e,t,n){return t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},W=function(e,t){for(var n in t)U(e,n,{get:t[n],enumerable:!0})},G=function(e,t,n){return de(e,(t===void 0?`undefined`:le(t))===`symbol`?t:t+``,n)},fe=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];function pe(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0)t=fe[(o.value.charCodeAt(0)^t>>8)&255]^t<<8}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return(t^0)&65535}function K(e){for(var t=[],n=0;n<e.length;){var r=e.substring(n),i=r.substring(0,2),a=parseInt(r.substring(2,4)),o=r.substring(4,4+a);t.push({id:i,length:a,value:o}),n+=a+4}return t}function q(e){var t=``,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0){var s=o.value;if(t+=s.id,t+=(`00`+s.length).slice(-2),s.subTags){t+=q(s.subTags);continue}t+=s.value}}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return t}function J(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=pe(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function Y(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=J(e,n),e}function me(e,t,n){var r=e.find(function(e){return e.id==t});return n?r?.subTags?.find(function(e){return e.id==n}):r}function X(e,t){return{id:e,length:t.length,value:t}}function he(e){var t=e.billerId,n=e.amount,r=e.ref1,i=e.ref2,a=e.ref3,o=[X(`00`,`A000000677010112`),X(`01`,t),X(`02`,r)];i&&o.push(X(`03`,i));var s=[X(`00`,`01`),X(`01`,n?`12`:`11`),X(`30`,q(o)),X(`53`,`764`),X(`58`,`TH`)];return n&&s.push(X(`54`,Number(n).toFixed(2))),a&&s.push(X(`62`,q([X(`07`,a)]))),Y(q(s),`63`)}var ge=function(){function e(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;ie(this,e),G(this,`billerId`),G(this,`ref1`),G(this,`ref2`),G(this,`amount`),this.billerId=t,this.ref1=n,this.ref2=r,this.amount=i}return ae(e,[{key:`toString`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount,a=i?String(Number(i.toFixed(2))*100):`0`;return`|${t}\r${n}\r${r??``}\r${a}`}},{key:`toQrTag30`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return he({billerId:t,ref1:n,ref2:r??void 0,amount:i??void 0})}}],[{key:`fromString`,value:function(t){if(!t.startsWith(`|`))return null;var n=t.slice(1).split(`\r`,4);if(n.length!=4)return null;var r=ce(n,4),i=r[0],a=r[1],o=r[2],s=r[3];return new e(i,a,o.length>0?o:null,s==`0`?null:Number((parseInt(s)/100).toFixed(2)))}}]),e}(),Z=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(Z||{});function _e(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=q([X(`00`,`A000000677010111`),X(Z[t],n)]),a=[X(`00`,`01`),X(`01`,r?`12`:`11`),X(`29`,i),X(`53`,`764`),X(`58`,`TH`)];return r&&a.push(X(`54`,Number(r).toFixed(2))),Y(q(a),`63`)}W({},{ProxyType:function(){return Z},anyId:function(){return _e},billPayment:function(){return he},botBarcode:function(){return ve},slipVerify:function(){return ye},trueMoney:function(){return xe},trueMoneySlipVerify:function(){return Se}});function ve(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new ge(t,n,r,i).toString()}function ye(e){var t=e.sendingBank,n=e.transRef;return Y(q([X(`00`,q([X(`00`,`000001`),X(`01`,t),X(`02`,n)])),X(`51`,`TH`)]),`91`)}function be(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function xe(e){var t=e.mobileNo,n=e.amount,r=e.message,i=q([X(`00`,`A000000677010111`),X(`03`,`14000${t}`)]),a=[X(`00`,`01`),X(`01`,n?`12`:`11`),X(`29`,i),X(`53`,`764`),X(`58`,`TH`)];return n&&a.push(X(`54`,Number(n).toFixed(2))),r&&a.push(X(`81`,be(r))),Y(q(a),`63`)}function Se(e){var t=e.eventType,n=e.transactionId,r=e.date;return Y(q([X(`00`,q([X(`00`,`01`),X(`01`,`01`),X(`02`,t),X(`03`,n),X(`04`,r)]))]),`91`,!1)}function Q(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Ce(e){if(Array.isArray(e))return e}function we(e){if(Array.isArray(e))return Q(e)}function Te(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Ee(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function De(e,t,n){return t&&Ee(e.prototype,t),n&&Ee(e,n),e}function Oe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ke(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Ae(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function je(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Me(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ne(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){Oe(e,t,n[t])})}return e}function Pe(e,t){return Ce(e)||Ae(e,t)||Ie(e,t)||je()}function Fe(e){return we(e)||ke(e)||Ie(e)||Me()}function Ie(e,t){if(e){if(typeof e==`string`)return Q(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Q(e,t)}}W({},{anyId:function(){return ze},bcelOneProof:function(){return Re},billPayment:function(){return Be},slipVerify:function(){return Ve},trueMoneySlipVerify:function(){return He}});var Le=function(){function e(t,n){Te(this,e),G(this,`payload`),G(this,`tags`),this.payload=t,this.tags=n}return De(e,[{key:`getTag`,value:function(e,t){return me(this.tags,e,t)}},{key:`getTagValue`,value:function(e,t){return this.getTag(e,t)?.value}},{key:`getTags`,value:function(){return this.tags}},{key:`getPayload`,value:function(){return this.payload}},{key:`validate`,value:function(e){var t=Y(q(Fe(this.tags).filter(function(t){return t.id!=e})),e);return this.payload===t}}]),e}();function $(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e.match(/^\d{4}.+/)||t&&e.slice(-4).toUpperCase()!=J(e.slice(0,-4)))return null;var r=K(e);if(r.length==0)return null;if(n){var i=!0,a=!1,o=void 0;try{for(var s=r[Symbol.iterator](),c;!(i=(c=s.next()).done);i=!0){var l=c.value;if(!(typeof l.value!=`string`||!l.value.match(/^\d{4}.+/))){var u=K(l.value);u.every(function(e){return e.length>0&&e.length===e.value.length})&&(l.subTags=u)}}}catch(e){a=!0,o=e}finally{try{!i&&s.return!=null&&s.return()}finally{if(a)throw o}}}return new Le(e,r)}function Re(e){var t=$(e,!0),n=t?.getTagValue(`33`,`02`),r=t?.getTagValue(`33`,`03`),i=t?.getTagValue(`33`,`04`);return t?.getTagValue(`00`)!==`01`&&t?.getTagValue(`01`)!==`11`&&t?.getTagValue(`33`,`00`)!==`BCEL`&&t?.getTagValue(`33`,`00`)!==`ONEPROOF`?null:{type:n,ticket:r,fccref:i}}function ze(e){var t=$(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`29`,`00`);if(n!==`01`||r!==`A000000677010111`)return null;var i=Object.entries(Z).find(function(e){var n=Pe(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=Pe(i,2),o=a[0],s=a[1],c=t.getTagValue(`29`,s);o===`MSISDN`&&c.length==13&&c.startsWith(`0066`)&&(c=`0`+c.slice(-9));var l=t?.getTagValue(`54`),u=l===void 0?void 0:parseFloat(l);return Ne({type:o,target:c},u!==void 0&&{amount:u})}function Be(e){var t=$(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`30`,`00`),i=t?.getTagValue(`30`,`01`),a=t?.getTagValue(`30`,`02`);if(n!==`01`||r!==`A000000677010112`||!i||!a)return null;var o=t?.getTagValue(`30`,`03`),s=t?.getTagValue(`62`,`07`),c=t?.getTagValue(`54`),l=c===void 0?void 0:parseFloat(c);return Ne({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function Ve(e){if(!(arguments.length>1&&arguments[1]!==void 0)||arguments[1]){var t=e.lastIndexOf(`9104`);if(t!=-1){var n=e.substring(t+4);n.length>0&&n.length<4&&(e=e.substring(0,t+4)+n.padStart(4,`0`))}}var r=$(e,!0),i=r?.getTagValue(`00`,`00`),a=r?.getTagValue(`00`,`01`),o=r?.getTagValue(`00`,`02`);return i!==`000001`||!a||!o?null:{sendingBank:a,transRef:o}}function He(e){var t=$(e,!0),n=t?.getTagValue(`00`,`02`),r=t?.getTagValue(`00`,`03`),i=t?.getTagValue(`00`,`04`);return t?.getTagValue(`00`,`00`)!==`01`&&t?.getTagValue(`00`,`01`)!==`01`?null:{eventType:n,transactionId:r,date:i}}const Ue={aeon:[`PH`,`VN`,`BR`,`AR`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`]};function We(e){return e?e.getTagValue(`58`)??null:null}function Ge(e){let t=[];for(let[n,r]of Object.entries(Ue))r.includes(e)&&t.push(n);return t}function Ke(e,t,n){if(!e||typeof e!=`string`||e.trim().length===0)return[];let r=e.trim(),i=[];try{let e=We($(r));if(e){let n=Ge(e);for(let e of n)(!t||t.includes(e))&&i.push({provider:e,action:`resolve`});if(i.length>0)return i}}catch{}if(n){let e=n(r);e&&(!t||t.includes(`bcpilot`))&&i.push(e)}return i}function qe(e,t){return!e||typeof e!=`string`||e.trim().length===0||!Ke(e).find(e=>e.action===`resolve`)?null:`${t.replace(/\/$/,``)}/resolve?data=${encodeURIComponent(e)}`}function Je({qrData:e,onTransactionSent:t,onPaymentDetails:n,onError:r,style:a,backgroundColor:o}){let{provider:c,address:l,chainId:u,supportedChainIds:d,sdk:f}=h(),p=i(()=>qe(e,f.config.yodlUiBaseUrl),[e,f.config.yodlUiBaseUrl]);return p?s(z,{uri:p,sdkConfig:f.config,provider:c,address:l,chainId:u,supportedChainIds:d,...t!==void 0&&{onTransactionSent:t},...n!==void 0&&{onPaymentDetails:n},...r!==void 0&&{onError:r},...a!==void 0&&{style:a},...o!==void 0&&{backgroundColor:o}}):null}function Ye(e){return`${e.replace(/\/$/,``)}/sdk/signup`}function Xe({onStatusChange:e,onSignedUp:t,onError:n,onDismiss:r,style:a,backgroundColor:o}){let{provider:c,address:l,chainId:u,supportedChainIds:d,sdk:f}=h();return s(z,{uri:i(()=>Ye(f.config.yodlUiBaseUrl),[f.config.yodlUiBaseUrl]),sdkConfig:f.config,provider:c,address:l,chainId:u,supportedChainIds:d,...e!==void 0&&{onSignupStatusChange:e},...t!==void 0&&{onSignedUp:t},...n!==void 0&&{onError:n},...r!==void 0&&{onSignupDismissed:r},...a!==void 0&&{style:a},...o!==void 0&&{backgroundColor:o}})}function Ze(e){return(Array.isArray(e)?e:[e]).some(e=>Ke(e).some(e=>e.action===`resolve`))}var Qe=class{config;constructor(e){let t=C(e),n=e.supportedChainIds;if(!Array.isArray(n)||n.length===0)throw Error(`Yodl supportedChainIds is required — provide at least one chain id`);this.config={integrationId:t,yodlUiBaseUrl:e.yodlUiBaseUrl??`https://sdk-webview.yodl.me`,supportedChainIds:[...n]}}};function $e(e){return new Qe(e)}export{Qe as Yodl,ne as YodlDashboard,Je as YodlPayment,m as YodlProvider,Xe as YodlSignup,$e as createSdk,Ze as isPaymentQr};
|
|
228
|
+
true;`}function Ce(e){return JSON.stringify(e)}function V(e){return{state:e,message:null,readyAccepted:!1}}function we(e,t){return e.currentFingerprint===e.deliveredFingerprint?{state:e,message:null,readyAccepted:t}:{state:{...e,deliveredFingerprint:e.currentFingerprint},message:A(e.sessionId,e.currentTheme),readyAccepted:t}}function Te(e,t){let n=Ce(t);return{sessionId:e,currentTheme:t,currentFingerprint:n,deliveredFingerprint:n,ready:!1}}function H(e,t){let n=Ce(t);if(n===e.currentFingerprint)return V(e);let r={...e,currentTheme:t,currentFingerprint:n};return r.ready?we(r,!1):V(r)}function Ee(e,t){return!w(t)||t.sessionId!==e.sessionId||e.ready?V(e):we({...e,ready:!0},!0)}function De(e){return e.toLowerCase()}function Oe(e,t){let n=De(t.address),r=e.address!==n,i=e.propChainId!==t.chainId;if(!r&&!i)return null;let a=i&&e.activeChainId!==t.chainId;return{nextAddress:n,nextPropChainId:t.chainId,nextActiveChainId:a?t.chainId:e.activeChainId,...r?{accountsChanged:[n]}:{},...a?{chainChanged:{chainId:t.chainId,chainIdHex:B(t.chainId)}}:{}}}function U(e,t,n,r){let i=r?{id:t,error:r}:{id:t,result:n};e.current?.injectJavaScript(`window.ethereum._handleResponse(${JSON.stringify(i)});true;`)}function W(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function ke(e){let{provider:n,address:s,chainId:c,supportedChainIds:l,onTransactionSent:u,onPaymentDetails:d,onSignupStatusChange:f,onSignedUp:p,onSignupDismissed:m,onError:h,onReady:g,sessionId:_,hostTheme:v=null,initialHostTheme:y=null}=e,b=o(null),x=o(De(s)),S=o(c),C=o(c),w=o(new Set),T=o(v),E=o(_?Te(_,y):null);i(()=>{T.current=v},[v]),i(()=>{E.current=_?Te(_,y):null},[y,_]);let D=t(e=>{w.current.has(e)||(w.current.add(e),u?.(e))},[u]);r(()=>{let e=Oe({address:x.current,propChainId:S.current,activeChainId:C.current},{address:s,chainId:c});e&&(x.current=e.nextAddress,S.current=e.nextPropChainId,C.current=e.nextActiveChainId,e.accountsChanged&&W(b,`accountsChanged`,e.accountsChanged),e.chainChanged&&W(b,`chainChanged`,e.chainChanged.chainIdHex))},[s,c]),r(()=>{if(!E.current)return;let e=H(E.current,v);E.current=e.state,e.message&&b.current?.postMessage(e.message)},[v]);let ee=a(()=>Se({address:s,chainId:c}),[s,c]),O=t(async(e,t,r)=>{try{let i=_e(t,r,l);if(`error`in i){U(b,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),U(b,e,null),i.switchesActiveChain&&(C.current=i.requestedChainId,W(b,`chainChanged`,i.chainIdHex))}catch(t){let n=L(t,`Chain request failed`);U(b,e,void 0,R(n)),h?.(n)}},[n,l,h]),k=t(async(e,t)=>{try{let r=t.length>0?t:[s,l.map(e=>B(e))];U(b,e,await n.request({method:`wallet_getCapabilities`,params:r}))}catch(n){let r=L(n,`Capabilities unavailable`);if(!re(r)){U(b,e,void 0,R(r));return}U(b,e,me(ve(t,l),`unsupported`))}},[n,s,l]),A=t(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=xe(r);i&&D(i),U(b,e,r)}catch(t){U(b,e,void 0,R(L(t,`Failed to get call status`)))}},[n,D]),j=t(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&D(i),U(b,e,i)}catch(t){let n=L(t,`Request failed`),r=I(n);U(b,e,void 0,r?{code:4001,message:n.message}:R(n)),r||h?.(n)}},[n,D,h]);return{uiRef:b,injectedJavaScript:ee,onMessage:t(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(!t||typeof t!=`object`||!(`type`in t))return;if(t.type===`yodl_ready`){if(!E.current){g?.();return}let e=H(E.current,T.current);E.current=e.state,e.message&&b.current?.postMessage(e.message);let n=Ee(E.current,t);if(E.current=n.state,!n.readyAccepted)return;n.message&&b.current?.postMessage(n.message),g?.();return}if(t.type===`yodl_payment_details`){d?.(t.details);return}if(t.type===`yodl_payment_error`){let e=t.error?.message??`Payment details error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),h?.(n);return}if(t.type===`yodl_signup_status`){f?.(t.status);return}if(t.type===`yodl_signup_complete`){p?.();return}if(t.type===`yodl_signup_error`){let e=t.error?.message??`Signup error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),h?.(n);return}if(t.type===`yodl_signup_dismissed`){m?.();return}if(t.type!==`ethereum_rpc_request`)return;let{id:n,method:r,params:i}=t;ge(r)?O(n,r,i):r===`wallet_getCapabilities`?k(n,i):r===`wallet_getCallsStatus`?A(n,i):j(n,r,i)},[O,k,A,j,d,f,p,m,h,g])}}function G(e){return f(Ae,{...e},e.uri)}function Ae({uri:e,sdkConfig:n,provider:r,address:i,chainId:o,supportedChainIds:l,onTransactionSent:d,onPaymentDetails:h,onSignupStatusChange:g,onSignedUp:_,onSignupDismissed:v,onError:y,style:b,backgroundColor:x,hostTheme:S=null,sharedCookiesEnabled:C=!0,thirdPartyCookiesEnabled:w=!0,onLoadStart:T,...E}){let[D,k]=s(()=>fe(null,e,S)),A=ee(S,x),j=A.background,[M,N]=s(null),P=M===D.sessionId,te=t(()=>{N(D.sessionId)},[D.sessionId]),ne=t(e=>{let t=e?.nativeEvent?.url;t&&(T?.(e),k(e=>pe(e,t,S,M===e.sessionId)))},[S,T,M]),{uiRef:F,injectedJavaScript:I,onMessage:L}=ke({provider:r,address:i,chainId:o,supportedChainIds:l,onReady:te,sessionId:D.sessionId,hostTheme:S,initialHostTheme:D.initialHostTheme,...d!==void 0&&{onTransactionSent:d},...h!==void 0&&{onPaymentDetails:h},...g!==void 0&&{onSignupStatusChange:g},..._!==void 0&&{onSignedUp:_},...v!==void 0&&{onSignupDismissed:v},...y!==void 0&&{onError:y}}),R=a(()=>ie(e),[e]),z=a(()=>{let e=le(n,D.uri);return e?{uri:D.uri,headers:e}:{uri:D.uri}},[n,D.uri]),re=a(()=>e=>!R||!e?.url?!1:ae(e.url,R)||e.url.startsWith(`about:`),[R]);return p(u,{style:[K.container,{backgroundColor:j},b],children:[f(m,{ref:F,source:z,originWhitelist:R?[R]:[],onShouldStartLoadWithRequest:re,javaScriptEnabled:!0,sharedCookiesEnabled:C,thirdPartyCookiesEnabled:w,injectedJavaScriptBeforeContentLoaded:I,injectedJavaScriptObject:O(D.sessionId,D.initialHostTheme,n.integrationAddress),onMessage:L,onLoadStart:ne,style:[K.ui,{backgroundColor:j}],...E},D.sessionId),P?null:f(u,{style:[K.overlay,{backgroundColor:j}],children:f(c,{color:A.spinner})})]})}const K=l.create({container:{flex:1},ui:{flex:1},overlay:{...l.absoluteFillObject,alignItems:`center`,justifyContent:`center`}});function je({onTransactionSent:e,onPaymentDetails:t,onError:n,style:r,backgroundColor:i,theme:o,themeMode:s}){let{provider:c,address:l,chainId:u,supportedChainIds:d,sdk:p,hostTheme:m}=F(o,s);return f(G,{uri:a(()=>p.config.yodlUiBaseUrl.replace(/\/$/,``),[p.config.yodlUiBaseUrl]),sdkConfig:p.config,provider:c,address:l,chainId:u,supportedChainIds:d,hostTheme:m,...e!==void 0&&{onTransactionSent:e},...t!==void 0&&{onPaymentDetails:t},...n!==void 0&&{onError:n},...r!==void 0&&{style:r},...i!==void 0&&{backgroundColor:i}})}function Me(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Ne(e){if(Array.isArray(e))return e}function Pe(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Fe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Ie(e,t,n){return t&&Fe(e.prototype,t),n&&Fe(e,n),e}function Le(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function Re(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ze(e,t){return Ne(e)||Le(e,t)||Ve(e,t)||Re()}function Be(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function Ve(e,t){if(e){if(typeof e==`string`)return Me(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Me(e,t)}}var He=Object.defineProperty,Ue=function(e,t,n){return t in e?He(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},We=function(e,t){for(var n in t)He(e,n,{get:t[n],enumerable:!0})},q=function(e,t,n){return Ue(e,(t===void 0?`undefined`:Be(t))===`symbol`?t:t+``,n)},Ge=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];function Ke(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0)t=Ge[(o.value.charCodeAt(0)^t>>8)&255]^t<<8}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return(t^0)&65535}function qe(e){for(var t=[],n=0;n<e.length;){var r=e.substring(n),i=r.substring(0,2),a=parseInt(r.substring(2,4)),o=r.substring(4,4+a);t.push({id:i,length:a,value:o}),n+=a+4}return t}function J(e){var t=``,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0){var s=o.value;if(t+=s.id,t+=(`00`+s.length).slice(-2),s.subTags){t+=J(s.subTags);continue}t+=s.value}}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return t}function Je(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=Ke(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function Y(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=Je(e,n),e}function Ye(e,t,n){var r=e.find(function(e){return e.id==t});return n?r?.subTags?.find(function(e){return e.id==n}):r}function X(e,t){return{id:e,length:t.length,value:t}}function Xe(e){var t=e.billerId,n=e.amount,r=e.ref1,i=e.ref2,a=e.ref3,o=[X(`00`,`A000000677010112`),X(`01`,t),X(`02`,r)];i&&o.push(X(`03`,i));var s=[X(`00`,`01`),X(`01`,n?`12`:`11`),X(`30`,J(o)),X(`53`,`764`),X(`58`,`TH`)];return n&&s.push(X(`54`,Number(n).toFixed(2))),a&&s.push(X(`62`,J([X(`07`,a)]))),Y(J(s),`63`)}var Ze=function(){function e(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;Pe(this,e),q(this,`billerId`),q(this,`ref1`),q(this,`ref2`),q(this,`amount`),this.billerId=t,this.ref1=n,this.ref2=r,this.amount=i}return Ie(e,[{key:`toString`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount,a=i?String(Number(i.toFixed(2))*100):`0`;return`|${t}\r${n}\r${r??``}\r${a}`}},{key:`toQrTag30`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return Xe({billerId:t,ref1:n,ref2:r??void 0,amount:i??void 0})}}],[{key:`fromString`,value:function(t){if(!t.startsWith(`|`))return null;var n=t.slice(1).split(`\r`,4);if(n.length!=4)return null;var r=ze(n,4),i=r[0],a=r[1],o=r[2],s=r[3];return new e(i,a,o.length>0?o:null,s==`0`?null:Number((parseInt(s)/100).toFixed(2)))}}]),e}(),Z=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(Z||{});function Qe(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=J([X(`00`,`A000000677010111`),X(Z[t],n)]),a=[X(`00`,`01`),X(`01`,r?`12`:`11`),X(`29`,i),X(`53`,`764`),X(`58`,`TH`)];return r&&a.push(X(`54`,Number(r).toFixed(2))),Y(J(a),`63`)}We({},{ProxyType:function(){return Z},anyId:function(){return Qe},billPayment:function(){return Xe},botBarcode:function(){return $e},slipVerify:function(){return et},trueMoney:function(){return nt},trueMoneySlipVerify:function(){return rt}});function $e(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new Ze(t,n,r,i).toString()}function et(e){var t=e.sendingBank,n=e.transRef;return Y(J([X(`00`,J([X(`00`,`000001`),X(`01`,t),X(`02`,n)])),X(`51`,`TH`)]),`91`)}function tt(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function nt(e){var t=e.mobileNo,n=e.amount,r=e.message,i=J([X(`00`,`A000000677010111`),X(`03`,`14000${t}`)]),a=[X(`00`,`01`),X(`01`,n?`12`:`11`),X(`29`,i),X(`53`,`764`),X(`58`,`TH`)];return n&&a.push(X(`54`,Number(n).toFixed(2))),r&&a.push(X(`81`,tt(r))),Y(J(a),`63`)}function rt(e){var t=e.eventType,n=e.transactionId,r=e.date;return Y(J([X(`00`,J([X(`00`,`01`),X(`01`,`01`),X(`02`,t),X(`03`,n),X(`04`,r)]))]),`91`,!1)}function Q(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function it(e){if(Array.isArray(e))return e}function at(e){if(Array.isArray(e))return Q(e)}function ot(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function st(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ct(e,t,n){return t&&st(e.prototype,t),n&&st(e,n),e}function lt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ut(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function dt(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function ft(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function pt(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){lt(e,t,n[t])})}return e}function ht(e,t){return it(e)||dt(e,t)||_t(e,t)||ft()}function gt(e){return at(e)||ut(e)||_t(e)||pt()}function _t(e,t){if(e){if(typeof e==`string`)return Q(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Q(e,t)}}We({},{anyId:function(){return bt},bcelOneProof:function(){return yt},billPayment:function(){return xt},slipVerify:function(){return St},trueMoneySlipVerify:function(){return Ct}});var vt=function(){function e(t,n){ot(this,e),q(this,`payload`),q(this,`tags`),this.payload=t,this.tags=n}return ct(e,[{key:`getTag`,value:function(e,t){return Ye(this.tags,e,t)}},{key:`getTagValue`,value:function(e,t){return this.getTag(e,t)?.value}},{key:`getTags`,value:function(){return this.tags}},{key:`getPayload`,value:function(){return this.payload}},{key:`validate`,value:function(e){var t=Y(J(gt(this.tags).filter(function(t){return t.id!=e})),e);return this.payload===t}}]),e}();function $(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e.match(/^\d{4}.+/)||t&&e.slice(-4).toUpperCase()!=Je(e.slice(0,-4)))return null;var r=qe(e);if(r.length==0)return null;if(n){var i=!0,a=!1,o=void 0;try{for(var s=r[Symbol.iterator](),c;!(i=(c=s.next()).done);i=!0){var l=c.value;if(!(typeof l.value!=`string`||!l.value.match(/^\d{4}.+/))){var u=qe(l.value);u.every(function(e){return e.length>0&&e.length===e.value.length})&&(l.subTags=u)}}}catch(e){a=!0,o=e}finally{try{!i&&s.return!=null&&s.return()}finally{if(a)throw o}}}return new vt(e,r)}function yt(e){var t=$(e,!0),n=t?.getTagValue(`33`,`02`),r=t?.getTagValue(`33`,`03`),i=t?.getTagValue(`33`,`04`);return t?.getTagValue(`00`)!==`01`&&t?.getTagValue(`01`)!==`11`&&t?.getTagValue(`33`,`00`)!==`BCEL`&&t?.getTagValue(`33`,`00`)!==`ONEPROOF`?null:{type:n,ticket:r,fccref:i}}function bt(e){var t=$(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`29`,`00`);if(n!==`01`||r!==`A000000677010111`)return null;var i=Object.entries(Z).find(function(e){var n=ht(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=ht(i,2),o=a[0],s=a[1],c=t.getTagValue(`29`,s);o===`MSISDN`&&c.length==13&&c.startsWith(`0066`)&&(c=`0`+c.slice(-9));var l=t?.getTagValue(`54`),u=l===void 0?void 0:parseFloat(l);return mt({type:o,target:c},u!==void 0&&{amount:u})}function xt(e){var t=$(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`30`,`00`),i=t?.getTagValue(`30`,`01`),a=t?.getTagValue(`30`,`02`);if(n!==`01`||r!==`A000000677010112`||!i||!a)return null;var o=t?.getTagValue(`30`,`03`),s=t?.getTagValue(`62`,`07`),c=t?.getTagValue(`54`),l=c===void 0?void 0:parseFloat(c);return mt({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function St(e){if(!(arguments.length>1&&arguments[1]!==void 0)||arguments[1]){var t=e.lastIndexOf(`9104`);if(t!=-1){var n=e.substring(t+4);n.length>0&&n.length<4&&(e=e.substring(0,t+4)+n.padStart(4,`0`))}}var r=$(e,!0),i=r?.getTagValue(`00`,`00`),a=r?.getTagValue(`00`,`01`),o=r?.getTagValue(`00`,`02`);return i!==`000001`||!a||!o?null:{sendingBank:a,transRef:o}}function Ct(e){var t=$(e,!0),n=t?.getTagValue(`00`,`02`),r=t?.getTagValue(`00`,`03`),i=t?.getTagValue(`00`,`04`);return t?.getTagValue(`00`,`00`)!==`01`&&t?.getTagValue(`00`,`01`)!==`01`?null:{eventType:n,transactionId:r,date:i}}const wt={aeon:[`PH`,`VN`,`BR`,`AR`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`]};function Tt(e){return e?e.getTagValue(`58`)??null:null}function Et(e){let t=[];for(let[n,r]of Object.entries(wt))r.includes(e)&&t.push(n);return t}function Dt(e,t,n){if(!e||typeof e!=`string`||e.trim().length===0)return[];let r=e.trim(),i=[];try{let e=Tt($(r));if(e){let n=Et(e);for(let e of n)(!t||t.includes(e))&&i.push({provider:e,action:`resolve`});if(i.length>0)return i}}catch{}if(n){let e=n(r);e&&(!t||t.includes(`bcpilot`))&&i.push(e)}return i}function Ot(e,t){return!e||typeof e!=`string`||e.trim().length===0||!Dt(e).find(e=>e.action===`resolve`)?null:`${t.replace(/\/$/,``)}/resolve?data=${encodeURIComponent(e)}`}function kt({qrData:e,onTransactionSent:t,onPaymentDetails:n,onError:r,style:i,backgroundColor:o,theme:s,themeMode:c}){let{provider:l,address:u,chainId:d,supportedChainIds:p,sdk:m,hostTheme:h}=F(s,c),g=a(()=>Ot(e,m.config.yodlUiBaseUrl),[e,m.config.yodlUiBaseUrl]);return g?f(G,{uri:g,sdkConfig:m.config,provider:l,address:u,chainId:d,supportedChainIds:p,hostTheme:h,...t!==void 0&&{onTransactionSent:t},...n!==void 0&&{onPaymentDetails:n},...r!==void 0&&{onError:r},...i!==void 0&&{style:i},...o!==void 0&&{backgroundColor:o}}):null}function At(e){return`${e.replace(/\/$/,``)}/sdk/signup`}function jt({onStatusChange:e,onSignedUp:t,onError:n,onDismiss:r,style:i,backgroundColor:o,theme:s,themeMode:c}){let{provider:l,address:u,chainId:d,supportedChainIds:p,sdk:m,hostTheme:h}=F(s,c);return f(G,{uri:a(()=>At(m.config.yodlUiBaseUrl),[m.config.yodlUiBaseUrl]),sdkConfig:m.config,provider:l,address:u,chainId:d,supportedChainIds:p,hostTheme:h,...e!==void 0&&{onSignupStatusChange:e},...t!==void 0&&{onSignedUp:t},...n!==void 0&&{onError:n},...r!==void 0&&{onSignupDismissed:r},...i!==void 0&&{style:i},...o!==void 0&&{backgroundColor:o}})}function Mt(e){return(Array.isArray(e)?e:[e]).some(e=>Dt(e).some(e=>e.action===`resolve`))}var Nt=class{config;constructor(e){let t=se(e),n=e.supportedChainIds;if(!Array.isArray(n)||n.length===0)throw Error(`Yodl supportedChainIds is required — provide at least one chain id`);this.config={integrationAddress:t,yodlUiBaseUrl:e.yodlUiBaseUrl??`https://sdk-webview.yodl.me`,supportedChainIds:[...n]}}};function Pt(e){return new Nt(e)}export{Nt as Yodl,je as YodlDashboard,kt as YodlPayment,te as YodlProvider,jt as YodlSignup,Pt as createSdk,Mt as isPaymentQr};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yodlpay/react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Yodl React Native SDK — drop-in components for EIP-1193 wallets",
|
|
6
6
|
"keywords": [
|
|
@@ -75,7 +75,10 @@
|
|
|
75
75
|
"tsdown": "^0.22.0",
|
|
76
76
|
"typescript": "^5.7.2",
|
|
77
77
|
"vitest": "^4.1.7",
|
|
78
|
-
"@yodlpay/sdk-core": "0.
|
|
78
|
+
"@yodlpay/sdk-core": "0.5.0"
|
|
79
|
+
},
|
|
80
|
+
"dependencies": {
|
|
81
|
+
"zod": "^4.4.3"
|
|
79
82
|
},
|
|
80
83
|
"scripts": {
|
|
81
84
|
"build": "tsdown",
|