@zerohash-sdk/fund-withdrawals-react 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/index.d.ts +124 -0
- package/dist/index.js +42 -0
- package/package.json +29 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { default as default_2 } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generic app event structure
|
|
5
|
+
* @template TType - Event type string
|
|
6
|
+
* @template TData - Event data payload
|
|
7
|
+
*/
|
|
8
|
+
declare type AppEvent<TType extends string = string, TData = Record<string, unknown>> = {
|
|
9
|
+
/** The type of event that occurred */
|
|
10
|
+
type: TType;
|
|
11
|
+
/** Data associated with the event */
|
|
12
|
+
data: TData;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Available environments for the Fund Withdrawals service.
|
|
17
|
+
*/
|
|
18
|
+
declare type Environment = 'local' | 'dev' | 'cert' | 'prod';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Generic error codes for all Connect applications
|
|
22
|
+
*/
|
|
23
|
+
declare enum ErrorCode {
|
|
24
|
+
/** Network connectivity error */
|
|
25
|
+
NETWORK_ERROR = 'network_error',
|
|
26
|
+
/** Authentication or session expired error */
|
|
27
|
+
AUTH_ERROR = 'auth_error',
|
|
28
|
+
/** Resource not found error */
|
|
29
|
+
NOT_FOUND_ERROR = 'not_found_error',
|
|
30
|
+
/** Validation error from user input */
|
|
31
|
+
VALIDATION_ERROR = 'validation_error',
|
|
32
|
+
/** Server error (5xx) */
|
|
33
|
+
SERVER_ERROR = 'server_error',
|
|
34
|
+
/** Client error (4xx) */
|
|
35
|
+
CLIENT_ERROR = 'client_error',
|
|
36
|
+
/** Unknown or unexpected error */
|
|
37
|
+
UNKNOWN_ERROR = 'unknown_error',
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Generic error payload structure for error callbacks
|
|
42
|
+
*/
|
|
43
|
+
declare type ErrorPayload = {
|
|
44
|
+
/** Error code indicating the type of error */
|
|
45
|
+
errorCode: ErrorCode;
|
|
46
|
+
/** Human-readable reason for the error */
|
|
47
|
+
reason: string;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* A React wrapper component for the Fund Withdrawals product.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```tsx
|
|
55
|
+
* <FundWithdrawals jwt="your-jwt-token" env="cert" />
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare const FundWithdrawals: default_2.FC<FundWithdrawalsProps>;
|
|
59
|
+
|
|
60
|
+
declare type FundWithdrawalsCompletedData = {
|
|
61
|
+
/** External account identifier the funds were sent to */
|
|
62
|
+
externalAccountId: string;
|
|
63
|
+
/** Symbol of the asset that was withdrawn (e.g. 'BTC') */
|
|
64
|
+
assetSymbol: string;
|
|
65
|
+
/** Quantity withdrawn as a string */
|
|
66
|
+
amount: string;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
declare type FundWithdrawalsEvent = AppEvent<FundWithdrawalsEventType>;
|
|
70
|
+
|
|
71
|
+
declare type FundWithdrawalsEventType = string;
|
|
72
|
+
|
|
73
|
+
declare interface FundWithdrawalsProps {
|
|
74
|
+
/**
|
|
75
|
+
* JWT token used for authentication.
|
|
76
|
+
*/
|
|
77
|
+
jwt: string;
|
|
78
|
+
/**
|
|
79
|
+
* Target environment for the Fund Withdrawals service.
|
|
80
|
+
*
|
|
81
|
+
* @default "prod"
|
|
82
|
+
*/
|
|
83
|
+
env?: Environment;
|
|
84
|
+
/**
|
|
85
|
+
* Theme mode.
|
|
86
|
+
*
|
|
87
|
+
* @default "auto"
|
|
88
|
+
*/
|
|
89
|
+
theme?: Theme;
|
|
90
|
+
/**
|
|
91
|
+
* When true, the widget renders as the Payouts flow. When false or omitted,
|
|
92
|
+
* renders as the standard Fund Withdrawals flow.
|
|
93
|
+
*
|
|
94
|
+
* @default false
|
|
95
|
+
*/
|
|
96
|
+
isPayouts?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Callback invoked when the withdrawal flow is successfully completed.
|
|
99
|
+
*/
|
|
100
|
+
onCompleted?: (data: FundWithdrawalsCompletedData) => void;
|
|
101
|
+
/**
|
|
102
|
+
* Callback invoked when an error occurs.
|
|
103
|
+
*/
|
|
104
|
+
onError?: (error: ErrorPayload) => void;
|
|
105
|
+
/**
|
|
106
|
+
* Callback invoked when the user closes the widget.
|
|
107
|
+
*/
|
|
108
|
+
onClose?: () => void;
|
|
109
|
+
/**
|
|
110
|
+
* Callback invoked when the widget has finished loading and is ready.
|
|
111
|
+
*/
|
|
112
|
+
onLoaded?: () => void;
|
|
113
|
+
/**
|
|
114
|
+
* Callback invoked for general application events during the flow.
|
|
115
|
+
*/
|
|
116
|
+
onEvent?: (event: FundWithdrawalsEvent) => void;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Theme mode for the Fund Withdrawals interface.
|
|
121
|
+
*/
|
|
122
|
+
declare type Theme = 'auto' | 'light' | 'dark';
|
|
123
|
+
|
|
124
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import m, { useRef as x, useEffect as h } from "react";
|
|
2
|
+
const b = {
|
|
3
|
+
local: "http://localhost:5173/fund-withdrawals-web/index.js",
|
|
4
|
+
dev: "https://connect-sdk.dev.0hash.com/fund-withdrawals-web/index.js",
|
|
5
|
+
cert: "https://sdk.sandbox.connect.xyz/fund-withdrawals-web/index.js",
|
|
6
|
+
prod: "https://sdk.connect.xyz/fund-withdrawals-web/index.js"
|
|
7
|
+
}, y = "zerohash-fund-withdrawals-script", u = "zerohash-fund-withdrawals", I = (s = "prod") => b[s], j = ({
|
|
8
|
+
jwt: s,
|
|
9
|
+
env: r = "prod",
|
|
10
|
+
theme: p,
|
|
11
|
+
isPayouts: c = !1,
|
|
12
|
+
onCompleted: n,
|
|
13
|
+
onError: d,
|
|
14
|
+
onClose: o,
|
|
15
|
+
onLoaded: i,
|
|
16
|
+
onEvent: a,
|
|
17
|
+
...w
|
|
18
|
+
}) => {
|
|
19
|
+
const l = x(null);
|
|
20
|
+
return h(() => {
|
|
21
|
+
const t = l.current;
|
|
22
|
+
t && (t.isPayouts = c, n && (t.onCompleted = n), d && (t.onError = d), o && (t.onClose = o), i && (t.onLoaded = i), a && (t.onEvent = a));
|
|
23
|
+
}, [c, n, d, o, i, a]), h(() => {
|
|
24
|
+
const t = I(r), f = `${y}-${r}`;
|
|
25
|
+
if (document.getElementById(f))
|
|
26
|
+
return;
|
|
27
|
+
const e = document.createElement("script");
|
|
28
|
+
e.id = f, e.src = t, e.type = "module", e.async = !0, e.onerror = () => {
|
|
29
|
+
console.error(`Failed to load the script for ${u} from ${r} environment.`);
|
|
30
|
+
}, document.head.appendChild(e);
|
|
31
|
+
}, [r]), m.createElement(u, {
|
|
32
|
+
ref: l,
|
|
33
|
+
jwt: s,
|
|
34
|
+
env: r,
|
|
35
|
+
theme: p,
|
|
36
|
+
"is-payouts": c ? "true" : "false",
|
|
37
|
+
...w
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
j as FundWithdrawals
|
|
42
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zerohash-sdk/fund-withdrawals-react",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"exports": {
|
|
11
|
+
"./package.json": "./package.json",
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"!**/*.tsbuildinfo"
|
|
21
|
+
],
|
|
22
|
+
"nx": {
|
|
23
|
+
"name": "fund-withdrawals-react"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"react": ">=18.0.0",
|
|
27
|
+
"react-dom": ">=18.0.0"
|
|
28
|
+
}
|
|
29
|
+
}
|