@openocean.finance/wallet 0.4.20 → 0.4.21

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,6 +1,5 @@
1
1
  import { EnumChains, EnumWalletName, EnumWalletType } from "../types";
2
2
  import BaseWallet from "./BaseWallet";
3
- import WalletConnectProvider from "@walletconnect/web3-provider";
4
3
  declare class WalletConnect extends BaseWallet {
5
4
  name: EnumWalletName;
6
5
  icon: any;
@@ -8,8 +7,6 @@ declare class WalletConnect extends BaseWallet {
8
7
  type: EnumWalletType;
9
8
  sdk: any;
10
9
  infuraId?: string;
11
- provider: WalletConnectProvider;
12
- disconnect(): Promise<boolean>;
13
10
  /**
14
11
  * connect metamask and get wallet address
15
12
  * @param chainId specific chainId,throw error when not match
@@ -102,43 +102,8 @@ var WalletConnect = /** @class */ (function (_super) {
102
102
  ];
103
103
  _this.type = types_1.EnumWalletType.WalletConnect;
104
104
  _this.sdk = null;
105
- _this.provider = new web3_provider_1.default({
106
- infuraId: '2c7c4d86c2c746c89de722551b606119',
107
- chainId: 1,
108
- rpc: {
109
- 69: "https://kovan.optimism.io",
110
- 420: "https://goerli.optimism.io",
111
- 10: "https://rpc.ankr.com/optimism",
112
- 25: "https://evm.cronos.org",
113
- 56: "https://bsc-dataseed1.binance.org",
114
- 66: "https://exchainrpc.okex.org",
115
- 100: "https://rpc.xdaichain.com",
116
- 128: "https://http-mainnet.hecochain.com",
117
- 137: "https://rpc-mainnet.maticvigil.com",
118
- 250: "https://rpcapi.fantom.network",
119
- 288: "https://mainnet.boba.network",
120
- 1285: "https://rpc.moonriver.moonbeam.network",
121
- 42161: "https://arb1.arbitrum.io/rpc",
122
- 421611: "https://rinkeby.arbitrum.io/rpc",
123
- 43114: "https://api.avax.network/ext/bc/C/rpc",
124
- 1313161554: "https://mainnet.aurora.dev",
125
- 1666600000: "https://api.s0.t.hmny.io",
126
- }
127
- });
128
105
  return _this;
129
106
  }
130
- WalletConnect.prototype.disconnect = function () {
131
- return __awaiter(this, void 0, void 0, function () {
132
- return __generator(this, function (_a) {
133
- switch (_a.label) {
134
- case 0: return [4 /*yield*/, this.provider.disconnect()];
135
- case 1:
136
- _a.sent();
137
- return [2 /*return*/, true];
138
- }
139
- });
140
- });
141
- };
142
107
  /**
143
108
  * connect metamask and get wallet address
144
109
  * @param chainId specific chainId,throw error when not match
@@ -147,27 +112,42 @@ var WalletConnect = /** @class */ (function (_super) {
147
112
  WalletConnect.prototype.requestConnect = function (chainId, config) {
148
113
  if (chainId === void 0) { chainId = 1; }
149
114
  return __awaiter(this, void 0, void 0, function () {
150
- var currentChainId, address;
115
+ var provider, currentChainId, address;
151
116
  return __generator(this, function (_a) {
152
117
  switch (_a.label) {
153
118
  case 0:
154
- // this.provider.infuraId = this.infuraId
155
- // await this.provider.disconnect()
156
- // await new Promise(r => {
157
- // setTimeout(r, 200);
158
- // })
159
- this.provider.chainId = chainId;
160
- this.provider.updateRpcUrl(chainId);
161
- return [4 /*yield*/, this.provider.enable()];
119
+ if (!this.infuraId) {
120
+ throw new Error("infuraId not set");
121
+ }
122
+ provider = new web3_provider_1.default(__assign({ infuraId: this.infuraId, chainId: chainId, rpc: {
123
+ 69: "https://kovan.optimism.io",
124
+ 420: "https://goerli.optimism.io",
125
+ 10: "https://rpc.ankr.com/optimism",
126
+ 25: "https://evm.cronos.org",
127
+ 56: "https://bsc-dataseed1.binance.org",
128
+ 66: "https://exchainrpc.okex.org",
129
+ 100: "https://rpc.xdaichain.com",
130
+ 128: "https://http-mainnet.hecochain.com",
131
+ 137: "https://rpc-mainnet.maticvigil.com",
132
+ 250: "https://rpcapi.fantom.network",
133
+ 288: "https://mainnet.boba.network",
134
+ 1285: "https://rpc.moonriver.moonbeam.network",
135
+ 42161: "https://arb1.arbitrum.io/rpc",
136
+ 421611: "https://rinkeby.arbitrum.io/rpc",
137
+ 43114: "https://api.avax.network/ext/bc/C/rpc",
138
+ 1313161554: "https://mainnet.aurora.dev",
139
+ 1666600000: "https://api.s0.t.hmny.io",
140
+ } }, config));
141
+ return [4 /*yield*/, provider.enable()];
162
142
  case 1:
163
143
  _a.sent();
164
- this.sdk = new web3_1.default(this.provider);
144
+ this.sdk = new web3_1.default(provider);
165
145
  return [4 /*yield*/, this.sdk.eth.getChainId()];
166
146
  case 2:
167
147
  currentChainId = _a.sent();
168
148
  if (!(chainId && currentChainId != chainId)) return [3 /*break*/, 6];
169
- if (!(!config || !config.isTow)) return [3 /*break*/, 6];
170
- return [4 /*yield*/, this.provider.disconnect()];
149
+ if (!(!config || !config.isSecond)) return [3 /*break*/, 6];
150
+ return [4 /*yield*/, provider.disconnect()];
171
151
  case 3:
172
152
  _a.sent();
173
153
  return [4 /*yield*/, new Promise(function (r) {
@@ -175,7 +155,7 @@ var WalletConnect = /** @class */ (function (_super) {
175
155
  })];
176
156
  case 4:
177
157
  _a.sent();
178
- return [4 /*yield*/, this.requestConnect(chainId, __assign({ isTow: true }, config))];
158
+ return [4 /*yield*/, this.requestConnect(chainId, __assign({ isSecond: true }, config))];
179
159
  case 5: return [2 /*return*/, _a.sent()];
180
160
  case 6:
181
161
  if (chainId && currentChainId != chainId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openocean.finance/wallet",
3
- "version": "0.4.20",
3
+ "version": "0.4.21",
4
4
  "description": "A multi-chain wallets manager",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {