@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,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 OntoMobile
|
|
59
|
+
* @author openocean
|
|
60
|
+
* @date 2021/4/21
|
|
61
|
+
* @desc
|
|
62
|
+
*/
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
var onto_svg_1 = __importDefault(require("../assets/onto.svg"));
|
|
65
|
+
var types_1 = require("../types");
|
|
66
|
+
var BaseWallet_1 = __importDefault(require("./BaseWallet"));
|
|
67
|
+
var web3_1 = __importDefault(require("web3"));
|
|
68
|
+
var OntoMobile = /** @class */ (function (_super) {
|
|
69
|
+
__extends(OntoMobile, _super);
|
|
70
|
+
function OntoMobile() {
|
|
71
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
72
|
+
_this.name = types_1.EnumWalletName.OntoMobile;
|
|
73
|
+
_this.icon = onto_svg_1.default;
|
|
74
|
+
_this.supportChains = [types_1.EnumChains.ONT];
|
|
75
|
+
_this.type = types_1.EnumWalletType.Mobile;
|
|
76
|
+
_this.sdk = null;
|
|
77
|
+
return _this;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* connect metamask and get wallet address
|
|
81
|
+
* @param chainId specific chainId,throw error when not match
|
|
82
|
+
*/
|
|
83
|
+
OntoMobile.prototype.requestConnect = function (chainId) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
+
var currentChainId, address;
|
|
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.getChainId()];
|
|
94
|
+
case 1:
|
|
95
|
+
currentChainId = _a.sent();
|
|
96
|
+
if (chainId && currentChainId !== chainId) {
|
|
97
|
+
throw new Error(types_1.EnumErrors.ChainIdNotMath);
|
|
98
|
+
}
|
|
99
|
+
return [4 /*yield*/, this.sdk.eth.requestAccounts()];
|
|
100
|
+
case 2:
|
|
101
|
+
address = (_a.sent())[0];
|
|
102
|
+
this.address = address;
|
|
103
|
+
this.chainId = currentChainId;
|
|
104
|
+
return [2 /*return*/, address];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
return OntoMobile;
|
|
110
|
+
}(BaseWallet_1.default));
|
|
111
|
+
exports.default = OntoMobile;
|
|
@@ -0,0 +1,112 @@
|
|
|
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 OntoWallet
|
|
59
|
+
* @author openocean
|
|
60
|
+
* @date 2022/3/1
|
|
61
|
+
* @desc
|
|
62
|
+
*/
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
var onto_svg_1 = __importDefault(require("../assets/onto.svg"));
|
|
65
|
+
var types_1 = require("../types");
|
|
66
|
+
var BaseWallet_1 = __importDefault(require("./BaseWallet"));
|
|
67
|
+
var web3_1 = __importDefault(require("web3"));
|
|
68
|
+
var OntoWallet = /** @class */ (function (_super) {
|
|
69
|
+
__extends(OntoWallet, _super);
|
|
70
|
+
function OntoWallet() {
|
|
71
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
72
|
+
_this.name = types_1.EnumWalletName.OntoWallet;
|
|
73
|
+
_this.icon = onto_svg_1.default;
|
|
74
|
+
_this.supportChains = [types_1.EnumChains.ETH, types_1.EnumChains.BSC, types_1.EnumChains.OKEX, types_1.EnumChains.Polygon, types_1.EnumChains.HECO, types_1.EnumChains.Arbitrum, types_1.EnumChains.Avalanche];
|
|
75
|
+
_this.type = types_1.EnumWalletType.Extension;
|
|
76
|
+
_this.sdk = null;
|
|
77
|
+
return _this;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* connect OntoWallet and get wallet address
|
|
81
|
+
* @param chainId specific chainId,throw error when not match
|
|
82
|
+
*/
|
|
83
|
+
OntoWallet.prototype.requestConnect = function (chainId) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
+
var address, _currentChainId, currentChainId;
|
|
86
|
+
return __generator(this, function (_a) {
|
|
87
|
+
switch (_a.label) {
|
|
88
|
+
case 0:
|
|
89
|
+
if (!(window.onto)) {
|
|
90
|
+
throw new Error(types_1.EnumErrors.NoOnto);
|
|
91
|
+
}
|
|
92
|
+
this.sdk = new web3_1.default(window.onto);
|
|
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
|
+
currentChainId = web3_1.default.utils.hexToNumber(_currentChainId);
|
|
100
|
+
if (chainId && currentChainId !== chainId) {
|
|
101
|
+
throw new Error(types_1.EnumErrors.OntoChainIdNotMath);
|
|
102
|
+
}
|
|
103
|
+
this.address = address;
|
|
104
|
+
this.chainId = currentChainId;
|
|
105
|
+
return [2 /*return*/, address];
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
return OntoWallet;
|
|
111
|
+
}(BaseWallet_1.default));
|
|
112
|
+
exports.default = OntoWallet;
|
|
@@ -0,0 +1,65 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
/**
|
|
22
|
+
* @name Sollet
|
|
23
|
+
* @author openocean
|
|
24
|
+
* @date 2021/4/21
|
|
25
|
+
* @desc
|
|
26
|
+
*/
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
var phantom_svg_1 = __importDefault(require("../assets/phantom.svg"));
|
|
29
|
+
var types_1 = require("../types");
|
|
30
|
+
var BaseWallet_1 = __importDefault(require("./BaseWallet"));
|
|
31
|
+
var Phantom = /** @class */ (function (_super) {
|
|
32
|
+
__extends(Phantom, _super);
|
|
33
|
+
function Phantom() {
|
|
34
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
35
|
+
_this.name = types_1.EnumWalletName.Phantom;
|
|
36
|
+
_this.icon = phantom_svg_1.default;
|
|
37
|
+
_this.supportChains = [types_1.EnumChains.Solana];
|
|
38
|
+
_this.type = types_1.EnumWalletType.Extension;
|
|
39
|
+
_this.sdk = null;
|
|
40
|
+
return _this;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* connect metamask and get wallet address
|
|
44
|
+
* @param chainId specific chainId,throw error when not match
|
|
45
|
+
*/
|
|
46
|
+
Phantom.prototype.requestSolanaConnect = function (chainId) {
|
|
47
|
+
var _this = this;
|
|
48
|
+
return new Promise(function (res) {
|
|
49
|
+
if (!((window.solana && window.solana.isPhantom) || (window.parent && window.parent.solana))) {
|
|
50
|
+
throw new Error(types_1.EnumErrors.NoPhantom);
|
|
51
|
+
}
|
|
52
|
+
var wallet = window.parent && window.parent.solana ? window.parent.solana : window.solana;
|
|
53
|
+
_this.sdk = wallet;
|
|
54
|
+
wallet.on('connect', function (publicKey) {
|
|
55
|
+
var address = wallet.publicKey.toString();
|
|
56
|
+
_this.address = address;
|
|
57
|
+
_this.chainId = ''; // todo sollet chainId
|
|
58
|
+
res(address);
|
|
59
|
+
});
|
|
60
|
+
wallet.connect();
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
return Phantom;
|
|
64
|
+
}(BaseWallet_1.default));
|
|
65
|
+
exports.default = Phantom;
|
|
@@ -0,0 +1,126 @@
|
|
|
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 SafePalWallet
|
|
59
|
+
* @author openocean
|
|
60
|
+
* @date 2021/4/21
|
|
61
|
+
* @desc
|
|
62
|
+
*/
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
var safepal_svg_1 = __importDefault(require("../assets/safepal.svg"));
|
|
65
|
+
var types_1 = require("../types");
|
|
66
|
+
var BaseWallet_1 = __importDefault(require("./BaseWallet"));
|
|
67
|
+
var web3_1 = __importDefault(require("web3"));
|
|
68
|
+
var SafePalWallet = /** @class */ (function (_super) {
|
|
69
|
+
__extends(SafePalWallet, _super);
|
|
70
|
+
function SafePalWallet() {
|
|
71
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
72
|
+
_this.name = types_1.EnumWalletName.SafePalWallet;
|
|
73
|
+
_this.icon = safepal_svg_1.default;
|
|
74
|
+
_this.supportChains = [
|
|
75
|
+
types_1.EnumChains.ETH,
|
|
76
|
+
types_1.EnumChains.BSC,
|
|
77
|
+
types_1.EnumChains.Polygon,
|
|
78
|
+
types_1.EnumChains.OKEX,
|
|
79
|
+
types_1.EnumChains.XDai,
|
|
80
|
+
types_1.EnumChains.HECO,
|
|
81
|
+
types_1.EnumChains.Fantom,
|
|
82
|
+
types_1.EnumChains.Avalanche,
|
|
83
|
+
types_1.EnumChains.Arbitrum,
|
|
84
|
+
types_1.EnumChains.Optimism,
|
|
85
|
+
types_1.EnumChains.Boba,
|
|
86
|
+
types_1.EnumChains.Moonriver,
|
|
87
|
+
types_1.EnumChains.Cronos,
|
|
88
|
+
types_1.EnumChains.Harmony
|
|
89
|
+
];
|
|
90
|
+
_this.type = types_1.EnumWalletType.Extension;
|
|
91
|
+
_this.sdk = null;
|
|
92
|
+
return _this;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* connect SafePalWallet and get wallet address
|
|
96
|
+
* @param chainId specific chainId,throw error when not match
|
|
97
|
+
*/
|
|
98
|
+
SafePalWallet.prototype.requestConnect = function (chainId) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
100
|
+
var address, currentChainId;
|
|
101
|
+
return __generator(this, function (_a) {
|
|
102
|
+
switch (_a.label) {
|
|
103
|
+
case 0:
|
|
104
|
+
if (!(window.ethereum && window.ethereum.isMetaMask)) {
|
|
105
|
+
throw new Error(types_1.EnumErrors.NotMetamask);
|
|
106
|
+
}
|
|
107
|
+
this.sdk = new web3_1.default(window.ethereum);
|
|
108
|
+
return [4 /*yield*/, this.sdk.eth.requestAccounts()];
|
|
109
|
+
case 1:
|
|
110
|
+
address = (_a.sent())[0];
|
|
111
|
+
return [4 /*yield*/, this.sdk.eth.getChainId()];
|
|
112
|
+
case 2:
|
|
113
|
+
currentChainId = _a.sent();
|
|
114
|
+
if (chainId && currentChainId !== chainId) {
|
|
115
|
+
throw new Error(types_1.EnumErrors.ChainIdNotMath);
|
|
116
|
+
}
|
|
117
|
+
this.address = address;
|
|
118
|
+
this.chainId = currentChainId;
|
|
119
|
+
return [2 /*return*/, address];
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
return SafePalWallet;
|
|
125
|
+
}(BaseWallet_1.default));
|
|
126
|
+
exports.default = SafePalWallet;
|
|
@@ -0,0 +1,110 @@
|
|
|
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 Slope
|
|
59
|
+
* @author openocean
|
|
60
|
+
* @date 2021/4/21
|
|
61
|
+
* @desc
|
|
62
|
+
*/
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
var slope_svg_1 = __importDefault(require("../assets/slope.svg"));
|
|
65
|
+
var types_1 = require("../types");
|
|
66
|
+
var BaseWallet_1 = __importDefault(require("./BaseWallet"));
|
|
67
|
+
var SlopeWallet = /** @class */ (function (_super) {
|
|
68
|
+
__extends(SlopeWallet, _super);
|
|
69
|
+
function SlopeWallet() {
|
|
70
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
71
|
+
_this.name = types_1.EnumWalletName.SlopeWallet;
|
|
72
|
+
_this.icon = slope_svg_1.default;
|
|
73
|
+
_this.supportChains = [types_1.EnumChains.Solana];
|
|
74
|
+
_this.type = types_1.EnumWalletType.Extension;
|
|
75
|
+
_this.sdk = null;
|
|
76
|
+
return _this;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* connect metamask and get wallet address
|
|
80
|
+
* @param chainId specific chainId,throw error when not match
|
|
81
|
+
*/
|
|
82
|
+
SlopeWallet.prototype.requestSolanaConnect = function (chainId) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
84
|
+
var wallet, _a, msg, data, address;
|
|
85
|
+
return __generator(this, function (_b) {
|
|
86
|
+
switch (_b.label) {
|
|
87
|
+
case 0:
|
|
88
|
+
if (!window.Slope) {
|
|
89
|
+
throw new Error(types_1.EnumErrors.NoSlope);
|
|
90
|
+
}
|
|
91
|
+
wallet = new window.Slope();
|
|
92
|
+
wallet.isSlopeWallet = true;
|
|
93
|
+
this.sdk = wallet;
|
|
94
|
+
return [4 /*yield*/, wallet.connect()];
|
|
95
|
+
case 1:
|
|
96
|
+
_a = _b.sent(), msg = _a.msg, data = _a.data;
|
|
97
|
+
address = '';
|
|
98
|
+
if (msg === 'ok') {
|
|
99
|
+
address = data.publicKey;
|
|
100
|
+
}
|
|
101
|
+
this.address = address;
|
|
102
|
+
this.chainId = '';
|
|
103
|
+
return [2 /*return*/, address];
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
return SlopeWallet;
|
|
109
|
+
}(BaseWallet_1.default));
|
|
110
|
+
exports.default = SlopeWallet;
|
|
@@ -0,0 +1,106 @@
|
|
|
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 Solflare
|
|
59
|
+
* @author openocean
|
|
60
|
+
* @date 2021/4/21
|
|
61
|
+
* @desc
|
|
62
|
+
*/
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
var solflare_svg_1 = __importDefault(require("../assets/solflare.svg"));
|
|
65
|
+
var types_1 = require("../types");
|
|
66
|
+
var BaseWallet_1 = __importDefault(require("./BaseWallet"));
|
|
67
|
+
var SolflareWallet = /** @class */ (function (_super) {
|
|
68
|
+
__extends(SolflareWallet, _super);
|
|
69
|
+
function SolflareWallet() {
|
|
70
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
71
|
+
_this.name = types_1.EnumWalletName.SolflareWallet;
|
|
72
|
+
_this.icon = solflare_svg_1.default;
|
|
73
|
+
_this.supportChains = [types_1.EnumChains.Solana];
|
|
74
|
+
_this.type = types_1.EnumWalletType.Extension;
|
|
75
|
+
_this.sdk = null;
|
|
76
|
+
return _this;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* connect metamask and get wallet address
|
|
80
|
+
* @param chainId specific chainId,throw error when not match
|
|
81
|
+
*/
|
|
82
|
+
SolflareWallet.prototype.requestSolanaConnect = function (chainId) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
84
|
+
var _this = this;
|
|
85
|
+
return __generator(this, function (_a) {
|
|
86
|
+
return [2 /*return*/, new Promise(function (res) {
|
|
87
|
+
// if (!(window.solflare && window.solflare.isSolflare)) {
|
|
88
|
+
// throw new Error(EnumErrors.NoPhantom);
|
|
89
|
+
// }
|
|
90
|
+
var wallet = window.parent && window.parent.solflare ? window.parent.solflare : window.solflare;
|
|
91
|
+
// const wallet = window.solflare;
|
|
92
|
+
_this.sdk = wallet;
|
|
93
|
+
wallet.on('connect', function (publicKey) {
|
|
94
|
+
var address = wallet.publicKey.toString();
|
|
95
|
+
_this.address = address;
|
|
96
|
+
_this.chainId = ''; // todo sollet chainId
|
|
97
|
+
res(address);
|
|
98
|
+
});
|
|
99
|
+
wallet.connect();
|
|
100
|
+
})];
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
return SolflareWallet;
|
|
105
|
+
}(BaseWallet_1.default));
|
|
106
|
+
exports.default = SolflareWallet;
|