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.
- package/README.md +743 -0
- package/lib/CpaySDK.d.ts +30 -0
- package/lib/CpaySDK.js +35 -0
- package/lib/CpaySDKBase.d.ts +30 -0
- package/lib/CpaySDKBase.js +216 -0
- package/lib/CryptoNowSDK.d.ts +30 -0
- package/lib/CryptoNowSDK.js +35 -0
- package/lib/CryptoNowSDKBase.d.ts +30 -0
- package/lib/CryptoNowSDKBase.js +216 -0
- package/lib/PaytonzSDK.d.ts +28 -0
- package/lib/PaytonzSDK.js +33 -0
- package/lib/PaytonzSDKBase.d.ts +30 -0
- package/lib/PaytonzSDKBase.js +198 -0
- package/lib/auth/auth.d.ts +9 -0
- package/lib/auth/auth.interface.d.ts +25 -0
- package/lib/auth/auth.interface.js +2 -0
- package/lib/auth/auth.js +37 -0
- package/lib/checkout/checkout.d.ts +24 -0
- package/lib/checkout/checkout.interface.d.ts +94 -0
- package/lib/checkout/checkout.interface.js +2 -0
- package/lib/checkout/checkout.js +215 -0
- package/lib/client/client.d.ts +11 -0
- package/lib/client/client.interface.d.ts +45 -0
- package/lib/client/client.interface.js +2 -0
- package/lib/client/client.js +62 -0
- package/lib/constant.d.ts +1 -0
- package/lib/constant.js +4 -0
- package/lib/currency/currency.d.ts +10 -0
- package/lib/currency/currency.interface.d.ts +20 -0
- package/lib/currency/currency.interface.js +2 -0
- package/lib/currency/currency.js +50 -0
- package/lib/external/external.d.ts +13 -0
- package/lib/external/external.interface.d.ts +59 -0
- package/lib/external/external.interface.js +12 -0
- package/lib/external/external.js +64 -0
- package/lib/external/external.solana.d.ts +9 -0
- package/lib/external/external.solana.js +47 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +28 -0
- package/lib/interfaces/cpay.interface.d.ts +20 -0
- package/lib/interfaces/cpay.interface.js +2 -0
- package/lib/interfaces/cryptonow.interface.d.ts +20 -0
- package/lib/interfaces/cryptonow.interface.js +2 -0
- package/lib/interfaces/paytonz.interface.d.ts +20 -0
- package/lib/interfaces/paytonz.interface.js +2 -0
- package/lib/multisend/multisend.d.ts +11 -0
- package/lib/multisend/multisend.interface.d.ts +28 -0
- package/lib/multisend/multisend.interface.js +2 -0
- package/lib/multisend/multisend.js +75 -0
- package/lib/swap/swap.d.ts +11 -0
- package/lib/swap/swap.interface.d.ts +84 -0
- package/lib/swap/swap.interface.js +2 -0
- package/lib/swap/swap.js +75 -0
- package/lib/transaction/transaction.d.ts +9 -0
- package/lib/transaction/transaction.interface.d.ts +82 -0
- package/lib/transaction/transaction.interface.js +2 -0
- package/lib/transaction/transaction.js +34 -0
- package/lib/utils/httpClient.d.ts +9 -0
- package/lib/utils/httpClient.js +64 -0
- package/lib/wallet/wallet.d.ts +16 -0
- package/lib/wallet/wallet.interface.d.ts +60 -0
- package/lib/wallet/wallet.interface.js +2 -0
- package/lib/wallet/wallet.js +107 -0
- package/lib/wallet/wallet.signature.d.ts +14 -0
- package/lib/wallet/wallet.signature.js +104 -0
- package/lib/withdrawal/withdrawal.d.ts +14 -0
- package/lib/withdrawal/withdrawal.interface.d.ts +79 -0
- package/lib/withdrawal/withdrawal.interface.js +14 -0
- package/lib/withdrawal/withdrawal.js +104 -0
- package/package.json +26 -0
- package/src/PaytonzSDK.ts +41 -0
- package/src/PaytonzSDKBase.ts +252 -0
- package/src/auth/auth.interface.ts +26 -0
- package/src/auth/auth.ts +31 -0
- package/src/checkout/checkout.interface.ts +110 -0
- package/src/checkout/checkout.ts +279 -0
- package/src/constant.ts +1 -0
- package/src/currency/currency.interface.ts +21 -0
- package/src/currency/currency.ts +60 -0
- package/src/external/external.interface.ts +65 -0
- package/src/external/external.solana.ts +54 -0
- package/src/external/external.ts +73 -0
- package/src/index.ts +5 -0
- package/src/interfaces/paytonz.interface.ts +23 -0
- package/src/multisend/multisend.interface.ts +32 -0
- package/src/multisend/multisend.ts +91 -0
- package/src/swap/swap.interface.ts +90 -0
- package/src/swap/swap.ts +93 -0
- package/src/transaction/transaction.interface.ts +76 -0
- package/src/transaction/transaction.ts +35 -0
- package/src/utils/httpClient.ts +60 -0
- package/src/wallet/wallet.interface.ts +67 -0
- package/src/wallet/wallet.signature.ts +106 -0
- package/src/wallet/wallet.ts +103 -0
- package/src/withdrawal/withdrawal.interface.ts +89 -0
- package/src/withdrawal/withdrawal.ts +135 -0
- 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
|
+
}
|