@openocean.finance/openocean-sdk 1.2.33 → 1.2.35

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 (38) hide show
  1. package/lib/api/index.js +205 -0
  2. package/lib/api/vo/RequestVo.js +401 -0
  3. package/lib/asset/abi/ERC20_abi.js +119 -0
  4. package/lib/asset/abi/aggregator.js +391 -0
  5. package/lib/config/index.js +33 -0
  6. package/lib/index.d.ts +1 -1
  7. package/lib/index.js +50 -2
  8. package/lib/swapSdk/Approve.js +349 -0
  9. package/lib/swapSdk/NotoMobile.js +144 -0
  10. package/lib/swapSdk/RequestVo.js +94 -0
  11. package/lib/swapSdk/Swap.js +1159 -0
  12. package/lib/swapSdk/getAllowance.js +98 -0
  13. package/lib/swapSdk/getBalance.js +280 -0
  14. package/lib/swapSdk/index.js +257 -0
  15. package/lib/swapSdk/qrcode.js +969 -0
  16. package/lib/utils/ajx.js +153 -0
  17. package/lib/utils/index.js +367 -0
  18. package/lib/utils/web3.js +9 -0
  19. package/lib/v1/abis/ERC20.js +22 -0
  20. package/lib/v1/abis/IUniswapV2Pair.js +1434 -0
  21. package/lib/v1/constants.js +71 -0
  22. package/lib/v1/entities/currency.js +39 -0
  23. package/lib/v1/entities/fractions/currencyAmount.js +83 -0
  24. package/lib/v1/entities/fractions/fraction.js +109 -0
  25. package/lib/v1/entities/fractions/index.js +21 -0
  26. package/lib/v1/entities/fractions/percent.js +37 -0
  27. package/lib/v1/entities/fractions/price.js +90 -0
  28. package/lib/v1/entities/fractions/tokenAmount.js +43 -0
  29. package/lib/v1/entities/index.js +22 -0
  30. package/lib/v1/entities/pair.js +210 -0
  31. package/lib/v1/entities/route.js +43 -0
  32. package/lib/v1/entities/token.js +87 -0
  33. package/lib/v1/entities/trade.js +336 -0
  34. package/lib/v1/errors.js +56 -0
  35. package/lib/v1/fetcher.js +140 -0
  36. package/lib/v1/router.js +97 -0
  37. package/lib/v1/utils.js +87 -0
  38. package/package.json +2 -2
@@ -0,0 +1,349 @@
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 (g && (g = 0, op[0] && (_ = 0)), _) 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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.Approve = void 0;
43
+ var web3_1 = __importDefault(require("web3"));
44
+ var ethers_1 = require("ethers");
45
+ var bignumber_js_1 = __importDefault(require("bignumber.js"));
46
+ var providerEth = new ethers_1.ethers.providers.JsonRpcProvider({
47
+ url: "https://rpc.ankr.com/eth"
48
+ });
49
+ var Approve = /** @class */ (function () {
50
+ function Approve(contract, wallet) {
51
+ this.errorCallback = function () { };
52
+ this.transactionHashCallback = function () { };
53
+ this.receiptCallback = function () { };
54
+ this.successCallback = function () { };
55
+ this.contract = contract;
56
+ this.wallet = wallet;
57
+ }
58
+ Approve.prototype.send = function (reqApproveVo, address) {
59
+ return __awaiter(this, void 0, void 0, function () {
60
+ var web3, data, safeTxHash, e_1, hash, e_2, _a, _b, gasAmount, error_1, json;
61
+ var _this = this;
62
+ return __generator(this, function (_c) {
63
+ switch (_c.label) {
64
+ case 0:
65
+ this.account = address;
66
+ this.key = 0;
67
+ this.approveContract = reqApproveVo.approveContract;
68
+ this.tokenAddress = reqApproveVo.tokenAddress;
69
+ if (String(reqApproveVo.gasPrice).indexOf('.') > -1 || Number(reqApproveVo.gasPrice) < Math.pow(10, 6)) {
70
+ reqApproveVo.gasPrice = new bignumber_js_1.default(reqApproveVo.gasPrice + '').times(Math.pow(10, 9)).toFixed(0);
71
+ }
72
+ if (reqApproveVo.decimals) {
73
+ reqApproveVo.amount = (0, bignumber_js_1.default)(reqApproveVo.amount).times(Math.pow(10, reqApproveVo.decimals)).toFixed(0);
74
+ }
75
+ if (!(this.wallet.key === "GnosisSafeWallet")) return [3 /*break*/, 5];
76
+ web3 = new web3_1.default();
77
+ data = web3.eth.abi.encodeFunctionCall({
78
+ inputs: [
79
+ {
80
+ name: "spender",
81
+ type: "address",
82
+ },
83
+ {
84
+ name: "value",
85
+ type: "uint256",
86
+ },
87
+ ],
88
+ name: "approve",
89
+ type: "function",
90
+ }, [this.approveContract, reqApproveVo.amount]);
91
+ console.log("data", this.approveContract, reqApproveVo.amount, data);
92
+ _c.label = 1;
93
+ case 1:
94
+ _c.trys.push([1, 3, , 4]);
95
+ return [4 /*yield*/, this.wallet.sdk.txs.send({
96
+ txs: [
97
+ {
98
+ to: this.tokenAddress,
99
+ value: 0,
100
+ data: data,
101
+ },
102
+ ],
103
+ })];
104
+ case 2:
105
+ safeTxHash = (_c.sent()).safeTxHash;
106
+ console.log("safeTxHash", safeTxHash);
107
+ setTimeout(function () {
108
+ console.log("successCallback");
109
+ _this.successCallback(1);
110
+ }, 3000);
111
+ return [3 /*break*/, 4];
112
+ case 3:
113
+ e_1 = _c.sent();
114
+ setTimeout(function () {
115
+ _this.errorCallback(e_1);
116
+ }, 500);
117
+ return [3 /*break*/, 4];
118
+ case 4: return [3 /*break*/, 23];
119
+ case 5:
120
+ if (!(this.wallet.key === "LedgerWallet")) return [3 /*break*/, 6];
121
+ this.signEthTransactionByLedger(reqApproveVo, address);
122
+ return [3 /*break*/, 23];
123
+ case 6:
124
+ if (!(this.wallet.key === "TronLink")) return [3 /*break*/, 14];
125
+ this.approveContract = "TRtQA3D9BFRLFw3rajKBziAof2eAWkAL7B";
126
+ _c.label = 7;
127
+ case 7:
128
+ _c.trys.push([7, 12, , 13]);
129
+ hash = "";
130
+ this.amount = reqApproveVo.amount + "";
131
+ if (!([
132
+ "TMwFHYXLJaRUPeW6421aqXL4ZEzPRFGkGT",
133
+ "TCFLL5dx5ZJdKnWuesXxi1VPwjLVmWZZy9",
134
+ "TKfjV9RNKJJCqPvBtK8L7Knykh7DNWvnYt",
135
+ "TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR"
136
+ ].indexOf(this.tokenAddress) >= 0)) return [3 /*break*/, 9];
137
+ return [4 /*yield*/, this.contract.methods
138
+ .approve(this.approveContract)
139
+ .send({ feeLimit: 100000000 })];
140
+ case 8:
141
+ hash = _c.sent();
142
+ return [3 /*break*/, 11];
143
+ case 9:
144
+ console.log('send approve', this.amount);
145
+ return [4 /*yield*/, this.contract.methods
146
+ .approve(this.approveContract, this.amount)
147
+ .send({ feeLimit: 100000000 })];
148
+ case 10:
149
+ hash = _c.sent();
150
+ _c.label = 11;
151
+ case 11:
152
+ console.log('hash', hash);
153
+ this.successCallback(1);
154
+ return [3 /*break*/, 13];
155
+ case 12:
156
+ e_2 = _c.sent();
157
+ this.errorCallback(e_2);
158
+ return [3 /*break*/, 13];
159
+ case 13: return [3 /*break*/, 23];
160
+ case 14:
161
+ if (!!reqApproveVo.amount) return [3 /*break*/, 16];
162
+ _a = reqApproveVo;
163
+ return [4 /*yield*/, this.contract.methods.totalSupply().call()];
164
+ case 15:
165
+ _a.amount = _c.sent();
166
+ _c.label = 16;
167
+ case 16:
168
+ if (!(this.tokenAddress === "0xfa17b330bcc4e7f3e2456996d89a5a54ab044831")) return [3 /*break*/, 18];
169
+ _b = reqApproveVo;
170
+ return [4 /*yield*/, this.contract.methods
171
+ .balanceOf(this.account)
172
+ .call()];
173
+ case 17:
174
+ _b.amount = _c.sent();
175
+ if (Number(reqApproveVo.amount) == 0) {
176
+ this.errorCallback("Insufficient Balance.");
177
+ return [2 /*return*/];
178
+ }
179
+ _c.label = 18;
180
+ case 18:
181
+ this.amount = reqApproveVo.amount + "";
182
+ gasAmount = "80000";
183
+ _c.label = 19;
184
+ case 19:
185
+ _c.trys.push([19, 21, , 22]);
186
+ return [4 /*yield*/, this.contract.methods
187
+ .approve(this.approveContract, this.amount)
188
+ .estimateGas({
189
+ from: this.account,
190
+ })];
191
+ case 20:
192
+ gasAmount = _c.sent();
193
+ return [3 /*break*/, 22];
194
+ case 21:
195
+ error_1 = _c.sent();
196
+ setTimeout(function () {
197
+ _this.errorCallback(error_1);
198
+ }, 500);
199
+ return [2 /*return*/];
200
+ case 22:
201
+ json = {
202
+ from: address,
203
+ };
204
+ if (reqApproveVo.gasPrice) {
205
+ json.gasPrice = reqApproveVo.gasPrice;
206
+ }
207
+ this.contract.methods
208
+ .approve(this.approveContract, this.amount)
209
+ .send(json)
210
+ .on("error", function (error) {
211
+ console.log('eee error1111', error);
212
+ _this.errorCallback(error);
213
+ })
214
+ .on("transactionHash", function (transactionHash) {
215
+ console.log('eee transactionHash');
216
+ _this.transactionHashCallback(transactionHash);
217
+ })
218
+ .on("receipt", function (receipt) {
219
+ console.log('eee receipt');
220
+ _this.receiptCallback(receipt);
221
+ _this.getSuccess(receipt);
222
+ });
223
+ _c.label = 23;
224
+ case 23: return [2 /*return*/];
225
+ }
226
+ });
227
+ });
228
+ };
229
+ Approve.prototype.on = function (events, callback) {
230
+ if (events === "error") {
231
+ this.errorCallback = callback;
232
+ }
233
+ else if (events === "transactionHash") {
234
+ this.transactionHashCallback = callback;
235
+ }
236
+ else if (events === "receipt") {
237
+ this.receiptCallback = callback;
238
+ }
239
+ else if (events === "success") {
240
+ this.successCallback = callback;
241
+ }
242
+ return this;
243
+ };
244
+ Approve.prototype.signEthTransactionByLedger = function (reqApproveVo, address) {
245
+ return __awaiter(this, void 0, void 0, function () {
246
+ var web3, data, account, myWallet, gasPrice, txParams, serializedTx, signature, signedTx, hash, e_3;
247
+ var _a;
248
+ var _this = this;
249
+ return __generator(this, function (_b) {
250
+ switch (_b.label) {
251
+ case 0:
252
+ _b.trys.push([0, 5, , 6]);
253
+ web3 = new web3_1.default();
254
+ data = web3.eth.abi.encodeFunctionCall({
255
+ inputs: [
256
+ {
257
+ name: "spender",
258
+ type: "address",
259
+ },
260
+ {
261
+ name: "value",
262
+ type: "uint256",
263
+ },
264
+ ],
265
+ name: "approve",
266
+ type: "function",
267
+ }, [reqApproveVo.approveContract, reqApproveVo.amount]);
268
+ console.log("data", reqApproveVo.approveContract, reqApproveVo.amount, data);
269
+ console.log('signEthTransactionByLedger params', reqApproveVo);
270
+ account = address;
271
+ myWallet = this.wallet.sdk;
272
+ return [4 /*yield*/, providerEth.getGasPrice()];
273
+ case 1:
274
+ gasPrice = _b.sent();
275
+ _a = {
276
+ to: this.tokenAddress,
277
+ gasPrice: gasPrice._hex,
278
+ gasLimit: web3_1.default.utils.numberToHex(50000 * 2)
279
+ };
280
+ return [4 /*yield*/, providerEth.getTransactionCount(account, "latest")];
281
+ case 2:
282
+ txParams = (_a.nonce = _b.sent(),
283
+ _a.chainId = 1,
284
+ _a.data = data,
285
+ _a.value = web3_1.default.utils.numberToHex(0),
286
+ _a);
287
+ serializedTx = ethers_1.ethers.utils.serializeTransaction(txParams).slice(2);
288
+ console.log('signEthTransactionByLedger serializeTransaction', txParams, serializedTx);
289
+ return [4 /*yield*/, myWallet.signTransaction("44'/60'/0'/0/0", serializedTx)];
290
+ case 3:
291
+ signature = _b.sent();
292
+ console.log('signEthTransactionByLedger signature1', signature);
293
+ signature.r = "0x" + signature.r;
294
+ signature.s = "0x" + signature.s;
295
+ signature.v = parseInt("0x" + signature.v);
296
+ signature.from = account;
297
+ console.log('signEthTransactionByLedger signature2', signature);
298
+ signedTx = ethers_1.ethers.utils.serializeTransaction(txParams, signature);
299
+ console.log('signEthTransactionByLedger signedTx', signedTx);
300
+ return [4 /*yield*/, providerEth.sendTransaction(signedTx)];
301
+ case 4:
302
+ hash = (_b.sent()).hash;
303
+ console.log('signEthTransactionByLedger hash', hash);
304
+ setTimeout(function () {
305
+ console.log("successCallback");
306
+ _this.successCallback(1);
307
+ }, 3000);
308
+ return [3 /*break*/, 6];
309
+ case 5:
310
+ e_3 = _b.sent();
311
+ setTimeout(function () {
312
+ _this.errorCallback(e_3);
313
+ }, 500);
314
+ return [3 /*break*/, 6];
315
+ case 6: return [2 /*return*/];
316
+ }
317
+ });
318
+ });
319
+ };
320
+ Approve.prototype.getSuccess = function (receipt) {
321
+ return __awaiter(this, void 0, void 0, function () {
322
+ var balance;
323
+ var _this = this;
324
+ return __generator(this, function (_a) {
325
+ switch (_a.label) {
326
+ case 0: return [4 /*yield*/, this.contract.methods
327
+ .allowance(this.account, this.approveContract)
328
+ .call()];
329
+ case 1:
330
+ balance = _a.sent();
331
+ this.key++;
332
+ if (this.key > 20)
333
+ return [2 /*return*/];
334
+ if (balance >= Number(this.amount)) {
335
+ this.successCallback(balance);
336
+ }
337
+ else {
338
+ setTimeout(function () {
339
+ _this.getSuccess(receipt);
340
+ }, 2000);
341
+ }
342
+ return [2 /*return*/];
343
+ }
344
+ });
345
+ });
346
+ };
347
+ return Approve;
348
+ }());
349
+ exports.Approve = Approve;
@@ -0,0 +1,144 @@
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.NotoMobile = void 0;
7
+ var QRCode = require("./qrcode").QRCode;
8
+ // import { QRCode } from "./qrcode";
9
+ var axios_1 = __importDefault(require("axios"));
10
+ var NotoMobile = /** @class */ (function () {
11
+ function NotoMobile(qrData) {
12
+ this.time = 0;
13
+ var id = qrData.id, qrCode = qrData.qrCode;
14
+ this.id = id;
15
+ this.qrCode = JSON.stringify(qrCode);
16
+ this.setCloseStyle();
17
+ this.show();
18
+ }
19
+ NotoMobile.prototype.$on = function (key, callBack) {
20
+ if (key == 'close')
21
+ this.close = callBack;
22
+ };
23
+ NotoMobile.prototype.loop = function () {
24
+ var _this = this;
25
+ axios_1.default.get('https://ethapi.openocean.finance/v1/ont/qrcode/result/' + this.id).then(function (res) {
26
+ var _a = res.data, action = _a.action, state = _a.state, account = _a.account;
27
+ if (state === '0') {
28
+ _this.close('success', action, account);
29
+ _this.cancel();
30
+ }
31
+ else {
32
+ _this.time++;
33
+ if (_this.time > 120) {
34
+ _this.close('error', 'over time');
35
+ _this.cancel();
36
+ return;
37
+ }
38
+ _this.outTime = setTimeout(function () {
39
+ _this.loop();
40
+ }, 1000);
41
+ }
42
+ }).catch(function (e) {
43
+ console.log(e);
44
+ _this.close('error', e);
45
+ _this.cancel();
46
+ });
47
+ };
48
+ NotoMobile.prototype.setCloseStyle = function () {
49
+ var k = document.getElementById('qrcodeStyle09');
50
+ if (k)
51
+ return;
52
+ var style = document.createElement('style');
53
+ style.type = "text/css";
54
+ style.id = 'qrcodeStyle09';
55
+ document.head.appendChild(style);
56
+ 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 ";
57
+ };
58
+ NotoMobile.prototype.createQrcode = function (w) {
59
+ var _this = this;
60
+ if (!document.getElementById("qrcode")) {
61
+ setTimeout(function () {
62
+ _this.createQrcode(w);
63
+ }, 100);
64
+ }
65
+ var qrcode = new QRCode(document.getElementById("qrcode"), {
66
+ text: this.qrCode,
67
+ width: w,
68
+ height: w,
69
+ colorDark: "#000000",
70
+ colorLight: "#ffffff",
71
+ correctLevel: QRCode.CorrectLevel.H
72
+ });
73
+ this.loop();
74
+ };
75
+ NotoMobile.prototype.show = function () {
76
+ var _this = this;
77
+ var page_width = document.documentElement.scrollWidth;
78
+ var page_height = document.documentElement.scrollHeight;
79
+ var b_width = document.documentElement.clientWidth;
80
+ var b_height = document.documentElement.clientHeight;
81
+ this.mask = document.createElement("div");
82
+ this.mask.id = "mask";
83
+ this.mask.style.width = page_width + "px";
84
+ this.mask.style.height = page_height + "px";
85
+ this.mask.style.position = 'absolute';
86
+ this.mask.style.background = 'rgba(37,41,46,.95)';
87
+ this.mask.style.zIndex = '999';
88
+ this.mask.style.top = '0';
89
+ this.mask.style.left = '0';
90
+ document.body.appendChild(this.mask);
91
+ var width = 0;
92
+ var height = 0;
93
+ var headHeight = 60;
94
+ var headHeight1 = 50;
95
+ var qrcodeWidth = 0;
96
+ var padding = 50;
97
+ // pc
98
+ if (b_width > b_height) {
99
+ height = b_height;
100
+ width = b_height - headHeight1 - headHeight - headHeight / 2;
101
+ qrcodeWidth = width - padding * 2;
102
+ }
103
+ else {
104
+ // phone
105
+ padding = 30;
106
+ headHeight = 50;
107
+ headHeight1 = 50;
108
+ width = b_width - 60;
109
+ height = width + headHeight1 + headHeight + headHeight / 2;
110
+ qrcodeWidth = width - padding * 2;
111
+ }
112
+ this.qrcodeBox = document.createElement("div");
113
+ this.qrcodeBox.id = "qrcodeBox";
114
+ this.qrcodeBox.style.left = (b_width - width) / 2 + "px";
115
+ this.qrcodeBox.style.top = (b_height - height) / 2 + "px";
116
+ this.qrcodeBox.style.height = height + "px";
117
+ this.qrcodeBox.style.width = width + "px";
118
+ this.qrcodeBox.style.position = 'absolute';
119
+ this.qrcodeBox.style.zIndex = '10000';
120
+ // qrcodeBox.style.padding = '0 30px 0 30px'
121
+ this.qrcodeBox.innerHTML =
122
+ "<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 ");
123
+ document.body.appendChild(this.qrcodeBox);
124
+ var qrcodeb = document.getElementById("qrcodeb");
125
+ qrcodeb.style.borderRadius = "20px";
126
+ qrcodeb.style.boxSizing = 'border-box';
127
+ this.createQrcode(qrcodeWidth);
128
+ var close = window.document.getElementById("close8");
129
+ close.onclick = function () {
130
+ _this.cancel();
131
+ };
132
+ this.mask.onclick = function () {
133
+ _this.cancel();
134
+ };
135
+ };
136
+ NotoMobile.prototype.cancel = function () {
137
+ this.time = 0;
138
+ this.outTime ? clearTimeout(this.outTime) : '';
139
+ document.body.removeChild(this.mask);
140
+ document.body.removeChild(this.qrcodeBox);
141
+ };
142
+ return NotoMobile;
143
+ }());
144
+ exports.NotoMobile = NotoMobile;
@@ -0,0 +1,94 @@
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, "approveContract", void 0);
92
+ return ReqApproveVo;
93
+ }(RequestVo_1.ChainName));
94
+ exports.ReqApproveVo = ReqApproveVo;