@openocean.finance/wallet 0.4.22 → 0.4.25

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.
@@ -90,10 +90,15 @@ var BscWallet = /** @class */ (function (_super) {
90
90
  // go2 download page
91
91
  throw new Error(types_1.EnumErrors.NotBinance);
92
92
  }
93
+ console.log('BinanceChain-1');
94
+ console.log(window.BinanceChain);
93
95
  this.sdk = new web3_1.default(window.BinanceChain);
96
+ console.log('BinanceChain-2');
97
+ console.log(this.sdk);
94
98
  return [4 /*yield*/, this.sdk.eth.requestAccounts()];
95
99
  case 1:
96
100
  account = (_a.sent())[0];
101
+ console.log('BinanceChain-3');
97
102
  return [4 /*yield*/, this.sdk.eth.getChainId()];
98
103
  case 2:
99
104
  currentChainId = _a.sent();
@@ -0,0 +1,15 @@
1
+ import { EnumChains, EnumWalletName, EnumWalletType } from "../types";
2
+ import BaseWallet from "./BaseWallet";
3
+ declare class GnosisSafeWallet extends BaseWallet {
4
+ name: EnumWalletName;
5
+ icon: any;
6
+ supportChains: EnumChains[];
7
+ type: EnumWalletType;
8
+ sdk: any;
9
+ /**
10
+ * connect metamask and get wallet address
11
+ * @param chainId specific chainId,throw error when not match
12
+ */
13
+ requestConnect(chainId?: number): Promise<string>;
14
+ }
15
+ export default GnosisSafeWallet;
@@ -0,0 +1,114 @@
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 GnosisSafe
59
+ * @author openocean
60
+ * @date 2021/4/21
61
+ * @desc
62
+ */
63
+ // @ts-ignore
64
+ var metamask_svg_1 = __importDefault(require("../assets/metamask.svg"));
65
+ var types_1 = require("../types");
66
+ var BaseWallet_1 = __importDefault(require("./BaseWallet"));
67
+ var web3_1 = __importDefault(require("web3"));
68
+ var safe_apps_sdk_1 = __importDefault(require("@gnosis.pm/safe-apps-sdk"));
69
+ var safe_apps_provider_1 = require("@gnosis.pm/safe-apps-provider");
70
+ var GnosisSafeWallet = /** @class */ (function (_super) {
71
+ __extends(GnosisSafeWallet, _super);
72
+ function GnosisSafeWallet() {
73
+ var _this = _super !== null && _super.apply(this, arguments) || this;
74
+ _this.name = types_1.EnumWalletName.GnosisSafeWallet;
75
+ _this.icon = metamask_svg_1.default;
76
+ _this.supportChains = [types_1.EnumChains.RINKEBY];
77
+ _this.type = types_1.EnumWalletType.Extension;
78
+ return _this;
79
+ }
80
+ /**
81
+ * connect metamask and get wallet address
82
+ * @param chainId specific chainId,throw error when not match
83
+ */
84
+ GnosisSafeWallet.prototype.requestConnect = function (chainId) {
85
+ return __awaiter(this, void 0, void 0, function () {
86
+ var opts, sdk, safe, provider, currentChainId;
87
+ return __generator(this, function (_a) {
88
+ switch (_a.label) {
89
+ case 0:
90
+ opts = {
91
+ allowedDomains: [/gnosis-safe.io/],
92
+ debug: true
93
+ };
94
+ sdk = new safe_apps_sdk_1.default(opts);
95
+ return [4 /*yield*/, sdk.safe.getInfo()];
96
+ case 1:
97
+ safe = _a.sent();
98
+ provider = new safe_apps_provider_1.SafeAppProvider(safe, sdk);
99
+ this.sdk = new web3_1.default(provider).currentProvider.sdk;
100
+ console.log('sdk', this.sdk);
101
+ currentChainId = safe.chainId;
102
+ if (chainId && currentChainId !== chainId) {
103
+ throw new Error(types_1.EnumErrors.ChainIdNotMath);
104
+ }
105
+ this.address = safe.safeAddress;
106
+ this.chainId = currentChainId;
107
+ return [2 /*return*/, this.address];
108
+ }
109
+ });
110
+ });
111
+ };
112
+ return GnosisSafeWallet;
113
+ }(BaseWallet_1.default));
114
+ exports.default = GnosisSafeWallet;
@@ -105,7 +105,7 @@ var NearWallet = /** @class */ (function (_super) {
105
105
  }
106
106
  if (!account_id) return [3 /*break*/, 2];
107
107
  _a = near_api_js_1.WalletConnection.bind;
108
- return [4 /*yield*/, (0, near_api_js_1.connect)(this.config)];
108
+ return [4 /*yield*/, near_api_js_1.connect(this.config)];
109
109
  case 1:
110
110
  new (_a.apply(near_api_js_1.WalletConnection, [void 0, _b.sent(), 'openOcen']))();
111
111
  _b.label = 2;
@@ -123,7 +123,7 @@ var NearWallet = /** @class */ (function (_super) {
123
123
  var near, account, address;
124
124
  return __generator(this, function (_a) {
125
125
  switch (_a.label) {
126
- case 0: return [4 /*yield*/, (0, near_api_js_1.connect)(this.config)];
126
+ case 0: return [4 /*yield*/, near_api_js_1.connect(this.config)];
127
127
  case 1:
128
128
  near = _a.sent();
129
129
  this.sdk = new near_api_js_1.WalletConnection(near, 'openOcen');
package/lib/index.d.ts CHANGED
@@ -34,6 +34,7 @@ import BraveWallet from "./Wallets/BraveWallet";
34
34
  import CryptoCom from './Wallets/CryptoCom';
35
35
  import NearWallet from './Wallets/NearWallet';
36
36
  import BitKeepWallet from './Wallets/BitKeepWallet';
37
+ import GnosisSafeWallet from './Wallets/GnosisSafeWallet';
37
38
  import { EnumChains } from "./types";
38
39
  export default WalletManager;
39
- export { WalletManager, MetaMask, BscWallet, Cyano, TronLink, EnumChains, Sollet, SolletIo, OntoMobile, WalletConnect, MathWallet, OntoWallet, SafePalWallet, ImTokenWallet, TokenPocket, TrustWallet, Coin98, Phantom, OKExWallet, TerraStation, CoinbaseWallet, CloverWallet, XDEFIWallet, SlopeWallet, SolflareWallet, MetaXWallet, KeplrWallet, BraveWallet, CryptoCom, NearWallet, BitKeepWallet };
40
+ export { WalletManager, MetaMask, BscWallet, Cyano, TronLink, EnumChains, Sollet, SolletIo, OntoMobile, WalletConnect, MathWallet, OntoWallet, SafePalWallet, ImTokenWallet, TokenPocket, TrustWallet, Coin98, Phantom, OKExWallet, TerraStation, CoinbaseWallet, CloverWallet, XDEFIWallet, SlopeWallet, SolflareWallet, MetaXWallet, KeplrWallet, BraveWallet, CryptoCom, NearWallet, BitKeepWallet, GnosisSafeWallet };
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.BitKeepWallet = exports.NearWallet = exports.CryptoCom = exports.BraveWallet = exports.KeplrWallet = exports.MetaXWallet = exports.SolflareWallet = exports.SlopeWallet = exports.XDEFIWallet = exports.CloverWallet = exports.CoinbaseWallet = exports.TerraStation = exports.OKExWallet = 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 = exports.WalletManager = void 0;
6
+ exports.GnosisSafeWallet = exports.BitKeepWallet = exports.NearWallet = exports.CryptoCom = exports.BraveWallet = exports.KeplrWallet = exports.MetaXWallet = exports.SolflareWallet = exports.SlopeWallet = exports.XDEFIWallet = exports.CloverWallet = exports.CoinbaseWallet = exports.TerraStation = exports.OKExWallet = 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 = exports.WalletManager = void 0;
7
7
  /**
8
8
  * wallets-manager entry
9
9
  * @author openocean
@@ -70,6 +70,8 @@ var NearWallet_1 = __importDefault(require("./Wallets/NearWallet"));
70
70
  exports.NearWallet = NearWallet_1.default;
71
71
  var BitKeepWallet_1 = __importDefault(require("./Wallets/BitKeepWallet"));
72
72
  exports.BitKeepWallet = BitKeepWallet_1.default;
73
+ var GnosisSafeWallet_1 = __importDefault(require("./Wallets/GnosisSafeWallet"));
74
+ exports.GnosisSafeWallet = GnosisSafeWallet_1.default;
73
75
  var types_1 = require("./types");
74
76
  Object.defineProperty(exports, "EnumChains", { enumerable: true, get: function () { return types_1.EnumChains; } });
75
77
  var process = {};
package/lib/types.d.ts CHANGED
@@ -71,7 +71,8 @@ export declare enum EnumWalletName {
71
71
  keplrWallet = "Keplr Wallet",
72
72
  BraveWallet = "Brave Wallet",
73
73
  CryptoCom = "Crypto.com DeFi Wallet",
74
- BitKeepWallet = "BitKeep Wallet"
74
+ BitKeepWallet = "BitKeep Wallet",
75
+ GnosisSafeWallet = "GnosisSafe Wallet"
75
76
  }
76
77
  export declare enum EnumErrors {
77
78
  NotMetamask = "40001",
package/lib/types.js CHANGED
@@ -74,6 +74,7 @@ var EnumWalletName;
74
74
  EnumWalletName["BraveWallet"] = "Brave Wallet";
75
75
  EnumWalletName["CryptoCom"] = "Crypto.com DeFi Wallet";
76
76
  EnumWalletName["BitKeepWallet"] = "BitKeep Wallet";
77
+ EnumWalletName["GnosisSafeWallet"] = "GnosisSafe Wallet";
77
78
  })(EnumWalletName = exports.EnumWalletName || (exports.EnumWalletName = {}));
78
79
  var EnumErrors;
79
80
  (function (EnumErrors) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openocean.finance/wallet",
3
- "version": "0.4.22",
3
+ "version": "0.4.25",
4
4
  "description": "A multi-chain wallets manager",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -42,6 +42,8 @@
42
42
  "dependencies": {
43
43
  "@cosmjs/launchpad": "^0.27.1",
44
44
  "@cosmjs/stargate": "^0.28.4",
45
+ "@gnosis.pm/safe-apps-provider": "^0.11.3",
46
+ "@gnosis.pm/safe-apps-sdk": "^7.5.0",
45
47
  "@ont-dev/ontology-dapi": "^0.5.7",
46
48
  "@project-serum/sol-wallet-adapter": "0.2.0",
47
49
  "@solana/web3.js": "1.31.0",