@openocean.finance/openocean-sdk 0.1.68 → 0.1.69

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.
@@ -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;
@@ -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;