@openocean.finance/wallet 0.4.7 → 0.4.10

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.
@@ -74,6 +74,7 @@ var MetaMask = /** @class */ (function (_super) {
74
74
  _this.supportChains = [
75
75
  types_1.EnumChains.ETH,
76
76
  types_1.EnumChains.ROPSTEN,
77
+ types_1.EnumChains.RINKEBY,
77
78
  types_1.EnumChains.BSC,
78
79
  types_1.EnumChains.BSCTEST,
79
80
  types_1.EnumChains.Polygon,
@@ -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;
@@ -61,46 +61,72 @@ Object.defineProperty(exports, "__esModule", { value: true });
61
61
  * @desc
62
62
  */
63
63
  // @ts-ignore
64
- var metamask_svg_1 = __importDefault(require("../assets/metamask.svg"));
64
+ var near_svg_1 = __importDefault(require("../assets/near.svg"));
65
65
  var types_1 = require("../types");
66
66
  var BaseWallet_1 = __importDefault(require("./BaseWallet"));
67
67
  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
- _this.icon = metamask_svg_1.default;
73
+ _this.icon = near_svg_1.default;
74
74
  _this.supportChains = [
75
75
  types_1.EnumChains.NEAR
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://public-rpc.blockpi.io/http/near",
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',
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="32px" height="32px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <title>near</title>
4
+ <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
5
+ <g id="near" fill-rule="nonzero">
6
+ <circle id="Oval" fill="#FFFFFF" cx="16" cy="16" r="16"></circle>
7
+ <path d="M22.0444,7.02222 L17.8667,13.22222 C17.5778,13.64444 18.1333,14.15556 18.5333,13.8 L22.6444,10.22222 C22.7556,10.13333 22.9111,10.2 22.9111,10.35556 L22.9111,21.5333 C22.9111,21.6889 22.7111,21.7556 22.6222,21.6444 L10.17778,6.755556 C9.77778,6.266667 9.2,6 8.55556,6 L8.11111,6 C6.955556,6 6,6.955556 6,8.13333 L6,23.8667 C6,25.0444 6.955556,26 8.13333,26 C8.86667,26 9.55556,25.6222 9.95556,24.9778 L14.13333,18.7778 C14.42222,18.3556 13.86667,17.8444 13.46667,18.2 L9.35556,21.7556 C9.24444,21.8444 9.08889,21.7778 9.08889,21.6222 L9.08889,10.46667 C9.08889,10.31111 9.28889,10.24444 9.37778,10.35556 L21.8222,25.2444 C22.2222,25.7333 22.8222,26 23.4444,26 L23.8889,26 C25.0667,26 26.0222,25.0444 26.0222,23.8667 L26.0222,8.13333 C26,6.955556 25.0444,6 23.8667,6 C23.1333,6 22.4444,6.377778 22.0444,7.02222 Z" id="Path" fill="#000000"></path>
8
+ </g>
9
+ </g>
10
+ </svg>
package/lib/types.d.ts CHANGED
@@ -12,6 +12,7 @@ export declare enum EnumChains {
12
12
  NEAR = "near",
13
13
  ETH = "eth",
14
14
  ROPSTEN = "ropsten",
15
+ RINKEBY = "rinkeby",
15
16
  ONT = "ont",
16
17
  BSC = "bsc",
17
18
  BSCTEST = "bsctest",
package/lib/types.js CHANGED
@@ -12,6 +12,7 @@ var EnumChains;
12
12
  EnumChains["NEAR"] = "near";
13
13
  EnumChains["ETH"] = "eth";
14
14
  EnumChains["ROPSTEN"] = "ropsten";
15
+ EnumChains["RINKEBY"] = "rinkeby";
15
16
  EnumChains["ONT"] = "ont";
16
17
  EnumChains["BSC"] = "bsc";
17
18
  EnumChains["BSCTEST"] = "bsctest";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openocean.finance/wallet",
3
- "version": "0.4.7",
3
+ "version": "0.4.10",
4
4
  "description": "A multi-chain wallets manager",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {