@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.
@@ -10,6 +10,7 @@ declare abstract class BaseWallet {
10
10
  abstract readonly icon: string;
11
11
  abstract readonly supportChains: EnumChains[];
12
12
  abstract readonly type: EnumWalletType;
13
+ account?: string;
13
14
  address?: string;
14
15
  chain?: EnumChains;
15
16
  chainId?: string | number;
@@ -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 (_a) {
107
- switch (_a.label) {
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: "https://app.openocean.finance",
111
+ redirectUri: "http://localhost:8080",
112
+ responseMode: "fragment",
113
+ clientAuthMethod: "none",
114
+ prompt: "login",
112
115
  scope: "openid wallet"
113
116
  });
114
- return [4 /*yield*/, uauth.loginWithPopup()];
117
+ _account = window.localStorage.getItem('uAuthAccount');
118
+ if (!_account) return [3 /*break*/, 7];
119
+ _c.label = 1;
115
120
  case 1:
116
- authorization = _a.sent();
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
- console.log('account', account);
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 2:
125
- address = (_a.sent())[0];
158
+ case 11:
159
+ address = (_c.sent())[0];
126
160
  return [4 /*yield*/, this.sdk.eth.getChainId()];
127
- case 3:
128
- currentChainId = _a.sent();
161
+ case 12:
162
+ currentChainId = _c.sent();
129
163
  if (chainId && currentChainId !== chainId) {
130
164
  throw new Error(types_1.EnumErrors.ChainIdNotMath);
131
165
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openocean.finance/wallet",
3
- "version": "0.4.37",
3
+ "version": "0.4.38",
4
4
  "description": "A multi-chain wallets manager",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {