@openocean.finance/openocean-sdk 1.0.0 → 1.0.2
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/lib/index.js +2 -20
- package/lib/index.js.LICENSE.txt +109 -2
- package/package.json +2 -2
- package/lib/api/index.js +0 -139
- package/lib/api/vo/RequestVo.js +0 -411
- package/lib/asset/abi/ERC20_abi.js +0 -119
- package/lib/asset/abi/aggregator.js +0 -391
- package/lib/config/Chains.d.ts +0 -16
- package/lib/config/Chains.js +0 -666
- package/lib/config/Wallets.d.ts +0 -45
- package/lib/config/Wallets.js +0 -99
- package/lib/config/index.js +0 -33
- package/lib/swapSdk/Approve.js +0 -342
- package/lib/swapSdk/ConnectWallet.d.ts +0 -8
- package/lib/swapSdk/ConnectWallet.js +0 -339
- package/lib/swapSdk/Nft.d.ts +0 -30
- package/lib/swapSdk/NotoMobile.js +0 -141
- package/lib/swapSdk/RequestVo.js +0 -94
- package/lib/swapSdk/Swap.js +0 -1123
- package/lib/swapSdk/getAllowance.js +0 -97
- package/lib/swapSdk/getBalance.js +0 -280
- package/lib/swapSdk/index.js +0 -257
- package/lib/swapSdk/limitOrder.d.ts +0 -15
- package/lib/swapSdk/qrcode.d.ts +0 -6
- package/lib/swapSdk/qrcode.js +0 -969
- package/lib/utils/ajx.js +0 -150
- package/lib/utils/index.js +0 -369
- package/lib/utils/web3.js +0 -9
|
@@ -1,339 +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.ConnectWallet = void 0;
|
|
40
|
-
var Wallets_1 = require("../config/Wallets");
|
|
41
|
-
var utils_1 = require("../utils");
|
|
42
|
-
var web3_js_1 = require("@solana/web3.js");
|
|
43
|
-
var Chains_1 = require("../config/Chains");
|
|
44
|
-
var NotoMobile_1 = require("./NotoMobile");
|
|
45
|
-
var axios = require('axios');
|
|
46
|
-
var ConnectWallet = /** @class */ (function () {
|
|
47
|
-
function ConnectWallet() {
|
|
48
|
-
}
|
|
49
|
-
ConnectWallet.isChainIdEq = function (wallet, chainId, utilsEht, k) {
|
|
50
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
51
|
-
var key, chainIdNow;
|
|
52
|
-
return __generator(this, function (_a) {
|
|
53
|
-
switch (_a.label) {
|
|
54
|
-
case 0:
|
|
55
|
-
key = k || 0;
|
|
56
|
-
return [4 /*yield*/, utils_1.utils.sleep(1000)];
|
|
57
|
-
case 1:
|
|
58
|
-
_a.sent();
|
|
59
|
-
chainIdNow = utilsEht.hexToNumber(wallet.sdk.currentProvider.chainId);
|
|
60
|
-
if (!(chainId == chainIdNow)) return [3 /*break*/, 2];
|
|
61
|
-
wallet.chainId = chainId;
|
|
62
|
-
return [2 /*return*/, true];
|
|
63
|
-
case 2:
|
|
64
|
-
if (!(key < 3)) return [3 /*break*/, 4];
|
|
65
|
-
return [4 /*yield*/, this.isChainIdEq(wallet, chainId, utilsEht, key + 1)];
|
|
66
|
-
case 3: return [2 /*return*/, _a.sent()];
|
|
67
|
-
case 4: throw new Error('User rejected the request.');
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
ConnectWallet.link = function (reqConnectWalletVo) {
|
|
73
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
74
|
-
var wallet, chain, chainId, selectedChain, qrData, instance_1, account, res, res, res, res, res, res, res, _a, e_1, message, _b, currentProvider, utilsEht;
|
|
75
|
-
return __generator(this, function (_c) {
|
|
76
|
-
switch (_c.label) {
|
|
77
|
-
case 0:
|
|
78
|
-
wallet = Wallets_1.wallets.walletObj[reqConnectWalletVo.walletName];
|
|
79
|
-
if (!wallet)
|
|
80
|
-
wallet = Wallets_1.wallets.walletList.find(function (item) { return item.name == reqConnectWalletVo.walletName; });
|
|
81
|
-
chain = Chains_1.chains.chainObj[reqConnectWalletVo.chain];
|
|
82
|
-
if (!chain)
|
|
83
|
-
throw new Error('Chain error.');
|
|
84
|
-
chainId = chain.chainId;
|
|
85
|
-
selectedChain = chain.key;
|
|
86
|
-
_c.label = 1;
|
|
87
|
-
case 1:
|
|
88
|
-
_c.trys.push([1, 26, , 30]);
|
|
89
|
-
if (!(wallet.type === 'WalletConnect')) return [3 /*break*/, 3];
|
|
90
|
-
wallet.infuraId = '2c7c4d86c2c746c89de722551b606119';
|
|
91
|
-
return [4 /*yield*/, wallet.requestConnect(chainId)];
|
|
92
|
-
case 2:
|
|
93
|
-
_c.sent();
|
|
94
|
-
return [3 /*break*/, 25];
|
|
95
|
-
case 3:
|
|
96
|
-
if (!(wallet.key === 'OntoMobile')) return [3 /*break*/, 6];
|
|
97
|
-
return [4 /*yield*/, axios.get('https://ethapi.openocean.finance/v1/ont/login')];
|
|
98
|
-
case 4:
|
|
99
|
-
qrData = _c.sent();
|
|
100
|
-
wallet.qrData = qrData.data;
|
|
101
|
-
instance_1 = new NotoMobile_1.NotoMobile(qrData.data);
|
|
102
|
-
return [4 /*yield*/, new Promise(function (r, q) {
|
|
103
|
-
instance_1.$on('close', function (result, action, account) {
|
|
104
|
-
if (action === 'login' && result === 'success') {
|
|
105
|
-
r(account);
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
q(action);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
})];
|
|
112
|
-
case 5:
|
|
113
|
-
account = _c.sent();
|
|
114
|
-
wallet.address = account;
|
|
115
|
-
return [3 /*break*/, 25];
|
|
116
|
-
case 6:
|
|
117
|
-
if (!(wallet.key === 'KeplrWallet')) return [3 /*break*/, 8];
|
|
118
|
-
return [4 /*yield*/, wallet.requestCosmosConnect(chainId)];
|
|
119
|
-
case 7:
|
|
120
|
-
res = _c.sent();
|
|
121
|
-
console.log('wallet.requestConnect', res, wallet);
|
|
122
|
-
return [3 /*break*/, 25];
|
|
123
|
-
case 8:
|
|
124
|
-
if (!(selectedChain === 'terra')) return [3 /*break*/, 11];
|
|
125
|
-
if (!!wallet.sdk) return [3 /*break*/, 10];
|
|
126
|
-
return [4 /*yield*/, wallet.requestTerraConnect()];
|
|
127
|
-
case 9:
|
|
128
|
-
res = _c.sent();
|
|
129
|
-
if (res) {
|
|
130
|
-
// this.connect(wallet);
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
// const message = {
|
|
134
|
-
// 'XDEFI Wallet': 'wallet_message_40018',
|
|
135
|
-
// 'Terra Station': 'wallet_message_40015'
|
|
136
|
-
// }[wallet.name];
|
|
137
|
-
// showToast(this.$t(message));
|
|
138
|
-
}
|
|
139
|
-
_c.label = 10;
|
|
140
|
-
case 10: return [3 /*break*/, 25];
|
|
141
|
-
case 11:
|
|
142
|
-
if (!(selectedChain === "solana")) return [3 /*break*/, 13];
|
|
143
|
-
return [4 /*yield*/, wallet.requestSolanaConnect()];
|
|
144
|
-
case 12:
|
|
145
|
-
res = _c.sent();
|
|
146
|
-
wallet.customPublicKey = new web3_js_1.PublicKey(res);
|
|
147
|
-
// "https://api.mainnet-beta.solana.com"
|
|
148
|
-
// "https://solana-mainnet.phantom.tech"
|
|
149
|
-
// "https://rpc.ankr.com/solana"
|
|
150
|
-
// https://solana-api.projectserum.com
|
|
151
|
-
// https://mercuria-fronten-1cd8.mainnet.rpcpool.com/
|
|
152
|
-
// "https://rpc.ankr.com/solana/ad9d7bb3250b29d691330e63e3b46778099aca307af8f5e49b2ebc0a470dd848"
|
|
153
|
-
wallet.connection = new web3_js_1.Connection("https://solana-mainnet.g.alchemy.com/v2/aTdPTJc3R936_mNf4ABtPvl1NFgejm8w");
|
|
154
|
-
if (res) {
|
|
155
|
-
// this.connect(wallet);
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
// const message = {
|
|
159
|
-
// 'Sollet': 'wallet_message_40010',
|
|
160
|
-
// 'Coin98 Wallet': 'wallet_message_40011',
|
|
161
|
-
// 'Phantom': 'wallet_message_40013',
|
|
162
|
-
// 'Clover Wallet': 'wallet_message_40017',
|
|
163
|
-
// 'Slope Wallet': 'wallet_message_40019',
|
|
164
|
-
// 'Solflare Wallet': 'wallet_message_40020',
|
|
165
|
-
// };
|
|
166
|
-
// return {
|
|
167
|
-
// code: 401,
|
|
168
|
-
// message: message
|
|
169
|
-
// }
|
|
170
|
-
}
|
|
171
|
-
return [3 /*break*/, 25];
|
|
172
|
-
case 13:
|
|
173
|
-
if (!(selectedChain === 'tron')) return [3 /*break*/, 15];
|
|
174
|
-
return [4 /*yield*/, wallet.requestTronConnect()];
|
|
175
|
-
case 14:
|
|
176
|
-
res = _c.sent();
|
|
177
|
-
console.log('wallet.requestConnect', res, wallet);
|
|
178
|
-
return [3 /*break*/, 25];
|
|
179
|
-
case 15:
|
|
180
|
-
if (!(selectedChain === 'aptos')) return [3 /*break*/, 17];
|
|
181
|
-
return [4 /*yield*/, wallet.requestAptosConnect()];
|
|
182
|
-
case 16:
|
|
183
|
-
res = _c.sent();
|
|
184
|
-
// wallet.customPublicKey = new PublicKey(res);
|
|
185
|
-
console.log('wallet.requestConnect', res, wallet);
|
|
186
|
-
return [3 /*break*/, 25];
|
|
187
|
-
case 17:
|
|
188
|
-
if (!(selectedChain === 'near')) return [3 /*break*/, 19];
|
|
189
|
-
return [4 /*yield*/, wallet.requestConnect()];
|
|
190
|
-
case 18:
|
|
191
|
-
res = _c.sent();
|
|
192
|
-
console.log('wallet.requestConnect', res, wallet);
|
|
193
|
-
return [3 /*break*/, 25];
|
|
194
|
-
case 19:
|
|
195
|
-
if (!chainId) return [3 /*break*/, 21];
|
|
196
|
-
return [4 /*yield*/, wallet.requestConnect(chainId)];
|
|
197
|
-
case 20:
|
|
198
|
-
_a = _c.sent();
|
|
199
|
-
return [3 /*break*/, 23];
|
|
200
|
-
case 21: return [4 /*yield*/, wallet.requestConnect()];
|
|
201
|
-
case 22:
|
|
202
|
-
_a = _c.sent();
|
|
203
|
-
_c.label = 23;
|
|
204
|
-
case 23:
|
|
205
|
-
res = _a;
|
|
206
|
-
console.log('wallet.requestConnect', res, wallet);
|
|
207
|
-
return [4 /*yield*/, utils_1.utils.sleep(200)];
|
|
208
|
-
case 24:
|
|
209
|
-
_c.sent();
|
|
210
|
-
if (res) {
|
|
211
|
-
// this.connect(wallet);
|
|
212
|
-
}
|
|
213
|
-
_c.label = 25;
|
|
214
|
-
case 25: return [2 /*return*/, { chain: chain, wallet: wallet }];
|
|
215
|
-
case 26:
|
|
216
|
-
e_1 = _c.sent();
|
|
217
|
-
message = e_1.message;
|
|
218
|
-
_b = wallet.sdk || {}, currentProvider = _b.currentProvider, utilsEht = _b.utils;
|
|
219
|
-
if (reqConnectWalletVo.noSwitch) {
|
|
220
|
-
throw new Error('No Switch');
|
|
221
|
-
}
|
|
222
|
-
if (!(message === "40006" && currentProvider)) return [3 /*break*/, 28];
|
|
223
|
-
return [4 /*yield*/, this.linkAddOrSwitch(reqConnectWalletVo, wallet, chain)];
|
|
224
|
-
case 27: return [2 /*return*/, _c.sent()];
|
|
225
|
-
case 28: throw new Error(message);
|
|
226
|
-
case 29: return [3 /*break*/, 30];
|
|
227
|
-
case 30: return [2 /*return*/];
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
};
|
|
232
|
-
ConnectWallet.linkAddOrSwitch = function (reqConnectWalletVo, wallet, chain) {
|
|
233
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
234
|
-
var _a, currentProvider, utilsEht, chainId, params, address, address, switchError_1, address, address, error_1, address, address;
|
|
235
|
-
return __generator(this, function (_b) {
|
|
236
|
-
switch (_b.label) {
|
|
237
|
-
case 0:
|
|
238
|
-
_a = wallet.sdk || {}, currentProvider = _a.currentProvider, utilsEht = _a.utils;
|
|
239
|
-
chainId = chain.chainId;
|
|
240
|
-
params = Chains_1.chains.ethereumChainParams[reqConnectWalletVo.chain];
|
|
241
|
-
if (!params) return [3 /*break*/, 23];
|
|
242
|
-
_b.label = 1;
|
|
243
|
-
case 1:
|
|
244
|
-
_b.trys.push([1, 9, , 22]);
|
|
245
|
-
return [4 /*yield*/, currentProvider.request({
|
|
246
|
-
method: 'wallet_switchEthereumChain',
|
|
247
|
-
params: [{ chainId: params[0].chainId }],
|
|
248
|
-
})];
|
|
249
|
-
case 2:
|
|
250
|
-
_b.sent();
|
|
251
|
-
return [4 /*yield*/, this.isChainIdEq(wallet, chainId, utilsEht)];
|
|
252
|
-
case 3:
|
|
253
|
-
if (!_b.sent()) return [3 /*break*/, 8];
|
|
254
|
-
if (!(wallet.type === 'WalletConnect')) return [3 /*break*/, 5];
|
|
255
|
-
return [4 /*yield*/, wallet.sdk.eth.getAccounts()];
|
|
256
|
-
case 4:
|
|
257
|
-
address = (_b.sent())[0];
|
|
258
|
-
wallet.address = address;
|
|
259
|
-
return [3 /*break*/, 7];
|
|
260
|
-
case 5: return [4 /*yield*/, wallet.sdk.eth.requestAccounts()];
|
|
261
|
-
case 6:
|
|
262
|
-
address = (_b.sent())[0];
|
|
263
|
-
wallet.address = address;
|
|
264
|
-
_b.label = 7;
|
|
265
|
-
case 7: return [2 /*return*/, { chain: chain, wallet: wallet }];
|
|
266
|
-
case 8: return [3 /*break*/, 22];
|
|
267
|
-
case 9:
|
|
268
|
-
switchError_1 = _b.sent();
|
|
269
|
-
console.log('wallet_switchEthereumChain errer');
|
|
270
|
-
console.log(JSON.stringify(switchError_1));
|
|
271
|
-
if (!(switchError_1.code === 4902 || (switchError_1.data && switchError_1.data.originalError && switchError_1.data.originalError.code == 4902))) return [3 /*break*/, 20];
|
|
272
|
-
_b.label = 10;
|
|
273
|
-
case 10:
|
|
274
|
-
_b.trys.push([10, 18, , 19]);
|
|
275
|
-
return [4 /*yield*/, currentProvider.request({
|
|
276
|
-
method: "wallet_addEthereumChain",
|
|
277
|
-
params: params
|
|
278
|
-
})];
|
|
279
|
-
case 11:
|
|
280
|
-
_b.sent();
|
|
281
|
-
return [4 /*yield*/, this.isChainIdEq(wallet, chainId, utilsEht)];
|
|
282
|
-
case 12:
|
|
283
|
-
if (!_b.sent()) return [3 /*break*/, 17];
|
|
284
|
-
if (!(wallet.type === 'WalletConnect')) return [3 /*break*/, 14];
|
|
285
|
-
return [4 /*yield*/, wallet.sdk.eth.getAccounts()];
|
|
286
|
-
case 13:
|
|
287
|
-
address = (_b.sent())[0];
|
|
288
|
-
wallet.address = address;
|
|
289
|
-
return [3 /*break*/, 16];
|
|
290
|
-
case 14: return [4 /*yield*/, wallet.sdk.eth.requestAccounts()];
|
|
291
|
-
case 15:
|
|
292
|
-
address = (_b.sent())[0];
|
|
293
|
-
wallet.address = address;
|
|
294
|
-
_b.label = 16;
|
|
295
|
-
case 16: return [2 /*return*/, { chain: chain, wallet: wallet }];
|
|
296
|
-
case 17: return [3 /*break*/, 19];
|
|
297
|
-
case 18:
|
|
298
|
-
error_1 = _b.sent();
|
|
299
|
-
console.log('wallet_addEthereumChain Error', JSON.stringify(error_1));
|
|
300
|
-
throw new Error('Network error');
|
|
301
|
-
case 19: return [3 /*break*/, 21];
|
|
302
|
-
case 20: throw new Error(switchError_1);
|
|
303
|
-
case 21: return [3 /*break*/, 22];
|
|
304
|
-
case 22: return [3 /*break*/, 32];
|
|
305
|
-
case 23:
|
|
306
|
-
if (!(chainId == '1' || chainId == '3' || chainId == '4')) return [3 /*break*/, 31];
|
|
307
|
-
return [4 /*yield*/, currentProvider.request({
|
|
308
|
-
method: 'wallet_switchEthereumChain',
|
|
309
|
-
params: [{
|
|
310
|
-
chainId: utilsEht.toHex(chainId)
|
|
311
|
-
}],
|
|
312
|
-
})];
|
|
313
|
-
case 24:
|
|
314
|
-
_b.sent();
|
|
315
|
-
return [4 /*yield*/, this.isChainIdEq(wallet, chainId, utilsEht)];
|
|
316
|
-
case 25:
|
|
317
|
-
if (!_b.sent()) return [3 /*break*/, 30];
|
|
318
|
-
if (!(wallet.type === 'WalletConnect')) return [3 /*break*/, 27];
|
|
319
|
-
return [4 /*yield*/, wallet.sdk.eth.getAccounts()];
|
|
320
|
-
case 26:
|
|
321
|
-
address = (_b.sent())[0];
|
|
322
|
-
wallet.address = address;
|
|
323
|
-
return [3 /*break*/, 29];
|
|
324
|
-
case 27: return [4 /*yield*/, wallet.sdk.eth.requestAccounts()];
|
|
325
|
-
case 28:
|
|
326
|
-
address = (_b.sent())[0];
|
|
327
|
-
wallet.address = address;
|
|
328
|
-
_b.label = 29;
|
|
329
|
-
case 29: return [2 /*return*/, { chain: chain, wallet: wallet }];
|
|
330
|
-
case 30: return [3 /*break*/, 32];
|
|
331
|
-
case 31: throw new Error('Network error');
|
|
332
|
-
case 32: return [2 /*return*/];
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
});
|
|
336
|
-
};
|
|
337
|
-
return ConnectWallet;
|
|
338
|
-
}());
|
|
339
|
-
exports.ConnectWallet = ConnectWallet;
|
package/lib/swapSdk/Nft.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export declare class Nft {
|
|
2
|
-
private getDataCallback;
|
|
3
|
-
private errorCallback;
|
|
4
|
-
private transactionHashCallback;
|
|
5
|
-
private receiptCallback;
|
|
6
|
-
private successCallback;
|
|
7
|
-
wallet: any;
|
|
8
|
-
chain: any;
|
|
9
|
-
constructor(wallet: any, chain: any);
|
|
10
|
-
sendSolanaNFTTransaction(swapParams: any, swapType?: string): Promise<string>;
|
|
11
|
-
sendBuyNFTTransaction(swapParams: any, gasPrice: any): Promise<unknown>;
|
|
12
|
-
signOrderMessageByNFTrade(signatureData: any): Promise<unknown>;
|
|
13
|
-
sendSellNFTTransaction(swapParams: any, data: any): Promise<string | {
|
|
14
|
-
market: any;
|
|
15
|
-
order: any;
|
|
16
|
-
signature: any;
|
|
17
|
-
} | undefined>;
|
|
18
|
-
sendOfferNFTTransaction(swapParams: any, data: any): Promise<string | {
|
|
19
|
-
market: any;
|
|
20
|
-
order: any;
|
|
21
|
-
signature: any;
|
|
22
|
-
} | undefined>;
|
|
23
|
-
sendCancelNFTTransaction(swapParams: any, gasPrice: any): Promise<unknown>;
|
|
24
|
-
signOrder(orderParameters: any): Promise<unknown>;
|
|
25
|
-
signOrderMessage(clientMessage: any): Promise<unknown>;
|
|
26
|
-
signMessageX2Y2(): Promise<string>;
|
|
27
|
-
WrapperETH(amount: any): Promise<any>;
|
|
28
|
-
unWrapperETH(amount: any): Promise<any>;
|
|
29
|
-
on(events: string, callback: Function): this;
|
|
30
|
-
}
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NotoMobile = void 0;
|
|
4
|
-
var QRCode = require("./qrcode").QRCode;
|
|
5
|
-
// import { QRCode } from "./qrcode";
|
|
6
|
-
var axios = require('axios');
|
|
7
|
-
var NotoMobile = /** @class */ (function () {
|
|
8
|
-
function NotoMobile(qrData) {
|
|
9
|
-
this.time = 0;
|
|
10
|
-
var id = qrData.id, qrCode = qrData.qrCode;
|
|
11
|
-
this.id = id;
|
|
12
|
-
this.qrCode = JSON.stringify(qrCode);
|
|
13
|
-
this.setCloseStyle();
|
|
14
|
-
this.show();
|
|
15
|
-
}
|
|
16
|
-
NotoMobile.prototype.$on = function (key, callBack) {
|
|
17
|
-
if (key == 'close')
|
|
18
|
-
this.close = callBack;
|
|
19
|
-
};
|
|
20
|
-
NotoMobile.prototype.loop = function () {
|
|
21
|
-
var _this = this;
|
|
22
|
-
axios.get('https://ethapi.openocean.finance/v1/ont/qrcode/result/' + this.id).then(function (res) {
|
|
23
|
-
var _a = res.data, action = _a.action, state = _a.state, account = _a.account;
|
|
24
|
-
if (state === '0') {
|
|
25
|
-
_this.close('success', action, account);
|
|
26
|
-
_this.cancel();
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
_this.time++;
|
|
30
|
-
if (_this.time > 120) {
|
|
31
|
-
_this.close('error', 'over time');
|
|
32
|
-
_this.cancel();
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
_this.outTime = setTimeout(function () {
|
|
36
|
-
_this.loop();
|
|
37
|
-
}, 1000);
|
|
38
|
-
}
|
|
39
|
-
}).catch(function (e) {
|
|
40
|
-
console.log(e);
|
|
41
|
-
_this.close('error', e);
|
|
42
|
-
_this.cancel();
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
NotoMobile.prototype.setCloseStyle = function () {
|
|
46
|
-
var k = document.getElementById('qrcodeStyle09');
|
|
47
|
-
if (k)
|
|
48
|
-
return;
|
|
49
|
-
var style = document.createElement('style');
|
|
50
|
-
style.type = "text/css";
|
|
51
|
-
style.id = 'qrcodeStyle09';
|
|
52
|
-
document.head.appendChild(style);
|
|
53
|
-
style.innerHTML = "\n #qrcodeBox div,#qrcodeBox span{box-sizing: border-box;}\n #qrcodeBox #close8 :hover{cursor:pointer;opacity:0.5;}\n #qrcodeBox #close8 >div:before,#qrcodeBox #close8 >div:after{\n content: '';position: absolute;height: 2px;width: 100%;top: 50%;left: 0;margin-top: -1px;background: #000;border-radius:5px;\n }\n #qrcodeBox #close8 >div:before{transform: rotate(45deg);}\n #qrcodeBox #close8 >div:after{transform: rotate(-45deg);}\n #qrcodeBox #qrcode img{ display:inline-block;}\n ";
|
|
54
|
-
};
|
|
55
|
-
NotoMobile.prototype.createQrcode = function (w) {
|
|
56
|
-
var _this = this;
|
|
57
|
-
if (!document.getElementById("qrcode")) {
|
|
58
|
-
setTimeout(function () {
|
|
59
|
-
_this.createQrcode(w);
|
|
60
|
-
}, 100);
|
|
61
|
-
}
|
|
62
|
-
var qrcode = new QRCode(document.getElementById("qrcode"), {
|
|
63
|
-
text: this.qrCode,
|
|
64
|
-
width: w,
|
|
65
|
-
height: w,
|
|
66
|
-
colorDark: "#000000",
|
|
67
|
-
colorLight: "#ffffff",
|
|
68
|
-
correctLevel: QRCode.CorrectLevel.H
|
|
69
|
-
});
|
|
70
|
-
this.loop();
|
|
71
|
-
};
|
|
72
|
-
NotoMobile.prototype.show = function () {
|
|
73
|
-
var _this = this;
|
|
74
|
-
var page_width = document.documentElement.scrollWidth;
|
|
75
|
-
var page_height = document.documentElement.scrollHeight;
|
|
76
|
-
var b_width = document.documentElement.clientWidth;
|
|
77
|
-
var b_height = document.documentElement.clientHeight;
|
|
78
|
-
this.mask = document.createElement("div");
|
|
79
|
-
this.mask.id = "mask";
|
|
80
|
-
this.mask.style.width = page_width + "px";
|
|
81
|
-
this.mask.style.height = page_height + "px";
|
|
82
|
-
this.mask.style.position = 'absolute';
|
|
83
|
-
this.mask.style.background = 'rgba(37,41,46,.95)';
|
|
84
|
-
this.mask.style.zIndex = '999';
|
|
85
|
-
this.mask.style.top = '0';
|
|
86
|
-
this.mask.style.left = '0';
|
|
87
|
-
document.body.appendChild(this.mask);
|
|
88
|
-
var width = 0;
|
|
89
|
-
var height = 0;
|
|
90
|
-
var headHeight = 60;
|
|
91
|
-
var headHeight1 = 50;
|
|
92
|
-
var qrcodeWidth = 0;
|
|
93
|
-
var padding = 50;
|
|
94
|
-
// pc
|
|
95
|
-
if (b_width > b_height) {
|
|
96
|
-
height = b_height;
|
|
97
|
-
width = b_height - headHeight1 - headHeight - headHeight / 2;
|
|
98
|
-
qrcodeWidth = width - padding * 2;
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
// phone
|
|
102
|
-
padding = 30;
|
|
103
|
-
headHeight = 50;
|
|
104
|
-
headHeight1 = 50;
|
|
105
|
-
width = b_width - 60;
|
|
106
|
-
height = width + headHeight1 + headHeight + headHeight / 2;
|
|
107
|
-
qrcodeWidth = width - padding * 2;
|
|
108
|
-
}
|
|
109
|
-
this.qrcodeBox = document.createElement("div");
|
|
110
|
-
this.qrcodeBox.id = "qrcodeBox";
|
|
111
|
-
this.qrcodeBox.style.left = (b_width - width) / 2 + "px";
|
|
112
|
-
this.qrcodeBox.style.top = (b_height - height) / 2 + "px";
|
|
113
|
-
this.qrcodeBox.style.height = height + "px";
|
|
114
|
-
this.qrcodeBox.style.width = width + "px";
|
|
115
|
-
this.qrcodeBox.style.position = 'absolute';
|
|
116
|
-
this.qrcodeBox.style.zIndex = '10000';
|
|
117
|
-
// qrcodeBox.style.padding = '0 30px 0 30px'
|
|
118
|
-
this.qrcodeBox.innerHTML =
|
|
119
|
-
"<div style=\"font-size: 22px;height:100%;padding-top:".concat(headHeight, "px;padding-bottom:").concat(headHeight / 2, "px;position:relative;\">\n <div style=\"color:#ffffff;line-height: ").concat(headHeight, "px;position:absolute;top:0;left:0;width:100%\">\n <img style=\"vertical-align: middle; width: 30px;height:30px\" src=\"https://cloudstorage.openocean.finance/openocean/img/icon-onto-white.b4f61a37.svg\"/>\n <span style=\"vertical-align: middle;\">Onto Mobile</span>\n <div id=\"close8\" style=\"margin-top: 20px;position: relative;float: right;background: #fff;border-radius: 100px;width:25px;height:25px;padding:5px;display: inline-block;\">\n <div style=\"position: relative;width:100%;height:100%;display: block;\"></div>\n </div>\n </div>\n <div id=\"qrcodeb\" style=\"padding-top:").concat(headHeight1, "px;position:relative;height:100%;width:100%;background:#fff;text-align: center;\">\n <div style=\"position:absolute;top:0;left:0;width:100%;font-size:").concat(width > 400 ? 18 : 14, "px;color:rgba(60,66,82,.6);line-height: ").concat(headHeight1 + padding, "px;\">Scan QR code with a Onto wallet</div>\n <div style=\"display: flex;justify-content: center;align-items: center;height:100%;height:100%;\">\n <div id=\"qrcode\"></div>\n </div>\n </div>\n </div>\n ");
|
|
120
|
-
document.body.appendChild(this.qrcodeBox);
|
|
121
|
-
var qrcodeb = document.getElementById("qrcodeb");
|
|
122
|
-
qrcodeb.style.borderRadius = "20px";
|
|
123
|
-
qrcodeb.style.boxSizing = 'border-box';
|
|
124
|
-
this.createQrcode(qrcodeWidth);
|
|
125
|
-
var close = window.document.getElementById("close8");
|
|
126
|
-
close.onclick = function () {
|
|
127
|
-
_this.cancel();
|
|
128
|
-
};
|
|
129
|
-
this.mask.onclick = function () {
|
|
130
|
-
_this.cancel();
|
|
131
|
-
};
|
|
132
|
-
};
|
|
133
|
-
NotoMobile.prototype.cancel = function () {
|
|
134
|
-
this.time = 0;
|
|
135
|
-
this.outTime ? clearTimeout(this.outTime) : '';
|
|
136
|
-
document.body.removeChild(this.mask);
|
|
137
|
-
document.body.removeChild(this.qrcodeBox);
|
|
138
|
-
};
|
|
139
|
-
return NotoMobile;
|
|
140
|
-
}());
|
|
141
|
-
exports.NotoMobile = NotoMobile;
|
package/lib/swapSdk/RequestVo.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
-
};
|
|
23
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.ReqApproveVo = exports.ReqAllowanceVo = exports.ReqBalanceVo = exports.ReqConnectWalletVo = void 0;
|
|
25
|
-
var class_validator_1 = require("class-validator");
|
|
26
|
-
var class_transformer_1 = require("class-transformer");
|
|
27
|
-
var RequestVo_1 = require("../api/vo/RequestVo");
|
|
28
|
-
var ReqConnectWalletVo = /** @class */ (function (_super) {
|
|
29
|
-
__extends(ReqConnectWalletVo, _super);
|
|
30
|
-
function ReqConnectWalletVo() {
|
|
31
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
32
|
-
}
|
|
33
|
-
__decorate([
|
|
34
|
-
(0, class_validator_1.IsNotEmpty)({ message: 'Wallet name cannot be empty' })
|
|
35
|
-
// @IsEnum(WalletNames, { message: 'Wallet name error' })
|
|
36
|
-
,
|
|
37
|
-
(0, class_transformer_1.Type)(function () { return String; })
|
|
38
|
-
], ReqConnectWalletVo.prototype, "walletName", void 0);
|
|
39
|
-
return ReqConnectWalletVo;
|
|
40
|
-
}(RequestVo_1.ChainName));
|
|
41
|
-
exports.ReqConnectWalletVo = ReqConnectWalletVo;
|
|
42
|
-
var ReqBalanceVo = /** @class */ (function (_super) {
|
|
43
|
-
__extends(ReqBalanceVo, _super);
|
|
44
|
-
function ReqBalanceVo() {
|
|
45
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
46
|
-
}
|
|
47
|
-
__decorate([
|
|
48
|
-
(0, class_validator_1.IsNotEmpty)({ message: 'TokenAddressOrSymbol cannot be empty' }),
|
|
49
|
-
(0, class_transformer_1.Type)(function () { return String; })
|
|
50
|
-
], ReqBalanceVo.prototype, "tokenAddressOrSymbol", void 0);
|
|
51
|
-
__decorate([
|
|
52
|
-
(0, class_validator_1.IsNotEmpty)({ message: 'Decimals cannot be empty' }),
|
|
53
|
-
(0, class_transformer_1.Type)(function () { return Number; })
|
|
54
|
-
], ReqBalanceVo.prototype, "decimals", void 0);
|
|
55
|
-
return ReqBalanceVo;
|
|
56
|
-
}(RequestVo_1.ChainName));
|
|
57
|
-
exports.ReqBalanceVo = ReqBalanceVo;
|
|
58
|
-
var ReqAllowanceVo = /** @class */ (function (_super) {
|
|
59
|
-
__extends(ReqAllowanceVo, _super);
|
|
60
|
-
function ReqAllowanceVo() {
|
|
61
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
62
|
-
}
|
|
63
|
-
__decorate([
|
|
64
|
-
(0, class_validator_1.IsNotEmpty)({ message: 'ApproveContract cannot be empty' })
|
|
65
|
-
], ReqAllowanceVo.prototype, "approveContract", void 0);
|
|
66
|
-
__decorate([
|
|
67
|
-
(0, class_validator_1.IsNotEmpty)({ message: 'TokenAddress cannot be empty' }),
|
|
68
|
-
(0, class_transformer_1.Type)(function () { return String; })
|
|
69
|
-
], ReqAllowanceVo.prototype, "tokenAddress", void 0);
|
|
70
|
-
__decorate([
|
|
71
|
-
(0, class_validator_1.IsNotEmpty)({ message: 'Decimals cannot be empty' }),
|
|
72
|
-
(0, class_transformer_1.Type)(function () { return Number; })
|
|
73
|
-
], ReqAllowanceVo.prototype, "decimals", void 0);
|
|
74
|
-
return ReqAllowanceVo;
|
|
75
|
-
}(RequestVo_1.ChainName));
|
|
76
|
-
exports.ReqAllowanceVo = ReqAllowanceVo;
|
|
77
|
-
var ReqApproveVo = /** @class */ (function (_super) {
|
|
78
|
-
__extends(ReqApproveVo, _super);
|
|
79
|
-
function ReqApproveVo() {
|
|
80
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
81
|
-
}
|
|
82
|
-
__decorate([
|
|
83
|
-
(0, class_validator_1.IsNotEmpty)({ message: 'Token addresses cannot be empty' }),
|
|
84
|
-
(0, class_validator_1.MinLength)(30, { message: 'Token addresses length error' }),
|
|
85
|
-
(0, class_transformer_1.Type)(function () { return String; })
|
|
86
|
-
], ReqApproveVo.prototype, "tokenAddress", void 0);
|
|
87
|
-
__decorate([
|
|
88
|
-
(0, class_validator_1.IsNotEmpty)({ message: 'Contract addresses cannot be empty' }),
|
|
89
|
-
(0, class_validator_1.MinLength)(30, { message: 'Contract addresses length error' }),
|
|
90
|
-
(0, class_transformer_1.Type)(function () { return String; })
|
|
91
|
-
], ReqApproveVo.prototype, "contractAddress", void 0);
|
|
92
|
-
return ReqApproveVo;
|
|
93
|
-
}(RequestVo_1.ChainName));
|
|
94
|
-
exports.ReqApproveVo = ReqApproveVo;
|