@openocean.finance/openocean-sdk 0.1.88 → 0.1.90

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 (60) hide show
  1. package/lib/index.js +2 -20
  2. package/lib/index.js.LICENSE.txt +145 -0
  3. package/package.json +3 -2
  4. package/lib/api/index.js +0 -136
  5. package/lib/api/vo/RequestVo.js +0 -401
  6. package/lib/asset/abi/ERC20_abi.js +0 -119
  7. package/lib/asset/abi/aggregator.js +0 -391
  8. package/lib/config/Chains.js +0 -508
  9. package/lib/config/Wallets.js +0 -89
  10. package/lib/config/index.js +0 -11
  11. package/lib/swapSdk/Approve.js +0 -227
  12. package/lib/swapSdk/ConnectWallet.js +0 -312
  13. package/lib/swapSdk/NotoMobile.js +0 -141
  14. package/lib/swapSdk/RequestVo.js +0 -94
  15. package/lib/swapSdk/Swap.js +0 -739
  16. package/lib/swapSdk/getAllowance.js +0 -97
  17. package/lib/swapSdk/getBalance.js +0 -220
  18. package/lib/swapSdk/index.js +0 -277
  19. package/lib/swapSdk/limitOrder.js +0 -225
  20. package/lib/swapSdk/qrcode.d.ts +0 -6
  21. package/lib/swapSdk/qrcode.js +0 -969
  22. package/lib/utils/ajx.js +0 -150
  23. package/lib/utils/index.js +0 -91
  24. package/lib/utils/limit-order-sdk/abi/ERC20ABI.json +0 -222
  25. package/lib/utils/limit-order-sdk/abi/LimitOrderProtocol.json +0 -1506
  26. package/lib/utils/limit-order-sdk/connector/private-key-provider.connector.d.ts +0 -10
  27. package/lib/utils/limit-order-sdk/connector/private-key-provider.connector.js +0 -36
  28. package/lib/utils/limit-order-sdk/connector/provider.connector.d.ts +0 -1
  29. package/lib/utils/limit-order-sdk/connector/provider.connector.js +0 -2
  30. package/lib/utils/limit-order-sdk/connector/web3-provider.connector.d.ts +0 -9
  31. package/lib/utils/limit-order-sdk/connector/web3-provider.connector.js +0 -38
  32. package/lib/utils/limit-order-sdk/erc20.facade.d.ts +0 -7
  33. package/lib/utils/limit-order-sdk/erc20.facade.js +0 -19
  34. package/lib/utils/limit-order-sdk/index.d.ts +0 -1
  35. package/lib/utils/limit-order-sdk/index.js +0 -14
  36. package/lib/utils/limit-order-sdk/limit-order-predicate.builder.d.ts +0 -12
  37. package/lib/utils/limit-order-sdk/limit-order-predicate.builder.js +0 -60
  38. package/lib/utils/limit-order-sdk/limit-order-protocol.const.d.ts +0 -18
  39. package/lib/utils/limit-order-sdk/limit-order-protocol.const.js +0 -45
  40. package/lib/utils/limit-order-sdk/limit-order-protocol.facade.d.ts +0 -26
  41. package/lib/utils/limit-order-sdk/limit-order-protocol.facade.js +0 -180
  42. package/lib/utils/limit-order-sdk/limit-order.builder.d.ts +0 -101
  43. package/lib/utils/limit-order-sdk/limit-order.builder.js +0 -120
  44. package/lib/utils/limit-order-sdk/model/abi.model.d.ts +0 -1
  45. package/lib/utils/limit-order-sdk/model/abi.model.js +0 -2
  46. package/lib/utils/limit-order-sdk/model/eip712.model.d.ts +0 -1
  47. package/lib/utils/limit-order-sdk/model/eip712.model.js +0 -2
  48. package/lib/utils/limit-order-sdk/model/limit-order-protocol.model.d.ts +0 -3
  49. package/lib/utils/limit-order-sdk/model/limit-order-protocol.model.js +0 -38
  50. package/lib/utils/limit-order-sdk/utils/get-rpc-code.d.ts +0 -2
  51. package/lib/utils/limit-order-sdk/utils/get-rpc-code.js +0 -28
  52. package/lib/utils/limit-order-sdk/utils/limit-order-rfq.const.d.ts +0 -89
  53. package/lib/utils/limit-order-sdk/utils/limit-order-rfq.const.js +0 -140
  54. package/lib/utils/limit-order-sdk/utils/limit-order-rfq.helpers.d.ts +0 -10
  55. package/lib/utils/limit-order-sdk/utils/limit-order-rfq.helpers.js +0 -254
  56. package/lib/utils/limit-order-sdk/utils/limit-order-rfq.model.d.ts +0 -1
  57. package/lib/utils/limit-order-sdk/utils/limit-order-rfq.model.js +0 -2
  58. package/lib/utils/limit-order-sdk/utils/limit-order-rfq.utils.d.ts +0 -2
  59. package/lib/utils/limit-order-sdk/utils/limit-order-rfq.utils.js +0 -82
  60. package/lib/utils/web3.js +0 -9
package/lib/utils/ajx.js DELETED
@@ -1,150 +0,0 @@
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 __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.post = exports.get = exports.validateReq = void 0;
40
- var class_validator_1 = require("class-validator");
41
- var class_transformer_1 = require("class-transformer");
42
- var axios = require('axios');
43
- function validateReq(option, vo) {
44
- return __awaiter(this, void 0, void 0, function () {
45
- var reqAllowanceVo, errors;
46
- return __generator(this, function (_a) {
47
- switch (_a.label) {
48
- case 0:
49
- reqAllowanceVo = (0, class_transformer_1.plainToClass)(vo, option);
50
- return [4 /*yield*/, (0, class_validator_1.validate)(reqAllowanceVo)];
51
- case 1:
52
- errors = _a.sent();
53
- if (errors.length) {
54
- return [2 /*return*/, errors.reduce(function (o, n) {
55
- Object.keys(n.constraints).forEach(function (key) {
56
- o.push(n.constraints[key]);
57
- });
58
- return o;
59
- }, []).join(', ')];
60
- }
61
- return [2 /*return*/];
62
- }
63
- });
64
- });
65
- }
66
- exports.validateReq = validateReq;
67
- function get(url, option, vo) {
68
- return __awaiter(this, void 0, void 0, function () {
69
- var _this = this;
70
- return __generator(this, function (_a) {
71
- return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
72
- var errors, error_1;
73
- return __generator(this, function (_a) {
74
- switch (_a.label) {
75
- case 0:
76
- _a.trys.push([0, 2, , 3]);
77
- return [4 /*yield*/, validateReq(option, vo)];
78
- case 1:
79
- errors = _a.sent();
80
- if (errors) {
81
- reject(errors);
82
- }
83
- else {
84
- axios({
85
- method: 'get',
86
- url: "".concat(url),
87
- params: option
88
- })
89
- .then(function (response) {
90
- resolve(response.data);
91
- })
92
- .catch(function (error) {
93
- reject(error ? error.message : 'An unknown error');
94
- });
95
- }
96
- return [3 /*break*/, 3];
97
- case 2:
98
- error_1 = _a.sent();
99
- reject(error_1 || 'An unknown error');
100
- return [3 /*break*/, 3];
101
- case 3: return [2 /*return*/];
102
- }
103
- });
104
- }); })];
105
- });
106
- });
107
- }
108
- exports.get = get;
109
- function post(url, option, vo) {
110
- return __awaiter(this, void 0, void 0, function () {
111
- var _this = this;
112
- return __generator(this, function (_a) {
113
- return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
114
- var errors, error_2;
115
- return __generator(this, function (_a) {
116
- switch (_a.label) {
117
- case 0:
118
- _a.trys.push([0, 2, , 3]);
119
- return [4 /*yield*/, validateReq(option, vo)];
120
- case 1:
121
- errors = _a.sent();
122
- if (errors) {
123
- reject(errors);
124
- }
125
- else {
126
- axios({
127
- method: 'post',
128
- url: "".concat(url),
129
- data: option
130
- })
131
- .then(function (response) {
132
- resolve(response.data);
133
- })
134
- .catch(function (error) {
135
- reject(error ? error.message : 'An unknown error');
136
- });
137
- }
138
- return [3 /*break*/, 3];
139
- case 2:
140
- error_2 = _a.sent();
141
- reject(error_2 || 'An unknown error');
142
- return [3 /*break*/, 3];
143
- case 3: return [2 /*return*/];
144
- }
145
- });
146
- }); })];
147
- });
148
- });
149
- }
150
- exports.post = post;
@@ -1,91 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isPc = exports.utils = exports.Utils = exports.ChainNames = void 0;
7
- var axios = require('axios');
8
- var bignumber_js_1 = __importDefault(require("bignumber.js"));
9
- var ChainNames;
10
- (function (ChainNames) {
11
- ChainNames[ChainNames["eth"] = 0] = "eth";
12
- ChainNames[ChainNames["solana"] = 1] = "solana";
13
- ChainNames[ChainNames["ont"] = 2] = "ont";
14
- ChainNames[ChainNames["terra"] = 3] = "terra";
15
- ChainNames[ChainNames["tron"] = 4] = "tron";
16
- ChainNames[ChainNames["osmosis"] = 5] = "osmosis";
17
- ChainNames[ChainNames["sifchain"] = 6] = "sifchain";
18
- ChainNames[ChainNames["ropsten"] = 7] = "ropsten";
19
- ChainNames[ChainNames["bsc"] = 8] = "bsc";
20
- ChainNames[ChainNames["okex"] = 9] = "okex";
21
- ChainNames[ChainNames["polygon"] = 10] = "polygon";
22
- ChainNames[ChainNames["fantom"] = 11] = "fantom";
23
- ChainNames[ChainNames["heco"] = 12] = "heco";
24
- ChainNames[ChainNames["avax"] = 13] = "avax";
25
- ChainNames[ChainNames["arbitrum"] = 14] = "arbitrum";
26
- ChainNames[ChainNames["xdai"] = 15] = "xdai";
27
- ChainNames[ChainNames["optimism"] = 16] = "optimism";
28
- ChainNames[ChainNames["boba"] = 17] = "boba";
29
- ChainNames[ChainNames["moonriver"] = 18] = "moonriver";
30
- ChainNames[ChainNames["aurora"] = 19] = "aurora";
31
- ChainNames[ChainNames["cronos"] = 20] = "cronos";
32
- ChainNames[ChainNames["cosmos"] = 21] = "cosmos";
33
- ChainNames[ChainNames["harmony"] = 22] = "harmony";
34
- ChainNames[ChainNames["bsctest"] = 23] = "bsctest";
35
- })(ChainNames = exports.ChainNames || (exports.ChainNames = {}));
36
- var Utils = /** @class */ (function () {
37
- function Utils() {
38
- }
39
- Utils.prototype.sleep = function (interval) {
40
- return new Promise(function (resolve) {
41
- setTimeout(resolve, interval);
42
- });
43
- };
44
- Utils.prototype.getShift = function (a, b) {
45
- return new bignumber_js_1.default(a).shiftedBy(Number(b)).toFixed();
46
- };
47
- Utils.prototype.decimals2Amount = function (amount, decimals) {
48
- return this.getShift(amount, -decimals);
49
- };
50
- Utils.prototype.amount2Decimals = function (amount, decimals) {
51
- return this.getFixed(this.getShift(amount, decimals), 0);
52
- };
53
- Utils.prototype.getFixed = function (val, fixed, trailingZeros) {
54
- var numStr = val || '0';
55
- if (trailingZeros) {
56
- return new bignumber_js_1.default(numStr).toFixed(fixed);
57
- }
58
- return new bignumber_js_1.default(numStr).decimalPlaces(fixed).toString();
59
- };
60
- Utils.prototype.toFixed = function (n, k, z) {
61
- if (isNaN(n)) {
62
- return 0;
63
- }
64
- if (!k)
65
- k = 4;
66
- var a = Math.pow(10, k);
67
- if (Number(n) < 0) {
68
- a = Math.ceil(Number(n) * a) / a;
69
- }
70
- else {
71
- a = Math.floor(Number(n) * a) / a;
72
- }
73
- if (!z) {
74
- return a;
75
- }
76
- else {
77
- return a.toFixed(k);
78
- }
79
- };
80
- return Utils;
81
- }());
82
- exports.Utils = Utils;
83
- exports.utils = new Utils();
84
- function isPc() {
85
- var userAgent = navigator.userAgent, Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
86
- console.log('userAgent:', userAgent);
87
- return Agents.some(function (i) {
88
- return userAgent.includes(i);
89
- });
90
- }
91
- exports.isPc = isPc;
@@ -1,222 +0,0 @@
1
- [
2
- {
3
- "constant": true,
4
- "inputs": [],
5
- "name": "name",
6
- "outputs": [
7
- {
8
- "name": "",
9
- "type": "string"
10
- }
11
- ],
12
- "payable": false,
13
- "stateMutability": "view",
14
- "type": "function"
15
- },
16
- {
17
- "constant": false,
18
- "inputs": [
19
- {
20
- "name": "_spender",
21
- "type": "address"
22
- },
23
- {
24
- "name": "_value",
25
- "type": "uint256"
26
- }
27
- ],
28
- "name": "approve",
29
- "outputs": [
30
- {
31
- "name": "",
32
- "type": "bool"
33
- }
34
- ],
35
- "payable": false,
36
- "stateMutability": "nonpayable",
37
- "type": "function"
38
- },
39
- {
40
- "constant": true,
41
- "inputs": [],
42
- "name": "totalSupply",
43
- "outputs": [
44
- {
45
- "name": "",
46
- "type": "uint256"
47
- }
48
- ],
49
- "payable": false,
50
- "stateMutability": "view",
51
- "type": "function"
52
- },
53
- {
54
- "constant": false,
55
- "inputs": [
56
- {
57
- "name": "_from",
58
- "type": "address"
59
- },
60
- {
61
- "name": "_to",
62
- "type": "address"
63
- },
64
- {
65
- "name": "_value",
66
- "type": "uint256"
67
- }
68
- ],
69
- "name": "transferFrom",
70
- "outputs": [
71
- {
72
- "name": "",
73
- "type": "bool"
74
- }
75
- ],
76
- "payable": false,
77
- "stateMutability": "nonpayable",
78
- "type": "function"
79
- },
80
- {
81
- "constant": true,
82
- "inputs": [],
83
- "name": "decimals",
84
- "outputs": [
85
- {
86
- "name": "",
87
- "type": "uint8"
88
- }
89
- ],
90
- "payable": false,
91
- "stateMutability": "view",
92
- "type": "function"
93
- },
94
- {
95
- "constant": true,
96
- "inputs": [
97
- {
98
- "name": "_owner",
99
- "type": "address"
100
- }
101
- ],
102
- "name": "balanceOf",
103
- "outputs": [
104
- {
105
- "name": "balance",
106
- "type": "uint256"
107
- }
108
- ],
109
- "payable": false,
110
- "stateMutability": "view",
111
- "type": "function"
112
- },
113
- {
114
- "constant": true,
115
- "inputs": [],
116
- "name": "symbol",
117
- "outputs": [
118
- {
119
- "name": "",
120
- "type": "string"
121
- }
122
- ],
123
- "payable": false,
124
- "stateMutability": "view",
125
- "type": "function"
126
- },
127
- {
128
- "constant": false,
129
- "inputs": [
130
- {
131
- "name": "_to",
132
- "type": "address"
133
- },
134
- {
135
- "name": "_value",
136
- "type": "uint256"
137
- }
138
- ],
139
- "name": "transfer",
140
- "outputs": [
141
- {
142
- "name": "",
143
- "type": "bool"
144
- }
145
- ],
146
- "payable": false,
147
- "stateMutability": "nonpayable",
148
- "type": "function"
149
- },
150
- {
151
- "constant": true,
152
- "inputs": [
153
- {
154
- "name": "_owner",
155
- "type": "address"
156
- },
157
- {
158
- "name": "_spender",
159
- "type": "address"
160
- }
161
- ],
162
- "name": "allowance",
163
- "outputs": [
164
- {
165
- "name": "",
166
- "type": "uint256"
167
- }
168
- ],
169
- "payable": false,
170
- "stateMutability": "view",
171
- "type": "function"
172
- },
173
- {
174
- "payable": true,
175
- "stateMutability": "payable",
176
- "type": "fallback"
177
- },
178
- {
179
- "anonymous": false,
180
- "inputs": [
181
- {
182
- "indexed": true,
183
- "name": "owner",
184
- "type": "address"
185
- },
186
- {
187
- "indexed": true,
188
- "name": "spender",
189
- "type": "address"
190
- },
191
- {
192
- "indexed": false,
193
- "name": "value",
194
- "type": "uint256"
195
- }
196
- ],
197
- "name": "Approval",
198
- "type": "event"
199
- },
200
- {
201
- "anonymous": false,
202
- "inputs": [
203
- {
204
- "indexed": true,
205
- "name": "from",
206
- "type": "address"
207
- },
208
- {
209
- "indexed": true,
210
- "name": "to",
211
- "type": "address"
212
- },
213
- {
214
- "indexed": false,
215
- "name": "value",
216
- "type": "uint256"
217
- }
218
- ],
219
- "name": "Transfer",
220
- "type": "event"
221
- }
222
- ]