@zerohash-sdk/fund-withdrawals-react 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -3
- package/dist/index.js +21 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,78 @@
|
|
|
1
1
|
# @zerohash-sdk/fund-withdrawals-react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A React SDK for embedding the Zerohash Fund Withdrawals flow into web applications. Lets users withdraw assets from their Fund account to an external destination.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Requirements
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- React 18.0.0 or higher
|
|
8
|
+
- React DOM 18.0.0 or higher
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @zerohash-sdk/fund-withdrawals-react
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Getting Started
|
|
17
|
+
|
|
18
|
+
### 1. Import the FundWithdrawals component
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import { FundWithdrawals } from '@zerohash-sdk/fund-withdrawals-react';
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### 2. Add it to your app
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
function App() {
|
|
28
|
+
const jwt = 'your-jwt-token';
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<FundWithdrawals
|
|
32
|
+
jwt={jwt}
|
|
33
|
+
env="prod"
|
|
34
|
+
theme="auto"
|
|
35
|
+
isPayouts={false}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 3. Configure event callbacks (optional)
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
<FundWithdrawals
|
|
45
|
+
jwt={jwt}
|
|
46
|
+
env="prod"
|
|
47
|
+
theme="auto"
|
|
48
|
+
onCompleted={({ externalAccountId, assetSymbol, amount }) => {
|
|
49
|
+
console.log(`Withdrew ${amount} ${assetSymbol} to ${externalAccountId}`);
|
|
50
|
+
}}
|
|
51
|
+
onError={({ errorCode, reason }) => console.error(errorCode, reason)}
|
|
52
|
+
onClose={() => console.log('Widget closed')}
|
|
53
|
+
onEvent={(event) => console.log('Event:', event)}
|
|
54
|
+
onLoaded={() => console.log('Widget ready')}
|
|
55
|
+
/>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## API Reference
|
|
59
|
+
|
|
60
|
+
### FundWithdrawals Component Props
|
|
61
|
+
|
|
62
|
+
| Prop | Type | Required | Default | Description |
|
|
63
|
+
| ------------- | ------------------------------------------------------ | -------- | -------- | ---------------------------------------------------------------------------------- |
|
|
64
|
+
| `jwt` | `string` | Yes | - | JWT token for authentication with Connect |
|
|
65
|
+
| `env` | `"prod" \| "cert" \| "dev" \| "local"` | No | `"prod"` | Target environment |
|
|
66
|
+
| `theme` | `"auto" \| "light" \| "dark"` | No | `"auto"` | Theme mode for the interface |
|
|
67
|
+
| `isPayouts` | `boolean` | No | `false` | When true, renders the Payouts flow instead of the standard Fund Withdrawals flow. |
|
|
68
|
+
| `onCompleted` | `({ externalAccountId, assetSymbol, amount }) => void` | No | - | Callback when the withdrawal is successfully initiated |
|
|
69
|
+
| `onError` | `({ errorCode, reason }) => void` | No | - | Callback for error events |
|
|
70
|
+
| `onClose` | `() => void` | No | - | Callback when the widget is closed |
|
|
71
|
+
| `onEvent` | `(event) => void` | No | - | Callback for general events |
|
|
72
|
+
| `onLoaded` | `() => void` | No | - | Callback when the widget is loaded and ready |
|
|
73
|
+
|
|
74
|
+
`onCompleted` payload shape: `{ externalAccountId: string; assetSymbol: string; amount: string }`.
|
|
75
|
+
|
|
76
|
+
## More Information & Support
|
|
77
|
+
|
|
78
|
+
For comprehensive documentation, visit the [Zerohash Documentation Page](https://docs.zerohash.com/).
|
package/dist/index.js
CHANGED
|
@@ -4,36 +4,36 @@ const b = {
|
|
|
4
4
|
dev: "https://connect-sdk.dev.0hash.com/fund-withdrawals-web/index.js",
|
|
5
5
|
cert: "https://sdk.sandbox.connect.xyz/fund-withdrawals-web/index.js",
|
|
6
6
|
prod: "https://sdk.connect.xyz/fund-withdrawals-web/index.js"
|
|
7
|
-
}, y = "zerohash-fund-withdrawals-script",
|
|
8
|
-
jwt:
|
|
7
|
+
}, y = "zerohash-fund-withdrawals-script", p = "zerohash-fund-withdrawals", I = (c = "prod") => b[c], j = ({
|
|
8
|
+
jwt: c,
|
|
9
9
|
env: r = "prod",
|
|
10
|
-
theme:
|
|
11
|
-
isPayouts:
|
|
12
|
-
onCompleted:
|
|
13
|
-
onError:
|
|
10
|
+
theme: s,
|
|
11
|
+
isPayouts: n = !1,
|
|
12
|
+
onCompleted: d,
|
|
13
|
+
onError: i,
|
|
14
14
|
onClose: o,
|
|
15
|
-
onLoaded:
|
|
16
|
-
onEvent:
|
|
15
|
+
onLoaded: a,
|
|
16
|
+
onEvent: l,
|
|
17
17
|
...w
|
|
18
18
|
}) => {
|
|
19
|
-
const
|
|
19
|
+
const f = x(null);
|
|
20
20
|
return h(() => {
|
|
21
|
-
const t =
|
|
22
|
-
t && (t.isPayouts =
|
|
23
|
-
}, [
|
|
24
|
-
const t = I(r),
|
|
25
|
-
if (document.getElementById(
|
|
21
|
+
const t = f.current;
|
|
22
|
+
t && (t.isPayouts = n, s !== void 0 && (t.theme = s), d && (t.onCompleted = d), i && (t.onError = i), o && (t.onClose = o), a && (t.onLoaded = a), l && (t.onEvent = l));
|
|
23
|
+
}, [n, s, d, i, o, a, l]), h(() => {
|
|
24
|
+
const t = I(r), u = `${y}-${r}`;
|
|
25
|
+
if (document.getElementById(u))
|
|
26
26
|
return;
|
|
27
27
|
const e = document.createElement("script");
|
|
28
|
-
e.id =
|
|
29
|
-
console.error(`Failed to load the script for ${
|
|
28
|
+
e.id = u, e.src = t, e.type = "module", e.async = !0, e.onerror = () => {
|
|
29
|
+
console.error(`Failed to load the script for ${p} from ${r} environment.`);
|
|
30
30
|
}, document.head.appendChild(e);
|
|
31
|
-
}, [r]), m.createElement(
|
|
32
|
-
ref:
|
|
33
|
-
jwt:
|
|
31
|
+
}, [r]), m.createElement(p, {
|
|
32
|
+
ref: f,
|
|
33
|
+
jwt: c,
|
|
34
34
|
env: r,
|
|
35
|
-
theme:
|
|
36
|
-
"is-payouts":
|
|
35
|
+
theme: s,
|
|
36
|
+
"is-payouts": n ? "true" : "false",
|
|
37
37
|
...w
|
|
38
38
|
});
|
|
39
39
|
};
|