@openocean.finance/wallet 0.4.47 → 0.4.49
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/MetaMask.js +2 -1
- package/lib/Wallets/NearWallet.d.ts +8 -4
- package/lib/Wallets/NearWallet.js +35 -30
- package/lib/Wallets/OntoWallet.js +1 -1
- package/lib/types.d.ts +1 -0
- package/lib/types.js +1 -0
- package/package.json +1 -1
package/lib/Wallets/MetaMask.js
CHANGED
|
@@ -89,7 +89,8 @@ var MetaMask = /** @class */ (function (_super) {
|
|
|
89
89
|
types_1.EnumChains.Moonriver,
|
|
90
90
|
types_1.EnumChains.Aurora,
|
|
91
91
|
types_1.EnumChains.Cronos,
|
|
92
|
-
types_1.EnumChains.Harmony
|
|
92
|
+
types_1.EnumChains.Harmony,
|
|
93
|
+
types_1.EnumChains.ONTEVM
|
|
93
94
|
];
|
|
94
95
|
_this.type = types_1.EnumWalletType.Extension;
|
|
95
96
|
_this.sdk = null;
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import { EnumChains, EnumWalletName, EnumWalletType } from "../types";
|
|
2
2
|
import BaseWallet from "./BaseWallet";
|
|
3
|
+
import { WalletConnection, utils } from "near-api-js";
|
|
4
|
+
import { createTransaction, functionCall } from 'near-api-js/lib/transaction';
|
|
3
5
|
declare class NearWallet extends BaseWallet {
|
|
4
6
|
name: EnumWalletName;
|
|
5
7
|
icon: any;
|
|
6
8
|
supportChains: EnumChains[];
|
|
7
9
|
type: EnumWalletType;
|
|
8
|
-
sdk:
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
sdk: WalletConnection | null;
|
|
11
|
+
createTransaction: typeof createTransaction;
|
|
12
|
+
functionCall: typeof functionCall;
|
|
13
|
+
PublicKey: typeof utils.key_pair.PublicKey;
|
|
14
|
+
utils: typeof utils;
|
|
11
15
|
init(): Promise<void>;
|
|
12
16
|
/**
|
|
13
17
|
* connect metamask and get wallet address
|
|
14
18
|
* @param chainId specific chainId,throw error when not match
|
|
15
19
|
*/
|
|
16
|
-
requestConnect(): Promise<
|
|
20
|
+
requestConnect(): Promise<string>;
|
|
17
21
|
constructor();
|
|
18
22
|
}
|
|
19
23
|
export default NearWallet;
|
|
@@ -65,6 +65,8 @@ var near_svg_1 = __importDefault(require("../assets/near.svg"));
|
|
|
65
65
|
var types_1 = require("../types");
|
|
66
66
|
var BaseWallet_1 = __importDefault(require("./BaseWallet"));
|
|
67
67
|
var near_api_js_1 = require("near-api-js");
|
|
68
|
+
var transaction_1 = require("near-api-js/lib/transaction");
|
|
69
|
+
var utils_1 = require("near-api-js/lib/utils");
|
|
68
70
|
var NearWallet = /** @class */ (function (_super) {
|
|
69
71
|
__extends(NearWallet, _super);
|
|
70
72
|
function NearWallet() {
|
|
@@ -76,23 +78,18 @@ var NearWallet = /** @class */ (function (_super) {
|
|
|
76
78
|
];
|
|
77
79
|
_this.type = types_1.EnumWalletType.Extension;
|
|
78
80
|
_this.sdk = null;
|
|
79
|
-
_this.
|
|
80
|
-
_this.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
nodeUrl: "https://public-rpc.blockpi.io/http/near",
|
|
84
|
-
walletUrl: "https://wallet.mainnet.near.org",
|
|
85
|
-
helperUrl: "https://helper.mainnet.near.org",
|
|
86
|
-
explorerUrl: "https://explorer.mainnet.near.org",
|
|
87
|
-
};
|
|
81
|
+
_this.createTransaction = transaction_1.createTransaction;
|
|
82
|
+
_this.functionCall = transaction_1.functionCall;
|
|
83
|
+
_this.PublicKey = utils_1.PublicKey;
|
|
84
|
+
_this.utils = near_api_js_1.utils;
|
|
88
85
|
_this.init();
|
|
89
86
|
return _this;
|
|
90
87
|
}
|
|
91
88
|
NearWallet.prototype.init = function () {
|
|
92
89
|
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
-
var account_id, query, vars, i, pair
|
|
94
|
-
return __generator(this, function (
|
|
95
|
-
switch (
|
|
90
|
+
var account_id, query, vars, i, pair;
|
|
91
|
+
return __generator(this, function (_a) {
|
|
92
|
+
switch (_a.label) {
|
|
96
93
|
case 0:
|
|
97
94
|
account_id = '';
|
|
98
95
|
query = window.location.search.substring(1);
|
|
@@ -104,11 +101,10 @@ var NearWallet = /** @class */ (function (_super) {
|
|
|
104
101
|
}
|
|
105
102
|
}
|
|
106
103
|
if (!account_id) return [3 /*break*/, 2];
|
|
107
|
-
|
|
108
|
-
return [4 /*yield*/, (0, near_api_js_1.connect)(this.config)];
|
|
104
|
+
return [4 /*yield*/, this.requestConnect()];
|
|
109
105
|
case 1:
|
|
110
|
-
|
|
111
|
-
|
|
106
|
+
_a.sent();
|
|
107
|
+
_a.label = 2;
|
|
112
108
|
case 2: return [2 /*return*/];
|
|
113
109
|
}
|
|
114
110
|
});
|
|
@@ -120,25 +116,34 @@ var NearWallet = /** @class */ (function (_super) {
|
|
|
120
116
|
*/
|
|
121
117
|
NearWallet.prototype.requestConnect = function () {
|
|
122
118
|
return __awaiter(this, void 0, void 0, function () {
|
|
123
|
-
var
|
|
119
|
+
var wallet, account;
|
|
124
120
|
return __generator(this, function (_a) {
|
|
125
121
|
switch (_a.label) {
|
|
126
|
-
case 0: return [4 /*yield*/, (0, near_api_js_1.connect)(
|
|
122
|
+
case 0: return [4 /*yield*/, (0, near_api_js_1.connect)({
|
|
123
|
+
networkId: "mainnet",
|
|
124
|
+
keyStore: new near_api_js_1.keyStores.BrowserLocalStorageKeyStore(),
|
|
125
|
+
nodeUrl: "https://rpc.mainnet.near.org",
|
|
126
|
+
walletUrl: "https://wallet.mainnet.near.org",
|
|
127
|
+
helperUrl: "https://helper.mainnet.near.org",
|
|
128
|
+
headers: {}
|
|
129
|
+
// explorerUrl: "https://explorer.mainnet.near.org",
|
|
130
|
+
})];
|
|
127
131
|
case 1:
|
|
128
|
-
|
|
129
|
-
this.sdk = new near_api_js_1.WalletConnection(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
wallet = _a.sent();
|
|
133
|
+
this.sdk = new near_api_js_1.WalletConnection(wallet, 'openOcen');
|
|
134
|
+
account = this.sdk.account();
|
|
135
|
+
if (!!account.accountId) return [3 /*break*/, 3];
|
|
136
|
+
return [4 /*yield*/, this.sdk.requestSignIn({
|
|
137
|
+
contractId: 'a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.factory.bridge.near',
|
|
133
138
|
methodNames: [], // optional
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
139
|
+
})];
|
|
140
|
+
case 2:
|
|
141
|
+
_a.sent();
|
|
142
|
+
_a.label = 3;
|
|
143
|
+
case 3:
|
|
138
144
|
account = this.sdk.account();
|
|
139
|
-
address = account.accountId;
|
|
140
|
-
this.address
|
|
141
|
-
return [2 /*return*/, address];
|
|
145
|
+
this.address = account.accountId;
|
|
146
|
+
return [2 /*return*/, this.address || ''];
|
|
142
147
|
}
|
|
143
148
|
});
|
|
144
149
|
});
|
|
@@ -71,7 +71,7 @@ var OntoWallet = /** @class */ (function (_super) {
|
|
|
71
71
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
72
72
|
_this.name = types_1.EnumWalletName.OntoWallet;
|
|
73
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];
|
|
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, types_1.EnumChains.ONTEVM];
|
|
75
75
|
_this.type = types_1.EnumWalletType.Extension;
|
|
76
76
|
_this.sdk = null;
|
|
77
77
|
_this.installUrl = "https://chrome.google.com/webstore/detail/onto-wallet/ifckdpamphokdglkkdomedpdegcjhjdp";
|
package/lib/types.d.ts
CHANGED
package/lib/types.js
CHANGED