paj_ramp 1.2.9 → 1.3.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.
Files changed (62) hide show
  1. package/README.md +99 -1
  2. package/dist/lib/core/addBankAccount.d.ts +23 -0
  3. package/dist/lib/core/addBankAccount.js +30 -0
  4. package/dist/lib/core/addWallet.d.ts +12 -0
  5. package/dist/lib/core/addWallet.js +27 -0
  6. package/dist/lib/core/getAllRate.d.ts +27 -0
  7. package/dist/lib/core/getAllRate.js +20 -0
  8. package/dist/lib/core/getAllTransactions.d.ts +12 -0
  9. package/dist/lib/core/getAllTransactions.js +20 -0
  10. package/dist/lib/core/getAllTranstions.d.ts +12 -0
  11. package/dist/lib/core/getAllTranstions.js +18 -0
  12. package/dist/lib/core/getBankAccounts.d.ts +18 -0
  13. package/dist/lib/core/getBankAccounts.js +22 -0
  14. package/dist/lib/core/getBanks.d.ts +17 -0
  15. package/dist/lib/core/getBanks.js +22 -0
  16. package/dist/lib/core/getRateByAmount.d.ts +27 -0
  17. package/dist/lib/core/getRateByAmount.js +23 -0
  18. package/dist/lib/core/getRateByType.d.ts +18 -0
  19. package/dist/lib/core/getRateByType.js +19 -0
  20. package/dist/lib/core/getTXPoolAddress.d.ts +13 -0
  21. package/dist/lib/core/getTXPoolAddress.js +20 -0
  22. package/dist/lib/core/getTokenValue.d.ts +20 -0
  23. package/dist/lib/core/getTokenValue.js +24 -0
  24. package/dist/lib/core/getTransaction.d.ts +26 -0
  25. package/dist/lib/core/getTransaction.js +21 -0
  26. package/dist/lib/core/getWallet.d.ts +24 -0
  27. package/dist/lib/core/getWallet.js +23 -0
  28. package/dist/lib/core/initiate.d.ts +18 -0
  29. package/dist/lib/core/initiate.js +23 -0
  30. package/dist/lib/core/resolveBankAccount.d.ts +26 -0
  31. package/dist/lib/core/resolveBankAccount.js +26 -0
  32. package/dist/lib/core/switchWalletBankAccount.d.ts +2 -0
  33. package/dist/lib/core/switchWalletBankAccount.js +18 -0
  34. package/dist/lib/core/verify.d.ts +30 -0
  35. package/dist/lib/core/verify.js +29 -0
  36. package/dist/lib/off_ramp/directCreateOrder.d.ts +19 -0
  37. package/dist/lib/off_ramp/directCreateOrder.js +19 -0
  38. package/dist/sdk.d.ts +14 -12
  39. package/dist/sdk.js +21 -22
  40. package/dist/utils/enums.d.ts +21 -0
  41. package/dist/utils/enums.js +30 -0
  42. package/lib/{direct_off_ramp → off_ramp}/directCreateOrder.ts +14 -13
  43. package/lib/on_ramp/createOrder.ts +3 -1
  44. package/lib/utility/getAllTransactions.ts +27 -0
  45. package/lib/{off_ramp → utility}/getRateByType.ts +1 -5
  46. package/lib/utility/getTransaction.ts +46 -0
  47. package/package.json +1 -1
  48. package/sdk.ts +26 -28
  49. package/utils/enums.ts +31 -0
  50. /package/lib/{off_ramp → utility}/addBankAccount.ts +0 -0
  51. /package/lib/{off_ramp → utility}/addWallet.ts +0 -0
  52. /package/lib/{off_ramp → utility}/getAllRate.ts +0 -0
  53. /package/lib/{off_ramp → utility}/getBankAccounts.ts +0 -0
  54. /package/lib/{off_ramp → utility}/getBanks.ts +0 -0
  55. /package/lib/{off_ramp → utility}/getRateByAmount.ts +0 -0
  56. /package/lib/{off_ramp → utility}/getTXPoolAddress.ts +0 -0
  57. /package/lib/{off_ramp → utility}/getTokenValue.ts +0 -0
  58. /package/lib/{off_ramp → utility}/getWallet.ts +0 -0
  59. /package/lib/{off_ramp → utility}/initiate.ts +0 -0
  60. /package/lib/{off_ramp → utility}/resolveBankAccount.ts +0 -0
  61. /package/lib/{off_ramp → utility}/switchWalletBankAccount.ts +0 -0
  62. /package/lib/{off_ramp → utility}/verify.ts +0 -0
package/README.md CHANGED
@@ -186,6 +186,57 @@ const accounts = await getBankAccounts('token');
186
186
  // Response: [ { id: string, accountName: string, accountNumber: string, bank: string } ]
187
187
  ```
188
188
 
189
+ ### Transaction History:
190
+
191
+ **_Get All Transactions_**
192
+
193
+ ```typescript
194
+ import { getAllTransactions } from 'paj_ramp';
195
+
196
+ const transactions = await getAllTransactions('token_from_verification');
197
+ /* Response: [{
198
+ id: string;
199
+ address: string;
200
+ mint: string;
201
+ currency: Currency;
202
+ amount: number;
203
+ usdcAmount: number;
204
+ fiatAmount: number;
205
+ sender: string;
206
+ receipiant: string;
207
+ rate: number;
208
+ status: TransactionStatus;
209
+ transactionType: TransactionType;
210
+ createdAt: string | Date;
211
+ }]*/
212
+ ```
213
+
214
+ **_Get Transaction_**
215
+
216
+ ```typescript
217
+ import { getTransaction } from 'paj_ramp';
218
+
219
+ const transactions = await getTransaction(
220
+ 'token_from_verification',
221
+ 'transaction_id'
222
+ );
223
+ /* Response: {
224
+ id: string;
225
+ address: string;
226
+ mint: string;
227
+ currency: Currency;
228
+ amount: number;
229
+ usdcAmount: number;
230
+ fiatAmount: number;
231
+ sender: string;
232
+ receipiant: string;
233
+ rate: number;
234
+ status: TransactionStatus;
235
+ transactionType: TransactionType;
236
+ createdAt: string | Date;
237
+ }*/
238
+ ```
239
+
189
240
  ## Offramp Webhook (Direct Offramp)
190
241
 
191
242
  ### Usage Example
@@ -202,7 +253,21 @@ const createOrder = await offRampCreateOrder(
202
253
  'token_mint_address'
203
254
  'webhook_url'
204
255
  );
205
- // Response: { id: string, address: string, signature?: string, mint: string, currency: Currency, amount: number, usdcAmount: number, fiatAmount: number, sender: string, receipiant: string, rate: number, status: TransactionStatus, transactionType: TransactionType }
256
+ /* Response: {
257
+ id: string,
258
+ address: string,
259
+ signature?: string,
260
+ mint: string,
261
+ currency: Currency,
262
+ amount: number,
263
+ usdcAmount: number,
264
+ fiatAmount: number,
265
+ sender: string,
266
+ receipiant: string,
267
+ rate: number,
268
+ status: TransactionStatus,
269
+ transactionType: TransactionType
270
+ }*/
206
271
  ```
207
272
 
208
273
  ## Onramp Webhook: Creates a new onramp order and sends status to the webhook url.
@@ -224,6 +289,39 @@ const order = await createOrder({
224
289
  // Response: { id: string, accountNumber: string, accountName: string, fiatAmount: number, bank: string }
225
290
  ```
226
291
 
292
+ ## Webhook Response Data Structure
293
+
294
+ ### For both onramp and offramp
295
+
296
+ ```typescript
297
+ {
298
+ id: string;
299
+ address: string;
300
+ signature?: string;
301
+ mint: string;
302
+ currency: Currency; // eg. NGN, USD
303
+ amount: number;
304
+ usdcAmount: number;
305
+ fiatAmount: number;
306
+ sender: string;
307
+ receipiant: string;
308
+ rate: number;
309
+ status: TransactionStatus; // eg. INIT, PAID, COMPLETED
310
+ transactionType: TransactionType; // ON_RAMP or OFF_RAMP
311
+ }
312
+ ```
313
+
314
+ ## Other types
315
+
316
+ ```typescript
317
+ import {
318
+ // Chain, // SOLANA, etc
319
+ TransactionStatus, // INIT<, etc
320
+ TransactionType, // ON_RAMP, etc
321
+ Currency, // NGN
322
+ } from 'paj_ramp';
323
+ ```
324
+
227
325
  <!--
228
326
  ## Quick Start
229
327
 
@@ -0,0 +1,23 @@
1
+ type AddBankAccountType = {
2
+ id: string;
3
+ accountName: string;
4
+ accountNumber: string;
5
+ bank: string;
6
+ };
7
+ /**
8
+ * Adds a new bank account by sending the provided token, bank ID, and account number to the public API.
9
+ * Returns the added bank account details or throws an error if the request fails.
10
+ *
11
+ * Args:
12
+ * token: The authentication token for the request.
13
+ * bankId: The ID of the bank.
14
+ * accountNumber: The bank account number to add.
15
+ *
16
+ * Returns:
17
+ * An object containing the new bank account's id, accountName, accountNumber, and bank.
18
+ *
19
+ * Raises:
20
+ * Throws an error if the request fails.
21
+ */
22
+ export declare const addBankAccount: (token: string, bankId: string, accountNumber: string) => Promise<AddBankAccountType>;
23
+ export {};
@@ -0,0 +1,30 @@
1
+ import { post } from "../../utils/api.js";
2
+ /**
3
+ * Adds a new bank account by sending the provided token, bank ID, and account number to the public API.
4
+ * Returns the added bank account details or throws an error if the request fails.
5
+ *
6
+ * Args:
7
+ * token: The authentication token for the request.
8
+ * bankId: The ID of the bank.
9
+ * accountNumber: The bank account number to add.
10
+ *
11
+ * Returns:
12
+ * An object containing the new bank account's id, accountName, accountNumber, and bank.
13
+ *
14
+ * Raises:
15
+ * Throws an error if the request fails.
16
+ */
17
+ export const addBankAccount = async (token, bankId, accountNumber) => {
18
+ try {
19
+ return await post('/pub/bank-account', {
20
+ bankId,
21
+ accountNumber,
22
+ }, {
23
+ Authorization: `Bearer ${token}`,
24
+ });
25
+ }
26
+ catch (err) {
27
+ console.error("Error adding bank account:", err);
28
+ throw err;
29
+ }
30
+ };
@@ -0,0 +1,12 @@
1
+ import { WalletType } from "./getWallet.js";
2
+ /**
3
+ * Adds a new wallet for the user.
4
+ * Returns the added wallet object or throws an error if the request fails.
5
+ *
6
+ * Returns:
7
+ * An object containing id, accountName, accountNumber, and bank of the bank account.
8
+ *
9
+ * Raises:
10
+ * Throws an error if the wallet file is not found or if the secret key is invalid.
11
+ */
12
+ export declare const addWallet: (apiKey: string, accountId: string, secretKey: Uint8Array) => Promise<WalletType>;
@@ -0,0 +1,27 @@
1
+ import { post } from "../../utils/api.js";
2
+ import { getWalletBody } from "../../utils/getWalletBody.js";
3
+ /**
4
+ * Adds a new wallet for the user.
5
+ * Returns the added wallet object or throws an error if the request fails.
6
+ *
7
+ * Returns:
8
+ * An object containing id, accountName, accountNumber, and bank of the bank account.
9
+ *
10
+ * Raises:
11
+ * Throws an error if the wallet file is not found or if the secret key is invalid.
12
+ */
13
+ export const addWallet = async (apiKey, accountId, secretKey) => {
14
+ try {
15
+ const body = await getWalletBody(accountId, secretKey);
16
+ if (!body) {
17
+ throw new Error("Failed to get wallet body");
18
+ }
19
+ return await post("/pub/wallet", body, {
20
+ Authorization: `Bearer ${apiKey}`,
21
+ });
22
+ }
23
+ catch (err) {
24
+ console.error("Error adding wallet:", err);
25
+ throw err;
26
+ }
27
+ };
@@ -0,0 +1,27 @@
1
+ type AllRateResponseType = {
2
+ onRampRate: {
3
+ baseCurrency: string;
4
+ targetCurrency: string;
5
+ isActive: boolean;
6
+ rate: number;
7
+ type: string;
8
+ };
9
+ offRampRate: {
10
+ baseCurrency: string;
11
+ targetCurrency: string;
12
+ isActive: boolean;
13
+ rate: number;
14
+ type: string;
15
+ };
16
+ };
17
+ /**
18
+ * This TypeScript function asynchronously fetches all rates from a specified URL and handles any
19
+ * errors that may occur.
20
+ * @returns The `getAllRate` function is returning the result of the `get<AllRateResponseType>(url)`
21
+ * function call, which is fetching rate data from the specified URL '/pub/rate'. The function is using
22
+ * async/await syntax to handle asynchronous operations and is catching any errors that occur during
23
+ * the fetch operation. If successful, the function will return the rate data, and if an error occurs,
24
+ * it
25
+ */
26
+ export declare const getAllRate: () => Promise<AllRateResponseType>;
27
+ export {};
@@ -0,0 +1,20 @@
1
+ import { get } from '../../utils/api.js';
2
+ /**
3
+ * This TypeScript function asynchronously fetches all rates from a specified URL and handles any
4
+ * errors that may occur.
5
+ * @returns The `getAllRate` function is returning the result of the `get<AllRateResponseType>(url)`
6
+ * function call, which is fetching rate data from the specified URL '/pub/rate'. The function is using
7
+ * async/await syntax to handle asynchronous operations and is catching any errors that occur during
8
+ * the fetch operation. If successful, the function will return the rate data, and if an error occurs,
9
+ * it
10
+ */
11
+ export const getAllRate = async () => {
12
+ const url = '/pub/rate';
13
+ try {
14
+ return await get(url);
15
+ }
16
+ catch (err) {
17
+ console.error('Error fetching Rate:', err);
18
+ throw err;
19
+ }
20
+ };
@@ -0,0 +1,12 @@
1
+ import { TransactionResponse } from './getTransaction.js';
2
+ type TransactionsResponse = TransactionResponse[];
3
+ /**
4
+ * The function getAllTransactions fetches all transactions from a specified endpoint and handles any
5
+ * errors that occur.
6
+ * @returns The `getAllTransactions` function is returning the result of the `get` function called with
7
+ * the '/pub/transactions' endpoint. The result is expected to be of type `TransactionsResponse`. If
8
+ * successful, the function will return the transactions data. If an error occurs during the API call,
9
+ * it will be caught, logged to the console, and rethrown.
10
+ */
11
+ export declare const getAllTransactions: (token: string) => Promise<TransactionsResponse>;
12
+ export {};
@@ -0,0 +1,20 @@
1
+ import { get } from '../../utils/api.js';
2
+ /**
3
+ * The function getAllTransactions fetches all transactions from a specified endpoint and handles any
4
+ * errors that occur.
5
+ * @returns The `getAllTransactions` function is returning the result of the `get` function called with
6
+ * the '/pub/transactions' endpoint. The result is expected to be of type `TransactionsResponse`. If
7
+ * successful, the function will return the transactions data. If an error occurs during the API call,
8
+ * it will be caught, logged to the console, and rethrown.
9
+ */
10
+ export const getAllTransactions = async (token) => {
11
+ try {
12
+ return await get('/pub/transactions', {}, {
13
+ Authorization: `Bearer ${token}`,
14
+ });
15
+ }
16
+ catch (err) {
17
+ console.error('Error fetching Transactions:', err);
18
+ throw err;
19
+ }
20
+ };
@@ -0,0 +1,12 @@
1
+ import { TransactionResponse } from './getTransaction.js';
2
+ type TransactionsResponse = TransactionResponse[];
3
+ /**
4
+ * The function getAllTransactions fetches all transactions from a specified endpoint and handles any
5
+ * errors that occur.
6
+ * @returns The `getAllTransactions` function is returning the result of the `get` function called with
7
+ * the '/pub/transactions' endpoint. The result is expected to be of type `TransactionsResponse`. If
8
+ * successful, the function will return the transactions data. If an error occurs during the API call,
9
+ * it will be caught, logged to the console, and rethrown.
10
+ */
11
+ export declare const getAllTransactions: () => Promise<TransactionsResponse>;
12
+ export {};
@@ -0,0 +1,18 @@
1
+ import { get } from '../../utils/api.js';
2
+ /**
3
+ * The function getAllTransactions fetches all transactions from a specified endpoint and handles any
4
+ * errors that occur.
5
+ * @returns The `getAllTransactions` function is returning the result of the `get` function called with
6
+ * the '/pub/transactions' endpoint. The result is expected to be of type `TransactionsResponse`. If
7
+ * successful, the function will return the transactions data. If an error occurs during the API call,
8
+ * it will be caught, logged to the console, and rethrown.
9
+ */
10
+ export const getAllTransactions = async () => {
11
+ try {
12
+ return await get('/pub/transactions');
13
+ }
14
+ catch (err) {
15
+ console.error('Error fetching Transactions:', err);
16
+ throw err;
17
+ }
18
+ };
@@ -0,0 +1,18 @@
1
+ type GetBankAccountsType = {
2
+ id: string;
3
+ accountName: string;
4
+ accountNumber: string;
5
+ bank: string;
6
+ };
7
+ /**
8
+ * Fetches a list of added bank accounts from the public API endpoint.
9
+ * Returns an array of bank account objects or throws an error if the request fails.
10
+ *
11
+ * Returns:
12
+ * An array of objects, each containing id, accountName, accountNumber, and bank of a bank account.
13
+ *
14
+ * Raises:
15
+ * Throws an error if the request fails.
16
+ */
17
+ export declare const getBankAccounts: (apiKey: string) => Promise<GetBankAccountsType[]>;
18
+ export {};
@@ -0,0 +1,22 @@
1
+ import { get } from "../../utils/api.js";
2
+ /**
3
+ * Fetches a list of added bank accounts from the public API endpoint.
4
+ * Returns an array of bank account objects or throws an error if the request fails.
5
+ *
6
+ * Returns:
7
+ * An array of objects, each containing id, accountName, accountNumber, and bank of a bank account.
8
+ *
9
+ * Raises:
10
+ * Throws an error if the request fails.
11
+ */
12
+ export const getBankAccounts = async (apiKey) => {
13
+ try {
14
+ return await get(`/pub/bank-account`, {}, {
15
+ Authorization: `Bearer ${apiKey}`,
16
+ });
17
+ }
18
+ catch (err) {
19
+ console.error("Error fetching bank accounts:", err);
20
+ throw err;
21
+ }
22
+ };
@@ -0,0 +1,17 @@
1
+ type BankType = {
2
+ id: string;
3
+ name: string;
4
+ country: string;
5
+ };
6
+ /**
7
+ * Fetches a list of banks from the public API endpoint.
8
+ * Returns an array of bank objects or throws an error if the request fails.
9
+ *
10
+ * Returns:
11
+ * An array of objects, each containing id, name, and country of a bank.
12
+ *
13
+ * Raises:
14
+ * Throws an error if the request fails.
15
+ */
16
+ export declare const getBanks: (token: string) => Promise<BankType[]>;
17
+ export {};
@@ -0,0 +1,22 @@
1
+ import { get } from '../../utils/api.js';
2
+ /**
3
+ * Fetches a list of banks from the public API endpoint.
4
+ * Returns an array of bank objects or throws an error if the request fails.
5
+ *
6
+ * Returns:
7
+ * An array of objects, each containing id, name, and country of a bank.
8
+ *
9
+ * Raises:
10
+ * Throws an error if the request fails.
11
+ */
12
+ export const getBanks = async (token) => {
13
+ try {
14
+ return await get(`/pub/bank`, {}, {
15
+ Authorization: `Bearer ${token}`,
16
+ });
17
+ }
18
+ catch (err) {
19
+ console.error('Error fetching Banks:', err);
20
+ throw err;
21
+ }
22
+ };
@@ -0,0 +1,27 @@
1
+ type RateByAmountType = {
2
+ rate: {
3
+ baseCurrency: string;
4
+ targetCurrency: string;
5
+ rate: number;
6
+ };
7
+ amounts: {
8
+ userTax: number;
9
+ merchantTax: number;
10
+ amountUSD: number;
11
+ userAmountFiat: number;
12
+ };
13
+ };
14
+ /**
15
+ * The function `getRateByAmount` fetches a rate based on a specified amount asynchronously.
16
+ * @param {number} amount - The `amount` parameter in the `getRateByAmount` function is a number
17
+ * representing the amount for which you want to retrieve the rate. This function makes an asynchronous
18
+ * request to the `/pub/rate` endpoint with the specified amount to fetch the rate information. If
19
+ * successful, it returns the rate
20
+ * @returns The `getRateByAmount` function is returning a Promise that resolves to the rate for a
21
+ * specific amount. The rate is fetched from the specified URL endpoint `/pub/rate` with the provided
22
+ * amount as a parameter. If the rate is successfully fetched, it will be returned. If there is an
23
+ * error during the fetching process, an error message will be logged to the console and the error will
24
+ * be
25
+ */
26
+ export declare const getRateByAmount: (amount: number) => Promise<RateByAmountType>;
27
+ export {};
@@ -0,0 +1,23 @@
1
+ import { get } from '../../utils/api.js';
2
+ /**
3
+ * The function `getRateByAmount` fetches a rate based on a specified amount asynchronously.
4
+ * @param {number} amount - The `amount` parameter in the `getRateByAmount` function is a number
5
+ * representing the amount for which you want to retrieve the rate. This function makes an asynchronous
6
+ * request to the `/pub/rate` endpoint with the specified amount to fetch the rate information. If
7
+ * successful, it returns the rate
8
+ * @returns The `getRateByAmount` function is returning a Promise that resolves to the rate for a
9
+ * specific amount. The rate is fetched from the specified URL endpoint `/pub/rate` with the provided
10
+ * amount as a parameter. If the rate is successfully fetched, it will be returned. If there is an
11
+ * error during the fetching process, an error message will be logged to the console and the error will
12
+ * be
13
+ */
14
+ export const getRateByAmount = async (amount) => {
15
+ const url = '/pub/rate';
16
+ try {
17
+ return await get(`${url}/${amount}`);
18
+ }
19
+ catch (err) {
20
+ console.error('Error fetching Rate by Amount:', err);
21
+ throw err;
22
+ }
23
+ };
@@ -0,0 +1,18 @@
1
+ import { RateType } from '../../utils/enums.js';
2
+ type RateByType = {
3
+ baseCurrency: string;
4
+ targetCurrency: string;
5
+ isActive: true;
6
+ rate: number;
7
+ type: string;
8
+ };
9
+ /**
10
+ * This function fetches a rate based on a specified rate type asynchronously.
11
+ * @param {RateType} rateType - RateType is a type that specifies the type of rate being requested,
12
+ * such as 'standard', 'premium', 'discount', etc.
13
+ * @returns The `getRateByType` function is returning a Promise that resolves to a `RateByType` object
14
+ * fetched from the specified URL based on the `rateType` parameter. If an error occurs during the
15
+ * fetching process, the function will log an error message and rethrow the error.
16
+ */
17
+ export declare const getRateByType: (rateType: RateType) => Promise<RateByType>;
18
+ export {};
@@ -0,0 +1,19 @@
1
+ import { get } from '../../utils/api.js';
2
+ /**
3
+ * This function fetches a rate based on a specified rate type asynchronously.
4
+ * @param {RateType} rateType - RateType is a type that specifies the type of rate being requested,
5
+ * such as 'standard', 'premium', 'discount', etc.
6
+ * @returns The `getRateByType` function is returning a Promise that resolves to a `RateByType` object
7
+ * fetched from the specified URL based on the `rateType` parameter. If an error occurs during the
8
+ * fetching process, the function will log an error message and rethrow the error.
9
+ */
10
+ export const getRateByType = async (rateType) => {
11
+ const url = '/pub/rate';
12
+ try {
13
+ return await get(`${url}/${rateType}`);
14
+ }
15
+ catch (err) {
16
+ console.error('Error fetching Rate by Rate Type:', err);
17
+ throw err;
18
+ }
19
+ };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Fetches the transaction pool address from the public API endpoint.
3
+ * Returns the address as a string or throws an error if the request fails.
4
+ *
5
+ * Returns:
6
+ * The transaction pool address as a string.
7
+ *
8
+ * Raises:
9
+ * Throws an error if the request fails.
10
+ */
11
+ export declare const getTXPoolAddress: () => Promise<{
12
+ address: string;
13
+ }>;
@@ -0,0 +1,20 @@
1
+ import { get } from "../../utils/api.js";
2
+ /**
3
+ * Fetches the transaction pool address from the public API endpoint.
4
+ * Returns the address as a string or throws an error if the request fails.
5
+ *
6
+ * Returns:
7
+ * The transaction pool address as a string.
8
+ *
9
+ * Raises:
10
+ * Throws an error if the request fails.
11
+ */
12
+ export const getTXPoolAddress = async () => {
13
+ try {
14
+ return await get("/pub/txpool-address");
15
+ }
16
+ catch (err) {
17
+ console.error("Error fetching TX Pool Address:", err);
18
+ throw err;
19
+ }
20
+ };
@@ -0,0 +1,20 @@
1
+ type TokenValueType = {
2
+ amount: number;
3
+ usdcValue: number;
4
+ mint: string;
5
+ };
6
+ /**
7
+ * The function `getTokenValue` asynchronously fetches the value of a token based on the specified
8
+ * amount and token mint.
9
+ * @param {number} amount - The `amount` parameter is a number representing the quantity of tokens for
10
+ * which you want to retrieve the value.
11
+ * @param {string} mint_token - The `mint_token` parameter in the `getTokenValue` function represents
12
+ * the unique identifier for a specific token. It is used to specify which token you are interested in
13
+ * when fetching its value.
14
+ * @returns The `getTokenValue` function is returning the result of the `get` function call with the
15
+ * URL `/value?amount=&mint=` as its argument. The `get` function is likely
16
+ * making an HTTP request to fetch the token value based on the provided amount and mint token. If
17
+ * successful, the function will return the token value. If there is an error during
18
+ */
19
+ export declare const getTokenValue: (amount: number, mint_token: string) => Promise<TokenValueType>;
20
+ export {};
@@ -0,0 +1,24 @@
1
+ import { get } from '../../utils/api.js';
2
+ /**
3
+ * The function `getTokenValue` asynchronously fetches the value of a token based on the specified
4
+ * amount and token mint.
5
+ * @param {number} amount - The `amount` parameter is a number representing the quantity of tokens for
6
+ * which you want to retrieve the value.
7
+ * @param {string} mint_token - The `mint_token` parameter in the `getTokenValue` function represents
8
+ * the unique identifier for a specific token. It is used to specify which token you are interested in
9
+ * when fetching its value.
10
+ * @returns The `getTokenValue` function is returning the result of the `get` function call with the
11
+ * URL `/value?amount=&mint=` as its argument. The `get` function is likely
12
+ * making an HTTP request to fetch the token value based on the provided amount and mint token. If
13
+ * successful, the function will return the token value. If there is an error during
14
+ */
15
+ export const getTokenValue = async (amount, mint_token) => {
16
+ const url = '/pub/rate';
17
+ try {
18
+ return await get(`${url}/value?amount=${amount}&mint=${mint_token}`);
19
+ }
20
+ catch (err) {
21
+ console.log('Error fetching Token Value:', err);
22
+ throw err;
23
+ }
24
+ };
@@ -0,0 +1,26 @@
1
+ import { Currency, TransactionStatus, TransactionType } from '../../utils/enums.js';
2
+ export type TransactionResponse = {
3
+ id: string;
4
+ address: string;
5
+ mint: string;
6
+ currency: Currency;
7
+ amount: number;
8
+ usdcAmount: number;
9
+ fiatAmount: number;
10
+ sender: string;
11
+ receipiant: string;
12
+ rate: number;
13
+ status: TransactionStatus;
14
+ transactionType: TransactionType;
15
+ createdAt: string | Date;
16
+ };
17
+ /**
18
+ * The function `getTransaction` asynchronously fetches a transaction with a specified ID and handles
19
+ * any errors that may occur.
20
+ * @param {string} id - The `id` parameter in the `getTransaction` function is a string representing
21
+ * the unique identifier of the transaction that you want to retrieve.
22
+ * @returns The `getTransaction` function is returning the result of the `get` function called with the
23
+ * endpoint `/pub/transactions/`. This function is fetching transaction data based on the provided
24
+ * `id`.
25
+ */
26
+ export declare const getTransaction: (token: string, id: string) => Promise<TransactionResponse>;
@@ -0,0 +1,21 @@
1
+ import { get } from '../../utils/api.js';
2
+ /**
3
+ * The function `getTransaction` asynchronously fetches a transaction with a specified ID and handles
4
+ * any errors that may occur.
5
+ * @param {string} id - The `id` parameter in the `getTransaction` function is a string representing
6
+ * the unique identifier of the transaction that you want to retrieve.
7
+ * @returns The `getTransaction` function is returning the result of the `get` function called with the
8
+ * endpoint `/pub/transactions/`. This function is fetching transaction data based on the provided
9
+ * `id`.
10
+ */
11
+ export const getTransaction = async (token, id) => {
12
+ try {
13
+ return await get(`/pub/transactions/${id}`, {}, {
14
+ Authorization: `Bearer ${token}`,
15
+ });
16
+ }
17
+ catch (err) {
18
+ console.error('Error fetching Transaction:', err);
19
+ throw err;
20
+ }
21
+ };
@@ -0,0 +1,24 @@
1
+ export type WalletType = {
2
+ id: string;
3
+ publicKey: string;
4
+ bankAccount: {
5
+ id: string;
6
+ accountName: string;
7
+ accountNumber: string;
8
+ bank: string;
9
+ };
10
+ };
11
+ /**
12
+ * Fetches wallet details for a given public key from the public API endpoint.
13
+ * Returns the wallet information including bank account details or throws an error if the request fails.
14
+ *
15
+ * Args:
16
+ * publicKey: The public key of the wallet to fetch.
17
+ *
18
+ * Returns:
19
+ * An object containing wallet id, publicKey, and associated bank account details.
20
+ *
21
+ * Raises:
22
+ * Throws an error if the request fails.
23
+ */
24
+ export declare const getWallet: (publicKey: string) => Promise<WalletType>;