@openocean.finance/wallet 1.7.1 → 1.7.2

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.
@@ -13,5 +13,10 @@ declare class SafePalWallet extends BaseWallet {
13
13
  * @param chainId specific chainId,throw error when not match
14
14
  */
15
15
  requestConnect(chainId?: number): Promise<string>;
16
+ /**
17
+ * connect metamask and get wallet address
18
+ * @param chainId specific chainId,throw error when not match
19
+ */
20
+ requestSolanaConnect(chainId?: number): Promise<string>;
16
21
  }
17
22
  export default SafePalWallet;
@@ -62,6 +62,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
62
62
  */
63
63
  // @ts-ignore
64
64
  var safepal_svg_1 = __importDefault(require("../assets/safepal.svg"));
65
+ var helper_1 = require("../helper");
65
66
  var types_1 = require("../types");
66
67
  var BaseWallet_1 = __importDefault(require("./BaseWallet"));
67
68
  var web3_1 = __importDefault(require("web3"));
@@ -134,6 +135,43 @@ var SafePalWallet = /** @class */ (function (_super) {
134
135
  });
135
136
  });
136
137
  };
138
+ /**
139
+ * connect metamask and get wallet address
140
+ * @param chainId specific chainId,throw error when not match
141
+ */
142
+ SafePalWallet.prototype.requestSolanaConnect = function (chainId) {
143
+ return __awaiter(this, void 0, void 0, function () {
144
+ var _this = this;
145
+ return __generator(this, function (_a) {
146
+ return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
147
+ var result, account;
148
+ return __generator(this, function (_a) {
149
+ switch (_a.label) {
150
+ case 0: return [4 /*yield*/, (0, helper_1.autoWalletCheck)(function () {
151
+ return window.safepal;
152
+ }, 3000)];
153
+ case 1:
154
+ result = _a.sent();
155
+ if (!result) {
156
+ throw new Error(types_1.EnumErrors.NoSafePal);
157
+ }
158
+ this.sdk = window.safepal;
159
+ return [4 /*yield*/, window.safepal.connect()];
160
+ case 2:
161
+ _a.sent();
162
+ return [4 /*yield*/, window.safepal.getAccount()];
163
+ case 3:
164
+ account = _a.sent();
165
+ this.address = account;
166
+ this.chainId = ''; // todo sollet chainId
167
+ resolve(account);
168
+ return [2 /*return*/];
169
+ }
170
+ });
171
+ }); })];
172
+ });
173
+ });
174
+ };
137
175
  return SafePalWallet;
138
176
  }(BaseWallet_1.default));
139
177
  exports.default = SafePalWallet;
Binary file
package/lib/types.js CHANGED
@@ -57,14 +57,14 @@ var EnumChains;
57
57
  EnumChains["Mode"] = "mode";
58
58
  EnumChains["PulseChain"] = "pulse";
59
59
  EnumChains["MerlinChain"] = "merlin";
60
- })(EnumChains = exports.EnumChains || (exports.EnumChains = {}));
60
+ })(EnumChains || (exports.EnumChains = EnumChains = {}));
61
61
  var EnumWalletType;
62
62
  (function (EnumWalletType) {
63
63
  EnumWalletType["Extension"] = "Extension";
64
64
  EnumWalletType["WalletConnect"] = "WalletConnect";
65
65
  EnumWalletType["Web"] = "Web";
66
66
  EnumWalletType["Mobile"] = "Mobile";
67
- })(EnumWalletType = exports.EnumWalletType || (exports.EnumWalletType = {}));
67
+ })(EnumWalletType || (exports.EnumWalletType = EnumWalletType = {}));
68
68
  var EnumWalletName;
69
69
  (function (EnumWalletName) {
70
70
  EnumWalletName["NearWallet"] = "NearWallet";
@@ -117,7 +117,7 @@ var EnumWalletName;
117
117
  EnumWalletName["BlockWallet"] = "BlockWallet";
118
118
  EnumWalletName["HaHaWallet"] = "HaHa Wallet";
119
119
  EnumWalletName["ZerionWallet"] = "Zerion Wallet";
120
- })(EnumWalletName = exports.EnumWalletName || (exports.EnumWalletName = {}));
120
+ })(EnumWalletName || (exports.EnumWalletName = EnumWalletName = {}));
121
121
  var EnumErrors;
122
122
  (function (EnumErrors) {
123
123
  EnumErrors["NotMetamask"] = "40001";
@@ -165,4 +165,4 @@ var EnumErrors;
165
165
  EnumErrors["NoFewcha"] = "40045";
166
166
  EnumErrors["NoBlockWallet"] = "40046";
167
167
  EnumErrors["NotZerion"] = "40047";
168
- })(EnumErrors = exports.EnumErrors || (exports.EnumErrors = {}));
168
+ })(EnumErrors || (exports.EnumErrors = EnumErrors = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openocean.finance/wallet",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "description": "A multi-chain wallets manager",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {