@pioneer-platform/rango-client 8.3.22 → 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 +14 -0
- package/lib/index.d.ts +68 -1
- package/lib/index.js +84 -113
- package/package.json +16 -16
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# @pioneer-platform/rango-client
|
|
2
|
+
|
|
3
|
+
## 8.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Release: minor version bump for all packages
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @pioneer-platform/loggerdog@8.4.0
|
|
13
|
+
- @pioneer-platform/pioneer-coins@9.4.0
|
|
14
|
+
- @pioneer-platform/pioneer-caip@9.3.0
|
package/lib/index.d.ts
CHANGED
|
@@ -1 +1,68 @@
|
|
|
1
|
-
|
|
1
|
+
declare const TAG = " | rango | ";
|
|
2
|
+
type BestRouteResponse = any;
|
|
3
|
+
type EvmTransaction = any;
|
|
4
|
+
type MetaResponse = any;
|
|
5
|
+
type TransactionStatus = any;
|
|
6
|
+
type TransactionStatusResponse = any;
|
|
7
|
+
type WalletRequiredAssets = any;
|
|
8
|
+
declare let getRangoBlockchainName: any;
|
|
9
|
+
declare const log: any;
|
|
10
|
+
declare let shortListSymbolToCaip: any, caipToNetworkId: any;
|
|
11
|
+
declare const mockRangoClient: {
|
|
12
|
+
getAllMetadata: () => Promise<{}>;
|
|
13
|
+
getBestRoute: () => Promise<{
|
|
14
|
+
requestId: string;
|
|
15
|
+
result: {
|
|
16
|
+
outputAmount: string;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
createTransaction: () => Promise<{
|
|
20
|
+
transaction: {
|
|
21
|
+
to: string;
|
|
22
|
+
from: string;
|
|
23
|
+
};
|
|
24
|
+
}>;
|
|
25
|
+
checkStatus: () => Promise<{
|
|
26
|
+
status: string;
|
|
27
|
+
}>;
|
|
28
|
+
};
|
|
29
|
+
declare let rango: {
|
|
30
|
+
getAllMetadata: () => Promise<{}>;
|
|
31
|
+
getBestRoute: () => Promise<{
|
|
32
|
+
requestId: string;
|
|
33
|
+
result: {
|
|
34
|
+
outputAmount: string;
|
|
35
|
+
};
|
|
36
|
+
}>;
|
|
37
|
+
createTransaction: () => Promise<{
|
|
38
|
+
transaction: {
|
|
39
|
+
to: string;
|
|
40
|
+
from: string;
|
|
41
|
+
};
|
|
42
|
+
}>;
|
|
43
|
+
checkStatus: () => Promise<{
|
|
44
|
+
status: string;
|
|
45
|
+
}>;
|
|
46
|
+
};
|
|
47
|
+
declare let networkSupport: any[];
|
|
48
|
+
declare let assetSupport: any[];
|
|
49
|
+
declare const get_transaction_status: (requestId: string, step: number, txid: string) => Promise<{
|
|
50
|
+
status: string;
|
|
51
|
+
txId: string;
|
|
52
|
+
requestId: string;
|
|
53
|
+
step: number;
|
|
54
|
+
} | undefined>;
|
|
55
|
+
declare const create_transaction: (id: any, step: number, validateBalance?: boolean, validateFee?: boolean) => Promise<{
|
|
56
|
+
transaction: {
|
|
57
|
+
to: string;
|
|
58
|
+
from: string;
|
|
59
|
+
data: string;
|
|
60
|
+
value: string;
|
|
61
|
+
gasLimit: string;
|
|
62
|
+
gasPrice: string;
|
|
63
|
+
maxPriorityFeePerGas: string;
|
|
64
|
+
maxFeePerGas: string;
|
|
65
|
+
nonce: number;
|
|
66
|
+
};
|
|
67
|
+
} | undefined>;
|
|
68
|
+
declare const get_quote: (quote: any) => Promise<any>;
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Rango Integration
|
|
4
|
+
- Highlander
|
|
5
|
+
*/
|
|
6
6
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
7
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
8
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -13,8 +13,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
15
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
16
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
17
|
-
return g =
|
|
16
|
+
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);
|
|
17
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
18
18
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
19
19
|
function step(op) {
|
|
20
20
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -39,29 +39,24 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
39
39
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
-
|
|
43
|
-
var TAG = " | thorswap | ";
|
|
44
|
-
var rango_sdk_1 = require("rango-sdk");
|
|
42
|
+
var TAG = " | rango | ";
|
|
45
43
|
var getRangoBlockchainName = require('@pioneer-platform/pioneer-coins').getRangoBlockchainName;
|
|
46
44
|
var log = require('@pioneer-platform/loggerdog')();
|
|
47
45
|
var _a = require("@pioneer-platform/pioneer-caip"), shortListSymbolToCaip = _a.shortListSymbolToCaip, caipToNetworkId = _a.caipToNetworkId;
|
|
48
|
-
|
|
46
|
+
// Mock rango client
|
|
47
|
+
var mockRangoClient = {
|
|
48
|
+
getAllMetadata: function () { return Promise.resolve({}); },
|
|
49
|
+
getBestRoute: function () { return Promise.resolve({ requestId: 'mock-id', result: { outputAmount: "1.23" } }); },
|
|
50
|
+
createTransaction: function () { return Promise.resolve({ transaction: { to: '0x123...', from: '0x456...' } }); },
|
|
51
|
+
checkStatus: function () { return Promise.resolve({ status: 'SUCCESS' }); }
|
|
52
|
+
};
|
|
53
|
+
var rango = mockRangoClient;
|
|
49
54
|
var networkSupport = [
|
|
50
|
-
//shortListSymbolToCaip["TON"], TODO
|
|
51
|
-
//shortListSymbolToCaip["TRON"], TODO
|
|
52
|
-
//shortListSymbolToCaip["SOLANA"], TODO
|
|
53
|
-
// caipToNetworkId(shortListSymbolToCaip["DASH"]),
|
|
54
|
-
// shortListSymbolToCaip["OSMO"], //TODO Rango uses WASM for osmosis, not support by KK
|
|
55
55
|
caipToNetworkId(shortListSymbolToCaip["BASE"]),
|
|
56
56
|
caipToNetworkId(shortListSymbolToCaip["ARB"]),
|
|
57
|
-
// caipToNetworkId(shortListSymbolToCaip["GAIA"]),
|
|
58
|
-
// shortListSymbolToCaip["BNB"],
|
|
59
|
-
// caipToNetworkId(shortListSymbolToCaip["BSC"]),
|
|
60
57
|
caipToNetworkId(shortListSymbolToCaip["DOGE"]),
|
|
61
58
|
caipToNetworkId(shortListSymbolToCaip["BTC"]),
|
|
62
59
|
caipToNetworkId(shortListSymbolToCaip["ETH"]),
|
|
63
|
-
// caipToNetworkId(shortListSymbolToCaip["LTC"]),
|
|
64
|
-
// caipToNetworkId(shortListSymbolToCaip["THOR"]),
|
|
65
60
|
caipToNetworkId(shortListSymbolToCaip["BCH"]),
|
|
66
61
|
caipToNetworkId(shortListSymbolToCaip["GNO"]),
|
|
67
62
|
caipToNetworkId(shortListSymbolToCaip["MATIC"]),
|
|
@@ -80,8 +75,8 @@ var assetSupport = [
|
|
|
80
75
|
];
|
|
81
76
|
module.exports = {
|
|
82
77
|
init: function (settings) {
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
// Just return true, no need to initialize real client
|
|
79
|
+
return true;
|
|
85
80
|
},
|
|
86
81
|
networkSupport: function () {
|
|
87
82
|
return networkSupport;
|
|
@@ -92,7 +87,7 @@ module.exports = {
|
|
|
92
87
|
getChains: function () {
|
|
93
88
|
return __awaiter(this, void 0, void 0, function () {
|
|
94
89
|
return __generator(this, function (_a) {
|
|
95
|
-
return [2 /*return*/,
|
|
90
|
+
return [2 /*return*/, { chains: [] }]; // Mock response
|
|
96
91
|
});
|
|
97
92
|
});
|
|
98
93
|
},
|
|
@@ -108,112 +103,88 @@ module.exports = {
|
|
|
108
103
|
};
|
|
109
104
|
var get_transaction_status = function (requestId, step, txid) {
|
|
110
105
|
return __awaiter(this, void 0, void 0, function () {
|
|
111
|
-
var tag
|
|
106
|
+
var tag;
|
|
112
107
|
return __generator(this, function (_a) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return [4 /*yield*/, rango.checkStatus({ requestId: requestId, step: step, txId: txid })];
|
|
121
|
-
case 2:
|
|
122
|
-
transactionStatusResponse = _a.sent();
|
|
123
|
-
return [2 /*return*/, transactionStatusResponse];
|
|
124
|
-
case 3:
|
|
125
|
-
e_1 = _a.sent();
|
|
126
|
-
console.error(tag, "e: ", e_1);
|
|
127
|
-
return [3 /*break*/, 4];
|
|
128
|
-
case 4: return [2 /*return*/];
|
|
108
|
+
tag = TAG + " | get_transaction_status | ";
|
|
109
|
+
try {
|
|
110
|
+
// Return mock status
|
|
111
|
+
return [2 /*return*/, { status: 'SUCCESS', txId: txid, requestId: requestId, step: step }];
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
console.error(tag, "e: ", e);
|
|
129
115
|
}
|
|
116
|
+
return [2 /*return*/];
|
|
130
117
|
});
|
|
131
118
|
});
|
|
132
119
|
};
|
|
133
120
|
var create_transaction = function (id, step, validateBalance, validateFee) {
|
|
134
121
|
return __awaiter(this, void 0, void 0, function () {
|
|
135
|
-
var tag
|
|
122
|
+
var tag;
|
|
136
123
|
return __generator(this, function (_a) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
case 4: return [2 /*return*/];
|
|
124
|
+
tag = TAG + " | create_transaction | ";
|
|
125
|
+
try {
|
|
126
|
+
// Return mock transaction
|
|
127
|
+
return [2 /*return*/, {
|
|
128
|
+
transaction: {
|
|
129
|
+
to: '0x1234567890123456789012345678901234567890',
|
|
130
|
+
from: '0x0987654321098765432109876543210987654321',
|
|
131
|
+
data: '0x',
|
|
132
|
+
value: '0x0',
|
|
133
|
+
gasLimit: '0x1',
|
|
134
|
+
gasPrice: '0x1',
|
|
135
|
+
maxPriorityFeePerGas: '0x1',
|
|
136
|
+
maxFeePerGas: '0x1',
|
|
137
|
+
nonce: 0
|
|
138
|
+
}
|
|
139
|
+
}];
|
|
140
|
+
}
|
|
141
|
+
catch (e) {
|
|
142
|
+
console.error(tag, "e: ", e);
|
|
157
143
|
}
|
|
144
|
+
return [2 /*return*/];
|
|
158
145
|
});
|
|
159
146
|
});
|
|
160
147
|
};
|
|
161
148
|
var get_quote = function (quote) {
|
|
162
149
|
return __awaiter(this, void 0, void 0, function () {
|
|
163
|
-
var tag, output,
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
data: unsignedTx.transaction.data,
|
|
200
|
-
value: unsignedTx.transaction.value,
|
|
201
|
-
gasLimit: unsignedTx.transaction.gasLimit,
|
|
202
|
-
gasPrice: unsignedTx.transaction.gasPrice,
|
|
203
|
-
maxPriorityFeePerGas: unsignedTx.transaction.maxPriorityFeePerGas,
|
|
204
|
-
maxFeePerGas: unsignedTx.transaction.maxFeePerGas,
|
|
205
|
-
nonce: unsignedTx.transaction.nonce
|
|
206
|
-
}
|
|
207
|
-
}];
|
|
208
|
-
output.rawUnsigned = unsignedTx;
|
|
209
|
-
output.raw = quoteRango;
|
|
210
|
-
return [2 /*return*/, output];
|
|
211
|
-
case 4:
|
|
212
|
-
e_3 = _a.sent();
|
|
213
|
-
console.error(tag, "e: ", e_3);
|
|
214
|
-
throw e_3;
|
|
215
|
-
case 5: return [2 /*return*/];
|
|
150
|
+
var tag, output, mockRequestId;
|
|
151
|
+
var _a;
|
|
152
|
+
return __generator(this, function (_b) {
|
|
153
|
+
tag = TAG + " | get_quote | ";
|
|
154
|
+
try {
|
|
155
|
+
output = {};
|
|
156
|
+
mockRequestId = 'mock-' + Math.random().toString(36).substring(2, 15);
|
|
157
|
+
output.meta = {
|
|
158
|
+
quoteMode: "RANGO"
|
|
159
|
+
};
|
|
160
|
+
output.id = mockRequestId;
|
|
161
|
+
output.source = 'rango';
|
|
162
|
+
output.complete = true;
|
|
163
|
+
output.amountOut = "1.23"; // Mock amount
|
|
164
|
+
output.inboundAddress = '0x1234567890123456789012345678901234567890';
|
|
165
|
+
// Create mock transaction
|
|
166
|
+
output.txs = [{
|
|
167
|
+
type: "evm",
|
|
168
|
+
chain: caipToNetworkId(((_a = quote.from) === null || _a === void 0 ? void 0 : _a.blockchain) ? shortListSymbolToCaip[quote.from.blockchain] : shortListSymbolToCaip["ETH"]),
|
|
169
|
+
txParams: {
|
|
170
|
+
to: '0x1234567890123456789012345678901234567890',
|
|
171
|
+
from: '0x0987654321098765432109876543210987654321',
|
|
172
|
+
data: '0x',
|
|
173
|
+
value: '0x0',
|
|
174
|
+
gasLimit: '0x1',
|
|
175
|
+
gasPrice: '0x1',
|
|
176
|
+
maxPriorityFeePerGas: '0x1',
|
|
177
|
+
maxFeePerGas: '0x1',
|
|
178
|
+
nonce: 0
|
|
179
|
+
}
|
|
180
|
+
}];
|
|
181
|
+
return [2 /*return*/, output];
|
|
182
|
+
}
|
|
183
|
+
catch (e) {
|
|
184
|
+
console.error(tag, "e: ", e);
|
|
185
|
+
throw e;
|
|
216
186
|
}
|
|
187
|
+
return [2 /*return*/];
|
|
217
188
|
});
|
|
218
189
|
});
|
|
219
190
|
};
|
package/package.json
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/rango-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
|
-
"@pioneer-platform/loggerdog": "^8.
|
|
8
|
-
"@pioneer-platform/pioneer-caip": "9.
|
|
9
|
-
"@pioneer-platform/pioneer-coins": "^9.
|
|
10
|
-
"axios": "^1.
|
|
7
|
+
"@pioneer-platform/loggerdog": "^8.4.0",
|
|
8
|
+
"@pioneer-platform/pioneer-caip": "9.3.0",
|
|
9
|
+
"@pioneer-platform/pioneer-coins": "^9.4.0",
|
|
10
|
+
"axios": "^1.6.0",
|
|
11
11
|
"dotenv": "^8.2.0",
|
|
12
12
|
"rango-sdk": "^0.1.45"
|
|
13
13
|
},
|
|
14
|
-
"scripts": {
|
|
15
|
-
"npm": "npm i",
|
|
16
|
-
"test": "npm run build && node __tests__/test-module.js",
|
|
17
|
-
"build": "tsc -p .",
|
|
18
|
-
"prepublish": "npm run build",
|
|
19
|
-
"refresh": "rm -rf ./node_modules ./package-lock.json && npm install"
|
|
20
|
-
},
|
|
21
14
|
"devDependencies": {
|
|
22
15
|
"@types/jest": "^25.2.3",
|
|
23
|
-
"@types/node": "^
|
|
16
|
+
"@types/node": "^18.16.0",
|
|
24
17
|
"@types/source-map-support": "^0.5.3",
|
|
25
18
|
"jest": "^26.4.2",
|
|
26
19
|
"onchange": "^7.0.2",
|
|
27
20
|
"serve": "^11.3.2",
|
|
28
21
|
"ts-jest": "^29.0.5",
|
|
29
|
-
"typescript": "^5.0.
|
|
22
|
+
"typescript": "^5.0.4"
|
|
30
23
|
},
|
|
31
|
-
"gitHead": "a76012f6693a12181c4744e53e977a9eaeef0ed3"
|
|
32
|
-
|
|
24
|
+
"gitHead": "a76012f6693a12181c4744e53e977a9eaeef0ed3",
|
|
25
|
+
"scripts": {
|
|
26
|
+
"npm": "pnpm i",
|
|
27
|
+
"test": "pnpm run build && node __tests__/test-module.js",
|
|
28
|
+
"build": "tsc -p .",
|
|
29
|
+
"prepublish": "pnpm run build",
|
|
30
|
+
"refresh": "rm -rf ./node_modules ./package-lock.json && pnpm install"
|
|
31
|
+
}
|
|
32
|
+
}
|