paj_ramp 1.2.2 → 1.2.4
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 +495 -421
- package/dist/lib/direct_off_ramp/directCreateOrder.d.ts +19 -0
- package/dist/lib/direct_off_ramp/directCreateOrder.js +23 -0
- package/dist/lib/off_ramp/addBankAccount.js +1 -1
- package/dist/lib/off_ramp/getBankAccounts.js +1 -1
- package/dist/lib/off_ramp/getBanks.d.ts +1 -1
- package/dist/lib/off_ramp/getBanks.js +6 -4
- package/dist/lib/off_ramp/getRate.d.ts +69 -10
- package/dist/lib/off_ramp/getRate.js +89 -7
- package/dist/lib/off_ramp/initiate.d.ts +1 -1
- package/dist/lib/off_ramp/initiate.js +2 -2
- package/dist/lib/off_ramp/resolveBankAccount.d.ts +1 -1
- package/dist/lib/off_ramp/resolveBankAccount.js +6 -4
- package/dist/lib/off_ramp/verify.d.ts +15 -6
- package/dist/lib/off_ramp/verify.js +6 -2
- package/dist/lib/on_ramp/createOrder.d.ts +1 -0
- package/dist/lib/on_ramp/createOrder.js +2 -1
- package/dist/sdk.d.ts +6 -9
- package/dist/sdk.js +16 -14
- package/jest.config.js +8 -8
- package/lib/direct_off_ramp/directCreateOrder.ts +60 -0
- package/lib/off_ramp/addBankAccount.ts +1 -1
- package/lib/off_ramp/getBankAccounts.ts +1 -1
- package/lib/off_ramp/getBanks.ts +10 -4
- package/lib/off_ramp/getRate.ts +119 -11
- package/lib/off_ramp/initiate.ts +2 -2
- package/lib/off_ramp/resolveBankAccount.ts +8 -3
- package/lib/off_ramp/verify.ts +25 -9
- package/lib/on_ramp/createOrder.ts +3 -1
- package/package.json +42 -42
- package/sdk.ts +18 -15
- package/test-protocol.js +41 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare enum Currency {
|
|
2
|
+
NGN = "NGN"
|
|
3
|
+
}
|
|
4
|
+
type offRampCreateOrderResponse = {
|
|
5
|
+
amount: number;
|
|
6
|
+
expectedAmount: number;
|
|
7
|
+
mint: string;
|
|
8
|
+
decimals: number;
|
|
9
|
+
address: string;
|
|
10
|
+
walletId: string;
|
|
11
|
+
creatorId: string;
|
|
12
|
+
bankId: string;
|
|
13
|
+
accountNumber: string;
|
|
14
|
+
currency: Currency;
|
|
15
|
+
status: string;
|
|
16
|
+
webhookURL: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const offRampCreateOrder: (token: string, bank: string, accountNumber: string, currency: Currency, amount: number, mint: string, webhookURL: string) => Promise<offRampCreateOrderResponse>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { post } from '../../utils/api.js';
|
|
2
|
+
var Currency;
|
|
3
|
+
(function (Currency) {
|
|
4
|
+
Currency["NGN"] = "NGN";
|
|
5
|
+
})(Currency || (Currency = {}));
|
|
6
|
+
export const offRampCreateOrder = async (token, bank, accountNumber, currency, amount, mint, webhookURL) => {
|
|
7
|
+
try {
|
|
8
|
+
return await post('/pub/offramp', {
|
|
9
|
+
bank,
|
|
10
|
+
accountNumber,
|
|
11
|
+
currency,
|
|
12
|
+
amount,
|
|
13
|
+
mint,
|
|
14
|
+
webhookURL,
|
|
15
|
+
}, {
|
|
16
|
+
Authorization: `Bearer ${token}`,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
console.error('Error Creating Order', err);
|
|
21
|
+
throw err;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { get } from
|
|
1
|
+
import { get } from '../../utils/api.js';
|
|
2
2
|
/**
|
|
3
3
|
* Fetches a list of banks from the public API endpoint.
|
|
4
4
|
* Returns an array of bank objects or throws an error if the request fails.
|
|
@@ -9,12 +9,14 @@ import { get } from "../../utils/api.js";
|
|
|
9
9
|
* Raises:
|
|
10
10
|
* Throws an error if the request fails.
|
|
11
11
|
*/
|
|
12
|
-
export const getBanks = async () => {
|
|
12
|
+
export const getBanks = async (token) => {
|
|
13
13
|
try {
|
|
14
|
-
return await get(`/pub/bank
|
|
14
|
+
return await get(`/pub/bank`, {}, {
|
|
15
|
+
Authorization: `Bearer ${token}`,
|
|
16
|
+
});
|
|
15
17
|
}
|
|
16
18
|
catch (err) {
|
|
17
|
-
console.error(
|
|
19
|
+
console.error('Error fetching Banks:', err);
|
|
18
20
|
throw err;
|
|
19
21
|
}
|
|
20
22
|
};
|
|
@@ -1,7 +1,25 @@
|
|
|
1
|
-
type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
type AllRateResponseType = {
|
|
2
|
+
onRampRate: {
|
|
3
|
+
baseCurrency: "USD";
|
|
4
|
+
targetCurrency: "NGN";
|
|
5
|
+
isActive: true;
|
|
6
|
+
rate: 1510;
|
|
7
|
+
type: "onRamp";
|
|
8
|
+
};
|
|
9
|
+
offRampRate: {
|
|
10
|
+
baseCurrency: "USD";
|
|
11
|
+
targetCurrency: "NGN";
|
|
12
|
+
isActive: true;
|
|
13
|
+
rate: 1525;
|
|
14
|
+
type: "offRamp";
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
type RateByAmountType = {
|
|
18
|
+
rate: {
|
|
19
|
+
baseCurrency: string;
|
|
20
|
+
targetCurrency: string;
|
|
21
|
+
rate: number;
|
|
22
|
+
};
|
|
5
23
|
amounts: {
|
|
6
24
|
userTax: number;
|
|
7
25
|
merchantTax: number;
|
|
@@ -9,18 +27,59 @@ type RateType = {
|
|
|
9
27
|
userAmountFiat: number;
|
|
10
28
|
};
|
|
11
29
|
};
|
|
30
|
+
type RateByRateTypeType = {
|
|
31
|
+
baseCurrency: "USD";
|
|
32
|
+
targetCurrency: "NGN";
|
|
33
|
+
isActive: true;
|
|
34
|
+
rate: 1525;
|
|
35
|
+
type: "offRamp";
|
|
36
|
+
};
|
|
37
|
+
export declare enum RateType {
|
|
38
|
+
onRamp = "onRamp",
|
|
39
|
+
offRamp = "offRamp"
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Fetches rate information based on the provided parameter, which can be a number or a rate type.
|
|
43
|
+
* This function returns all rates, rates by amount, or rates by type depending on the input.
|
|
44
|
+
*
|
|
45
|
+
* Args:
|
|
46
|
+
* param: A number representing the amount or a RateType enum value.
|
|
47
|
+
*
|
|
48
|
+
* Returns:
|
|
49
|
+
* A promise resolving to the rate information relevant to the input parameter.
|
|
50
|
+
*
|
|
51
|
+
* Raises:
|
|
52
|
+
* Throws an error if the rate information cannot be fetched.
|
|
53
|
+
*/
|
|
54
|
+
export declare const getRate: (param: number | RateType) => Promise<AllRateResponseType | RateByAmountType | RateByRateTypeType>;
|
|
55
|
+
/**
|
|
56
|
+
* Retrieves rate information based on a specific amount for on-ramp or off-ramp transactions.
|
|
57
|
+
* This function returns a promise that resolves to the rate and associated amounts for the given value.
|
|
58
|
+
*
|
|
59
|
+
* Args:
|
|
60
|
+
* url: The endpoint URL to fetch rate information from.
|
|
61
|
+
* amount: The amount for which the rate information is requested.
|
|
62
|
+
*
|
|
63
|
+
* Returns:
|
|
64
|
+
* A promise resolving to the rate and amount details for the specified value.
|
|
65
|
+
*
|
|
66
|
+
* Raises:
|
|
67
|
+
* Throws an error if the rate information cannot be fetched.
|
|
68
|
+
*/
|
|
69
|
+
export declare const getRateByAmount: (url: string, amount: number) => Promise<RateByAmountType>;
|
|
12
70
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
71
|
+
* Retrieves rate information based on a specific rate type for on-ramp or off-ramp transactions.
|
|
72
|
+
* This function returns a promise that resolves to the rate details for the given rate type.
|
|
15
73
|
*
|
|
16
74
|
* Args:
|
|
17
|
-
*
|
|
75
|
+
* url: The endpoint URL to fetch rate information from.
|
|
76
|
+
* rateType: The type of rate to retrieve, specified as a RateType enum value.
|
|
18
77
|
*
|
|
19
78
|
* Returns:
|
|
20
|
-
*
|
|
79
|
+
* A promise resolving to the rate details for the specified rate type.
|
|
21
80
|
*
|
|
22
81
|
* Raises:
|
|
23
|
-
* Throws an error if the
|
|
82
|
+
* Throws an error if the rate information cannot be fetched.
|
|
24
83
|
*/
|
|
25
|
-
export declare const
|
|
84
|
+
export declare const getRateByRateType: (url: string, rateType: RateType) => Promise<RateByRateTypeType>;
|
|
26
85
|
export {};
|
|
@@ -1,23 +1,105 @@
|
|
|
1
1
|
import { get } from "../../utils/api.js";
|
|
2
|
+
export var RateType;
|
|
3
|
+
(function (RateType) {
|
|
4
|
+
RateType["onRamp"] = "onRamp";
|
|
5
|
+
RateType["offRamp"] = "offRamp";
|
|
6
|
+
})(RateType || (RateType = {}));
|
|
2
7
|
/**
|
|
3
|
-
* Fetches the
|
|
4
|
-
*
|
|
8
|
+
* Fetches rate information based on the provided parameter, which can be a number or a rate type.
|
|
9
|
+
* This function returns all rates, rates by amount, or rates by type depending on the input.
|
|
5
10
|
*
|
|
6
11
|
* Args:
|
|
7
|
-
*
|
|
12
|
+
* param: A number representing the amount or a RateType enum value.
|
|
8
13
|
*
|
|
9
14
|
* Returns:
|
|
10
|
-
*
|
|
15
|
+
* A promise resolving to the rate information relevant to the input parameter.
|
|
11
16
|
*
|
|
12
17
|
* Raises:
|
|
13
|
-
* Throws an error if the
|
|
18
|
+
* Throws an error if the rate information cannot be fetched.
|
|
14
19
|
*/
|
|
15
|
-
export const getRate = async (
|
|
20
|
+
export const getRate = async (param) => {
|
|
16
21
|
try {
|
|
17
|
-
|
|
22
|
+
const url = "/pub/rate";
|
|
23
|
+
if (!param) {
|
|
24
|
+
return getAllRate(url);
|
|
25
|
+
}
|
|
26
|
+
else if (typeof param === "number") {
|
|
27
|
+
return getRateByAmount(url, param);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return getRateByRateType(url, param);
|
|
31
|
+
}
|
|
18
32
|
}
|
|
19
33
|
catch (err) {
|
|
20
34
|
console.error("Error fetching Rate:", err);
|
|
21
35
|
throw err;
|
|
22
36
|
}
|
|
23
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* Retrieves all available rate information for on-ramp and off-ramp transactions.
|
|
40
|
+
* This function returns a promise that resolves to the complete set of rate data.
|
|
41
|
+
*
|
|
42
|
+
* Args:
|
|
43
|
+
* url: The endpoint URL to fetch rate information from.
|
|
44
|
+
*
|
|
45
|
+
* Returns:
|
|
46
|
+
* A promise resolving to the full rate response data.
|
|
47
|
+
*
|
|
48
|
+
* Raises:
|
|
49
|
+
* Throws an error if the rate information cannot be fetched.
|
|
50
|
+
*/
|
|
51
|
+
const getAllRate = async (url) => {
|
|
52
|
+
try {
|
|
53
|
+
return await get(url);
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
console.error("Error fetching Rate:", err);
|
|
57
|
+
throw err;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Retrieves rate information based on a specific amount for on-ramp or off-ramp transactions.
|
|
62
|
+
* This function returns a promise that resolves to the rate and associated amounts for the given value.
|
|
63
|
+
*
|
|
64
|
+
* Args:
|
|
65
|
+
* url: The endpoint URL to fetch rate information from.
|
|
66
|
+
* amount: The amount for which the rate information is requested.
|
|
67
|
+
*
|
|
68
|
+
* Returns:
|
|
69
|
+
* A promise resolving to the rate and amount details for the specified value.
|
|
70
|
+
*
|
|
71
|
+
* Raises:
|
|
72
|
+
* Throws an error if the rate information cannot be fetched.
|
|
73
|
+
*/
|
|
74
|
+
export const getRateByAmount = async (url, amount) => {
|
|
75
|
+
try {
|
|
76
|
+
return await get(`/pub/rate/${amount}`);
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
console.error("Error fetching Rate by Amount:", err);
|
|
80
|
+
throw err;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Retrieves rate information based on a specific rate type for on-ramp or off-ramp transactions.
|
|
85
|
+
* This function returns a promise that resolves to the rate details for the given rate type.
|
|
86
|
+
*
|
|
87
|
+
* Args:
|
|
88
|
+
* url: The endpoint URL to fetch rate information from.
|
|
89
|
+
* rateType: The type of rate to retrieve, specified as a RateType enum value.
|
|
90
|
+
*
|
|
91
|
+
* Returns:
|
|
92
|
+
* A promise resolving to the rate details for the specified rate type.
|
|
93
|
+
*
|
|
94
|
+
* Raises:
|
|
95
|
+
* Throws an error if the rate information cannot be fetched.
|
|
96
|
+
*/
|
|
97
|
+
export const getRateByRateType = async (url, rateType) => {
|
|
98
|
+
try {
|
|
99
|
+
return await get(`/pub/rate/${rateType}`);
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
console.error("Error fetching Rate by Rate Type:", err);
|
|
103
|
+
throw err;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
@@ -14,5 +14,5 @@ type InitiateResponse = {
|
|
|
14
14
|
* Raises:
|
|
15
15
|
* Throws an error if the request fails.
|
|
16
16
|
*/
|
|
17
|
-
export declare const initiate: (email: string) => Promise<InitiateResponse>;
|
|
17
|
+
export declare const initiate: (email: string, apiKey: string) => Promise<InitiateResponse>;
|
|
18
18
|
export {};
|
|
@@ -12,9 +12,9 @@ import { post } from "../../utils/api.js";
|
|
|
12
12
|
* Raises:
|
|
13
13
|
* Throws an error if the request fails.
|
|
14
14
|
*/
|
|
15
|
-
export const initiate = async (email) => {
|
|
15
|
+
export const initiate = async (email, apiKey) => {
|
|
16
16
|
try {
|
|
17
|
-
return await post("/pub/initiate", { email }, { "x-api-key": "
|
|
17
|
+
return await post("/pub/initiate", { email }, { "x-api-key": apiKey, "Content-Type": "application/json" });
|
|
18
18
|
}
|
|
19
19
|
catch (err) {
|
|
20
20
|
console.error("Error initiating:", err);
|
|
@@ -22,5 +22,5 @@ type ResolveBankAccountType = {
|
|
|
22
22
|
* Raises:
|
|
23
23
|
* Throws an error if the request fails.
|
|
24
24
|
*/
|
|
25
|
-
export declare const resolveBankAccount: (bankId: string, accountNumber: string) => Promise<ResolveBankAccountType>;
|
|
25
|
+
export declare const resolveBankAccount: (token: string, bankId: string, accountNumber: string) => Promise<ResolveBankAccountType>;
|
|
26
26
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { get } from
|
|
1
|
+
import { get } from '../../utils/api.js';
|
|
2
2
|
/**
|
|
3
3
|
* Resolves and fetches bank account details for a given bank ID and account number from the public API.
|
|
4
4
|
* Returns the account name, account number, and bank details or throws an error if the request fails.
|
|
@@ -13,12 +13,14 @@ import { get } from "../../utils/api.js";
|
|
|
13
13
|
* Raises:
|
|
14
14
|
* Throws an error if the request fails.
|
|
15
15
|
*/
|
|
16
|
-
export const resolveBankAccount = async (bankId, accountNumber) => {
|
|
16
|
+
export const resolveBankAccount = async (token, bankId, accountNumber) => {
|
|
17
17
|
try {
|
|
18
|
-
return await get(`/pub/
|
|
18
|
+
return await get(`/pub/bank-account/confirm/?bankId=${bankId}&accountNumber=${accountNumber}`, {}, {
|
|
19
|
+
Authorization: `Bearer ${token}`,
|
|
20
|
+
});
|
|
19
21
|
}
|
|
20
22
|
catch (err) {
|
|
21
|
-
console.error(
|
|
23
|
+
console.error('Error resolving bank account:', err);
|
|
22
24
|
throw err;
|
|
23
25
|
}
|
|
24
26
|
};
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
type VerifyType = {
|
|
2
|
+
email: string;
|
|
3
|
+
isActive: string;
|
|
4
|
+
expiresAt: string;
|
|
5
|
+
token: string;
|
|
6
|
+
};
|
|
7
|
+
type deviceSignatureType = {
|
|
8
|
+
uuid: string;
|
|
9
|
+
device: string;
|
|
10
|
+
os?: string;
|
|
11
|
+
browser?: string;
|
|
12
|
+
ip?: string;
|
|
13
|
+
};
|
|
1
14
|
/**
|
|
2
15
|
* Verifies a user's identity using email, OTP, and device signature via the public API.
|
|
3
16
|
* Returns verification details including email, activation status, expiration, and token, or throws an error if the request fails.
|
|
@@ -13,9 +26,5 @@
|
|
|
13
26
|
* Raises:
|
|
14
27
|
* Throws an error if the request fails.
|
|
15
28
|
*/
|
|
16
|
-
export declare const verify: (email: string, otp: string, deviceSignature: string) => Promise<
|
|
17
|
-
|
|
18
|
-
isActive: string;
|
|
19
|
-
expiresAt: string;
|
|
20
|
-
token: string;
|
|
21
|
-
}>;
|
|
29
|
+
export declare const verify: (email: string, otp: string, deviceSignature: deviceSignatureType, apiKey: string) => Promise<VerifyType>;
|
|
30
|
+
export {};
|
|
@@ -14,9 +14,13 @@ import { post } from "../../utils/api.js";
|
|
|
14
14
|
* Raises:
|
|
15
15
|
* Throws an error if the request fails.
|
|
16
16
|
*/
|
|
17
|
-
export const verify = async (email, otp, deviceSignature) => {
|
|
17
|
+
export const verify = async (email, otp, deviceSignature, apiKey) => {
|
|
18
18
|
try {
|
|
19
|
-
return await post("/pub/verify", {
|
|
19
|
+
return await post("/pub/verify", {
|
|
20
|
+
email,
|
|
21
|
+
otp,
|
|
22
|
+
device: deviceSignature,
|
|
23
|
+
}, { "x-api-key": apiKey });
|
|
20
24
|
}
|
|
21
25
|
catch (err) {
|
|
22
26
|
console.error("Error verifying:", err);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { post } from "../../utils/api.js";
|
|
2
2
|
export const createOrder = async (options) => {
|
|
3
|
-
const { fiatAmount, currency, recipient, mint, chain, token } = options;
|
|
3
|
+
const { fiatAmount, currency, recipient, mint, chain, webhookURL, token } = options;
|
|
4
4
|
try {
|
|
5
5
|
return await post("/pub/onramp", {
|
|
6
6
|
fiatAmount,
|
|
@@ -8,6 +8,7 @@ export const createOrder = async (options) => {
|
|
|
8
8
|
recipient,
|
|
9
9
|
mint,
|
|
10
10
|
chain,
|
|
11
|
+
webhookURL
|
|
11
12
|
}, {
|
|
12
13
|
Authorization: `Bearer ${token}`,
|
|
13
14
|
});
|
package/dist/sdk.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
export declare const initializeSDK: (env: "staging" | "production") => void;
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export { verify } from "./lib/off_ramp/verify.js";
|
|
2
|
+
export { getRate, RateType } from './lib/off_ramp/getRate.js';
|
|
3
|
+
export { initiate } from './lib/off_ramp/initiate.js';
|
|
4
|
+
export { verify } from './lib/off_ramp/verify.js';
|
|
6
5
|
export { getBanks } from "./lib/off_ramp/getBanks.js";
|
|
7
6
|
export { resolveBankAccount } from "./lib/off_ramp/resolveBankAccount.js";
|
|
8
7
|
export { addBankAccount } from "./lib/off_ramp/addBankAccount.js";
|
|
9
8
|
export { getBankAccounts } from "./lib/off_ramp/getBankAccounts.js";
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export { createOrder } from "./lib/on_ramp/createOrder.js";
|
|
14
|
-
export { observeOrder } from "./lib/on_ramp/observeOrder.js";
|
|
9
|
+
export { offRampCreateOrder } from './lib/direct_off_ramp/directCreateOrder.js';
|
|
10
|
+
export { createOrder } from './lib/on_ramp/createOrder.js';
|
|
11
|
+
export { observeOrder } from './lib/on_ramp/observeOrder.js';
|
package/dist/sdk.js
CHANGED
|
@@ -1,32 +1,34 @@
|
|
|
1
1
|
// A JavaScript SDK for interacting with our offramp and onramp service.
|
|
2
2
|
// Switch Environment: "staging" | "production"
|
|
3
|
-
import { setBaseUrl } from
|
|
3
|
+
import { setBaseUrl } from './utils/axios.js';
|
|
4
4
|
export const initializeSDK = (env) => {
|
|
5
|
-
if (env ===
|
|
6
|
-
setBaseUrl(
|
|
5
|
+
if (env === 'staging') {
|
|
6
|
+
setBaseUrl('https://api-staging.paj.cash');
|
|
7
7
|
}
|
|
8
8
|
else {
|
|
9
|
-
setBaseUrl(
|
|
9
|
+
setBaseUrl('https://api.paj.cash');
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
12
|
// OFF RAMP
|
|
13
13
|
// Wallet Info
|
|
14
|
-
export { getTXPoolAddress } from "./lib/off_ramp/getTXPoolAddress.js";
|
|
15
|
-
export { getRate } from
|
|
14
|
+
// export { getTXPoolAddress } from "./lib/off_ramp/getTXPoolAddress.js";
|
|
15
|
+
export { getRate, RateType } from './lib/off_ramp/getRate.js';
|
|
16
16
|
// Session Management
|
|
17
|
-
export { initiate } from
|
|
18
|
-
export { verify } from
|
|
19
|
-
// Banking Operations
|
|
17
|
+
export { initiate } from './lib/off_ramp/initiate.js';
|
|
18
|
+
export { verify } from './lib/off_ramp/verify.js';
|
|
19
|
+
// // Banking Operations
|
|
20
20
|
export { getBanks } from "./lib/off_ramp/getBanks.js";
|
|
21
21
|
export { resolveBankAccount } from "./lib/off_ramp/resolveBankAccount.js";
|
|
22
22
|
export { addBankAccount } from "./lib/off_ramp/addBankAccount.js";
|
|
23
23
|
export { getBankAccounts } from "./lib/off_ramp/getBankAccounts.js";
|
|
24
24
|
// Wallet Operations
|
|
25
|
-
export { getWallet } from
|
|
26
|
-
export { addWallet } from
|
|
27
|
-
export { switchWalletBankAccount } from
|
|
25
|
+
// export { getWallet } from './lib/off_ramp/getWallet.js';
|
|
26
|
+
// export { addWallet } from './lib/off_ramp/addWallet.js';
|
|
27
|
+
// export { switchWalletBankAccount } from './lib/off_ramp/switchWalletBankAccount.js';
|
|
28
|
+
// DIRECT OFF RAMP
|
|
29
|
+
export { offRampCreateOrder } from './lib/direct_off_ramp/directCreateOrder.js';
|
|
28
30
|
// ON RAMP
|
|
29
31
|
// Create Order
|
|
30
|
-
export { createOrder } from
|
|
32
|
+
export { createOrder } from './lib/on_ramp/createOrder.js';
|
|
31
33
|
// Observe Order Socket.IO
|
|
32
|
-
export { observeOrder } from
|
|
34
|
+
export { observeOrder } from './lib/on_ramp/observeOrder.js';
|
package/jest.config.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
preset: 'ts-jest',
|
|
3
|
-
testEnvironment: 'node',
|
|
4
|
-
transform: {
|
|
5
|
-
'^.+\\.tsx?$': 'ts-jest',
|
|
6
|
-
},
|
|
7
|
-
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
|
|
8
|
-
};
|
|
1
|
+
export default {
|
|
2
|
+
preset: 'ts-jest',
|
|
3
|
+
testEnvironment: 'node',
|
|
4
|
+
transform: {
|
|
5
|
+
'^.+\\.tsx?$': 'ts-jest',
|
|
6
|
+
},
|
|
7
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
|
|
8
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { post } from '../../utils/api.js';
|
|
2
|
+
|
|
3
|
+
enum Currency {
|
|
4
|
+
NGN = 'NGN',
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// type offRampCreateOrderType = {
|
|
8
|
+
// token?: string;
|
|
9
|
+
// bank: string;
|
|
10
|
+
// accountNumber: string;
|
|
11
|
+
// currency: Currency;
|
|
12
|
+
// amount: number;
|
|
13
|
+
// mint: string;
|
|
14
|
+
// webhookURL: string;
|
|
15
|
+
// };
|
|
16
|
+
|
|
17
|
+
type offRampCreateOrderResponse = {
|
|
18
|
+
amount: number;
|
|
19
|
+
expectedAmount: number;
|
|
20
|
+
mint: string;
|
|
21
|
+
decimals: number;
|
|
22
|
+
address: string;
|
|
23
|
+
walletId: string;
|
|
24
|
+
creatorId: string;
|
|
25
|
+
bankId: string;
|
|
26
|
+
accountNumber: string;
|
|
27
|
+
currency: Currency;
|
|
28
|
+
status: string;
|
|
29
|
+
webhookURL: string;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const offRampCreateOrder = async (
|
|
33
|
+
token: string,
|
|
34
|
+
bank: string,
|
|
35
|
+
accountNumber: string,
|
|
36
|
+
currency: Currency,
|
|
37
|
+
amount: number,
|
|
38
|
+
mint: string,
|
|
39
|
+
webhookURL: string
|
|
40
|
+
) => {
|
|
41
|
+
try {
|
|
42
|
+
return await post<offRampCreateOrderResponse>(
|
|
43
|
+
'/pub/offramp',
|
|
44
|
+
{
|
|
45
|
+
bank,
|
|
46
|
+
accountNumber,
|
|
47
|
+
currency,
|
|
48
|
+
amount,
|
|
49
|
+
mint,
|
|
50
|
+
webhookURL,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
Authorization: `Bearer ${token}`,
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
} catch (err) {
|
|
57
|
+
console.error('Error Creating Order', err);
|
|
58
|
+
throw err;
|
|
59
|
+
}
|
|
60
|
+
};
|
package/lib/off_ramp/getBanks.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { get } from
|
|
1
|
+
import { get } from '../../utils/api.js';
|
|
2
2
|
|
|
3
3
|
type BankType = {
|
|
4
4
|
id: string;
|
|
@@ -15,11 +15,17 @@ type BankType = {
|
|
|
15
15
|
* Raises:
|
|
16
16
|
* Throws an error if the request fails.
|
|
17
17
|
*/
|
|
18
|
-
export const getBanks = async () => {
|
|
18
|
+
export const getBanks = async (token: string) => {
|
|
19
19
|
try {
|
|
20
|
-
return await get<BankType[]>(
|
|
20
|
+
return await get<BankType[]>(
|
|
21
|
+
`/pub/bank`,
|
|
22
|
+
{},
|
|
23
|
+
{
|
|
24
|
+
Authorization: `Bearer ${token}`,
|
|
25
|
+
}
|
|
26
|
+
);
|
|
21
27
|
} catch (err) {
|
|
22
|
-
console.error(
|
|
28
|
+
console.error('Error fetching Banks:', err);
|
|
23
29
|
throw err;
|
|
24
30
|
}
|
|
25
31
|
};
|