paytonz-node-api-sdk 1.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.
Files changed (97) hide show
  1. package/README.md +743 -0
  2. package/lib/CpaySDK.d.ts +30 -0
  3. package/lib/CpaySDK.js +35 -0
  4. package/lib/CpaySDKBase.d.ts +30 -0
  5. package/lib/CpaySDKBase.js +216 -0
  6. package/lib/CryptoNowSDK.d.ts +30 -0
  7. package/lib/CryptoNowSDK.js +35 -0
  8. package/lib/CryptoNowSDKBase.d.ts +30 -0
  9. package/lib/CryptoNowSDKBase.js +216 -0
  10. package/lib/PaytonzSDK.d.ts +28 -0
  11. package/lib/PaytonzSDK.js +33 -0
  12. package/lib/PaytonzSDKBase.d.ts +30 -0
  13. package/lib/PaytonzSDKBase.js +198 -0
  14. package/lib/auth/auth.d.ts +9 -0
  15. package/lib/auth/auth.interface.d.ts +25 -0
  16. package/lib/auth/auth.interface.js +2 -0
  17. package/lib/auth/auth.js +37 -0
  18. package/lib/checkout/checkout.d.ts +24 -0
  19. package/lib/checkout/checkout.interface.d.ts +94 -0
  20. package/lib/checkout/checkout.interface.js +2 -0
  21. package/lib/checkout/checkout.js +215 -0
  22. package/lib/client/client.d.ts +11 -0
  23. package/lib/client/client.interface.d.ts +45 -0
  24. package/lib/client/client.interface.js +2 -0
  25. package/lib/client/client.js +62 -0
  26. package/lib/constant.d.ts +1 -0
  27. package/lib/constant.js +4 -0
  28. package/lib/currency/currency.d.ts +10 -0
  29. package/lib/currency/currency.interface.d.ts +20 -0
  30. package/lib/currency/currency.interface.js +2 -0
  31. package/lib/currency/currency.js +50 -0
  32. package/lib/external/external.d.ts +13 -0
  33. package/lib/external/external.interface.d.ts +59 -0
  34. package/lib/external/external.interface.js +12 -0
  35. package/lib/external/external.js +64 -0
  36. package/lib/external/external.solana.d.ts +9 -0
  37. package/lib/external/external.solana.js +47 -0
  38. package/lib/index.d.ts +5 -0
  39. package/lib/index.js +28 -0
  40. package/lib/interfaces/cpay.interface.d.ts +20 -0
  41. package/lib/interfaces/cpay.interface.js +2 -0
  42. package/lib/interfaces/cryptonow.interface.d.ts +20 -0
  43. package/lib/interfaces/cryptonow.interface.js +2 -0
  44. package/lib/interfaces/paytonz.interface.d.ts +20 -0
  45. package/lib/interfaces/paytonz.interface.js +2 -0
  46. package/lib/multisend/multisend.d.ts +11 -0
  47. package/lib/multisend/multisend.interface.d.ts +28 -0
  48. package/lib/multisend/multisend.interface.js +2 -0
  49. package/lib/multisend/multisend.js +75 -0
  50. package/lib/swap/swap.d.ts +11 -0
  51. package/lib/swap/swap.interface.d.ts +84 -0
  52. package/lib/swap/swap.interface.js +2 -0
  53. package/lib/swap/swap.js +75 -0
  54. package/lib/transaction/transaction.d.ts +9 -0
  55. package/lib/transaction/transaction.interface.d.ts +82 -0
  56. package/lib/transaction/transaction.interface.js +2 -0
  57. package/lib/transaction/transaction.js +34 -0
  58. package/lib/utils/httpClient.d.ts +9 -0
  59. package/lib/utils/httpClient.js +64 -0
  60. package/lib/wallet/wallet.d.ts +16 -0
  61. package/lib/wallet/wallet.interface.d.ts +60 -0
  62. package/lib/wallet/wallet.interface.js +2 -0
  63. package/lib/wallet/wallet.js +107 -0
  64. package/lib/wallet/wallet.signature.d.ts +14 -0
  65. package/lib/wallet/wallet.signature.js +104 -0
  66. package/lib/withdrawal/withdrawal.d.ts +14 -0
  67. package/lib/withdrawal/withdrawal.interface.d.ts +79 -0
  68. package/lib/withdrawal/withdrawal.interface.js +14 -0
  69. package/lib/withdrawal/withdrawal.js +104 -0
  70. package/package.json +26 -0
  71. package/src/PaytonzSDK.ts +41 -0
  72. package/src/PaytonzSDKBase.ts +252 -0
  73. package/src/auth/auth.interface.ts +26 -0
  74. package/src/auth/auth.ts +31 -0
  75. package/src/checkout/checkout.interface.ts +110 -0
  76. package/src/checkout/checkout.ts +279 -0
  77. package/src/constant.ts +1 -0
  78. package/src/currency/currency.interface.ts +21 -0
  79. package/src/currency/currency.ts +60 -0
  80. package/src/external/external.interface.ts +65 -0
  81. package/src/external/external.solana.ts +54 -0
  82. package/src/external/external.ts +73 -0
  83. package/src/index.ts +5 -0
  84. package/src/interfaces/paytonz.interface.ts +23 -0
  85. package/src/multisend/multisend.interface.ts +32 -0
  86. package/src/multisend/multisend.ts +91 -0
  87. package/src/swap/swap.interface.ts +90 -0
  88. package/src/swap/swap.ts +93 -0
  89. package/src/transaction/transaction.interface.ts +76 -0
  90. package/src/transaction/transaction.ts +35 -0
  91. package/src/utils/httpClient.ts +60 -0
  92. package/src/wallet/wallet.interface.ts +67 -0
  93. package/src/wallet/wallet.signature.ts +106 -0
  94. package/src/wallet/wallet.ts +103 -0
  95. package/src/withdrawal/withdrawal.interface.ts +89 -0
  96. package/src/withdrawal/withdrawal.ts +135 -0
  97. package/tsconfig.json +21 -0
@@ -0,0 +1,110 @@
1
+ export interface CheckoutInfo {
2
+ _id: string;
3
+ identifier: string;
4
+ currencies: string[];
5
+ createdAt: string;
6
+ updatedAt: string;
7
+ organizationName?: string;
8
+ type: string;
9
+ merchant: string;
10
+ expireTime: number;
11
+ description: string;
12
+ collectName: boolean;
13
+ collectEmail: boolean;
14
+ fiatCurrency?: string;
15
+ price?: string;
16
+ productName?: string;
17
+ fixed?: boolean;
18
+ max?: string;
19
+ min?: string;
20
+ tradedCurrency?: string;
21
+ tradedWallet?: string;
22
+ accentColor?: string;
23
+ backgroundColor?: string;
24
+ logoImage?: string;
25
+ image?: string;
26
+ metadata?: Record<string, any>;
27
+ }
28
+ export interface CheckoutListInfo {
29
+ entities: CheckoutInfo[];
30
+ page: number;
31
+ pages: number;
32
+ countItem: number;
33
+ }
34
+
35
+ export interface CheckoutChargeListInfo {
36
+ entities: {
37
+ id: boolean;
38
+ systemStatus: string;
39
+ createdAt: string;
40
+ }[];
41
+ page: number;
42
+ pages: number;
43
+ countItem: number;
44
+ }
45
+
46
+ export interface CreateCheckoutBaseOptions {
47
+ expireTime: number;
48
+ currencies: string[];
49
+ collectName?: boolean;
50
+ collectEmail?: boolean;
51
+ description: string;
52
+ linkImage?: string;
53
+ linkLogoImage?: string;
54
+ metadata?: Record<string, any>;
55
+ accentColor?: string;
56
+ backgroundColor?: string;
57
+ }
58
+
59
+ export interface UpdateCheckoutBaseOptions {
60
+ deleteImage?: boolean;
61
+ deleteLogoImage?: boolean;
62
+ }
63
+
64
+ export interface CreateDonationOptions extends CreateCheckoutBaseOptions {
65
+ organizationName: string;
66
+ }
67
+
68
+ export interface UpdateDonationOptions
69
+ extends CreateDonationOptions,
70
+ UpdateCheckoutBaseOptions {}
71
+
72
+ export interface CreateSaleOptions extends CreateCheckoutBaseOptions {
73
+ productName: string;
74
+ price: string;
75
+ fiatCurrency: string;
76
+ }
77
+
78
+ export interface UpdateSaleOptions
79
+ extends CreateSaleOptions,
80
+ UpdateCheckoutBaseOptions {}
81
+
82
+ export interface CreateCartOptions extends CreateCheckoutBaseOptions {
83
+ cartName: string;
84
+ fiatCurrency: string;
85
+ }
86
+
87
+ export interface UpdateCartOptions
88
+ extends CreateCartOptions,
89
+ UpdateCheckoutBaseOptions {}
90
+
91
+ export interface CreateSaleTokenOptions extends CreateCheckoutBaseOptions {
92
+ productName: string;
93
+ price?: string;
94
+ min: string;
95
+ max: string;
96
+ fiatCurrency?: string;
97
+ fixed: string;
98
+ tradedCurrency: string;
99
+ tradedWallet: string;
100
+ }
101
+
102
+ export interface UpdateSaleTokenOptions
103
+ extends CreateSaleTokenOptions,
104
+ UpdateCheckoutBaseOptions {}
105
+
106
+ export interface SaleTokenEstimateMaxOptions {
107
+ tradedWallet: string;
108
+ tradedCurrency: string;
109
+ checkoutId?: string;
110
+ }
@@ -0,0 +1,279 @@
1
+ import { PaytonzSDKBase, PaytonzSDKBaseOptions } from "../PaytonzSDKBase";
2
+ import { BasePaginationOptions } from "../interfaces/paytonz.interface";
3
+ import {
4
+ CheckoutChargeListInfo,
5
+ CheckoutInfo,
6
+ CheckoutListInfo,
7
+ CreateCartOptions,
8
+ CreateDonationOptions,
9
+ CreateSaleOptions,
10
+ CreateSaleTokenOptions,
11
+ SaleTokenEstimateMaxOptions,
12
+ UpdateCartOptions,
13
+ UpdateDonationOptions,
14
+ UpdateSaleOptions,
15
+ UpdateSaleTokenOptions,
16
+ } from "./checkout.interface";
17
+
18
+ export interface PaytonzSDKOptions extends PaytonzSDKBaseOptions {}
19
+
20
+ export class Checkout extends PaytonzSDKBase {
21
+ constructor(parameters: PaytonzSDKOptions) {
22
+ super(parameters);
23
+ }
24
+
25
+ async list(options: BasePaginationOptions, accessToken?: string) {
26
+ try {
27
+ if (!accessToken) {
28
+ const { token } = await this.auth(
29
+ this.options.publicKey,
30
+ this.options.privateKey
31
+ );
32
+ accessToken = token;
33
+ }
34
+
35
+ const path = `/api/public/checkout`;
36
+
37
+ return this.auth_get<CheckoutListInfo>(
38
+ `${path}`,
39
+ { ...options },
40
+ accessToken
41
+ );
42
+ } catch (err) {
43
+ throw err;
44
+ }
45
+ }
46
+
47
+ async info(checkoutId: string, accessToken?: string) {
48
+ try {
49
+ if (!accessToken) {
50
+ const { token } = await this.auth(
51
+ this.options.publicKey,
52
+ this.options.privateKey
53
+ );
54
+ accessToken = token;
55
+ }
56
+ const path = `/api/public/checkout/${checkoutId}`;
57
+
58
+ return this.auth_get<CheckoutInfo>(`${path}`, {}, accessToken);
59
+ } catch (err) {
60
+ throw err;
61
+ }
62
+ }
63
+
64
+ async remove(checkoutId: string, accessToken?: string) {
65
+ try {
66
+ if (!accessToken) {
67
+ const { token } = await this.auth(
68
+ this.options.publicKey,
69
+ this.options.privateKey
70
+ );
71
+ accessToken = token;
72
+ }
73
+ const path = `/api/public/checkout/${checkoutId}`;
74
+
75
+ return this.auth_delete<boolean>(`${path}`, {}, accessToken);
76
+ } catch (err) {
77
+ throw err;
78
+ }
79
+ }
80
+
81
+ async createDonation(options: CreateDonationOptions, accessToken?: string) {
82
+ try {
83
+ if (!accessToken) {
84
+ const { token } = await this.auth(
85
+ this.options.publicKey,
86
+ this.options.privateKey
87
+ );
88
+ accessToken = token;
89
+ }
90
+ const path = `/api/public/checkout/donation`;
91
+
92
+ return this.auth_post<CheckoutInfo>(`${path}`, options, accessToken);
93
+ } catch (err) {
94
+ throw err;
95
+ }
96
+ }
97
+
98
+ async createSale(options: CreateSaleOptions, accessToken?: string) {
99
+ try {
100
+ if (!accessToken) {
101
+ const { token } = await this.auth(
102
+ this.options.publicKey,
103
+ this.options.privateKey
104
+ );
105
+ accessToken = token;
106
+ }
107
+ const path = `/api/public/checkout/sale`;
108
+
109
+ return this.auth_post<CheckoutInfo>(`${path}`, options, accessToken);
110
+ } catch (err) {
111
+ throw err;
112
+ }
113
+ }
114
+
115
+ async createSaleToken(options: CreateSaleTokenOptions, accessToken?: string) {
116
+ try {
117
+ if (!accessToken) {
118
+ const { token } = await this.auth(
119
+ this.options.publicKey,
120
+ this.options.privateKey
121
+ );
122
+ accessToken = token;
123
+ }
124
+ const path = `/api/public/checkout/saleToken`;
125
+
126
+ return this.auth_post<CheckoutInfo>(`${path}`, options, accessToken);
127
+ } catch (err) {
128
+ throw err;
129
+ }
130
+ }
131
+
132
+ async createCart(options: CreateCartOptions, accessToken?: string) {
133
+ try {
134
+ if (!accessToken) {
135
+ const { token } = await this.auth(
136
+ this.options.publicKey,
137
+ this.options.privateKey
138
+ );
139
+ accessToken = token;
140
+ }
141
+ const path = `/api/public/checkout/cart`;
142
+
143
+ return this.auth_post<CheckoutInfo>(`${path}`, options, accessToken);
144
+ } catch (err) {
145
+ throw err;
146
+ }
147
+ }
148
+
149
+ async saleTokenEstimateMax(
150
+ options: SaleTokenEstimateMaxOptions,
151
+ accessToken?: string
152
+ ) {
153
+ try {
154
+ if (!accessToken) {
155
+ const { token } = await this.auth(
156
+ this.options.publicKey,
157
+ this.options.privateKey
158
+ );
159
+ accessToken = token;
160
+ }
161
+ const path = `/api/public/checkout/saleToken/estimateMax`;
162
+
163
+ return this.auth_post<{ max: string }>(`${path}`, options, accessToken);
164
+ } catch (err) {
165
+ throw err;
166
+ }
167
+ }
168
+
169
+ async updateDonation(
170
+ checkoutId: string,
171
+ options: UpdateDonationOptions,
172
+ accessToken?: string
173
+ ) {
174
+ try {
175
+ if (!accessToken) {
176
+ const { token } = await this.auth(
177
+ this.options.publicKey,
178
+ this.options.privateKey
179
+ );
180
+ accessToken = token;
181
+ }
182
+ const path = `/api/public/checkout/${checkoutId}/donation`;
183
+
184
+ return this.auth_patch<CheckoutInfo>(`${path}`, options, accessToken);
185
+ } catch (err) {
186
+ throw err;
187
+ }
188
+ }
189
+
190
+ async updateSale(
191
+ checkoutId: string,
192
+ options: UpdateSaleOptions,
193
+ accessToken?: string
194
+ ) {
195
+ try {
196
+ if (!accessToken) {
197
+ const { token } = await this.auth(
198
+ this.options.publicKey,
199
+ this.options.privateKey
200
+ );
201
+ accessToken = token;
202
+ }
203
+ const path = `/api/public/checkout/${checkoutId}/sale`;
204
+
205
+ return this.auth_patch<CheckoutInfo>(`${path}`, options, accessToken);
206
+ } catch (err) {
207
+ throw err;
208
+ }
209
+ }
210
+
211
+ async updateSaleToken(
212
+ checkoutId: string,
213
+ options: UpdateSaleTokenOptions,
214
+ accessToken?: string
215
+ ) {
216
+ try {
217
+ if (!accessToken) {
218
+ const { token } = await this.auth(
219
+ this.options.publicKey,
220
+ this.options.privateKey
221
+ );
222
+ accessToken = token;
223
+ }
224
+ const path = `/api/public/checkout/${checkoutId}/saleToken`;
225
+
226
+ return this.auth_patch<CheckoutInfo>(`${path}`, options, accessToken);
227
+ } catch (err) {
228
+ throw err;
229
+ }
230
+ }
231
+
232
+ async updateCart(
233
+ checkoutId: string,
234
+ options: UpdateCartOptions,
235
+ accessToken?: string
236
+ ) {
237
+ try {
238
+ if (!accessToken) {
239
+ const { token } = await this.auth(
240
+ this.options.publicKey,
241
+ this.options.privateKey
242
+ );
243
+ accessToken = token;
244
+ }
245
+ const path = `/api/public/checkout/${checkoutId}/cart`;
246
+
247
+ return this.auth_patch<CheckoutInfo>(`${path}`, options, accessToken);
248
+ } catch (err) {
249
+ throw err;
250
+ }
251
+ }
252
+
253
+ async chargeList(
254
+ checkoutId: string,
255
+ options?: BasePaginationOptions,
256
+ accessToken?: string
257
+ ) {
258
+ try {
259
+ if (!accessToken) {
260
+ const { token } = await this.auth(
261
+ this.options.publicKey,
262
+ this.options.privateKey
263
+ );
264
+ accessToken = token;
265
+ }
266
+ const path = `/api/public/checkout/${checkoutId}/charge-list`;
267
+
268
+ return this.auth_get<CheckoutChargeListInfo>(
269
+ `${path}`,
270
+ { ...options },
271
+ accessToken
272
+ );
273
+ } catch (err) {
274
+ throw err;
275
+ }
276
+ }
277
+ }
278
+
279
+ export default Checkout;
@@ -0,0 +1 @@
1
+ export const REST_URL = "https://api.paytonz.com";
@@ -0,0 +1,21 @@
1
+ export interface CurrencyInfo {
2
+ currencies: {
3
+ _id: string;
4
+ title: string;
5
+ name: string;
6
+ nodeType: string;
7
+ currencyType: string;
8
+ mainCurrency?: string;
9
+ replenishMinimumValue?: number;
10
+ decimals: number;
11
+ supportMultisend: boolean;
12
+ supportSwap: boolean;
13
+ }[];
14
+ page: number;
15
+ pages: number;
16
+ }
17
+
18
+ export interface CurrencyOptions {
19
+ page?: number;
20
+ limit?: number;
21
+ }
@@ -0,0 +1,60 @@
1
+ import { PaytonzSDKBase, PaytonzSDKBaseOptions } from "../PaytonzSDKBase";
2
+ import { CurrencyInfo, CurrencyOptions } from "./currency.interface";
3
+
4
+ export interface PaytonzSDKOptions extends PaytonzSDKBaseOptions {}
5
+
6
+ export class Currency extends PaytonzSDKBase {
7
+ constructor(parameters: PaytonzSDKOptions) {
8
+ super(parameters);
9
+ }
10
+
11
+ async getAvailableCurrencies(
12
+ options: CurrencyOptions,
13
+ accessToken?: string
14
+ ): Promise<CurrencyInfo> {
15
+ try {
16
+ if (!accessToken) {
17
+ const { token } = await this.auth(
18
+ this.options.publicKey,
19
+ this.options.privateKey
20
+ );
21
+ accessToken = token;
22
+ }
23
+ const path = `/api/public/currency`;
24
+
25
+ return this.auth_get<CurrencyInfo>(
26
+ `${path}`,
27
+ { ...options },
28
+ accessToken
29
+ );
30
+ } catch (err) {
31
+ throw err;
32
+ }
33
+ }
34
+
35
+ async getPaymasters(
36
+ options: CurrencyOptions,
37
+ accessToken?: string
38
+ ): Promise<CurrencyInfo> {
39
+ try {
40
+ if (!accessToken) {
41
+ const { token } = await this.auth(
42
+ this.options.publicKey,
43
+ this.options.privateKey
44
+ );
45
+ accessToken = token;
46
+ }
47
+ const path = `/api/public/currency/paymasters`;
48
+
49
+ return this.auth_get<CurrencyInfo>(
50
+ `${path}`,
51
+ { ...options },
52
+ accessToken
53
+ );
54
+ } catch (err) {
55
+ throw err;
56
+ }
57
+ }
58
+ }
59
+
60
+ export default Currency;
@@ -0,0 +1,65 @@
1
+ import { AccessWalletOptions } from "src/interfaces/paytonz.interface";
2
+
3
+ export interface ExternalOptions extends AccessWalletOptions {
4
+ abi: Record<string, any>[];
5
+ contractAddress: string;
6
+ method: string;
7
+ args?: any[];
8
+ value?: string;
9
+ options?: Record<string, any>;
10
+ isSmartAccount?: boolean;
11
+ isGasless?: boolean;
12
+ paymasterCurrencyToken?: string;
13
+ idempotencyKey?: string;
14
+ }
15
+
16
+ export interface ExternalEstimateWriteInfo {
17
+ gasPrice?: string;
18
+ gasLimit?: string;
19
+ fee: string;
20
+ }
21
+
22
+ export interface ExternalWriteInfo {
23
+ _id: string;
24
+ hash: string;
25
+ }
26
+
27
+ export interface ExternalSolanaMintNftInfo extends ExternalWriteInfo {
28
+ address: string;
29
+ }
30
+
31
+ export interface SolanaMetadataOptions {
32
+ trait_type: string;
33
+ value: string;
34
+ }
35
+
36
+ export enum SolanaNftType {
37
+ COLLECTION = "collection",
38
+ NFT = "nft",
39
+ }
40
+
41
+ export enum SolanaNftStorageType {
42
+ CPAY = "cpay",
43
+ }
44
+
45
+ export interface SolanaCollectionInfo {
46
+ name: string;
47
+ family: string;
48
+ }
49
+
50
+ export interface ExternalSolanaMintNftOptions extends AccessWalletOptions {
51
+ name: string;
52
+ description: string;
53
+ symbol: string;
54
+ attributes?: SolanaMetadataOptions[];
55
+ type: SolanaNftType;
56
+ image?: string;
57
+ sellerFeeBasisPoints?: number;
58
+ collectionAddress?: string;
59
+ storage?: SolanaNftStorageType;
60
+ collectionInfo?: SolanaCollectionInfo;
61
+ payerFeePrivateKey?: string;
62
+ tokenOwner?: string;
63
+ creators?: { address: string; share: number }[];
64
+ imageLink?: string;
65
+ }
@@ -0,0 +1,54 @@
1
+ import { PaytonzSDKBase, PaytonzSDKBaseOptions } from "../PaytonzSDKBase";
2
+ import {
3
+ ExternalEstimateWriteInfo,
4
+ ExternalSolanaMintNftInfo,
5
+ ExternalSolanaMintNftOptions,
6
+ } from "./external.interface";
7
+
8
+ export interface PaytonzSDKOptions extends PaytonzSDKBaseOptions {}
9
+
10
+ export class ExternalSolana extends PaytonzSDKBase {
11
+ constructor(parameters: PaytonzSDKOptions) {
12
+ super(parameters);
13
+ }
14
+
15
+ async mintNft(
16
+ options: ExternalSolanaMintNftOptions,
17
+ accessToken?: string
18
+ ): Promise<ExternalSolanaMintNftInfo> {
19
+ try {
20
+ if (!accessToken) {
21
+ accessToken = await this.getToken(true);
22
+ }
23
+ const path = `/api/public/external/mint-solana-nft`;
24
+
25
+ return this.auth_post<ExternalSolanaMintNftInfo>(
26
+ `${path}`,
27
+ options,
28
+ accessToken
29
+ );
30
+ } catch (err) {
31
+ throw err;
32
+ }
33
+ }
34
+
35
+ async estimateMintNft(
36
+ options: ExternalSolanaMintNftOptions,
37
+ accessToken?: string
38
+ ): Promise<ExternalEstimateWriteInfo> {
39
+ try {
40
+ if (!accessToken) {
41
+ accessToken = await this.getToken(true);
42
+ }
43
+ const path = `/api/public/external/mint-solana-nft/estimate`;
44
+
45
+ return this.auth_post<ExternalEstimateWriteInfo>(
46
+ `${path}`,
47
+ options,
48
+ accessToken
49
+ );
50
+ } catch (err) {
51
+ throw err;
52
+ }
53
+ }
54
+ }
@@ -0,0 +1,73 @@
1
+ import { PaytonzSDKBase, PaytonzSDKBaseOptions } from "../PaytonzSDKBase";
2
+ import {
3
+ ExternalEstimateWriteInfo,
4
+ ExternalOptions,
5
+ ExternalWriteInfo,
6
+ } from "./external.interface";
7
+ import { ExternalSolana } from "./external.solana";
8
+
9
+ export interface PaytonzSDKOptions extends PaytonzSDKBaseOptions {}
10
+
11
+ export class External extends PaytonzSDKBase {
12
+ constructor(parameters: PaytonzSDKOptions) {
13
+ super(parameters);
14
+ this.solana = new ExternalSolana(parameters);
15
+ }
16
+
17
+ solana: ExternalSolana;
18
+
19
+ async read(options: ExternalOptions, accessToken?: string): Promise<any> {
20
+ try {
21
+ if (!accessToken) {
22
+ accessToken = await this.getToken(true);
23
+ }
24
+ const path = `/api/public/external/read`;
25
+
26
+ return this.auth_post<any>(`${path}`, { ...options }, accessToken);
27
+ } catch (err) {
28
+ throw err;
29
+ }
30
+ }
31
+
32
+ async estimateWrite(
33
+ options: ExternalOptions,
34
+ accessToken?: string
35
+ ): Promise<ExternalEstimateWriteInfo> {
36
+ try {
37
+ if (!accessToken) {
38
+ accessToken = await this.getToken(true);
39
+ }
40
+ const path = `/api/public/external/estimateWrite`;
41
+
42
+ return this.auth_post<ExternalEstimateWriteInfo>(
43
+ `${path}`,
44
+ { ...options },
45
+ accessToken
46
+ );
47
+ } catch (err) {
48
+ throw err;
49
+ }
50
+ }
51
+
52
+ async write(
53
+ options: ExternalOptions,
54
+ accessToken?: string
55
+ ): Promise<ExternalWriteInfo> {
56
+ try {
57
+ if (!accessToken) {
58
+ accessToken = await this.getToken(true);
59
+ }
60
+ const path = `/api/public/external/write`;
61
+
62
+ return this.auth_post<ExternalWriteInfo>(
63
+ `${path}`,
64
+ { ...options },
65
+ accessToken
66
+ );
67
+ } catch (err) {
68
+ throw err;
69
+ }
70
+ }
71
+ }
72
+
73
+ export default External;
package/src/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from "./constant";
2
+ export { default as PaytonzSDK } from "./PaytonzSDK";
3
+ export { default as default } from "./PaytonzSDK";
4
+ export { PaytonzSDKBase } from "./PaytonzSDKBase";
5
+ export * from "./interfaces/paytonz.interface";
@@ -0,0 +1,23 @@
1
+ export interface PaytonzToken {
2
+ token: string;
3
+ }
4
+
5
+ export interface AccessWalletOptions {
6
+ sign?: string;
7
+ password?: string;
8
+ }
9
+
10
+ export interface BasePaginationOptions {
11
+ search?: string;
12
+ sort?: string;
13
+ order?: string;
14
+ page?: number;
15
+ limit?: number;
16
+ }
17
+
18
+ export interface IGetToken {
19
+ publicKey: string;
20
+ privateKey: string;
21
+ walletId?: string;
22
+ passphrase?: string;
23
+ }