@pioneer-platform/changelly-client 8.3.19 → 8.4.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/CHANGELOG.md +13 -0
- package/lib/index.js +2 -2
- package/package.json +15 -15
- package/lib/client.d.ts +0 -19
- package/lib/client.js +0 -101
package/CHANGELOG.md
ADDED
package/lib/index.js
CHANGED
|
@@ -12,8 +12,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
12
12
|
});
|
|
13
13
|
};
|
|
14
14
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
15
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
16
|
-
return g =
|
|
15
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
16
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
17
17
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
18
18
|
function step(op) {
|
|
19
19
|
if (f) throw new TypeError("Generator is already executing.");
|
package/package.json
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/changelly-client",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.0",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@bithighlander/changelly": "^1.0.1",
|
|
8
|
-
"@pioneer-platform/loggerdog": "^8.
|
|
9
|
-
"@pioneer-platform/pioneer-caip": "^9.
|
|
10
|
-
"axios": "^1.
|
|
8
|
+
"@pioneer-platform/loggerdog": "^8.4.0",
|
|
9
|
+
"@pioneer-platform/pioneer-caip": "^9.3.0",
|
|
10
|
+
"axios": "^1.6.0",
|
|
11
11
|
"dotenv": "^8.2.0",
|
|
12
12
|
"jayson": "^4.1.0",
|
|
13
13
|
"micro-ftch": "^0.3.1"
|
|
14
14
|
},
|
|
15
|
-
"scripts": {
|
|
16
|
-
"npm": "npm i",
|
|
17
|
-
"test": "npm run build && node __tests__/test-module.js",
|
|
18
|
-
"build": "tsc -p .",
|
|
19
|
-
"prepublish": "npm run build",
|
|
20
|
-
"refresh": "rm -rf ./node_modules ./package-lock.json && npm install"
|
|
21
|
-
},
|
|
22
15
|
"devDependencies": {
|
|
23
16
|
"@types/jest": "^25.2.3",
|
|
24
|
-
"@types/node": "^
|
|
17
|
+
"@types/node": "^18.16.0",
|
|
25
18
|
"@types/source-map-support": "^0.5.3",
|
|
26
19
|
"jest": "^26.4.2",
|
|
27
20
|
"onchange": "^7.0.2",
|
|
28
21
|
"serve": "^11.3.2",
|
|
29
22
|
"source-map-support": "^0.5.19",
|
|
30
23
|
"ts-jest": "^29.0.5",
|
|
31
|
-
"typescript": "^5.0.
|
|
24
|
+
"typescript": "^5.0.4"
|
|
32
25
|
},
|
|
33
|
-
"gitHead": "a76012f6693a12181c4744e53e977a9eaeef0ed3"
|
|
34
|
-
|
|
26
|
+
"gitHead": "a76012f6693a12181c4744e53e977a9eaeef0ed3",
|
|
27
|
+
"scripts": {
|
|
28
|
+
"npm": "pnpm i",
|
|
29
|
+
"test": "pnpm run build && node __tests__/test-module.js",
|
|
30
|
+
"build": "tsc -p .",
|
|
31
|
+
"prepublish": "pnpm run build",
|
|
32
|
+
"refresh": "rm -rf ./node_modules ./package-lock.json && pnpm install"
|
|
33
|
+
}
|
|
34
|
+
}
|
package/lib/client.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
type CallbackFunction = (err: Error | null, response?: any) => void;
|
|
2
|
-
declare class Changelly {
|
|
3
|
-
private apiKey;
|
|
4
|
-
private apiSecret;
|
|
5
|
-
private client;
|
|
6
|
-
private _socket;
|
|
7
|
-
constructor(apiKey: string, apiSecret: string);
|
|
8
|
-
private _id;
|
|
9
|
-
private _sign;
|
|
10
|
-
private _request;
|
|
11
|
-
getCurrencies(callback: CallbackFunction): void;
|
|
12
|
-
createTransaction(from: string, to: string, address: string, amount: number, extraId: string | null, callback: CallbackFunction): void;
|
|
13
|
-
getMinAmount(from: string, to: string, callback: CallbackFunction): void;
|
|
14
|
-
getExchangeAmount(from: string, to: string, amount: number, callback: CallbackFunction): void;
|
|
15
|
-
getTransactions(limit: number, offset: number, currency: string, address: string, extraId: string, callback: CallbackFunction): void;
|
|
16
|
-
getStatus(id: string, callback: CallbackFunction): void;
|
|
17
|
-
on(channel: string, callback: (...args: any[]) => void): void;
|
|
18
|
-
}
|
|
19
|
-
export = Changelly;
|
package/lib/client.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var io = __importStar(require("socket.io-client"));
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
var jayson = __importStar(require("jayson"));
|
|
28
|
-
var crypto = __importStar(require("crypto"));
|
|
29
|
-
var Changelly = /** @class */ (function () {
|
|
30
|
-
function Changelly(apiKey, apiSecret) {
|
|
31
|
-
var _this = this;
|
|
32
|
-
this.apiKey = apiKey;
|
|
33
|
-
this.apiSecret = apiSecret;
|
|
34
|
-
// @ts-ignore
|
|
35
|
-
this.client = jayson.client.https('https://api.changelly.com');
|
|
36
|
-
this._socket = io.connect('https://api.changelly.com', {
|
|
37
|
-
reconnection: true,
|
|
38
|
-
reconnectionDelay: 1000,
|
|
39
|
-
reconnectionDelayMax: 5000,
|
|
40
|
-
reconnectionAttempts: Infinity,
|
|
41
|
-
});
|
|
42
|
-
this._socket.on('connect', function () {
|
|
43
|
-
var message = { "Login": {} };
|
|
44
|
-
_this._socket.emit('subscribe', {
|
|
45
|
-
apiKey: _this.apiKey,
|
|
46
|
-
sign: _this._sign(message),
|
|
47
|
-
message: message
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
Changelly.prototype._id = function () {
|
|
52
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
53
|
-
var r = Math.random() * 16 | 0;
|
|
54
|
-
var v = c == 'x' ? r : (r & 0x3 | 0x8);
|
|
55
|
-
return v.toString(16);
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
Changelly.prototype._sign = function (message) {
|
|
59
|
-
return crypto
|
|
60
|
-
.createHmac('sha512', this.apiSecret)
|
|
61
|
-
.update(JSON.stringify(message))
|
|
62
|
-
.digest('hex');
|
|
63
|
-
};
|
|
64
|
-
Changelly.prototype._request = function (method, options, callback) {
|
|
65
|
-
var id = this._id();
|
|
66
|
-
var message = jayson.utils.request(method, options, id);
|
|
67
|
-
this.client.options.headers = {
|
|
68
|
-
'api-key': this.apiKey,
|
|
69
|
-
'sign': this._sign(message)
|
|
70
|
-
};
|
|
71
|
-
this.client.request(method, options, id, callback);
|
|
72
|
-
};
|
|
73
|
-
Changelly.prototype.getCurrencies = function (callback) {
|
|
74
|
-
this._request('getCurrencies', {}, callback);
|
|
75
|
-
};
|
|
76
|
-
Changelly.prototype.createTransaction = function (from, to, address, amount, extraId, callback) {
|
|
77
|
-
var params = { from: from, to: to, address: address, amount: amount, extraId: extraId };
|
|
78
|
-
this._request('createTransaction', params, callback);
|
|
79
|
-
};
|
|
80
|
-
Changelly.prototype.getMinAmount = function (from, to, callback) {
|
|
81
|
-
var params = { from: from, to: to };
|
|
82
|
-
this._request('getMinAmount', params, callback);
|
|
83
|
-
};
|
|
84
|
-
Changelly.prototype.getExchangeAmount = function (from, to, amount, callback) {
|
|
85
|
-
var params = { from: from, to: to, amount: amount };
|
|
86
|
-
this._request('getExchangeAmount', params, callback);
|
|
87
|
-
};
|
|
88
|
-
Changelly.prototype.getTransactions = function (limit, offset, currency, address, extraId, callback) {
|
|
89
|
-
var params = { limit: limit, offset: offset, currency: currency, address: address, extraId: extraId };
|
|
90
|
-
this._request('getTransactions', params, callback);
|
|
91
|
-
};
|
|
92
|
-
Changelly.prototype.getStatus = function (id, callback) {
|
|
93
|
-
var params = { id: id };
|
|
94
|
-
this._request('getStatus', params, callback);
|
|
95
|
-
};
|
|
96
|
-
Changelly.prototype.on = function (channel, callback) {
|
|
97
|
-
this._socket.on(channel, callback);
|
|
98
|
-
};
|
|
99
|
-
return Changelly;
|
|
100
|
-
}());
|
|
101
|
-
module.exports = Changelly;
|