heraldex-onramp-sdk 2.0.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 +123 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +36 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +84 -0
package/Readme.md
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Herald Exchange Onramp SDK Widget
|
|
2
|
+
|
|
3
|
+
Herald Exchange Onramp SDK Widget is a simple component for React applications.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
You can install Herald Exchange Onramp SDK Widget via npm:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install herald-exchange-onramp-widget
|
|
11
|
+
# or
|
|
12
|
+
yarn add herald-exchange-onramp-widget
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
To use widget in your React application, follow these steps:
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { BuyCryptoWidget } from "herald-exchange-onramp-widget";
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Initialize the widget:
|
|
24
|
+
|
|
25
|
+
> To Generate API Key Please Visit : [Herald Exchange](https://app.herald.exchange/login).
|
|
26
|
+
> Supported Token Types : ["USDT", "USDC", "ETH", "BNB", "MATIC", "SOL", "TRX"]
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
<BuyCryptoWidget
|
|
30
|
+
clientReferenceID={YOUR_CLIENT_REFERENCE_ID}
|
|
31
|
+
apiKey={YOUR_API_KEY}
|
|
32
|
+
redirectUrl={REDIRECT_URL}
|
|
33
|
+
buyParameters={{ from_amount: "25", token_type: "TRX" }}
|
|
34
|
+
/>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
> **Note:**
|
|
38
|
+
>
|
|
39
|
+
> - In development mode, the widget operates on **testnet** and runs in a sandbox environment.
|
|
40
|
+
> - Transactions are simulated based on the fromAmount value:
|
|
41
|
+
> - 100 → Success
|
|
42
|
+
> - 200 → Failure
|
|
43
|
+
> - Any other value → Initiated
|
|
44
|
+
> - ⚠️ Ensure your application is deployed in a **production environment** when going live to enable accurate transaction tracking and wallet interactions.
|
|
45
|
+
|
|
46
|
+
## 🔧 Props
|
|
47
|
+
|
|
48
|
+
### `apiKey` (required)
|
|
49
|
+
|
|
50
|
+
- **Type**: `string`
|
|
51
|
+
|
|
52
|
+
- **Description**: A unique API key generated via the [Herald Exchange App](https://app.herald.exchange/login).
|
|
53
|
+
|
|
54
|
+
- This key is used to authenticate and authorize the widget.
|
|
55
|
+
|
|
56
|
+
- Example: `4bb06e2fdbfb8e392a0ab49e4d9819ae072dcef82d79af7893625a5ff1416f`
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
### `mode` (optional)
|
|
61
|
+
|
|
62
|
+
- Type: string
|
|
63
|
+
|
|
64
|
+
- Allowed Values: "development" | "production"
|
|
65
|
+
|
|
66
|
+
- Default: "development"
|
|
67
|
+
|
|
68
|
+
- Description: Specifies the environment in which the widget runs.
|
|
69
|
+
|
|
70
|
+
- "development" is used for testing and debugging purposes.
|
|
71
|
+
|
|
72
|
+
- "production" should be used in live environments for optimized performance.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
### `clientReferenceID` (required)
|
|
77
|
+
|
|
78
|
+
- **Type**: `string`
|
|
79
|
+
|
|
80
|
+
- **Description**: A unique identifier (UUID) generated via the [Herald Exchange App](https://app.herald.exchange/login), used to associate a transaction with a specific user or session.
|
|
81
|
+
|
|
82
|
+
- Helps track user activity and transaction flow.
|
|
83
|
+
|
|
84
|
+
- Example: `34edd6d6-eb12-422f-bd0e-63c5733527`
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
### `redirectUrl` (optional)
|
|
89
|
+
|
|
90
|
+
- **Type**: `string`
|
|
91
|
+
|
|
92
|
+
- **Description**: The URL to which the user will be redirected **after completing the transaction**.
|
|
93
|
+
|
|
94
|
+
- A **callback** will be made to this URL along with the **transaction result or status** as query parameters or payload (depending on the integration).
|
|
95
|
+
|
|
96
|
+
- Example: `https://yourapp.com/transaction-complete`
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
### `buyParameters` (required)
|
|
101
|
+
|
|
102
|
+
- **Type**:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
{
|
|
106
|
+
from_amount: string;
|
|
107
|
+
token_type: string;
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
- **Description**: Defines the default configuration for the buy flow.
|
|
112
|
+
|
|
113
|
+
- from_amount: A string representing the default amount to be displayed in the input field (e.g., "25").
|
|
114
|
+
|
|
115
|
+
- token_type: The token that should be selected by default for purchase (e.g., "USDC").
|
|
116
|
+
|
|
117
|
+
⚠️ If the passed token_type is not active, the widget will automatically fall back to the first activated token.
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## License
|
|
122
|
+
|
|
123
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
type BuyParamsType = {
|
|
4
|
+
from_amount?: string;
|
|
5
|
+
token_type?: string;
|
|
6
|
+
};
|
|
7
|
+
type CallBackResponse = {
|
|
8
|
+
status: "success" | "failed";
|
|
9
|
+
message: string;
|
|
10
|
+
data: {
|
|
11
|
+
transaction_id: string | number;
|
|
12
|
+
from_currency: string;
|
|
13
|
+
to_currency: string;
|
|
14
|
+
network_type?: string;
|
|
15
|
+
from_value: string | number;
|
|
16
|
+
to_value: number | string;
|
|
17
|
+
explorer_url?: string;
|
|
18
|
+
wallet_address?: string;
|
|
19
|
+
exchange_rate: number | string;
|
|
20
|
+
transaction_hash?: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type WidgetComponentProps = {
|
|
25
|
+
apiKey: string;
|
|
26
|
+
buyParameters?: BuyParamsType;
|
|
27
|
+
clientReferenceID: string;
|
|
28
|
+
mode?: "development" | "production";
|
|
29
|
+
callback: (data: CallBackResponse) => void;
|
|
30
|
+
redirect?: boolean;
|
|
31
|
+
redirectUrl?: string;
|
|
32
|
+
};
|
|
33
|
+
declare const WidgetComponent: ({ apiKey, redirectUrl, buyParameters, clientReferenceID, mode, callback, redirect, }: WidgetComponentProps) => react_jsx_runtime.JSX.Element;
|
|
34
|
+
|
|
35
|
+
export { WidgetComponent as BuyCryptoWidget };
|