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,11 @@
|
|
|
1
|
+
import { PaytonzSDKBase, PaytonzSDKBaseOptions } from "../PaytonzSDKBase";
|
|
2
|
+
import { SwapCreateInfo, SwapCreateOptions, SwapEstimateInfo, SwapEstimateOptions, SwapHistoryInfo, SwapHistoryListOptions } from "./swap.interface";
|
|
3
|
+
export interface PaytonzSDKOptions extends PaytonzSDKBaseOptions {
|
|
4
|
+
}
|
|
5
|
+
export declare class Swap extends PaytonzSDKBase {
|
|
6
|
+
constructor(parameters: PaytonzSDKOptions);
|
|
7
|
+
estimate(options: SwapEstimateOptions, accessToken?: string): Promise<SwapEstimateInfo[]>;
|
|
8
|
+
bestOffer(options: SwapEstimateOptions, accessToken?: string): Promise<SwapEstimateInfo>;
|
|
9
|
+
create(options: SwapCreateOptions, accessToken?: string): Promise<SwapCreateInfo>;
|
|
10
|
+
history(options: SwapHistoryListOptions, accessToken?: string): Promise<SwapHistoryInfo>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { AccessWalletOptions } from "src/interfaces/paytonz.interface";
|
|
2
|
+
export interface SwapEstimateOptions {
|
|
3
|
+
fromId: string;
|
|
4
|
+
toId: string;
|
|
5
|
+
amount: string;
|
|
6
|
+
sort?: string;
|
|
7
|
+
type?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface SwapCreateOptions extends AccessWalletOptions {
|
|
10
|
+
currencyFromId: string;
|
|
11
|
+
toId: string;
|
|
12
|
+
currencyToId: string;
|
|
13
|
+
amount: number;
|
|
14
|
+
partner: string;
|
|
15
|
+
fixed: boolean;
|
|
16
|
+
rateId: string;
|
|
17
|
+
idempotencyKey?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface SwapEstimateInfo {
|
|
20
|
+
id: string;
|
|
21
|
+
supportRate: number;
|
|
22
|
+
duration: string;
|
|
23
|
+
min: number;
|
|
24
|
+
max: number;
|
|
25
|
+
fixed: boolean;
|
|
26
|
+
partner: string;
|
|
27
|
+
exists: boolean;
|
|
28
|
+
fromAmount: number;
|
|
29
|
+
fromCurrency: string;
|
|
30
|
+
fromNetwork: string;
|
|
31
|
+
toAmount: number;
|
|
32
|
+
toCurrency: string;
|
|
33
|
+
toNetwork: string;
|
|
34
|
+
}
|
|
35
|
+
export interface SwapCreateInfo {
|
|
36
|
+
id: string;
|
|
37
|
+
exchangeId: string;
|
|
38
|
+
}
|
|
39
|
+
export interface SwapHistoryListOptions {
|
|
40
|
+
currencyFromId?: string;
|
|
41
|
+
currencyToId?: string;
|
|
42
|
+
search?: string;
|
|
43
|
+
sort?: string;
|
|
44
|
+
order?: string;
|
|
45
|
+
page?: number;
|
|
46
|
+
limit?: number;
|
|
47
|
+
}
|
|
48
|
+
interface SwapWalletInfo {
|
|
49
|
+
id: string;
|
|
50
|
+
address: string;
|
|
51
|
+
amount: {
|
|
52
|
+
value: number;
|
|
53
|
+
usd: number;
|
|
54
|
+
};
|
|
55
|
+
currency: {
|
|
56
|
+
id: string;
|
|
57
|
+
name: string;
|
|
58
|
+
};
|
|
59
|
+
paymentId: string;
|
|
60
|
+
hash: string;
|
|
61
|
+
}
|
|
62
|
+
export interface SwapHistoryInfo {
|
|
63
|
+
page: number;
|
|
64
|
+
pages: number;
|
|
65
|
+
countItems: number;
|
|
66
|
+
entities: {
|
|
67
|
+
_id: string;
|
|
68
|
+
exchangeId: string;
|
|
69
|
+
partner: string;
|
|
70
|
+
fixed: boolean;
|
|
71
|
+
typeNetwork: string;
|
|
72
|
+
status: boolean;
|
|
73
|
+
systemStatus: string;
|
|
74
|
+
convertRate: number;
|
|
75
|
+
from: SwapWalletInfo;
|
|
76
|
+
to: SwapWalletInfo;
|
|
77
|
+
merchant: string;
|
|
78
|
+
user: string;
|
|
79
|
+
rateId: string;
|
|
80
|
+
createdAt: Date;
|
|
81
|
+
updatedAt: Date;
|
|
82
|
+
}[];
|
|
83
|
+
}
|
|
84
|
+
export {};
|
package/lib/swap/swap.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Swap = void 0;
|
|
13
|
+
const PaytonzSDKBase_1 = require("../PaytonzSDKBase");
|
|
14
|
+
class Swap extends PaytonzSDKBase_1.PaytonzSDKBase {
|
|
15
|
+
constructor(parameters) {
|
|
16
|
+
super(parameters);
|
|
17
|
+
}
|
|
18
|
+
estimate(options, accessToken) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
try {
|
|
21
|
+
if (!accessToken) {
|
|
22
|
+
accessToken = yield this.getToken(true);
|
|
23
|
+
}
|
|
24
|
+
const path = `/api/public/swap/estimate`;
|
|
25
|
+
return this.auth_get(`${path}`, Object.assign({}, options), accessToken);
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
throw err;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
bestOffer(options, accessToken) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
try {
|
|
35
|
+
if (!accessToken) {
|
|
36
|
+
accessToken = yield this.getToken(true);
|
|
37
|
+
}
|
|
38
|
+
const path = `/api/public/swap/best-offer`;
|
|
39
|
+
return this.auth_get(`${path}`, Object.assign({}, options), accessToken);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
throw err;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
create(options, accessToken) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
try {
|
|
49
|
+
if (!accessToken) {
|
|
50
|
+
accessToken = yield this.getToken(true);
|
|
51
|
+
}
|
|
52
|
+
const path = `/api/public/swap/create`;
|
|
53
|
+
return this.auth_post(`${path}`, options, accessToken);
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
throw err;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
history(options, accessToken) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
try {
|
|
63
|
+
if (!accessToken) {
|
|
64
|
+
accessToken = yield this.getToken(true);
|
|
65
|
+
}
|
|
66
|
+
const path = `/api/public/swap/history`;
|
|
67
|
+
return this.auth_get(`${path}`, Object.assign({}, options), accessToken);
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
throw err;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.Swap = Swap;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PaytonzSDKBase, PaytonzSDKBaseOptions } from "../PaytonzSDKBase";
|
|
2
|
+
import { TransactionListInfo, TransactionListOptions } from "./transaction.interface";
|
|
3
|
+
export interface PaytonzSDKOptions extends PaytonzSDKBaseOptions {
|
|
4
|
+
}
|
|
5
|
+
export declare class Transaction extends PaytonzSDKBase {
|
|
6
|
+
constructor(parameters: PaytonzSDKOptions);
|
|
7
|
+
list(options: TransactionListOptions, accessToken?: string): Promise<TransactionListInfo>;
|
|
8
|
+
}
|
|
9
|
+
export default Transaction;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export interface TransactionListOptions {
|
|
2
|
+
search?: string;
|
|
3
|
+
from?: number;
|
|
4
|
+
to?: number;
|
|
5
|
+
currencyId?: string;
|
|
6
|
+
fromUSD?: number;
|
|
7
|
+
toUSD?: number;
|
|
8
|
+
type?: string;
|
|
9
|
+
status?: string;
|
|
10
|
+
sort?: string;
|
|
11
|
+
order?: string;
|
|
12
|
+
page?: number;
|
|
13
|
+
limit?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface TransactionListInfo {
|
|
16
|
+
page: number;
|
|
17
|
+
pages: number;
|
|
18
|
+
countItem: number;
|
|
19
|
+
entities: {
|
|
20
|
+
id: string;
|
|
21
|
+
type: string;
|
|
22
|
+
typeNetwork: string;
|
|
23
|
+
status: boolean;
|
|
24
|
+
systemStatus: string;
|
|
25
|
+
merchant: string;
|
|
26
|
+
user: string;
|
|
27
|
+
checkout?: {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
description: string;
|
|
31
|
+
identifier: string;
|
|
32
|
+
charge: {
|
|
33
|
+
id: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
info: {
|
|
37
|
+
incomingTxHash: string;
|
|
38
|
+
currencyId: string;
|
|
39
|
+
currency: string;
|
|
40
|
+
nodeType: string;
|
|
41
|
+
currencyType: string;
|
|
42
|
+
exchangeId: number;
|
|
43
|
+
from: string;
|
|
44
|
+
to: string;
|
|
45
|
+
fromId: string;
|
|
46
|
+
toId: string;
|
|
47
|
+
hashs: [string];
|
|
48
|
+
addresses: [string];
|
|
49
|
+
multisend: {
|
|
50
|
+
address: string;
|
|
51
|
+
value: string;
|
|
52
|
+
usd: string;
|
|
53
|
+
}[];
|
|
54
|
+
amount: {
|
|
55
|
+
value: string;
|
|
56
|
+
usd: number;
|
|
57
|
+
};
|
|
58
|
+
minerFee: {
|
|
59
|
+
value: string;
|
|
60
|
+
usd: number;
|
|
61
|
+
currency: string;
|
|
62
|
+
};
|
|
63
|
+
systemFee?: {
|
|
64
|
+
value: string;
|
|
65
|
+
usd: number;
|
|
66
|
+
currency: string;
|
|
67
|
+
hash: string;
|
|
68
|
+
};
|
|
69
|
+
call?: {
|
|
70
|
+
contractAddress: string;
|
|
71
|
+
method: string;
|
|
72
|
+
options: Record<string, any>;
|
|
73
|
+
arguments: any[];
|
|
74
|
+
value: string;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
fees?: Record<string, any>;
|
|
78
|
+
errorMessage?: string;
|
|
79
|
+
createdAt: Date;
|
|
80
|
+
updatedAt?: Date;
|
|
81
|
+
}[];
|
|
82
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Transaction = void 0;
|
|
13
|
+
const PaytonzSDKBase_1 = require("../PaytonzSDKBase");
|
|
14
|
+
class Transaction extends PaytonzSDKBase_1.PaytonzSDKBase {
|
|
15
|
+
constructor(parameters) {
|
|
16
|
+
super(parameters);
|
|
17
|
+
}
|
|
18
|
+
list(options, accessToken) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
try {
|
|
21
|
+
if (!accessToken) {
|
|
22
|
+
accessToken = yield this.getToken(true);
|
|
23
|
+
}
|
|
24
|
+
const path = `/api/public/transaction/list`;
|
|
25
|
+
return this.auth_get(`${path}`, Object.assign({}, options), accessToken);
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
throw err;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.Transaction = Transaction;
|
|
34
|
+
exports.default = Transaction;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Headers, Method } from "got";
|
|
2
|
+
export interface Options {
|
|
3
|
+
timeout?: number;
|
|
4
|
+
headers?: Headers;
|
|
5
|
+
method?: Method;
|
|
6
|
+
json?: Record<string, any>;
|
|
7
|
+
searchParams?: Record<string, any>;
|
|
8
|
+
}
|
|
9
|
+
export declare const request: <T>(url: any, options?: Options) => Promise<T>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.request = void 0;
|
|
16
|
+
const http_1 = __importDefault(require("http"));
|
|
17
|
+
const https_1 = __importDefault(require("https"));
|
|
18
|
+
const got_1 = __importDefault(require("got"));
|
|
19
|
+
const url_to_options_1 = __importDefault(require("got/dist/source/core/utils/url-to-options"));
|
|
20
|
+
const DEFAULT_HEADER = {
|
|
21
|
+
"content-type": "application/json;charset=utf-8",
|
|
22
|
+
};
|
|
23
|
+
const keepAliveAgent = new http_1.default.Agent({ keepAlive: true, maxSockets: 256 });
|
|
24
|
+
const keepAliveAgent2 = new https_1.default.Agent({ keepAlive: true, maxSockets: 256 });
|
|
25
|
+
const request = function (url, options = {}) {
|
|
26
|
+
var _a;
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const instance = got_1.default.extend({
|
|
29
|
+
request: (url, options, callback) => {
|
|
30
|
+
if (url.protocol === "https:") {
|
|
31
|
+
return https_1.default.request(Object.assign(Object.assign({}, options), (0, url_to_options_1.default)(url)), callback);
|
|
32
|
+
}
|
|
33
|
+
return http_1.default.request(Object.assign(Object.assign({}, options), (0, url_to_options_1.default)(url)), callback);
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
try {
|
|
37
|
+
const response = yield instance(url, {
|
|
38
|
+
method: options.method,
|
|
39
|
+
timeout: options.timeout || 6000,
|
|
40
|
+
headers: options.headers || DEFAULT_HEADER,
|
|
41
|
+
agent: {
|
|
42
|
+
http: keepAliveAgent,
|
|
43
|
+
https: keepAliveAgent2,
|
|
44
|
+
},
|
|
45
|
+
json: options.json,
|
|
46
|
+
searchParams: options.searchParams,
|
|
47
|
+
});
|
|
48
|
+
if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
49
|
+
return response.body;
|
|
50
|
+
}
|
|
51
|
+
if (response.statusMessage) {
|
|
52
|
+
throw Error(response.statusMessage);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
const parseError = JSON.parse(((_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.body) || '{"message":"Unknown error"}');
|
|
57
|
+
if (parseError && parseError.data && parseError.data.message) {
|
|
58
|
+
throw Error(parseError.data.message);
|
|
59
|
+
}
|
|
60
|
+
throw Error(err.message);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
exports.request = request;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PaytonzSDKBase, PaytonzSDKBaseOptions } from "../PaytonzSDKBase";
|
|
2
|
+
import { CreateWalletInfo, CreateWalletOptions, WalletInfo } from "./wallet.interface";
|
|
3
|
+
import { WalletSignature } from "./wallet.signature";
|
|
4
|
+
export interface PaytonzSDKOptions extends PaytonzSDKBaseOptions {
|
|
5
|
+
}
|
|
6
|
+
export declare class Wallet extends PaytonzSDKBase {
|
|
7
|
+
constructor(parameters: PaytonzSDKOptions);
|
|
8
|
+
signature: WalletSignature;
|
|
9
|
+
createDepositWallet(options: CreateWalletOptions, accessToken?: string): Promise<CreateWalletInfo>;
|
|
10
|
+
createSmartAccount(accessToken?: string): Promise<boolean>;
|
|
11
|
+
getWalletInfo(accessToken?: string): Promise<WalletInfo>;
|
|
12
|
+
getSmartWalletInfo(accessToken?: string): Promise<WalletInfo>;
|
|
13
|
+
getPrivateKey(accessToken?: string): Promise<string>;
|
|
14
|
+
getMnemonic(accessToken?: string): Promise<string>;
|
|
15
|
+
}
|
|
16
|
+
export default Wallet;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
interface WalletTokensData {
|
|
2
|
+
currencyId: string;
|
|
3
|
+
currencyName: string;
|
|
4
|
+
balance: string;
|
|
5
|
+
holdBalance: string;
|
|
6
|
+
balanceUSD: string;
|
|
7
|
+
availableBalance: string;
|
|
8
|
+
availableBalanceUSD: string;
|
|
9
|
+
}
|
|
10
|
+
interface NftItem {
|
|
11
|
+
contractAddress: string;
|
|
12
|
+
tokenId: number;
|
|
13
|
+
balance: number;
|
|
14
|
+
holdBalance: number;
|
|
15
|
+
name: string;
|
|
16
|
+
symbol: string;
|
|
17
|
+
}
|
|
18
|
+
interface NftData {
|
|
19
|
+
erc721: NftItem[];
|
|
20
|
+
erc1155: NftItem[];
|
|
21
|
+
}
|
|
22
|
+
export interface WalletInfo {
|
|
23
|
+
id: string;
|
|
24
|
+
address: string;
|
|
25
|
+
currencyId: string;
|
|
26
|
+
balance: string;
|
|
27
|
+
balanceUSD: string;
|
|
28
|
+
holdBalance: string;
|
|
29
|
+
availableBalance: string;
|
|
30
|
+
availableBalanceUSD: string;
|
|
31
|
+
tokens?: WalletTokensData[];
|
|
32
|
+
nfts?: NftData;
|
|
33
|
+
}
|
|
34
|
+
export interface CreateWalletOptions {
|
|
35
|
+
currencyId: string;
|
|
36
|
+
typeWallet?: string;
|
|
37
|
+
privateKey?: string;
|
|
38
|
+
isMnemonic?: boolean;
|
|
39
|
+
password?: string;
|
|
40
|
+
setMain?: boolean;
|
|
41
|
+
isNew?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface CreateWalletInfo {
|
|
44
|
+
id: string;
|
|
45
|
+
address: string;
|
|
46
|
+
balance: number;
|
|
47
|
+
balanceUSD: number;
|
|
48
|
+
passphrase: string;
|
|
49
|
+
}
|
|
50
|
+
export interface SignatureCommonOptions {
|
|
51
|
+
password?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface SignatureOnOptions extends SignatureCommonOptions {
|
|
54
|
+
sign: string;
|
|
55
|
+
}
|
|
56
|
+
export interface SignatureChangePasswordOptions {
|
|
57
|
+
oldPassword?: string;
|
|
58
|
+
password: string;
|
|
59
|
+
}
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Wallet = void 0;
|
|
13
|
+
const PaytonzSDKBase_1 = require("../PaytonzSDKBase");
|
|
14
|
+
const wallet_signature_1 = require("./wallet.signature");
|
|
15
|
+
class Wallet extends PaytonzSDKBase_1.PaytonzSDKBase {
|
|
16
|
+
constructor(parameters) {
|
|
17
|
+
super(parameters);
|
|
18
|
+
this.signature = new wallet_signature_1.WalletSignature(parameters);
|
|
19
|
+
}
|
|
20
|
+
createDepositWallet(options, accessToken) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
try {
|
|
23
|
+
if (!accessToken) {
|
|
24
|
+
accessToken = yield this.getToken();
|
|
25
|
+
}
|
|
26
|
+
const path = `/api/public/wallet/${options.currencyId}`;
|
|
27
|
+
delete options.currencyId;
|
|
28
|
+
return this.auth_post(`${path}`, options, accessToken);
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
throw err;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
createSmartAccount(accessToken) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
try {
|
|
38
|
+
if (!accessToken) {
|
|
39
|
+
accessToken = yield this.getToken();
|
|
40
|
+
}
|
|
41
|
+
const path = `/api/public/wallet/smart-account`;
|
|
42
|
+
return this.auth_post(`${path}`, {}, accessToken);
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
throw err;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
getWalletInfo(accessToken) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
try {
|
|
52
|
+
if (!accessToken) {
|
|
53
|
+
accessToken = yield this.getToken(true);
|
|
54
|
+
}
|
|
55
|
+
const path = `/api/public/wallet`;
|
|
56
|
+
return this.auth_get(`${path}`, {}, accessToken);
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
throw err;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
getSmartWalletInfo(accessToken) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
try {
|
|
66
|
+
if (!accessToken) {
|
|
67
|
+
accessToken = yield this.getToken(true);
|
|
68
|
+
}
|
|
69
|
+
const path = `/api/public/wallet/smart-account`;
|
|
70
|
+
return this.auth_get(`${path}`, {}, accessToken);
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
throw err;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
getPrivateKey(accessToken) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
try {
|
|
80
|
+
if (!accessToken) {
|
|
81
|
+
accessToken = yield this.getToken(true);
|
|
82
|
+
}
|
|
83
|
+
const path = `/api/public/wallet/private-key`;
|
|
84
|
+
return this.auth_get(`${path}`, {}, accessToken);
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
throw err;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
getMnemonic(accessToken) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
try {
|
|
94
|
+
if (!accessToken) {
|
|
95
|
+
accessToken = yield this.getToken(true);
|
|
96
|
+
}
|
|
97
|
+
const path = `/api/public/wallet/mnemonic`;
|
|
98
|
+
return this.auth_get(`${path}`, {}, accessToken);
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
throw err;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.Wallet = Wallet;
|
|
107
|
+
exports.default = Wallet;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PaytonzSDKBase, PaytonzSDKBaseOptions } from "../PaytonzSDKBase";
|
|
2
|
+
import { SignatureChangePasswordOptions, SignatureCommonOptions, SignatureOnOptions } from "./wallet.interface";
|
|
3
|
+
export interface PaytonzSDKOptions extends PaytonzSDKBaseOptions {
|
|
4
|
+
}
|
|
5
|
+
export declare class WalletSignature extends PaytonzSDKBase {
|
|
6
|
+
constructor(parameters: PaytonzSDKOptions);
|
|
7
|
+
on(options: SignatureOnOptions, accessToken?: string): Promise<boolean>;
|
|
8
|
+
off(options: SignatureCommonOptions, accessToken?: string): Promise<string>;
|
|
9
|
+
status(accessToken?: string): Promise<boolean>;
|
|
10
|
+
download(options: SignatureCommonOptions, accessToken?: string): Promise<string>;
|
|
11
|
+
changePassword(options: SignatureChangePasswordOptions, accessToken?: string): Promise<boolean>;
|
|
12
|
+
passwordStatus(accessToken?: string): Promise<boolean>;
|
|
13
|
+
}
|
|
14
|
+
export default WalletSignature;
|