@openocean.finance/wallet 0.3.8 → 0.4.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.
- package/lib/.DS_Store +0 -0
- package/lib/Chains/BaseChain.js +8 -0
- package/lib/Chains/EthChain.js +41 -0
- package/lib/Chains/index.js +1 -0
- package/lib/WalletManager.js +117 -0
- package/lib/Wallets/BaseWallet.js +8 -0
- package/lib/Wallets/BraveWallet.js +129 -0
- package/lib/Wallets/BscWallet.js +112 -0
- package/lib/Wallets/CloverWallet.js +136 -0
- package/lib/Wallets/Coin98.js +139 -0
- package/lib/Wallets/CoinbaseWallet.js +111 -0
- package/lib/Wallets/CryptoCom.d.ts +16 -0
- package/lib/Wallets/CryptoCom.js +111 -0
- package/lib/Wallets/Cyano.js +108 -0
- package/lib/Wallets/ImTokenWallet.js +111 -0
- package/lib/Wallets/KeplrWallet.js +121 -0
- package/lib/Wallets/MathWallet.js +111 -0
- package/lib/Wallets/MetaMask.js +130 -0
- package/lib/Wallets/MetaXWallet.js +112 -0
- package/lib/Wallets/OKExWallet.js +112 -0
- package/lib/Wallets/OntoMobile.js +111 -0
- package/lib/Wallets/OntoWallet.js +112 -0
- package/lib/Wallets/Phantom.js +65 -0
- package/lib/Wallets/SafePalWallet.js +126 -0
- package/lib/Wallets/SlopeWallet.js +110 -0
- package/lib/Wallets/SolflareWallet.js +106 -0
- package/lib/Wallets/Sollet.js +67 -0
- package/lib/Wallets/SolletIo.js +64 -0
- package/lib/Wallets/TerraStation.js +64 -0
- package/lib/Wallets/TokenPocket.js +111 -0
- package/lib/Wallets/TronLink.js +101 -0
- package/lib/Wallets/TrustWallet.js +163 -0
- package/lib/Wallets/WalletConnect.js +163 -0
- package/lib/Wallets/{XDEFIWallet.d.ts → XDeFiWallet.d.ts} +0 -0
- package/lib/Wallets/XDeFiWallet.js +138 -0
- package/lib/assets/.DS_Store +0 -0
- package/lib/assets/approveErc20Abi.json +23 -0
- package/lib/assets/brave.svg +24 -0
- package/lib/assets/bscwallet.svg +23 -0
- package/lib/assets/clover.svg +11 -0
- package/lib/assets/coin98.svg +18 -0
- package/lib/assets/coinbase.svg +17 -0
- package/lib/assets/cryptoCom.svg +14 -0
- package/lib/assets/cyano.svg +7 -0
- package/lib/assets/erc20Abi.json +222 -0
- package/lib/assets/imtoken.svg +12 -0
- package/lib/assets/keplr.png +0 -0
- package/lib/assets/math.svg +1 -0
- package/lib/assets/metamask.svg +1 -0
- package/lib/assets/metax.svg +10 -0
- package/lib/assets/okex.svg +21 -0
- package/lib/assets/onto.svg +1 -0
- package/lib/assets/phantom.svg +22 -0
- package/lib/assets/safepal.svg +1 -0
- package/lib/assets/slope.svg +25 -0
- package/lib/assets/solflare.svg +23 -0
- package/lib/assets/sollet.svg +7 -0
- package/lib/assets/terra.svg +17 -0
- package/lib/assets/tokenpocket.svg +1 -0
- package/lib/assets/tronlink.svg +25 -0
- package/lib/assets/trust.svg +10 -0
- package/lib/assets/walletconnect.svg +1 -0
- package/lib/assets/xdefi.svg +15 -0
- package/lib/index.d.ts +3 -2
- package/lib/index.js +72 -2
- package/lib/types.d.ts +4 -2
- package/lib/types.js +101 -0
- package/package.json +28 -10
- package/README.md +0 -6
- package/lib/index.js.LICENSE.txt +0 -216
|
@@ -0,0 +1,139 @@
|
|
|
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 Coin98
|
|
59
|
+
* @author openocean
|
|
60
|
+
* @date 2021/4/21
|
|
61
|
+
* @desc
|
|
62
|
+
*/
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
var coin98_svg_1 = __importDefault(require("../assets/coin98.svg"));
|
|
65
|
+
var types_1 = require("../types");
|
|
66
|
+
var BaseWallet_1 = __importDefault(require("./BaseWallet"));
|
|
67
|
+
var web3_1 = __importDefault(require("web3"));
|
|
68
|
+
var Coin98 = /** @class */ (function (_super) {
|
|
69
|
+
__extends(Coin98, _super);
|
|
70
|
+
function Coin98() {
|
|
71
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
72
|
+
_this.name = types_1.EnumWalletName.Coin98;
|
|
73
|
+
_this.icon = coin98_svg_1.default;
|
|
74
|
+
_this.supportChains = [types_1.EnumChains.ETH, types_1.EnumChains.BSC, types_1.EnumChains.Polygon, types_1.EnumChains.HECO, types_1.EnumChains.XDai, types_1.EnumChains.Fantom, types_1.EnumChains.Avalanche, types_1.EnumChains.Arbitrum, types_1.EnumChains.OKEX, types_1.EnumChains.Aurora];
|
|
75
|
+
_this.type = types_1.EnumWalletType.Extension;
|
|
76
|
+
_this.sdk = null;
|
|
77
|
+
return _this;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* connect TrustWallet and get wallet address
|
|
81
|
+
* @param chainId specific chainId,throw error when not match
|
|
82
|
+
*/
|
|
83
|
+
Coin98.prototype.requestConnect = function (chainId) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
+
var address, currentChainId;
|
|
86
|
+
return __generator(this, function (_a) {
|
|
87
|
+
switch (_a.label) {
|
|
88
|
+
case 0:
|
|
89
|
+
if (!(window.ethereum.isCoin98 || window.coin98)) {
|
|
90
|
+
// go2 download page
|
|
91
|
+
throw new Error(types_1.EnumErrors.NoCoin98);
|
|
92
|
+
}
|
|
93
|
+
// this.sdk = new Web3(window.coin98.provider);
|
|
94
|
+
this.sdk = new web3_1.default(window.ethereum);
|
|
95
|
+
return [4 /*yield*/, this.sdk.eth.requestAccounts()];
|
|
96
|
+
case 1:
|
|
97
|
+
address = (_a.sent())[0];
|
|
98
|
+
return [4 /*yield*/, this.sdk.eth.getChainId()];
|
|
99
|
+
case 2:
|
|
100
|
+
currentChainId = _a.sent();
|
|
101
|
+
if (chainId && currentChainId !== chainId) {
|
|
102
|
+
throw new Error(types_1.EnumErrors.ChainIdNotMath);
|
|
103
|
+
}
|
|
104
|
+
this.address = address;
|
|
105
|
+
this.chainId = currentChainId;
|
|
106
|
+
return [2 /*return*/, address];
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* connect TrustWallet and get wallet address
|
|
113
|
+
* @param chainId specific chainId,throw error when not match
|
|
114
|
+
*/
|
|
115
|
+
Coin98.prototype.requestSolanaConnect = function () {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
117
|
+
var accounts, address;
|
|
118
|
+
return __generator(this, function (_a) {
|
|
119
|
+
switch (_a.label) {
|
|
120
|
+
case 0:
|
|
121
|
+
if (!(window.ethereum.isCoin98 || window.coin98 && window.coin98.sol)) {
|
|
122
|
+
// go2 download page
|
|
123
|
+
throw new Error(types_1.EnumErrors.NoCoin98);
|
|
124
|
+
}
|
|
125
|
+
this.sdk = window.coin98.sol;
|
|
126
|
+
return [4 /*yield*/, this.sdk.request({ method: 'sol_accounts' })];
|
|
127
|
+
case 1:
|
|
128
|
+
accounts = _a.sent();
|
|
129
|
+
address = accounts && accounts[0] || "";
|
|
130
|
+
this.address = address;
|
|
131
|
+
this.chainId = '';
|
|
132
|
+
return [2 /*return*/, address];
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
return Coin98;
|
|
138
|
+
}(BaseWallet_1.default));
|
|
139
|
+
exports.default = Coin98;
|
|
@@ -0,0 +1,111 @@
|
|
|
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 Coinbase
|
|
59
|
+
* @author openocean
|
|
60
|
+
* @date 2021/4/21
|
|
61
|
+
* @desc
|
|
62
|
+
*/
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
var coinbase_svg_1 = __importDefault(require("../assets/coinbase.svg"));
|
|
65
|
+
var types_1 = require("../types");
|
|
66
|
+
var BaseWallet_1 = __importDefault(require("./BaseWallet"));
|
|
67
|
+
var web3_1 = __importDefault(require("web3"));
|
|
68
|
+
var CoinbaseWallet = /** @class */ (function (_super) {
|
|
69
|
+
__extends(CoinbaseWallet, _super);
|
|
70
|
+
function CoinbaseWallet() {
|
|
71
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
72
|
+
_this.name = types_1.EnumWalletName.CoinbaseWallet;
|
|
73
|
+
_this.icon = coinbase_svg_1.default;
|
|
74
|
+
_this.supportChains = [types_1.EnumChains.ETH, types_1.EnumChains.BSC, types_1.EnumChains.Polygon, types_1.EnumChains.XDai, types_1.EnumChains.Fantom, types_1.EnumChains.Avalanche, types_1.EnumChains.Arbitrum, types_1.EnumChains.Optimism];
|
|
75
|
+
_this.type = types_1.EnumWalletType.Extension;
|
|
76
|
+
_this.sdk = null;
|
|
77
|
+
return _this;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* connect Coinbase and get wallet address
|
|
81
|
+
* @param chainId specific chainId,throw error when not match
|
|
82
|
+
*/
|
|
83
|
+
CoinbaseWallet.prototype.requestConnect = function (chainId) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
+
var address, currentChainId;
|
|
86
|
+
return __generator(this, function (_a) {
|
|
87
|
+
switch (_a.label) {
|
|
88
|
+
case 0:
|
|
89
|
+
if (!(window.ethereum && window.ethereum.isCoinbaseWallet)) {
|
|
90
|
+
throw new Error(types_1.EnumErrors.NoCoinbase);
|
|
91
|
+
}
|
|
92
|
+
this.sdk = new web3_1.default(window.ethereum);
|
|
93
|
+
return [4 /*yield*/, this.sdk.eth.requestAccounts()];
|
|
94
|
+
case 1:
|
|
95
|
+
address = (_a.sent())[0];
|
|
96
|
+
return [4 /*yield*/, this.sdk.eth.getChainId()];
|
|
97
|
+
case 2:
|
|
98
|
+
currentChainId = _a.sent();
|
|
99
|
+
if (chainId && currentChainId !== chainId) {
|
|
100
|
+
throw new Error(types_1.EnumErrors.ChainIdNotMath);
|
|
101
|
+
}
|
|
102
|
+
this.address = address;
|
|
103
|
+
this.chainId = currentChainId;
|
|
104
|
+
return [2 /*return*/, address];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
return CoinbaseWallet;
|
|
110
|
+
}(BaseWallet_1.default));
|
|
111
|
+
exports.default = CoinbaseWallet;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EnumChains, EnumWalletName, EnumWalletType } from "../types";
|
|
2
|
+
import BaseWallet from "./BaseWallet";
|
|
3
|
+
import Web3 from 'web3';
|
|
4
|
+
declare class CryptoCom extends BaseWallet {
|
|
5
|
+
name: EnumWalletName;
|
|
6
|
+
icon: any;
|
|
7
|
+
supportChains: EnumChains[];
|
|
8
|
+
type: EnumWalletType;
|
|
9
|
+
sdk: Web3 | null;
|
|
10
|
+
/**
|
|
11
|
+
* connect Coinbase and get wallet address
|
|
12
|
+
* @param chainId specific chainId,throw error when not match
|
|
13
|
+
*/
|
|
14
|
+
requestConnect(chainId?: number): Promise<string>;
|
|
15
|
+
}
|
|
16
|
+
export default CryptoCom;
|
|
@@ -0,0 +1,111 @@
|
|
|
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 Coinbase
|
|
59
|
+
* @author openocean
|
|
60
|
+
* @date 2021/4/21
|
|
61
|
+
* @desc
|
|
62
|
+
*/
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
var cryptoCom_svg_1 = __importDefault(require("../assets/cryptoCom.svg"));
|
|
65
|
+
var types_1 = require("../types");
|
|
66
|
+
var BaseWallet_1 = __importDefault(require("./BaseWallet"));
|
|
67
|
+
var web3_1 = __importDefault(require("web3"));
|
|
68
|
+
var CryptoCom = /** @class */ (function (_super) {
|
|
69
|
+
__extends(CryptoCom, _super);
|
|
70
|
+
function CryptoCom() {
|
|
71
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
72
|
+
_this.name = types_1.EnumWalletName.CryptoCom;
|
|
73
|
+
_this.icon = cryptoCom_svg_1.default;
|
|
74
|
+
_this.supportChains = [types_1.EnumChains.Cronos];
|
|
75
|
+
_this.type = types_1.EnumWalletType.Extension;
|
|
76
|
+
_this.sdk = null;
|
|
77
|
+
return _this;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* connect Coinbase and get wallet address
|
|
81
|
+
* @param chainId specific chainId,throw error when not match
|
|
82
|
+
*/
|
|
83
|
+
CryptoCom.prototype.requestConnect = function (chainId) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
+
var address, currentChainId;
|
|
86
|
+
return __generator(this, function (_a) {
|
|
87
|
+
switch (_a.label) {
|
|
88
|
+
case 0:
|
|
89
|
+
if (!window.deficonnectProvider) {
|
|
90
|
+
throw new Error(types_1.EnumErrors.NoCryptoCom);
|
|
91
|
+
}
|
|
92
|
+
this.sdk = new web3_1.default(window.deficonnectProvider);
|
|
93
|
+
return [4 /*yield*/, this.sdk.eth.requestAccounts()];
|
|
94
|
+
case 1:
|
|
95
|
+
address = (_a.sent())[0];
|
|
96
|
+
return [4 /*yield*/, this.sdk.eth.getChainId()];
|
|
97
|
+
case 2:
|
|
98
|
+
currentChainId = _a.sent();
|
|
99
|
+
if (chainId && currentChainId !== chainId) {
|
|
100
|
+
throw new Error(types_1.EnumErrors.ChainIdNotMath);
|
|
101
|
+
}
|
|
102
|
+
this.address = address;
|
|
103
|
+
this.chainId = currentChainId;
|
|
104
|
+
return [2 /*return*/, address];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
return CryptoCom;
|
|
110
|
+
}(BaseWallet_1.default));
|
|
111
|
+
exports.default = CryptoCom;
|
|
@@ -0,0 +1,108 @@
|
|
|
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 Cyano
|
|
59
|
+
* @author openocean
|
|
60
|
+
* @date 2021/4/21
|
|
61
|
+
* @desc
|
|
62
|
+
*/
|
|
63
|
+
var types_1 = require("../types");
|
|
64
|
+
var ontology_dapi_1 = require("@ont-dev/ontology-dapi");
|
|
65
|
+
var BaseWallet_1 = __importDefault(require("./BaseWallet"));
|
|
66
|
+
// @ts-ignore
|
|
67
|
+
var cyano_svg_1 = __importDefault(require("../assets/cyano.svg"));
|
|
68
|
+
var Cyano = /** @class */ (function (_super) {
|
|
69
|
+
__extends(Cyano, _super);
|
|
70
|
+
function Cyano() {
|
|
71
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
72
|
+
_this.name = types_1.EnumWalletName.Cyano;
|
|
73
|
+
_this.icon = cyano_svg_1.default;
|
|
74
|
+
_this.supportChains = [types_1.EnumChains.ONT];
|
|
75
|
+
_this.type = types_1.EnumWalletType.Extension;
|
|
76
|
+
_this.sdk = null;
|
|
77
|
+
return _this;
|
|
78
|
+
}
|
|
79
|
+
Cyano.prototype.requestConnect = function (chainId) {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
81
|
+
var network, account;
|
|
82
|
+
return __generator(this, function (_a) {
|
|
83
|
+
switch (_a.label) {
|
|
84
|
+
case 0:
|
|
85
|
+
ontology_dapi_1.client.registerClient({
|
|
86
|
+
logMessages: false,
|
|
87
|
+
logWarnings: false,
|
|
88
|
+
});
|
|
89
|
+
this.sdk = ontology_dapi_1.client; // not support return instance currently
|
|
90
|
+
return [4 /*yield*/, ontology_dapi_1.client.api.network.getNetwork()];
|
|
91
|
+
case 1:
|
|
92
|
+
network = _a.sent();
|
|
93
|
+
if (chainId && network.type !== chainId) {
|
|
94
|
+
throw new Error(types_1.EnumErrors.ChainIdNotMath);
|
|
95
|
+
}
|
|
96
|
+
return [4 /*yield*/, ontology_dapi_1.client.api.asset.getAccount()];
|
|
97
|
+
case 2:
|
|
98
|
+
account = _a.sent();
|
|
99
|
+
this.address = account;
|
|
100
|
+
this.chainId = network.type;
|
|
101
|
+
return [2 /*return*/, account];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
return Cyano;
|
|
107
|
+
}(BaseWallet_1.default));
|
|
108
|
+
exports.default = Cyano;
|
|
@@ -0,0 +1,111 @@
|
|
|
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 ImTokenWallet
|
|
59
|
+
* @author openocean
|
|
60
|
+
* @date 2021/4/21
|
|
61
|
+
* @desc
|
|
62
|
+
*/
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
var imtoken_svg_1 = __importDefault(require("../assets/imtoken.svg"));
|
|
65
|
+
var types_1 = require("../types");
|
|
66
|
+
var BaseWallet_1 = __importDefault(require("./BaseWallet"));
|
|
67
|
+
var web3_1 = __importDefault(require("web3"));
|
|
68
|
+
var ImTokenWallet = /** @class */ (function (_super) {
|
|
69
|
+
__extends(ImTokenWallet, _super);
|
|
70
|
+
function ImTokenWallet() {
|
|
71
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
72
|
+
_this.name = types_1.EnumWalletName.ImTokenWallet;
|
|
73
|
+
_this.icon = imtoken_svg_1.default;
|
|
74
|
+
_this.supportChains = [types_1.EnumChains.ETH, types_1.EnumChains.BSC, types_1.EnumChains.Polygon, types_1.EnumChains.OKEX, types_1.EnumChains.XDai, types_1.EnumChains.HECO, types_1.EnumChains.Fantom, types_1.EnumChains.Avalanche];
|
|
75
|
+
_this.type = types_1.EnumWalletType.Extension;
|
|
76
|
+
_this.sdk = null;
|
|
77
|
+
return _this;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* connect ImTokenWallet and get wallet address
|
|
81
|
+
* @param chainId specific chainId,throw error when not match
|
|
82
|
+
*/
|
|
83
|
+
ImTokenWallet.prototype.requestConnect = function (chainId) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
+
var address, currentChainId;
|
|
86
|
+
return __generator(this, function (_a) {
|
|
87
|
+
switch (_a.label) {
|
|
88
|
+
case 0:
|
|
89
|
+
if (!(window.ethereum && window.ethereum.isMetaMask)) {
|
|
90
|
+
throw new Error(types_1.EnumErrors.NotMetamask);
|
|
91
|
+
}
|
|
92
|
+
this.sdk = new web3_1.default(window.ethereum);
|
|
93
|
+
return [4 /*yield*/, this.sdk.eth.requestAccounts()];
|
|
94
|
+
case 1:
|
|
95
|
+
address = (_a.sent())[0];
|
|
96
|
+
return [4 /*yield*/, this.sdk.eth.getChainId()];
|
|
97
|
+
case 2:
|
|
98
|
+
currentChainId = _a.sent();
|
|
99
|
+
if (chainId && currentChainId !== chainId) {
|
|
100
|
+
throw new Error(types_1.EnumErrors.ChainIdNotMath);
|
|
101
|
+
}
|
|
102
|
+
this.address = address;
|
|
103
|
+
this.chainId = currentChainId;
|
|
104
|
+
return [2 /*return*/, address];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
return ImTokenWallet;
|
|
110
|
+
}(BaseWallet_1.default));
|
|
111
|
+
exports.default = ImTokenWallet;
|