paj_ramp 1.0.0 → 1.1.1
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 +304 -178
- package/dist/index.d.ts +13 -11
- package/dist/index.js +16 -11
- package/dist/lib/{addBankAccount.d.ts → off_ramp/addBankAccount.d.ts} +8 -6
- package/dist/lib/{addBankAccount.js → off_ramp/addBankAccount.js} +3 -3
- package/dist/lib/{addWallet.d.ts → off_ramp/addWallet.d.ts} +2 -1
- package/dist/lib/{addWallet.js → off_ramp/addWallet.js} +3 -3
- package/dist/lib/{getBankAccounts.js → off_ramp/getBankAccounts.js} +1 -1
- package/dist/lib/{getBanks.js → off_ramp/getBanks.js} +2 -2
- package/dist/lib/{getRate.js → off_ramp/getRate.js} +3 -3
- package/dist/lib/{getTXPoolAddress.js → off_ramp/getTXPoolAddress.js} +3 -3
- package/dist/lib/{getWallet.js → off_ramp/getWallet.js} +2 -2
- package/dist/lib/{initiate.js → off_ramp/initiate.js} +3 -3
- package/dist/lib/{resolveBankAccount.js → off_ramp/resolveBankAccount.js} +2 -2
- package/dist/lib/{switchWalletBankAccount.js → off_ramp/switchWalletBankAccount.js} +3 -4
- package/dist/lib/{verify.js → off_ramp/verify.js} +3 -3
- package/dist/lib/on_ramp/createOrder.d.ts +10 -0
- package/dist/lib/on_ramp/createOrder.js +19 -0
- package/dist/lib/on_ramp/observeOrder.d.ts +23 -0
- package/dist/lib/on_ramp/observeOrder.js +62 -0
- package/dist/utils/api.js +6 -6
- package/dist/utils/axios.js +3 -3
- package/dist/utils/baseUrl.d.ts +1 -0
- package/dist/utils/baseUrl.js +1 -0
- package/dist/utils/off_ramp_api.d.ts +80 -0
- package/dist/utils/off_ramp_api.js +122 -0
- package/dist/utils/off_ramp_axios.d.ts +2 -0
- package/dist/utils/off_ramp_axios.js +8 -0
- package/dist/utils/on_ramp_api.d.ts +80 -0
- package/dist/utils/on_ramp_api.js +122 -0
- package/dist/utils/on_ramp_axios.d.ts +2 -0
- package/dist/utils/on_ramp_axios.js +8 -0
- package/dist/utils/onramp-socket.d.ts +45 -0
- package/dist/utils/onramp-socket.js +82 -0
- package/index.ts +21 -11
- package/lib/{addBankAccount.ts → off_ramp/addBankAccount.ts} +16 -10
- package/lib/{addWallet.ts → off_ramp/addWallet.ts} +3 -3
- package/lib/{getBankAccounts.ts → off_ramp/getBankAccounts.ts} +1 -1
- package/lib/{getBanks.ts → off_ramp/getBanks.ts} +2 -2
- package/lib/{getRate.ts → off_ramp/getRate.ts} +3 -3
- package/lib/{getTXPoolAddress.ts → off_ramp/getTXPoolAddress.ts} +3 -3
- package/lib/{getWallet.ts → off_ramp/getWallet.ts} +2 -2
- package/lib/{initiate.ts → off_ramp/initiate.ts} +12 -12
- package/lib/{resolveBankAccount.ts → off_ramp/resolveBankAccount.ts} +2 -2
- package/lib/{switchWalletBankAccount.ts → off_ramp/switchWalletBankAccount.ts} +4 -5
- package/lib/{verify.ts → off_ramp/verify.ts} +21 -22
- package/lib/on_ramp/createOrder.ts +32 -0
- package/lib/on_ramp/observeOrder.ts +98 -0
- package/package.json +6 -4
- package/utils/api.ts +7 -7
- package/utils/axios.ts +3 -3
- package/utils/onramp-socket.ts +126 -0
- /package/dist/lib/{getBankAccounts.d.ts → off_ramp/getBankAccounts.d.ts} +0 -0
- /package/dist/lib/{getBanks.d.ts → off_ramp/getBanks.d.ts} +0 -0
- /package/dist/lib/{getRate.d.ts → off_ramp/getRate.d.ts} +0 -0
- /package/dist/lib/{getTXPoolAddress.d.ts → off_ramp/getTXPoolAddress.d.ts} +0 -0
- /package/dist/lib/{getWallet.d.ts → off_ramp/getWallet.d.ts} +0 -0
- /package/dist/lib/{initiate.d.ts → off_ramp/initiate.d.ts} +0 -0
- /package/dist/lib/{resolveBankAccount.d.ts → off_ramp/resolveBankAccount.d.ts} +0 -0
- /package/dist/lib/{switchWalletBankAccount.d.ts → off_ramp/switchWalletBankAccount.d.ts} +0 -0
- /package/dist/lib/{verify.d.ts → off_ramp/verify.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,254 +1,380 @@
|
|
|
1
|
-
#
|
|
1
|
+
# PAJ Ramp SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A comprehensive SDK for PAJ Ramp onramp and offramp operations with real-time transaction updates using Socket.IO.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Features
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- **Onramp Operations**: Create orders and observe real-time updates
|
|
8
|
+
- **Offramp Operations**: Complete offramp workflow with bank account management
|
|
9
|
+
- **Real-time Updates**: Socket.IO integration for live transaction status updates
|
|
10
|
+
- **TypeScript Support**: Full TypeScript definitions included
|
|
11
|
+
- **Functional API**: Clean functional approach for better composability
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install paj-ramp
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
yarn add paj-ramp
|
|
21
|
+
```
|
|
10
22
|
|
|
11
23
|
---
|
|
12
24
|
|
|
13
|
-
|
|
25
|
+
# Onramp SDK (Real-time Order Observation)
|
|
14
26
|
|
|
15
|
-
|
|
16
|
-
- 🔐 Handles Session Management
|
|
17
|
-
- 🧱 Clean, modular API
|
|
18
|
-
- 🕊️ No need to write `fetch()` or `axios` manually
|
|
19
|
-
- 🕸️ Handles Bank Operations like getting banks, adding banks, resolving banks and getting banks linked to the account
|
|
27
|
+
## Quick Start
|
|
20
28
|
|
|
21
|
-
|
|
29
|
+
### Real-time Order Observation
|
|
22
30
|
|
|
23
|
-
|
|
31
|
+
The SDK provides Socket.IO functionality to observe onramp orders in real-time:
|
|
24
32
|
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
```typescript
|
|
34
|
+
import {
|
|
35
|
+
observeOrder,
|
|
36
|
+
createOrderObserver,
|
|
37
|
+
createOnRampSocket,
|
|
38
|
+
} from "paj-ramp";
|
|
39
|
+
|
|
40
|
+
// Using observeOrder function
|
|
41
|
+
const observer = observeOrder({
|
|
42
|
+
orderId: "your_order_id",
|
|
43
|
+
onOrderUpdate: (data) => {
|
|
44
|
+
console.log("Order update:", data);
|
|
45
|
+
// Handle status changes: pending, processing, completed, failed, cancelled
|
|
46
|
+
},
|
|
47
|
+
onError: (error) => {
|
|
48
|
+
console.error("Socket error:", error);
|
|
49
|
+
},
|
|
50
|
+
});
|
|
28
51
|
|
|
29
|
-
|
|
30
|
-
yarn add paj_ramp
|
|
52
|
+
await observer.connect();
|
|
31
53
|
```
|
|
32
54
|
|
|
33
|
-
|
|
55
|
+
### Order Update Data Structure
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
interface OnRampOrderUpdate {
|
|
59
|
+
id: string;
|
|
60
|
+
fiatAmount: string;
|
|
61
|
+
currency: string;
|
|
62
|
+
recipient: string; // wallet address
|
|
63
|
+
mint: string; // token address
|
|
64
|
+
chain: Chain; // enum: 'solana', 'ethereum', 'polygon'
|
|
65
|
+
status: OnRampStatus; // enum: 'pending', 'processing', 'completed', 'failed', 'cancelled'
|
|
66
|
+
}
|
|
67
|
+
```
|
|
34
68
|
|
|
35
|
-
|
|
69
|
+
### Socket Events
|
|
36
70
|
|
|
37
|
-
|
|
71
|
+
The SDK listens for these Socket.IO events:
|
|
38
72
|
|
|
39
|
-
|
|
40
|
-
|
|
73
|
+
- **ORDER_UPDATE**: Real-time order status updates
|
|
74
|
+
- **ERROR**: Error messages from the server
|
|
41
75
|
|
|
42
|
-
|
|
76
|
+
## API Reference
|
|
43
77
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
78
|
+
### observeOrder(options)
|
|
79
|
+
|
|
80
|
+
Creates an order observer.
|
|
81
|
+
|
|
82
|
+
**Parameters:**
|
|
83
|
+
|
|
84
|
+
- `options.orderId` (string, required): The order ID to observe
|
|
85
|
+
- `options.onOrderUpdate` (function, optional): Callback for order updates
|
|
86
|
+
- `options.onError` (function, optional): Callback for errors
|
|
87
|
+
- `options.onConnect` (function, optional): Callback when connected
|
|
88
|
+
- `options.onDisconnect` (function, optional): Callback when disconnected
|
|
89
|
+
- `options.onConnectionStatusChange` (function, optional): Callback for connection status changes
|
|
90
|
+
|
|
91
|
+
**Returns:**
|
|
92
|
+
|
|
93
|
+
- `socket`: The Socket.IO instance
|
|
94
|
+
- `isConnected()`: Function to check connection status
|
|
95
|
+
- `connect()`: Function to connect to the socket
|
|
96
|
+
- `disconnect()`: Function to disconnect from the socket
|
|
97
|
+
|
|
98
|
+
**Example:**
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
import { observeOrder } from "paj-ramp";
|
|
102
|
+
|
|
103
|
+
const observer = observeOrder({
|
|
104
|
+
orderId: "your_order_id",
|
|
105
|
+
onOrderUpdate: (data) => console.log(data),
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// Connect manually
|
|
109
|
+
await observer.connect();
|
|
110
|
+
|
|
111
|
+
// Check connection status
|
|
112
|
+
console.log("Connected:", observer.isConnected());
|
|
113
|
+
|
|
114
|
+
// Disconnect manually: you could use setTimeout to keep the socket alive for a certain amount of time before you disconnect
|
|
115
|
+
observer.disconnect();
|
|
48
116
|
```
|
|
49
117
|
|
|
50
|
-
|
|
118
|
+
## Error Handling
|
|
51
119
|
|
|
52
|
-
|
|
53
|
-
import { getRate } from 'paj_ramp';
|
|
120
|
+
The SDK provides comprehensive error handling:
|
|
54
121
|
|
|
55
|
-
|
|
122
|
+
```typescript
|
|
123
|
+
const observer = observeOrder({
|
|
124
|
+
orderId: "your_order_id",
|
|
125
|
+
onError: (error) => {
|
|
126
|
+
// Handle connection errors, order not found, etc.
|
|
127
|
+
console.error("Socket error:", error);
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Common error messages:
|
|
133
|
+
|
|
134
|
+
- `"Order not found: {orderId}"`
|
|
135
|
+
- `"Connection failed"`
|
|
136
|
+
- `"Socket timeout"`
|
|
137
|
+
|
|
138
|
+
### createOrder(orderData)
|
|
139
|
+
|
|
140
|
+
Creates a new onramp order.
|
|
141
|
+
|
|
142
|
+
**Parameters:**
|
|
143
|
+
|
|
144
|
+
- `orderData` (object, required): Order creation data
|
|
145
|
+
- `orderData.fiatAmount` (number, required): Order amount
|
|
146
|
+
- `orderData.currency` (string, required): Currency code (e.g., 'USD', 'NGN')
|
|
147
|
+
- `orderData.recipient` (string, required): Wallet address to receive tokens
|
|
148
|
+
- `orderData.mint` (string, required): Token mint address
|
|
149
|
+
- `orderData.chain` (Chain, required): Blockchain network ('solana', 'ethereum', 'polygon')
|
|
150
|
+
- `orderData.token` (string, required): Verification token
|
|
151
|
+
|
|
152
|
+
**Returns:**
|
|
56
153
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
154
|
+
- `id` (string): Unique order identifier
|
|
155
|
+
- `accountNumber` (string): Bank account number for payment
|
|
156
|
+
- `accountName` (string): Bank account holder name
|
|
157
|
+
- `fiatAmount` (number): Order amount in fiat currency
|
|
158
|
+
- `bank` (string): Bank name
|
|
159
|
+
|
|
160
|
+
**Example:**
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
import { createOrder } from "paj-ramp";
|
|
164
|
+
|
|
165
|
+
const order = await createOrder({
|
|
166
|
+
fiatAmount: 10000,
|
|
167
|
+
currency: "NGN",
|
|
168
|
+
recipient: "wallet_address_here",
|
|
169
|
+
mint: "token_mint_address_here",
|
|
170
|
+
chain: "SOLANA",
|
|
171
|
+
token: "token_from_verification",
|
|
172
|
+
});
|
|
173
|
+
// Response: { id: string, accountNumber: string, accountName: string, fiatAmount: number, bank: string }
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Usage Example
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
import { observeOrder } from "paj-ramp";
|
|
180
|
+
|
|
181
|
+
async function example(orderId) {
|
|
182
|
+
console.log("Observe Order");
|
|
183
|
+
|
|
184
|
+
const observer = observeOrder({
|
|
185
|
+
orderId,
|
|
186
|
+
onOrderUpdate: (data) => {
|
|
187
|
+
console.log("Order update received:", data);
|
|
188
|
+
console.log("Status:", data.status);
|
|
189
|
+
console.log("Amount:", data.amount);
|
|
190
|
+
console.log("Currency:", data.currency);
|
|
191
|
+
},
|
|
192
|
+
onError: (error) => {
|
|
193
|
+
console.error("Socket error:", error);
|
|
194
|
+
},
|
|
195
|
+
onConnect: () => {
|
|
196
|
+
console.log("Connected to order socket");
|
|
197
|
+
},
|
|
198
|
+
onDisconnect: () => {
|
|
199
|
+
console.log("Disconnected from order socket");
|
|
200
|
+
},
|
|
201
|
+
onConnectionStatusChange: (connected) => {
|
|
202
|
+
console.log(
|
|
203
|
+
"Connection status changed:",
|
|
204
|
+
connected ? "Connected" : "Disconnected"
|
|
205
|
+
);
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
try {
|
|
210
|
+
await observer.connect();
|
|
211
|
+
console.log("Successfully connected to order observer");
|
|
212
|
+
|
|
213
|
+
// Keep the connection alive for 1 minute
|
|
214
|
+
setTimeout(() => {
|
|
215
|
+
console.log("Disconnecting after 1 minute...");
|
|
216
|
+
observer.disconnect();
|
|
217
|
+
}, 1 * 60 * 1000);
|
|
218
|
+
} catch (error) {
|
|
219
|
+
console.error("Failed to connect:", error);
|
|
220
|
+
}
|
|
62
221
|
}
|
|
222
|
+
|
|
223
|
+
const order = await createOrder({
|
|
224
|
+
fiatAmount: 10000,
|
|
225
|
+
currency: "NGN",
|
|
226
|
+
recipient: "your_wallet_address",
|
|
227
|
+
mint: "your_token_mint_address",
|
|
228
|
+
chain: "SOLANA",
|
|
229
|
+
token: token_from_verification,
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
await example(order.id);
|
|
233
|
+
// Response: { id: string, fiatAmount: string, currency: string, , recipient: string, mint: string, chain: Chain, amount: number, status: OnRampStatus }
|
|
63
234
|
```
|
|
64
235
|
|
|
65
|
-
|
|
236
|
+
---
|
|
66
237
|
|
|
67
|
-
|
|
68
|
-
import { getRate } from 'paj_ramp';
|
|
238
|
+
# Offramp SDK
|
|
69
239
|
|
|
70
|
-
|
|
240
|
+
## Overview
|
|
71
241
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
userAmountFiat": number
|
|
84
|
-
}
|
|
85
|
-
}
|
|
242
|
+
The Offramp SDK provides a set of functions to help users convert Solana-based digital assets to fiat and transfer the resulting funds to traditional bank accounts. It includes session management, rate queries, bank account management, and wallet operations.
|
|
243
|
+
|
|
244
|
+
## Usage Examples
|
|
245
|
+
|
|
246
|
+
### Get TX Pool Address
|
|
247
|
+
|
|
248
|
+
```typescript
|
|
249
|
+
import { getTXPoolAddress } from "paj-ramp";
|
|
250
|
+
|
|
251
|
+
const txpooladdress = await getTXPoolAddress();
|
|
252
|
+
// Response: { address: string }
|
|
86
253
|
```
|
|
87
254
|
|
|
88
|
-
###
|
|
255
|
+
### Get Rate
|
|
89
256
|
|
|
90
|
-
```
|
|
91
|
-
import {
|
|
257
|
+
```typescript
|
|
258
|
+
import { getRate } from "paj-ramp";
|
|
92
259
|
|
|
93
|
-
const
|
|
260
|
+
const rate = await getRate();
|
|
261
|
+
// Response: { baseCurrency: string, targetCurrency: string, rate: number }
|
|
262
|
+
```
|
|
94
263
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
264
|
+
### Get Rate with Amount
|
|
265
|
+
|
|
266
|
+
```typescript
|
|
267
|
+
import { getRate } from "paj-ramp";
|
|
268
|
+
|
|
269
|
+
const rate = await getRate(50000);
|
|
270
|
+
// Response:
|
|
271
|
+
// {
|
|
272
|
+
// rate: { baseCurrency: string, targetCurrency: string, rate: number },
|
|
273
|
+
// amounts: { userTax: number, merchantTax: number, amountUSD: number, userAmountFiat: number }
|
|
274
|
+
// }
|
|
99
275
|
```
|
|
100
276
|
|
|
101
|
-
###
|
|
277
|
+
### Initiate Session
|
|
102
278
|
|
|
103
|
-
```
|
|
104
|
-
import {
|
|
279
|
+
```typescript
|
|
280
|
+
import { initiate } from "paj-ramp";
|
|
105
281
|
|
|
106
|
-
const
|
|
282
|
+
const initialized = await initiate("your_email@gmail.com");
|
|
283
|
+
// Response: { email: string }
|
|
284
|
+
```
|
|
107
285
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
286
|
+
### Verify Session
|
|
287
|
+
|
|
288
|
+
```typescript
|
|
289
|
+
import { verify } from "paj-ramp";
|
|
290
|
+
|
|
291
|
+
const verified = await verify(
|
|
292
|
+
"your_email@gmail.com",
|
|
293
|
+
"1234",
|
|
294
|
+
"device signature"
|
|
295
|
+
);
|
|
296
|
+
// Response: { email: string, isActive: string, expiresAt: string, token: string }
|
|
115
297
|
```
|
|
116
298
|
|
|
117
|
-
### Get Banks
|
|
299
|
+
### Get Banks
|
|
118
300
|
|
|
119
|
-
```
|
|
120
|
-
import { getBanks } from
|
|
301
|
+
```typescript
|
|
302
|
+
import { getBanks } from "paj-ramp";
|
|
121
303
|
|
|
122
304
|
const banks = await getBanks();
|
|
123
|
-
|
|
124
|
-
# Response
|
|
125
|
-
[
|
|
126
|
-
{
|
|
127
|
-
id: string,
|
|
128
|
-
name: string,
|
|
129
|
-
country: string
|
|
130
|
-
}
|
|
131
|
-
]
|
|
305
|
+
// Response: [ { id: string, name: string, country: string } ]
|
|
132
306
|
```
|
|
133
307
|
|
|
134
308
|
### Resolve Bank Account
|
|
135
309
|
|
|
136
|
-
```
|
|
137
|
-
import { resolveBankAccount } from
|
|
138
|
-
|
|
139
|
-
const resolvedBankAccount = await resolveBankAccount(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
accountNumber: string,
|
|
145
|
-
bank: {
|
|
146
|
-
id: string,
|
|
147
|
-
name: string,
|
|
148
|
-
code: string,
|
|
149
|
-
country: string,
|
|
150
|
-
}
|
|
151
|
-
}
|
|
310
|
+
```typescript
|
|
311
|
+
import { resolveBankAccount } from "paj-ramp";
|
|
312
|
+
|
|
313
|
+
const resolvedBankAccount = await resolveBankAccount(
|
|
314
|
+
"bank id",
|
|
315
|
+
"account number"
|
|
316
|
+
);
|
|
317
|
+
// Response: { accountName: string, accountNumber: string, bank: { id: string, name: string, code: string, country: string } }
|
|
152
318
|
```
|
|
153
319
|
|
|
154
320
|
### Add Bank Account
|
|
155
321
|
|
|
156
|
-
```
|
|
157
|
-
import { addBankAccount } from
|
|
322
|
+
```typescript
|
|
323
|
+
import { addBankAccount } from "paj-ramp";
|
|
158
324
|
|
|
159
|
-
const addedBankAccount = await addBankAccount(
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
accountNumber: string,
|
|
166
|
-
bank: string
|
|
167
|
-
}
|
|
325
|
+
const addedBankAccount = await addBankAccount(
|
|
326
|
+
"token",
|
|
327
|
+
"bank id",
|
|
328
|
+
"account number"
|
|
329
|
+
);
|
|
330
|
+
// Response: { id: string, accountName: string, accountNumber: string, bank: string }
|
|
168
331
|
```
|
|
169
332
|
|
|
170
333
|
### Get Bank Accounts
|
|
171
334
|
|
|
172
|
-
```
|
|
173
|
-
import { getBankAccounts } from
|
|
335
|
+
```typescript
|
|
336
|
+
import { getBankAccounts } from "paj-ramp";
|
|
174
337
|
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
# Response
|
|
178
|
-
[
|
|
179
|
-
{
|
|
180
|
-
id: string,
|
|
181
|
-
accountName: string,
|
|
182
|
-
accountNumber: string,
|
|
183
|
-
bank: string
|
|
184
|
-
}
|
|
185
|
-
]
|
|
338
|
+
const accounts = await getBankAccounts("token");
|
|
339
|
+
// Response: [ { id: string, accountName: string, accountNumber: string, bank: string } ]
|
|
186
340
|
```
|
|
187
341
|
|
|
188
342
|
### Get Wallet Info
|
|
189
343
|
|
|
190
|
-
```
|
|
191
|
-
import { getWallet } from
|
|
192
|
-
|
|
193
|
-
const wallet = await getWallet(
|
|
194
|
-
|
|
195
|
-
# Response
|
|
196
|
-
{
|
|
197
|
-
id: string,
|
|
198
|
-
publicKey: string,
|
|
199
|
-
bankAccount: {
|
|
200
|
-
id: string,
|
|
201
|
-
accountName: string,
|
|
202
|
-
accountNumber: string,
|
|
203
|
-
bank: string
|
|
204
|
-
}
|
|
205
|
-
}
|
|
344
|
+
```typescript
|
|
345
|
+
import { getWallet } from "paj-ramp";
|
|
346
|
+
|
|
347
|
+
const wallet = await getWallet("wallet public key");
|
|
348
|
+
// Response: { id: string, publicKey: string, bankAccount: { id: string, accountName: string, accountNumber: string, bank: string } }
|
|
206
349
|
```
|
|
207
350
|
|
|
208
351
|
### Add Wallet
|
|
209
352
|
|
|
210
|
-
```
|
|
211
|
-
import { addWallet } from
|
|
212
|
-
|
|
213
|
-
const addedWallet = await addWallet(
|
|
214
|
-
|
|
215
|
-
# Response
|
|
216
|
-
{
|
|
217
|
-
id: string,
|
|
218
|
-
publicKey: string,
|
|
219
|
-
bankAccount: {
|
|
220
|
-
id: string,
|
|
221
|
-
accountName: string,
|
|
222
|
-
accountNumber: string,
|
|
223
|
-
bank: string
|
|
224
|
-
}
|
|
225
|
-
}
|
|
353
|
+
```typescript
|
|
354
|
+
import { addWallet } from "paj-ramp";
|
|
355
|
+
|
|
356
|
+
const addedWallet = await addWallet("token", "bank account id", "secret key");
|
|
357
|
+
// Response: { id: string, publicKey: string, bankAccount: { id: string, accountName: string, accountNumber: string, bank: string } }
|
|
226
358
|
```
|
|
227
359
|
|
|
228
360
|
### Switch Bank Account on Wallet
|
|
229
361
|
|
|
230
|
-
```
|
|
231
|
-
import { switchWalletBankAccount } from
|
|
232
|
-
|
|
233
|
-
const switchedWallet = await switchWalletBankAccount('token','bank account id to switch to', 'wallet id', 'secret key');
|
|
234
|
-
|
|
235
|
-
# Response
|
|
236
|
-
{
|
|
237
|
-
id: string,
|
|
238
|
-
publicKey: string,
|
|
239
|
-
bankAccount: {
|
|
240
|
-
id: string,
|
|
241
|
-
accountName: string,
|
|
242
|
-
accountNumber: string,
|
|
243
|
-
bank: string
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
```
|
|
362
|
+
```typescript
|
|
363
|
+
import { switchWalletBankAccount } from "paj-ramp";
|
|
247
364
|
|
|
248
|
-
|
|
365
|
+
const switchedWallet = await switchWalletBankAccount(
|
|
366
|
+
"token",
|
|
367
|
+
"bank account id to switch to",
|
|
368
|
+
"wallet id",
|
|
369
|
+
"secret key"
|
|
370
|
+
);
|
|
371
|
+
// Response: { id: string, publicKey: string, bankAccount: { id: string, accountName: string, accountNumber: string, bank: string } }
|
|
372
|
+
```
|
|
249
373
|
|
|
250
|
-
##
|
|
374
|
+
## License
|
|
251
375
|
|
|
252
|
-
|
|
376
|
+
MIT
|
|
253
377
|
|
|
378
|
+
## 🧑💻 Author
|
|
254
379
|
|
|
380
|
+
Gospel Chidiebube Chukwu
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
export { getTXPoolAddress } from
|
|
2
|
-
export { getRate } from
|
|
3
|
-
export { initiate } from
|
|
4
|
-
export { verify } from
|
|
5
|
-
export { getBanks } from
|
|
6
|
-
export { resolveBankAccount } from
|
|
7
|
-
export { addBankAccount } from
|
|
8
|
-
export { getBankAccounts } from
|
|
9
|
-
export { getWallet } from
|
|
10
|
-
export { addWallet } from
|
|
11
|
-
export { switchWalletBankAccount } from
|
|
1
|
+
export { getTXPoolAddress } from "./lib/off_ramp/getTXPoolAddress.js";
|
|
2
|
+
export { getRate } from "./lib/off_ramp/getRate.js";
|
|
3
|
+
export { initiate } from "./lib/off_ramp/initiate.js";
|
|
4
|
+
export { verify } from "./lib/off_ramp/verify.js";
|
|
5
|
+
export { getBanks } from "./lib/off_ramp/getBanks.js";
|
|
6
|
+
export { resolveBankAccount } from "./lib/off_ramp/resolveBankAccount.js";
|
|
7
|
+
export { addBankAccount } from "./lib/off_ramp/addBankAccount.js";
|
|
8
|
+
export { getBankAccounts } from "./lib/off_ramp/getBankAccounts.js";
|
|
9
|
+
export { getWallet } from "./lib/off_ramp/getWallet.js";
|
|
10
|
+
export { addWallet } from "./lib/off_ramp/addWallet.js";
|
|
11
|
+
export { switchWalletBankAccount } from "./lib/off_ramp/switchWalletBankAccount.js";
|
|
12
|
+
export { createOrder } from "./lib/on_ramp/createOrder.js";
|
|
13
|
+
export { observeOrder, OnRampOrderUpdate } from "./lib/on_ramp/observeOrder.js";
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
//Web3.js - A JavaScript library for interacting with the Web3 ecosystem.
|
|
2
|
+
//OFF RAMP
|
|
2
3
|
//Wallet Info
|
|
3
|
-
export { getTXPoolAddress } from
|
|
4
|
-
export { getRate } from
|
|
4
|
+
export { getTXPoolAddress } from "./lib/off_ramp/getTXPoolAddress.js";
|
|
5
|
+
export { getRate } from "./lib/off_ramp/getRate.js";
|
|
5
6
|
//Session Management
|
|
6
|
-
export { initiate } from
|
|
7
|
-
export { verify } from
|
|
7
|
+
export { initiate } from "./lib/off_ramp/initiate.js";
|
|
8
|
+
export { verify } from "./lib/off_ramp/verify.js";
|
|
8
9
|
//Banking Operations
|
|
9
|
-
export { getBanks } from
|
|
10
|
-
export { resolveBankAccount } from
|
|
11
|
-
export { addBankAccount } from
|
|
12
|
-
export { getBankAccounts } from
|
|
10
|
+
export { getBanks } from "./lib/off_ramp/getBanks.js";
|
|
11
|
+
export { resolveBankAccount } from "./lib/off_ramp/resolveBankAccount.js";
|
|
12
|
+
export { addBankAccount } from "./lib/off_ramp/addBankAccount.js";
|
|
13
|
+
export { getBankAccounts } from "./lib/off_ramp/getBankAccounts.js";
|
|
13
14
|
//Wallet Operations
|
|
14
|
-
export { getWallet } from
|
|
15
|
-
export { addWallet } from
|
|
16
|
-
export { switchWalletBankAccount } from
|
|
15
|
+
export { getWallet } from "./lib/off_ramp/getWallet.js";
|
|
16
|
+
export { addWallet } from "./lib/off_ramp/addWallet.js";
|
|
17
|
+
export { switchWalletBankAccount } from "./lib/off_ramp/switchWalletBankAccount.js";
|
|
18
|
+
// ON RAMP
|
|
19
|
+
export { createOrder } from "./lib/on_ramp/createOrder.js";
|
|
20
|
+
// NEW: Socket.IO exports
|
|
21
|
+
export { observeOrder } from "./lib/on_ramp/observeOrder.js";
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
type AddBankAccountType = {
|
|
2
|
+
id: string;
|
|
3
|
+
accountName: string;
|
|
4
|
+
accountNumber: string;
|
|
5
|
+
bank: string;
|
|
6
|
+
};
|
|
1
7
|
/**
|
|
2
8
|
* Adds a new bank account by sending the provided token, bank ID, and account number to the public API.
|
|
3
9
|
* Returns the added bank account details or throws an error if the request fails.
|
|
@@ -13,9 +19,5 @@
|
|
|
13
19
|
* Raises:
|
|
14
20
|
* Throws an error if the request fails.
|
|
15
21
|
*/
|
|
16
|
-
export declare const addBankAccount: (token: string, bankId: string, accountNumber: string) => Promise<
|
|
17
|
-
|
|
18
|
-
accountName: string;
|
|
19
|
-
accountNumber: string;
|
|
20
|
-
bank: string;
|
|
21
|
-
}>;
|
|
22
|
+
export declare const addBankAccount: (token: string, bankId: string, accountNumber: string) => Promise<AddBankAccountType>;
|
|
23
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { post } from
|
|
1
|
+
import { post } from "../../utils/api.js";
|
|
2
2
|
/**
|
|
3
3
|
* Adds a new bank account by sending the provided token, bank ID, and account number to the public API.
|
|
4
4
|
* Returns the added bank account details or throws an error if the request fails.
|
|
@@ -16,7 +16,7 @@ import { post } from '../utils/api.js';
|
|
|
16
16
|
*/
|
|
17
17
|
export const addBankAccount = async (token, bankId, accountNumber) => {
|
|
18
18
|
try {
|
|
19
|
-
return await post(
|
|
19
|
+
return await post("/pub/bankAccount", {
|
|
20
20
|
bankId,
|
|
21
21
|
accountNumber,
|
|
22
22
|
}, {
|
|
@@ -24,7 +24,7 @@ export const addBankAccount = async (token, bankId, accountNumber) => {
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
catch (err) {
|
|
27
|
-
console.error(
|
|
27
|
+
console.error("Error adding bank account:", err);
|
|
28
28
|
throw err;
|
|
29
29
|
}
|
|
30
30
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WalletType } from "./getWallet.js";
|
|
1
2
|
/**
|
|
2
3
|
* Adds a new wallet for the user.
|
|
3
4
|
* Returns the added wallet object or throws an error if the request fails.
|
|
@@ -8,4 +9,4 @@
|
|
|
8
9
|
* Raises:
|
|
9
10
|
* Throws an error if the wallet file is not found or if the secret key is invalid.
|
|
10
11
|
*/
|
|
11
|
-
export declare const addWallet: (apiKey: string, accountId: string, secretKey: Uint8Array) => Promise<
|
|
12
|
+
export declare const addWallet: (apiKey: string, accountId: string, secretKey: Uint8Array) => Promise<WalletType>;
|