@openocean.finance/wallet 0.4.58 → 0.4.60

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.
@@ -8,12 +8,12 @@ declare class Coin98 extends BaseWallet {
8
8
  sdk: any | null;
9
9
  installUrl: string;
10
10
  /**
11
- * connect TrustWallet and get wallet address
11
+ * connect Coin98 and get wallet address
12
12
  * @param chainId specific chainId,throw error when not match
13
13
  */
14
14
  requestConnect(chainId?: number): Promise<any>;
15
15
  /**
16
- * connect TrustWallet and get wallet address
16
+ * connect Coin98 and get wallet address
17
17
  * @param chainId specific chainId,throw error when not match
18
18
  */
19
19
  requestSolanaConnect(): Promise<any>;
@@ -79,7 +79,7 @@ var Coin98 = /** @class */ (function (_super) {
79
79
  return _this;
80
80
  }
81
81
  /**
82
- * connect TrustWallet and get wallet address
82
+ * connect Coin98 and get wallet address
83
83
  * @param chainId specific chainId,throw error when not match
84
84
  */
85
85
  Coin98.prototype.requestConnect = function (chainId) {
@@ -111,7 +111,7 @@ var Coin98 = /** @class */ (function (_super) {
111
111
  });
112
112
  };
113
113
  /**
114
- * connect TrustWallet and get wallet address
114
+ * connect Coin98 and get wallet address
115
115
  * @param chainId specific chainId,throw error when not match
116
116
  */
117
117
  Coin98.prototype.requestSolanaConnect = function () {
@@ -0,0 +1,23 @@
1
+ import { EnumChains, EnumWalletName, EnumWalletType } from "../types";
2
+ import BaseWallet from "./BaseWallet";
3
+ import { WalletConnection, utils } from "near-api-js";
4
+ import { createTransaction, functionCall } from 'near-api-js/lib/transaction';
5
+ declare class MyNearWallet extends BaseWallet {
6
+ name: EnumWalletName;
7
+ icon: any;
8
+ supportChains: EnumChains[];
9
+ type: EnumWalletType;
10
+ sdk: WalletConnection | null;
11
+ createTransaction: typeof createTransaction;
12
+ functionCall: typeof functionCall;
13
+ PublicKey: typeof utils.key_pair.PublicKey;
14
+ utils: typeof utils;
15
+ init(): Promise<void>;
16
+ /**
17
+ * connect metamask and get wallet address
18
+ * @param chainId specific chainId,throw error when not match
19
+ */
20
+ requestConnect(): Promise<string>;
21
+ constructor();
22
+ }
23
+ export default MyNearWallet;
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ var __importDefault = (this && this.__importDefault) || function (mod) {
54
+ return (mod && mod.__esModule) ? mod : { "default": mod };
55
+ };
56
+ Object.defineProperty(exports, "__esModule", { value: true });
57
+ /**
58
+ * @name MyNearWallet
59
+ * @author openocean
60
+ * @date 2021/4/21
61
+ * @desc
62
+ */
63
+ // @ts-ignore
64
+ var mynear_svg_1 = __importDefault(require("../assets/mynear.svg"));
65
+ var types_1 = require("../types");
66
+ var BaseWallet_1 = __importDefault(require("./BaseWallet"));
67
+ var near_api_js_1 = require("near-api-js");
68
+ var transaction_1 = require("near-api-js/lib/transaction");
69
+ var utils_1 = require("near-api-js/lib/utils");
70
+ var helper_1 = require("../helper");
71
+ var MyNearWallet = /** @class */ (function (_super) {
72
+ __extends(MyNearWallet, _super);
73
+ function MyNearWallet() {
74
+ var _this = _super.call(this) || this;
75
+ _this.name = types_1.EnumWalletName.MyNearWallet;
76
+ _this.icon = mynear_svg_1.default;
77
+ _this.supportChains = [
78
+ types_1.EnumChains.NEAR
79
+ ];
80
+ _this.type = types_1.EnumWalletType.Extension;
81
+ _this.sdk = null;
82
+ _this.createTransaction = transaction_1.createTransaction;
83
+ _this.functionCall = transaction_1.functionCall;
84
+ _this.PublicKey = utils_1.PublicKey;
85
+ _this.utils = near_api_js_1.utils;
86
+ _this.init();
87
+ return _this;
88
+ }
89
+ MyNearWallet.prototype.init = function () {
90
+ return __awaiter(this, void 0, void 0, function () {
91
+ var account_id, query, vars, i, pair;
92
+ return __generator(this, function (_a) {
93
+ switch (_a.label) {
94
+ case 0:
95
+ if (window.localStorage.getItem('connectwallet') !== this.name) {
96
+ return [2 /*return*/];
97
+ }
98
+ account_id = '';
99
+ query = window.location.search.substring(1);
100
+ vars = query.split("&");
101
+ for (i = 0; i < vars.length; i++) {
102
+ pair = vars[i].split("=");
103
+ if (pair[0] == 'account_id') {
104
+ account_id = pair[1];
105
+ }
106
+ }
107
+ if (!account_id) return [3 /*break*/, 2];
108
+ return [4 /*yield*/, this.requestConnect()];
109
+ case 1:
110
+ _a.sent();
111
+ _a.label = 2;
112
+ case 2: return [2 /*return*/];
113
+ }
114
+ });
115
+ });
116
+ };
117
+ /**
118
+ * connect metamask and get wallet address
119
+ * @param chainId specific chainId,throw error when not match
120
+ */
121
+ MyNearWallet.prototype.requestConnect = function () {
122
+ return __awaiter(this, void 0, void 0, function () {
123
+ var wallet, account;
124
+ return __generator(this, function (_a) {
125
+ switch (_a.label) {
126
+ case 0: return [4 /*yield*/, (0, helper_1.sleep)(1000)];
127
+ case 1:
128
+ _a.sent();
129
+ window.localStorage.setItem('connectwallet', this.name);
130
+ return [4 /*yield*/, (0, near_api_js_1.connect)({
131
+ networkId: "mainnet",
132
+ keyStore: new near_api_js_1.keyStores.BrowserLocalStorageKeyStore(),
133
+ nodeUrl: "https://rpc.mainnet.near.org",
134
+ walletUrl: "https://app.mynearwallet.com",
135
+ helperUrl: "https://helper.mainnet.near.org",
136
+ headers: {}
137
+ // explorerUrl: "https://explorer.mainnet.near.org",
138
+ })];
139
+ case 2:
140
+ wallet = _a.sent();
141
+ this.sdk = new near_api_js_1.WalletConnection(wallet, 'OpenOcean');
142
+ account = this.sdk.account();
143
+ if (!!account.accountId) return [3 /*break*/, 4];
144
+ return [4 /*yield*/, this.sdk.requestSignIn({
145
+ contractId: 'a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.factory.bridge.near',
146
+ methodNames: [], // optional
147
+ })];
148
+ case 3:
149
+ _a.sent();
150
+ _a.label = 4;
151
+ case 4:
152
+ account = this.sdk.account();
153
+ this.address = account.accountId;
154
+ return [2 /*return*/, this.address || ''];
155
+ }
156
+ });
157
+ });
158
+ };
159
+ return MyNearWallet;
160
+ }(BaseWallet_1.default));
161
+ exports.default = MyNearWallet;
@@ -92,6 +92,9 @@ var NearWallet = /** @class */ (function (_super) {
92
92
  return __generator(this, function (_a) {
93
93
  switch (_a.label) {
94
94
  case 0:
95
+ if (window.localStorage.getItem('connectwallet') !== this.name) {
96
+ return [2 /*return*/];
97
+ }
95
98
  account_id = '';
96
99
  query = window.location.search.substring(1);
97
100
  vars = query.split("&");
@@ -123,6 +126,7 @@ var NearWallet = /** @class */ (function (_super) {
123
126
  case 0: return [4 /*yield*/, (0, helper_1.sleep)(1000)];
124
127
  case 1:
125
128
  _a.sent();
129
+ window.localStorage.setItem('connectwallet', this.name);
126
130
  return [4 /*yield*/, (0, near_api_js_1.connect)({
127
131
  networkId: "mainnet",
128
132
  keyStore: new near_api_js_1.keyStores.BrowserLocalStorageKeyStore(),
@@ -134,7 +138,7 @@ var NearWallet = /** @class */ (function (_super) {
134
138
  })];
135
139
  case 2:
136
140
  wallet = _a.sent();
137
- this.sdk = new near_api_js_1.WalletConnection(wallet, 'openOcen');
141
+ this.sdk = new near_api_js_1.WalletConnection(wallet, 'OpenOcean');
138
142
  account = this.sdk.account();
139
143
  if (!!account.accountId) return [3 /*break*/, 4];
140
144
  return [4 /*yield*/, this.sdk.requestSignIn({
@@ -9,7 +9,7 @@ declare class OKXWallet extends BaseWallet {
9
9
  sdk: Web3 | null;
10
10
  installUrl: string;
11
11
  /**
12
- * connect TrustWallet and get wallet address
12
+ * connect OKXWallet and get wallet address
13
13
  * @param chainId specific chainId,throw error when not match
14
14
  */
15
15
  requestConnect(chainId?: number): Promise<string>;
@@ -91,7 +91,7 @@ var OKXWallet = /** @class */ (function (_super) {
91
91
  return _this;
92
92
  }
93
93
  /**
94
- * connect TrustWallet and get wallet address
94
+ * connect OKXWallet and get wallet address
95
95
  * @param chainId specific chainId,throw error when not match
96
96
  */
97
97
  OKXWallet.prototype.requestConnect = function (chainId) {
@@ -0,0 +1,40 @@
1
+ <svg width="96.000000" height="96.000000" viewBox="0 0 96 96" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
2
+ <desc>
3
+ Created with Pixso.
4
+ </desc>
5
+ <g id="组合 1">
6
+ <g id="circle">
7
+ <circle cx="48.000000" cy="48.000000" r="48.000000" fill="#FFFFFF"/>
8
+ </g>
9
+ <g id="path">
10
+ <path d="M63.7621 55.5089L63.7621 35.9256C63.7621 32.023 59.803 28.1983 54.9107 28.1983C52.2811 28.2441 49.772 29.3086 47.9116 31.1676L39.0814 22.4505C41.4277 20.1671 44.2389 18.4166 47.3233 17.3186C50.4076 16.2205 53.6925 15.8006 56.9539 16.0876C68.4353 17.1764 76 26.4731 76 36.2012L76 68.0154L63.7621 55.5089Z" fill-rule="nonzero" fill="url(#paint_linear_2_15_0)"/>
11
+ </g>
12
+ <g id="path">
13
+ <path d="M20 28.4032L20 60.2173C20 69.9454 27.5718 79.2422 39.0461 80.3309C42.3075 80.618 45.5924 80.1981 48.6767 79.1C51.7611 78.002 54.5723 76.2515 56.9186 73.9681L48.0884 65.251C46.228 67.11 43.7189 68.1746 41.0893 68.2204C36.1969 68.2204 32.2378 64.3956 32.2378 60.4931L32.2378 41.0511L20 28.4032Z" fill-rule="nonzero" fill="url(#paint_linear_2_16_0)"/>
14
+ </g>
15
+ <g id="path">
16
+ <path d="M53.0159 44.7982L75.9857 67.8316L75.9857 74.1945C75.9857 76.2801 73.9213 78.4788 71.4398 78.5212C70.0258 78.5212 68.5483 77.4112 67.6292 76.4921L44.2493 52.9921L20.0069 28.6013L20.0069 22.2384C20.0069 20.1528 22.0713 17.9541 24.5528 17.9117C25.9667 17.9117 27.4444 19.0216 28.3634 19.9407L53.0159 44.7982Z" fill-rule="nonzero" fill="url(#paint_linear_2_17_0)"/>
17
+ </g>
18
+ </g>
19
+ <defs>
20
+ <linearGradient id="paint_linear_2_15_0" x1="44.645351" y1="15.317019" x2="85.388687" y2="58.336792" gradientUnits="userSpaceOnUse">
21
+ <stop offset="0.060000" stop-color="#B6D7FE"/>
22
+ <stop offset="0.120000" stop-color="#A6D4FC"/>
23
+ <stop offset="0.260000" stop-color="#88CEF8"/>
24
+ <stop offset="0.380000" stop-color="#76CAF6"/>
25
+ <stop offset="0.470000" stop-color="#70C9F5"/>
26
+ <stop offset="0.730000" stop-color="#18A0EC"/>
27
+ </linearGradient>
28
+ <linearGradient id="paint_linear_2_16_0" x1="23.690454" y1="33.974197" x2="47.911629" y2="91.465981" gradientUnits="userSpaceOnUse">
29
+ <stop offset="0.010000" stop-color="#8537FF"/>
30
+ <stop offset="0.490000" stop-color="#D095FE"/>
31
+ <stop offset="0.720000" stop-color="#E9ADFF"/>
32
+ <stop offset="0.850000" stop-color="#F8BCFF"/>
33
+ </linearGradient>
34
+ <linearGradient id="paint_linear_2_17_0" x1="78.170280" y1="77.686935" x2="21.279451" y2="22.153585" gradientUnits="userSpaceOnUse">
35
+ <stop stop-color="#35D7FD"/>
36
+ <stop offset="0.680000" stop-color="#9A68FE"/>
37
+ <stop offset="1.000000" stop-color="#B45DFF"/>
38
+ </linearGradient>
39
+ </defs>
40
+ </svg>
package/lib/index.d.ts CHANGED
@@ -38,5 +38,6 @@ import PetraWallet from './Wallets/PetraWallet';
38
38
  import MartianWallet from './Wallets/MartianWallet';
39
39
  import PontemWallet from './Wallets/PontemWallet';
40
40
  import UnstoppableDomains from './Wallets/UnstoppableDomains';
41
+ import MyNearWallet from "./Wallets/MyNearWallet";
41
42
  import { EnumChains } from "./types";
42
- export { MetaMask, BscWallet, Cyano, TronLink, EnumChains, Sollet, SolletIo, OntoMobile, WalletConnect, MathWallet, OntoWallet, SafePalWallet, ImTokenWallet, TokenPocket, TrustWallet, Coin98, Phantom, TerraStation, CoinbaseWallet, CloverWallet, XDEFIWallet, SlopeWallet, SolflareWallet, OKXWallet, KeplrWallet, BraveWallet, CryptoCom, NearWallet, BitKeepWallet, GnosisSafeWallet, BloctoWallet, PetraWallet, MartianWallet, PontemWallet, UnstoppableDomains };
43
+ export { MetaMask, BscWallet, Cyano, TronLink, EnumChains, Sollet, SolletIo, OntoMobile, WalletConnect, MathWallet, OntoWallet, SafePalWallet, ImTokenWallet, TokenPocket, TrustWallet, Coin98, Phantom, TerraStation, CoinbaseWallet, CloverWallet, XDEFIWallet, SlopeWallet, SolflareWallet, OKXWallet, KeplrWallet, BraveWallet, CryptoCom, NearWallet, BitKeepWallet, GnosisSafeWallet, BloctoWallet, PetraWallet, MartianWallet, PontemWallet, UnstoppableDomains, MyNearWallet };
package/lib/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.UnstoppableDomains = exports.PontemWallet = exports.MartianWallet = exports.PetraWallet = exports.BloctoWallet = exports.GnosisSafeWallet = exports.BitKeepWallet = exports.NearWallet = exports.CryptoCom = exports.BraveWallet = exports.KeplrWallet = exports.OKXWallet = exports.SolflareWallet = exports.SlopeWallet = exports.XDEFIWallet = exports.CloverWallet = exports.CoinbaseWallet = exports.TerraStation = exports.Phantom = exports.Coin98 = exports.TrustWallet = exports.TokenPocket = exports.ImTokenWallet = exports.SafePalWallet = exports.OntoWallet = exports.MathWallet = exports.WalletConnect = exports.OntoMobile = exports.SolletIo = exports.Sollet = exports.EnumChains = exports.TronLink = exports.Cyano = exports.BscWallet = exports.MetaMask = void 0;
6
+ exports.MyNearWallet = exports.UnstoppableDomains = exports.PontemWallet = exports.MartianWallet = exports.PetraWallet = exports.BloctoWallet = exports.GnosisSafeWallet = exports.BitKeepWallet = exports.NearWallet = exports.CryptoCom = exports.BraveWallet = exports.KeplrWallet = exports.OKXWallet = exports.SolflareWallet = exports.SlopeWallet = exports.XDEFIWallet = exports.CloverWallet = exports.CoinbaseWallet = exports.TerraStation = exports.Phantom = exports.Coin98 = exports.TrustWallet = exports.TokenPocket = exports.ImTokenWallet = exports.SafePalWallet = exports.OntoWallet = exports.MathWallet = exports.WalletConnect = exports.OntoMobile = exports.SolletIo = exports.Sollet = exports.EnumChains = exports.TronLink = exports.Cyano = exports.BscWallet = exports.MetaMask = void 0;
7
7
  /**
8
8
  * wallets-manager entry
9
9
  * @author openocean
@@ -78,5 +78,7 @@ var PontemWallet_1 = __importDefault(require("./Wallets/PontemWallet"));
78
78
  exports.PontemWallet = PontemWallet_1.default;
79
79
  var UnstoppableDomains_1 = __importDefault(require("./Wallets/UnstoppableDomains"));
80
80
  exports.UnstoppableDomains = UnstoppableDomains_1.default;
81
+ var MyNearWallet_1 = __importDefault(require("./Wallets/MyNearWallet"));
82
+ exports.MyNearWallet = MyNearWallet_1.default;
81
83
  var types_1 = require("./types");
82
84
  Object.defineProperty(exports, "EnumChains", { enumerable: true, get: function () { return types_1.EnumChains; } });
package/lib/types.d.ts CHANGED
@@ -80,7 +80,8 @@ export declare enum EnumWalletName {
80
80
  PetraWallet = "Petra wallet",
81
81
  MartianWallet = "Martian wallet",
82
82
  PontemWallet = "Pontem Wallet",
83
- UnstoppableDomains = "Unstoppable Domains"
83
+ UnstoppableDomains = "Unstoppable Domains",
84
+ MyNearWallet = "MyNearWallet"
84
85
  }
85
86
  export declare enum EnumErrors {
86
87
  NotMetamask = "40001",
package/lib/types.js CHANGED
@@ -83,6 +83,7 @@ var EnumWalletName;
83
83
  EnumWalletName["MartianWallet"] = "Martian wallet";
84
84
  EnumWalletName["PontemWallet"] = "Pontem Wallet";
85
85
  EnumWalletName["UnstoppableDomains"] = "Unstoppable Domains";
86
+ EnumWalletName["MyNearWallet"] = "MyNearWallet";
86
87
  })(EnumWalletName = exports.EnumWalletName || (exports.EnumWalletName = {}));
87
88
  var EnumErrors;
88
89
  (function (EnumErrors) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openocean.finance/wallet",
3
- "version": "0.4.58",
3
+ "version": "0.4.60",
4
4
  "description": "A multi-chain wallets manager",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {