@openocean.finance/wallet 1.6.5 → 1.6.7
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.
- package/lib/Wallets/ZerionWallet.d.ts +17 -0
- package/lib/Wallets/ZerionWallet.js +127 -0
- package/lib/Wallets/index.js +3 -1
- package/lib/assets/zerionWallet.png +0 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -0
- package/lib/types.d.ts +4 -2
- package/lib/types.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { EnumChains, EnumWalletName, EnumWalletType } from "../types";
|
|
2
|
+
import BaseWallet from "./BaseWallet";
|
|
3
|
+
import Web3 from "web3";
|
|
4
|
+
declare class ZerionWallet extends BaseWallet {
|
|
5
|
+
name: EnumWalletName;
|
|
6
|
+
icon: any;
|
|
7
|
+
supportChains: EnumChains[];
|
|
8
|
+
type: EnumWalletType;
|
|
9
|
+
sdk: Web3 | null;
|
|
10
|
+
installUrl: string;
|
|
11
|
+
/**
|
|
12
|
+
* connect metamask and get wallet address
|
|
13
|
+
* @param chainId specific chainId,throw error when not match
|
|
14
|
+
*/
|
|
15
|
+
requestConnect(chainId?: number): Promise<string>;
|
|
16
|
+
}
|
|
17
|
+
export default ZerionWallet;
|
|
@@ -0,0 +1,127 @@
|
|
|
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 (g && (g = 0, op[0] && (_ = 0)), _) 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 ZerionWallet
|
|
59
|
+
* @author openocean
|
|
60
|
+
* @date 2024/2/20
|
|
61
|
+
* @desc
|
|
62
|
+
*/
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
var zerionWallet_png_1 = __importDefault(require("../assets/zerionWallet.png"));
|
|
65
|
+
var types_1 = require("../types");
|
|
66
|
+
var BaseWallet_1 = __importDefault(require("./BaseWallet"));
|
|
67
|
+
var web3_1 = __importDefault(require("web3"));
|
|
68
|
+
var ZerionWallet = /** @class */ (function (_super) {
|
|
69
|
+
__extends(ZerionWallet, _super);
|
|
70
|
+
function ZerionWallet() {
|
|
71
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
72
|
+
_this.name = types_1.EnumWalletName.ZerionWallet;
|
|
73
|
+
_this.icon = zerionWallet_png_1.default;
|
|
74
|
+
_this.supportChains = [
|
|
75
|
+
types_1.EnumChains.ETH,
|
|
76
|
+
types_1.EnumChains.BSC,
|
|
77
|
+
types_1.EnumChains.Polygon,
|
|
78
|
+
types_1.EnumChains.XDai,
|
|
79
|
+
types_1.EnumChains.Fantom,
|
|
80
|
+
types_1.EnumChains.Avalanche,
|
|
81
|
+
types_1.EnumChains.Arbitrum,
|
|
82
|
+
types_1.EnumChains.Optimism,
|
|
83
|
+
types_1.EnumChains.Aurora,
|
|
84
|
+
types_1.EnumChains.Celo,
|
|
85
|
+
types_1.EnumChains.ZKSYNC,
|
|
86
|
+
types_1.EnumChains.Linea,
|
|
87
|
+
types_1.EnumChains.Scroll,
|
|
88
|
+
types_1.EnumChains.Base,
|
|
89
|
+
];
|
|
90
|
+
_this.type = types_1.EnumWalletType.Extension;
|
|
91
|
+
_this.sdk = null;
|
|
92
|
+
_this.installUrl = "https://chromewebstore.google.com/detail/zerion-wallet-for-web3-nf/klghhnkeealcohjjanjjdaeeggmfmlpl?hl=zh-CN&utm_source=ext_sidebar";
|
|
93
|
+
return _this;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* connect metamask and get wallet address
|
|
97
|
+
* @param chainId specific chainId,throw error when not match
|
|
98
|
+
*/
|
|
99
|
+
ZerionWallet.prototype.requestConnect = function (chainId) {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
+
var address, currentChainId;
|
|
102
|
+
return __generator(this, function (_a) {
|
|
103
|
+
switch (_a.label) {
|
|
104
|
+
case 0:
|
|
105
|
+
if (!(window.ethereum || !window.ethereum.isZerion)) {
|
|
106
|
+
throw new Error(types_1.EnumErrors.NotZerion);
|
|
107
|
+
}
|
|
108
|
+
this.sdk = new web3_1.default(window.ethereum);
|
|
109
|
+
return [4 /*yield*/, this.sdk.eth.requestAccounts()];
|
|
110
|
+
case 1:
|
|
111
|
+
address = (_a.sent())[0];
|
|
112
|
+
return [4 /*yield*/, this.sdk.eth.getChainId()];
|
|
113
|
+
case 2:
|
|
114
|
+
currentChainId = _a.sent();
|
|
115
|
+
if (chainId && currentChainId !== chainId) {
|
|
116
|
+
throw new Error(types_1.EnumErrors.ChainIdNotMath);
|
|
117
|
+
}
|
|
118
|
+
this.address = address;
|
|
119
|
+
this.chainId = currentChainId;
|
|
120
|
+
return [2 /*return*/, address];
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
return ZerionWallet;
|
|
126
|
+
}(BaseWallet_1.default));
|
|
127
|
+
exports.default = ZerionWallet;
|
package/lib/Wallets/index.js
CHANGED
|
@@ -52,6 +52,7 @@ var Risewallet_1 = __importDefault(require("./Risewallet"));
|
|
|
52
52
|
var Fewcha_1 = __importDefault(require("./Fewcha"));
|
|
53
53
|
var BlockWallet_1 = __importDefault(require("./BlockWallet"));
|
|
54
54
|
var HaHaWallet_1 = __importDefault(require("./HaHaWallet"));
|
|
55
|
+
var ZerionWallet_1 = __importDefault(require("./ZerionWallet"));
|
|
55
56
|
var WalletObj = {
|
|
56
57
|
MetaMask: new MetaMask_1.default(),
|
|
57
58
|
BscWallet: new BscWallet_1.default(),
|
|
@@ -99,7 +100,8 @@ var WalletObj = {
|
|
|
99
100
|
Risewallet: new Risewallet_1.default(),
|
|
100
101
|
Fewcha: new Fewcha_1.default(),
|
|
101
102
|
BlockWallet: new BlockWallet_1.default(),
|
|
102
|
-
HaHaWallet: new HaHaWallet_1.default()
|
|
103
|
+
HaHaWallet: new HaHaWallet_1.default(),
|
|
104
|
+
ZerionWallet: new ZerionWallet_1.default()
|
|
103
105
|
};
|
|
104
106
|
var Wallets = /** @class */ (function () {
|
|
105
107
|
function Wallets() {
|
|
Binary file
|
package/lib/index.d.ts
CHANGED
|
@@ -47,8 +47,9 @@ import PlenaWallet from './Wallets/PlenaWallet';
|
|
|
47
47
|
import Krystal from './Wallets/Krystal';
|
|
48
48
|
import Risewallet from './Wallets/Risewallet';
|
|
49
49
|
import Fewcha from './Wallets/Fewcha';
|
|
50
|
+
import ZerionWallet from './Wallets/ZerionWallet';
|
|
50
51
|
import { EnumChains, EnumWalletName } from "./types";
|
|
51
52
|
import { tryWalletConnect, ReqConnectWalletVo } from "./TryWalletConnect";
|
|
52
53
|
import { chainsObj, Chains, Chain } from "./Chains";
|
|
53
54
|
import { walletsObj, Wallets } from "./Wallets/index";
|
|
54
|
-
export { chainsObj, Chains, Chain, walletsObj, Wallets, ReqConnectWalletVo, tryWalletConnect, EnumChains, EnumWalletName, BaseWallet, MetaMask, BscWallet, Cyano, TronLink, Sollet, SolletIo, OntoMobile, WalletConnect, MathWallet, OntoWallet, SafePalWallet, ImTokenWallet, TokenPocket, TrustWallet, Coin98, Phantom, TerraStation, CoinbaseWallet, CloverWallet, XDEFIWallet, SolflareWallet, OKXWallet, KeplrWallet, BraveWallet, CryptoCom, NearWallet, BitgetWallet, GnosisSafeWallet, BloctoWallet, PetraWallet, MartianWallet, PontemWallet, UnstoppableDomains, MyNearWallet, MeteorWallet, SenderWallet, LedgerWallet, LedgerEmbedWallet, PlenaWallet, Krystal, Risewallet, Fewcha, };
|
|
55
|
+
export { chainsObj, Chains, Chain, walletsObj, Wallets, ReqConnectWalletVo, tryWalletConnect, EnumChains, EnumWalletName, BaseWallet, MetaMask, BscWallet, Cyano, TronLink, Sollet, SolletIo, OntoMobile, WalletConnect, MathWallet, OntoWallet, SafePalWallet, ImTokenWallet, TokenPocket, TrustWallet, Coin98, Phantom, TerraStation, CoinbaseWallet, CloverWallet, XDEFIWallet, SolflareWallet, OKXWallet, KeplrWallet, BraveWallet, CryptoCom, NearWallet, BitgetWallet, GnosisSafeWallet, BloctoWallet, PetraWallet, MartianWallet, PontemWallet, UnstoppableDomains, MyNearWallet, MeteorWallet, SenderWallet, LedgerWallet, LedgerEmbedWallet, PlenaWallet, Krystal, Risewallet, Fewcha, ZerionWallet, };
|
package/lib/index.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Fewcha = exports.Risewallet = exports.Krystal = exports.PlenaWallet = exports.LedgerEmbedWallet = exports.LedgerWallet = exports.SenderWallet = exports.MeteorWallet = exports.MyNearWallet = exports.UnstoppableDomains = exports.PontemWallet = exports.MartianWallet = exports.PetraWallet = exports.BloctoWallet = exports.GnosisSafeWallet = exports.BitgetWallet = exports.NearWallet = exports.CryptoCom = exports.BraveWallet = exports.KeplrWallet = exports.OKXWallet = exports.SolflareWallet = 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.TronLink = exports.Cyano = exports.BscWallet = exports.MetaMask = exports.BaseWallet = exports.EnumWalletName = exports.EnumChains = exports.tryWalletConnect = exports.Wallets = exports.walletsObj = exports.Chains = exports.chainsObj = void 0;
|
|
7
|
+
exports.ZerionWallet = void 0;
|
|
7
8
|
/**
|
|
8
9
|
* wallets-manager entry
|
|
9
10
|
* @author openocean
|
|
@@ -97,6 +98,8 @@ var Risewallet_1 = __importDefault(require("./Wallets/Risewallet"));
|
|
|
97
98
|
exports.Risewallet = Risewallet_1.default;
|
|
98
99
|
var Fewcha_1 = __importDefault(require("./Wallets/Fewcha"));
|
|
99
100
|
exports.Fewcha = Fewcha_1.default;
|
|
101
|
+
var ZerionWallet_1 = __importDefault(require("./Wallets/ZerionWallet"));
|
|
102
|
+
exports.ZerionWallet = ZerionWallet_1.default;
|
|
100
103
|
var types_1 = require("./types");
|
|
101
104
|
Object.defineProperty(exports, "EnumChains", { enumerable: true, get: function () { return types_1.EnumChains; } });
|
|
102
105
|
Object.defineProperty(exports, "EnumWalletName", { enumerable: true, get: function () { return types_1.EnumWalletName; } });
|
package/lib/types.d.ts
CHANGED
|
@@ -110,7 +110,8 @@ export declare enum EnumWalletName {
|
|
|
110
110
|
Risewallet = "Rise Wallet",
|
|
111
111
|
Fewcha = "Fewcha",
|
|
112
112
|
BlockWallet = "BlockWallet",
|
|
113
|
-
HaHaWallet = "HaHa Wallet"
|
|
113
|
+
HaHaWallet = "HaHa Wallet",
|
|
114
|
+
ZerionWallet = "ZerionWallet"
|
|
114
115
|
}
|
|
115
116
|
export declare enum EnumErrors {
|
|
116
117
|
NotMetamask = "40001",
|
|
@@ -156,7 +157,8 @@ export declare enum EnumErrors {
|
|
|
156
157
|
NoBraavos = "40043",
|
|
157
158
|
NoRisewallet = "40044",
|
|
158
159
|
NoFewcha = "40045",
|
|
159
|
-
NoBlockWallet = "40046"
|
|
160
|
+
NoBlockWallet = "40046",
|
|
161
|
+
NotZerion = "40047"
|
|
160
162
|
}
|
|
161
163
|
export interface ConnectResult {
|
|
162
164
|
chain: EnumChains;
|
package/lib/types.js
CHANGED
|
@@ -113,6 +113,7 @@ var EnumWalletName;
|
|
|
113
113
|
EnumWalletName["Fewcha"] = "Fewcha";
|
|
114
114
|
EnumWalletName["BlockWallet"] = "BlockWallet";
|
|
115
115
|
EnumWalletName["HaHaWallet"] = "HaHa Wallet";
|
|
116
|
+
EnumWalletName["ZerionWallet"] = "ZerionWallet";
|
|
116
117
|
})(EnumWalletName = exports.EnumWalletName || (exports.EnumWalletName = {}));
|
|
117
118
|
var EnumErrors;
|
|
118
119
|
(function (EnumErrors) {
|
|
@@ -160,4 +161,5 @@ var EnumErrors;
|
|
|
160
161
|
EnumErrors["NoRisewallet"] = "40044";
|
|
161
162
|
EnumErrors["NoFewcha"] = "40045";
|
|
162
163
|
EnumErrors["NoBlockWallet"] = "40046";
|
|
164
|
+
EnumErrors["NotZerion"] = "40047";
|
|
163
165
|
})(EnumErrors = exports.EnumErrors || (exports.EnumErrors = {}));
|