@openocean.finance/wallet 0.4.6 → 0.4.9

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.
@@ -6,10 +6,14 @@ declare class NearWallet extends BaseWallet {
6
6
  supportChains: EnumChains[];
7
7
  type: EnumWalletType;
8
8
  sdk: any | null;
9
+ private keyStore;
10
+ private config;
11
+ init(): Promise<void>;
9
12
  /**
10
13
  * connect metamask and get wallet address
11
14
  * @param chainId specific chainId,throw error when not match
12
15
  */
13
16
  requestConnect(): Promise<any>;
17
+ constructor();
14
18
  }
15
19
  export default NearWallet;
@@ -68,7 +68,7 @@ var near_api_js_1 = require("near-api-js");
68
68
  var NearWallet = /** @class */ (function (_super) {
69
69
  __extends(NearWallet, _super);
70
70
  function NearWallet() {
71
- var _this = _super !== null && _super.apply(this, arguments) || this;
71
+ var _this = _super.call(this) || this;
72
72
  _this.name = types_1.EnumWalletName.NearWallet;
73
73
  _this.icon = metamask_svg_1.default;
74
74
  _this.supportChains = [
@@ -76,31 +76,57 @@ var NearWallet = /** @class */ (function (_super) {
76
76
  ];
77
77
  _this.type = types_1.EnumWalletType.Extension;
78
78
  _this.sdk = null;
79
+ _this.keyStore = new near_api_js_1.keyStores.BrowserLocalStorageKeyStore();
80
+ _this.config = {
81
+ networkId: "mainnet",
82
+ keyStore: _this.keyStore,
83
+ nodeUrl: "https://public-rpc.blockpi.io/http/near",
84
+ walletUrl: "https://wallet.mainnet.near.org",
85
+ helperUrl: "https://helper.mainnet.near.org",
86
+ explorerUrl: "https://explorer.mainnet.near.org",
87
+ };
88
+ _this.init();
79
89
  return _this;
80
90
  }
91
+ NearWallet.prototype.init = function () {
92
+ return __awaiter(this, void 0, void 0, function () {
93
+ var account_id, query, vars, i, pair, _a;
94
+ return __generator(this, function (_b) {
95
+ switch (_b.label) {
96
+ case 0:
97
+ account_id = '';
98
+ query = window.location.search.substring(1);
99
+ vars = query.split("&");
100
+ for (i = 0; i < vars.length; i++) {
101
+ pair = vars[i].split("=");
102
+ if (pair[0] == 'account_id') {
103
+ account_id = pair[1];
104
+ }
105
+ }
106
+ if (!account_id) return [3 /*break*/, 2];
107
+ _a = near_api_js_1.WalletConnection.bind;
108
+ return [4 /*yield*/, (0, near_api_js_1.connect)(this.config)];
109
+ case 1:
110
+ new (_a.apply(near_api_js_1.WalletConnection, [void 0, _b.sent(), 'openOcen']))();
111
+ _b.label = 2;
112
+ case 2: return [2 /*return*/];
113
+ }
114
+ });
115
+ });
116
+ };
81
117
  /**
82
118
  * connect metamask and get wallet address
83
119
  * @param chainId specific chainId,throw error when not match
84
120
  */
85
121
  NearWallet.prototype.requestConnect = function () {
86
122
  return __awaiter(this, void 0, void 0, function () {
87
- var keyStore, config, near, account, address;
123
+ var near, account, address;
88
124
  return __generator(this, function (_a) {
89
125
  switch (_a.label) {
90
- case 0:
91
- keyStore = new near_api_js_1.keyStores.BrowserLocalStorageKeyStore();
92
- config = {
93
- networkId: "mainnet",
94
- keyStore: keyStore,
95
- nodeUrl: "https://rpc.mainnet.near.org",
96
- walletUrl: "https://wallet.mainnet.near.org",
97
- helperUrl: "https://helper.mainnet.near.org",
98
- explorerUrl: "https://explorer.mainnet.near.org",
99
- };
100
- return [4 /*yield*/, (0, near_api_js_1.connect)(config)];
126
+ case 0: return [4 /*yield*/, (0, near_api_js_1.connect)(this.config)];
101
127
  case 1:
102
128
  near = _a.sent();
103
- this.sdk = new near_api_js_1.WalletConnection(near, null);
129
+ this.sdk = new near_api_js_1.WalletConnection(near, 'openOcen');
104
130
  if (!this.sdk._authData.accountId) {
105
131
  this.sdk.requestSignIn({
106
132
  contractId: 'v2.ref-farming.near',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openocean.finance/wallet",
3
- "version": "0.4.6",
3
+ "version": "0.4.9",
4
4
  "description": "A multi-chain wallets manager",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {