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,103 @@
1
+ import { PaytonzSDKBase, PaytonzSDKBaseOptions } from "../PaytonzSDKBase";
2
+ import {
3
+ CreateWalletInfo,
4
+ CreateWalletOptions,
5
+ WalletInfo,
6
+ } from "./wallet.interface";
7
+ import { WalletSignature } from "./wallet.signature";
8
+
9
+ export interface PaytonzSDKOptions extends PaytonzSDKBaseOptions {}
10
+
11
+ export class Wallet extends PaytonzSDKBase {
12
+ constructor(parameters: PaytonzSDKOptions) {
13
+ super(parameters);
14
+ this.signature = new WalletSignature(parameters);
15
+ }
16
+
17
+ signature: WalletSignature;
18
+
19
+ async createDepositWallet(
20
+ options: CreateWalletOptions,
21
+ accessToken?: string
22
+ ): Promise<CreateWalletInfo> {
23
+ try {
24
+ if (!accessToken) {
25
+ accessToken = await this.getToken();
26
+ }
27
+ const path = `/api/public/wallet/${options.currencyId}`;
28
+
29
+ delete options.currencyId;
30
+
31
+ return this.auth_post<CreateWalletInfo>(`${path}`, options, accessToken);
32
+ } catch (err) {
33
+ throw err;
34
+ }
35
+ }
36
+
37
+ async createSmartAccount(accessToken?: string): Promise<boolean> {
38
+ try {
39
+ if (!accessToken) {
40
+ accessToken = await this.getToken();
41
+ }
42
+ const path = `/api/public/wallet/smart-account`;
43
+
44
+ return this.auth_post<boolean>(`${path}`, {}, accessToken);
45
+ } catch (err) {
46
+ throw err;
47
+ }
48
+ }
49
+
50
+ async getWalletInfo(accessToken?: string): Promise<WalletInfo> {
51
+ try {
52
+ if (!accessToken) {
53
+ accessToken = await this.getToken(true);
54
+ }
55
+ const path = `/api/public/wallet`;
56
+
57
+ return this.auth_get<WalletInfo>(`${path}`, {}, accessToken);
58
+ } catch (err) {
59
+ throw err;
60
+ }
61
+ }
62
+
63
+ async getSmartWalletInfo(accessToken?: string): Promise<WalletInfo> {
64
+ try {
65
+ if (!accessToken) {
66
+ accessToken = await this.getToken(true);
67
+ }
68
+ const path = `/api/public/wallet/smart-account`;
69
+
70
+ return this.auth_get<WalletInfo>(`${path}`, {}, accessToken);
71
+ } catch (err) {
72
+ throw err;
73
+ }
74
+ }
75
+
76
+ async getPrivateKey(accessToken?: string): Promise<string> {
77
+ try {
78
+ if (!accessToken) {
79
+ accessToken = await this.getToken(true);
80
+ }
81
+ const path = `/api/public/wallet/private-key`;
82
+
83
+ return this.auth_get<string>(`${path}`, {}, accessToken);
84
+ } catch (err) {
85
+ throw err;
86
+ }
87
+ }
88
+
89
+ async getMnemonic(accessToken?: string): Promise<string> {
90
+ try {
91
+ if (!accessToken) {
92
+ accessToken = await this.getToken(true);
93
+ }
94
+ const path = `/api/public/wallet/mnemonic`;
95
+
96
+ return this.auth_get<string>(`${path}`, {}, accessToken);
97
+ } catch (err) {
98
+ throw err;
99
+ }
100
+ }
101
+ }
102
+
103
+ export default Wallet;
@@ -0,0 +1,89 @@
1
+ import { AccessWalletOptions } from "src/interfaces/paytonz.interface";
2
+
3
+ export interface CreateWithdrawalInfo {
4
+ id: string;
5
+ }
6
+
7
+ export interface EstimateFeeInfo {
8
+ fee: string;
9
+ minerFee: string;
10
+ systemFee?: string;
11
+ merchantFee?: string;
12
+ currencyMinerFee: string;
13
+ currencyFee: string;
14
+ }
15
+
16
+ export interface EstimateFeeNftInfo {
17
+ fee: string;
18
+ minerFee: string;
19
+ systemFee: string;
20
+ currencyMinerFee: string;
21
+ currencySystemFee: string;
22
+ }
23
+
24
+ export interface EstimateMaxInfo {
25
+ amount: string;
26
+ }
27
+
28
+ export enum PriorityTx {
29
+ LOW = "low",
30
+ MEDIUM = "medium",
31
+ HIGH = "high",
32
+ }
33
+
34
+ export interface CreateWithdrawalOptions extends AccessWalletOptions {
35
+ to: string;
36
+ amount: string;
37
+ priority?: PriorityTx;
38
+ currencyToken?: string;
39
+ payerFeePrivateKey?: string;
40
+ comment?: string;
41
+ isSmartAccount?: boolean;
42
+ paymasterCurrencyToken?: string;
43
+ isGasless?: boolean;
44
+ idempotencyKey?: string;
45
+ }
46
+
47
+ export interface InternalTransferOptions {
48
+ to: string;
49
+ amount: string;
50
+ idempotencyKey?: string;
51
+ }
52
+
53
+ export interface EstimateFeeOptions extends AccessWalletOptions {
54
+ to: string;
55
+ amount: string;
56
+ priority?: PriorityTx;
57
+ currencyToken?: string;
58
+ payerFeePrivateKey?: string;
59
+ isSmartAccount?: boolean;
60
+ paymasterCurrencyToken?: string;
61
+ isGasless?: boolean;
62
+ }
63
+
64
+ enum TypeNFt {
65
+ ERC_721 = "erc721",
66
+ ERC_1155 = "erc1155",
67
+ }
68
+
69
+ export interface EstimateFeeNftOptions extends AccessWalletOptions {
70
+ to: string;
71
+ amount: string;
72
+ contractAddress: string;
73
+ tokenId: number;
74
+ type: TypeNFt;
75
+ payerFeePrivateKey?: string;
76
+ idempotencyKey?: string;
77
+ }
78
+
79
+ export interface CreateNftWithdrawalOptions extends EstimateFeeNftOptions {}
80
+
81
+ export interface EstimateMaxOptions extends AccessWalletOptions {
82
+ to: string;
83
+ currencyToken?: string;
84
+ payerFeePrivateKey?: string;
85
+ priority?: PriorityTx;
86
+ isSmartAccount?: boolean;
87
+ paymasterCurrencyToken?: string;
88
+ isGasless?: boolean;
89
+ }
@@ -0,0 +1,135 @@
1
+ import { PaytonzSDKBase, PaytonzSDKBaseOptions } from "../PaytonzSDKBase";
2
+ import {
3
+ CreateNftWithdrawalOptions,
4
+ CreateWithdrawalInfo,
5
+ CreateWithdrawalOptions,
6
+ EstimateFeeInfo,
7
+ EstimateFeeNftInfo,
8
+ EstimateFeeNftOptions,
9
+ EstimateFeeOptions,
10
+ EstimateMaxInfo,
11
+ EstimateMaxOptions,
12
+ InternalTransferOptions,
13
+ } from "./withdrawal.interface";
14
+
15
+ export interface PaytonzSDKOptions extends PaytonzSDKBaseOptions {}
16
+
17
+ export class Withdrawal extends PaytonzSDKBase {
18
+ constructor(parameters: PaytonzSDKOptions) {
19
+ super(parameters);
20
+ }
21
+
22
+ async create(
23
+ options: CreateWithdrawalOptions,
24
+ accessToken?: string
25
+ ): Promise<CreateWithdrawalInfo> {
26
+ try {
27
+ if (!accessToken) {
28
+ accessToken = await this.getToken(true);
29
+ }
30
+ const path = `/api/public/withdrawal`;
31
+
32
+ return this.auth_post<CreateWithdrawalInfo>(
33
+ `${path}`,
34
+ options,
35
+ accessToken
36
+ );
37
+ } catch (err) {
38
+ throw err;
39
+ }
40
+ }
41
+
42
+ async nftTransfer(
43
+ options: CreateNftWithdrawalOptions,
44
+ accessToken?: string
45
+ ): Promise<CreateWithdrawalInfo> {
46
+ try {
47
+ if (!accessToken) {
48
+ accessToken = await this.getToken(true);
49
+ }
50
+ const path = `/api/public/withdrawal/nft`;
51
+
52
+ return this.auth_post<CreateWithdrawalInfo>(
53
+ `${path}`,
54
+ options,
55
+ accessToken
56
+ );
57
+ } catch (err) {
58
+ throw err;
59
+ }
60
+ }
61
+
62
+ async internalTransfer(
63
+ options: InternalTransferOptions,
64
+ accessToken?: string
65
+ ): Promise<CreateWithdrawalInfo> {
66
+ try {
67
+ if (!accessToken) {
68
+ accessToken = await this.getToken(true);
69
+ }
70
+ const path = `/api/public/withdrawal/internal`;
71
+
72
+ return this.auth_post<CreateWithdrawalInfo>(
73
+ `${path}`,
74
+ options,
75
+ accessToken
76
+ );
77
+ } catch (err) {
78
+ throw err;
79
+ }
80
+ }
81
+
82
+ async estimateFee(
83
+ options: EstimateFeeOptions,
84
+ accessToken?: string
85
+ ): Promise<EstimateFeeInfo> {
86
+ try {
87
+ if (!accessToken) {
88
+ accessToken = await this.getToken(true);
89
+ }
90
+ const path = `/api/public/transaction/fee`;
91
+
92
+ return this.auth_post<EstimateFeeInfo>(`${path}`, options, accessToken);
93
+ } catch (err) {
94
+ throw err;
95
+ }
96
+ }
97
+
98
+ async estimateNftFee(
99
+ options: EstimateFeeNftOptions,
100
+ accessToken?: string
101
+ ): Promise<EstimateFeeNftInfo> {
102
+ try {
103
+ if (!accessToken) {
104
+ accessToken = await this.getToken(true);
105
+ }
106
+ const path = `/api/public/transaction/feeNft`;
107
+
108
+ return this.auth_post<EstimateFeeNftInfo>(
109
+ `${path}`,
110
+ options,
111
+ accessToken
112
+ );
113
+ } catch (err) {
114
+ throw err;
115
+ }
116
+ }
117
+
118
+ async estimateMax(
119
+ options: EstimateMaxOptions,
120
+ accessToken?: string
121
+ ): Promise<EstimateMaxInfo> {
122
+ try {
123
+ if (!accessToken) {
124
+ accessToken = await this.getToken(true);
125
+ }
126
+ const path = `/api/public/withdrawal/estimate-max`;
127
+
128
+ return this.auth_post<EstimateMaxInfo>(`${path}`, options, accessToken);
129
+ } catch (err) {
130
+ throw err;
131
+ }
132
+ }
133
+ }
134
+
135
+ export default Withdrawal;
package/tsconfig.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "allowSyntheticDefaultImports": true,
4
+ "experimentalDecorators": true,
5
+ "esModuleInterop": true,
6
+ "declaration": true,
7
+ "target": "es6",
8
+ "module": "CommonJS",
9
+ "moduleResolution": "node",
10
+ "lib":["es2018"],
11
+ "outDir": "./lib",
12
+ "baseUrl": ".",
13
+ "paths": {
14
+ },
15
+ "skipLibCheck": true
16
+ },
17
+ "exclude": [
18
+ "lib",
19
+ "node_modules"
20
+ ]
21
+ }