@openocean.finance/wallet 0.4.61 → 0.4.63
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.
|
@@ -97,11 +97,12 @@ var MeteorWallet = /** @class */ (function (_super) {
|
|
|
97
97
|
meteorWallet = (0, meteor_wallet_1.setupMeteorWallet)();
|
|
98
98
|
return [4 /*yield*/, (0, core_1.setupWalletSelector)({
|
|
99
99
|
network: "mainnet",
|
|
100
|
+
debug: true,
|
|
100
101
|
modules: [meteorWallet],
|
|
101
102
|
})];
|
|
102
103
|
case 1:
|
|
103
104
|
selector = _a.sent();
|
|
104
|
-
return [4 /*yield*/, selector.wallet()];
|
|
105
|
+
return [4 /*yield*/, selector.wallet('meteor-wallet')];
|
|
105
106
|
case 2:
|
|
106
107
|
wallet = _a.sent();
|
|
107
108
|
return [4 /*yield*/, wallet.signIn({
|
|
@@ -111,7 +112,7 @@ var MeteorWallet = /** @class */ (function (_super) {
|
|
|
111
112
|
case 3:
|
|
112
113
|
accounts = _a.sent();
|
|
113
114
|
this.sdk = wallet;
|
|
114
|
-
this.address = accounts;
|
|
115
|
+
this.address = accounts && accounts[0] && accounts[0].accountId || "";
|
|
115
116
|
return [2 /*return*/, this.address || ""];
|
|
116
117
|
}
|
|
117
118
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EnumChains, EnumWalletName, EnumWalletType } from "../types";
|
|
2
2
|
import BaseWallet from "./BaseWallet";
|
|
3
3
|
import { WalletConnection, utils } from "near-api-js";
|
|
4
|
-
import { createTransaction, functionCall } from
|
|
4
|
+
import { createTransaction, functionCall } from "near-api-js/lib/transaction";
|
|
5
5
|
declare class NearWallet extends BaseWallet {
|
|
6
6
|
name: EnumWalletName;
|
|
7
7
|
icon: any;
|
|
@@ -12,12 +12,10 @@ declare class NearWallet extends BaseWallet {
|
|
|
12
12
|
functionCall: typeof functionCall;
|
|
13
13
|
PublicKey: typeof utils.key_pair.PublicKey;
|
|
14
14
|
utils: typeof utils;
|
|
15
|
-
init(): Promise<void>;
|
|
16
15
|
/**
|
|
17
16
|
* connect metamask and get wallet address
|
|
18
17
|
* @param chainId specific chainId,throw error when not match
|
|
19
18
|
*/
|
|
20
19
|
requestConnect(): Promise<string>;
|
|
21
|
-
constructor();
|
|
22
20
|
}
|
|
23
21
|
export default NearWallet;
|
|
@@ -67,91 +67,53 @@ var BaseWallet_1 = __importDefault(require("./BaseWallet"));
|
|
|
67
67
|
var near_api_js_1 = require("near-api-js");
|
|
68
68
|
var transaction_1 = require("near-api-js/lib/transaction");
|
|
69
69
|
var utils_1 = require("near-api-js/lib/utils");
|
|
70
|
-
var
|
|
70
|
+
var core_1 = require("@near-wallet-selector/core");
|
|
71
|
+
var near_wallet_1 = require("@near-wallet-selector/near-wallet");
|
|
71
72
|
var NearWallet = /** @class */ (function (_super) {
|
|
72
73
|
__extends(NearWallet, _super);
|
|
73
74
|
function NearWallet() {
|
|
74
|
-
var _this = _super.
|
|
75
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
75
76
|
_this.name = types_1.EnumWalletName.NearWallet;
|
|
76
77
|
_this.icon = near_svg_1.default;
|
|
77
|
-
_this.supportChains = [
|
|
78
|
-
types_1.EnumChains.NEAR
|
|
79
|
-
];
|
|
78
|
+
_this.supportChains = [types_1.EnumChains.NEAR];
|
|
80
79
|
_this.type = types_1.EnumWalletType.Extension;
|
|
81
80
|
_this.sdk = null;
|
|
82
81
|
_this.createTransaction = transaction_1.createTransaction;
|
|
83
82
|
_this.functionCall = transaction_1.functionCall;
|
|
84
83
|
_this.PublicKey = utils_1.PublicKey;
|
|
85
84
|
_this.utils = near_api_js_1.utils;
|
|
86
|
-
_this.init();
|
|
87
85
|
return _this;
|
|
88
86
|
}
|
|
89
|
-
NearWallet.prototype.init = function () {
|
|
90
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
91
|
-
var account_id, query, vars, i, pair;
|
|
92
|
-
return __generator(this, function (_a) {
|
|
93
|
-
switch (_a.label) {
|
|
94
|
-
case 0:
|
|
95
|
-
if (window.localStorage.getItem('connectwallet') !== this.name) {
|
|
96
|
-
return [2 /*return*/];
|
|
97
|
-
}
|
|
98
|
-
account_id = '';
|
|
99
|
-
query = window.location.search.substring(1);
|
|
100
|
-
vars = query.split("&");
|
|
101
|
-
for (i = 0; i < vars.length; i++) {
|
|
102
|
-
pair = vars[i].split("=");
|
|
103
|
-
if (pair[0] == 'account_id') {
|
|
104
|
-
account_id = pair[1];
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
if (!account_id) return [3 /*break*/, 2];
|
|
108
|
-
return [4 /*yield*/, this.requestConnect()];
|
|
109
|
-
case 1:
|
|
110
|
-
_a.sent();
|
|
111
|
-
_a.label = 2;
|
|
112
|
-
case 2: return [2 /*return*/];
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
};
|
|
117
87
|
/**
|
|
118
88
|
* connect metamask and get wallet address
|
|
119
89
|
* @param chainId specific chainId,throw error when not match
|
|
120
90
|
*/
|
|
121
91
|
NearWallet.prototype.requestConnect = function () {
|
|
122
92
|
return __awaiter(this, void 0, void 0, function () {
|
|
123
|
-
var wallet,
|
|
93
|
+
var nearWallet, selector, wallet, accounts;
|
|
124
94
|
return __generator(this, function (_a) {
|
|
125
95
|
switch (_a.label) {
|
|
126
|
-
case 0:
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
keyStore: new near_api_js_1.keyStores.BrowserLocalStorageKeyStore(),
|
|
133
|
-
nodeUrl: "https://rpc.mainnet.near.org",
|
|
134
|
-
walletUrl: "https://wallet.mainnet.near.org",
|
|
135
|
-
helperUrl: "https://helper.mainnet.near.org",
|
|
136
|
-
headers: {}
|
|
137
|
-
// explorerUrl: "https://explorer.mainnet.near.org",
|
|
96
|
+
case 0:
|
|
97
|
+
nearWallet = (0, near_wallet_1.setupNearWallet)();
|
|
98
|
+
return [4 /*yield*/, (0, core_1.setupWalletSelector)({
|
|
99
|
+
network: "mainnet",
|
|
100
|
+
debug: true,
|
|
101
|
+
modules: [nearWallet],
|
|
138
102
|
})];
|
|
103
|
+
case 1:
|
|
104
|
+
selector = _a.sent();
|
|
105
|
+
return [4 /*yield*/, selector.wallet("near-wallet")];
|
|
139
106
|
case 2:
|
|
140
107
|
wallet = _a.sent();
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return [4 /*yield*/, this.sdk.requestSignIn({
|
|
145
|
-
contractId: 'a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.factory.bridge.near',
|
|
146
|
-
methodNames: [], // optional
|
|
108
|
+
return [4 /*yield*/, wallet.signIn({
|
|
109
|
+
contractId: "a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.factory.bridge.near",
|
|
110
|
+
accounts: []
|
|
147
111
|
})];
|
|
148
112
|
case 3:
|
|
149
|
-
_a.sent();
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
this.address = account.accountId;
|
|
154
|
-
return [2 /*return*/, this.address || ''];
|
|
113
|
+
accounts = _a.sent();
|
|
114
|
+
this.sdk = wallet;
|
|
115
|
+
this.address = accounts && accounts[0] && accounts[0].accountId || "";
|
|
116
|
+
return [2 /*return*/, this.address || ""];
|
|
155
117
|
}
|
|
156
118
|
});
|
|
157
119
|
});
|
|
@@ -97,11 +97,12 @@ var SenderWallet = /** @class */ (function (_super) {
|
|
|
97
97
|
sender = (0, sender_1.setupSender)();
|
|
98
98
|
return [4 /*yield*/, (0, core_1.setupWalletSelector)({
|
|
99
99
|
network: "mainnet",
|
|
100
|
+
debug: true,
|
|
100
101
|
modules: [sender],
|
|
101
102
|
})];
|
|
102
103
|
case 1:
|
|
103
104
|
selector = _a.sent();
|
|
104
|
-
return [4 /*yield*/, selector.wallet()];
|
|
105
|
+
return [4 /*yield*/, selector.wallet("sender")];
|
|
105
106
|
case 2:
|
|
106
107
|
wallet = _a.sent();
|
|
107
108
|
return [4 /*yield*/, wallet.signIn({
|
|
@@ -111,7 +112,7 @@ var SenderWallet = /** @class */ (function (_super) {
|
|
|
111
112
|
case 3:
|
|
112
113
|
accounts = _a.sent();
|
|
113
114
|
this.sdk = wallet;
|
|
114
|
-
this.address = accounts;
|
|
115
|
+
this.address = accounts && accounts[0] && accounts[0].accountId || "";
|
|
115
116
|
return [2 /*return*/, this.address || ""];
|
|
116
117
|
}
|
|
117
118
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openocean.finance/wallet",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.63",
|
|
4
4
|
"description": "A multi-chain wallets manager",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -46,6 +46,8 @@
|
|
|
46
46
|
"@gnosis.pm/safe-apps-sdk": "^7.5.0",
|
|
47
47
|
"@near-wallet-selector/core": "^7.8.2",
|
|
48
48
|
"@near-wallet-selector/meteor-wallet": "^7.8.2",
|
|
49
|
+
"@near-wallet-selector/my-near-wallet": "^7.8.2",
|
|
50
|
+
"@near-wallet-selector/near-wallet": "^7.8.2",
|
|
49
51
|
"@near-wallet-selector/sender": "^7.8.2",
|
|
50
52
|
"@onflow/fcl": "^0.0.71",
|
|
51
53
|
"@ont-dev/ontology-dapi": "^0.5.7",
|