@openocean.finance/wallet 0.4.37 → 0.4.38
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.
|
@@ -102,30 +102,64 @@ var UnstoppableDomains = /** @class */ (function (_super) {
|
|
|
102
102
|
*/
|
|
103
103
|
UnstoppableDomains.prototype.requestConnect = function (chainId) {
|
|
104
104
|
return __awaiter(this, void 0, void 0, function () {
|
|
105
|
-
var uauth, authorization, account, address, currentChainId;
|
|
106
|
-
return __generator(this, function (
|
|
107
|
-
switch (
|
|
105
|
+
var uauth, _account, sub, e_1, authorization, account, _a, sub, wallet_address, authorization, account, _b, sub, wallet_address, address, currentChainId;
|
|
106
|
+
return __generator(this, function (_c) {
|
|
107
|
+
switch (_c.label) {
|
|
108
108
|
case 0:
|
|
109
109
|
uauth = new js_1.default({
|
|
110
110
|
clientID: "05c3a150-4fef-49c9-a153-af16851c75ba",
|
|
111
|
-
redirectUri: "
|
|
111
|
+
redirectUri: "http://localhost:8080",
|
|
112
|
+
responseMode: "fragment",
|
|
113
|
+
clientAuthMethod: "none",
|
|
114
|
+
prompt: "login",
|
|
112
115
|
scope: "openid wallet"
|
|
113
116
|
});
|
|
114
|
-
|
|
117
|
+
_account = window.localStorage.getItem('uAuthAccount');
|
|
118
|
+
if (!_account) return [3 /*break*/, 7];
|
|
119
|
+
_c.label = 1;
|
|
115
120
|
case 1:
|
|
116
|
-
|
|
121
|
+
_c.trys.push([1, 3, , 6]);
|
|
122
|
+
return [4 /*yield*/, uauth.user()];
|
|
123
|
+
case 2:
|
|
124
|
+
sub = (_c.sent()).sub;
|
|
125
|
+
console.log('account', sub);
|
|
126
|
+
this.account = sub;
|
|
127
|
+
return [3 /*break*/, 6];
|
|
128
|
+
case 3:
|
|
129
|
+
e_1 = _c.sent();
|
|
130
|
+
return [4 /*yield*/, uauth.loginWithPopup()];
|
|
131
|
+
case 4:
|
|
132
|
+
authorization = _c.sent();
|
|
117
133
|
account = uauth.getAuthorizationAccount(authorization);
|
|
118
|
-
|
|
134
|
+
return [4 /*yield*/, uauth.user()];
|
|
135
|
+
case 5:
|
|
136
|
+
_a = _c.sent(), sub = _a.sub, wallet_address = _a.wallet_address;
|
|
137
|
+
console.log('account', account, sub, wallet_address);
|
|
138
|
+
this.account = sub;
|
|
139
|
+
return [3 /*break*/, 6];
|
|
140
|
+
case 6: return [3 /*break*/, 10];
|
|
141
|
+
case 7: return [4 /*yield*/, uauth.loginWithPopup()];
|
|
142
|
+
case 8:
|
|
143
|
+
authorization = _c.sent();
|
|
144
|
+
account = uauth.getAuthorizationAccount(authorization);
|
|
145
|
+
return [4 /*yield*/, uauth.user()];
|
|
146
|
+
case 9:
|
|
147
|
+
_b = _c.sent(), sub = _b.sub, wallet_address = _b.wallet_address;
|
|
148
|
+
console.log('account', account, sub, wallet_address);
|
|
149
|
+
this.account = sub;
|
|
150
|
+
_c.label = 10;
|
|
151
|
+
case 10:
|
|
152
|
+
window.localStorage.setItem('uAuthAccount', this.account);
|
|
119
153
|
if (!window.ethereum) {
|
|
120
154
|
throw new Error(types_1.EnumErrors.NotMetamask);
|
|
121
155
|
}
|
|
122
156
|
this.sdk = new web3_1.default(window.ethereum);
|
|
123
157
|
return [4 /*yield*/, this.sdk.eth.requestAccounts()];
|
|
124
|
-
case
|
|
125
|
-
address = (
|
|
158
|
+
case 11:
|
|
159
|
+
address = (_c.sent())[0];
|
|
126
160
|
return [4 /*yield*/, this.sdk.eth.getChainId()];
|
|
127
|
-
case
|
|
128
|
-
currentChainId =
|
|
161
|
+
case 12:
|
|
162
|
+
currentChainId = _c.sent();
|
|
129
163
|
if (chainId && currentChainId !== chainId) {
|
|
130
164
|
throw new Error(types_1.EnumErrors.ChainIdNotMath);
|
|
131
165
|
}
|