@openocean.finance/wallet 0.4.24 → 0.4.27

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.
@@ -73,10 +73,7 @@ var BitKeepWallet = /** @class */ (function (_super) {
73
73
  _this.icon = bitkeep_svg_1.default;
74
74
  _this.supportChains = [
75
75
  types_1.EnumChains.ETH,
76
- types_1.EnumChains.ROPSTEN,
77
- types_1.EnumChains.RINKEBY,
78
76
  types_1.EnumChains.BSC,
79
- types_1.EnumChains.BSCTEST,
80
77
  types_1.EnumChains.Polygon,
81
78
  types_1.EnumChains.OKEX,
82
79
  types_1.EnumChains.XDai,
@@ -85,11 +82,11 @@ var BitKeepWallet = /** @class */ (function (_super) {
85
82
  types_1.EnumChains.Avalanche,
86
83
  types_1.EnumChains.Arbitrum,
87
84
  types_1.EnumChains.Optimism,
88
- types_1.EnumChains.Boba,
89
- types_1.EnumChains.Moonriver,
90
- types_1.EnumChains.Aurora,
91
- types_1.EnumChains.Cronos,
92
- types_1.EnumChains.Harmony
85
+ // EnumChains.Boba,
86
+ // EnumChains.Moonriver,
87
+ // EnumChains.Aurora,
88
+ // EnumChains.Cronos,
89
+ // EnumChains.Harmony
93
90
  ];
94
91
  _this.type = types_1.EnumWalletType.Extension;
95
92
  _this.sdk = null;
@@ -0,0 +1,15 @@
1
+ import { EnumChains, EnumWalletName, EnumWalletType } from "../types";
2
+ import BaseWallet from "./BaseWallet";
3
+ declare class BloctoWallet 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
+ requestFlowConnect(chainId?: number): Promise<void>;
14
+ }
15
+ export default BloctoWallet;
@@ -0,0 +1,130 @@
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
30
+ }) : function(o, v) {
31
+ o["default"] = v;
32
+ });
33
+ var __importStar = (this && this.__importStar) || function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
41
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
42
+ return new (P || (P = Promise))(function (resolve, reject) {
43
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
44
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
45
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
46
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
47
+ });
48
+ };
49
+ var __generator = (this && this.__generator) || function (thisArg, body) {
50
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
51
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
52
+ function verb(n) { return function (v) { return step([n, v]); }; }
53
+ function step(op) {
54
+ if (f) throw new TypeError("Generator is already executing.");
55
+ while (_) try {
56
+ 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;
57
+ if (y = 0, t) op = [op[0] & 2, t.value];
58
+ switch (op[0]) {
59
+ case 0: case 1: t = op; break;
60
+ case 4: _.label++; return { value: op[1], done: false };
61
+ case 5: _.label++; y = op[1]; op = [0]; continue;
62
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
63
+ default:
64
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
65
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
66
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
67
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
68
+ if (t[2]) _.ops.pop();
69
+ _.trys.pop(); continue;
70
+ }
71
+ op = body.call(thisArg, _);
72
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
73
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
74
+ }
75
+ };
76
+ var __importDefault = (this && this.__importDefault) || function (mod) {
77
+ return (mod && mod.__esModule) ? mod : { "default": mod };
78
+ };
79
+ Object.defineProperty(exports, "__esModule", { value: true });
80
+ /**
81
+ * @name Sollet
82
+ * @author openocean
83
+ * @date 2021/4/21
84
+ * @desc
85
+ */
86
+ // @ts-ignore
87
+ var blocto_svg_1 = __importDefault(require("../assets/blocto.svg"));
88
+ var types_1 = require("../types");
89
+ var BaseWallet_1 = __importDefault(require("./BaseWallet"));
90
+ var fcl = __importStar(require("@onflow/fcl"));
91
+ var BloctoWallet = /** @class */ (function (_super) {
92
+ __extends(BloctoWallet, _super);
93
+ function BloctoWallet() {
94
+ var _this = _super !== null && _super.apply(this, arguments) || this;
95
+ _this.name = types_1.EnumWalletName.BloctoWallet;
96
+ _this.icon = blocto_svg_1.default;
97
+ _this.supportChains = [types_1.EnumChains.Flow];
98
+ _this.type = types_1.EnumWalletType.Extension;
99
+ _this.sdk = null;
100
+ return _this;
101
+ }
102
+ /**
103
+ * connect metamask and get wallet address
104
+ * @param chainId specific chainId,throw error when not match
105
+ */
106
+ BloctoWallet.prototype.requestFlowConnect = function (chainId) {
107
+ return __awaiter(this, void 0, void 0, function () {
108
+ var currentUser;
109
+ return __generator(this, function (_a) {
110
+ switch (_a.label) {
111
+ case 0:
112
+ fcl.config()
113
+ .put("challenge.scope", "email") // request for Email
114
+ .put("accessNode.api", "https://rest-mainnet.onflow.org") // Flow mainnet
115
+ .put("discovery.wallet", "https://flow-wallet.blocto.app/authn") // Blocto wallet
116
+ .put("service.OpenID.scopes", "email!");
117
+ this.sdk = fcl;
118
+ return [4 /*yield*/, fcl.currentUser.snapshot()];
119
+ case 1:
120
+ currentUser = _a.sent();
121
+ this.address = currentUser;
122
+ this.chainId = ''; // todo sollet chainId
123
+ return [2 /*return*/];
124
+ }
125
+ });
126
+ });
127
+ };
128
+ return BloctoWallet;
129
+ }(BaseWallet_1.default));
130
+ exports.default = BloctoWallet;
@@ -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();
@@ -1,12 +1,11 @@
1
- import { EnumWalletName, EnumWalletType } from "../types";
1
+ import { EnumChains, EnumWalletName, EnumWalletType } from "../types";
2
2
  import BaseWallet from "./BaseWallet";
3
- import Web3 from "web3";
4
3
  declare class GnosisSafeWallet extends BaseWallet {
5
4
  name: EnumWalletName;
6
5
  icon: any;
7
- supportChains: never[];
6
+ supportChains: EnumChains[];
8
7
  type: EnumWalletType;
9
- sdk: Web3 | null;
8
+ sdk: any;
10
9
  /**
11
10
  * connect metamask and get wallet address
12
11
  * @param chainId specific chainId,throw error when not match
@@ -73,9 +73,8 @@ var GnosisSafeWallet = /** @class */ (function (_super) {
73
73
  var _this = _super !== null && _super.apply(this, arguments) || this;
74
74
  _this.name = types_1.EnumWalletName.GnosisSafeWallet;
75
75
  _this.icon = metamask_svg_1.default;
76
- _this.supportChains = [];
76
+ _this.supportChains = [types_1.EnumChains.RINKEBY];
77
77
  _this.type = types_1.EnumWalletType.Extension;
78
- _this.sdk = null;
79
78
  return _this;
80
79
  }
81
80
  /**
@@ -97,7 +96,8 @@ var GnosisSafeWallet = /** @class */ (function (_super) {
97
96
  case 1:
98
97
  safe = _a.sent();
99
98
  provider = new safe_apps_provider_1.SafeAppProvider(safe, sdk);
100
- this.sdk = new web3_1.default(provider);
99
+ this.sdk = new web3_1.default(provider).currentProvider.sdk;
100
+ console.log('sdk', this.sdk);
101
101
  currentChainId = safe.chainId;
102
102
  if (chainId && currentChainId !== chainId) {
103
103
  throw new Error(types_1.EnumErrors.ChainIdNotMath);
@@ -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*/, near_api_js_1.connect(this.config)];
108
+ return [4 /*yield*/, (0, 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*/, near_api_js_1.connect(this.config)];
126
+ case 0: return [4 /*yield*/, (0, 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');
@@ -145,24 +145,23 @@ var WalletConnect = /** @class */ (function (_super) {
145
145
  return [4 /*yield*/, this.sdk.eth.getChainId()];
146
146
  case 2:
147
147
  currentChainId = _a.sent();
148
- if (!(chainId && currentChainId != chainId)) return [3 /*break*/, 6];
149
- if (!(!config || !config.isSecond)) return [3 /*break*/, 6];
150
- return [4 /*yield*/, provider.disconnect()];
151
- case 3:
152
- _a.sent();
153
- return [4 /*yield*/, new Promise(function (r) {
154
- setTimeout(r, 500);
155
- })];
156
- case 4:
157
- _a.sent();
158
- return [4 /*yield*/, this.requestConnect(chainId, __assign({ isSecond: true }, config))];
159
- case 5: return [2 /*return*/, _a.sent()];
160
- case 6:
148
+ // if (chainId && currentChainId != chainId) {
149
+ // if (!config || !config.isSecond) {
150
+ // await provider.disconnect()
151
+ // await new Promise(r => {
152
+ // setTimeout(r, 500);
153
+ // })
154
+ // return await this.requestConnect(chainId, {
155
+ // isSecond: true,
156
+ // ...config
157
+ // })
158
+ // }
159
+ // }
161
160
  if (chainId && currentChainId != chainId) {
162
161
  throw new Error(types_1.EnumErrors.ChainIdNotMath);
163
162
  }
164
163
  return [4 /*yield*/, this.sdk.eth.getAccounts()];
165
- case 7:
164
+ case 3:
166
165
  address = (_a.sent())[0];
167
166
  this.address = address;
168
167
  this.chainId = currentChainId;
package/lib/index.d.ts CHANGED
@@ -35,6 +35,7 @@ import CryptoCom from './Wallets/CryptoCom';
35
35
  import NearWallet from './Wallets/NearWallet';
36
36
  import BitKeepWallet from './Wallets/BitKeepWallet';
37
37
  import GnosisSafeWallet from './Wallets/GnosisSafeWallet';
38
+ import BloctoWallet from './Wallets/BloctoWallet';
38
39
  import { EnumChains } from "./types";
39
40
  export default WalletManager;
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 };
41
+ 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, BloctoWallet };
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.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;
6
+ exports.BloctoWallet = 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
@@ -72,6 +72,8 @@ var BitKeepWallet_1 = __importDefault(require("./Wallets/BitKeepWallet"));
72
72
  exports.BitKeepWallet = BitKeepWallet_1.default;
73
73
  var GnosisSafeWallet_1 = __importDefault(require("./Wallets/GnosisSafeWallet"));
74
74
  exports.GnosisSafeWallet = GnosisSafeWallet_1.default;
75
+ var BloctoWallet_1 = __importDefault(require("./Wallets/BloctoWallet"));
76
+ exports.BloctoWallet = BloctoWallet_1.default;
75
77
  var types_1 = require("./types");
76
78
  Object.defineProperty(exports, "EnumChains", { enumerable: true, get: function () { return types_1.EnumChains; } });
77
79
  var process = {};
package/lib/types.d.ts CHANGED
@@ -33,7 +33,8 @@ export declare enum EnumChains {
33
33
  Cronos = "cronos",
34
34
  Harmony = "harmony",
35
35
  Osmosis = "osmosis",
36
- Sifchain = "sifchain"
36
+ Sifchain = "sifchain",
37
+ Flow = "flow"
37
38
  }
38
39
  export declare enum EnumWalletType {
39
40
  Extension = "Extension",
@@ -72,7 +73,8 @@ export declare enum EnumWalletName {
72
73
  BraveWallet = "Brave Wallet",
73
74
  CryptoCom = "Crypto.com DeFi Wallet",
74
75
  BitKeepWallet = "BitKeep Wallet",
75
- GnosisSafeWallet = "GnosisSafe Wallet"
76
+ GnosisSafeWallet = "GnosisSafe Wallet",
77
+ BloctoWallet = "Blocto Wallet"
76
78
  }
77
79
  export declare enum EnumErrors {
78
80
  NotMetamask = "40001",
@@ -100,7 +102,8 @@ export declare enum EnumErrors {
100
102
  NoKeplr = "40024",
101
103
  NoBrave = "40025",
102
104
  NoCryptoCom = "40026",
103
- NoBitKeep = "40027"
105
+ NoBitKeep = "40027",
106
+ NoBlocto = "40028"
104
107
  }
105
108
  export interface ConnectResult {
106
109
  chain: EnumChains;
package/lib/types.js CHANGED
@@ -34,6 +34,7 @@ var EnumChains;
34
34
  EnumChains["Harmony"] = "harmony";
35
35
  EnumChains["Osmosis"] = "osmosis";
36
36
  EnumChains["Sifchain"] = "sifchain";
37
+ EnumChains["Flow"] = "flow";
37
38
  })(EnumChains = exports.EnumChains || (exports.EnumChains = {}));
38
39
  var EnumWalletType;
39
40
  (function (EnumWalletType) {
@@ -75,6 +76,7 @@ var EnumWalletName;
75
76
  EnumWalletName["CryptoCom"] = "Crypto.com DeFi Wallet";
76
77
  EnumWalletName["BitKeepWallet"] = "BitKeep Wallet";
77
78
  EnumWalletName["GnosisSafeWallet"] = "GnosisSafe Wallet";
79
+ EnumWalletName["BloctoWallet"] = "Blocto Wallet";
78
80
  })(EnumWalletName = exports.EnumWalletName || (exports.EnumWalletName = {}));
79
81
  var EnumErrors;
80
82
  (function (EnumErrors) {
@@ -104,4 +106,5 @@ var EnumErrors;
104
106
  EnumErrors["NoBrave"] = "40025";
105
107
  EnumErrors["NoCryptoCom"] = "40026";
106
108
  EnumErrors["NoBitKeep"] = "40027";
109
+ EnumErrors["NoBlocto"] = "40028";
107
110
  })(EnumErrors = exports.EnumErrors || (exports.EnumErrors = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openocean.finance/wallet",
3
- "version": "0.4.24",
3
+ "version": "0.4.27",
4
4
  "description": "A multi-chain wallets manager",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -44,6 +44,7 @@
44
44
  "@cosmjs/stargate": "^0.28.4",
45
45
  "@gnosis.pm/safe-apps-provider": "^0.11.3",
46
46
  "@gnosis.pm/safe-apps-sdk": "^7.5.0",
47
+ "@onflow/fcl": "^0.0.71",
47
48
  "@ont-dev/ontology-dapi": "^0.5.7",
48
49
  "@project-serum/sol-wallet-adapter": "0.2.0",
49
50
  "@solana/web3.js": "1.31.0",